$host = HOST ;
$directory = UPLOAD_DIR . '/';
$userName = USER;
$password = PASSWORD;
$methods = array(
'kex' => 'diffie-hellman-group1-sha1',
'client_to_server' => array(
'crypt' => '3des-cbc',
'comp' => 'none'),
'server_to_client' => array(
'crypt' => 'aes256-cbc,aes192-cbc,aes128-cbc',
'comp' => 'none'
)
);
$this->lfPrintLog("ファイル送信を開始します");
if (!($connection = ssh2_connect($host, 22, $methods))) {
$this->lfPrintLog("ホスト {$host} とのコネクションの確立に失敗しました");
return false;
}
$this->lfPrintLog("ホスト {$host} とのコネクションの確立に成功しました");
if (!ssh2_auth_password($connection, $userName, $password)) {
$this->lfPrintLog("ユーザ {$userName} でのログインに失敗しました");
return false;
}
$this->lfPrintLog("ユーザ {$userName} でログインしました");
$fileName = $this->lfGetCsvFileName();
$path = DISH_ARCHIVE_DIR . $fileName;
if (!ssh2_scp_send($connection, $path, $directory . $fileName)) {
$this->lfPrintLog("ホスト {$host} へのSCPによるファイル送信に失敗しました");
return false;
}
$fileName = $this->lfGetEofFileName();
$path = DISH_ARCHIVE_DIR . $fileName;
if (!ssh2_scp_send($connection, $path, $directory . $fileName)) {
$this->lfPrintLog("ホスト {$host} へのSCPによるファイル送信に失敗しました");
return false;
}
$this->lfPrintLog("ホスト {$host} へのファイル送信が完了しました");