示例#1
0
 /**
  * Runs a functional test
  */
 function run_test()
 {
     $ftp = new ftp_client("localhost", 21, "user", "pass");
     $ftp->debug_level = 1;
     $ftp->open();
     if ($ftp->login()) {
         $t = 'test.txt';
         $ftp->cd("public_html");
         $ftp->put(__FILE__, $t);
         $ftp->chmod($t, 777);
         $buff = $ftp->get($t);
         if ($buff) {
             echo "<pre>" . htmlspecialchars($buff) . "</pre>";
             $ftp->delete($t);
         }
         $ftp->close();
     } else {
         $ftp->error('Login incorrect', E_USER_ERROR);
     }
 }
 public static function rename($path, $old, $new)
 {
     if ($_SESSION['transfer_type'] == "ftp") {
         $ftp = new ftp_client();
         return $ftp->rename($path, $old, $new);
     } else {
         $ssh2 = new scp_client();
         return $ssh2->rename($path, $old, $new);
     }
 }