lib_remote.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) Copyright (C) 2008 - 2013 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. require_once("Crypt/XXTEA.php");
  25. // Screen type for servers
  26. define("OGP_SCREEN_TYPE_HOME","HOME");
  27. define("OGP_SCREEN_TYPE_UPDATE","UPDATE");
  28. define("AGENT_ERROR_NOT_EXECUTABLE",-13);
  29. class OGPRemoteLibrary
  30. {
  31. private $port;
  32. private $host;
  33. private $encryption_key;
  34. private $enc;
  35. private $timeout;
  36. function __construct($host,$port,$encryption_key,$timeout = 2)
  37. {
  38. $this->host = $host;
  39. $this->port = $port;
  40. $this->encryption_key = $encryption_key;
  41. $this->enc = new Crypt_XXTEA();
  42. $this->enc->setKey($this->encryption_key);
  43. $this->timeout = $timeout;
  44. }
  45. function __destruct()
  46. {
  47. }
  48. private function sendRequest($request)
  49. {
  50. $context = stream_context_create
  51. (array('http' => array
  52. (
  53. 'method' => "POST",
  54. 'header' => "Content-Type: text/xml",
  55. 'content' => $request,
  56. 'timeout' => $this->timeout
  57. )));
  58. $status = @file_get_contents("http://".$this->host.":".$this->port."/RPC2", false, $context);
  59. $retval = xmlrpc_decode($status);
  60. return $retval;
  61. }
  62. private function encryptParam($param)
  63. {
  64. $param = base64_encode($param);
  65. $param = $this->enc->encrypt($param);
  66. $param = base64_encode($param);
  67. return $param;
  68. }
  69. private function encrypt_params()
  70. {
  71. $params_array = array();
  72. $args = func_get_args();
  73. foreach ($args as $arg)
  74. {
  75. array_push($params_array,$this->encryptParam($arg));
  76. }
  77. return $params_array;
  78. }
  79. /// \return FALSE If there was problems in the decoding.
  80. private function decryptParam($param)
  81. {
  82. $param_tmp = base64_decode($param_tmp,true);
  83. $param_tmp = $this->enc->decrypt($param);
  84. // Lets check in strict mode, so that errors are found.
  85. $param_tmp = base64_decode($param_tmp,true);
  86. if ( $param_tmp === FALSE )
  87. return FALSE;
  88. $param = $param_tmp;
  89. return TRUE;
  90. }
  91. /// \returns 1 If file exists
  92. /// \returns 0 If file does not exist
  93. /// \returns -1 If server not available.
  94. public function rfile_exists($file)
  95. {
  96. $args = $this->encryptParam(trim($file));
  97. $request = xmlrpc_encode_request("rfile_exists", $args);
  98. $status = $this->sendRequest($request);
  99. if ( $status === 0 )
  100. return 1;
  101. if ( empty($status) )
  102. return -1;
  103. // File does not exist.
  104. return 0;
  105. }
  106. /// \returns 1 If online
  107. /// \returns 0 If offline
  108. /// \returns -1 If encryption key mismatch
  109. public function status_chk()
  110. {
  111. $param = "hello";
  112. $args = $this->encryptParam($param);
  113. $request = xmlrpc_encode_request("quick_chk", $args);
  114. $status = $this->sendRequest($request);
  115. // If 1 is returned then the encryption key did not match.
  116. if ( $status === 1 )
  117. return -1;
  118. // When 0 is returned everythin is OK.
  119. else if ( $status === 0 )
  120. return 1;
  121. // We could not connect to the remote host, offline?.
  122. else
  123. return 0;
  124. }
  125. /// \returns 0 When server offline / could not be connected.
  126. /// \returns the log in $data in case the log can be found.
  127. public function get_log($screen_type,$home_id,$home_path,&$data,$nb_of_lines = 100)
  128. {
  129. $params_array = $this->encrypt_params($screen_type,$home_id,$home_path,$nb_of_lines);
  130. $request = xmlrpc_encode_request('get_log',$params_array);
  131. $response = $this->sendRequest($request);
  132. if ( $response === NULL )
  133. return 0;
  134. @list($retval,$data_tmp) = @explode(";",$response);
  135. // We get log only with positive values.
  136. if ( $retval > 0 )
  137. {
  138. $lines = explode('\n',$data_tmp);
  139. foreach ($lines as $line)
  140. {
  141. $data .= base64_decode($line);
  142. }
  143. }
  144. return $retval;
  145. }
  146. /// \brief Stops remote server.
  147. /// \return 1 On success.
  148. /// \return 0 When server offline / could not be connected.
  149. /// \return -1 When error occurred
  150. public function remote_stop_server($home_id, $server_ip,
  151. $server_port, $control_protocol, $control_password, $control_type, $home_path)
  152. {
  153. $params_array = $this->encrypt_params($home_id,$server_ip,$server_port,
  154. $control_protocol,$control_password,$control_type,$home_path);
  155. $request = xmlrpc_encode_request("stop_server", $params_array);
  156. $status = $this->sendRequest($request);
  157. // Error occurred on the remote end.
  158. if( $status === 1 )
  159. return -1;
  160. // Server successfully stopped.
  161. else if ( $status == 0 )
  162. return 1;
  163. // Connection problems.
  164. else
  165. return 0;
  166. }
  167. /// \brief Send a RCON command.
  168. /// \return 1 On success.
  169. public function remote_send_rcon_command($home_id, $server_ip,
  170. $server_port, $control_protocol, $control_password, $control_type, $rconCommand,&$data)
  171. {
  172. $params_array = $this->encrypt_params($home_id,$server_ip,$server_port,
  173. $control_protocol,$control_password,$control_type, $rconCommand);
  174. $request = xmlrpc_encode_request("send_rcon_command", $params_array);
  175. $response = $this->sendRequest($request);
  176. @list($retval,$data_tmp) = @explode(";",$response);
  177. if ( $retval > 0 )
  178. {
  179. $lines = explode('\n',$data_tmp);
  180. foreach ($lines as $line)
  181. {
  182. $data .= base64_decode($line);
  183. }
  184. return 1;
  185. }
  186. elseif ( $retval === 0 )
  187. return 0;
  188. elseif ( $retval === -10 )
  189. return -10;
  190. else
  191. return -1;
  192. }
  193. /// \return 1 If success
  194. /// \return 0 If file does not exist.
  195. /// \return -1 In case of connection error
  196. /// \return -2 If failed to read file.
  197. public function remote_readfile($args,&$data)
  198. {
  199. $args = trim($args);
  200. $args = $this->encryptParam($args);
  201. $request = xmlrpc_encode_request("readfile", $args);
  202. $response = $this->sendRequest($request);
  203. if ( $response === NULL )
  204. return -1;
  205. if ( is_array($response) && xmlrpc_is_fault($response))
  206. return -1;
  207. @list($retval,$data_tmp) = @explode(";",$response);
  208. $retval = (integer) $retval;
  209. if ( $retval === 0 )
  210. return 0;
  211. else if ( $retval === -1 )
  212. return -2;
  213. $data = base64_decode($data_tmp);
  214. return 1;
  215. }
  216. /// \return 1 If success
  217. /// \return 0 On failure
  218. /// \return -1 If agent could not be connected.
  219. public function remote_writefile($writefile, $content)
  220. {
  221. $content = base64_encode($content);
  222. $params = $this->encrypt_params($writefile,$content);
  223. $request = xmlrpc_encode_request("writefile", $params);
  224. $response = $this->sendRequest($request);
  225. if ( $response === 1 )
  226. return 1;
  227. else if ( $response === 0 )
  228. return 0;
  229. else
  230. return -1;
  231. }
  232. /// Updates the mod located in the game home with steam.
  233. /// \return 1 If update started successfully
  234. /// \return 0 If error
  235. /// \return -1 In case of connection error.
  236. public function steam($home_id,$game_home,$mod,$exec_folder_path,$exec_path,$precmd,$postcmd)
  237. {
  238. $params = $this->encrypt_params($home_id,$game_home,$mod,$exec_folder_path,$exec_path,$precmd,$postcmd);
  239. $request = xmlrpc_encode_request("steam", $params);
  240. $response = $this->sendRequest($request);
  241. if ( $response === 1 )
  242. return 1;
  243. else if ( $response === 0 )
  244. return 0;
  245. else
  246. return -1;
  247. }
  248. /// Updates the mod located in the game home with steamCmd.
  249. /// \return 1 If update started successfully
  250. /// \return 0 If error
  251. /// \return -1 In case of connection error.
  252. public function steam_cmd($home_id,$game_home,$mod,$modname,$betaname,$betapwd,$user,$pass,$guard,$exec_folder_path,$exec_path,$precmd,$postcmd,$cfg_os)
  253. {
  254. $params = $this->encrypt_params($home_id,$game_home,$mod,$modname,$betaname,$betapwd,$user,$pass,$guard,$exec_folder_path,$exec_path,$precmd,$postcmd,$cfg_os);
  255. $request = xmlrpc_encode_request("steam_cmd", $params);
  256. $response = $this->sendRequest($request);
  257. if ( $response === 1 )
  258. return 1;
  259. else if ( $response === 0 )
  260. return 0;
  261. else
  262. return -1;
  263. }
  264. /// Updates the mod located in the game home with master server.
  265. /// \return 1 If update started successfully
  266. /// \return 0 If error
  267. /// \return -1 In case of connection error.
  268. public function masterServerUpdate($home_id,$home_path,$ms_home_id,$ms_home_path,$exec_folder_path,$exec_path,$precmd,$postcmd)
  269. {
  270. $params = $this->encrypt_params($home_id,$home_path,$ms_home_id,$ms_home_path,$exec_folder_path,$exec_path,$precmd,$postcmd);
  271. $request = xmlrpc_encode_request("master_server_update", $params);
  272. $response = $this->sendRequest($request);
  273. if ( $response === 1 )
  274. return 1;
  275. else if ( $response === 0 )
  276. return 0;
  277. else
  278. return -1;
  279. }
  280. /// \brief Checks if the game update is running for the certain gamehome.
  281. /// \return 1 if the update is active
  282. /// \return 0 if the update is not active
  283. /// \return -1 If unable to connect to the remote server.
  284. /// \return -2 In other errors.
  285. public function game_update_active($game_home,$mod)
  286. {
  287. $game_home = $this->encryptParam($game_home);
  288. $mod = $this->encryptParam($mod);
  289. $request = xmlrpc_encode_request("game_update_active", array($game_home, $mod));
  290. if(!$response = $this->sendRequest($request) )
  291. return -1;
  292. else if ( $response === 1 )
  293. return 1;
  294. else if ( $response === 0 )
  295. return 0;
  296. // other errors.
  297. else
  298. return -2;
  299. }
  300. /// \return -1 If could not connect to the remote host.
  301. /// \return -3 In case of unknown error
  302. /// \todo This function is not complete. Also the agent side requires work.
  303. public function start_file_download($url, $dest, $filename, $action = "", $post_script = "" )
  304. {
  305. $params_array = $this->encrypt_params($url,$dest,$filename,$action,$post_script);
  306. $request = xmlrpc_encode_request("start_file_download",$params_array);
  307. $response = $this->sendRequest($request);
  308. if( !$response )
  309. return -1;
  310. if (is_array($response) && xmlrpc_is_fault($response))
  311. return -3;
  312. return $response;
  313. }
  314. public function is_file_download_in_progress($pid)
  315. {
  316. $pid = $this->encryptParam($pid);
  317. $request = xmlrpc_encode_request("is_file_download_in_progress", array($pid));
  318. $response = $this->sendRequest($request);
  319. return $response;
  320. }
  321. public function uncompress_file($file_location, $destination)
  322. {
  323. $params_array = $this->encrypt_params($file_location,$destination);
  324. $request = xmlrpc_encode_request("uncompress_file",$params_array);
  325. $response = $this->sendRequest($request);
  326. return $response;
  327. }
  328. /// \return -1 If could not connect to the remote host.
  329. /// \return -3 In case of unknown error
  330. /// \todo This function is not complete. Also the agent side requires work.
  331. public function start_rsync_install($home_id,$home_path,$url,$exec_folder_path,$exec_path,$precmd,$postcmd)
  332. {
  333. $params_array = $this->encrypt_params($home_id,$home_path,$url,$exec_folder_path,$exec_path,$precmd,$postcmd);
  334. $request = xmlrpc_encode_request("start_rsync_install",$params_array);
  335. $response = $this->sendRequest($request);
  336. if ( $response === 1 )
  337. return 1;
  338. else if ( $response === 0 )
  339. return 0;
  340. else
  341. return -1;
  342. }
  343. public function rsync_progress($home)
  344. {
  345. $params_array = $this->encrypt_params($home);
  346. $request = xmlrpc_encode_request("rsync_progress",$params_array);
  347. $response = $this->sendRequest($request);
  348. if( !$response )
  349. return -1;
  350. #if (is_array($response) && xmlrpc_is_fault($response))
  351. # return -3;
  352. return $response;
  353. }
  354. /// \return array of files in directory, when request success.
  355. /// \return -1 If unable to connect to the remote server.
  356. /// \return -2 In case directory was not accessible.
  357. /// \return -3 Any other error.
  358. public function remote_dirlist($args)
  359. {
  360. $args = $this->encryptParam($args);
  361. $request = xmlrpc_encode_request("dirlist", $args);
  362. if( !$response = $this->sendRequest($request))
  363. return -1;
  364. if (is_array($response) && xmlrpc_is_fault($response))
  365. return -3;
  366. if( $response < 0 )
  367. return -2;
  368. return explode(";", $response);
  369. }
  370. /// \return array of files and file info (size owner etc) in directory, when request success.
  371. /// \return -1 If unable to connect to the remote server.
  372. /// \return -2 In case directory was not accessible.
  373. /// \return -3 Any other error.
  374. public function remote_dirlistfm($args)
  375. {
  376. $args = $this->encryptParam($args);
  377. $request = xmlrpc_encode_request("dirlistfm", $args);
  378. $response = $this->sendRequest($request);
  379. if ( $response === NULL )
  380. return -1;
  381. if (is_array($response) && xmlrpc_is_fault($response))
  382. return -3;
  383. if( $response < 0 )
  384. return -2;
  385. if ( $response == "" )
  386. return array();
  387. return explode(";", $response);
  388. }
  389. /// \returns the number of CPUs on the server
  390. /// \returns -1 If the server cannot be reached.
  391. public function cpu_count()
  392. {
  393. $request = xmlrpc_encode_request("cpu_count", NULL);
  394. $status = $this->sendRequest($request);
  395. if ( empty($status) )
  396. {
  397. return -1;
  398. }
  399. return $status;
  400. }
  401. public function renice_process($home_path, $nice)
  402. {
  403. $home_path = $this->encryptParam($home_path);
  404. $nice = $this->encryptParam($nice);
  405. $request = xmlrpc_encode_request("renice_process",
  406. array($home_path,$nice));
  407. $status = $this->sendRequest($response);
  408. return $status;
  409. }
  410. /// \return 1 If everything ok
  411. /// \return -1 If connection could not be established.
  412. /// \return -2 In other errors.
  413. /// \todo Other return values?
  414. public function universal_start($home_id, $game_home, $game_binary, $run_dir, $startup_cmd,
  415. $server_port, $server_ip, $cpu, $nice)
  416. {
  417. $params_array = $this->encrypt_params($home_id, $game_home, $game_binary,
  418. $run_dir, $startup_cmd, $server_port, $server_ip, $cpu, $nice);
  419. $request = xmlrpc_encode_request("universal_start", $params_array);
  420. $response = $this->sendRequest($request);
  421. if($response === NULL)
  422. return -1;
  423. if (is_array($response) && xmlrpc_is_fault($response))
  424. return -2;
  425. return $response;
  426. }
  427. /// \returns the os of the remote host.
  428. public function what_os()
  429. {
  430. $request = xmlrpc_encode_request("what_os", NULL);
  431. $status = $this->sendRequest($request);
  432. return "$status";
  433. }
  434. /// \return Available IP addresses of the remote host.
  435. /// \return empty array if no ip's are found.
  436. /// \return array containing the ip's on success.
  437. public function discover_ips()
  438. {
  439. $args = "chk";
  440. $args = $this->encryptParam($args);
  441. $request = xmlrpc_encode_request("discover_ips", $args);
  442. $status = $this->sendRequest($request);
  443. if ( $status == 0 )
  444. return array();
  445. $retval = explode(",",$status);
  446. return $retval;
  447. }
  448. /// \brief Checks if the server is running.
  449. /// \return 1 If is
  450. /// \return 0 If is not
  451. /// \return -1 If agent could not be reached.
  452. public function is_screen_running($screen_type,$home_id)
  453. {
  454. $params = $this->encrypt_params($screen_type,$home_id);
  455. $request = xmlrpc_encode_request("is_screen_running", $params);
  456. $status = $this->sendRequest($request);
  457. if ( $status === 1 )
  458. return 1;
  459. else if ( $status === 0 )
  460. return 0;
  461. else
  462. return -1;
  463. }
  464. public function mon_stats()
  465. {
  466. $args = $this->encrypt_params("mon_stats");
  467. $request = xmlrpc_encode_request("mon_stats", $args);
  468. $response = $this->sendRequest($request);
  469. @list($retval,$data_tmp) = @explode(";",$response);
  470. $data = NULL;
  471. if ( $retval > 0 )
  472. {
  473. $lines = explode('\n',$data_tmp);
  474. foreach ($lines as $line)
  475. {
  476. $data .= base64_decode($line);
  477. }
  478. }
  479. return $data;
  480. }
  481. /// \brief copies a game home on the filesystem.
  482. /// \return 1 On success.
  483. /// \return 0 When server offline / could not be connected.
  484. /// \return -1 When error occurred
  485. /// Usually a -1 happens because of a connection timeout during the copy. This is expected
  486. public function clone_home($source_home, $dest_home, $owner)
  487. {
  488. $params_array = $this->encrypt_params($source_home, $dest_home, $owner);
  489. $request = xmlrpc_encode_request("clone_home", $params_array);
  490. $status = $this->sendRequest($request);
  491. // Copy was successful.
  492. if( $status === 1 )
  493. return 1;
  494. // Copy failed.
  495. else if ( $status === 0 )
  496. return 0;
  497. // Connection problems.
  498. else
  499. return -1;
  500. }
  501. /// \brief removes a game home from the filesystem.
  502. /// \return 1 On success.
  503. /// \return 0 When server offline / could not be connected.
  504. /// \return -1 When error occurred
  505. public function remove_home($game_home_del)
  506. {
  507. $game_home_del = $this->encryptParam($game_home_del);
  508. $request = xmlrpc_encode_request("remove_home", $game_home_del);
  509. $status = $this->sendRequest($request);
  510. // Delete was successful.
  511. if( $status === 1 )
  512. return 1;
  513. // Delete failed.
  514. else if ( $status === 0 )
  515. return 0;
  516. // Connection problems.
  517. else
  518. return -1;
  519. }
  520. public function remote_restart_server($home_id,$server_ip,$server_port,
  521. $control_protocol,$control_password,$control_type,
  522. $home_path,$server_exe,$run_dir,$cmd,$cpu,$nice)
  523. {
  524. $params_array = $this->encrypt_params($home_id,$server_ip,$server_port,
  525. $control_protocol,$control_password,$control_type,
  526. $home_path,$server_exe,$run_dir,$cmd,$cpu,$nice);
  527. $request = xmlrpc_encode_request("restart_server", $params_array);
  528. $status = $this->sendRequest($request);
  529. // Error server cant stop.
  530. if( $status === -2 )
  531. return -2;
  532. // Error server cant start.
  533. else if ( $status === -1 )
  534. return -1;
  535. //// OK successfully restarted.
  536. else if ( $status === 1 )
  537. return 1;
  538. // Connection problems.
  539. else
  540. return 0;
  541. }
  542. public function sudo_exec($update_ftp_users)
  543. {
  544. $params_array = $this->encrypt_params($update_ftp_users);
  545. $request = xmlrpc_encode_request("sudo_exec", $params_array);
  546. $status = $this->sendRequest($request);
  547. @list($retval,$data_tmp) = @explode(";",$status);
  548. $data = NULL;
  549. if ( $retval > 0 )
  550. {
  551. $lines = explode('\n',$data_tmp);
  552. foreach ($lines as $line)
  553. {
  554. $data .= base64_decode($line);
  555. }
  556. return $data;
  557. }
  558. return 0;
  559. }
  560. public function exec($command)
  561. {
  562. $params_array = $this->encrypt_params($command);
  563. $request = xmlrpc_encode_request("exec", $params_array);
  564. $response = $this->sendRequest($request);
  565. @list($retval,$data_tmp) = @explode(";",$response);
  566. $data = NULL;
  567. if ( $retval > 0 )
  568. {
  569. $lines = explode('\n',$data_tmp);
  570. foreach ($lines as $line)
  571. {
  572. $data .= base64_decode($line);
  573. }
  574. }
  575. return $data;
  576. }
  577. public function secure_path($action, $path)
  578. {
  579. $params_array = $this->encrypt_params($action, $path);
  580. $request = xmlrpc_encode_request("secure_path", $params_array);
  581. $status = $this->sendRequest($request);
  582. @list($retval,$data_tmp) = @explode(";",$status);
  583. $data = NULL;
  584. if ( $retval > 0 )
  585. {
  586. $lines = explode('\n',$data_tmp);
  587. foreach ($lines as $line)
  588. {
  589. $data .= base64_decode($line);
  590. }
  591. }
  592. return $data;
  593. }
  594. public function get_chattr($path)
  595. {
  596. $params_array = $this->encrypt_params($path);
  597. $request = xmlrpc_encode_request("get_chattr", $params_array);
  598. $status = $this->sendRequest($request);
  599. @list($retval,$data_tmp) = @explode(";",$status);
  600. $data = NULL;
  601. if ( $retval > 0 )
  602. {
  603. $lines = explode('\n',$data_tmp);
  604. foreach ($lines as $line)
  605. {
  606. $data .= base64_decode($line);
  607. }
  608. }
  609. return $data;
  610. }
  611. public function ftp_mgr($action, $login = "", $password = "", $home_path = "")
  612. {
  613. $params_array = $this->encrypt_params($action, $login, $password, $home_path);
  614. $request = xmlrpc_encode_request("ftp_mgr", $params_array);
  615. $status = $this->sendRequest($request);
  616. @list($retval,$data_tmp) = @explode(";",$status);
  617. $data = NULL;
  618. if ( $retval > 0 )
  619. {
  620. $lines = explode('\n',$data_tmp);
  621. foreach ($lines as $line)
  622. {
  623. $data .= base64_decode($line);
  624. }
  625. return $data;
  626. }
  627. return 0;
  628. }
  629. }
  630. ?>