<?php
// /home/work/scripts/gp-data/conf/system.conf.php
return [
'sftp' => [
'host' => 'data.sftp.daiyuanpei.com',
'port' => '3333',
'user' => 'data-online',
'password' => 'SFTPDAIYUANPEI',
'root' => 'upload/online'
]
];
<?php
// /home/work/scripts/gp-data/lib/sftp.class.php
if (!defined("ROOT")) {
define("ROOT", dirname(dirname(__FILE__)));
}
class sftp {
private $conn;
private $config;
public function connect()
{
$this->config = require(ROOT . "/conf/system.conf.php");
$this->config = $this->config['sftp'];
$this->conn = ssh2_connect($this->config['host'], $this->config['port']);
ssh2_auth_password($this->conn, $this->config['user'], $this->config['password']);
return $this;
}
public function download($remote, $local)