-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmicrocosm.php
More file actions
executable file
·90 lines (70 loc) · 2.17 KB
/
Copy pathmicrocosm.php
File metadata and controls
executable file
·90 lines (70 loc) · 2.17 KB
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
86
87
88
89
90
<?php
require_once('fileutils.php');
require_once('querymap.php');
require_once('system.php');
require_once('auth.php');
//******************************
//Start up functions and logging
//******************************
ob_start();
CallFuncByMessage(Message::SCRIPT_START,Null);
////-------------------------
if(DEBUG_MODE) dprint("$_SERVER",$_SERVER);
global $PROG_ARG_LONG;
$options = getopt(PROG_ARG_STRING, $PROG_ARG_LONG);
if(isset($options['g'])) $_GET = CommandLineOptionsSetVar($options['g'], $_GET);
//print_r($_GET);
//print_r($_SERVER);
list($login, $pass) = GetUsernameAndPassword();
CheckPermissions();
//Split URL for processing
$pathInfo = GetRequestPath();
$urlExp = explode("/",$pathInfo);
if(DEBUG_MODE) dprint("pathinfo",$pathInfo);
$putdata = fopen("php://input", "r");
$putDataStr = "";
while ($data = fread($putdata, 1024))
{
$putDataStr = $putDataStr . $data;
}
//***********************
//User Authentication
//***********************
try
{
//Authentication, if there is a server username variable or non-GET method used
$displayName = null;
$userId = null;
$authFailed = False;
if ($login !== Null or strcmp(GetServerRequestMethod(),"GET")!=0)
{
$authRet = RequireAuth($login, $pass);
if($authRet == -1) //If authentication failed
$authFailed = True;
else
{
list ($displayName, $userId) = $authRet;
}
}
//This function determines with function to call based on the URL and, if it can, responds to the client.
if(!$authFailed)
CallFuncByMessage(Message::API_EVENT,array($pathInfo,$urlExp,$putDataStr,$_GET,$_POST,$_FILES,$displayName,$userId));
}
catch(Exception $e)
{
echo "Exception: ".$e->getMessage()."\n";
}
//Save console output to debug file
$debugLog = False;
if(DEBUG_MODE) $debugLog = fopen("debuglog.txt","at");
if($debugLog) {fwrite($debugLog,ob_get_contents());}
ob_end_clean();
CallFuncByMessage(Message::FLUSH_RESPONSE_TO_CLIENT,Null);
//Trigger destructors acts better, rather than letting database handle going out of scope
ob_start();
CallFuncByMessage(Message::SCRIPT_END,Null);
if($debugLog) {fwrite($debugLog,ob_get_contents());fclose($debugLog);}
ob_end_clean();
//Housekeeping? Process traces?
//TODO Close changesets that time out
?>