1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12:
13:
14:
15: $autoload = __DIR__ . '/vendor/autoload.php';
16: if(!file_exists($autoload)) {
17: die('Please install composer from https://getcomposer.org and run composer install');
18: }
19:
20: require $autoload;
21:
22: if(isset($_SERVER["PEG_SKELETON_PATH"]))
23: define("PEG_SKELETON_PATH", $_SERVER["PEG_SKELETON_PATH"]);
24: else
25: define("PEG_SKELETON_PATH", __DIR__ . "/vendor/peg-org/peg-src/skeleton");
26:
27: if(isset($_SERVER["PEG_LIBRARY_PATH"]))
28: define("PEG_LIBRARY_PATH", $_SERVER["PEG_LIBRARY_PATH"]);
29: else
30: define("PEG_LIBRARY_PATH", __DIR__ . "/");
31:
32: if(isset($_SERVER["PEG_LOCALE_PATH"]))
33: define("PEG_LOCALE_PATH", $_SERVER["PEG_LOCALE_PATH"]);
34: else
35: define("PEG_LOCALE_PATH", __DIR__ . "/locale");
36:
37:
38: if(!file_exists(PEG_LIBRARY_PATH . "src"))
39: throw new Exception("Peg lib path not found.");
40:
41: if(!file_exists(PEG_SKELETON_PATH))
42: throw new Exception("Peg skeleton files path not found.");
43:
44:
45: function peg_custom_autoloader($class_name)
46: {
47: $file = str_replace("\\", "/", $class_name) . ".php";
48: $file = str_replace("Peg/Custom/", "", $file);
49:
50: include(PEG_LIBRARY_PATH . "src/" . $file);
51: }
52:
53: spl_autoload_register("peg_custom_autoloader");
54:
55:
56:
57: function t($text)
58: {
59: static $language_object;
60:
61: if(!$language_object)
62: {
63: $language_object = new Peg\Custom\Localization\Language(PEG_LOCALE_PATH);
64: }
65:
66: return $language_object->Translate($text);
67: }
68:
69:
70: date_default_timezone_set("UTC");
71:
72:
73: Peg\Custom\Application::Initialize();
74:
75:
76: $parser = Peg\Custom\Application::GetCLIParser();
77:
78:
79: $parser->Start($argc, $argv);
80: