|
@@ -1307,13 +1307,68 @@ class Notify extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //用户观看行为数据文件上传到卓望ftp
|
|
|
+ //用户观看行为数据文件上传到卓望ftp(每小时第10分钟提供)
|
|
|
public function uploadpayftp() {
|
|
|
+ $host = config('pay_ftp_ip');
|
|
|
+ $port = config('pay_ftp_port');
|
|
|
+ $username = config('pay_ftp_user');
|
|
|
+ $password = config('pay_ftp_pwd');
|
|
|
|
|
|
+ $filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_userviewdata_1.dat';
|
|
|
+ $check_filename = date('YmdH', time() - 3600).'_'.config('cp_id').'_userviewdata_1.chk';
|
|
|
+
|
|
|
+ //判断文件是否存在, 不存在则创建
|
|
|
+ if (!is_dir('./dashuju/' . $filename)) {
|
|
|
+ @mkdir('./dashuju/' . $filename, 0755, true);
|
|
|
+ }
|
|
|
+ if (!is_dir('./dashuju/' . $check_filename)) {
|
|
|
+ @mkdir('./dashuju/' . $check_filename, 0755, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ $conn = ftp_connect($host, $port) or die("Could not connect");
|
|
|
+
|
|
|
+ ftp_login($conn,$username,$password);
|
|
|
+ //利用ftp创建目录
|
|
|
+ /*$path = "home/2021-12-08";
|
|
|
+ $this->make_directory($conn,$path);
|
|
|
+ //利用ftp选择进入目录
|
|
|
+ ftp_chdir($conn,$path);*/
|
|
|
+ //开始上传 ftp_put(ftp链接,服务器地址,本地地址,上传模式);
|
|
|
+ if(ftp_put($conn,$filename,'./dashuju/' . $filename,FTP_BINARY)){
|
|
|
+ //上传成功
|
|
|
+ }
|
|
|
+ if(ftp_put($conn,$check_filename,'./dashuju/' . $check_filename,FTP_BINARY)){
|
|
|
+ //上传成功
|
|
|
+ }
|
|
|
+ ftp_close($conn);
|
|
|
+ //注意上传端的ftp权限设置
|
|
|
}
|
|
|
|
|
|
- //大数据文件上传到大数据ftp
|
|
|
+ //大数据文件上传到大数据ftp(每天一点提供)
|
|
|
public function uploaddataftp() {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public function make_directory($ftp_stream, $dir){
|
|
|
+ // if directory already exists or can be immediately created return true
|
|
|
+ if ($this->ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) return true;
|
|
|
+ // otherwise recursively try to make the directory
|
|
|
+ if (!$this->make_directory($ftp_stream, dirname($dir))) return false;
|
|
|
+ // final step to create the directory
|
|
|
+ return ftp_mkdir($ftp_stream, $dir);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function ftp_is_dir($ftp_stream, $dir){
|
|
|
+ // get current directory
|
|
|
+ $original_directory = ftp_pwd($ftp_stream);
|
|
|
+ // test if you can change directory to $dir
|
|
|
+ // suppress errors in case $dir is not a file or not a directory
|
|
|
+ if ( @ftp_chdir( $ftp_stream, $dir ) ) {
|
|
|
+ // If it is a directory, then change the directory back to the original directory
|
|
|
+ ftp_chdir( $ftp_stream, $original_directory );
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|