forked from edusoho/edusoho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.php
75 lines (64 loc) · 2.05 KB
/
app.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
if (!file_exists(__DIR__.'/../app/data/install.lock')) {
header('Location: install/install.php');
exit();
}
if ((0 !== strpos($_SERVER['REQUEST_URI'], '/admin')) && file_exists(__DIR__.'/../app/data/upgrade.lock')) {
$time = file_get_contents(__DIR__.'/../app/data/upgrade.lock');
date_default_timezone_set('Asia/Shanghai');
$currentTime = time();
if ($currentTime <= (int) $time) {
header('Content-Type: text/html; charset=utf-8');
echo file_get_contents(__DIR__.'/../app/Resources/TwigBundle/views/Exception/upgrade-info.html');
exit();
}
}
if (isOldApiCall()) {
define('API_ENV', 'prod');
include __DIR__.'/../api/index.php';
exit();
}
use Symfony\Component\HttpFoundation\Request;
fix_gpc_magic();
$loader = require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/bootstrap.php.cache';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$kernel->setRequest($request);
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
function fix_gpc_magic()
{
if (get_magic_quotes_gpc()) {
array_walk($_GET, '_fix_gpc_magic');
array_walk($_POST, '_fix_gpc_magic');
array_walk($_COOKIE, '_fix_gpc_magic');
array_walk($_REQUEST, '_fix_gpc_magic');
array_walk($_FILES, '_fix_gpc_magic_files');
}
}
function _fix_gpc_magic(&$item)
{
if (is_array($item)) {
array_walk($item, '_fix_gpc_magic');
} else {
$item = stripslashes($item);
}
}
function _fix_gpc_magic_files(&$item, $key)
{
if ('tmp_name' != $key) {
if (is_array($item)) {
array_walk($item, '_fix_gpc_magic_files');
} else {
$item = stripslashes($item);
}
}
}
function isOldApiCall()
{
return (!(isset($_SERVER['HTTP_ACCEPT']) && 'application/vnd.edusoho.v2+json' == $_SERVER['HTTP_ACCEPT']))
&& ((0 === strpos($_SERVER['REQUEST_URI'], '/api')) || (0 === strpos($_SERVER['REQUEST_URI'], '/app.php/api')));
}