[PHP] web版ftp工具 phpWebFTP →→→→→进入此内容的聊天室

来自 , 2020-01-28, 写在 PHP, 查看 137 次.
URL http://www.code666.cn/view/ec0bfd00
  1. <?php
  2.         session_start();
  3.  
  4.         include('config.inc.php'); //load configuration
  5.         include("include/functions.inc.php");
  6.         include("include/ftp.class.php");
  7.  
  8.         // Report simple running errors
  9.         //error_reporting(E_ERROR | E_WARNING | E_PARSE);
  10.         error_reporting(E_ERROR | E_PARSE);
  11.         //error_reporting(E_ALL);
  12.  
  13.         /*
  14.          * check availability of tar, zip, bzip2 and gzip
  15.          */
  16.  
  17.         // zip
  18.         exec("which unzip", $unzipLocation, $retVal);
  19.  
  20.         if (preg_match("/unzip$/", $unzipLocation[0])) {
  21.                 $uncompress["zip"] = $unzipLocation[0];
  22.         }
  23.  
  24.  
  25.         // tar
  26.         exec("which tar", $tarLocation, $retVal);
  27.  
  28.         if (preg_match("/tar/", $tarLocation[0])) {
  29.                 $uncompress["tar"] = $tarLocation[0] . " xf";
  30.         }
  31.  
  32.         // gz
  33.         exec("which gunzip", $gunzipLocation, $retVal);
  34.  
  35.         if (preg_match("/gunzip$/", $gunzipLocation[0])) {
  36.  
  37.                 // tar.gz
  38.                 if (preg_match("/tar/", $tarLocation[0])) {
  39.                         $uncompress["tar.gz"] = $tarLocation[0] . " xzf";
  40.                         $uncompress["tgz"] = $tarLocation[0] . " xzf";
  41.                 }
  42.  
  43.                 $uncompress["gz"] = $gunzipLocation[0];
  44.         }
  45.  
  46.         // bz2
  47.         exec("which bunzip2", $bunzip2Location, $retVal);
  48.  
  49.         if (preg_match("/bunzip2$/", $bunzip2Location[0])) {
  50.  
  51.                 // tar.bz2
  52.                 if (preg_match("/tar$/", $tarLocation[0])) {
  53.                         $uncompress["tar.bz2"] = $tarLocation[0] . " xjf";
  54.                 }
  55.  
  56.                 $uncompress["bz2"] = $bunzip2Location[0];
  57.         }
  58.  
  59.  
  60.         //Procedure for emptying the tmp directory
  61.         if($clearTemp==true)
  62.         {
  63.         deleteRecursive($downloadDir, false);
  64.         }
  65.  
  66.         // Get the POST and SESSION variables (if register_globals=off (PHP4.2.1+))
  67.         /*
  68.         $goPassive=(isset($_POST['goPassive']))?$_POST['goPassive']:$_GET['goPassive'];
  69.         */
  70.     if (isset($_POST['goPassive'])) {
  71.             $goPassive=$_POST['goPassive'];
  72.     }
  73.  
  74.         if (isset($_POST['mode'])) {
  75.                 $ftpMode = $_POST['mode'];
  76.     }
  77.  
  78.         if (isset($_POST['actionType'])) {
  79.             $actionType=$_POST['actionType'];
  80.     }
  81.  
  82.         if (isset($_POST['currentDir'])) {
  83.             $currentDir=stripSlashes($_POST['currentDir']);
  84.     } else {
  85.                 $currentDir="";
  86.         }
  87.    
  88.     if (isset($_POST['file'])) {
  89.             $file=$_POST['file'];
  90.             $file=StripSlashes($file);
  91.         }
  92.  
  93.     if (isset($_POST['file2'])) {
  94.             $file2=$_POST['file2'];
  95.             $file2=StripSlashes($file2);
  96.     }
  97.  
  98.     if (isset($_POST['permissions'])) {
  99.             $permissions=$_POST['permissions'];
  100.     }
  101.  
  102.     if (isset($_POST['directory'])) {
  103.             $directory=$_POST['directory'];
  104.     }
  105.  
  106.     if (isset($_POST['fileContent'])) {
  107.             $fileContent=$_POST['fileContent'];
  108.     }
  109.  
  110.         if (
  111.                 ($disableLoginScreen == false) &&
  112.                 isset($_POST['user'])
  113.         )
  114.         {
  115.                 // we dont care if we are already logged or not in case user provides
  116.                 // login information. That allows relogging in without explicitly
  117.                 // loging out, eg with the "back" button.
  118.                 if ($editDefaultServer)
  119.                         $_SESSION['server']=$_POST['server'];
  120.                 else
  121.                         $_SESSION['server']=$defaultServer;
  122.  
  123.                 if (isset($_POST['user'])) {
  124.                         $_SESSION['user']=$_POST['user'];
  125.                 }
  126.  
  127.                 if (isset($_POST['password'])) {
  128.                         $_SESSION['password']=$_POST['password'];
  129.                 }
  130.  
  131.                 if (isset($_POST['language'])) {
  132.                         $_SESSION['language']=$_POST['language'];
  133.                 }
  134.  
  135.                 if (isset($_POST['port'])) {
  136.                         $_SESSION['port']=$_POST['port'];
  137.                 }
  138.  
  139.                 if (isset($_POST['passive'])) {
  140.                         $_SESSION['passive']=$_POST['passive'];
  141.                 }
  142.         }
  143.  
  144.         if (isset($actionType) and $actionType=="logoff")
  145.         {
  146.                 unset($_SESSION['server']);
  147.                 unset($_SESSION['user']);
  148.                 unset($_SESSION['password']);
  149.                 unset($_SESSION['port']);
  150.                 unset($_SESSION['passive']);
  151.                 session_destroy();
  152.  
  153.                 if ($disableLoginScreen) {
  154. ?>
  155. <script type="text/javascript">
  156.                                 window.close();
  157.                         </script>
  158. <?
  159.                 }
  160.         }
  161.  
  162.     if (isset($_SESSION['server'])) {
  163.             $server=$_SESSION['server'];
  164.         }
  165.  
  166.     if (isset($_SESSION['user'])) {
  167.             $user=$_SESSION['user'];
  168.     }
  169.  
  170.     if (isset($_SESSION['password'])) {
  171.             $password=$_SESSION['password'];
  172.     }
  173.  
  174.     if (isset($_SESSION['language'])) {
  175.             $language=$_SESSION['language'];
  176.     }
  177.  
  178.     if (isset($_SESSION['port'])) {
  179.             $port=$_SESSION['port'];
  180.     }
  181.  
  182.     if (isset($_SESSION['passive'])) {
  183.             $passive=$_SESSION['passive'];
  184.     } else {
  185.                 $passive = false;
  186.         }
  187.  
  188.         // If language is not yet set, check the default language or try to get the language from your browser.
  189.  
  190.     $validLanguage = false;
  191.         if(!isset($language) or $language==""){
  192.                 if ($defaultLanguage !="") {
  193.                         $language = $defaultLanguage ;
  194.                         if(file_exists("include/language/" . $languages[$language] . ".lang.php")) {
  195.                 $validLanguage = true;
  196.             }
  197.                 } else {
  198.                         $browser_lang = getenv("http_accept_language");
  199.                         $tmplang = $languages[$browser_lang];
  200.                         if(file_exists("include/language/" . $tmplang . ".lang.php")) {
  201.                                 $language = $tmplang;
  202.                         } else {
  203.                                 $language = "english";
  204.                         }
  205.                         $validLanguage=true;
  206.                 }
  207.         } else {
  208.                 //Check if the language is a valid language
  209.                 foreach($languages as $langid=>$thisLanguage) {
  210.                         if($langid==$language) {
  211.                                 $validLanguage=true;
  212.                         }
  213.                 }
  214.         }
  215.  
  216.         //Include Language file
  217.         if($validLanguage) {
  218.                 include("include/language/" . $languages[$language] . ".lang.php");   // Selected language
  219.         } else {
  220.                 die("Invalid language entered. Exiting script");
  221.         }
  222.  
  223.         if (isset($server) && $server!="")
  224.         {
  225.                 $ftp = new ftp($server, $port, $user, $password, $passive);
  226.  
  227.                 if (isset($_SESSION["ftpmode"])) {
  228.                         $ftp->setMode($_SESSION["ftpmode"]);
  229.                 }
  230.                 $ftp->setCurrentDir($currentDir);
  231.  
  232.                 // set some default values as defined in config.inc.php
  233.                 $ftp->setResumeDownload($resumeDownload);
  234.                 $ftp->setDownloadDir($downloadDir);
  235.  
  236.                 if ($ftp->loggedOn)
  237.                 {
  238.                         $msg = $ftp->getCurrentDirectoryShort();
  239.                         // what to do now ???
  240.                         if(isset($actionType))
  241.                         {
  242.                                 switch ($actionType)
  243.                                 {
  244.                                         case "changemode":
  245.                                                 $_SESSION["ftpmode"] = $ftpMode;
  246.                                                 $ftp->setMode($_SESSION["ftpmode"]);
  247.                                                 break;
  248.                                         case "chmod":   // Change permissions
  249.                                                 if($ftp->chmod($permissions, $file)){
  250.                                                         $msg = $lblFilePermissionChanged;
  251.                                                 } else {
  252.                                                         $msg = $lblCouldNotChangePermissions;
  253.                                                 }
  254.                                                 break;
  255.                                         case "cd":                      // Change directory
  256.                                                 $ftp->cd($file);
  257.                                                 $msg = /*$lblndexOf .*/ $ftp->getCurrentDirectoryShort();
  258.                                                 break;
  259.                                         case "get":                     // Download file
  260.                                                 $ftp->download($file) or DIE($lblErrorDownloadingFile);
  261.                                                 break;
  262.                                         case "put":                     // Upload file
  263.  
  264.                                                 $fileObject = $_FILES['file'];
  265.  
  266.                                                 if($fileObject['size'] <= $maxFileSize) {
  267.                                                         if (isset($_POST["putunzip"])) {
  268.                                                                 $file = $fileObject["name"];
  269.                                                                 $tmpfile = $fileObject["tmp_name"];
  270.                                                                 copy($fileObject["tmp_name"], $ftp->downloadDir . "/" . $file);
  271.  
  272.                                                                 // 1. check if file is unzippable
  273.                                                                 // 2. unzip file
  274.                                                                 // 3. clean up
  275.                                                                 set_time_limit(30); //for big archives
  276.                                                                 $dir = $ftp->downloadDir . $ftp->userDir . "/";  
  277.  
  278.                                                                 // 2. mkdir
  279.                                                                 mkdir($dir);
  280.                                                                 chdir($dir);
  281.  
  282.                                                                 // 3. unzip
  283.                                                                 $cmd = false;
  284.  
  285.                                                                 foreach ($uncompress as $key=>$value) {
  286.                                                                         if (!$cmd and preg_match("/\.$key$/", $file)) {
  287.                                                                                 $dir = preg_replace("/\.$key$/", "", $file);
  288.                                                                                 $cmd = $value;
  289.                                                                         }
  290.                                                                 }
  291.  
  292.                                                                 // 4. recursive upload
  293.  
  294.                                                                 if ($cmd) {
  295.                                                                         mkdir($dir);
  296.                                                                         chdir($dir);
  297.                                                                         `$cmd ../../$file`;
  298.                                                                         chdir("..");
  299.                                                                         $ftp->putRecursive($dir);
  300.                                                                 } else {
  301.                                                                         $msg = "bestandstype wordt niet ondersteund.";
  302.                                                                         $ftp->upload($fileObject);
  303.                                                                 }
  304.                                                         } else {
  305.                                                                 if(!$ftp->upload($fileObject)) {
  306.                                                                         $msg = $lblFileCouldNotBeUploaded;
  307.                                                                 }
  308.                                                         }
  309.                                                 } else {
  310.                                                         $msg = "<B>" . $lblFileSizeTooBig . "</B> (max. " . $maxFileSize . " bytes)<P>";
  311.                                                 }
  312.                                                 break;
  313.                                         case "deldir";          // Delete directory
  314.                                                 $ftp->deleteRecursive($file);
  315.                                                 break;
  316.                                         case "delfile";         // Delete file
  317.                                                 $ftp->deleteFile($file);
  318.                                                 break;
  319.                                         case "rename";          // Rename file
  320.                                                 if($ftp->rename($file, $file2)) {
  321.                                                         $msg = $file . " " . $lblRenamedTo . " " . $file2;
  322.                                                 } else {
  323.                                                         $msg = $lblCouldNotRename . " " . $file . " " . $lblTo . " " . $file2;
  324.                                                 }
  325.                                                 break;
  326.                                         case "createdir":  // Create a new directory
  327.                                                 if($ftp->makeDir($file)) {
  328.                                                         $msg = $file . " " . $lblCreated;
  329.                                                 } else {
  330.                                                         $msg = $lblCouldNotCreate . " " . $file;
  331.                                                 }
  332.                                                 break;
  333.                                         case "edit":
  334.                                                 //First download the file to the server
  335.                                                 $ftp->get($file);
  336.  
  337.                                                 //Now open the content of the file in an edit window
  338.                                                 // ToDo: separate file, html editor.
  339.                                         ?>
  340. <?///BEGIN EDITOR///?>
  341. <?
  342. echo <<<XML
  343. <?xml version="1.0" encoding="UTF-8"?>
  344. XML;
  345. ?>
  346. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  347.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  348.  
  349. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  350.                         <head>
  351.                         <title>phpWebFTP
  352.             <?=$currentVersion;?>
  353.             By Edwin van Wijk</title>
  354.                         <link rel="stylesheet" href="style/cm.css" title=contemporary type="text/css"/>
  355.                         <script type="text/javascript" src="include/script.js"></script>
  356.                         <?
  357.                 if (
  358.                         preg_match("/\.htm$/", $file)
  359.                         ||
  360.                         preg_match("/\.html$/", $file)
  361.                 )
  362.                 {
  363. ?>
  364.                         <script type="text/javascript" src="include/fckeditor/fckeditor.js"></script>
  365.                         <script type="text/javascript">
  366.  
  367.                         window.onload = function()
  368.                         {
  369.                                 // Automatically calculates the editor base path based on the _samples directory.
  370.                                 // This is usefull only for these samples. A real application should use something like this:
  371.                                 // oFCKeditor.BasePath = '/fckeditor/' ;        // '/fckeditor/' is the default value.
  372.                                 var oFCKeditor = new FCKeditor( 'fileContent' ) ;
  373.                                 oFCKeditor.BasePath = 'include/fckeditor/' ;
  374.                                 oFCKeditor.Height       = 500 ;
  375.                                 oFCKeditor.ReplaceTextarea() ;
  376.                         }
  377.  
  378.                         </script>
  379.                         <?
  380.                 }
  381. ?>
  382.                         </head>
  383.                         <body>
  384.             <form method="post" name="editFileForm" action="<?=$_SERVER["PHP_SELF"];?>">
  385.               <table cellpadding="0" cellspacing="0" width="100%">
  386.                 <tr>
  387.                   <td valign="top"><table border="0" cellpadding="2" cellspacing="0" width="100%">
  388.                       <tr>
  389.                       <td class="titlebar" colspan="3"><b>phpWebFTP
  390.                         <?=$lblVersion;?>
  391.                         <?=$currentVersion;?>
  392.                         </b></td>
  393.                     </tr>
  394.                       <tr>
  395.                       <td class="menu"><?
  396.                                                                         $newMode=($ftp->mode==1)?0:1;
  397.  
  398.                                                                         if($ftp->loggedOn)
  399.                                                                         {
  400. ?>
  401.                           <table cellpadding="0" cellspacing="0">
  402.                           <tr>
  403.                               <td><div class="toolbarButton" onClick="cancelEditFile();">
  404.                                   <table border="0">
  405.                                   <tr>
  406.                                       <td><img src="img/back.gif" border="0" alt=""/></td>
  407.                                       <td>&nbsp;Terug
  408.                                       <?//$lblChangeMode;?></td>
  409.                                     </tr>
  410.                                 </table>
  411.                                 </div></td>
  412.                               <td><div class="toolbarButton" onClick="document.editFileForm.submit();">
  413.                                   <table border="0">
  414.                                   <tr>
  415.                                       <td><img src="img/save.gif" border="0" alt=""/></td>
  416.                                       <td> Opslaan en afsluiten </td>
  417.                                     </tr>
  418.                                 </table>
  419.                                 </div></td>
  420.                               <td align="right" width="100%"> Edit
  421.                               <?=directoryPath($ftp->currentDir, $server);?>
  422.                               <?=$file;?></td>
  423.                             </tr>
  424.                         </table>
  425.                           <?
  426.                                                                         }
  427.                                                                         else
  428.                                                                         {
  429. ?>
  430.                           <table cellpadding="0" cellspacing="0">
  431.                           <tr>
  432.                               <td valign="middle">&nbsp;<a class="menu" href="javascript:logOff()"><img src="img/logoff.gif" height="24" border="0" align="middle" alt=""/></a></td>
  433.                               <td valign="middle">&nbsp;<a class="menu" href="javascript:logOff()">
  434.                                 <?=$lblRetry;?>
  435.                                 </a></td>
  436.                             </tr>
  437.                         </table>
  438.                           <?
  439.                                                                         }
  440. ?></td>
  441.                     </tr>
  442.                     </table></td>
  443.                 </tr>
  444.                 <tr>
  445.                   <td valign="top"><?
  446.                                                 $content = file_get_contents($ftp->downloadDir . $file);
  447.                                                 $content = htmlspecialchars($content, ENT_QUOTES);
  448. ?>
  449.                     <textarea name="fileContent" rows="30" cols="80" style="width: 100%; height: 500px;"><?=$content?>
  450. </textarea>
  451.                     <input type="hidden" name="actionType" value="saveFile"/>
  452.                     <input type="hidden" name="currentDir" value="<?=$ftp->currentDir;?>"/>
  453.                     <input type="hidden" name="file" value="<?=$file;?>"/>
  454.                     <input type="hidden" name="mode" value="<?=$ftp->mode;?>"/></td>
  455.                 </tr>
  456.               </table>
  457.             </form>
  458. </body>
  459. </html>
  460. <?///END EDITOR///?>
  461. <?
  462.                                                 unlink($ftp->downloadDir . $file);
  463.                                                 exit;
  464.                                                 break;
  465.                                         case "saveFile":
  466.                                                 //Write content of fileContent to tempFile
  467.                                                 $tempFile = "tmpFile.txt";
  468.                                                 $fp = fopen($ftp->downloadDir . $tempFile, "w+t");
  469.                                                 if ($bytes=!fwrite($fp, stripslashes($fileContent))) {
  470.                                                         $msg = $lblFileCouldNotBeUploaded;
  471.                                                 }
  472.                                                 fclose($fp);
  473.  
  474.                                                 //Upload the file to the server
  475.                                                 if(!$ftp->put($ftp->currentDir . "/" . filePart(StripSlashes($file)),$ftp->downloadDir . $tempFile)) $msg = $lblFileCouldNotBeUploaded;
  476.  
  477.                                                 //Delete temporary file
  478.                                                 unlink($ftp->downloadDir . $tempFile);
  479.                                                 break;
  480.  
  481.                                         case "getzip":
  482.                                                 set_time_limit(30); //for big archives
  483.                                                 $zipfile = $file . ".zip";
  484.  
  485.                                                 // a directory for every user, just in case...
  486.                                                 $dir = $ftp->downloadDir . $ftp->userDir . "/";  
  487.  
  488.                                                 header("Content-disposition: attachment; filename=\"$zipfile\"");
  489.                                                 header("Content-type: application/octetstream");
  490.                                                 header("Pragma: ");
  491.                                                 header("Cache-Control: cache");
  492.                                                 header("Expires: 0");
  493.  
  494.                                                 $zipfile = $ftp->downloadDir . $zipfile;
  495.  
  496.                                                 //Create temporary directory
  497.                                                 mkdir($dir);
  498.  
  499.                                                 //Get entire directory and store to temporary directory
  500.                                                 $ftp->getRecursive($ftp->currentDir, $file);
  501.  
  502.                                                 //zip the directory
  503.                                                 $zip = new ss_zip('',6);
  504.                                                 $zip->zipDirTree($dir, $dir);
  505.                                                 $zip->save($zipfile);
  506.  
  507.                                                 //send zipfile to the browser
  508.                                                 $filearray = explode("/",$zipfile);
  509.                                                 $file = $filearray[sizeof($filearray)-1];
  510.  
  511.                                                 $data = readfile($zipfile);
  512.                                                 $i=0;
  513.                                                 while ($data[$i] != "")
  514.                                                 {
  515.                                                         echo $data[$i];
  516.                                                         $i++;
  517.                                                 }
  518.  
  519.                                                 //Delete zip file
  520.                                                 unlink($zipfile);
  521.  
  522.                                                 //Delete downloaded files from user specific directory
  523.                                                 deleteRecursive($dir);
  524.                                                 exit;
  525.                                                 break;
  526.                                         case "unzip": // BK20061114
  527.                                                 set_time_limit(30); //for big archives
  528.                                                 $dir = $ftp->downloadDir . $ftp->userDir . "/";  
  529.  
  530.                                                 // 1. download
  531.                                                 $ftp->get($file);
  532.  
  533.                                                 // 2. mkdir
  534.                                                 mkdir($dir);
  535.                                                 chdir($dir);
  536.  
  537.                                                 // 3. unzip
  538.                                                 $cmd = false;
  539.  
  540.                                                 foreach ($uncompress as $key=>$value) {
  541.                                                         if (!$cmd and preg_match("/\.$key$/", $file)) {
  542.                                                                 $dir = preg_replace("/\.$key$/", "", $file);
  543.                                                                 $cmd = $value;
  544.                                                         }
  545.                                                 }
  546.  
  547.                                                 // 4. recursive upload
  548.                                                 if ($cmd) {
  549.                                                         mkdir($dir);
  550.                                                         chdir($dir);
  551.                                                         `$cmd ../../$file`;
  552.                                                         chdir("..");
  553.                                                         $ftp->putRecursive($dir);
  554.                                                 }
  555.                                 }
  556.                         }
  557. ?>
  558. <?///BEGIN FILE MANAGER///?>
  559. <?
  560. echo <<<XML
  561. <?xml version="1.0" encoding="UTF-8"?>
  562. XML;
  563. ?>
  564. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  565.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  566.  
  567. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  568.                 <head>
  569.                 <title>phpWebFTP
  570.         <?=$currentVersion;?>
  571.         By Edwin van Wijk</title>
  572.                 <link rel="stylesheet" href="style/cm.css" title="Contemporary" type="text/css"/>
  573.                 <style type="text/css">
  574. body {
  575.         background-color: white;
  576.         background-image: url(img/menubg.gif);
  577.         background-repeat: repeat-y;
  578. }
  579. </style>
  580.                 <script type="text/javascript">
  581.                         // variables for javascript
  582.                         var currentUser = "<?=$_SESSION["user"]?>";
  583.                         var dir = "<?=$ftp->currentDir;?>";
  584.                         var uncompress = new Array();
  585. <?
  586.                         $uc = 0;
  587.                         foreach ($uncompress as $key=>$value) {
  588. ?>
  589.                                 uncompress[<?=$uc++?>] = "<?=$key?>";
  590. <?
  591.                         }
  592. ?>
  593.                         var ucNum = <?=$uc?>;
  594.  
  595.                         /*
  596.                                 strip public_html or www from dirname (for file view);
  597.                                 for use within hosting management systems
  598.                         */
  599.                         var site = "<?=$server?>";
  600.                         dir = dir.replace(/^\/www\/?/, "");
  601.                         dir = dir.replace(/^\/public_html\/?/, "");
  602.                 </script>
  603.                 <script type="text/javascript" src="include/script.js"></script>
  604.                 </head>
  605.                 <body>
  606.         <table cellpadding="0" cellspacing="0" style="height:100%;width:100%;">
  607.           <tr>
  608.             <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
  609.                 <tr>
  610.                 <td class="titlebar"><b>phpWebFTP
  611.                   <?=$lblVersion;?>
  612.                   <?=$currentVersion;?>
  613.                   </b></td>
  614.               </tr>
  615.               </table>
  616.               <table border="0" cellpadding="0" cellspacing="0" width="100%">
  617.                 <tr>
  618.                   <?
  619.                                                         $newMode=($ftp->mode==1)?0:1;
  620.                                                         if($ftp->loggedOn)
  621.                                                         {
  622. ?>
  623.                   <td class="menu"><table border="0">
  624.                       <tr>
  625.                       <td><div class="toolbarButton" onClick="submitForm('cd', '..');">
  626.                           <table border="0">
  627.                           <tr>
  628.                               <td><img src="img/parent.gif" border="0" alt=""/></td>
  629.                               <td><?=$lblUp?></td>
  630.                             </tr>
  631.                         </table>
  632.                         </div></td>
  633.                       <td><div class="toolbarButton" onClick="changeMode('<?=$newMode?>');">
  634.                           <table border="0">
  635.                           <tr>
  636.                               <td><img src="img/mode.gif" border="0" alt=""/></td>
  637.                               <td><?=$lblChangeMode?></td>
  638.                             </tr>
  639.                         </table>
  640.                         </div></td>
  641.                       <td><div class="toolbarButton" onClick="logOff();">
  642.                           <table border="0">
  643.                           <tr>
  644.                               <td><img src="img/logoff.gif" border="0" alt=""/></td>
  645.                               <td><?=$lblLogOff?></td>
  646.                             </tr>
  647.                         </table>
  648.                         </div></td>
  649.                     </tr>
  650.                     </table></td>
  651.                   <td colspan="6" class="menu" width="100%" valign="middle" align="right"><?=directoryPath($ftp->currentDir, $server);?></td>
  652.                   <?
  653.                                                         }
  654.                                                         else
  655.                                                         {
  656.         ?>
  657.                   <td class="menu"><table border="0">
  658.                       <tr>
  659.                       <td><div class="toolbarButton" onClick="logOff();">
  660.                           <table border="0">
  661.                           <tr>
  662.                               <td><img src="img/parent.gif" border="0" alt=""/></td>
  663.                               <td><?=$lblRetry?></td>
  664.                             </tr>
  665.                         </table>
  666.                         </div></td>
  667.                     </tr>
  668.                     </table></td>
  669.                   <?
  670.                                                         }
  671. ?>
  672.                 </tr>
  673.               </table></td>
  674.           </tr>
  675.           <tr>
  676.             <td style="height:100%;width:100%;"><div style="display:none;">
  677.                 <form name="actionform" method="post" action="<?=$_SERVER["PHP_SELF"];?>" enctype="multipart/form-data">
  678.                 <input type="hidden" name="actionType" value=""/>
  679.                 <input type="hidden" name="delaction" value=""/>
  680.                 <input type="hidden" name="currentDir" value="<?=$ftp->currentDir;?>"/>
  681.                 <input type="hidden" name="file" value=""/>
  682.                 <input type="hidden" name="file2" value=""/>
  683.                 <input type="hidden" name="extension" value=""/>
  684.                 <input type="hidden" name="permissions" value=""/>
  685.                 <input type="hidden" name="mode" value="<?=$ftp->mode;?>"/>
  686.               </form>
  687.               </div>
  688.               <table style="height:100%;width:100%;" border="0" cellspacing="0" cellpadding="0">
  689.                 <tr>
  690.                   <td class="leftmenu" valign="top"><img src="img/1px.gif" width="212" height="1">
  691.                     <div align="center"> <br/>
  692.                       <!-- File and folder -->
  693.                       <table border="0" cellspacing="0" cellpadding="0" class="item">
  694.                         <tr>
  695.                           <td valign="top" class="itemheadContainer"><div class="itemhead">
  696.                               <?=$lblFileTasks;?>
  697.                             </div></td>
  698.                         </tr>
  699.                         <tr>
  700.                           <td valign="top" class="leftmenuitem"><table id="action_delete" border="0" cellspacing="0" cellpadding="0" style="display:none;">
  701.                               <!-- Delete File -->
  702.                               <tr>
  703.                               <td valign="middle"><img src="img/menu_delete.gif" alt=""/></td>
  704.                               <td valign="middle"><a href='javascript:deleteFile()' class=leftmenulink>
  705.                                 <?=$lblDeleteFile;?>
  706.                                 </A></td>
  707.                             </tr>
  708.                             </table>
  709.                             <table id="action_zipdl" style="display:none;" border="0" cellspacing="0" cellpadding="0">
  710.                               <!-- zip&download directory -->
  711.                               <tr>
  712.                                 <td valign="middle"><img src="img/zip.gif" alt=""/></td>
  713.                                 <td valign="middle"><a href='javascript:zipFile()' class=leftmenulink>
  714.                                   <?="download";?>
  715.                                   </A></td>
  716.                               </tr>
  717.                             </table>
  718.                             <table id="action_unzip" style="display:none;" border="0" cellspacing="0" cellpadding="0">
  719.                               <!-- unzip to <filename>/ -->
  720.                               <tr>
  721.                                 <td valign="middle"><img src="img/zip.gif" alt=""/></td>
  722.                                 <td valign="middle"><a href='javascript:unzipFile()' class="leftmenulink" id="unzipto">
  723.                                   <?="unzip";?>
  724.                                   </A></td>
  725.                               </tr>
  726.                             </table>
  727.                            
  728.                             <!-- View file on http server -->
  729.                            
  730.                             <table id="action_view" style="display:none;" border="0" cellspacing="0" cellpadding="0">
  731.                               <tr>
  732.                                 <td valign=center><img src="img/menu_edit.gif" alt=""/></td>
  733.                                 <td valign=center><a href='javascript:viewFile()' class=leftmenulink>View
  734.                                   <?//$lblEditFile;?>
  735.                                   </A></td>
  736.                               </tr>
  737.                             </table>
  738.                             <table id="action_edit" style="display:none;" border="0" cellspacing="0" cellpadding="0">
  739.                               <!-- edit file
  740.                                                                                                         Only if $user is allowed to edit the file.
  741.                                                                                                         -->
  742.                               <tr>
  743.                                 <td valign="middle"><img src="img/menu_edit.gif" alt=""/></td>
  744.                                 <td valign="middle"><a href='javascript:editFile()' class=leftmenulink>
  745.                                   <?=$lblEditFile;?>
  746.                                   </A></td>
  747.                               </tr>
  748.                             </table>
  749.                             <table id="action_rename" style="display:none;" border="0" cellspacing="0" cellpadding="0">
  750.                              
  751.                               <!-- rename file
  752.                                                                                                         Only if $user is allowed to rename the file
  753.                                                                                                         -->
  754.                               <tr>
  755.                                 <td VALIGN=top><img src="img/menu_rename.gif" alt=""/></td>
  756.                                 <td VALIGN=top><a href='javascript:setNewFileName()' class=leftmenulink>
  757.                                   <?=$lblRename;?>
  758.                                   </A>
  759.                                   <!-- Rename file -->
  760.                                  
  761.                                   <DIV ID='renameFileEntry' style='display:none;'>
  762.                                     <form NAME=renameFile>
  763.                                       <table border="0" cellpadding="0" cellspacing="0" class=lined align=center>
  764.                                         <tr>
  765.                                           <td class=tinyblue><B>
  766.                                             <?=$lblNewName;?>
  767.                                             </B><br/>
  768.                                             <input type="text" name="newName" value=""/></td>
  769.                                         </tr>
  770.                                       </table>
  771.                                       <br/>
  772.                                       <div align=center>
  773.                                         <input type=button onclick='renameItem();' value='<?=$lblRename;?>'/>
  774.                                       </div>
  775.                                     </form>
  776.                                     <br/>
  777.                                   </div></td>
  778.                               </tr>
  779.                             </table>
  780.                             <table id="action_permissions" style="display:none;" border="0" cellspacing="0" cellpadding="0">
  781.                              
  782.                               <!-- permissions
  783.                                                                                                         Only if $user is allowed to edit the permissions
  784.                                                                                                         -->
  785.                               <tr>
  786.                                 <td valign="top"><img src="img/menu_settings.gif" alt=""/></td>
  787.                                 <td valign="top"><a href="javascript:;" onClick="setPermissions()" class="leftmenulink">
  788.                                   <?=$lblSetPermissions;?>
  789.                                   </a>
  790.                                   <!-- Change permissions -->
  791.                                  
  792.                                   <div id="setPermissions" style="display:none;">
  793.                                     <form name=permissions>
  794.                                       <table border="0" cellpadding="0" cellspacing="0" class="lined" align="center">
  795.                                         <tr>
  796.                                           <td class="tinyblue" align="center"><b>
  797.                                             <?=$lblOwner;?>
  798.                                             </b></td>
  799.                                           <td class="tiny" align="center"><b>
  800.                                             <?=$lblGroup;?>
  801.                                             </b></td>
  802.                                           <td class="tinywhite" align="center"><b>
  803.                                             <?=$lblPublic;?>
  804.                                             </b></td>
  805.                                         </tr>
  806.                                         <tr>
  807.                                           <td class="tinyblue"><input type="checkbox" name="iOr"/>
  808.                                             <?=$lblRead;?></td>
  809.                                           <td class="tiny"><input type="checkbox" name="iGr"/>
  810.                                             <?=$lblRead;?></td>
  811.                                           <td class="tinywhite"><input type="checkbox" name="iPr"/>
  812.                                             <?=$lblRead;?></td>
  813.                                         </tr>
  814.                                         <tr>
  815.                                           <td class="tinyblue"><input type="checkbox" name="iOw"/>
  816.                                             <?=$lblWrite;?></td>
  817.                                           <td class="tiny"><input type="checkbox" name="iGw"/>
  818.                                             <?=$lblWrite;?></td>
  819.                                           <td class="tinywhite"><input type="checkbox" name="iPw"/>
  820.                                             <?=$lblWrite;?></td>
  821.                                         </tr>
  822.                                         <tr>
  823.                                           <td class="tinyblue"><input type="checkbox" name="iOx"/>
  824.                                             <?=$lblExecute;?></td>
  825.                                           <td class="tiny"><input type="checkbox" name="iGx"/>
  826.                                             <?=$lblExecute;?></td>
  827.                                           <td class="tinywhite"><input type="checkbox" name="iPx"/>
  828.                                             <?=$lblExecute;?></td>
  829.                                         </tr>
  830.                                       </table>
  831.                                       <br/>
  832.                                       <div align="center">
  833.                                         <input type="button" onClick="changePermissions()" value="<?=$lblSetPermissions;?>"/>
  834.                                       </div>
  835.                                     </form>
  836.                                     <br/>
  837.                                   </div></td>
  838.                               </tr>
  839.                             </table>
  840.                            
  841.                             <!-- Standaard actions -->
  842.                            
  843.                             <table border="0" cellspacing="0" cellpadding="0">
  844.                               <tr>
  845.                                 <td VALIGN=top><img src="img/upload.gif" border="0" alt=""/></td>
  846.                                 <td VALIGN=top><a href="JavaScript:toggle('uploadform');" class=leftmenulink>
  847.                                   <?=$lblUploadFile;?>
  848.                                   </A>
  849.                                   <form id="uploadform" style="display:none;" name="uploadform" enctype="multipart/form-data" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
  850.                                     <input type="hidden" name="actionType" value="put"/>
  851.                                     <input type='hidden' name='currentDir' value='<?=$ftp->currentDir;?>'/>
  852.                                     <input type='hidden' name='mode' value='<?=$ftp->mode;?>'/>
  853.                                     <input type="file" name="file" size="8" style="width:100px; font-size:7pt;" onChange='/*document.uploadform.submit();*/'/>
  854.                                     <br/>
  855.                                     <input type="checkbox" name="putunzip"/>
  856.                                     <?=$lblCompressedFolder?>
  857.                                     <input type="submit" value="Ok" style='width=150px; font-size:7pt;'/>
  858.                                   </form></td>
  859.                               </tr>
  860.                               <tr>
  861.                                 <td valign="top"><img src="img/createdir.gif" border="0" alt=""/></td>
  862.                                 <td valign="top"><a href="JavaScript:toggle('createform');" class=leftmenulink>
  863.                                   <?=$lblCreateDirectory;?>
  864.                                   </A>
  865.                                   <form id="createform" style='display:none;' method=post name='dirinput' action="<?=$_SERVER["PHP_SELF"];?>">
  866.                                     <input type="text" name="directory" value="" style="width:100px; font-size:7pt;"/>
  867.                                     <input type="button" value="Ok" onClick="javascript:createDirectory(dirinput.directory.value)" style="width:40px; font-size:7pt;"/>
  868.                                   </form></td>
  869.                               </tr>
  870.                               <tr>
  871.                                 <td valign="top"><img src="img/gotodir.gif" border="0" alt=""/></td>
  872.                                 <td valign="top"><a href="JavaScript:toggle('gotoform');" class="leftmenulink">
  873.                                   <?=$lblGoToDirectory;?>
  874.                                   </a>
  875.                                   <form id="gotoform" style="display:none;" name="cdDirect" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
  876.                                     <input type='hidden' name='actionType' value='cd'/>
  877.                                     <input type='hidden' name='currentDir' value='<?=$ftp->currentDir;?>'/>
  878.                                     <input type="text" name="file" value="" style="width:100px; font-size:7pt;"/>
  879.                                     <input type="submit" value="Ok" style="width:40px; font-size:7pt;"/>
  880.                                   </form></td>
  881.                               </tr>
  882.                             </table></td>
  883.                         </tr>
  884.                       </table>
  885.                       <br/>
  886.                       <br/>
  887.                       <!-- Details -->
  888.                       <table border="0" cellpadding="0" cellspacing="0" class="item">
  889.                         <tr>
  890.                           <td valign="top" class="itemheadContainer"><div class="itemhead">
  891.                               <?=$lblDetails;?>
  892.                             </div></td>
  893.                         </tr>
  894.                         <tr>
  895.                           <td valign="top" class=leftmenuitem style='color:black' ><br/>
  896.                             <div style="width:170px;overflow:hidden;"> <B>
  897.                               <?=$msg;?>
  898.                               </B>
  899.                               <P>
  900.                                 <?=($ftp->loggedOn)?"$lblConnectedTo  $server:$port ($ftp->systype)":$lblNotConnected;?>
  901.                              
  902.                               <P>
  903.                                 <?=$lblTransferMode;?>
  904.                                 :
  905.                                 <?=$ftp->mode==1?$lblBinaryMode:$lblASCIIMode;?>
  906.                                 <br/>
  907.                                 <br/>
  908.                             </div></td>
  909.                         </tr>
  910.                       </table>
  911.                     </div></td>
  912.                   <td valign="top"><div id="filelist">
  913.                       <table width="100%" border="0" cellspacing="0" cellpadding="0" onclick='resetEntries()'>
  914.                       <tr>
  915.                           <td colspan="2" class="listhead"><?=$lblName;?></td>
  916.                           <td class="listhead" align="right"><?=$lblSize;?>
  917.                           &nbsp;</td>
  918.                           <td class="listhead"><?=$lblFileType;?>
  919.                           &nbsp;</td>
  920.                           <td class="listhead"><?=$lblDate;?></td>
  921.                           <td class="listhead"><?=$lblPermissions;?></td>
  922.                           <td class="listhead"><?=$lblOwner;?></td>
  923.                           <td class="listhead"><?=$lblGroup;?></td>
  924.                         </tr>
  925.                       <?
  926.                                                                                 $list = $ftp->ftpRawList();
  927.  
  928.                                                                                 if (is_array($list))
  929.                                                                                 {
  930.                                                                                         // Directories
  931.                                                                                         $counter=0;
  932.  
  933.                                                                                         foreach($list as $myDir)
  934.                                                                                         {
  935.                                                                                                 if ($myDir["is_dir"]==1)
  936.                                                                                                 {
  937.                                                                                                         $fileAction = "cd";
  938.                                                                                                         $fileName = $myDir["name"];
  939.                                                                                                         $fileSize="";
  940.                                                                                                         $delAction = "deldir";
  941.                                                                                                         $fileType['description'] = 'File Folder';
  942.                                                                                                         $fileType['imgfilename'] = 'folder.gif';
  943.                                                                                                 }
  944.  
  945.                                                                                                 if ($myDir["is_link"]==1)
  946.                                                                                                 {
  947.                                                                                                         $fileAction = "cd";
  948.                                                                                                         $fileName = $myDir["target"];
  949.                                                                                                         $fileSize="";
  950.                                                                                                         $delAction = "delfile";
  951.                                                                                                         $fileType['description'] = 'Symbolic Link';
  952.                                                                                                         $fileType['imgfilename'] = 'link.gif';
  953.                                                                                                 }
  954.  
  955.                                                                                                 if ($myDir["is_link"]!=1 && $myDir["is_dir"]!=1)
  956.                                                                                                 {
  957.                                                                                                         $fileType = fileDescription($myDir["name"]);
  958.                                                                                                         $fileAction = "get";
  959.                                                                                                         $fileName = $myDir["name"];
  960.                                                                                                         $image = "file.gif";
  961.                                                                                                         if($myDir["size"]<1024) {
  962.                                                                                                                 $fileSize= $myDir["size"] . " bytes ";
  963.                                                                                                                         $fileSize=number_format($myDir["size"], 0, ',', '.') . " bytes";
  964.                                                                                                         } else {
  965.                                                                                                                 if($myDir["size"]<1073741824) {
  966.                                                                                                                         $fileSize=number_format($myDir["size"]/1024, 0, ',', '.') . " KB";
  967.                                                                                                                 } else {
  968.                                                                                                                         $fileSize=number_format($myDir["size"]/1048576, 0, ',', '.') . " MB";
  969.                                                                                                                 }
  970.                                                                                                         }
  971.  
  972.                                                                                                        
  973.                                                                                                         $delAction = "delfile";
  974.                                                                                                 }
  975.  
  976.                                                                                                 $escapedFileName = addslashes($fileName);
  977.         ?>
  978.                       <tr>
  979.                           <td class="filenamecol" width="20"><a href="javascript:selectEntry('<?=$fileAction?>','<?=$escapedFileName?>','filename<?=$counter?>','<?=addslashes($myDir["user"])?>','<?=$myDir["perms"]?>','<?=$delAction;?>')" onDblClick="submitForm('<?=$fileAction;?>','<?=$escapedFileName?>')"><img src="img/<?=$fileType['imgfilename'];?>" align="top" border="0" alt=""/></a></td>
  980.                           <td class="filenamecol"><a class="filename" id='filename<?=$counter;?>' href="javascript:selectEntry('<?=$fileAction?>','<?=$escapedFileName?>','filename<?=$counter?>','<?=$myDir["user"]?>','<?=$myDir["perms"];?>','<?=$delAction;?>')" onDblClick="submitForm('<?=$fileAction;?>','<?=$escapedFileName?>')">
  981.                             <?=$fileName;?>
  982.                             </A></td>
  983.                           <td class="listcol" align="right"><?=$fileSize;?></td>
  984.                           <td class="listcol" align="left"><?=$fileType['description'];?></td>
  985.                           <td class="listcol"><?=$myDir["date"];?></td>
  986.                           <td class="listcol"><?=$myDir["perms"];?></td>
  987.                           <td class="listcol"><?=$myDir["user"];?></td>
  988.                           <td class="listcol"><?=$myDir["group"];?></td>
  989.                         </tr>
  990.                       <?
  991.                                                                                                 $counter++;
  992.                                                                                         }
  993.                                                                                 } else {
  994. ?>
  995.                       <tr>
  996.                           <td colspan=14><b>
  997.                             <?=$lblDirectoryEmpty;?>
  998.                             ...</b></td>
  999.                         </tr>
  1000.                       <?
  1001.                                                                                 }
  1002. ?>
  1003.                     </table>
  1004.                     </div></td>
  1005.                 </tr>
  1006.               </table></td>
  1007.           </tr>
  1008.         </table>
  1009. </body>
  1010. </html>
  1011. <?///END FILE MANAGER///?>
  1012. <?
  1013.                 }
  1014.                 else
  1015.                 {
  1016.                         if(!isset($msg))
  1017.                         {
  1018.                                 $msg = "$lblCouldNotConnectToServer  $server:$port $lblWithUser $user<p><a href='" . $_SERVER["PHP_SELF"] . "'>$lblTryAgain</A>";
  1019.                                 unset($_SESSION['server']);
  1020.                                 unset($_SESSION['user']);
  1021.                                 unset($_SESSION['password']);
  1022.                                 unset($_SESSION['port']);
  1023.                                 session_destroy();
  1024.                         }
  1025.                         print $msg;
  1026.                 }
  1027.         }
  1028.         else // Still need to logon...
  1029.         {
  1030.                 if ($disableLoginScreen == false)
  1031.                 {
  1032. ?>
  1033. <?///BEGIN LOGIN SCREEN///?>
  1034. <?
  1035. echo <<<XML
  1036. <?xml version="1.0" encoding="UTF-8"?>
  1037. XML;
  1038. ?>
  1039. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  1040.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  1041.  
  1042. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  1043. <head>
  1044. <title>phpWebFTP
  1045. <?=$currentVersion;?>
  1046. By Edwin van Wijk</title>
  1047. <link rel="stylesheet" href="style/cm.css" title="contemporary" type="text/css"/>
  1048. <script type="text/javascript" src="include/script.js"></script>
  1049. </head>
  1050. <body>
  1051. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  1052.   <tr>
  1053.     <td class="titlebar"><B>phpWebFTP
  1054.       <?=$lblVersion;?>
  1055.       <?=$currentVersion;?>
  1056.       </B></td>
  1057.   </tr>
  1058.   <tr>
  1059.     <td class="menu"><table cellpadding="0" cellspacing="0">
  1060.         <tr>
  1061.           <td valign="middle"><img src="img/1px.gif" height="24" border="0" align="middle" alt=""/></td>
  1062.           <td valign="middle">&nbsp;</td>
  1063.         </tr>
  1064.       </table></td>
  1065.   </tr>
  1066. </table>
  1067. <form name="login" action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
  1068.   <table class="login" cellpadding="3">
  1069.     <tr>
  1070.       <td colspan="3"><b>&nbsp;
  1071.         <?=$lblLogIn;?>
  1072.         </b></td>
  1073.     </tr>
  1074.     <tr>
  1075.       <td colspan="3"><img src="img/1px.gif" height="60" alt=""/></td>
  1076.     </tr>
  1077.     <tr>
  1078.       <td colspan="3">&nbsp;
  1079.         <?=$lblConnectToFTPServer;?></td>
  1080.     </tr>
  1081.     <tr>
  1082.       <td valign="top">&nbsp;
  1083.         <?=$lblServer;?></td>
  1084.       <td valign="top"><?php
  1085.                                                         if($defaultServer == "")
  1086.                                                         {
  1087. ?>
  1088.         <input type="text" name="server" size="15"/>
  1089.         &nbsp;
  1090.         <?
  1091.                                                         }
  1092.                                                         else
  1093.                                                         {
  1094.                                                                 $inputType=($editDefaultServer==true)?"text":"hidden";
  1095. ?>
  1096.         <input type="<?=$inputType?>" name="server" value="<?=$defaultServer?>">
  1097.         <?
  1098.                                                                 if($editDefaultServer==false) {
  1099. ?>
  1100.         <b>
  1101.         <?=$defaultServer?>
  1102.         </b>&nbsp;
  1103.         <?
  1104.                                                                 }
  1105.                                                         }
  1106.                                                 ?></td>
  1107.       <td valign="top"><table cellspacing="0">
  1108.           <tr>
  1109.             <td><?=$lblPort;?></td>
  1110.             <td><input type="text" name="port" size="3" value="21"/></td>
  1111.           </tr>
  1112.           <tr>
  1113.             <td><?=$lblPasive;?></td>
  1114.             <td><input type="checkbox" name="goPassive"/></td>
  1115.           </tr>
  1116.         </table></td>
  1117.     </tr>
  1118.     <tr>
  1119.       <td>&nbsp;
  1120.         <?=$lblUser;?></td>
  1121.       <td><input type="text" name="user" size="18"/></td>
  1122.       <td>&nbsp;</td>
  1123.     </tr>
  1124.     <tr>
  1125.       <td>&nbsp;
  1126.         <?=$lblPassword;?></td>
  1127.       <td><input type="password" name="password" size="18"/></td>
  1128.       <td><input type="submit" value="Log on"/></td>
  1129.     </tr>
  1130.     <?
  1131.                                 if($defaultLanguage == "")
  1132.                                 {
  1133. ?>
  1134.     <tr>
  1135.       <td>&nbsp;
  1136.         <?=$lblLanguage;?></td>
  1137.       <td colspan=2><select name="language">
  1138.           <?
  1139.                                                                 if ($handle = opendir('include/language/'))
  1140.                                                                 {
  1141.                                                                         //Read file in directory and store them in an Array
  1142.                                                                         while (false !== ($file = readdir($handle)))
  1143.                                                                         {
  1144.                                                                                 $fileArray[$file] = $file;
  1145.                                                                         }
  1146.                                                                         //Sort the array
  1147.                                                                         ksort($fileArray);
  1148.  
  1149.                                                                         foreach($fileArray as $file) {
  1150.                                                                                 if ($file != "." && $file != ".." ) {
  1151.                                                                                         $file=str_replace(".lang.php","",$file);
  1152.                                                                                         $counter=0;
  1153.                                                                                         foreach($languages as $thislang)
  1154.                                                                                         {
  1155.                                                                                                 if($thislang==$file)
  1156.                                                                                                 {
  1157.                                                                                                         $counter++;
  1158.                                                                                                 }
  1159.                                                                                         }
  1160.                                                                                         if($counter>0) {
  1161.                                                                                                 $langName=strtoupper(substr($file,0,1)) . substr($file,1);
  1162. ?>
  1163.           <option value="<?=$file;?>" <?=($language==$file)?"selected=\"selected\"":"";?>>
  1164.           <?=$langName;?>
  1165.           </option>
  1166.           <?
  1167.                                                                                         }
  1168.  
  1169.                                                                                 }
  1170.                                                                         }
  1171.                                                                         closedir($handle);
  1172.                                                                 }
  1173. ?>
  1174.         </select></td>
  1175.     </tr>
  1176.     <?
  1177.                                 }
  1178. ?>
  1179.     <tr>
  1180.       <td colspan="2"><img src="img/1px.gif" height="5" alt=""/></td>
  1181.     </tr>
  1182.   </table>
  1183.   <table width="328">
  1184.     <tr>
  1185.       <td colspan="2" valign="top" class="leftmenuitem"><div style='font-size:7pt;'>
  1186.           <?=$lblDisclaimer;?>
  1187.           <br/>
  1188.           <br/>
  1189.           phpWebFTP
  1190.           <?=$lblVersion;?>
  1191.           <?=$currentVersion;?>
  1192.           <br/>
  1193.           &copy; 2002-2004, Edwin van Wijk,<br/>
  1194.           <a href="http://www.v-wijk.net" style='font-size:7pt;'>www.v-wijk.net</a> </div></td>
  1195.     </tr>
  1196.     <tr>
  1197.       <td align=left>&nbsp;</td>
  1198.       <td align=right>&nbsp;</td>
  1199.     </tr>
  1200.   </table>
  1201. </form>
  1202. </body>
  1203. </html>
  1204. <?///END LOGIN SCREEN///?>
  1205. <?
  1206.                 }
  1207.                 else
  1208.                 {
  1209. ?>
  1210. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  1211.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  1212.  
  1213. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  1214.                 <head>
  1215.                 <title>Login disabled</title>
  1216.                 <style type="text/css">
  1217. body {
  1218.         font-family: Verdana, sans-serif;
  1219. }
  1220. </style>
  1221.                 </head>
  1222.                 <body>
  1223. Manual login functionality is disabled by your provider. <a href="#" onClick="window.close();">Close window</a>
  1224. </body>
  1225. </html>
  1226. <?
  1227.                 }
  1228.         }
  1229. ?>
  1230.  

回复 "web版ftp工具 phpWebFTP"

这儿你可以回复上面这条便签

downloadDir . $file); exit; break; case "saveFile": //Write content of fileContent to tempFile $tempFile = "tmpFile.txt"; $fp = fopen($ftp->downloadDir . $tempFile, "w+t"); if ($bytes=!fwrite($fp, stripslashes($fileContent))) { $msg = $lblFileCouldNotBeUploaded; } fclose($fp); //Upload the file to the server if(!$ftp->put($ftp->currentDir . "/" . filePart(StripSlashes($file)),$ftp->downloadDir . $tempFile)) $msg = $lblFileCouldNotBeUploaded; //Delete temporary file unlink($ftp->downloadDir . $tempFile); break; case "getzip": set_time_limit(30); //for big archives $zipfile = $file . ".zip"; // a directory for every user, just in case... $dir = $ftp->downloadDir . $ftp->userDir . "/"; header("Content-disposition: attachment; filename=\"$zipfile\""); header("Content-type: application/octetstream"); header("Pragma: "); header("Cache-Control: cache"); header("Expires: 0"); $zipfile = $ftp->downloadDir . $zipfile; //Create temporary directory mkdir($dir); //Get entire directory and store to temporary directory $ftp->getRecursive($ftp->currentDir, $file); //zip the directory $zip = new ss_zip('',6); $zip->zipDirTree($dir, $dir); $zip->save($zipfile); //send zipfile to the browser $filearray = explode("/",$zipfile); $file = $filearray[sizeof($filearray)-1]; $data = readfile($zipfile); $i=0; while ($data[$i] != "") { echo $data[$i]; $i++; } //Delete zip file unlink($zipfile); //Delete downloaded files from user specific directory deleteRecursive($dir); exit; break; case "unzip": // BK20061114 set_time_limit(30); //for big archives $dir = $ftp->downloadDir . $ftp->userDir . "/"; // 1. download $ftp->get($file); // 2. mkdir mkdir($dir); chdir($dir); // 3. unzip $cmd = false; foreach ($uncompress as $key=>$value) { if (!$cmd and preg_match("/\.$key$/", $file)) { $dir = preg_replace("/\.$key$/", "", $file); $cmd = $value; } } // 4. recursive upload if ($cmd) { mkdir($dir); chdir($dir); `$cmd ../../$file`; chdir(".."); $ftp->putRecursive($dir); } } } ?> XML; ?> phpWebFTP <?=$currentVersion;?> By Edwin van Wijk
phpWebFTP
mode==1)?0:1; if($ftp->loggedOn) { ?>
" enctype="multipart/form-data">




loggedOn)?"$lblConnectedTo $server:$port ($ftp->systype)":$lblNotConnected;?>

: mode==1?$lblBinaryMode:$lblASCIIMode;?>

ftpRawList(); if (is_array($list)) { // Directories $counter=0; foreach($list as $myDir) { if ($myDir["is_dir"]==1) { $fileAction = "cd"; $fileName = $myDir["name"]; $fileSize=""; $delAction = "deldir"; $fileType['description'] = 'File Folder'; $fileType['imgfilename'] = 'folder.gif'; } if ($myDir["is_link"]==1) { $fileAction = "cd"; $fileName = $myDir["target"]; $fileSize=""; $delAction = "delfile"; $fileType['description'] = 'Symbolic Link'; $fileType['imgfilename'] = 'link.gif'; } if ($myDir["is_link"]!=1 && $myDir["is_dir"]!=1) { $fileType = fileDescription($myDir["name"]); $fileAction = "get"; $fileName = $myDir["name"]; $image = "file.gif"; if($myDir["size"]<1024) { $fileSize= $myDir["size"] . " bytes "; $fileSize=number_format($myDir["size"], 0, ',', '.') . " bytes"; } else { if($myDir["size"]<1073741824) { $fileSize=number_format($myDir["size"]/1024, 0, ',', '.') . " KB"; } else { $fileSize=number_format($myDir["size"]/1048576, 0, ',', '.') . " MB"; } } $delAction = "delfile"; } $escapedFileName = addslashes($fileName); ?>
   
','','')" onDblClick="submitForm('','')"> ','','')" onDblClick="submitForm('','')">
...
$lblTryAgain"; unset($_SESSION['server']); unset($_SESSION['user']); unset($_SESSION['password']); unset($_SESSION['port']); session_destroy(); } print $msg; } } else // Still need to logon... { if ($disableLoginScreen == false) { ?> XML; ?> phpWebFTP <?=$currentVersion;?> By Edwin van Wijk
phpWebFTP


phpWebFTP
© 2002-2004, Edwin van Wijk,
www.v-wijk.net
   
Login disabled Manual login functionality is disabled by your provider. Close window
captcha