CronAction.class.php 989 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class CronAction extends Action {
  3. public function searchFile2Ftp( ){
  4. while(true){
  5. $dir = C('FTP_LOCAL_DIR');
  6. $targetDir = C('FTP_SERVER_DIR');
  7. $config = C('FTP_CONFIG');
  8. $res = scanTargetFile($dir, 'md5');
  9. $files = explode(';', $res);
  10. array_pop($files);
  11. foreach($files as $v){
  12. $path_parts = pathinfo($v);
  13. $locDat = $path_parts['dirname']. '/' . $path_parts['filename'].'.dat';
  14. $tagetDat = $targetDir.'/'. $path_parts['filename'].'.dat';
  15. echo $tagetDat.PHP_EOL;
  16. $datRes = Zmcoding\FtpFile::getInstance($config)->up_file($locDat, $tagetDat);
  17. if($datRes){
  18. $md5Res = Zmcoding\FtpFile::getInstance($config)->up_file($v, $targetDir.'/'. $path_parts['basename']);//md5文件
  19. if($md5Res){
  20. debug_log('upload_info',json_encode($targetDir.'/'. $path_parts['basename'],JSON_UNESCAPED_UNICODE));
  21. }
  22. debug_log('upload_info',json_encode($tagetDat,JSON_UNESCAPED_UNICODE));
  23. }
  24. }
  25. sleep(3);
  26. }
  27. }
  28. }