51 var $Resp_ReturnObjectType;
52 var $Resp_ReturnObjectSize;
58 var $XRC_CMD = Array(
"version"=>
"",
"clientID"=>
"",
"password"=>
"",
"cmd"=>
"",
"args"=>Array());
60 function XRC_API_Method ($p_distID =
'', $p_distPWD =
'') {
63 $this->XRC_CMD[
"version"] =
"1";
64 $this->XRC_CMD[
"clientID"] = ($p_distID !=
'' ? $p_distID :
'1646757');
65 $this->XRC_CMD[
"password"] = ($p_distPWD !=
'' ? $p_distPWD :
'tpw4tnms');
67 $this->XRC_Server =
"xrc.everyone.net";
68 $this->XRC_Script =
"/ccc/xrc";
75 function XRC_Parse () {
84 $pattern =
"/version: ([\d]+)\nstatus: ([\d]+)\nserver: ([\w]+)\ntimestamp: ([\w]+)\n([^?]+)/";
86 preg_match ($pattern, $this->XRC_FullData, $matches);
95 $this->Resp_version = $matches[1];
96 $this->Resp_status = $matches[2];
97 $this->Resp_server = $matches[3];
98 $this->Resp_timestamp = $matches[4];
99 $this->Resp_response = $matches[5];
102 $this->is_success = ($this->Resp_status == 0 ? true :
false);
104 if ($this->is_success) {
107 $this->XRC_StripNewLine();
110 $this->Resp_Array = explode(
"\n", $this->Resp_response);
112 if ($this->Resp_Array[count($this->Resp_Array) - 1] ==
"") {
113 array_pop ($this->Resp_Array);
118 $this->values = $this->XRC_CreateList($this->Resp_Array);
123 $this->XRC_GetError();
125 print
"<br>*** RESPONSE *** <bR>Version: {$this->Resp_version}<br>Status: {$this->Resp_status}<bR>Server: {$this->Resp_server}<br>Timestamp: {$this->Resp_timestamp}<br>Remainder: {$this->Resp_response}<br>";
128 function clearArgs() {
130 $this->XRC_CMD[
"args"] = Array();
133 function addArgs($type, $value) {
138 $arg_value = $value .
"+";
139 } elseif ($type ==
"S") {
140 $arg_value = urlencode(
"\"$value\"") .
"+";
142 $this->XRC_CMD[
"args"][] = $arg_value;
145 function setCmd($value) {
147 $this->XRC_CMD[
'cmd'] = $value;
150 case "listClientIDsOfDistributor":
151 case "listUserNamesOfClient":
152 $this->Resp_ReturnObjectType =
"value";
153 $this->Resp_ReturnObjectSize =
"single";
155 case "summarizeEmailClient":
156 $this->Resp_ReturnObjectType =
"EmailClientSummary";
157 $this->Resp_ReturnObjectSize =
"single";
159 case "summarizeEmailClientsOfDistributor":
160 $this->Resp_ReturnObjectType =
"EmailClientSummary";
161 $this->Resp_ReturnObjectSize =
"list";
163 case "summarizeUserMailbox":
164 $this->Resp_ReturnObjectType =
"MailboxSummary";
165 $this->Resp_ReturnObjectSize =
"single";
168 $this->Resp_ReturnObjectType =
"value";
169 $this->Resp_ReturnObjectSize =
"single";
174 function SendRequest($useHTTPS =
true) {
176 $this->is_success =
false;
177 $this->XRC_FullData =
"";
181 $url =
"http" . ($useHTTPS ?
"s" :
"") .
"://{$this->XRC_Server}{$this->XRC_Script}";
183 fwrite ($fp,
"<br> CMD - $cmd");
187 $server_post .=
"version=" . $this->XRC_CMD[
'version'];
188 $server_post .=
"&clientID=" . $this->XRC_CMD[
'clientID'];
189 $server_post .=
"&password=" . $this->XRC_CMD[
'password'];
190 $server_post .=
"&cmd=" . $this->XRC_CMD[
'cmd'];
193 foreach ($this->XRC_CMD[
'args'] as $key => $value) {
195 $arg_string .= $value;
197 $server_post .=
"&args=($arg_string)";
207 $cmd = $url .
"?" . $server_post;
216 $curl_ptr = fopen($cmd,
"r");
220 $curl_data = @fread($curl_ptr, 8192);
221 if (strlen($curl_data) == 0) {
224 $curl_response .= $curl_data;
232 $fp = fopen (
"/home/ubuntu/mark/xrc_class.txt",
"a+");
233 fwrite ($fp,
"Response - $curl_response");
240 $this->XRC_FullData = $curl_response;
243 function XRC_GetError() {
245 $this->ErrDesc = $this->Resp_response;
247 function XRC_Decipher($pString) {
277 $Value_List = explode (
"\n", $pString);
306 switch ($this->Resp_ReturnObjectType) {
309 $retValue = $this->XRC_MassageData($matches[1]);
311 case "EmailClientSummary":
315 $this->is_success =
false;
316 $this->ErrDesc =
"Unknown Object Type";
322 function XRC_MassageData($pData) {
324 $pattern =
"/[\"\/]/";
328 $retValue = preg_replace ($pattern, $replacewith, $pData);
329 $retValue = trim($retValue);
334 function XRC_StripNewLine() {
337 while (substr($this->Resp_response, $cur_pos, 1) ==
"\n") {
342 $this->Resp_response = substr($this->Resp_response, $cur_pos);
347 function XRC_CreateList($pArray, $enumerate=
false) {
351 $partialArray = Array();
354 for ($idxArray = 0; $idxArray < count($pArray); $idxArray++) {
357 $partialArray = Array();
358 $value = $this->XRC_MassageData($pArray[$idxArray]);
370 $value = $this->XRC_MassageData($pArray[$idxArray]);
376 if (substr($value, 0, 1) ==
":" || substr($value, 0, 1) ==
"(") {
382 for ($partIdx = ($idxArray + 1); $partIdx < count($pArray); $partIdx++) {
387 $partValue = $this->XRC_MassageData($pArray[$partIdx]);
389 if ($level == 1 && $partValue ==
")") {
391 } elseif (strstr($partValue,
")") !== FALSE && $level > 1) {
392 $partialArray[] = $partValue;
394 } elseif ((strstr($partValue,
"(") !== FALSE) && ($partIdx == $idxArray)) {
396 } elseif (strstr($partValue,
"(") !== FALSE) {
398 $partialArray[] = $partValue;
400 $partialArray[] = $partValue;
404 $idxArray = $partIdx;
413 $retValue[] = $this->XRC_CreateList($partialArray, (substr($value, 0, 1) ==
":" ?
true :
false));
415 $retValue[$useKey] = $this->XRC_CreateList($partialArray, (substr($value, 0, 1) ==
":" ?
true :
false));
424 $retValue[] = $pArray[$idxArray];
427 $retValue[$useKey] = $pArray[$idxArray];