Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.86 KB | None | 0 0
  1. <?php
  2. /*
  3. * webadmin.php - a simple Web-based file manager
  4. * Copyright (C) 2002 Daniel Wacker <mail@wacker-welt.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. /* ------------------------------------------------------------------------- */
  21.  
  22. /* Select your language:
  23. * 'en' - English
  24. * 'de' - German
  25. * 'cz' - Czech
  26. * 'it' - Italian
  27. */
  28. $language = 'en';
  29.  
  30. /* This directory is shown when you start webadmin.php.
  31. * For example: './' would be the current directory.
  32. */
  33. $homedir = './';
  34.  
  35. /* This sets the root directory of the treeview.
  36. * Set it to '/' to see the whole filesystem.
  37. */
  38. $treeroot = '/';
  39.  
  40. /* When you create a directory, its permission is set to this octal value.
  41. * For example: 0705 would be 'drwx---r-x'.
  42. */
  43. $dirpermission = 0705;
  44.  
  45. /* Uncomment the following line to enable this feature (remove #):
  46. * When you create a file, its permission is set to this octal value.
  47. * For example: 0644 would be 'drwxr--r--'.
  48. */
  49. # $newfilepermission = 0666;
  50.  
  51. /* Uncomment the following line to enable this feature (remove #):
  52. * When you upload a file, its permission is set to this octal value.
  53. * For example: 0644 would be 'drwxr--r--'.
  54. */
  55. # $uploadedfilepermission = 0666;
  56.  
  57. /* The size of the file edit textarea
  58. */
  59. $editrows = 20;
  60. $editcols = 70;
  61.  
  62. /* ------------------------------------------------------------------------- */
  63.  
  64. $self = htmlentities(basename($_SERVER['PHP_SELF']));
  65. $homedir = relpathtoabspath($homedir, getcwd());
  66. $treeroot = relpathtoabspath($treeroot, getcwd());
  67. $words = getwords($language);
  68.  
  69. /* If PHP added any slashes, strip them */
  70. if (ini_get('magic_quotes_gpc')) {
  71. array_walk($_GET, 'strip');
  72. array_walk($_POST, 'strip');
  73. array_walk($_REQUEST, 'strip');
  74. }
  75.  
  76. /* Return Images */
  77. if (isset($_GET['imageid'])) {
  78. header('Content-Type: image/gif');
  79. echo(getimage($_GET['imageid']));
  80. exit;
  81. }
  82.  
  83. /* Initialize session */
  84. ini_set('session.use_cookies', FALSE);
  85. ini_set('session.use_trans_sid', FALSE);
  86. session_name('id');
  87. session_start();
  88.  
  89. /* Initialize dirlisting output */
  90. $error = $notice = '';
  91. $updatetreeview = FALSE;
  92.  
  93. /* Handle treeview requests */
  94. if (isset($_REQUEST['action'])) {
  95. switch ($_REQUEST['action']) {
  96. case 'treeon':
  97. $_SESSION['tree'] = array();
  98. $_SESSION['hassubdirs'][$treeroot] = tree_hassubdirs($treeroot);
  99. tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $treeroot);
  100. frameset();
  101. exit;
  102. case 'treeoff':
  103. $_SESSION['tree'] = NULL;
  104. $_SESSION['hassubdirs'] = NULL;
  105. dirlisting();
  106. exit;
  107. }
  108. }
  109.  
  110. /* Set current directory */
  111. if (!isset($_SESSION['dir'])) {
  112. $_SESSION['dir'] = $homedir;
  113. $updatetreeview = TRUE;
  114. }
  115. if (!empty($_REQUEST['dir'])) {
  116. $newdir = relpathtoabspath($_REQUEST['dir'], $_SESSION['dir']);
  117. /* If the requested directory is a file, show the file */
  118. if (@is_file($newdir) && @is_readable($newdir)) {
  119. /* if (@is_writable($newdir)) {
  120. $_REQUEST['edit'] = $newdir;
  121. } else */ if (is_script($newdir)) {
  122. $_GET['showh'] = $newdir;
  123. } else {
  124. $_GET['show'] = $newdir;
  125. }
  126. } elseif ($_SESSION['dir'] != $newdir) {
  127. $_SESSION['dir'] = $newdir;
  128. $updatetreeview = TRUE;
  129. }
  130. }
  131.  
  132. /* Show a file */
  133. if (!empty($_GET['show'])) {
  134. $show = relpathtoabspath($_GET['show'], $_SESSION['dir']);
  135. if (!show($show)) {
  136. $error= buildphrase('&quot;<b>' . htmlentities($show) . '</b>&quot;', $words['cantbeshown']);
  137. } else {
  138. exit;
  139. }
  140. }
  141.  
  142. /* Show a file syntax highlighted */
  143. if (!empty($_GET['showh'])) {
  144. $showh = relpathtoabspath($_GET['showh'], $_SESSION['dir']);
  145. if (!show_highlight($showh)) {
  146. $error = buildphrase('&quot;<b>' . htmlentities($showh) . '</b>&quot;', $words['cantbeshown']);
  147. } else {
  148. exit;
  149. }
  150. }
  151.  
  152. /* Upload file */
  153. if (isset($_FILES['upload'])) {
  154. $file = relpathtoabspath($_FILES['upload']['name'], $_SESSION['dir']);
  155. if (@is_writable($_SESSION['dir']) && @move_uploaded_file($_FILES['upload']['tmp_name'], $file) && (!isset($uploadedfilepermission) || chmod($file, $uploadedfilepermission))) {
  156. $notice = buildphrase(array('&quot;<b>' . htmlentities(basename($file)) . '</b>&quot;', '&quot;<b>' . htmlentities($_SESSION['dir']) . '</b>&quot;'), $words['uploaded']);
  157. } else {
  158. $error = buildphrase(array('&quot;<b>' . htmlentities(basename($file)) . '</b>&quot;', '&quot;<b>' . htmlentities($_SESSION['dir']) . '</b>&quot;'), $words['notuploaded']);
  159. }
  160. }
  161.  
  162. /* Create file */
  163. if (!empty($_GET['create']) && $_GET['type'] == 'file') {
  164. $file = relpathtoabspath($_GET['create'], $_SESSION['dir']);
  165. if (substr($file, strlen($file) - 1, 1) == '/') $file = substr($file, 0, strlen($file) - 1);
  166. if (is_free($file) && touch($file) && ((!isset($newfilepermission)) || chmod($file, $newfilepermission))) {
  167. $notice = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['created']);
  168. $_REQUEST['edit'] = $file;
  169. } else {
  170. $error = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['notcreated']);
  171. }
  172. }
  173.  
  174. /* Create directory */
  175. if (!empty($_GET['create']) && $_GET['type'] == 'dir') {
  176. $file = relpathtoabspath($_GET['create'], $_SESSION['dir']);
  177. if (is_free($file) && @mkdir($file, $dirpermission)) {
  178. $notice = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['created']);
  179. $updatetreeview = TRUE;
  180. if (!empty($_SESSION['tree'])) {
  181. $file = spath(dirname($file));
  182. $_SESSION['hassubdirs'][$file] = TRUE;
  183. tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $file);
  184. }
  185. } else {
  186. $error = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['notcreated']);
  187. }
  188. }
  189.  
  190. /* Ask symlink target */
  191. if (!empty($_GET['symlinktarget']) && empty($_GET['symlink'])) {
  192. $symlinktarget = relpathtoabspath($_GET['symlinktarget'], $_SESSION['dir']);
  193. html_header($words['createsymlink']);
  194. ?>
  195. <form action="<?php echo($self); ?>" method="get">
  196. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  197. <input type="hidden" name="symlinktarget" value="<?php echo(htmlentities($_GET['symlinktarget'])); ?>">
  198. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  199. <table border="0" cellspacing="1" cellpadding="4">
  200. <tr>
  201. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  202. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  203. </tr>
  204. <tr>
  205. <td colspan="2" bgcolor="#EEEEEE">
  206. <table border="0">
  207. <tr>
  208. <td valign="top"><?php echo($words['target']); ?>:&nbsp;</td>
  209. <td>
  210. <b><?php echo(htmlentities($_GET['symlinktarget'])); ?></b><br>
  211. <input type="checkbox" name="relative" value="yes" id="checkbox_relative" checked>
  212. <label for="checkbox_relative"><?php echo($words['reltarget']); ?></label>
  213. </td>
  214. </tr>
  215. <tr>
  216. <td><?php echo($words['symlink']); ?>:&nbsp;</td>
  217. <td><input type="text" name="symlink" value="<?php echo(htmlentities(spath(dirname($symlinktarget)))); ?>" size="<?php $size = strlen($_GET['symlinktarget']) + 9; if ($size < 30) $size = 30; echo($size); ?>"></td>
  218. </tr>
  219. <tr>
  220. <td>&nbsp;</td>
  221. <td><input type="submit" value="<?php echo($words['create']); ?>"></td>
  222. </tr>
  223. </table>
  224. </td>
  225. </tr>
  226. </table>
  227. </td></tr></table>
  228. </form>
  229. <?php
  230. html_footer();
  231. exit;
  232. }
  233.  
  234. /* Create symlink */
  235. if (!empty($_GET['symlink']) && !empty($_GET['symlinktarget'])) {
  236. $symlink = relpathtoabspath($_GET['symlink'], $_SESSION['dir']);
  237. $target = $_GET['symlinktarget'];
  238. if (@is_dir($symlink)) $symlink = spath($symlink) . basename($target);
  239. if ($symlink == $target) {
  240. $error = buildphrase(array('&quot;<b>' . htmlentities($symlink) . '</b>&quot;', '&quot;<b>' . htmlentities($target) . '</b>&quot;'), $words['samefiles']);
  241. } else {
  242. if (@$_GET['relative'] == 'yes') {
  243. $target = abspathtorelpath(dirname($symlink), $target);
  244. } else {
  245. $target = $_GET['symlinktarget'];
  246. }
  247. if (is_free($symlink) && @symlink($target, $symlink)) {
  248. $notice = buildphrase('&quot;<b>' . htmlentities($symlink) . '</b>&quot;', $words['created']);
  249. } else {
  250. $error = buildphrase('&quot;<b>' . htmlentities($symlink) . '</b>&quot;', $words['notcreated']);
  251. }
  252. }
  253. }
  254.  
  255. /* Delete file */
  256. if (!empty($_GET['delete'])) {
  257. $delete = relpathtoabspath($_GET['delete'], $_SESSION['dir']);
  258. if (@$_GET['sure'] == 'TRUE') {
  259. if (remove($delete)) {
  260. $notice = buildphrase('&quot;<b>' . htmlentities($delete) . '</b>&quot;', $words['deleted']);
  261. } else {
  262. $error = buildphrase('&quot;<b>' . htmlentities($delete) . '</b>&quot;', $words['notdeleted']);
  263. }
  264. } else {
  265. html_header($words['delete']);
  266. ?>
  267. <p>
  268. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  269. <table border="0" cellspacing="1" cellpadding="4">
  270. <tr>
  271. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  272. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  273. </tr>
  274. <tr>
  275. <td colspan="2" bgcolor="#FFFFFF"><?php echo(buildphrase('&quot;<b>' . htmlentities($delete) . '</b>&quot;', $words['suredelete'])); ?></td>
  276. </tr>
  277. <tr>
  278. <td colspan="2" align="center" bgcolor="#EEEEEE">
  279. <a href="<?php echo("$self?" . SID . '&delete=' . urlencode($delete) . '&sure=TRUE'); ?>">[ <?php echo($words['yes']); ?> ]</a>
  280. </td>
  281. </tr>
  282. </table>
  283. </td></tr></table>
  284. </p>
  285. <?php
  286. html_footer();
  287. exit;
  288. }
  289. }
  290.  
  291. /* Change permission */
  292. if (!empty($_GET['permission'])) {
  293. $permission = relpathtoabspath($_GET['permission'], $_SESSION['dir']);
  294. if ($p = @fileperms($permission)) {
  295. if (!empty($_GET['set'])) {
  296. $p = 0;
  297. if (isset($_GET['ur'])) $p |= 0400; if (isset($_GET['uw'])) $p |= 0200; if (isset($_GET['ux'])) $p |= 0100;
  298. if (isset($_GET['gr'])) $p |= 0040; if (isset($_GET['gw'])) $p |= 0020; if (isset($_GET['gx'])) $p |= 0010;
  299. if (isset($_GET['or'])) $p |= 0004; if (isset($_GET['ow'])) $p |= 0002; if (isset($_GET['ox'])) $p |= 0001;
  300. if (@chmod($_GET['permission'], $p)) {
  301. $notice = buildphrase(array('&quot<b>' . htmlentities($permission) . '</b>&quot;', '&quot;<b>' . substr(octtostr("0$p"), 1) . '</b>&quot; (<b>' . decoct($p) . '</b>)'), $words['permsset']);
  302. } else {
  303. $error = buildphrase('&quot;<b>' . htmlentities($permission) . '</b>&quot;', $words['permsnotset']);
  304. }
  305. } else {
  306. html_header($words['permission']);
  307. ?>
  308. <form action="<?php echo($self); ?>" method="get">
  309. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  310. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  311. <table border="0" cellspacing="1" cellpadding="4">
  312. <tr>
  313. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  314. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  315. </tr>
  316. <tr>
  317. <td bgcolor="#EEEEEE" colspan="2">
  318. <table>
  319. <tr>
  320. <td><?php echo($words['file']); ?>:</td>
  321. <td><input type="text" name="permission" value="<?php echo(htmlentities($permission)); ?>" size="<?php echo(textfieldsize($permission)); ?>"></td>
  322. <td><input type="submit" value="<?php echo($words['change']); ?>"></td>
  323. </tr>
  324. <tr>
  325. <td valign="top">
  326. <?php echo($words['permission']); ?>:&nbsp;
  327. </form><form action="<?php echo($self); ?>" method="get">
  328. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  329. <input type="hidden" name="permission" value="<?php echo(htmlentities($permission)); ?>">
  330. <input type="hidden" name="set" value="TRUE">
  331. </td>
  332. <td colspan="2">
  333. <table border="0">
  334. <tr>
  335. <td>&nbsp;</td>
  336. <td><?php echo($words['owner']); ?></td>
  337. <td><?php echo($words['group']); ?></td>
  338. <td><?php echo($words['other']); ?></td>
  339. </tr>
  340. <tr>
  341. <td><?php echo($words['read']); ?>:</td>
  342. <td align="center"><input type="checkbox" name="ur" value="1"<?php if ($p & 00400) echo(' checked'); ?>></td>
  343. <td align="center"><input type="checkbox" name="gr" value="1"<?php if ($p & 00040) echo(' checked'); ?>></td>
  344. <td align="center"><input type="checkbox" name="or" value="1"<?php if ($p & 00004) echo(' checked'); ?>></td>
  345. </tr>
  346. <tr>
  347. <td><?php echo($words['write']); ?>:</td>
  348. <td align="center"><input type="checkbox" name="uw" value="1"<?php if ($p & 00200) echo(' checked'); ?>></td>
  349. <td align="center"><input type="checkbox" name="gw" value="1"<?php if ($p & 00020) echo(' checked'); ?>></td>
  350. <td align="center"><input type="checkbox" name="ow" value="1"<?php if ($p & 00002) echo(' checked'); ?>></td>
  351. </tr>
  352. <tr>
  353. <td><?php echo($words['exec']); ?>:</td>
  354. <td align="center"><input type="checkbox" name="ux" value="1"<?php if ($p & 00100) echo(' checked'); ?>></td>
  355. <td align="center"><input type="checkbox" name="gx" value="1"<?php if ($p & 00010) echo(' checked'); ?>></td>
  356. <td align="center"><input type="checkbox" name="ox" value="1"<?php if ($p & 00001) echo(' checked'); ?>></td>
  357. </tr>
  358. </table>
  359. </td>
  360. </tr>
  361. <tr>
  362. <td>&nbsp;</td>
  363. <td colspan="2"><input type="submit" value="<?php echo($words['setperms']); ?>"></td>
  364. </tr>
  365. </table>
  366. </td>
  367. </tr>
  368. </table>
  369. </td></tr></table>
  370. </form>
  371. <?php
  372. html_footer();
  373. exit;
  374. }
  375. } else {
  376. $error = buildphrase('&quot;<b>' . htmlentities($permission) . '</b>&quot;', $words['permsnotset']);
  377. }
  378. }
  379.  
  380. /* Move file */
  381. if (!empty($_GET['move'])) {
  382. $move = relpathtoabspath($_GET['move'], $_SESSION['dir']);
  383. if (!empty($_GET['destination'])) {
  384. $destination = relpathtoabspath($_GET['destination'], dirname($move));
  385. if (@is_dir($destination)) $destination = spath($destination) . basename($move);
  386. if ($move == $destination) {
  387. $error = buildphrase(array('&quot;<b>' . htmlentities($move) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['samefiles']);
  388. } else {
  389. if (is_free($destination) && @rename($move, $destination)) {
  390. $notice = buildphrase(array('&quot;<b>' . htmlentities($move) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['moved']);
  391. } else {
  392. $error = buildphrase(array('&quot;<b>' . htmlentities($move) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['notmoved']);
  393. }
  394. }
  395. } else {
  396. html_header($words['move']);
  397. ?>
  398. <form action="<?php echo($self); ?>" method="get">
  399. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  400. <input type="hidden" name="move" value="<?php echo(htmlentities($move)); ?>">
  401. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  402. <table border="0" cellspacing="1" cellpadding="4">
  403. <tr>
  404. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  405. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  406. </tr>
  407. <tr>
  408. <td colspan="2" bgcolor="#EEEEEE">
  409. <table border="0">
  410. <tr>
  411. <td><?php echo($words['file']); ?>:&nbsp;</td>
  412. <td><b><?php echo(htmlentities($move)); ?></b></td>
  413. </tr>
  414. <tr>
  415. <td><?php echo($words['moveto']); ?>:&nbsp;</td>
  416. <td><input type="text" name="destination" value="<?php echo(htmlentities(spath(dirname($move)))); ?>" size="<?php echo(textfieldsize($move)); ?>"></td>
  417. </tr>
  418. <tr>
  419. <td>&nbsp;</td>
  420. <td><input type="submit" value="<?php echo($words['move']); ?>"></td>
  421. </tr>
  422. </table>
  423. </td>
  424. </tr>
  425. </table>
  426. </td></tr></table>
  427. </form>
  428. <?php
  429. html_footer();
  430. exit;
  431. }
  432. }
  433.  
  434. /* Copy file */
  435. if (!empty($_GET['cpy'])) {
  436. $copy = relpathtoabspath($_GET['cpy'], $_SESSION['dir']);
  437. if (!empty($_GET['destination'])) {
  438. $destination = relpathtoabspath($_GET['destination'], dirname($copy));
  439. if (@is_dir($destination)) $destination = spath($destination) . basename($copy);
  440. if ($copy == $destination) {
  441. $error = buildphrase(array('&quot;<b>' . htmlentities($copy) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['samefiles']);
  442. } else {
  443. if (is_free($destination) && @copy($copy, $destination)) {
  444. $notice = buildphrase(array('&quot;<b>' . htmlentities($copy) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['copied']);
  445. } else {
  446. $error = buildphrase(array('&quot;<b>' . htmlentities($copy) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['notcopied']);
  447. }
  448. }
  449. } else {
  450. html_header($words['copy']);
  451. ?>
  452. <form action="<?php echo($self); ?>" method="get">
  453. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  454. <input type="hidden" name="cpy" value="<?php echo(htmlentities($copy)); ?>">
  455. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  456. <table border="0" cellspacing="1" cellpadding="4">
  457. <tr>
  458. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  459. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  460. </tr>
  461. <tr>
  462. <td colspan="2" bgcolor="#EEEEEE">
  463. <table border="0">
  464. <tr>
  465. <td><?php echo($words['file']); ?>:&nbsp;</td>
  466. <td><b><?php echo(htmlentities($copy)); ?></b></td>
  467. </tr>
  468. <tr>
  469. <td><?php echo($words['copyto']); ?>:&nbsp;</td>
  470. <td><input type="text" name="destination" value="<?php echo(htmlentities(spath(dirname($copy)))); ?>" size="<?php echo(textfieldsize($copy)); ?>"></td>
  471. </tr>
  472. <tr>
  473. <td>&nbsp;</td>
  474. <td><input type="submit" value="<?php echo($words['copy']); ?>"></td>
  475. </tr>
  476. </table>
  477. </td>
  478. </tr>
  479. </table>
  480. </td></tr></table>
  481. </form>
  482. <?php
  483. html_footer();
  484. exit;
  485. }
  486. }
  487.  
  488. /* Save edited file */
  489. if (!empty($_POST['edit']) && isset($_POST['save'])) {
  490. $edit = relpathtoabspath($_POST['edit'], $_SESSION['dir']);
  491. if ($f = @fopen($edit, 'w')) {
  492. /* write file without carriage returns */
  493. fwrite($f, str_replace("\r\n", "\n", $_POST['content']));
  494. fclose($f);
  495. $notice = buildphrase('&quot;<b>' . htmlentities($edit) . '</b>&quot;', $words['saved']);
  496. } else {
  497. $error = buildphrase('&quot;<b>' . htmlentities($edit) . '</b>&quot;', $words['notsaved']);
  498. }
  499. }
  500.  
  501. /* Edit file */
  502. if (isset($_REQUEST['edit']) && !isset($_POST['save'])) {
  503. $file = relpathtoabspath($_REQUEST['edit'], $_SESSION['dir']);
  504. if (@is_dir($file)) {
  505. /* If the requested file is a directory, show the directory */
  506. $_SESSION['dir'] = $file;
  507. $updatetreeview = TRUE;
  508. } else {
  509. if ($f = @fopen($file, 'r')) {
  510. html_header($words['edit']);
  511. ?>
  512. <form action="<?php echo($self); ?>" method="get">
  513. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  514. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  515. <table border="0" cellspacing="1" cellpadding="4">
  516. <tr>
  517. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  518. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  519. </tr>
  520. <tr>
  521. <td bgcolor="#EEEEEE" colspan="2">
  522. <table border="0" cellspacing="0" cellpadding="0">
  523. <tr>
  524. <td><?php echo($words['file']); ?>:&nbsp;</td>
  525. <td><input type="text" name="edit" value="<?php echo(htmlentities($file)); ?>" size="<?php echo(textfieldsize($file)); ?>">&nbsp;</td>
  526. <td><input type="submit" value="<?php echo($words['change']); ?>"></td>
  527. </tr>
  528. </table>
  529. </td>
  530. </tr>
  531. </table>
  532. </td></tr></table>
  533. </form>
  534. <form action="<?php echo($self); ?>" method="post" name="f">
  535. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  536. <input type="hidden" name="edit" value="<?php echo(htmlentities($file)); ?>">
  537. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  538. <table border="0" cellspacing="1" cellpadding="4">
  539. <tr>
  540. <td bgcolor="#EEEEFF" align="center"><textarea name="content" rows="<?php echo($editrows); ?>" cols="<?php echo($editcols); ?>" wrap="off" style="background: #EEEEFF; border: none;"><?php
  541. if (isset($_POST['content'])) {
  542. echo(htmlentities($_POST['content']));
  543. if (isset($_POST['add']) && !empty($_POST['username']) && !empty($_POST['password'])) {
  544. echo("\n" . htmlentities($_POST['username'] . ':' . crypt($_POST['password'])));
  545. }
  546. } else {
  547. echo(htmlentities(fread($f, filesize($file))));
  548. }
  549. fclose($f);
  550. ?></textarea></td>
  551. </tr>
  552. <?php if (basename($file) == '.htpasswd') { /* specials with .htpasswd */ ?>
  553. <tr>
  554. <td bgcolor="#EEEEEE" align="center">
  555. <table border="0">
  556. <tr>
  557. <td><?php echo($words['username']); ?>:&nbsp;</td>
  558. <td><input type="text" name="username" size="15">&nbsp;</td>
  559. <td><?php echo($words['password']); ?>:&nbsp;</td>
  560. <td><input type="password" name="password" size="15">&nbsp;</td>
  561. <td><input type="submit" name="add" value="<?php echo($words['add']); ?>"></td>
  562. </tr>
  563. </table>
  564. </td>
  565. </tr>
  566. <?php } if (basename($file) == '.htaccess') { /* specials with .htaccess */ ?>
  567. <tr>
  568. <td bgcolor="#EEEEEE" align="center"><input type="button" value="<?php echo($words['addauth']); ?>" onClick="autheinf()"></td>
  569. </tr>
  570. <?php } ?>
  571. <tr>
  572. <td bgcolor="#EEEEEE" align="center">
  573. <input type="button" value="<?php echo($words['reset']); ?>" onClick="document.f.reset()">
  574. <input type="button" value="<?php echo($words['clear']); ?>" onClick="void(document.f.content.value='')">
  575. <input type="submit" name="save" value="<?php echo($words['save']); ?>">
  576. </td>
  577. </tr>
  578. </table>
  579. </td></tr></table>
  580. </form>
  581. <?php
  582. html_footer();
  583. exit;
  584. } else {
  585. $error = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot; ', $words['notopened']);
  586. }
  587. }
  588. }
  589.  
  590. /* Show directory listing (and treeview) */
  591. if (!empty($_SESSION['tree'])) {
  592. if (isset($_REQUEST['frame']) && $_REQUEST['frame'] == 'treeview') {
  593. treeview();
  594. } else {
  595. if (isset($_GET['noupdate'])) $updatetreeview = FALSE;
  596. dirlisting(TRUE);
  597. }
  598. } else {
  599. dirlisting();
  600. }
  601.  
  602. /* ------------------------------------------------------------------------- */
  603.  
  604. function strip (&$str) {
  605. $str = stripslashes($str);
  606. }
  607.  
  608. function relpathtoabspath ($file, $dir) {
  609. $dir = spath($dir);
  610. if (substr($file, 0, 1) != '/') $file = $dir . $file;
  611. if (!@is_link($file) && ($r = realpath($file)) != FALSE) $file = $r;
  612. if (@is_dir($file) && !@is_link($file)) $file = spath($file);
  613. return $file;
  614. }
  615.  
  616. function abspathtorelpath ($pos, $target) {
  617. $pos = spath($pos);
  618. $path = '';
  619. while ($pos != $target) {
  620. if ($pos == substr($target, 0, strlen($pos))) {
  621. $path .= substr($target, strlen($pos));
  622. break;
  623. } else {
  624. $path .= '../';
  625. $pos = strrev(strstr(strrev(substr($pos, 0, strlen($pos) - 1)), '/'));
  626. }
  627. }
  628. return $path;
  629. }
  630.  
  631. function is_script ($file) {
  632. return ereg('.php[3-4]?$', $file);
  633. }
  634.  
  635. function spath ($path) {
  636. if (substr($path, strlen($path) - 1, 1) != '/') $path .= '/';
  637. return $path;
  638. }
  639.  
  640. function textfieldsize ($str) {
  641. $size = strlen($str) + 5;
  642. if ($size < 30) $size = 30;
  643. return $size;
  644. }
  645.  
  646. function is_free ($file) {
  647. global $words;
  648. if (@file_exists($file) && empty($_GET['overwrite'])) {
  649. html_header($words['alreadyexists']);
  650. ?>
  651. <p>
  652. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  653. <table border="0" cellspacing="1" cellpadding="4">
  654. <tr>
  655. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  656. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  657. </tr>
  658. <tr>
  659. <td colspan="2" bgcolor="#FFFFFF"><?php echo(buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['overwrite'])); ?></td>
  660. </tr>
  661. <tr>
  662. <td colspan="2" align="center" bgcolor="#EEEEEE">
  663. <a href="<?php echo("{$_SERVER['REQUEST_URI']}&overwrite=yes"); ?>">[ <?php echo($words['yes']); ?> ]</a>
  664. </td>
  665. </tr>
  666. </table>
  667. </td></tr></table>
  668. </p>
  669. <?php
  670. html_footer();
  671. exit;
  672. }
  673. if (!empty($_GET['overwrite'])) {
  674. return remove($file);
  675. }
  676. return TRUE;
  677. }
  678.  
  679. function remove ($file) {
  680. global $updatetreeview;
  681. if (@is_dir($file) && !@is_link($file)) {
  682. $error = FALSE;
  683. if ($p = @opendir($file = spath($file))) {
  684. while (($f = readdir($p)) !== FALSE)
  685. if ($f != '.' && $f != '..' && !remove($file . $f))
  686. $error = TRUE;
  687. }
  688. if ($error) $x = FALSE; else $x = @rmdir($file);
  689. $updatetreeview = TRUE;
  690. if ($x && !empty($_SESSION['tree'])) {
  691. $file = spath(dirname($file));
  692. $_SESSION['hassubdirs'][$file] = tree_hassubdirs($file);
  693. tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $file, TRUE);
  694. }
  695. } else {
  696. $x = @unlink($file);
  697. }
  698. return $x;
  699. }
  700.  
  701. function getwords ($language) {
  702. switch ($language) {
  703. case 'de':
  704. $words['dir'] = 'Verzeichnis'; $words['file'] = 'Datei';
  705. $words['filename'] = 'Dateiname'; $words['size'] = 'Gr&ouml;&szlig;e'; $words['permission'] = 'Rechte'; $words['functions'] = 'Funktionen';
  706. $words['owner'] = 'Eigner'; $words['group'] = 'Gruppe'; $words['other'] = 'Andere';
  707. $words['create'] = 'erstellen'; $words['copy'] = 'kopieren'; $words['copyto'] = 'kopieren nach'; $words['move'] = 'verschieben'; $words['moveto'] = 'verschieben nach'; $words['delete'] = 'l&ouml;schen'; $words['edit'] = 'editieren';
  708. $words['read'] = 'lesen'; $words['write'] = 'schreiben'; $words['exec'] = 'ausf&uuml;hren'; $words['change'] = 'wechseln'; $words['upload'] = 'hochladen'; $words['configure'] = 'konfigurieren';
  709. $words['yes'] = 'ja'; $words['no'] = 'nein';
  710. $words['back'] = 'zur&uuml;ck'; $words['setperms'] = 'Rechte setzen';
  711. $words['readingerror'] = 'Fehler beim Lesen von 1';
  712. $words['permsset'] = 'Die Rechte von 1 wurden auf 2 gesetzt.'; $words['permsnotset'] = 'Die Rechte von 1 konnten nicht gesetzt werden.';
  713. $words['uploaded'] = '1 wurde nach 2 hochgeladen.'; $words['notuploaded'] = '1 konnte nicht nach 2 hochgeladen werden.';
  714. $words['moved'] = '1 wurde nach 2 verschoben.'; $words['notmoved'] = '1 konnte nicht nach 2 verschoben werden.';
  715. $words['copied'] = '1 wurde nach 2 kopiert.'; $words['notcopied'] = '1 konnte nicht nach 2 kopiert werden.';
  716. $words['created'] = '1 wurde erstellt.'; $words['notcreated'] = '1 konnte nicht erstellt werden.';
  717. $words['deleted'] = '1 wurde gel&ouml;scht.'; $words['notdeleted'] = '1 konnte nicht gel&ouml;scht werden.'; $words['suredelete'] = '1 wirklich l&ouml;schen?';
  718. $words['saved'] = '1 wurde gespeichert.'; $words['notsaved'] = '1 konnte nicht gespeichert werden.';
  719. $words['reset'] = 'zur&uuml;cksetzen'; $words['clear'] = 'verwerfen'; $words['save'] = 'speichern';
  720. $words['cantbeshown'] = '1 kann nicht angezeigt werden.'; $words['sourceof'] = 'Quelltext von 1';
  721. $words['notopened'] = '1 konnte nicht ge&ouml;ffnet werden.';
  722. $words['addauth'] = 'Standard-Authentifizierungseinstellungen hinzuf&uuml;gen';
  723. $words['username'] = 'Benutzername'; $words['password'] = 'Kennwort'; $words['add'] = 'hinzuf&uuml;gen';
  724. $words['treeon'] = 'Baumansicht aktivieren'; $words['treeoff'] = 'Baumansicht deaktivieren';
  725. $words['symlink'] = 'Symbolischer Link'; $words['createsymlink'] = 'Link erstellen'; $words['target'] = 'Ziel';
  726. $words['reltarget'] = 'Relative Pfadangabe des Ziels';
  727. $words['alreadyexists'] = 'Die Datei existiert bereits.';
  728. $words['overwrite'] = 'Soll 1 &uuml;berschrieben werden?';
  729. $words['samefiles'] = '1 und 2 sind identisch.';
  730. break;
  731. case 'cz':
  732. $words['dir'] = 'Adres&#xE1;&#x0159;'; $words['file'] = 'Soubor';
  733. $words['filename'] = 'Jm&#xE9;no souboru'; $words['size'] = 'Velikost'; $words['permission'] = 'Pr&#xE1;va'; $words['functions'] = 'Functions';
  734. $words['owner'] = 'Vlastn&#xED;k'; $words['group'] = 'Skupina'; $words['other'] = 'Ostatn&#xED;';
  735. $words['create'] = 'vytvo&#x0159;it'; $words['copy'] = 'kop&#xED;rovat'; $words['copyto'] = 'kop&#xED;rovat do'; $words['move'] = 'p&#x0159;esunout'; $words['moveto'] = 'p&#x0159;esunout do'; $words['delete'] = 'odstranit'; $words['edit'] = '&#xFA;pravy';
  736. $words['read'] = '&#x010D;ten&#xED;'; $words['write'] = 'z&#xE1;pis'; $words['exec'] = 'spu&#x0161;t&#x011B;n&#xED;'; $words['change'] = 'zm&#x011B;nit'; $words['upload'] = 'nahr&#xE1;t'; $words['configure'] = 'nastaven&#xED;';
  737. $words['yes'] = 'ano'; $words['no'] = 'ne';
  738. $words['back'] = 'zp&#xE1;tky'; $words['setperms'] = 'nastav pr&#xE1;va';
  739. $words['readingerror'] = 'Chyba p&#x0159;i &#x010D;ten&#xED; 1';
  740. $words['permsset'] = 'P&#x0159;&#xED;stupov&#xE1; pr&#xE1;va k 1 byla nastavena na 2.'; $words['permsnotset'] = 'P&#x0159;&#xED;stupov&#xE1; pr&#xE1;va k 1 nelze nastavit na 2.';
  741. $words['uploaded'] = 'Soubor 1 byl ulo&#x017E;en do adres&#xE1;&#x0159;e 2.'; $words['notuploaded'] = 'Chyba p&#x0159;i ukl&#xE1;d&#xE1;n&#xED; souboru 1 do adres&#xE1;&#x0159;e 2.';
  742. $words['moved'] = 'Soubor 1 byl p&#x0159;esunut do adres&#xE1;&#x0159;e 2.'; $words['notmoved'] = 'Soubor 1 nelze p&#x0159;esunout do adres&#xE1;&#x0159;e 2.';
  743. $words['copied'] = 'Soubor 1 byl zkop&#xED;rov&#xE1;n do adres&#xE1;&#x0159;e 2.'; $words['notcopied'] = 'Soubor 1 nelze zkop&#xED;rovat do adres&#xE1;&#x0159;e 2.';
  744. $words['created'] = '1 byl vytvo&#x0159;en.'; $words['notcreated'] = '1 nelze vytvo&#x0159;it.';
  745. $words['deleted'] = '1 byl vymaz&#xE1;n.'; $words['notdeleted'] = '1 nelze vymazat.'; $words['suredelete'] = 'Skute&#x010D;n&#x011B; smazat 1?';
  746. $words['saved'] = 'Soubor 1 byl ulo&#x017E;en.'; $words['notsaved'] = 'Soubor 1 nelze ulo&#x017E;it.';
  747. $words['reset'] = 'zp&#x011B;t'; $words['clear'] = 'vy&#x010D;istit'; $words['save'] = 'ulo&#x017E;';
  748. $words['cantbeshown'] = "1 can't be shown."; $words['sourceof'] = 'source of 1';
  749. $words['notopened'] = "1 nelze otev&#x0159;&#xED;t";
  750. $words['addauth'] = 'p&#x0159;idat z&#xE1;kladn&#xED;-authentifikaci';
  751. $words['username'] = 'U&#x017E;ivatelsk&#xE9; jm&#xE9;no'; $words['password'] = 'Heslo'; $words['add'] = 'p&#x0159;idat';
  752. $words['treeon'] = 'Zobraz strom adres&#xE1;&#x0159;&#x016F;'; $words['treeoff'] = 'Skryj strom adres&#xE1;&#x0159;&#x016F;';
  753. $words['symlink'] = 'Symbolick&#xFD; odkaz'; $words['createsymlink'] = 'vytvo&#x0159;it odkaz'; $words['target'] = 'C&#xED;l';
  754. $words['reltarget'] = 'Relativni cesta k c&#xED;li';
  755. $words['alreadyexists'] = 'Tento soubor u&#x017E; existuje.';
  756. $words['overwrite'] = 'P&#x0159;epsat 1?';
  757. $words['samefiles'] = '1 a 2 jsou identick&#xE9;l.';
  758. break;
  759. case 'it':
  760. $words['dir'] = 'Directory'; $words['file'] = 'File';
  761. $words['filename'] = 'Nome file'; $words['size'] = 'Dimensioni'; $words['permission'] = 'Permessi'; $words['functions'] = 'Funzioni';
  762. $words['owner'] = 'Proprietario'; $words['group'] = 'Gruppo'; $words['other'] = 'Altro';
  763. $words['create'] = 'crea'; $words['copy'] = 'copia'; $words['copyto'] = 'copia su'; $words['move'] = 'muovi'; $words['moveto'] = 'muove su'; $words['delete'] = 'delete'; $words['edit'] = 'edit';
  764. $words['read'] = 'leggi'; $words['write'] = 'scrivi'; $words['exec'] = 'esegui'; $words['change'] = 'modifica'; $words['upload'] = 'upload'; $words['configure'] = 'configura';
  765. $words['yes'] = 'si'; $words['no'] = 'no';
  766. $words['back'] = 'back'; $words['setperms'] = 'imposta permessi';
  767. $words['readingerror'] = 'Errore durante la lettura di 1';
  768. $words['permsset'] = 'I permessi di 1 sono stati impostati a 2.'; $words['permsnotset'] = 'I permessi di 1 non possono essere impostati.';
  769. $words['uploaded'] = '1 и stato uploadato su 2.'; $words['notuploaded'] = 'Errore durante l\'upload di 1 su 2.';
  770. $words['moved'] = '1 и stato spostato su 2.'; $words['notmoved'] = '1 non puт essere spostato su 2.';
  771. $words['copied'] = '1 и stato copiato su 2.'; $words['notcopied'] = '1 non puт essere copiato su 2.';
  772. $words['created'] = '1 и stato creato.'; $words['notcreated'] = 'impossibile creare 1.';
  773. $words['deleted'] = '1 и stato eliminato.'; $words['notdeleted'] = 'Impossibile eliminare 1.'; $words['suredelete'] = 'Confermi eliminazione di 1?';
  774. $words['saved'] = '1 и stato salvato.'; $words['notsaved'] = 'Impossibile salvare 1.';
  775. $words['reset'] = 'reimposta'; $words['clear'] = 'pulisci'; $words['save'] = 'salva';
  776. $words['cantbeshown'] = "Impossibile visualizzare 1."; $words['sourceof'] = 'sorgente di 1';
  777. $words['notopened'] = "Impossibile aprire 1";
  778. $words['addauth'] = 'aggiunge autenticazione di base';
  779. $words['username'] = 'Nome Utente'; $words['password'] = 'Password'; $words['add'] = 'add';
  780. $words['treeon'] = 'Abilita vista ad albero'; $words['treeoff'] = 'Disabilita vista ad albero';
  781. $words['symlink'] = 'Link simbolico'; $words['createsymlink'] = 'crea symlink'; $words['target'] = 'Target';
  782. $words['reltarget'] = 'Percorso relativo al target';
  783. $words['alreadyexists'] = 'Questo file esiste giа.';
  784. $words['overwrite'] = 'Sovrascrivi 1?';
  785. $words['samefiles'] = '1 e 2 sono identici.';
  786. break;
  787. case 'en':
  788. default:
  789. $words['dir'] = 'Directory'; $words['file'] = 'File';
  790. $words['filename'] = 'Filename'; $words['size'] = 'Size'; $words['permission'] = 'Permission'; $words['functions'] = 'Functions';
  791. $words['owner'] = 'Owner'; $words['group'] = 'Group'; $words['other'] = 'Other';
  792. $words['create'] = 'create'; $words['copy'] = 'copy'; $words['copyto'] = 'copy to'; $words['move'] = 'move'; $words['moveto'] = 'move to'; $words['delete'] = 'delete'; $words['edit'] = 'edit';
  793. $words['read'] = 'read'; $words['write'] = 'write'; $words['exec'] = 'execute'; $words['change'] = 'change'; $words['upload'] = 'upload'; $words['configure'] = 'configure';
  794. $words['yes'] = 'yes'; $words['no'] = 'no';
  795. $words['back'] = 'back'; $words['setperms'] = 'set permission';
  796. $words['readingerror'] = 'Error during read of 1';
  797. $words['permsset'] = 'The permission of 1 were set to 2.'; $words['permsnotset'] = 'The permission of 1 could not be set.';
  798. $words['uploaded'] = '1 has been uploaded to 2.'; $words['notuploaded'] = 'Error during upload of 1 to 2.';
  799. $words['moved'] = '1 has been moved to 2.'; $words['notmoved'] = '1 could not be moved to 2.';
  800. $words['copied'] = '1 has been copied to 2.'; $words['notcopied'] = '1 could not be copied to 2.';
  801. $words['created'] = '1 has been created.'; $words['notcreated'] = '1 could not be created.';
  802. $words['deleted'] = '1 has been deleted.'; $words['notdeleted'] = '1 could not be deleted.'; $words['suredelete'] = 'Really delete 1?';
  803. $words['saved'] = '1 has been saved.'; $words['notsaved'] = '1 could not be saved.';
  804. $words['reset'] = 'reset'; $words['clear'] = 'clear'; $words['save'] = 'save';
  805. $words['cantbeshown'] = "1 can't be shown."; $words['sourceof'] = 'source of 1';
  806. $words['notopened'] = "1 couldn't be opened";
  807. $words['addauth'] = 'add basic-authentification';
  808. $words['username'] = 'Username'; $words['password'] = 'Password'; $words['add'] = 'add';
  809. $words['treeon'] = 'Enable treeview'; $words['treeoff'] = 'Disable treeview';
  810. $words['symlink'] = 'Symbolic link'; $words['createsymlink'] = 'create link'; $words['target'] = 'Target';
  811. $words['reltarget'] = 'Relative path to target';
  812. $words['alreadyexists'] = 'This file already exists.';
  813. $words['overwrite'] = 'Overwrite 1?';
  814. $words['samefiles'] = '1 and 2 are identical.';
  815. }
  816. return $words;
  817. }
  818.  
  819. function getimage ($iid) {
  820. $image = 'GIF89a';
  821. switch ($iid) {
  822. case 1: $image .= "\23\0\22\0\242\4\0\0\0\0\377\377\377\314\314\314\231\231\231\377\377\377\0\0\0\0\0\0\0\0\0!\371\4\1\350\3\4\0,\0\0\0\0\23\0\22\0\0\3?H\272\334N \312\327@\270\30P%\273\237\213\205\215\244\240q\201\240\256\254:\234P\332\316o(\317l\215\342\255\36\363\71\230\5\270\362\15\211\2cr\300l:\231\60\310g\272\251Z\257\330l5\1\0;\0"; break;
  823. case 2: $image .= "\23\0\22\0\221\2\0\0\0\0\314\314\314\377\377\377\0\0\0!\371\4\1\350\3\2\0,\0\0\0\0\23\0\22\0\0\2\64\224\217\251\2\355\233@\230\24@#\251v\357d\15V^H\6\26fr\352\312\230ehI\337;\305\63}6\364\206\356\365\350\63!V\304\323\345\210L*\227\220\2\0;\0"; break;
  824. case 3: $image .= "\23\0\22\0\200\1\0\231\231\231\377\377\377!\371\4\1\350\3\1\0,\0\0\0\0\23\0\22\0\0\2\32\214o\200\313\355\255\236\234,\322+-\336K\363\357}[(^d9\235hP\0\0;\0"; break;
  825. case 4: $image .= "\23\0\22\0\221\3\0\231\231\231\377\377\377\0\0\0\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\23\0\22\0\0\2.\234\217\251\313\355\17\15\230\224:\20\262\16\340j\241u\15\226\201\231\310\140\302\272rC\207\36d\140\272\343\27z\333yUU\4\14\12\207DF\1\0;\0"; break;
  826. case 5: $image .= "\23\0\22\0\221\3\0\231\231\231\377\377\377\0\0\0\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\23\0\22\0\0\2*\234\217\251\313\355\17\15\230\224:\20\262\16\340n\335\65\330\307y\302y\226]\210\214\37\273\270\33\254\310\340UU\321\316\367\376\317(\0\0;\0"; break;
  827. case 6: $image .= "\23\0\22\0\200\1\0\231\231\231\377\377\377!\371\4\1\350\3\1\0,\0\0\0\0\23\0\22\0\0\2\33\214o\200\313\355\255\236\234,\322+-\336K\371\360q\224\46rd\211\235\350\270\76\5\0;\0"; break;
  828. case 7: $image .= "\23\0\22\0\221\3\0\231\231\231\377\377\377\0\0\0\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\23\0\22\0\0\2\60\234o\200\313\355\255\236\234\11\330k%\10\274\207\350l\234\320\201PGr\46\263\11\256\373\15\312*\243\245f\253\270\247?\330O\11\206\204\304a\221R\0\0;\0"; break;
  829. case 8: $image .= "\23\0\22\0\221\3\0\231\231\231\377\377\377\0\0\0\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\23\0\22\0\0\2/\234o\200\313\355\255\236\234\11\330k%\10\274\207\350l\36\7B#\251\5\302\272~\203R\46\247\373\210c\274\330\36\216\140\76\5\14\5\207B\42\245\0\0;\0"; break;
  830. case 9: $image .= "\23\0\22\0\200\1\0\231\231\231\377\377\377!\371\4\1\350\3\1\0,\0\0\0\0\23\0\22\0\0\2\30\214o\200\313\355\255\236\234,\322+-\336K\371\360q\342H\226\346\211r\5\0;\0"; break;
  831. case 10: $image .= "\23\0\22\0\221\3\0\231\231\231\377\377\377\0\0\0\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\23\0\22\0\0\2/\234o\200\313\355\255\236\234\11\330k%\10\274\207\350l\234\320\201PGr\46\263\11\256\373\15\312*\243\245f\253\270\247?\330O\11\12\207\304\242\260\0\0;\0"; break;
  832. case 11: $image .= "\23\0\22\0\221\3\0\231\231\231\377\377\377\0\0\0\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\23\0\22\0\0\2.\234o\200\313\355\255\236\234\11\330k%\10\274\207\350l\36\7B#\251\5\302\272~\203R\46\247\373\210c\274\330\36\216\140\76\5\14\12\207\304\140\1\0;\0"; break;
  833. case 12: $image .= "\21\0\15\0\221\3\0\231\231\231\377\377\377\0\0\0\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\21\0\15\0\0\2-\234\201\211\306\15\1\343j\354\211+\302\3\364D\231t\26\206i\342\207r\324Hf\252\203~o\25\264\227\271\306\322i\273\247\216s(\206\257\2\0;\0"; break;
  834. case 13: $image .= "\21\0\15\0\221\3\0\314\0\0\377\377\377\231\231\231\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\21\0\15\0\0\2-\234\201\211\306\15\1\343j\354\211+\302\3\364D\231t\26\206i\342\207r\324Hf\252\203~o\25\264\227\271\306\322i\273\247\216s(\206\257\2\0;\0"; break;
  835. case 14: $image .= "\21\0\15\0\242\4\0\231\231\231\377\377\377\0\0\0\314\0\0\377\377\377\0\0\0\0\0\0\0\0\0!\371\4\1\350\3\4\0,\0\0\0\0\21\0\15\0\0\3\71H\12\334\254\60\202@\353\213p\212-\302\4\330RYM8\15\3\305y\46\205\216,\204\316s\260\305\12M\217 6\5/[\247\47\1\246\140\304\314\210\63l\301,\46\207\224\230\0\0;\0"; break;
  836. case 15: $image .= "\21\0\15\0\221\3\0\231\231\231\377\377\377\314\314\314\377\377\377!\371\4\1\350\3\3\0,\0\0\0\0\21\0\15\0\0\2*\234\217\231\300\254\33b\4\317\264\213\235\225\274\13:\0\201@\226\46\11\212\347\372m\354\231\216o\31\317\264k\267a\216\36\331o(\0\0;\0"; break;
  837. case 16: $image .= "\21\0\15\0\221\2\0\0\0\0\377\377\0\377\377\377\0\0\0!\371\4\1\350\3\2\0,\0\0\0\0\21\0\15\0\0\2,\224\217\251\2\355\260\14\10\263\322\65\203\336\32\246\7\66_\325P\245x\224\34\207J\344vzi\7wJf\342\62\202\263\21\23\372\11\17\5\0;\0"; break;
  838. case 0:
  839. default: $image .= "\23\0\22\0\200\1\0\0\0\0\377\377\377!\371\4\1\350\3\1\0,\0\0\0\0\23\0\22\0\0\2\20\214\217\251\313\355\17\243\234\264\332\213\263\336\274\327\2\0;\0"; break;
  840. }
  841. return $image;
  842. }
  843.  
  844. function tree_hassubdirs ($path) {
  845. if ($p = @opendir($path)) {
  846. while (($filename = readdir($p)) !== FALSE) {
  847. if (tree_isrealdir($path . $filename)) return TRUE;
  848. }
  849. }
  850. return FALSE;
  851. }
  852.  
  853. function tree_isrealdir ($path) {
  854. if (basename($path) != '.' && basename($path) != '..' && @is_dir($path) && !@is_link($path)) return TRUE; else return FALSE;
  855. }
  856.  
  857. function treeview () {
  858. global $self, $treeroot;
  859. if (isset($_GET['plus'])) tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $_GET['plus']);
  860. if (isset($_GET['minus'])) $dirchanged = tree_minus($_SESSION['tree'], $_SESSION['hassubdirs'], $_GET['minus']); else $dirchanged = FALSE;
  861. for ($d = $_SESSION['dir']; strlen($d = dirname($d)) != 1; tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $d));
  862. ?>
  863. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  864. <html>
  865. <head>
  866. <title>Treeview</title>
  867. <style type="text/css">
  868. <!--
  869. td { font-family: sans-serif; font-size: 10pt; }
  870. a:link, a:visited, a:active { text-decoration: none; color: #000088; }
  871. a:hover { text-decoration: underline; color: #000088; }
  872. -->
  873. </style>
  874. </head>
  875. <body bgcolor="#FFFFFF"<?php if ($dirchanged) echo(" onLoad=\"void(parent.webadmin.location.replace('$self?noupdate=TRUE&dir=" . urlencode($_SESSION['dir']) . '&' . SID . '&pmru=' . time() . "'))\""); ?>>
  876. <table border="0" cellspacing="0" cellpadding="0">
  877. <?php
  878. tree_showtree($_SESSION['tree'], $_SESSION['hassubdirs'], $treeroot, 0, tree_calculatenumcols($_SESSION['tree'], $treeroot, 0));
  879. ?>
  880. </table>
  881. </body>
  882. </html>
  883. <?php
  884. return;
  885. }
  886.  
  887. function frameset () {
  888. global $self;
  889. ?>
  890. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Frameset//EN">
  891. <html>
  892. <head>
  893. <title><?php echo($self); ?></title>
  894. </head>
  895. <frameset cols="250,*">
  896. <frame src="<?php echo("$self?frame=treeview&" . SID . '#' . urlencode($_SESSION['dir'])); ?>" name="treeview">
  897. <frame src="<?php echo("$self?" . SID); ?>" name="webadmin">
  898. </frameset>
  899. </html>
  900. <?php
  901. return;
  902. }
  903.  
  904. function tree_calculatenumcols ($tree, $path, $col) {
  905. static $numcols = 0;
  906. if ($col > $numcols) $numcols = $col;
  907. if (isset($tree[$path])) {
  908. for ($i = 0; $i < sizeof($tree[$path]); $i++) {
  909. $numcols = tree_calculatenumcols($tree, $path . $tree[$path][$i], $col + 1);
  910. }
  911. }
  912. return $numcols;
  913. }
  914.  
  915. function tree_showtree ($tree, $hassubdirs, $path, $col, $numcols) {
  916. global $self, $treeroot;
  917. static $islast = array(0 => TRUE);
  918. echo(" <tr>\n");
  919. for ($i = 0; $i < $col; $i++) {
  920. if ($islast[$i]) $iid = 0; else $iid = 3;
  921. echo(" <td><img src=\"$self?imageid=$iid\" width=\"19\" height=\"18\"></td>\n");
  922. }
  923. if ($hassubdirs[$path]) {
  924. if (!empty($tree[$path])) { $action = 'minus'; $iid = 8; } else { $action = 'plus'; $iid = 7; }
  925. if ($col == 0) $iid -= 3; else if ($islast[$col]) $iid += 3;
  926. echo(" <td><a href=\"$self?frame=treeview&$action=" . urlencode($path) . '&dir=' . urlencode($_SESSION['dir']) . '&' . SID . '#' . urlencode($path) . '">');
  927. echo("<img src=\"$self?imageid=$iid\" width=\"19\" height=\"18\" border=\"0\">");
  928. echo("</a></td>\n");
  929. } else {
  930. if ($islast[$col]) $iid = 9; else $iid = 6;
  931. echo(" <td><img src=\"$self?imageid=$iid\" width=\"19\" height=\"18\"></td>\n");
  932. }
  933. if (@is_readable($path)) {
  934. $a1 = "<a name=\"" . urlencode($path) . "\" href=\"$self?dir=" . urlencode($path) . '&' . SID . '" target="webadmin">';
  935. $a2 = '</a>';
  936. } else {
  937. $a1 = $a2 = '';
  938. }
  939. if ($_SESSION['dir'] == $path) $iid = 2; else $iid = 1;
  940. echo(" <td>$a1<img src=\"$self?imageid=$iid\" width=\"19\" height=\"18\" border=\"0\">$a2</td>\n");
  941. $cspan = $numcols - $col + 1;
  942. if ($cspan > 1) $colspan = " colspan=\"$cspan\""; else $colspan = '';
  943. if ($col == $numcols) $width = ' width="100%"'; else $width = '';
  944. echo(" <td$width$colspan nowrap>&nbsp;");
  945. if ($path == $treeroot) $label = $path; else $label = basename($path);
  946. echo($a1 . htmlentities($label) . $a2);
  947. echo("</td>\n");
  948. echo(" </tr>\n");
  949. if (!empty($tree[$path])) {
  950. for ($i = 0; $i < sizeof($tree[$path]); $i++) {
  951. if (($i + 1) == sizeof($tree[$path])) $islast[$col + 1] = TRUE; else $islast[$col + 1] = FALSE;
  952. tree_showtree($tree, $hassubdirs, $path . $tree[$path][$i], $col + 1, $numcols);
  953. }
  954. }
  955. return;
  956. }
  957.  
  958. function tree_plus (&$tree, &$hassubdirs, $p) {
  959. if ($path = spath(realpath($p))) {
  960. $tree[$path] = tree_getsubdirs($path);
  961. for ($i = 0; $i < sizeof($tree[$path]); $i++) {
  962. $subdir = $path . $tree[$path][$i];
  963. if (empty($hassubdirs[$subdir])) $hassubdirs[$subdir] = tree_hassubdirs($subdir);
  964. }
  965. }
  966. return;
  967. }
  968.  
  969. function tree_minus (&$tree, &$hassubdirs, $p) {
  970. $dirchanged = FALSE;
  971. if ($path = spath(realpath($p))) {
  972. if (!empty($tree[$path])) {
  973. for ($i = 0; $i < sizeof($tree[$path]); $i++) {
  974. $subdir = $path . $tree[$path][$i] . '/';
  975. if (isset($hassubdirs[$subdir])) $hassubdirs[$subdir] = NULL;
  976. }
  977. $tree[$path] = NULL;
  978. if (substr($_SESSION['dir'], 0, strlen($path)) == $path) {
  979. $_SESSION['dir'] = $path;
  980. $dirchanged = TRUE;
  981. }
  982. }
  983. }
  984. return $dirchanged;
  985. }
  986.  
  987. function tree_getsubdirs ($path) {
  988. $subdirs = array();
  989. if ($p = @opendir($path)) {
  990. for ($i = 0; ($filename = readdir($p)) !== FALSE;) {
  991. if (tree_isrealdir($path . $filename)) $subdirs[$i++] = $filename . '/';
  992. }
  993. }
  994. sort($subdirs);
  995. return $subdirs;
  996. }
  997.  
  998. function show ($file) {
  999. global $words;
  1000. if (@is_readable($file) && @is_file($file)) {
  1001. header('Content-Disposition: filename=' . basename($file));
  1002. header('Content-Type: ' . getmimetype($file));
  1003. if (@readfile($file) !== FALSE) return TRUE;
  1004. }
  1005. return FALSE;
  1006. }
  1007.  
  1008. function show_highlight ($file) {
  1009. global $words;
  1010. if (@is_readable($file) && @is_file($file)) {
  1011. header('Content-Disposition: filename=' . basename($file));
  1012. echo("<html>\n<head><title>");
  1013. echo(buildphrase(array('&quot;' . htmlentities(basename($file)) . '&quot;'), $words['sourceof']));
  1014. echo("</title></head>\n<body>\n<table cellpadding=\"4\" border=\"0\">\n<tr>\n<td>\n<code style=\"color: #999999\">\n");
  1015. $size = sizeof(file($file));
  1016. for ($i = 1; $i <= $size; $i++) printf("%05d<br>\n", $i);
  1017. echo("</code>\n</td>\n<td nowrap>\n");
  1018. $shown = @highlight_file($file);
  1019. echo("\n");
  1020. echo("</td>\n</tr>\n</table>\n");
  1021. echo("</body>\n");
  1022. echo("</html>");
  1023. if ($shown) return TRUE;
  1024. }
  1025. return FALSE;
  1026. }
  1027.  
  1028. function getmimetype ($file) {
  1029. /* $mime = 'application/octet-stream'; */
  1030. $mime = 'text/plain';
  1031. $ext = substr($file, strrpos($file, '.') + 1);
  1032. if (@is_readable('/etc/mime.types')) {
  1033. $f = fopen('/etc/mime.types', 'r');
  1034. while (!feof($f)) {
  1035. $line = fgets($f, 4096);
  1036. $found = FALSE;
  1037. $mim = strtok($line," \n\t");
  1038. $ex = strtok(" \n\t");
  1039. while ($ex && !$found) {
  1040. if (strtolower($ex) == strtolower($ext)) {
  1041. $found = TRUE;
  1042. $mime = $mim;
  1043. break;
  1044. }
  1045. $ex = strtok(" \n\t");
  1046. }
  1047. if ($found) break;
  1048. }
  1049. fclose($f);
  1050. }
  1051. return $mime;
  1052. }
  1053.  
  1054. function dirlisting ($inaframe = FALSE) {
  1055. global $self, $homedir, $words;
  1056. global $error, $notice;
  1057. $p = '&' . SID;
  1058. html_header($_SESSION['dir']);
  1059. ?>
  1060. <form action="<?php echo($self); ?>" method="get">
  1061. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  1062. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  1063. <table border="0" cellspacing="1" cellpadding="4">
  1064. <tr>
  1065. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  1066. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  1067. </tr>
  1068. <tr>
  1069. <td bgcolor="#EEEEEE" colspan="2">
  1070. <table border="0" cellspacing="0" cellpadding="0">
  1071. <tr>
  1072. <td><?php echo("<a href=\"$self?dir=" . urlencode($homedir) . "$p\">" . $words['dir']); ?></a>:&nbsp;</td>
  1073. <td><input type="text" name="dir" value="<?php echo(htmlentities($_SESSION['dir'])); ?>" size="<?php echo(textfieldsize($_SESSION['dir'])); ?>">&nbsp;</td>
  1074. <td><input type="submit" value="<?php echo($words['change']); ?>"></td>
  1075. </tr>
  1076. </table>
  1077. </td>
  1078. </tr>
  1079. </table>
  1080. </td></tr></table>
  1081. </form>
  1082. <?php if (@is_writable($_SESSION['dir'])) { ?>
  1083. <form action="<?php echo($self); ?>" method="post" enctype="multipart/form-data">
  1084. <input type="hidden" name="dir" value="<?php echo(htmlentities($_SESSION['dir'])); ?>">
  1085. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  1086. <?php if (isset($_REQUEST['frame'])) { ?>
  1087. <input type="hidden" name="frame" value="<?php echo($_REQUEST['frame']); ?>">
  1088. <?php } ?>
  1089. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  1090. <table border="0" cellspacing="1" cellpadding="4">
  1091. <tr>
  1092. <td bgcolor="#EEEEEE">
  1093. <table border="0" cellspacing="0" cellpadding="0">
  1094. <tr>
  1095. <td><?php echo($words['file']); ?>&nbsp;</td>
  1096. <td><input type="file" name="upload">&nbsp;</td>
  1097. <td><input type="submit" value="<?php echo($words['upload']); ?>"></td>
  1098. </tr>
  1099. </table>
  1100. </td>
  1101. </tr>
  1102. <tr>
  1103. <td bgcolor="#EEEEEE">
  1104. </form>
  1105. <form action="<?php echo($self); ?>" method="get">
  1106. <input type="hidden" name="dir" value="<?php echo(htmlentities($_SESSION['dir'])); ?>">
  1107. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  1108. <?php if (isset($_REQUEST['frame'])) { ?>
  1109. <input type="hidden" name="frame" value="<?php echo($_REQUEST['frame']); ?>">
  1110. <?php } ?>
  1111. <table border="0" cellspacing="0" cellpadding="0">
  1112. <tr>
  1113. <td>
  1114. <select name="type" size="1">
  1115. <option value="file"><?php echo($words['file']); ?>
  1116.  
  1117. <option value="dir" selected><?php echo($words['dir']); ?>
  1118.  
  1119. </select>&nbsp;
  1120. </td>
  1121. <td><input type="text" name="create">&nbsp;</td>
  1122. <td><input type="submit" value="<?php echo($words['create']); ?>"></td>
  1123. </tr>
  1124. </table>
  1125. </td>
  1126. </tr>
  1127. </table>
  1128. </td></tr></table>
  1129. </form>
  1130. <?php
  1131. }
  1132. if (empty($_GET['sort'])) $sort = 'filename'; else $sort = $_GET['sort'];
  1133. $reverse = @$_GET['reverse'];
  1134. $GLOBALS['showsize'] = FALSE;
  1135. if ($files = dirtoarray($_SESSION['dir'])) {
  1136. $files = sortfiles($files, $sort, $reverse);
  1137. outputdirlisting($_SESSION['dir'], $files, $inaframe, $sort, $reverse);
  1138. } else {
  1139. perror(buildphrase('&quot;<b>' . htmlentities($_SESSION['dir']) . '</b>&quot', $words['readingerror']));
  1140. }
  1141. if ($inaframe) {
  1142. pnotice("<a href=\"$self?action=treeoff&" . SID . '" target="_top">' . $words['treeoff'] . '</a>');
  1143. } else {
  1144. pnotice("<a href=\"$self?action=treeon&" . SID . '" target="_top">' . $words['treeon'] . '</a>');
  1145. }
  1146. html_footer(FALSE);
  1147. return;
  1148. }
  1149.  
  1150. function dirtoarray ($dir) {
  1151. if ($dirstream = @opendir($dir)) {
  1152. for ($n = 0; ($filename = readdir($dirstream)) !== FALSE; $n++) {
  1153. $stat = @lstat($dir . $filename);
  1154. $files[$n]['filename'] = $filename;
  1155. $files[$n]['fullfilename'] = $fullfilename = relpathtoabspath($filename, $dir);
  1156. $files[$n]['is_file'] = @is_file($fullfilename);
  1157. $files[$n]['is_dir'] = @is_dir($fullfilename);
  1158. $files[$n]['is_link'] = $islink = @is_link($dir . $filename);
  1159. if ($islink) {
  1160. $files[$n]['readlink'] = @readlink($dir . $filename);
  1161. $files[$n]['linkinfo'] = linkinfo($dir . $filename);
  1162. }
  1163. $files[$n]['is_readable'] = @is_readable($fullfilename);
  1164. $files[$n]['is_writable'] = @is_writable($fullfilename);
  1165. $files[$n]['is_executable'] = @is_executable($fullfilename);
  1166. $files[$n]['permission'] = $islink ? 'lrwxrwxrwx' : octtostr(@fileperms($dir . $filename));
  1167. if (substr($files[$n]['permission'], 0, 1) != '-') {
  1168. $files[$n]['size'] = -1;
  1169. } else {
  1170. $files[$n]['size'] = @$stat['size'];
  1171. $GLOBALS['showsize'] = TRUE;
  1172. }
  1173. $files[$n]['owner'] = $owner = @$stat['uid'];
  1174. $files[$n]['group'] = $group = @$stat['gid'];
  1175. $files[$n]['ownername'] = @reset(posix_getpwuid($owner));
  1176. $files[$n]['groupname'] = @reset(posix_getgrgid($group));
  1177. }
  1178. closedir($dirstream);
  1179. return $files;
  1180. } else {
  1181. return FALSE;
  1182. }
  1183. }
  1184.  
  1185. function outputdirlisting ($dir, $files, $inaframe, $sort, $reverse) {
  1186. global $self, $words;
  1187. $uid = posix_getuid();
  1188. ?>
  1189. <p>
  1190. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  1191. <table border="0" cellspacing="1" cellpadding="4">
  1192. <?php
  1193. if ($inaframe) $p = '&notreeupdate=TRUE&'; $p = ''; $p .= SID . '&dir=' . urlencode($dir);
  1194. echo(" <tr>\n");
  1195. echo(" <td bgcolor=\"#EEEEEE\"><img src=\"$self?imageid=16\" width=\"17\" height=\"13\"></td>\n");
  1196. echo(" <td bgcolor=\"#EEEEEE\"><a href=\"$self?sort=filename&reverse=" . (($sort == 'filename') ? !$reverse : 0) . "&$p\"><b>{$words['filename']}</b></a></td>\n");
  1197. if ($GLOBALS['showsize']) echo(" <td bgcolor=\"#EEEEEE\" align=\"right\"><a href=\"$self?sort=size&reverse=" . (($sort == 'size') ? !$reverse : 0) . "&$p\"><b>{$words['size']}</b></a></td>\n");
  1198. echo(" <td bgcolor=\"#EEEEEE\"><a href=\"$self?sort=permission&reverse=" . (($sort == 'permission') ? !$reverse : 0) . "&$p\"><b>{$words['permission']}</b></a></td>\n");
  1199. echo(" <td bgcolor=\"#EEEEEE\"><a href=\"$self?sort=owner&reverse=" . (($sort == 'owner') ? !$reverse : 0) . "&$p\"><b>{$words['owner']}</b></a></td>\n");
  1200. echo(" <td bgcolor=\"#EEEEEE\"><a href=\"$self?sort=group&reverse=" . (($sort == 'group') ? !$reverse : 0) . "&$p\"><b>{$words['group']}</b></a></td>\n");
  1201. echo(" <td bgcolor=\"#EEEEEE\"><b>{$words['functions']}</b></td>\n");
  1202. echo(" </tr>\n");
  1203. $p = '&' . SID;
  1204. if ($GLOBALS['showsize']) $cspan = ' colspan="2"'; else $cspan = '';
  1205. foreach ($files as $file) {
  1206. echo(" <tr>\n");
  1207. if ($file['is_link']) {
  1208. echo(" <td bgcolor=\"#FFFFFF\" align=\"center\"><img src=\"$self?imageid=14\" width=\"17\" height=\"13\"></td>\n");
  1209. echo(" <td$cspan bgcolor=\"#FFFFFF\">");
  1210. if ($file['is_dir']) echo('[ ');
  1211. echo($file['filename']);
  1212. if ($file['is_dir']) echo(' ]');
  1213. echo(' -&gt; ');
  1214. if ($file['is_dir']) {
  1215. echo('[ ');
  1216. if ($file['is_readable']) echo("<a href=\"$self?dir=" . urlencode($file['readlink']) . "$p\">");
  1217. echo(htmlentities($file['readlink']));
  1218. if ($file['is_readable']) echo('</a>');
  1219. echo(' ]');
  1220. } else {
  1221. if (dirname($file['readlink']) != '.') {
  1222. if ($file['is_readable']) echo("<a href=\"$self?dir=" . urlencode(dirname($file['readlink'])) . "$p\">");
  1223. echo(htmlentities(dirname($file['readlink'])) . '/');
  1224. if ($file['is_readable']) echo('</a>');
  1225. }
  1226. if (strlen(basename($file['readlink'])) != 0) {
  1227. if ($file['is_file'] && $file['is_readable']) echo("<a href=\"$self?show=" . urlencode($file['readlink']) . "$p\">");
  1228. echo(htmlentities(basename($file['readlink'])));
  1229. if ($file['is_file'] && $file['is_readable']) echo('</a>');
  1230. }
  1231. if ($file['is_file'] && is_script($file['readlink'])) echo(" <a href=\"$self?showh=" . urlencode($file['readlink']) . "$p\">*</a>");
  1232. }
  1233. echo("</td>\n");
  1234. } elseif ($file['is_dir']) {
  1235. echo(" <td bgcolor=\"#FFFFFF\" align=\"center\"><img src=\"$self?imageid=15\" width=\"17\" height=\"13\"></td>\n");
  1236. echo(" <td$cspan bgcolor=\"#FFFFFF\">[ ");
  1237. if ($file['is_readable']) echo("<a href=\"$self?dir=" . urlencode($file['fullfilename']) . "$p\">");
  1238. echo(htmlentities($file['filename']));
  1239. if ($file['is_readable']) echo('</a>');
  1240. echo(" ]</td>\n");
  1241. } else {
  1242. echo(" <td bgcolor=\"#FFFFFF\" align=\"center\"><img src=\"$self?imageid=");
  1243. if (substr($file['filename'], 0, 1) == '.') echo('13'); else echo('12');
  1244. echo("\" width=\"17\" height=\"13\"></td>\n");
  1245. echo(' <td');
  1246. if (substr($file['permission'], 0, 1) != '-') echo($cspan);
  1247. echo(' bgcolor="#FFFFFF">');
  1248. if ($file['is_readable'] && $file['is_file']) echo("<a href=\"$self?show=" . urlencode($file['fullfilename']) . "$p\">");
  1249. echo(htmlentities($file['filename']));
  1250. if ($file['is_readable'] && $file['is_file']) echo('</a>');
  1251. if ($file['is_file'] && is_script($file['filename'])) echo(" <a href=\"$self?showh=" . urlencode($file['fullfilename']) . "$p\">*</a>");
  1252. echo("</td>\n");
  1253. if ($GLOBALS['showsize'] && $file['is_file']) {
  1254. echo(" <td bgcolor=\"#FFFFFF\" align=\"right\" nowrap>");
  1255. if ($file['is_file']) echo("{$file['size']} B");
  1256. echo("</td>\n");
  1257. }
  1258. }
  1259. echo(' <td bgcolor="#FFFFFF" class="perm">');
  1260. if ($uid == $file['owner'] && !$file['is_link']) echo("<a href=\"$self?permission=" . urlencode($file['fullfilename']) . "$p\">");
  1261. echo($file['permission']);
  1262. if ($uid == $file['owner'] && !$file['is_link']) echo('</a>');
  1263. echo("</td>\n");
  1264. $owner = ($file['ownername'] == NULL) ? $file['owner'] : $file['ownername'];
  1265. $group = ($file['groupname'] == NULL) ? $file['group'] : $file['groupname'];
  1266. echo(' <td bgcolor="#FFFFFF">' . $owner . "</td>\n");
  1267. echo(' <td bgcolor="#FFFFFF">' . $group . "</td>\n");
  1268. $f = "<a href=\"$self?symlinktarget=" . urlencode($dir . $file['filename']). "$p\">{$words['createsymlink']}</a> | ";;
  1269. if ($file['filename'] != '.' && $file['filename'] != '..') {
  1270. if ($file['is_readable'] && $file['is_file']) {
  1271. $f .= "<a href=\"$self?cpy=" . urlencode($file['fullfilename']). "$p\">{$words['copy']}</a> | ";
  1272. }
  1273. if ($uid == $file['owner']) {
  1274. $f .= "<a href=\"$self?move=" . urlencode($file['fullfilename']) . "$p\">{$words['move']}</a> | ";
  1275. $f .= "<a href=\"$self?delete=" . urlencode($dir . $file['filename']). "$p\">{$words['delete']}</a> | ";
  1276. }
  1277. if ($file['is_writable'] && $file['is_file']) {
  1278. $f .= "<a href=\"$self?edit=" . urlencode($file['fullfilename']) . "$p\">{$words['edit']}</a> | ";
  1279. }
  1280. }
  1281. if ($file['is_dir'] && @is_file($file['fullfilename'] . '.htaccess') && @is_writable($file['fullfilename'] . '.htaccess')) {
  1282. $f .= "<a href=\"$self?edit=" . urlencode($file['fullfilename']) . '.htaccess' . "$p\">{$words['configure']}</a> | ";
  1283. }
  1284. if (!empty($f)) $f = substr($f, 0, strlen($f) - 3); else $f = '&nbsp;';
  1285. echo(" <td bgcolor=\"#FFFFFF\" nowrap>$f</td>\n");
  1286. echo(" </tr>\n");
  1287. }
  1288. ?>
  1289. </table>
  1290. </td></tr></table>
  1291. </p>
  1292. <?php
  1293. return;
  1294. }
  1295.  
  1296. function sortfiles ($files, $sort, $reverse) {
  1297. $files = sortfield($files, $sort, $reverse, 0, sizeof($files) - 1);
  1298. if ($sort != 'filename') {
  1299. $old = $files[0][$sort]; $oldpos = 0;
  1300. for ($i = 1; $i < sizeof($files); $i++) {
  1301. if ($old != $files[$i][$sort]) {
  1302. if ($oldpos != ($i - 1)) $files = sortfield($files, 'filename', false, $oldpos, $i - 1);
  1303. $oldpos = $i;
  1304. }
  1305. $old = $files[$i][$sort];
  1306. }
  1307. if ($oldpos < ($i - 1)) $files = sortfield($files, 'filename', false, $oldpos, $i - 1);
  1308. }
  1309. return $files;
  1310. }
  1311.  
  1312. function octtostr ($mode) {
  1313. if (($mode & 0xC000) === 0xC000) $type = 's'; /* Unix domain socket */
  1314. elseif (($mode & 0x4000) === 0x4000) $type = 'd'; /* Directory */
  1315. elseif (($mode & 0xA000) === 0xA000) $type = 'l'; /* Symbolic link */
  1316. elseif (($mode & 0x8000) === 0x8000) $type = '-'; /* Regular file */
  1317. elseif (($mode & 0x6000) === 0x6000) $type = 'b'; /* Block special file */
  1318. elseif (($mode & 0x2000) === 0x2000) $type = 'c'; /* Character special file */
  1319. elseif (($mode & 0x1000) === 0x1000) $type = 'p'; /* Named pipe */
  1320. else $type = '?'; /* Unknown */
  1321. $owner = ($mode & 00400) ? 'r' : '-';
  1322. $owner .= ($mode & 00200) ? 'w' : '-';
  1323. if ($mode & 0x800) $owner .= ($mode & 00100) ? 's' : 'S'; else $owner .= ($mode & 00100) ? 'x' : '-';
  1324. $group = ($mode & 00040) ? 'r' : '-';
  1325. $group .= ($mode & 00020) ? 'w' : '-';
  1326. if ($mode & 0x400) $group .= ($mode & 00010) ? 's' : 'S'; else $group .= ($mode & 00010) ? 'x' : '-';
  1327. $other = ($mode & 00004) ? 'r' : '-';
  1328. $other .= ($mode & 00002) ? 'w' : '-';
  1329. if ($mode & 0x200) $other .= ($mode & 00001) ? 't' : 'T'; else $other .= ($mode & 00001) ? 'x' : '-';
  1330. return $type . $owner . $group . $other;
  1331. }
  1332.  
  1333. function sortfield ($field, $column, $reverse, $left, $right){
  1334. $g = $field[(int) (($left + $right) / 2)][$column];
  1335. $l = $left; $r = $right;
  1336. while ($l <= $r) {
  1337. if ($reverse) {
  1338. while (($l < $right) && ($field[$l][$column] > $g)) $l++;
  1339. while (($r > $left) && ($field[$r][$column] < $g)) $r--;
  1340. } else {
  1341. while (($l < $right) && ($field[$l][$column] < $g)) $l++;
  1342. while (($r > $left) && ($field[$r][$column] > $g)) $r--;
  1343. }
  1344. if ($l < $r) {
  1345. $tmp = $field[$r];
  1346. $field[$r] = $field[$l];
  1347. $field[$l] = $tmp;
  1348. $r--;
  1349. $l++;
  1350. } else {
  1351. $l++;
  1352. }
  1353. }
  1354. if ($r > $left) $field = sortfield($field, $column, $reverse, $left, $r);
  1355. if ($r + 1 < $right) $field = sortfield($field, $column, $reverse, $r + 1, $right);
  1356. return $field;
  1357. }
  1358.  
  1359. function buildphrase ($repl, $str) {
  1360. if (!is_array($repl)) $repl = array($repl);
  1361. $newstr = ''; $prevz = ' ';
  1362. for ($i = 0; $i < strlen($str); $i++) {
  1363. $z = substr($str, $i, 1);
  1364. if (((int) $z) > 0 && ((int) $z) <= count($repl) && $prevz == ' ') $newstr .= $repl[((int) $z) - 1]; else $newstr .= $z;
  1365. $prevz = $z;
  1366. }
  1367. return $newstr;
  1368. }
  1369.  
  1370. function html_header ($action) {
  1371. global $self;
  1372. global $error, $notice, $updatetreeview;
  1373. ?>
  1374. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  1375. <html>
  1376. <head>
  1377. <title><?php echo("$self - $action"); ?></title>
  1378. <style type="text/css">
  1379. <!--
  1380. td { font-family: sans-serif; font-size: 10pt; }
  1381. a:link, a:visited, a:active { text-decoration: none; color: #000088; }
  1382. a:hover { text-decoration: underline; color: #000088; }
  1383. .perm { font-family: monospace; font-size: 10pt; }
  1384. -->
  1385. </style>
  1386. <?php
  1387. if (isset($_REQUEST['edit']) && !isset($_POST['save']) && basename($edit = $_REQUEST['edit']) == '.htaccess') {
  1388. $file = dirname($edit) . '/.htpasswd';
  1389. ?>
  1390. <script type="text/javascript" language="JavaScript">
  1391. <!--
  1392. function autheinf () {
  1393. document.f.content.value += "Authtype Basic\nAuthName \"Restricted Directory\"\n";
  1394. document.f.content.value += "AuthUserFile <?php echo(htmlentities($file)); ?>\n";
  1395. document.f.content.value += "Require valid-user";
  1396. }
  1397. //-->
  1398. </script>
  1399. <?php
  1400. }
  1401. ?>
  1402. </head>
  1403. <body bgcolor="#FFFFFF"<?php if ($updatetreeview && !empty($_SESSION['tree'])) echo(" onLoad=\"void(parent.treeview.location.replace('$self?frame=treeview&dir=" . urlencode($_SESSION['dir']) . '&' . SID . '&pmru=' . time() . '#' . urlencode($_SESSION['dir']) . "'))\""); ?>>
  1404. <?php
  1405. if (!empty($error)) perror($error);
  1406. if (!empty($notice)) pnotice($notice);
  1407. return;
  1408. }
  1409.  
  1410. function html_footer ($backbutton = TRUE) {
  1411. global $self, $words;
  1412. if ($backbutton) {
  1413. ?>
  1414. <p>
  1415. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  1416. <table border="0" cellspacing="1" cellpadding="4"><tr><td bgcolor="#EEEEEE">
  1417. <a href="<?php echo("$self?id=". $_REQUEST['id']); ?>"><?php echo($words['back']); ?></a>
  1418. </td></tr></table>
  1419. </td></tr></table>
  1420. </p>
  1421. <?php
  1422. }
  1423. ?>
  1424. </body>
  1425. </html>
  1426. <?php
  1427. return;
  1428. }
  1429.  
  1430. function perror ($str) {
  1431. ?>
  1432. <p>
  1433. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  1434. <table border="0" cellspacing="1" cellpadding="4"><tr><td bgcolor="#FFCCCC">
  1435. <?php echo("$str\n"); ?>
  1436. </td></tr></table>
  1437. </td></tr></table>
  1438. </p>
  1439. <?php
  1440. return;
  1441. }
  1442.  
  1443. function pnotice ($str) {
  1444. ?>
  1445. <p>
  1446. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  1447. <table border="0" cellspacing="1" cellpadding="4"><tr><td bgcolor="#CCFFCC">
  1448. <?php echo("$str\n"); ?>
  1449. </td></tr></table>
  1450. </td></tr></table>
  1451. </p>
  1452. <?php
  1453. return;
  1454. }
  1455.  
  1456. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement