forked from ninnzz/kumusta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·85 lines (71 loc) · 1.78 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/* == DEFINES APPLICATION ENVIRONMENT ==
*
* Can create custom value but default values are set
*
* development
* production
*
*/
$start;
define('ENVIRONMENT', 'development');
/* == ERROR REPORTING ==
*
* Shows erros depending on the environment
* All error is shown in the development environment
*
*/
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;
case 'production':
error_reporting(0);
break;
default:
header('Content-Type: application/json');
header("HTTP/1.0 500 Internal Server Error");
print_r(json_encode(array("message"=>"Invalid environemnt setup")));
exit();
}
}
/* == DIRECTORY HANDLERS ==
*
* system path resolution
*
*/
$core_path = "core";
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
if (realpath($core_path) !== FALSE)
{
$core_path = realpath($core_path).'/';
}
$core_path = rtrim($core_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($core_path))
{
header('Content-Type: application/json');
header("HTTP/1.0 500 Internal Server Error");
print_r(json_encode(array("message"=>"Invalid core path")));
}
try{
$start = microtime(true);
require_once("core/KielRSLCore.php");
} catch(Exception $e){
header('Content-Type: application/json');
header('HTTP/1.1: ' . 500);
header('Status: ' . 500);
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: OPTIONS, DELETE, PUT');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
$end = round((microtime(true) - $start),5);
print_r(json_encode(array("error"=>$e->getMessage(),"ellapsed time"=>$end,"object"=>$object_name,"method"=>$method_name)));
exit();
}
?>