-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
62 lines (52 loc) · 1.75 KB
/
index.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
<?php
header('Content-Type: text/html; charset=utf-8');
session_start();
// Include the main Propel script
require_once 'propel/runtime/lib/Propel.php';
// Initialize Propel with the runtime configuration
Propel::init("seabattle/build/conf/seabattle-conf.php");
// Add the generated 'classes' directory to the include path
set_include_path("seabattle/build/classes" . PATH_SEPARATOR . get_include_path());
require_once 'lib/plainPhpView.php';
require_once 'lib/form.php';
require_once 'lib/routeUtils.php';
require_once 'lib/httpUtils.php';
require_once 'lib/gameException.php';
require_once 'config/mainConfig-home.php';
require_once 'app.php';
//var_dump( $_POST );
// die( 'qweqwe');
// Если передаем в ajax-запросе, то ставим обработчики ошибок и возвращаем валидный JSON
$isAjax = HttpUtils::getPost('isAjax', false);
if( $isAjax == true )
{
// Включаем буферизацию вывода
ob_start();
function handleException( $exception )
{
restore_exception_handler();
$res = array(
'error' => $exception->getMessage(),
);
// Очищаем буфер обмена
ob_end_clean();
echo json_encode($res);
exit(); // Выходим, иначе будет не валидный JSON в ответе
}
function handleError( $code, $message, $file, $line )
{
restore_error_handler();
ob_clean();
trigger_error( $message );
$res = array(
'error' => ob_get_clean(),
);
echo json_encode($res);
exit(); // Выходим, иначе будет не валидный JSON в ответе
}
set_exception_handler( 'handleException' );
set_error_handler( 'handleError', error_reporting() );
}
$app = App::instance();
$app->addScript( "jquery-1.7.2.min.js" );
$app->run();