-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient.php
executable file
·33 lines (31 loc) · 1.11 KB
/
client.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
#!/usr/bin/php
<?php
//Hackish way to make sure we switch to the directory that index.php is in
$file_path = $_SERVER['PWD'].'/'.$_SERVER['PHP_SELF'];
chdir(dirname($file_path));
//Keep our current directory since we're going to change it back in our cli controller.
$GLOBALS['pyrotoast_client_path'] = getcwd();
//prepare the arguments for URI parsing.
$default_args = array($argv[0], 'pyrotoast', 'cli','index');
$other_args = array_slice($argv, 1);
$args = array_merge($default_args, $other_args);
//generate the request URI
$request_URI = '/'.implode(array_slice($args,1), '/');
/* Just define some globals used in config to get rid of some errors.*/
$temp_server = array(
'SERVER_NAME' => 'localhost',
'REQUEST_URI' => $request_URI,
'QUERY_STRING' => '',
'SERVER_PORT' => 80,
'REQUEST_METHOD' => 'GET',
'SERVER_NAME' => 'localhost',
'ENVIRONMENT' => 'development',
'PHP_SELF' => $request_URI,
'HTTP_HOST' => 'localhost',
'argv' => $args
);
$_SERVER = array_merge($_SERVER, $temp_server);
//Finally, include the index.php file
$argv = $args;
chdir('../../../..');
require_once('index.php');