blob: 6a0b92412c8afb5abad717539f35924cae5e894d (
plain)
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
|
<?php
function squareup_validate() {
if (php_sapi_name() != 'cli') {
die("Not in Command Line.");
}
}
function squareup_chdir($current_dir) {
$root_dir = dirname(dirname(dirname($current_dir)));
chdir($root_dir);
return $root_dir;
}
function squareup_define_route() {
define('SQUAREUP_ROUTE', 'extension/recurring/squareup/recurring');
$_GET['route'] = SQUAREUP_ROUTE;
}
function squareup_init($current_dir) {
global $argc, $argv;
// Validate environment
squareup_validate();
// Set up default server vars
if (isset($argc) && isset($argv) && $argc >= 3) {
$_SERVER["HTTP_HOST"] = $argv[1];
$_SERVER["SERVER_NAME"] = $argv[1];
$_SERVER["SERVER_PORT"] = $argv[2];
} else {
$_SERVER["HTTP_HOST"] = "localhost";
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["SERVER_PORT"] = 80;
}
putenv("SERVER_NAME=" . $_SERVER["SERVER_NAME"]);
// Change root dir
$root_dir = squareup_chdir($current_dir);
squareup_define_route();
if (file_exists($root_dir . '/index.php')) {
return $root_dir . '/index.php';
}
}
|