本文整理汇总了PHP中Safe::filemtime方法的典型用法代码示例。如果您正苦于以下问题:PHP Safe::filemtime方法的具体用法?PHP Safe::filemtime怎么用?PHP Safe::filemtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Safe
的用法示例。
在下文中一共展示了Safe::filemtime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zipfile
} else {
// build a zip archive
include_once '../shared/zipfile.php';
$zipfile = new zipfile();
// get related files from the database
$items = array();
if (isset($type) && isset($id)) {
$items = Files::list_by_date_for_anchor($type . ':' . $id, 0, 20, 'raw');
}
// archive each file
$file_path = $context['path_to_root'] . Files::get_path($type . ':' . $id);
foreach ($items as $id => $attributes) {
// read file content
if ($content = Safe::file_get_contents($file_path . '/' . $attributes['file_name'], 'rb')) {
// add the binary data
$zipfile->deflate($attributes['file_name'], Safe::filemtime($file_path . '/' . $attributes['file_name']), $content);
}
}
//
// transfer to the user agent
//
// send the archive content
if ($archive = $zipfile->get()) {
// suggest a download
Safe::header('Content-Type: application/octet-stream');
// suggest a name for the saved file
$file_name = utf8::to_ascii($item['title']) . '.zip';
Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
// file size
Safe::header('Content-Length: ' . strlen($archive));
// already encoded
示例2: array
// process every reference file
$all_files = array();
$index = 0;
foreach ($references as $reference) {
// let's go
list($path, $file) = $reference;
if (strlen(trim($path)) > 0) {
$file = $path . '/' . $file;
}
// read file content
if (($content = Safe::file_get_contents($file_path . $file)) !== FALSE) {
// compress textual content
if ($content && preg_match('/\\.(css|htc|htm|html|include|js|mo|php|po|pot|sql|txt|xml)$/i', $file)) {
$zipfile->deflate('yacs/' . $file, Safe::filemtime($file_path . $file), $content);
} else {
$zipfile->store('yacs/' . $file, Safe::filemtime($file_path . $file), $content);
}
// to be included in tar file as well
$all_files[] = $file_path . $file;
} else {
$context['text'] .= BR . 'cannot read ' . $file_path . $file;
}
// avoid timeouts
if (!($index++ % 50)) {
Safe::set_time_limit(30);
SQL::ping();
}
}
// save the zipfile
if ($handle = Safe::fopen($context['path_to_root'] . $file_name . '.zip', 'wb')) {
fwrite($handle, $zipfile->get());
示例3: preg_replace
// not part of the reference set anymore
$content = preg_replace('/\\s*\\*\\s+@reference\\s*\\n/i', "\n", $content);
// save it as the new cache file
if (Safe::file_put_contents($target, $content)) {
$context['text'] .= sprintf(i18n::s('%s has been transcoded'), $target) . BR . "\n";
} else {
$context['text'] .= sprintf(i18n::s('Impossible to write to %s.'), $target) . BR . "\n";
$errors++;
}
// copy the file
} elseif (!Safe::copy($context['path_to_root'] . $origin, $context['path_to_root'] . $target)) {
$context['text'] .= sprintf(i18n::s('Impossible to copy file %s.'), $target) . BR . "\n";
$errors++;
// attempt to preserve the modification date of the origin file
} else {
Safe::touch($context['path_to_root'] . $target, Safe::filemtime($context['path_to_root'] . $origin));
$context['text'] .= sprintf(i18n::s('%s has been copied'), $target) . BR . "\n";
}
// this will be filtered by umask anyway
Safe::chmod($context['path_to_root'] . $target, $context['file_mask']);
}
$context['text'] .= "</p>\n";
}
// some errors have occured
if ($errors) {
$context['text'] .= '<p>' . i18n::s('Operation has failed.') . "</p>\n";
} else {
$context['text'] .= '<p>' . i18n::s('Congratulations, themes have been updated.') . '</p>' . '<p>' . sprintf(i18n::s('Feel free to change and adjust files at skins/%s to better suit your needs.'), $directory) . '</p>';
// follow-up commands
$follow_up = i18n::s('What do you want to do now?');
$menu = array();
示例4: zipfile
include_once '../shared/zipfile.php';
$zipfile = new zipfile();
// process every skin/current_skin/ file
$index = 0;
foreach ($datafiles as $datafile) {
// let's go
list($path, $filename) = $datafile;
if ($path) {
$file = $path . '/' . $filename;
} else {
$file = $filename;
}
// read file content
if (($content = Safe::file_get_contents($file_prefix . $file)) !== FALSE) {
// store binary data
$zipfile->store($file, Safe::filemtime($file_prefix . $file), $content);
// avoid timeouts
if (!($index++ % 50)) {
Safe::set_time_limit(30);
SQL::ping();
}
}
}
// suggest a download
Safe::header('Content-Type: application/zip');
Safe::header('Content-Disposition: attachment; filename="backup_' . $context['skin'] . '.zip"');
// send the archive content
echo $zipfile->get();
// do not allow for regular rendering
return;
// no file