本文整理汇总了PHP中filectime函数的典型用法代码示例。如果您正苦于以下问题:PHP filectime函数的具体用法?PHP filectime怎么用?PHP filectime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filectime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: printqueue_GET
function printqueue_GET(Web $w)
{
$print_folder = FILE_ROOT . "print";
$path = realpath($print_folder);
// Check if folder exists
if ($path === false) {
// Make print folder (If you specify a full path, use the recursion flag because it seems to crash without it in unix)
// Other wise you would need to chdir to the parent folder, create and change back to wherever execution currently was at
mkdir($print_folder, 0777, true);
$path = realpath($print_folder);
}
$exclude = array("THUMBS.db");
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
$table_data = array();
$table_header = array("Name", "Size", "Date Created", "Actions");
foreach ($objects as $name => $object) {
$filename = $object->getFilename();
// Ignore files starting with '.' and in exclude array
if ($filename[0] === '.' || in_array($filename, $exclude)) {
continue;
}
$table_data[] = array(Html::a("/uploads/print/" . $filename, $filename), humanReadableBytes($object->getSize()), date("H:i d/m/Y", filectime($name)), Html::box("/admin/printfile?filename=" . urlencode($name), "Print", true) . " " . Html::b("/admin/deleteprintfile?filename=" . urlencode($name), "Delete", "Are you sure you want to remove this file? (This is irreversible)"));
}
$w->out(Html::table($table_data, null, "tablesorter", $table_header));
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:25,代码来源:printqueue.php
示例2: run
/**
* Auszuführender Cron-Code
*/
public function run()
{
if (!\fpcm\classes\baseconfig::asyncCronjobsEnabled()) {
return false;
}
if (!is_writable(\fpcm\classes\baseconfig::$tempDir)) {
trigger_error('Unable to cleanup ' . \fpcm\classes\baseconfig::$tempDir . '! Access denied!');
return false;
}
$tempFiles = glob(\fpcm\classes\baseconfig::$tempDir . '*');
if (!is_array($tempFiles) || !count($tempFiles)) {
return true;
}
foreach ($tempFiles as $tempFile) {
if ($tempFile == \fpcm\classes\baseconfig::$tempDir . 'index.html') {
continue;
}
if (filectime($tempFile) + 3600 * 24 > time()) {
continue;
}
if (is_dir($tempFile)) {
\fpcm\model\files\ops::deleteRecursive($tempFile);
continue;
}
unlink($tempFile);
}
\fpcm\classes\logs::syslogWrite('Temp files cleanup in ' . \fpcm\classes\baseconfig::$tempDir);
return true;
}
开发者ID:sea75300,项目名称:fanpresscm3,代码行数:32,代码来源:clearTemp.php
示例3: resize
public function resize($filename, $width, $height)
{
if (!is_file(DIR_IMAGE . $filename)) {
return;
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
if (!is_file(DIR_IMAGE . $new_image) || filectime(DIR_IMAGE . $old_image) > filectime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!is_dir(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $new_image);
} else {
copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
}
}
if ($this->request->server['HTTPS']) {
return $this->config->get('config_ssl') . 'image/' . $new_image;
} else {
return $this->config->get('config_url') . 'image/' . $new_image;
}
}
开发者ID:sir-oga,项目名称:peterpan,代码行数:32,代码来源:image.php
示例4: dir_get_infos
function dir_get_infos($dir = '')
{
if ($dir == '') {
return;
}
$dir = str_replace('//', '/', $dir . '/');
foreach (self::glob($dir . '*') as $file) {
$array = array();
if (!is_dir($file)) {
if (self::webos() !== 'Windows') {
if (function_exists('posix_getpwuid')) {
$tmp = posix_getpwuid(fileowner($file));
$array['owner'] = $tmp['name'];
}
}
$array['md5file'] = md5_file($file);
$array['file'] = $file;
$array['filectime'] = filectime($file);
$array['filemtime'] = filemtime($file);
$array['isdir'] = false;
$return[] = $array;
} else {
$return[] = array('file' => $file, 'isdir' => true);
}
}
return serialize($return);
}
开发者ID:h136799711,项目名称:201507banma,代码行数:27,代码来源:dir_get_infos.php
示例5: deleteDirectory
public static function deleteDirectory($dir, $expireTime = null)
{
if (!file_exists($dir)) {
return false;
}
if (!is_dir($dir) || is_link($dir)) {
if ($expireTime) {
$fileCreationTime = filectime($dir);
if (time() - $fileCreationTime < $expireTime) {
return true;
}
}
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if (!org_glizy_helpers_Files::deleteDirectory($dir . "/" . $item, $expireTime)) {
chmod($dir . "/" . $item, 0777);
if (!org_glizy_helpers_Files::deleteDirectory($dir . "/" . $item, $expireTime)) {
return false;
}
}
}
return @rmdir($dir);
}
开发者ID:GruppoMeta,项目名称:Movio,代码行数:27,代码来源:Files.php
示例6: FastEncodeVideo
/**
* Asyncrhonous Convert all Video format to video/webm
*
* Use ffmpeg for conversion
* @return void
* @author Cédric Levasseur
*/
public static function FastEncodeVideo($file)
{
$basefile = new File($file);
$basepath = File::a2r($file);
$path_thumb_webm = File::Root() . '/' . Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . '.webm';
$path_thumb_jpg = File::Root() . '/' . Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . '.jpg';
if (!file_exists($path_thumb_webm) || filectime($file) > filectime($path_thumb_webm)) {
/// Create Folder
if (!file_exists(dirname($path_thumb_webm))) {
@mkdir(dirname($path_thumb_webm), 0755, true);
}
}
error_log($file, 0);
error_log($path_thumb_webm, 0);
if ($basefile->extension != "webm") {
if (!file_exists($path_thumb_webm)) {
///Create Thumbnail jpg in Thumbs folder
$u = Settings::$ffmpeg_path . ' -itsoffset -4 -i ' . $file . ' -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 -y ' . $path_thumb_jpg;
error_log($u, 0);
pclose(popen('start /b ' . $u . '', 'r'));
///Convert video to webm format in Thumbs folder
$u = Settings::$ffmpeg_path . ' -threads 4 -i ' . $file . ' ' . Settings::$ffmpeg_option . ' -y ' . $path_thumb_webm . ' 2>&1';
error_log($u, 0);
pclose(popen('start /b ' . $u . '', 'r'));
}
} else {
//Create Thumbnail jpg in Thumbs folder
$u = Settings::$ffmpeg_path . ' -itsoffset -4 -i ' . $file . ' -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 -y ' . $path_thumb_jpg;
pclose(popen('start /b ' . $u . '', 'r'));
///Copy original webm video to Thumbs folder
copy($file, $path_thumb_webm);
}
}
开发者ID:nemtos,项目名称:PhotoShow,代码行数:40,代码来源:Video.php
示例7: get_forecast_data
/**
* Perform a retrieval for the Wunderground forecast information
*/
function get_forecast_data($force = FALSE)
{
$req = "http://api.yr.no/weatherapi/locationforecast/1.8/?lat={$this->lat};lon={$this->lon};msl={$this->msl}";
if ($this->cache_dir && !$force) {
$cfile = "{$this->cache_dir}/WU-{$this->lat}-{$this->lon}-{$this->msl}.xml";
// Tidy cache
$expiry = mktime() + $this->cache_expiry;
foreach (glob("{$this->cache_dir}/*.xml") as $file) {
if (filectime($file) > $expiry) {
unlink($file);
}
}
if (!file_exists($cfile)) {
$blob = file_get_contents($req);
if (!$blob) {
die("Invalid return from request to {$req}");
}
$fh = fopen($cfile, 'w');
fwrite($fh, $blob);
fclose($fh);
}
$this->forecast_xml = simplexml_load_file($cfile);
} else {
$this->forecast_xml = simplexml_load_file($req);
}
}
开发者ID:nikolajsp,项目名称:PHP-Wunderground,代码行数:29,代码来源:wunderground.php
示例8: eDoUpdateOnclick
function eDoUpdateOnclick($table, $idf, $onclickf, $filename)
{
global $empire, $dbtbpre, $public_r;
if (!file_exists($filename)) {
return '';
}
if (filesize($filename) >= $public_r['onclickfilesize'] * 1024 || time() - filectime($filename) >= $public_r['onclickfiletime'] * 60) {
$lr = $ocr = array();
if (@($lr = file($filename))) {
if (!@unlink($filename)) {
if ($fp = @fopen($filename, 'w')) {
fwrite($fp, '');
fclose($fp);
}
}
$lr = array_count_values($lr);
foreach ($lr as $id => $oc) {
$ocr[$oc] .= $id > 0 ? ',' . intval($id) : '';
}
foreach ($ocr as $oc => $ids) {
$empire->query("UPDATE LOW_PRIORITY {$table} SET {$onclickf}={$onclickf}+'{$oc}' WHERE {$idf} IN (0{$ids})");
}
}
}
}
开发者ID:BGCX261,项目名称:zjh-dev-svn-to-git,代码行数:25,代码来源:onclickfun.php
示例9: filelist
function filelist($fold, $type = "fold", $cen = 1)
{
global $download_fold;
$cen1 = 3;
$handle = opendir($download_fold . $fold);
if ($handle) {
$fold1 = iconv("GB2312", "UTF-8", $fold);
while ($filedir1 = readdir($handle)) {
if ($filedir1[0] == '.' || $filedir1 == '..') {
continue;
}
$filename = $download_fold . $fold . "/" . $filedir1;
$filedir11 = iconv("GB2312", "UTF-8", $filedir1);
if (is_dir($filename) == false && $type == "file") {
$filetype = typeoffile($filedir1);
$filesize = filesize($filename);
$filetime = date("Y年m月d日H:i:s.", filectime($filename));
$filedir1 = urlencode($filedir1);
echo "<li class=\"{$filetype}\"><a href='http://zhiqiang.org/download{$fold1}/{$filedir1}'>{$filedir11}</a><br/><span>大小:{$filesize} Bytes</span><span><a href=\"javascript:\" onclick=\"ajaxShowPost('http://zhiqiang.org/blog/wp-content/themes/yuewei/jscript/searchfile.php?file={$fold}/{$filedir1}&cen={$cen1}&r='+parseInt(Math.random()*99999999), 'searchfile');return false;\">阅微堂上相关文章</a><span></li>";
} else {
if (is_dir($filename) == true && $type == "fold") {
$r = rand(1, 10000);
$filedir1 = urlencode($filedir1);
echo "<li class=\"folder\"><h{$cen1}><a href=\"javascript:\" onclick=\"if(\$('r{$r}').innerHTML==''){ajaxShowPost('http://zhiqiang.org/blog/wp-content/themes/yuewei/jscript/filelist.php?fold={$fold}/{$filedir1}&cen={$cen1}&r='+parseInt(Math.random()*99999999), 'r{$r}');}else{ \$('r{$r}').style.display!='none'?\$('r{$r}').style.display='none':\$('r{$r}').style.display='block';}return false;\">{$filedir11}</a></h{$cen1}><ul id=\"r{$r}\" style=\"list-style-type:none;\"></ul></li>";
}
}
}
closedir($handle);
}
}
开发者ID:BGCX261,项目名称:zhiqiang-blog-svn-to-git,代码行数:30,代码来源:filelist.php
示例10: load
public function load($path)
{
$r = array();
$path = $this->configuration['basepath'] . $path;
if (is_dir($path)) {
if (false !== ($d = @opendir($path))) {
while (false !== ($f = @readdir($d))) {
if (0 == strncmp($f, '.', 1)) {
continue;
}
$full_path = $path . '/' . $f;
$r2 = array();
$r2['basename'] = $f;
$is_collection = is_dir($full_path);
$r2['is_collection'] = $is_collection ? '1' : '0';
$r2['size'] = $is_collection ? 0 : @filesize($full_path);
$r2['date_created'] = $is_collection ? 0 : @filectime($full_path);
$r2['date_modified'] = $r2['date_created'];
$r2['content_type'] = amy_mime_content_type($full_path);
$r2['version'] = 1;
$r[] = $r2;
}
@closedir($d);
}
} else {
$r = @file_get_contents($path);
}
return $r;
}
开发者ID:aprilchild,项目名称:aprilchild,代码行数:29,代码来源:amy_file_resource_manager.php
示例11: __construct
public function __construct($folder = array())
{
$this->domainDirectory = 'http://' . $_SERVER['HTTP_HOST'] . '/';
$this->pathDirectory = $_SERVER['DOCUMENT_ROOT'] . '/';
foreach ($folder as $name) {
$this->domainFolder .= rawurlencode($name) . '/';
$this->pathFolder .= $name . '/';
}
$targetDirectory = $this->pathDirectory . $this->pathFolder;
$directory = opendir($targetDirectory);
while (($entry = readdir($directory)) !== false) {
if ($entry !== '.' && $entry !== '..') {
$data = array();
$data['name'] = iconv('tis-620', 'utf-8', $entry);
$splitName = explode('[', $entry);
if (count($splitName) > 1) {
$status = explode(']', $splitName[1]);
$data['status'] = $status[0];
} else {
$data['status'] = 'OnGoing';
}
if (is_file($targetDirectory . $entry)) {
$data['path'] = $targetDirectory . $entry;
$data['source'] = $this->domainDirectory . $this->domainFolder . rawurlencode($entry);
} elseif (is_dir($targetDirectory . $entry)) {
$data['path'] = $targetDirectory . $entry . '/';
}
$data['created'] = filectime($data['path']);
$this->arrayDirectory[] = $data;
}
}
closedir($directory);
}
开发者ID:dvgamer,项目名称:It-My.Selfip,代码行数:33,代码来源:manga.class.php
示例12: getPatch
public static function getPatch(array $patch)
{
static $cache = array();
if (!isset($cache[$patch['url']])) {
if (!empty($patch['local'])) {
if (is_file($patch['url']) && filesize($patch['url'])) {
$cache[$patch['url']] = $patch['url'];
} else {
throw new Exception("Unable to read patch from local path {$patch['url']}.");
}
} elseif (drush_get_option('no-cache')) {
$temp_file = drush_tempnam('drush_patchfile_', NULL, '.patch');
$cache[$patch['url']] = static::downloadPatch($patch['url'], $temp_file);
} else {
$cache_file = drush_directory_cache('patchfile') . '/' . md5($patch['url']) . '.patch';
if (is_file($cache_file) && filectime($cache_file) > $_SERVER['REQUEST_TIME'] - DRUSH_CACHE_LIFETIME_DEFAULT) {
drush_log(dt('Remote patch URL @url fetched from cache file @cache.', array('@url' => $patch['url'], '@cache' => $cache_file)));
$cache[$patch['url']] = $cache_file;
} else {
$cache[$patch['url']] = static::downloadPatch($patch['url'], $cache_file);
}
}
}
return $cache[$patch['url']];
}
开发者ID:gormus,项目名称:drush-patchfile,代码行数:25,代码来源:DrushPatchFileGit.php
示例13: rotate
/**
* @ignore
*/
private function rotate()
{
if ($this->_rotated) {
return;
}
if (!is_file($this->filename)) {
return;
}
clearstatcache($this->filename);
if (filesize($this->filename) >= $this->_max_size * 1024 && filectime($this->filename) >= time() - $this->_max_age * 3600) {
return;
}
// gotta rotate
$dest_pattern = $this->filename . '.%d';
$files = glob($this->filename . '.*');
if (is_array($files) && count($files)) {
for ($i = $this->_keepmax - 1; $i > 0; $i--) {
$test_fn = sprintf($dest_pattern, $i);
if (is_file($test_fn)) {
if ($i == $this->_keepmax) {
// only keeping a certain many of these.
unlink($test_fn);
} else {
// rename the file, incremeinging the number
$dest_fn = sprintf($dest_pattern, $i + 1);
rename($test_fn, $dest_fn);
}
}
}
}
$dest_fn = sprintf($dest_pattern, 1);
rename($this->filename, $dest_fn);
$this->_rotated = 1;
}
开发者ID:calguy1000,项目名称:logger,代码行数:37,代码来源:AutoRotateFileLogger.php
示例14: list_dirs
function list_dirs($dir, $mask = "")
{
$return = array();
if (!$mask) {
$mask = $this->mask;
}
if (!file_exists($dir)) {
echo "PHP_Dir: Directory does not exist";
return $return;
}
if (!($d = opendir($dir))) {
exit("PHP_Dir: Failure opening directory");
}
$counter = 0;
while ($file = readdir($d)) {
if (is_dir($dir . $file)) {
$return['dirname'][$counter] = $file;
$return[$counter]['dirsize'] = "-";
$return[$counter]['dirtype'] = "DIR";
$return[$counter]['dirctime'] = filectime($dir);
++$counter;
}
}
if (1 <= sizeof($return['dirname'])) {
sort($return['dirname']);
}
return $return;
}
开发者ID:shesai0519,项目名称:sunshineCRM,代码行数:28,代码来源:class.dir.php
示例15: resize
public function resize($filename, $width, $height)
{
if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
return;
}
$info = pathinfo($filename);
$extension = $info['extension'];
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
if (!file_exists(DIR_IMAGE . $new_image) || filectime(DIR_IMAGE . $old_image) > filectime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!file_exists(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $new_image);
}
if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
return HTTPS_CATALOG . 'image/' . $new_image;
} elseif (isset($this->request->server['HTTP_X_FORWARDED_PROTO']) && $this->request->server['HTTP_X_FORWARDED_PROTO'] == 'https') {
return HTTPS_CATALOG . 'image/' . $new_image;
} else {
return HTTP_CATALOG . 'image/' . $new_image;
}
}
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:30,代码来源:image.php
示例16: rollBackups
/**
* removes the oldest files matching a name pattern, so that $num files remain.
*
* @param string $name
* used in ls, (should be an absolute path) with filename pattern ending in *
* @param number $num
* number of log files to keep
*/
function rollBackups($name, $num = 2)
{
$lsBackupsCmd = 'ls -tU1 ' . $name;
echo ' -> ' . $lsBackupsCmd . "\n";
$roll = explode("\n", trim(shell_exec($lsBackupsCmd)));
if (count($roll) == 1 && stripos($roll[0], 'No such file or directory') !== false) {
echo ' - ' . $roll[0] . "\n";
return;
}
usort($roll, function ($a, $b) {
return filectime($b) - filectime($a);
});
global $dryroll;
global $dryrun;
$dryrunTemp = $dryrun;
$dryrun = $dryroll || $dryrun;
// added the ability to dryrun just the roll function //restores $dryrun after running shell_exec_
if (count($roll) > $num) {
foreach (array_slice($roll, $num) as $old) {
$rmCmd = 'rm \'' . $old . '\' -r -f';
shell_exec_($rmCmd);
}
}
$dryrun = $dryrunTemp;
}
开发者ID:nickolanack,项目名称:apache-vhost-backups-cron,代码行数:33,代码来源:vhost.daily.backup.cron.php
示例17: fileinfo
function fileinfo($uri, $options)
{
$fspath = $this->base . $uri;
$file = array();
$file["path"] = $uri;
$file["props"][] = $this->mkprop("displayname", strtoupper($uri));
$file["props"][] = $this->mkprop("creationdate", filectime($fspath));
$file["props"][] = $this->mkprop("getlastmodified", filemtime($fspath));
if (is_dir($fspath)) {
$file["props"][] = $this->mkprop("getcontentlength", 0);
$file["props"][] = $this->mkprop("resourcetype", "collection");
$file["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
} else {
$file["props"][] = $this->mkprop("resourcetype", "");
$file["props"][] = $this->mkprop("getcontentlength", filesize($fspath));
if (is_readable($fspath)) {
$file["props"][] = $this->mkprop("getcontenttype", rtrim(preg_replace("/^([^;]*);.*/", "\$1", `file -izb '{$fspath}' 2> /dev/null`)));
} else {
$file["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable");
}
}
$query = "SELECT ns, name, value FROM properties WHERE path = '{$uri}'";
$res = mysql_query($query);
while ($row = mysql_fetch_assoc($res)) {
$file["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
}
mysql_free_result($res);
return $file;
}
开发者ID:vojtajina,项目名称:sitellite,代码行数:29,代码来源:Filesystem.php
示例18: penConfigLoad
function penConfigLoad($penId)
{
global $srkEnv;
$fileName = $srkEnv->penPath . '/' . $penId . '/config.json';
$cfgContent = getFileContent($fileName);
if ($cfgContent === -1) {
$ret = (object) array('error' => 'No config file');
} else {
$ret = json_decode($cfgContent);
}
if (!isset($ret->error)) {
if (!isset($ret->penId)) {
$ret->penId = $penId;
}
if (!isset($ret->title)) {
$ret->title = $penId;
}
if (!isset($ret->modifyTime)) {
$ret->modifyTime = filectime($fileName);
}
if (!isset($ret->priority)) {
$ret->priority = $ret->modifyTime;
}
require_once $srkEnv->appPath . '/modules/db.php';
$ret->visitCount = srkVisitCountGet($ret->penId);
}
return $ret;
}
开发者ID:laekov,项目名称:shiruku,代码行数:28,代码来源:pen.php
示例19: syncFiles
/**
* Sync extension files to target.
*
* @param array $files
* @param string $from
* @param string $target
* @access public
* @return void
*/
function syncFiles($files, $from, $target)
{
$from = realpath($from);
$target = realpath($target);
static $copied = array();
foreach ($files as $file) {
$relativePath = str_replace($from, '', $file);
$targetFile = $target . $relativePath;
$targetPath = dirname($targetFile);
/* If file not exists, remove the target. */
if (!is_file($file)) {
@unlink($targetFile);
continue;
}
if (!is_dir($targetPath)) {
mkdir($targetPath, 0755, true);
}
$ctime = filectime($file);
if (!isset($copied[$file]) or $copied[$file] != $ctime) {
copy($file, $targetFile);
$copied[$file] = $ctime;
echo "{$file} copyed\n";
}
}
}
开发者ID:dyp8848,项目名称:chanzhieps,代码行数:34,代码来源:syncext.php
示例20: addLogEntry
/**
* Add's an entry to the changelog and saves the metadata for the page
*
* @param int $date Timestamp of the change
* @param String $id Name of the affected page
* @param String $type Type of the change see DOKU_CHANGE_TYPE_*
* @param String $summary Summary of the change
* @param mixed $extra In case of a revert the revision (timestmp) of the reverted page
* @param array $flags Additional flags in a key value array.
* Available flags:
* - ExternalEdit - mark as an external edit.
*
* @author Andreas Gohr <[email protected]>
* @author Esther Brunner <[email protected]>
* @author Ben Coburn <[email protected]>
*/
function addLogEntry($date, $id, $type = DOKU_CHANGE_TYPE_EDIT, $summary = '', $extra = '', $flags = null)
{
global $conf, $INFO;
/** @var Input $INPUT */
global $INPUT;
// check for special flags as keys
if (!is_array($flags)) {
$flags = array();
}
$flagExternalEdit = isset($flags['ExternalEdit']);
$id = cleanid($id);
$file = wikiFN($id);
$created = @filectime($file);
$minor = $type === DOKU_CHANGE_TYPE_MINOR_EDIT;
$wasRemoved = $type === DOKU_CHANGE_TYPE_DELETE;
if (!$date) {
$date = time();
}
//use current time if none supplied
$remote = !$flagExternalEdit ? clientIP(true) : '127.0.0.1';
$user = !$flagExternalEdit ? $INPUT->server->str('REMOTE_USER') : '';
$strip = array("\t", "\n");
$logline = array('date' => $date, 'ip' => $remote, 'type' => str_replace($strip, '', $type), 'id' => $id, 'user' => $user, 'sum' => utf8_substr(str_replace($strip, '', $summary), 0, 255), 'extra' => str_replace($strip, '', $extra));
// update metadata
if (!$wasRemoved) {
$oldmeta = p_read_metadata($id);
$meta = array();
if (!$INFO['exists'] && empty($oldmeta['persistent']['date']['created'])) {
// newly created
$meta['date']['created'] = $created;
if ($user) {
$meta['creator'] = $INFO['userinfo']['name'];
$meta['user'] = $user;
}
} elseif (!$INFO['exists'] && !empty($oldmeta['persistent']['date']['created'])) {
// re-created / restored
$meta['date']['created'] = $oldmeta['persistent']['date']['created'];
$meta['date']['modified'] = $created;
// use the files ctime here
$meta['creator'] = $oldmeta['persistent']['creator'];
if ($user) {
$meta['contributor'][$user] = $INFO['userinfo']['name'];
}
} elseif (!$minor) {
// non-minor modification
$meta['date']['modified'] = $date;
if ($user) {
$meta['contributor'][$user] = $INFO['userinfo']['name'];
}
}
$meta['last_change'] = $logline;
p_set_metadata($id, $meta);
}
// add changelog lines
$logline = implode("\t", $logline) . "\n";
io_saveFile(metaFN($id, '.changes'), $logline, true);
//page changelog
io_saveFile($conf['changelog'], $logline, true);
//global changelog cache
}
开发者ID:jotttt,项目名称:ttu-wiki,代码行数:76,代码来源:changelog.php
注:本文中的filectime函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论