本文整理汇总了PHP中ftp_mdtm函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_mdtm函数的具体用法?PHP ftp_mdtm怎么用?PHP ftp_mdtm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_mdtm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getFileInfo
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");
}
示例2: testFileModified
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');
}
示例3: is_file
function is_file($file)
{
$buff = @ftp_mdtm($this->_conn, $file);
if ($buff != -1) {
return true;
} else {
return false;
}
}
示例4: getLastModifiedTD
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";
}
}
示例5: getFilesInfo
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;
}
示例6: writeTempFile
/**
* 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;
}
示例7: addFile
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;
}
}
示例8: downloadAll
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;
}
}
示例9: modified
/**
* 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}");
}
示例10: mtime
/**
* {@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;
}
示例11: _modified
/**
* 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}");
}
示例12: lastModified
/**
* 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);
}
示例13: mdtm
/**
*
* 返回指定文件的最后修改时间
*
* @param string $remote_file
*/
public static function mdtm($remote_file)
{
return ftp_mdtm(self::$resource, $remote_file);
}
示例14: upload
/**
* 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);
}
示例15: getFileModificationTime
/**
* @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;
}