forked from fossar/selfoss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.php
30 lines (26 loc) · 967 Bytes
/
run.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// Only run this if running from php 5.4 embedded server
if (PHP_SAPI === 'cli-server') {
if (preg_match('/\.(?:js|ico|gif|jpg|png|css|asc|txt|svg)(?:\?.*)?$/', $_SERVER['REQUEST_URI'])) {
// serves fronted
if (preg_match('/^\/public/', $_SERVER['REQUEST_URI'])) {
return false;
}
// serves favicons
if (preg_match('/^\/data/', $_SERVER['REQUEST_URI'])) {
return false;
}
//redirects to proper location for favicons
if (preg_match('/(favicons|thumbnails)/', $_SERVER['REQUEST_URI'])) {
header('Location: /data' . $_SERVER['REQUEST_URI']);
exit;
}
//redirects to proper location for frontend
header('Location: /public' . $_SERVER['REQUEST_URI']);
exit;
} else {
// taken from cli arg, hack for updater
$_SERVER['SERVER_ADDR'] = $_SERVER['SERVER_NAME'];
require 'index.php';
}
}