コード例 #1
0
function escribe_archivo_via_sftp($cadena, $nombre_archivo_remoto = "", $factura_id, $fe_folio)
{
    $sql_update = "update vta_p_facturas set \n\tFE_SERIE='A', FE_FOLIO={$fe_folio}\n\twhere (FE_SERIE = '' OR FE_SERIE IS NULL or FE_SERIE=0) AND (FE_FOLIO = '' OR FE_FOLIO IS NULL or FE_FOLIO =0) \n\tAND FACTURA_ID=" . $factura_id;
    $result_update = mysql_db_query(DB_NAME, $sql_update);
    // echo $sql_update;
    define("TEPath", "../TableEditor/");
    include '../TableEditor/Net/SFTP.php';
    //  $ftp_sitio="demo-partners.xsa.com.mx";
    //  $ftp_usuario="testftpfacciisa";
    //  $ftp_pass="******";
    $ftp_sitio = "173.205.255.84";
    $ftp_usuario = "ftpciisa";
    $ftp_pass = "******";
    $sftp = new Net_SFTP($ftp_sitio);
    if (!$sftp->login($ftp_usuario, $ftp_pass)) {
        exit('Acceso incorrecto..');
    }
    $sftp->put($nombre_archivo_remoto, utf8_encode($cadena));
    $sftp->chdir("1");
    $sftp->put($nombre_archivo_remoto, utf8_encode($cadena));
    $folio_fiscal = consulta("select FOLIO_FISCAL from vta_p_facturas WHERE FACTURA_ID=" . $factura_id);
    $folio_fiscal = $folio_fiscal["FOLIO_FISCAL"];
    //echo $fe_serie["FE_FOLIO"]."+";
    echo "Envio exitoso... Factura " . $folio_fiscal;
}
コード例 #2
0
ファイル: PwSftpSave.php プロジェクト: fanqimeng/4tweb
 public function upload($localfile, $remotefile, $mode = null)
 {
     if (!in_array($savedir = dirname($remotefile), array('.', '/'))) {
         $this->mkdirs($savedir);
     }
     $remotefile = $this->rootPath . WindSecurity::escapePath($remotefile);
     return $this->conn->put($remotefile, $localfile, NET_SFTP_LOCAL_FILE);
 }
コード例 #3
0
ファイル: SftpHelper.php プロジェクト: giovdk21/deployii
 /**
  * @param string $remoteFile
  * @param string $localFile
  * @param int    $startPos
  *
  * @return bool
  */
 public function put($remoteFile, $localFile, $startPos = -1)
 {
     switch ($this->_connType) {
         case SftpHelper::TYPE_SFTP:
         default:
             $res = $this->_connection->put($remoteFile, $localFile, NET_SFTP_LOCAL_FILE, $startPos);
             break;
         case SftpHelper::TYPE_FTP:
             $startPos = $startPos === -1 ? 0 : $startPos;
             $res = @ftp_put($this->_connection, $remoteFile, $localFile, FTP_BINARY, $startPos);
             break;
     }
     return $res;
 }
コード例 #4
0
ファイル: tmp1234.php プロジェクト: avijitdeb/flatterbox.com
function sftp_printer($xml_file)
{
    if (strrpos(get_include_path(), "phpseclib0.3.0") === false) {
        set_include_path(get_include_path() . PATH_SEPARATOR . './phpseclib0.3.0');
        // Staging requires the ../ to be ./
    }
    include 'Net/SFTP.php';
    $rtn = false;
    $sftp = new Net_SFTP('ftp.tginc.com', 2222);
    if (isset($_GET['tID'])) {
        echo $sftp->login('flatterbox', 'T&!Fl@!!er');
    }
    //if ( isset($_GET['tID']) ) : print_r( $sftp->getSupportedVersions() ); endif;
    if (!$sftp->login('flatterbox', 'T&!Fl@!!er') || true) {
        $rtn = 'Login Failed';
    }
    $local_directory = './orderlist/';
    // Set in previous function -- orderlist/';
    $remote_directory = '/incoming/';
    //echo $local_directory.'<br/>';
    //echo $remote_directory.'<br/>';
    $files_to_upload = array();
    if ($xml_file != "." && $xml_file != "..") {
        $files_to_upload[] = $xml_file;
    }
    if (!empty($files_to_upload) && $rtn == false) {
        foreach ($files_to_upload as $file) {
            /*
            echo dirname(__FILE__).'<br/>';
            echo $file.'<br/>';
            echo $local_directory . $file.'<br/>';
            */
            //$rtn = $sftp->put($remote_directory . $file, $local_directory . $file, NET_SFTP_LOCAL_FILE);
            $data = file_get_contents($local_directory . $file);
            if (isset($_GET['tID'])) {
                echo $data;
            }
            $rtn = $sftp->put($remote_directory . $file, $data);
        }
    }
    return $rtn;
    /*
    	$conn = ssh2_connect('ftp.tginc.com', 2222);
    	ssh2_auth_password($conn, 'flatterbox', 'T&!Fl@!!er');
    
    	// send a file
    	return ssh2_scp_send($conn, $local_directory.$xml_file, $remote_directory.$xml_file, 0644);
    */
}
コード例 #5
0
ファイル: CSFTP.class.php プロジェクト: fbone/mediboard4
 /**
  * Add a file
  *
  * @param String $file_name   name of the target file
  * @param String $source_file source path
  * @param Bool   $data_string The source file is a content or a path
  *
  * @return bool
  * @throws CMbException
  */
 private function _addFile($file_name, $source_file, $data_string = true)
 {
     if (!$this->connexion) {
         throw new CMbException("CSourceSFTP-connexion-failed", $this->hostname);
     }
     // Upload the file
     if ($data_string) {
         if (!$this->connexion->put($file_name, $source_file)) {
             throw new CMbException("CSourceSFTP-upload-file-failed", $source_file);
         }
     } else {
         if (!$this->connexion->put($file_name, $source_file, NET_SFTP_LOCAL_FILE)) {
             throw new CMbException("CSourceSFTP-upload-file-failed", $source_file);
         }
     }
     return true;
 }
コード例 #6
0
 /**
  * Write a file
  *
  * @param string $filename
  * @param string $source string data or local file name
  * @param int $mode ignored parameter
  * @return bool
  */
 public function write($filename, $source, $mode = null)
 {
     $mode = is_readable($source) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING;
     return $this->_connection->put($filename, $source, $mode);
 }
コード例 #7
0
ファイル: gen_hl7_order.inc.php プロジェクト: minggLu/openemr
/**
 * Transmit HL7 for the specified lab.
 *
 * @param  integer $ppid  Procedure provider ID.
 * @param  string  $out   The HL7 text to be sent.
 * @return string         Error text, or empty if no errors.
 */
function send_hl7_order($ppid, $out)
{
    global $srcdir;
    $d0 = "\r";
    $pprow = sqlQuery("SELECT * FROM procedure_providers " . "WHERE ppid = ?", array($ppid));
    if (empty($pprow)) {
        return xl('Procedure provider') . " {$ppid} " . xl('not found');
    }
    $protocol = $pprow['protocol'];
    $remote_host = $pprow['remote_host'];
    // Extract MSH-10 which is the message control ID.
    $segmsh = explode(substr($out, 3, 1), substr($out, 0, strpos($out, $d0)));
    $msgid = $segmsh[9];
    if (empty($msgid)) {
        return xl('Internal error: Cannot find MSH-10');
    }
    if ($protocol == 'DL' || $pprow['orders_path'] === '') {
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename=order_{$msgid}.hl7");
        header("Content-Description: File Transfer");
        echo $out;
        exit;
    } else {
        if ($protocol == 'SFTP') {
            ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . "{$srcdir}/phpseclib");
            require_once "{$srcdir}/phpseclib/Net/SFTP.php";
            // Compute the target path/file name.
            $filename = $msgid . '.txt';
            if ($pprow['orders_path']) {
                $filename = $pprow['orders_path'] . '/' . $filename;
            }
            // Connect to the server and write the file.
            $sftp = new Net_SFTP($remote_host);
            if (!$sftp->login($pprow['login'], $pprow['password'])) {
                return xl('Login to this remote host failed') . ": '{$remote_host}'";
            }
            if (!$sftp->put($filename, $out)) {
                return xl('Creating this file on remote host failed') . ": '{$filename}'";
            }
        } else {
            if ($protocol == 'FS') {
                // Compute the target path/file name.
                $filename = $msgid . '.txt';
                if ($pprow['orders_path']) {
                    $filename = $pprow['orders_path'] . '/' . $filename;
                }
                $fh = fopen("{$filename}", 'w');
                if ($fh) {
                    fwrite($fh, $out);
                    fclose($fh);
                } else {
                    return xl('Cannot create file') . ' "' . "{$filename}" . '"';
                }
            } else {
                return xl('This protocol is not implemented') . ": '{$protocol}'";
            }
        }
    }
    // Falling through to here indicates success.
    newEvent("proc_order_xmit", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "ID: {$msgid} Protocol: {$protocol} Host: {$remote_host}");
    return '';
}
コード例 #8
0
ファイル: init.php プロジェクト: elephantcode/elephantcode
 public static function test($settings)
 {
     self::_init();
     // Connect to server.
     $server = $settings['address'];
     $port = '22';
     // Default sFTP port.
     if (strstr($server, ':')) {
         // Handle custom sFTP port.
         $server_params = explode(':', $server);
         $server = $server_params[0];
         $port = $server_params[1];
     }
     pb_backupbuddy::status('details', 'Connecting to sFTP server...');
     $sftp = new Net_SFTP($server, $port);
     if (!$sftp->login($settings['username'], $settings['password'])) {
         pb_backupbuddy::status('error', 'Connection to sFTP server FAILED.');
         pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.');
         return __('Unable to connect to server using host, username, and password combination provided.', 'it-l10n-backupbuddy');
     } else {
         pb_backupbuddy::status('details', 'Success connecting to sFTP server.');
     }
     pb_backupbuddy::status('details', 'Attempting to create path (if it does not exist)...');
     if (true === $sftp->mkdir($settings['path'])) {
         // Try to make directory.
         pb_backupbuddy::status('details', 'Directory created.');
     } else {
         pb_backupbuddy::status('details', 'Directory not created.');
     }
     $destination_file = $settings['path'] . '/backupbuddy_test.txt';
     pb_backupbuddy::status('details', 'About to put to sFTP test file `backupbuddy_test.txt` to remote location `' . $destination_file . '`.');
     $send_time = -microtime(true);
     if (true !== $sftp->put($destination_file, 'Upload test for BackupBuddy destination. Delete me.')) {
         pb_backupbuddy::status('details', 'sFTP test: Failure uploading test file.');
         $sftp->delete($destination_file);
         // Just in case it partionally made file. This has happened oddly.
         pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.');
         return __('Failure uploading. Check path & permissions.', 'it-l10n-backupbuddy');
     } else {
         // File uploaded.
         pb_backupbuddy::status('details', 'File uploaded.');
         if ($settings['url'] != '') {
             $response = wp_remote_get(rtrim($settings['url'], '/\\') . '/backupbuddy_test.txt', array('method' => 'GET', 'timeout' => 20, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => null, 'cookies' => array()));
             if (is_wp_error($response)) {
                 return __('Failure. Unable to connect to the provided optional URL.', 'it-l10n-backupbuddy');
             }
             if (stristr($response['body'], 'backupbuddy') === false) {
                 return __('Failure. The path appears valid but the URL does not correspond to it. Leave the URL blank if not using this destination for migrations.', 'it-l10n-backupbuddy');
             }
         }
         pb_backupbuddy::status('details', 'sFTP test: Deleting temp test file.');
         $sftp->delete($destination_file);
     }
     return true;
     // Success if we got this far.
 }
コード例 #9
0
ファイル: Sftp.php プロジェクト: Airmal/Magento-Em
 /**
  * Write a file
  * @param $src Must be a local file name
  */
 public function write($filename, $src, $mode = null)
 {
     return $this->_connection->put($filename, $src);
 }
コード例 #10
0
ファイル: functions_ts3.php プロジェクト: Eun/developer
function tsdns($action, $sship, $sshport, $sshuser, $keyuse, $sshkey, $sshpw, $notified, $path, $bitversion, $tsip, $tsport, $tsdns, $reseller_id, $maxnotified = 2)
{
    global $sql;
    $sshSftpObject = new Net_SFTP($sship, $sshport);
    if ($keyuse != 'N') {
        $privateKey = EASYWIDIR . '/keys/' . removePub($sshkey);
        $sshpw = new Crypt_RSA();
        if ($keyuse == 'B') {
            $sshpw->setPassword($sshpw);
        }
        $keyContent = @file_get_contents($privateKey);
        if ($keyContent) {
            $sshpw->loadKey($keyContent);
        }
    }
    if ($sshSftpObject->login($sshuser, $sshpw)) {
        $split_config = preg_split('/\\//', $path, -1, PREG_SPLIT_NO_EMPTY);
        $folderfilecount = count($split_config) - 1;
        $i = 0;
        $folders = substr($path, 0, 1) == '/' ? '/' : '';
        $lastFolder = '';
        while ($i <= $folderfilecount) {
            $folders .= $split_config[$i] . '/';
            $lastFolder = $split_config[$i];
            $i++;
        }
        if ($lastFolder != 'tsdns' or substr($path, 0, 1) != '/') {
            $folders .= 'tsdns/';
        }
        if ($action == 'md' or $action == 'dl') {
            $newip = $tsip[0];
            $oldip = isset($tsip[1]) ? $tsip[1] : '';
            $newport = $tsport[0];
            $oldport = isset($tsport[1]) ? $tsport[1] : '';
            $newdns = $tsdns[0];
            $olddns = isset($tsdns[1]) ? $tsdns[1] : '';
        } else {
            $dnsarray = array();
        }
        $file = substr($path, 0, 1) == '/' ? $folders . 'tsdns_settings.ini' : '/home/' . $sshuser . '/' . $folders . 'tsdns_settings.ini';
        if ($action != 'rs') {
            $data = $sshSftpObject->get($file);
            $data = str_replace(array("", "\\b", "\r", "\\Z"), '', $data);
        }
        if ($action != 'rs' and $action != 'mw') {
            $edited = false;
            $ca = array();
            foreach (preg_split('/\\n/', $data, -1, PREG_SPLIT_NO_EMPTY) as $configLine) {
                if ($action != 'li' and $configLine != $olddns . '=' . $oldip . ':' . $oldport and $configLine != $newdns . '=' . $newip . ':' . $newport) {
                    $ca[] = $configLine . "\r\n";
                } else {
                    if ($action == 'md' and $edited == false and ($configLine == $olddns . '=' . $oldip . ':' . $oldport or $configLine == $newdns . '=' . $newip . ':' . $newport)) {
                        $edited = true;
                        $ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n";
                    }
                }
                if ($action == 'li' and $configLine != '' and !preg_match('/^#(|\\s+)(.*)$/', $configLine)) {
                    $dnsconfig = explode('=', $configLine);
                    if (isset($dnsconfig[1])) {
                        $linedns = $dnsconfig[0];
                        $lineserver = $dnsconfig[1];
                        $dnsarray[$lineserver] = $linedns;
                    }
                }
            }
            if ($action == 'md' and $edited == false) {
                $ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n";
            }
            if ($action != 'li') {
                $ca = array_unique($ca);
                sort($ca);
                $newcfg = '';
                foreach ($ca as $line) {
                    $newcfg .= $line;
                }
                if ($newcfg == '') {
                    $newcfg = '# No TSDNS data entered';
                }
                $sshSftpObject->put($file, $newcfg);
            }
        }
        if ($action == 'mw' and isset($data)) {
            $usedIPs = array();
            foreach (preg_split('/\\n/', $data, -1, PREG_SPLIT_NO_EMPTY) as $configLine) {
                if ($configLine != '' and !preg_match('/^#(|\\s+)(.*)$/', $configLine)) {
                    $splittedLine = preg_split('/\\=/', $configLine, -1, PREG_SPLIT_NO_EMPTY);
                    $usedIPs[] = isset($splittedLine[1]) ? array('dns' => $splittedLine[0], 'address' => $splittedLine[1]) : $configLine;
                } else {
                    $usedIPs[] = $configLine;
                }
            }
            foreach ($tsip as $newLine) {
                $splittedLine = preg_split('/\\=/', strtolower($newLine), -1, PREG_SPLIT_NO_EMPTY);
                if (isset($splittedLine[1]) and !array_key_exists($splittedLine[1], $usedIPs)) {
                    $usedIPs[] = array('dns' => $splittedLine[0], 'address' => $splittedLine[1]);
                }
            }
            function array_multi_dimensional_unique($multi)
            {
                $unique = array();
                foreach ($multi as $sub) {
                    if (!in_array($sub, $unique)) {
                        $unique[] = $sub;
                    }
                }
                return $unique;
            }
            $newCfg = '';
            $usedIPs = array_multi_dimensional_unique($usedIPs);
            sort($usedIPs);
            foreach ($usedIPs as $value) {
                $newCfg .= (isset($value['dns']) and isset($value['address']) and !preg_match('/^#(|\\s+)(.*)$/', $value['dns'])) ? $value['dns'] . '=' . $value['address'] . "\r\n" : $value . "\r\n";
            }
            if ($newCfg == '') {
                $bad = 'Nothing to write';
            } else {
                $sshSftpObject->put($file, $newCfg);
            }
        }
        if (!isset($bad) and $action != 'li') {
            $sshObject = new Net_SSH2($sship, $sshport);
            if ($sshObject->error === false) {
                if ($sshObject->login($sshuser, $sshpw)) {
                    $bin = $bitversion == 32 ? 'tsdnsserver_linux_x86' : 'tsdnsserver_linux_amd64';
                    $ssh2cmd = 'cd ' . $folders . ' && function restart () { if [ "`ps fx | grep ' . $bin . ' | grep -v grep`" == "" ]; then ./' . $bin . ' > /dev/null & else ./' . $bin . ' --update > /dev/null & fi }; restart& ';
                    $sshObject->exec($ssh2cmd);
                    if ($notified > 0) {
                        $query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`=0 WHERE `ssh2ip`=? AND `resellerid`=? LIMIT 1");
                        $query->execute(array($sship, $reseller_id));
                    }
                } else {
                    $bad = 'The login data does not work';
                    $notified++;
                }
            } else {
                $bad = 'Could not connect to Server';
                $notified++;
            }
        }
    } else {
        $bad = 'Could not connect to Server';
    }
    if (isset($bad) and $notified == $maxnotified) {
        if ($reseller_id == 0) {
            $query = $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE `resellerid`=0 AND `accounttype`='a'");
            $query->execute();
        } else {
            $query = $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE (`id`=? AND `id`=`resellerid`) OR (`resellerid`=0 AND `accounttype`='a')");
            $query->execute(array($reseller_id));
        }
        while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
            if ($row['mail_serverdown'] == 'Y') {
                sendmail('emaildown', $row['id'], 'TS3 Master ' . $sship . ' ( ' . $bad . ' )', '');
            }
        }
        $query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`=`notified`+1 WHERE `ssh2ip`=? AND `resellerid`=? LIMIT 1");
        $query->execute(array($sship, $reseller_id));
        return $bad;
    } else {
        if (isset($bad)) {
            return $bad;
        } else {
            if ($action == 'li' and isset($dnsarray)) {
                return $dnsarray;
            }
        }
    }
    return 'ok';
}
コード例 #11
0
 /**
  * This method is called in response to fwrite()
  *
  * Writes to stream
  *
  * @param String $data
  * @return mixed
  * @access public
  */
 public function stream_write($data)
 {
     switch ($this->mode) {
         case 'r':
         case 'x':
         case 'x+':
             return FALSE;
     }
     $this->sftp->put($this->path, $data, NET_SFTP_STRING, $this->position);
     $this->position += strlen($data);
     return strlen($data);
 }
コード例 #12
0
 function ftp_backup($args)
 {
     extract($args);
     //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder
     if (isset($use_sftp) && $use_sftp == 1) {
         $port = $ftp_port ? $ftp_port : 22;
         //default port is 22
         /*
          * SFTP section start here phpseclib library is used for this functionality
          */
         $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
         $path = $iwp_mmb_plugin_dir . '/lib/phpseclib';
         set_include_path(get_include_path() . PATH_SEPARATOR . $path);
         include_once 'Net/SFTP.php';
         $sftp = new Net_SFTP($ftp_hostname, $port);
         if (!$sftp) {
             return array('error' => 'Failed to connect to ' . $ftp_hostname, 'partial' => 1);
         }
         if (!$sftp->login($ftp_username, $ftp_password)) {
             return array('error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password, 'partial' => 1);
         } else {
             if ($ftp_site_folder) {
                 $ftp_remote_folder .= '/' . $this->site_name;
             }
             $remote_loation = basename($backup_file);
             $local_location = $backup_file;
             $sftp->mkdir($ftp_remote_folder, -1, true);
             $sftp->chdir($ftp_remote_folder);
             //$this->iwp_sftp_mkdir($sftp,'sftpbackup/test123/test1/test2');
             $upload = $sftp->put(basename($backup_file), $backup_file, NET_SFTP_LOCAL_FILE);
             if ($upload === false) {
                 return array('error' => 'Failed to upload file to FTP. Please check your specified path.', 'partial' => 1);
             }
             //SFTP library has automatic connection closed. So no need to call seperate connection close function
         }
     } else {
         $port = $ftp_port ? $ftp_port : 21;
         //default port is 21
         if ($ftp_ssl) {
             if (function_exists('ftp_ssl_connect')) {
                 $conn_id = ftp_ssl_connect($ftp_hostname, $port);
                 if ($conn_id === false) {
                     return array('error' => 'Failed to connect to ' . $ftp_hostname, 'error_code' => 'failed_to_connect_ftp_if_ftp_ssl', 'partial' => 1);
                 }
             } else {
                 return array('error' => 'Your server doesn\'t support FTP SSL', 'error_code' => 'no_ftp_ssl_support', 'partial' => 1);
             }
         } else {
             if (function_exists('ftp_connect')) {
                 $conn_id = ftp_connect($ftp_hostname, $port);
                 if ($conn_id === false) {
                     return array('error' => 'Failed to connect to ' . $ftp_hostname, 'error_code' => 'failed_to_connect_ftp', 'partial' => 1);
                 }
             } else {
                 return array('error' => 'Your server doesn\'t support FTP', 'error_code' => 'no_ftp_support', 'partial' => 1);
             }
         }
         $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
         if ($login === false) {
             return array('error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password, 'error_code' => 'ftp_login_failed', 'partial' => 1);
         }
         if ($ftp_passive) {
             @ftp_pasv($conn_id, true);
         }
         @ftp_mkdir($conn_id, $ftp_remote_folder);
         if ($ftp_site_folder) {
             $ftp_remote_folder .= '/' . $this->site_name;
         }
         @ftp_mkdir($conn_id, $ftp_remote_folder);
         $upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_BINARY);
         if ($upload === false) {
             //Try ascii
             $upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_ASCII);
         }
         @ftp_close($conn_id);
         if ($upload === false) {
             return array('error' => 'Failed to upload file to FTP. Please check your specified path.', 'error_code' => 'failed_to_upload_file_check_path', 'partial' => 1);
         }
     }
     return true;
 }
コード例 #13
0
ファイル: class_masterserver.php プロジェクト: Eun/developer
 private function linuxSshConnectAndExecute($updating, $getReturn, $ssh2Pass)
 {
     $sftpObject = new Net_SFTP($this->sship, $this->sshport);
     $loginReturn = $sftpObject->login($this->sshuser, $ssh2Pass);
     if ($loginReturn) {
         $sftpObject->put('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh', $this->shellScript);
         $sftpObject->chmod(0700, '/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh');
         // File has been created, now login with SSH2 and execute the script
         $sshObject = new Net_SSH2($this->sship, $this->sshport);
         if ($sshObject->login($this->sshuser, $ssh2Pass)) {
             if ($updating === true) {
                 $this->setUpdating();
                 $removeLogs = $this->removeUpdateLogs();
                 if ($removeLogs !== false) {
                     $sftpObject->put('/home/' . $this->sshuser . '/temp/remove-update-logs-' . $this->uniqueHex . '.sh', $removeLogs);
                     $sftpObject->chmod(0700, '/home/' . $this->sshuser . '/temp/remove-update-logs-' . $this->uniqueHex . '.sh');
                     $sshObject->exec('/home/' . $this->sshuser . '/temp/remove-update-logs-' . $this->uniqueHex . '.sh & ');
                 }
             }
             if ($getReturn === false) {
                 $sshObject->exec('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh & ');
                 return true;
             }
             return $sshObject->exec('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh');
         }
     }
     return false;
 }
コード例 #14
0
<?php

session_start();
include 'header.php';
include 'Net/SFTP.php';
$ds = DIRECTORY_SEPARATOR;
$storeFolder = 'uploads';
if (!empty($_FILES)) {
    $tempFile = $_FILES['file']['tmp_name'];
    $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds;
    $targetFile = $targetPath . $_FILES['file']['name'];
    move_uploaded_file($tempFile, $targetFile);
    $sftp = new Net_SFTP(SSH_HOST);
    if ($sftp->login($_SESSION["id"], $_SESSION["passwd"])) {
        $sftp->put('/scratch/' . $_SESSION["id"] . '/meshslicer/' . $_FILES['file']['name'], $targetFile, NET_SFTP_LOCAL_FILE);
        $_SESSION['fileList'][] = $_FILES['file']['name'];
        sort($_SESSION['fileList']);
        $reply = json_encode(array('Error' => '0', 'Message' => ''));
    } else {
        $reply = json_encode(array('Error' => '1', 'Message' => 'Astral problem. Please try again.'));
    }
    unlink($targetFile);
    echo $reply;
}
コード例 #15
0
ファイル: CRM.php プロジェクト: zehash/ff
 public function signup($user, $member)
 {
     // Campaign Monitor
     $cm_details = Config::get('services.campaignmonitor');
     $campaignmonitor = new CS_REST_Subscribers($cm_details['list_id'], $cm_details['auth_details']);
     $result = $campaignmonitor->add(array('EmailAddress' => $user->email, 'Name' => $member->firstname . ' ' . $member->lastname, 'CustomFields' => array(), 'Resubscribe' => false));
     // Boxever
     $keys = "?client_key=mz5gfrJyaUcG4Pc2uugPhupj3KRV5kMt&api_token=ADvnoiQ4HJsgzt5479ltfu77Z6pTCweO&";
     $res = $this->curlGet('https://api.boxever.com/v1.2/customer/search.json' . $keys . "email=" . $user->email);
     $dobISO = new DateTime($member->dob);
     $nowISO = new DateTime();
     $message = array('first_name' => $member->firstname, 'lastname' => $member->lastname, 'dob' => $dobISO->format(DateTime::ISO8601), 'email' => $user->email, 'phone' => $member->phone, 'address' => $member->address, 'postcode' => $member->postcode, 'state' => $member->state, 'tiff_has_flown' => $member->hasflown == 'y' ? true : false, 'tiff_flights_per_year' => $member->flightsperyear, 'tiff_member' => true, 'subscriptions' => array(array('name' => "infrequent_flyers", 'pos' => "default", 'medium' => "EMAIL", 'status' => "SUBSCRIBED", 'effectiveDate' => urlencode($nowISO->format(DateTime::ISO8601)))));
     foreach ($message as $key => $val) {
         if (gettype($val) === 'string') {
             $message[$key] = urlencode($val);
         }
     }
     // Upload to SFTP server
     $dstFile = "iff_data_production/{$member->id}.json";
     $fileContents = json_encode($message);
     // set up basic connection
     $domain = "sftp.tiger.jba-processing.com";
     try {
         $sftp = new Net_SFTP($domain);
         // Turn on logging
         define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX);
         // Attempt login
         if ($sftp->login('tiger_mccann', 'fsJcBsuepHMVrYrY')) {
             // Attempt upload
             $i = 0;
             do {
                 $sftp->put($dstFile, $fileContents);
             } while ($sftp->size($dstFile) === false && ++$i < 5);
         } else {
             Log::error("SFTP Login failed");
         }
     } catch (Exception $e) {
         Log::error($e);
     }
     Log::error($sftp->getSFTPLog());
     // No longer sending to Boxever
     /*
         if ($res->status == 'OK' && !isset($res->customer_ref)) {
      // Customer doesn't exist, create new customer
      //
      // Boxever doesn't seem to return a customer_ref even if the customer exists...
      // So we'll attempt to add it, and if it fails, then the user already exists in our list.
     
      $message['customer_id'] = urlencode($user->email);
     
      $message = json_encode($message);
     
      $res = $this->curlGet('https://api.boxever.com/v1.2/customer/create.json' . $keys . 'message=' . $message );
     
         } else if (isset($res->customer_ref)) {
      // Customer exists, update their data
      $message = json_encode($message);
      
      $res = $this->curlGet('https://api.boxever.com/v1.2/customer/'.$res->customer_ref[0].'/update.json' . $keys . 'message=' . $message);
     
         } else {
      // Initial resource request failed
      $boxever = 'API Failed';
         }
     */
     return $res;
 }
コード例 #16
0
<?php

session_start();
include 'header.php';
include 'Net/SFTP.php';
if (isset($_SESSION['login'])) {
    $sftp = new Net_SFTP(SSH_HOST);
    if (!$sftp->login($_SESSION["id"], $_SESSION["passwd"])) {
        header("location:signin.php?error=1");
    }
    $ls = array_filter(explode("\n", $sftp->exec("cd \$w; ls -d *\\/")));
    if (!in_array("meshslicer/", $ls)) {
        $sftp->exec("cd \$w; mkdir meshslicer; cd meshslicer; mkdir conf; mkdir results; cd conf; touch config.ini; echo '0 0 0 0 0 0 0 1 2 0\nnone' > config.ini");
        $sftp->put('/scratch/' . $_SESSION["id"] . '/meshslicer/conf/StandAlone', 'uploads/StandAlone', NET_SFTP_LOCAL_FILE);
        $sftp->exec("cd \$w/meshslicer/conf/; chmod 777 StandAlone");
    }
    $_SESSION["fileList"] = array_map('trimFile', array_filter(explode("\n", $sftp->exec("cd \$w/meshslicer; find . -maxdepth 1 -not -type d"))));
    unset($_SESSION["login"]);
}
?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
コード例 #17
0
ファイル: cloner.cron.php プロジェクト: Telemedellin/tm
 } else {
     //set php path to include required sftp files
     set_include_path(get_include_path() . PATH_SEPARATOR . 'classes/phpseclib');
     include 'Net/SFTP.php';
     //define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX); // or NET_SFTP_LOG_SIMPLE
     //connect to host and authenticate user
     $sftp = new Net_SFTP($fhost);
     if (!$sftp->login($_CONFIG[cron_ftp_user], $_CONFIG[cron_ftp_pass])) {
         logxx('Login Failed');
         die("Login Failed");
     }
     logxx("Connected to {$connect} <b>{$_CONFIG['cron_ftp_server']} Successfully!><br />");
     //transfere files
     for ($i = 0; $i < sizeof($source_files); $i++) {
         // upload the file
         $upload = $sftp->put($destination_files[$i], $source_files[$i], NET_SFTP_LOCAL_FILE);
         // check upload status
         if (!$upload) {
             logxx("<b style='color:red'>FTP upload has failed for file {$source_files[$i]} ! Stopping ....<br /></b>");
             return;
         } else {
             logxx("<b>Upload success from file <i>{$source_files[$i]}</i> <br />to <i>{$destination_files[$i]}</i> ...<br /></b>");
         }
     }
     //disconnect from server
     unset($sftp);
 }
 logxx("Ftp transfer finished succesfully!");
 if ($_CONFIG[cron_ftp_delb] == 1) {
     @unlink($source_file);
     logxx("Backup succesfully deleted from the original server!");
コード例 #18
0
ファイル: backup.class.php プロジェクト: jeanpage/ca_learn
 /**
  * Uploads backup file from server to remote sftp server.
  *
  * @param 	array 	$args	arguments passed to the function
  * [sftp_username] -> sftp username on remote server
  * [sftp_password] -> sftp password on remote server
  * [sftp_hostname] -> sftp hostname of remote host
  * [sftp_remote_folder] -> folder on remote site which backup file should be upload to
  * [sftp_site_folder] -> subfolder with site name in ftp_remote_folder which backup file should be upload to
  * [sftp_passive] -> passive mode or not
  * [sftp_ssl] -> ssl or not
  * [sftp_port] -> number of port for ssl protocol
  * [backup_file] -> absolute path of backup file on local server
  * @return 	bool|array		true is successful, array with error message if not
  */
 function sftp_backup($args)
 {
     extract($args);
     //   file_put_contents("sftp_log.txt","sftp_backup",FILE_APPEND);
     $port = $sftp_port ? $sftp_port : 22;
     //default port is 22
     //   file_put_contents("sftp_log.txt","sftp port:".$sftp_port,FILE_APPEND);
     $sftp_hostname = $sftp_hostname ? $sftp_hostname : "";
     //    file_put_contents("sftp_log.txt","sftp host:".$sftp_hostname,FILE_APPEND);
     $sftp_username = $sftp_username ? $sftp_username : "";
     //   file_put_contents("sftp_log.txt","sftp user:"******"";
     //     file_put_contents("sftp_log.txt","sftp pass:"******"sftp_log.txt","Creating NetSFTP",FILE_APPEND);
     $sftp = new Net_SFTP($sftp_hostname);
     //       file_put_contents("sftp_log.txt","Created NetSFTP",FILE_APPEND);
     $remote = $sftp_remote_folder ? trim($sftp_remote_folder, "/") . "/" : '';
     if (!$sftp->login($sftp_username, $sftp_password)) {
         file_put_contents("sftp_log.txt", "sftp login failed in sftp_backup", FILE_APPEND);
         return array('error' => 'SFTP login failed for ' . $sftp_username . ', ' . $sftp_password, 'partial' => 1);
     }
     file_put_contents("sftp_log.txt", "making remote dir", FILE_APPEND);
     $sftp->mkdir($remote);
     file_put_contents("sftp_log.txt", "made remote dir", FILE_APPEND);
     if ($sftp_site_folder) {
         $remote .= '/' . $this->site_name;
     }
     $sftp->mkdir($remote);
     file_put_contents("sftp_log.txt", "making {$sftp_remote_folder} dir", FILE_APPEND);
     $sftp->mkdir($sftp_remote_folder);
     file_put_contents("sftp_log.txt", "made {$sftp_remote_folder} dir", FILE_APPEND);
     file_put_contents("sftp_log.txt", "starting upload", FILE_APPEND);
     $upload = $sftp->put($remote . '/' . basename($backup_file), $backup_file, NET_SFTP_LOCAL_FILE);
     file_put_contents("sftp_log.txt", "finish upload", FILE_APPEND);
     $sftp->disconnect();
     if ($upload === false) {
         file_put_contents("sftp_log.txt", "sftp upload failed", FILE_APPEND);
         return array('error' => 'Failed to upload file to SFTP. Please check your specified path.', 'partial' => 1);
     }
     return true;
 }
コード例 #19
0
ファイル: tesvik.php プロジェクト: kaantunc/MYK-BOR
 function sendToZiraatTxt($path)
 {
     $sftp = new Net_SFTP(ZIRAAT_FTP_HOST);
     if ($sftp->login(ZIRAAT_FTP_USER, ZIRAAT_FTP_PASS)) {
         $file = explode('/', $path);
         $filename = end($file);
         $fileTo = "/kurumdan_bankaya/" . $filename;
         $real_path = EK_FOLDER . "ziraat_eft/kurumdan_bankaya/" . $path;
         if (file_exists($real_path)) {
             if ($sftp->put($fileTo, fopen($real_path, 'r'))) {
                 $return['FILE'] = $filename;
                 $return['STATUS'] = true;
                 $return['TEXT'] = "Dosya basariyla yüklendi";
             } else {
                 $return['STATUS'] = false;
                 $return['TEXT'] = "Dosya yükleme hatasi";
             }
         } else {
             $return['STATUS'] = false;
             $return['TEXT'] = "dosya bulunamadı";
         }
     } else {
         $return['STATUS'] = false;
         $return['TEXT'] = "ftp bağlanti hatasi";
     }
     $this->ziraatLog($return);
 }
コード例 #20
0
    if (strlen($order['expiry_date']) == 4) {
        $expiry_date[] = substr($order['expiry_date'], 0, 2);
        $expiry_date[] = '20' . substr($order['expiry_date'], 2, 2);
    } elseif (strlen($order['expiry_date']) == 3) {
        $expiry_date[] = '0' . substr($order['expiry_date'], 0, 1);
        $expiry_date[] = '20' . substr($order['expiry_date'], 1, 2);
    } else {
        $expiry_date[] = '00';
        $expiry_date[] = '0000';
    }
    $expiryDate = implode('/', $expiry_date);
    $csv[] = array($order['order_id'], date("d/m/Y"), 'HHCRBM', $order['product_name'], '', '', $order['fname'], $order['lname'], $order['address1'], $order['address2'], $order['city'], $order['country_name'], $order['zip'], $order['phone'], '', $order['email'], sprintf("%02d", substr($order['created'], 8, 2)) . '/' . sprintf("%02d", substr($order['created'], 5, 2)) . '/' . sprintf("%02d", substr($order['created'], 0, 4)), 'Credit', $arrayNote1['ccn'], $expiryDate, '', '', $arrayNote1['ccc'], 'rocket', '1');
}
$name = 'lj3out_rocket_' . date('Ymdhis');
$path = array('files', 'csv', 'rockets');
$filePath = Csv::saveCsv($csv, $name, $path);
$fileZipPath = AF::path($name, $path, 'zip');
$phpFilePath = AF::path('zip', $path);
system('/usr/bin/php ' . $phpFilePath . ' name=' . $name . ' > /dev/null 2>&1 &');
$sftp = new Net_SFTP($option['server']);
if (!$sftp->login($option['username'], $option['password'])) {
    exit('Login Failed');
}
if (!$sftp->put($sftp->pwd() . $option['uploadPath'] . $name . '.zip', $fileZipPath, NET_SFTP_LOCAL_FILE)) {
    echo 'error';
    die;
}
$sql = "UPDATE `orders` SET `rocket` = 2\n        WHERE `order_id` IN (?a)";
$msql->query($sql, $orderIDs);
unlink($fileZipPath);
unlink($filePath);
コード例 #21
0
ファイル: processOutput.php プロジェクト: rlgruver/practicum
include 'Net/SFTP.php';
//ssh connect to cr2g server
$ssh = new Net_SSH2('cr2g01.cs.utep.edu', 22);
if (!$ssh->login('rlgruver', 'utep$2015')) {
    exit('ssh Login Failed');
}
//attempted to set an ssh timeout, not allowed on UTEP server
$ssh->setTimeout(7200);
//sftp connect to cr2g server
$sftp = new Net_SFTP('cr2g01.cs.utep.edu', 22);
if (!$sftp->login('rlgruver', 'utep$2015')) {
    exit('sftp Login Failed');
}
//send input file to cr2g server
$sftp->mkdir('/code/spopt-stable/tests/' . $session);
$sftp->put($remoteInputFile, $localInputFile, NET_SFTP_LOCAL_FILE);
$sftp->chmod(0777, $remoteInputFile);
//execute python script in this order to run the Solver:
//1. change to directory where solver script is located
$ssh->write("cd /code/spopt-stable\n");
//2. 'read' command to ensure script is called from the proper directory
$ssh->read('rlgruver@cr2g01:/code/spopt-stable$');
//3. run the solver script with the test from the current session
$ssh->write("python SpOpt.py tests/" . $session . "/input.txt\n");
//start timerin case anything gets stuck, will break within 120 minutes (7200 sec)
$starttime = time();
//ssh will break within 120 minutes (7200 sec) regardless of execution status
while ($ssh->isConnected()) {
    $now = time() - $starttime;
    if ($now > 7200) {
        break;
コード例 #22
0
ファイル: export.php プロジェクト: onyxnz/quartzpos
function connect()
{
    global $db;
    $message = "<h2>File Exporter</h2><br>";
    $message .= "Trying the export system across the network...";
    $exportuser = $db->QPResults("SELECT value FROM system WHERE name ='export_username'")['value'];
    $exportpass = $db->QPResults("SELECT value FROM system WHERE name ='export_password'")['value'];
    $exporthost = $db->QPResults("SELECT value FROM system WHERE name ='export_hostpath'")['value'];
    $exportdir = $db->QPResults("SELECT value FROM system WHERE name ='export_hostdir'")['value'];
    $exportfile = $db->QPResults("SELECT value FROM system WHERE name ='export_filename'")['value'];
    //rather than SAMBA, which proves to be a PITA with so many implentation issues under PHP+OSes in general, I have opted for SFTP - fast+secure http://phpseclib.sourceforge.net/
    $sftp = new Net_SFTP($exporthost);
    if (!$sftp->login($exportuser, $exportpass)) {
        $message .= "SFTP login failed for the user credentials supplied.";
        $message .= "Host =" . $exporthost . "<br>";
        $message .= "User = "******"<br>";
        $message .= "Password hidden. {$exportpass}<br>";
    } else {
        //now do the work
        if ($sftp->put($exportdir . "/" . $exportfile, "export/" . $exportfile, NET_SFTP_LOCAL_FILE)) {
            $message .= "export file saved successfully, you may close this tab: CTRL+W";
        } else {
            $message .= "failed to save file.<br>";
            $message .= "Host = " . $exporthost . "<br>";
            $message .= "Dir = " . $exportdir . "<br>";
            $message .= "File = " . $exportfile . "<br>";
        }
    }
    return $message;
}
コード例 #23
0
}*/
//if(file_exists($encryptedFileName))
if (file_exists($localfilename)) {
    include "Net/SFTP.php";
    $ftp_server = 'PDCFTP.cvty.com';
    $ftp_user = '******';
    $ftp_password = '******';
    $ftp_port = '21000';
    $ftp_directory = '/Incoming/';
    //'/Test/Incoming/'
    $sftp = new Net_SFTP($ftp_server, $ftp_port);
    // FTP Login
    if ($sftp->login($ftp_user, $ftp_password)) {
        // Change directory
        if ($sftp->chdir($ftp_directory)) {
            if ($sftp->put($remoteFileName, $localfilename, NET_SFTP_LOCAL_FILE)) {
                $destFileName = str_replace('C:\\Inetpub\\wwwroot\\plexis\\php\\', 'D:\\Documents\\Misc\\' . $clientName . "_", $savePathAndFileName);
                //echo "destFileName:  ".$destFileName."\n";
                //echo "localfilename:  ".$localfilename."\n";
                //echo "remoteFileName:  ".$remoteFileName."\n";
                if (file_exists($destFileName)) {
                    unlink($destFileName);
                }
                rename($localfilename, $destFileName);
            } else {
                $msg = "Unable to put " . $localfilename . " file to [" . $ftp_server . "] /" . $ftp_directory . "/" . $remoteFileName . "<br/>";
            }
        } else {
            $msg = "chdir failed to [" . $ftp_server . "] " . $ftp_directory;
        }
    } else {
コード例 #24
0
ファイル: class_app.php プロジェクト: Eun/developer
 private function executeLinux()
 {
     if (strlen($this->shellScripts['user']) > 0 or count($this->shellScripts['server']) > 0) {
         $sftpObject = new Net_SFTP($this->appMasterServerDetails['ssh2IP'], $this->appMasterServerDetails['ssh2Port']);
         $ssh2Pass = $this->getKeyAndOrPassword();
         $loginReturn = $sftpObject->login($this->appMasterServerDetails['ssh2User'], $ssh2Pass);
         if ($loginReturn) {
             $this->commandReturns[] = $sftpObject->put('/home/' . $this->appMasterServerDetails['ssh2User'] . '/temp/userCud-' . $this->uniqueHex . '.sh', $this->shellScripts['user']);
             $this->commandReturns[] = $sftpObject->chmod(0700, '/home/' . $this->appMasterServerDetails['ssh2User'] . '/temp/userCud-' . $this->uniqueHex . '.sh');
             foreach ($this->shellScripts['server'] as $fileName => $scriptContent) {
                 $this->commandReturns[] = 'script added: ' . $fileName;
                 $this->commandReturns[] = $sftpObject->put($fileName, $scriptContent);
             }
             // Files have been created, now login with SSH2 and execute the gobal script
             $sshObject = new Net_SSH2($this->appMasterServerDetails['ssh2IP'], $this->appMasterServerDetails['ssh2Port']);
             if ($sshObject->login($this->appMasterServerDetails['ssh2User'], $ssh2Pass)) {
                 $this->commandReturns[] = $sshObject->exec('/home/' . $this->appMasterServerDetails['ssh2User'] . '/temp/userCud-' . $this->uniqueHex . '.sh & ');
             }
             return true;
         }
         $this->handleFailedConnectAttemps();
     }
     return false;
 }
コード例 #25
0
ファイル: LoginController.php プロジェクト: zehash/ff
 public function dataPush($date = '2014-12-14 00:00:00')
 {
     $res = array();
     $dstFile = "iff_data_production/test_data.json";
     $fileContents = "test content";
     // set up basic connection
     $domain = "sftp.tiger.jba-processing.com";
     try {
         $sftp = new Net_SFTP($domain);
         if ($sftp->login('tiger_mccann', 'fsJcBsuepHMVrYrY')) {
             $sftp->put($dstFile, $fileContents);
             var_dump($sftp->size($dstFile));
             var_dump($sftp->size('nonexistant.json'));
         }
     } catch (Exception $e) {
         var_dump($e);
     }
     echo $sftp->getSFTPLog();
     return;
 }
コード例 #26
0
ファイル: sftp.php プロジェクト: Combustible/core
 public function uploadFile($path, $target)
 {
     $this->client->put($target, $path, NET_SFTP_LOCAL_FILE);
 }
コード例 #27
0
 public function uploadToFulfillment()
 {
     //test
     //return true;
     if (!$this->filePath) {
         return false;
     }
     $fType = $this->fulfillment_zip ? '.zip' : '.csv';
     if ($this->ssl) {
         $sftp = new Net_SFTP($this->server);
         if (!$sftp->login($this->username, $this->password)) {
             echo 'Login Failed';
             return false;
         }
         if (!$sftp->put($sftp->pwd() . $this->upload_path . $this->csvFileName . $fType, $this->filePath, NET_SFTP_LOCAL_FILE)) {
             // Download error
             echo 'error';
             return false;
         }
     } else {
         $ftp = ftp_connect($this->server, $this->port, 20);
         if ($this->username && $this->password) {
             ftp_login($ftp, $this->username, $this->password);
         }
         ftp_pasv($ftp, true);
         // Passive mode
         if (!ftp_put($ftp, $this->upload_path . $this->csvFileName . $fType, $this->filePath, FTP_BINARY)) {
             // Download error
             echo 'error';
             return false;
         }
         ftp_close($ftp);
     }
     return true;
 }
コード例 #28
0
ファイル: restore.php プロジェクト: xiaokangrj/cdp
 }
 $verifyvzdump = $ssh->exec(escapeshellcmd('vzdump'));
 if (strpos($verifyvzdump, 'command not found') !== false) {
     echo 'vzdump command not found' . PHP_EOL;
     die;
 } else {
     echo 'vzdump detected' . PHP_EOL;
 }
 echo $sftp->chdir('/');
 if (isset($backupjob['encryption']) && $backupjob['encryption'] == 'AES-256') {
     echo 'Decrypting file with AES-256' . PHP_EOL;
     $cipher = new Crypt_AES(CRYPT_AES_MODE_ECB);
     $cipher->setKey($backupjob['encryptionkey']);
     file_put_contents($config['path'] . '/files/' . $argv[1] . '.decrypted', $cipher->decrypt(file_get_contents($config['path'] . '/files/' . $argv[1])));
     echo 'Transferring the file' . PHP_EOL;
     echo $sftp->put($argv[1], $config['path'] . '/files/' . $argv[1] . '.decrypted', NET_SFTP_LOCAL_FILE);
     unlink($config['path'] . '/files/' . $argv[1] . '.decrypted');
 } else {
     echo 'Transferring the file' . PHP_EOL;
     echo $sftp->put($argv[1], $config['path'] . '/files/' . $argv[1], NET_SFTP_LOCAL_FILE);
 }
 $ctid = explode('vzdump-', trim($argv[1]));
 $ctid = explode('.tgz', $ctid[1]);
 echo $ssh->exec(escapeshellcmd('vzctl stop ' . $ctid[0]));
 echo $ssh->exec(escapeshellcmd('vzctl destroy ' . $ctid[0]));
 if (strpos($verifyproxmox, 'pve') !== false) {
     echo 'ProxMox detected, using vzrestore' . PHP_EOL;
     echo $ssh->exec(escapeshellcmd('vzrestore /' . $argv[1] . ' ' . $ctid[0]));
 } else {
     echo 'Standard OpenVZ detected, using vzdump restore' . PHP_EOL;
     echo $ssh->exec(escapeshellcmd('vzdump --restore /' . $argv[1] . ' ' . $ctid[0]));
コード例 #29
0
 public function put($from, $to)
 {
     return $this->ftp->put($to, file_get_contents($from)) && $this->ftp->chmod($this->permFile, $to);
 }
コード例 #30
0
$login = new Login();
if ($login->isUserLoggedIn() == true) {
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Minecraft Game Panel</title>
</head>
<body>
<?php 
    require 'includes/settings.php';
    $connection = new Net_SFTP($server_SSH_address);
    $connection->login($server_SSH_username, $server_SSH_password);
    if (isset($_POST['submit'])) {
        $connection->put('/srv/games/minecraft/server.properties', $_POST['serverProperties']);
        $connection->put('/srv/games/minecraft/ops.txt', $_POST['serverOPs']);
    }
    $current_serverProperties = $connection->get('/srv/games/minecraft/server.properties');
    $current_serverOPs = $connection->get('/srv/games/minecraft/ops.txt');
    ?>
<form action="<?php 
    echo $_SERVER["PHP_SELF"];
    ?>
" method="post">
  server.properties<br>
  <textarea rows="25" cols="100" name="serverProperties"><?php 
    echo $current_serverProperties;
    ?>
</textarea>
  <br />ops.txt<br />