Example #1
0
 function _getFileInfo($path)
 {
     //$curdir = ftp_pwd($this->_link);
     //$isDir = @ftp_chdir($this->_link, $path);
     //ftp_chdir($this->_link, $curdir);
     $size = ftp_size($this->_link, $path);
     return array(name => basename($path), modified => ftp_mdtm($this->_link, $path), size => $size, type => $size == -1 ? "text/directory" : "text/plain");
 }
 public function testFileModified()
 {
     $modifiedFilePath = $this->workspace . '/modified_source_file';
     $path = tempnam(sys_get_temp_dir(), 'ftp');
     ftp_put($this->connection, $modifiedFilePath, $path, $this->mode);
     $this->assertEquals(ftp_mdtm($this->connection, $modifiedFilePath), $this->adapter->mtime($modifiedFilePath));
     $this->setExpectedException('\\Pagekit\\Component\\File\\Exception\\IOException');
     $this->adapter->mtime($this->workspace . '/unknown_file');
 }
Example #3
0
 function is_file($file)
 {
     $buff = @ftp_mdtm($this->_conn, $file);
     if ($buff != -1) {
         return true;
     } else {
         return false;
     }
 }
 public function getLastModifiedTD($fileName)
 {
     $raw = ftp_mdtm($this->connectionId, $fileName);
     if ($raw != -1) {
         echo "{$fileName} was last modified on : " . date("F d Y  H:i:s.", $raw);
     } else {
         echo "Couldn't get mdtime";
     }
 }
 public function getFilesInfo($conn_id, $ftp_dir, $ftp, &$model, &$count)
 {
     $attribute = Attribute::model()->findByAttributes(array('structured_comment_name' => 'num_files'));
     ftp_pasv($conn_id, true);
     $buff = ftp_rawlist($conn_id, $ftp_dir);
     if (!$buff) {
         return false;
     }
     $file_count = count($buff);
     $date = new DateTime("2050-01-01");
     $date = $date->format("Y-m-d");
     foreach ($buff as $key => $value) {
         $info = preg_split("/\\s+/", $value);
         $name = $info[8];
         $new_dir = $ftp_dir . "/" . $name;
         if ($this->is_dir($conn_id, $new_dir)) {
             $new_ftp = $ftp . "/" . $name;
             if (!$this->getFilesInfo($conn_id, $new_dir, $new_ftp, $model, $count)) {
                 return false;
             }
         } else {
             $count++;
             //var_dump($info);
             $size = $info[4];
             $stamp = date("F d Y", ftp_mdtm($conn_id, $name));
             // var_dump($name);
             $file = new File();
             $file->dataset_id = $model->dataset_id;
             $file->name = $name;
             $file->size = $size;
             $file->location = $ftp . "/" . $name;
             $file->code = "None";
             $file->date_stamp = $date;
             $extension = "";
             $format = "";
             $this->getFileExtension($file->name, $extension, $format);
             $file->extension = $extension;
             $fileformat = FileFormat::model()->findByAttributes(array('name' => $format));
             if ($fileformat != null) {
                 $file->format_id = $fileformat->id;
             }
             $file->type_id = 1;
             $file->date_stamp = $stamp;
             if (!$file->save()) {
                 $model->addError('error', "Files are not saved correctly");
                 return false;
                 //how to
                 //                    var_dump($file->name);
             } else {
                 $this->setAutoFileAttributes($file);
             }
         }
     }
     return true;
 }
Example #6
0
 /**
  * Write temp file to remote system and count difference
  * @param string $localPath Path to local file
  * @return int Time difference between systems
  */
 private function writeTempFile($localPath)
 {
     // Remote file name
     $tsFileName = basename($localPath);
     // Copy file to remote
     if ($this->write($localPath)) {
         // Get difference
         $diff = abs(filemtime($localPath) - ftp_mdtm($this->handle, $tsFileName));
         $this->log('Time difference between servers is [##]', $diff);
         ftp_delete($this->handle, $tsFileName);
         // Convert to hours
         return (int) ($diff > 3600 ? floor($diff / 3600) * 3600 + $diff % 3600 : 0);
     }
     return 0;
 }
Example #7
0
 public function addFile($destination_filename, $source_filename)
 {
     /*
      * !!!!!
      * Do not use realpath() - this is not a local path! 
      * 
      */
     if ($this->getOnlyIfModified()) {
         if (filemtime($source_filename) > ftp_mdtm($this->_ftp_conn_id, $destination_filename)) {
             $index = $this->_remote_base_dir . $destination_filename;
             $this->_files[$index] = $source_filename;
         }
     } else {
         $index = $this->_remote_base_dir . $destination_filename;
         $this->_files[$index] = $source_filename;
     }
 }
 public function downloadAll()
 {
     $Dirs = ftp_nlist($this->ftpconnection, '/sales');
     $downloadCheck = false;
     $downloadArray = array();
     foreach ($Dirs as $Dir) {
         $files = ftp_nlist($this->ftpconnection, $Dir);
         foreach ($files as $file) {
             $time = ftp_mdtm($this->ftpconnection, $file);
             if ($time !== -1) {
                 if (ftp_get($this->ftpconnection, $this->downloadPath . basename($file, ".csv") . "-" . basename($Dir) . ".csv", $file, FTP_ASCII)) {
                     $downloadCheck = true;
                     $downloadArray[] = $this->downloadPath . basename($file, ".csv") . "-" . basename($Dir) . ".csv";
                 }
             }
         }
     }
     if ($downloadCheck !== true) {
         return false;
     } else {
         return $downloadArray;
     }
 }
Example #9
0
 /**
  * Return the last modified time of a given file
  *
  * @param $filename
  * @return bool
  */
 private function modified($filename)
 {
     if ($this->isSFTP()) {
         $info = @$this->ftp->lstat($filename);
         if ($info) {
             return $info['mtime'];
         }
     } else {
         if ($time = @ftp_mdtm($this->ftp, $filename)) {
             return $time;
         }
     }
     $this->fail("couldn't get the file size for {$filename}");
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function mtime($key)
 {
     $this->ensureDirectoryExists($this->directory, $this->create);
     $mtime = ftp_mdtm($this->getConnection(), $this->computePath($key));
     // the server does not support this function
     if (-1 === $mtime) {
         throw new \RuntimeException('Server does not support ftp_mdtm function.');
     }
     return $mtime;
 }
Example #11
0
 /**
  * Return the last modified time of a given file
  *
  * @param $filename
  * @return bool
  */
 private function _modified($filename)
 {
     switch (strtolower($this->config['type'])) {
         case 'sftp':
             if ($info = @$this->ftp->lstat($filename)) {
                 return $info['mtime'];
             }
             break;
         default:
             if ($time = @ftp_mdtm($this->ftp, $filename)) {
                 return $time;
             }
     }
     \PHPUnit_Framework_Assert::fail("couldn't get the file size for {$filename}");
 }
 /**
  * Return the last modified file time as an UNIX timestamp
  *
  * @param      string  $path   The path to the directory / file
  *
  * @return     int     The last modified time as an UNIX timestamp
  */
 public function lastModified(string $path) : int
 {
     return ftp_mdtm($this->resource, $path);
 }
Example #13
0
 /**
  *
  * 返回指定文件的最后修改时间
  *
  * @param string $remote_file
  */
 public static function mdtm($remote_file)
 {
     return ftp_mdtm(self::$resource, $remote_file);
 }
Example #14
0
 /**
  * Uploads files to FTP
  *
  * @param array $files
  * @param array $results
  * @param boolean $force_rewrite
  * @return boolean
  */
 function upload($files, &$results, $force_rewrite = false)
 {
     $error = null;
     if (!$this->_connect($error)) {
         $results = $this->_get_results($files, W3TC_CDN_RESULT_HALT, $error);
         return false;
     }
     $this->_set_error_handler();
     $home = @ftp_pwd($this->_ftp);
     if ($home === false) {
         $results = $this->_get_results($files, W3TC_CDN_RESULT_HALT, sprintf('Unable to get current directory (%s).', $this->_get_last_error()));
         $this->_restore_error_handler();
         $this->_disconnect();
         return false;
     }
     foreach ($files as $file) {
         $local_path = $file['local_path'];
         $remote_path = $file['remote_path'];
         if (!file_exists($local_path)) {
             $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, 'Source file not found.');
             continue;
         }
         @ftp_chdir($this->_ftp, $home);
         $remote_dir = dirname($remote_path);
         $remote_dirs = preg_split('~\\/+~', $remote_dir);
         foreach ($remote_dirs as $dir) {
             if (!@ftp_chdir($this->_ftp, $dir)) {
                 if (!@ftp_mkdir($this->_ftp, $dir)) {
                     $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf('Unable to create directory (%s).', $this->_get_last_error()));
                     continue 2;
                 }
                 if (!@ftp_chdir($this->_ftp, $dir)) {
                     $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf('Unable to change directory (%s).', $this->_get_last_error()));
                     continue 2;
                 }
             }
         }
         // basename cannot be used, kills chinese chars and similar characters
         $remote_file = substr($remote_path, strrpos($remote_path, '/') + 1);
         $mtime = @filemtime($local_path);
         if (!$force_rewrite) {
             $size = @filesize($local_path);
             $ftp_size = @ftp_size($this->_ftp, $remote_file);
             $ftp_mtime = @ftp_mdtm($this->_ftp, $remote_file);
             if ($size === $ftp_size && $mtime === $ftp_mtime) {
                 $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_OK, 'File up-to-date.');
                 continue;
             }
         }
         $result = @ftp_put($this->_ftp, $remote_file, $local_path, FTP_BINARY);
         if ($result) {
             $this->_mdtm($remote_file, $mtime);
             $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_OK, 'OK');
         } else {
             $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf('Unable to upload file (%s).', $this->_get_last_error()));
         }
     }
     $this->_restore_error_handler();
     $this->_disconnect();
     return !$this->_is_error($results);
 }
Example #15
0
 /**
  * @inheritdoc
  */
 public function getFileModificationTime($filepath)
 {
     $fileMdtm = ftp_mdtm($this->getFtp(), $filepath);
     if ($fileMdtm == -1) {
         throw new \Exception(sprintf("Error when trying to get file modification time"));
     }
     return $fileMdtm;
 }
Example #16
0
 /**
  * Returns the last modified time of the given file
  * @link http://php.net/ftp_mdtm
  *
  * @param  string  $remoteFile The file from which to extract the last modification time
  * @return integer Unix timestamp on success, -1 on error
  */
 public function mdtm($remoteFile)
 {
     return ftp_mdtm($this->connection->getStream(), $remoteFile);
 }
Example #17
0
 /**
  * Last date of file modification
  *
  * @param  string $file File name
  * @return mixed  On success a Unix Timestamp, otherwise FALSE
  */
 public function getLastModified($file)
 {
     if (is_resource($this->cid)) {
         $status = ftp_mdtm($this->cid, $file);
         if ($status == -1) {
             return false;
         }
         return $status;
     }
 }
 /**
  * Returns the last modified time of the given file
  * Note: Not all servers support this feature!
  * Note: mdtm method does not work with directories.
  *
  * @param	string remote file
  * @return	mixed Returns the last modified time as a Unix timestamp on success, or false on error.
  */
 public function mdtm($file)
 {
     if ($this->getActive()) {
         // get the last modified time
         $buff = ftp_mdtm($this->_connection, $file);
         if ($buff != -1) {
             return $buff;
         } else {
             return false;
         }
     } else {
         throw new CDbException('EFtpComponent is inactive and cannot perform any FTP operations.');
     }
 }
Example #19
0
 /**
  * @inheritdoc
  */
 public function getTimestamp($path)
 {
     $timestamp = ftp_mdtm($this->getConnection(), $path);
     return $timestamp !== -1 ? array('timestamp' => $timestamp) : false;
 }
Example #20
0
 /**
  * Returns the last modified time of a path.
  *
  * @param string $path
  *
  * @return int
  */
 public function mtime($path)
 {
     return ftp_mdtm($this->connection, $path);
 }
Example #21
0
 /**
  * Return true if remote file exists.
  * 
  * @param string $path
  * @return bool
  */
 public function hasFile($path)
 {
     return !empty($path) && @ftp_mdtm($this->ftp, $path) > 0;
 }
Example #22
0
 /**
  * Returns the last modified time of the given file
  *
  * @param $remoteFile
  * @return int
  */
 public function time($remoteFile)
 {
     try {
         return ftp_mdtm($this->connectionId, $remoteFile);
     } catch (\Exception $e) {
         return false;
     }
 }
Example #23
0
 /**
  * @see RemoteDriver::mdtm($path)
  */
 public function mdtm($path)
 {
     $this->connectIfNeeded();
     $this->param = $path;
     $res = ftp_mdtm($this->handle, $path);
     if ($res < 0) {
         throw new FtpException(Yii::t('gftp', 'Could not get modification time of file "{file}" on server "{host}"', ['host' => $this->host, 'file' => $path]));
     }
     return $res;
 }
 public function filedate($remote_file)
 {
     $this->login();
     $this->cdToHome();
     $date = ftp_mdtm($this->link_id, $this->root_dir . $remote_file);
     return $date != -1 ? $date : 'No Date available';
 }
Example #25
0
 /**
  * @desc Devuelve la fecha de modificación de un archivo en el servidor
  * @param string Ruta válida del archivo
  * @return int
  */
 public function mtime($ruta)
 {
     return ftp_mdtm($this->connection, $ruta);
 }
Example #26
0
 /**
  * @param $job_object
  * @return bool
  */
 public function job_run_archive(BackWPup_Job $job_object)
 {
     $job_object->substeps_todo = 2 + $job_object->backup_filesize;
     if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
         $job_object->log(sprintf(__('%d. Try to send backup file to an FTP server&#160;&hellip;', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']), E_USER_NOTICE);
     }
     if (!empty($job_object->job['ftpssl'])) {
         //make SSL FTP connection
         if (function_exists('ftp_ssl_connect')) {
             $ftp_conn_id = ftp_ssl_connect($job_object->job['ftphost'], $job_object->job['ftphostport'], $job_object->job['ftptimeout']);
             if ($ftp_conn_id) {
                 $job_object->log(sprintf(__('Connected via explicit SSL-FTP to server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_NOTICE);
             } else {
                 $job_object->log(sprintf(__('Cannot connect via explicit SSL-FTP to server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_ERROR);
                 return FALSE;
             }
         } else {
             $job_object->log(__('PHP function to connect with explicit SSL-FTP to server does not exist!', 'backwpup'), E_USER_ERROR);
             return TRUE;
         }
     } else {
         //make normal FTP connection if SSL not work
         $ftp_conn_id = ftp_connect($job_object->job['ftphost'], $job_object->job['ftphostport'], $job_object->job['ftptimeout']);
         if ($ftp_conn_id) {
             $job_object->log(sprintf(__('Connected to FTP server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_NOTICE);
         } else {
             $job_object->log(sprintf(__('Cannot connect to FTP server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_ERROR);
             return FALSE;
         }
     }
     //FTP Login
     $job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'USER ' . $job_object->job['ftpuser']), E_USER_NOTICE);
     if ($loginok = @ftp_login($ftp_conn_id, $job_object->job['ftpuser'], BackWPup_Encryption::decrypt($job_object->job['ftppass']))) {
         $job_object->log(sprintf(__('FTP server response: %s', 'backwpup'), 'User ' . $job_object->job['ftpuser'] . ' logged in.'), E_USER_NOTICE);
     } else {
         //if PHP ftp login don't work use raw login
         $return = ftp_raw($ftp_conn_id, 'USER ' . $job_object->job['ftpuser']);
         $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_NOTICE);
         if (substr(trim($return[0]), 0, 3) <= 400) {
             $job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'PASS *******'), E_USER_NOTICE);
             $return = ftp_raw($ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt($job_object->job['ftppass']));
             if (substr(trim($return[0]), 0, 3) <= 400) {
                 $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_NOTICE);
                 $loginok = TRUE;
             } else {
                 $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_ERROR);
             }
         }
     }
     if (!$loginok) {
         return FALSE;
     }
     //SYSTYPE
     $job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'SYST'), E_USER_NOTICE);
     $systype = ftp_systype($ftp_conn_id);
     if ($systype) {
         $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $systype), E_USER_NOTICE);
     } else {
         $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), __('Error getting SYSTYPE', 'backwpup')), E_USER_ERROR);
     }
     //set actual ftp dir to ftp dir
     if (empty($job_object->job['ftpdir'])) {
         $job_object->job['ftpdir'] = trailingslashit(ftp_pwd($ftp_conn_id));
     }
     // prepend actual ftp dir if relative dir
     if (substr($job_object->job['ftpdir'], 0, 1) != '/') {
         $job_object->job['ftpdir'] = trailingslashit(ftp_pwd($ftp_conn_id)) . $job_object->job['ftpdir'];
     }
     //test ftp dir and create it if not exists
     if ($job_object->job['ftpdir'] != '/') {
         @ftp_chdir($ftp_conn_id, '/');
         //go to root
         $ftpdirs = explode('/', trim($job_object->job['ftpdir'], '/'));
         foreach ($ftpdirs as $ftpdir) {
             if (empty($ftpdir)) {
                 continue;
             }
             if (!@ftp_chdir($ftp_conn_id, $ftpdir)) {
                 if (@ftp_mkdir($ftp_conn_id, $ftpdir)) {
                     $job_object->log(sprintf(__('FTP Folder "%s" created!', 'backwpup'), $ftpdir), E_USER_NOTICE);
                     ftp_chdir($ftp_conn_id, $ftpdir);
                 } else {
                     $job_object->log(sprintf(__('FTP Folder "%s" cannot be created!', 'backwpup'), $ftpdir), E_USER_ERROR);
                     return FALSE;
                 }
             }
         }
     }
     // Get the current working directory
     $current_ftp_dir = trailingslashit(ftp_pwd($ftp_conn_id));
     if ($job_object->substeps_done == 0) {
         $job_object->log(sprintf(__('FTP current folder is: %s', 'backwpup'), $current_ftp_dir), E_USER_NOTICE);
     }
     //get file size to resume upload
     @clearstatcache();
     $job_object->substeps_done = @ftp_size($ftp_conn_id, $job_object->job['ftpdir'] . $job_object->backup_file);
     if ($job_object->substeps_done == -1) {
         $job_object->substeps_done = 0;
     }
     //PASV
     $job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'PASV'), E_USER_NOTICE);
     if ($job_object->job['ftppasv']) {
         if (ftp_pasv($ftp_conn_id, TRUE)) {
             $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), __('Entering passive mode', 'backwpup')), E_USER_NOTICE);
         } else {
             $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), __('Cannot enter passive mode', 'backwpup')), E_USER_WARNING);
         }
     } else {
         if (ftp_pasv($ftp_conn_id, FALSE)) {
             $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), __('Entering normal mode', 'backwpup')), E_USER_NOTICE);
         } else {
             $job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), __('Cannot enter normal mode', 'backwpup')), E_USER_WARNING);
         }
     }
     if ($job_object->substeps_done < $job_object->backup_filesize) {
         $job_object->log(__('Starting upload to FTP &#160;&hellip;', 'backwpup'), E_USER_NOTICE);
         if ($fp = fopen($job_object->backup_folder . $job_object->backup_file, 'rb')) {
             //go to actual file pos
             fseek($fp, $job_object->substeps_done);
             $ret = ftp_nb_fput($ftp_conn_id, $current_ftp_dir . $job_object->backup_file, $fp, FTP_BINARY, $job_object->substeps_done);
             while ($ret == FTP_MOREDATA) {
                 $job_object->substeps_done = ftell($fp);
                 $job_object->update_working_data();
                 $job_object->do_restart_time();
                 $ret = ftp_nb_continue($ftp_conn_id);
             }
             if ($ret != FTP_FINISHED) {
                 $job_object->log(__('Cannot transfer backup to FTP server!', 'backwpup'), E_USER_ERROR);
                 return FALSE;
             } else {
                 $job_object->substeps_done = $job_object->backup_filesize + 1;
                 $job_object->log(sprintf(__('Backup transferred to FTP server: %s', 'backwpup'), $current_ftp_dir . $job_object->backup_file), E_USER_NOTICE);
                 if (!empty($job_object->job['jobid'])) {
                     BackWPup_Option::update($job_object->job['jobid'], 'lastbackupdownloadurl', "ftp://" . $job_object->job['ftpuser'] . ":" . BackWPup_Encryption::decrypt($job_object->job['ftppass']) . "@" . $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport'] . $current_ftp_dir . $job_object->backup_file);
                 }
             }
             fclose($fp);
         } else {
             $job_object->log(__('Can not open source file for transfer.', 'backwpup'), E_USER_ERROR);
             return FALSE;
         }
     }
     $backupfilelist = array();
     $filecounter = 0;
     $files = array();
     if ($filelist = ftp_nlist($ftp_conn_id, '.')) {
         foreach ($filelist as $file) {
             if (basename($file) != '.' && basename($file) != '..') {
                 if ($job_object->is_backup_archive($file)) {
                     $time = ftp_mdtm($ftp_conn_id, $file);
                     if ($time != -1) {
                         $backupfilelist[$time] = basename($file);
                     } else {
                         $backupfilelist[] = basename($file);
                     }
                 }
                 $files[$filecounter]['folder'] = 'ftp://' . $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport'] . $job_object->job['ftpdir'];
                 $files[$filecounter]['file'] = $job_object->job['ftpdir'] . basename($file);
                 $files[$filecounter]['filename'] = basename($file);
                 $files[$filecounter]['downloadurl'] = 'ftp://' . rawurlencode($job_object->job['ftpuser']) . ':' . rawurlencode(BackWPup_Encryption::decrypt($job_object->job['ftppass'])) . '@' . $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport'] . $job_object->job['ftpdir'] . basename($file);
                 $files[$filecounter]['filesize'] = ftp_size($ftp_conn_id, $file);
                 $files[$filecounter]['time'] = ftp_mdtm($ftp_conn_id, $file);
                 $filecounter++;
             }
         }
     }
     if (!empty($job_object->job['ftpmaxbackups']) && $job_object->job['ftpmaxbackups'] > 0) {
         //Delete old backups
         if (count($backupfilelist) > $job_object->job['ftpmaxbackups']) {
             ksort($backupfilelist);
             $numdeltefiles = 0;
             while ($file = array_shift($backupfilelist)) {
                 if (count($backupfilelist) < $job_object->job['ftpmaxbackups']) {
                     break;
                 }
                 if (ftp_delete($ftp_conn_id, $file)) {
                     //delete files on ftp
                     foreach ($files as $key => $filedata) {
                         if ($filedata['file'] == $job_object->job['ftpdir'] . $file) {
                             unset($files[$key]);
                         }
                     }
                     $numdeltefiles++;
                 } else {
                     $job_object->log(sprintf(__('Cannot delete "%s" on FTP server!', 'backwpup'), $job_object->job['ftpdir'] . $file), E_USER_ERROR);
                 }
             }
             if ($numdeltefiles > 0) {
                 $job_object->log(sprintf(_n('One file deleted on FTP server', '%d files deleted on FTP server', $numdeltefiles, 'backwpup'), $numdeltefiles), E_USER_NOTICE);
             }
         }
     }
     set_site_transient('backwpup_' . $job_object->job['jobid'] . '_ftp', $files, YEAR_IN_SECONDS);
     $job_object->substeps_done++;
     ftp_close($ftp_conn_id);
     return TRUE;
 }
Example #27
0
 /**
  * This will return the last modification-time of a file. You can either give this
  * function a relative or an absolute path to the file to check.
  * NOTE: Some servers will not support this feature and the function works
  * only on files, not directories! When successful,
  * it will return the last modification-time as a unix-timestamp or, when $format is
  * specified, a preformated timestring.
  *
  * @access  public
  * @param   string $file    The file to check
  * @param   string $format  (optional) The format to give the date back 
  *                          if not set, it will return a Unix timestamp
  * @return  mixed           Unix timestamp, a preformated date-string or PEAR::Error
  * @see     NET_FTP_ERR_MDTMDIR_UNSUPPORTED, NET_FTP_ERR_MDTM_FAILED, NET_FTP_ERR_DATEFORMAT_FAILED
  */
 function mdtm($file, $format = null)
 {
     $file = $this->_construct_path($file);
     if ($this->_check_dir($file)) {
         return $this->raiseError("Filename '{$file}' seems to be a directory.", NET_FTP_ERR_MDTMDIR_UNSUPPORTED);
     }
     $res = @ftp_mdtm($this->_handle, $file);
     if ($res == -1) {
         return $this->raiseError("Could not get last-modification-date of '{$file}'.", NET_FTP_ERR_MDTM_FAILED);
     }
     if (isset($format)) {
         $res = date($format, $res);
         if (!$res) {
             return $this->raiseError("Date-format failed on timestamp '{$res}'.", NET_FTP_ERR_DATEFORMAT_FAILED);
         }
     }
     return $res;
 }
Example #28
0
 /**
  * FTP-文件修改时间
  *
  * @param string $file 文件
  *
  * @return bool
  */
 public function mdtm($file)
 {
     return ftp_mdtm($this->linkid, $file);
 }
 /**
  * @param string $file
  * @return int
  */
 public function mtime($file)
 {
     return ftp_mdtm($this->link, $file);
 }
Example #30
0
 /**
  * 文件信息
  * @access public
  * @param string $path
  * @return array
  */
 public function fileinfo($path)
 {
     return ['size' => @ftp_size($this->link, $path), 'mondify' => @ftp_mdtm($this->link, $path)];
 }