Пример #1
0
<?php

$host = "127.0.0.1";
$user = "******";
$pass = "******";
$localFile = "/home/test1.txt";
$remoteFile = "/home/test2.txt";
include "class.shell2.php";
$ssh = new shell2();
// init class
// connect server
if ($ssh->login($user, $pass, $host)) {
    //SSH Command
    $ssh->exec_cmd("ls -la");
    echo $ssh->get_output();
    //SFTP Send/Upload to remote server
    //$ssh->send(localFile,remoteFile,filePermission)
    if ($ssh->send_file($localFile, $remoteFile, 0755)) {
        echo "File has been uploaded\n";
    } else {
        echo $ssh->error;
    }
    //SFTP Get/Download from remote server
    if ($ssh->get_file($remoteFile, $localFile)) {
        echo "File has been downloaded\n";
    } else {
        echo $ssh->error;
    }
} else {
    echo $ssh->error;
}
Пример #2
0
function removeFileFromEVENTS($remoteFile = '')
{
    global $configArray;
    $fi = "classes/class.shell2.php";
    if (file_exists($fi)) {
        require_once $fi;
    } else {
        echo "Nu am putut include un fisier. (ssh2)";
        exit;
    }
    //define ("LOG_NONE", 0) ;  // No log
    //define ("LOG_ECHO", 1) ;	// Echo to screen
    //define ("LOG_HIDE", 2) ;	// Echo to HTML comment <!-- -->
    //define ("LOG_FILE", 3) ;	// Echo to file
    $ssh = new shell2();
    if ($ssh->login($configArray['EventsFtpUser'], $configArray['EventsFtpPass'], $configArray['EventsFtpHost'])) {
        //SFTP Send/Upload to remote server
        //$ssh->send(localFile,remoteFile,filePermission)
        if ($ssh->delete_file('/var/web/events.ancs.ro/uploads/' . $remoteFile)) {
            //echo "File has been deleted\n";
            return true;
        } else {
            echo $ssh->error;
        }
    } else {
        echo $ssh->error;
    }
}