You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.4 KiB
PHTML
35 lines
1.4 KiB
PHTML
8 years ago
|
<?php
|
||
|
include('Net/SFTP.php');
|
||
|
|
||
7 years ago
|
set_time_limit(0);
|
||
|
|
||
8 years ago
|
$sftp = new Net_SFTP('106.14.1.181');
|
||
|
if (!$sftp->login('10000004000', 'YRATF0OtDaYa2Uhv6cWO8BV9FPBup5')) {
|
||
|
exit('Login Failed');
|
||
|
}
|
||
|
// 获取前一天的对账单
|
||
|
// target remote
|
||
7 years ago
|
$target_folder = str_replace("-", "/", date("Y-m", strtotime("-1 day")) );
|
||
8 years ago
|
$file_list = array_values(array_diff($sftp->nlist($target_folder), array(".","..")));
|
||
|
// target local
|
||
7 years ago
|
$target_local = "statement_files/" . $target_folder;
|
||
8 years ago
|
if ( ! is_dir($target_local)) {
|
||
8 years ago
|
mkdir($target_local, 0777, true);
|
||
8 years ago
|
}
|
||
|
// local files
|
||
|
$local_files = array_values(array_diff(scandir($target_local), array('.', '..')));
|
||
|
// new files
|
||
|
$new_files = array_values(array_diff($file_list, $local_files));
|
||
|
// copies filename.remote to filename.local from the SFTP server
|
||
|
$new_cnt = 0;
|
||
|
foreach ($new_files as $key => $new) {
|
||
|
$file_path = $target_folder . "/" . $new;
|
||
|
$sftp->get($file_path, $target_local . "/" . $new);
|
||
|
$new_cnt++;
|
||
|
}
|
||
|
echo "Copied new statements count: " . $new_cnt;
|
||
7 years ago
|
|
||
|
// header("Location: http://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/auto_update_statement?f=$target_folder&fjson=" . json_encode($new_files));
|
||
|
// header("Location: http://www.mycht.cn/webht.php/apps/pay/report/ipaylinks_excel?f=$target_folder&fjson=" . json_encode($new_files));
|
||
|
// header("Location: http://202.103.68.79:8083/webht.php/apps/pay/report/ipaylinks_excel?f=$target_folder&fjson=" . json_encode($new_files));
|