예제 #1
0
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));
}
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
파일: image.php 프로젝트: sir-oga/peterpan
 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;
     }
 }
예제 #4
0
 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);
 }
예제 #5
0
파일: Files.php 프로젝트: GruppoMeta/Movio
 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);
 }
예제 #6
0
파일: Video.php 프로젝트: nemtos/PhotoShow
 /**
  * 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);
     }
 }
예제 #7
0
 /**
  * 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);
     }
 }
예제 #8
0
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})");
            }
        }
    }
}
예제 #9
0
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);
    }
}
 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;
 }
예제 #11
0
 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);
 }
예제 #12
0
 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']];
 }
예제 #13
0
 /**
  * @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;
 }
예제 #14
0
 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;
 }
예제 #15
0
 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;
     }
 }
/**
 * 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;
}
예제 #17
0
 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;
 }
예제 #18
0
파일: pen.php 프로젝트: laekov/shiruku
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;
}
예제 #19
0
/**
 * 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";
        }
    }
}
예제 #20
0
/**
 * 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 <*****@*****.**>
 * @author Esther Brunner <*****@*****.**>
 * @author Ben Coburn <*****@*****.**>
 */
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
}
예제 #21
0
파일: index.php 프로젝트: SC7639/jade.php
function jade($fn, $file = false, $deps = array())
{
    global $jade;
    $time = @filectime($fn);
    foreach ($deps as $dn) {
        $x = @filectime($dn);
        if ($x === FALSE) {
            break;
        }
        if ($x > $time) {
            $time = $x;
        }
    }
    if ($time === FALSE) {
        die("can't open jade file '{$fn}'");
    }
    if (!isset($jade) || !$jade) {
        $jade = new Jade\Jade(true);
    }
    if ($file) {
        $cn = "cache" . DIRECTORY_SEPARATOR . "{$fn}.php";
        $to = @filectime($pn);
        if ($to === FALSE || $to < $time) {
            file_put_contents($cn, $jade->render($fn));
        }
        return $cn;
    }
    return $jade->render($fn);
}
예제 #22
0
 public function getFile($path = '/')
 {
     $arr = array();
     $paths = ROOT_PATH . $path;
     if (!is_dir($paths)) {
         return $arr;
     }
     $d = opendir($paths);
     while (false !== ($file = readdir($d))) {
         if ($file != '.' && $file != '..') {
             //遍历目录下文件
             $pafile = '' . $paths . '\\' . $file . '';
             if (is_file($pafile)) {
                 $size = filesize($pafile);
                 //文件大小
                 $arra = pathinfo($pafile);
                 $type = $arra['extension'];
                 //文件类型
                 $editdt = date("Y-m-d H:i:s", filectime($pafile));
                 //上次修改时间
                 $lastdt = date("Y-m-d H:i:s", filemtime($pafile));
                 //最后修改的时间
                 $file = iconv('gb2312', 'utf-8', $file);
                 $oi = count($arr);
                 $arr[] = array('file' => $file, 'id' => $file, 'sizecn' => $this->rock->formatsize($size), 'size' => $size, 'editdt' => $editdt, 'lastdt' => $lastdt, 'type' => $type);
             }
         }
     }
     return $arr;
 }
예제 #23
0
function backwpup_read_logheader($logfile)
{
    $headers = array("backwpup_version" => "version", "backwpup_logtime" => "logtime", "backwpup_errors" => "errors", "backwpup_warnings" => "warnings", "backwpup_jobid" => "jobid", "backwpup_jobname" => "name", "backwpup_jobtype" => "type", "backwpup_jobruntime" => "runtime", "backwpup_backupfilesize" => "backupfilesize");
    if (!is_readable($logfile)) {
        return false;
    }
    //Read file
    if (substr($logfile, -3) == ".gz") {
        $fp = gzopen($logfile, 'r');
        $file_data = gzread($fp, 1536);
        // Pull only the first 1,5kiB of the file in.
        gzclose($fp);
    } else {
        $fp = fopen($logfile, 'r');
        $file_data = fread($fp, 1536);
        // Pull only the first 1,5kiB of the file in.
        fclose($fp);
    }
    //get data form file
    foreach ($headers as $keyword => $field) {
        preg_match('/(<meta name="' . $keyword . '" content="(.*)" \\/>)/i', $file_data, $content);
        if (!empty($content)) {
            $joddata[$field] = $content[2];
        } else {
            $joddata[$field] = '';
        }
    }
    if (empty($joddata['logtime'])) {
        $joddata['logtime'] = filectime($logfile);
    }
    return $joddata;
}
예제 #24
0
 public function generate($categories, $offers)
 {
     if (file_exists($this->tmpFile)) {
         if (filectime($this->tmpFile) + $this->fileLifeTime < time()) {
             unlink($this->tmpFile);
             $this->writeHead();
         }
     } else {
         $this->writeHead();
     }
     try {
         if (!empty($categories)) {
             $this->writeCategories($categories);
             unset($categories);
         }
         if (!empty($offers)) {
             $this->writeOffers($offers);
             unset($offers);
         }
         $dom = dom_import_simplexml(simplexml_load_file($this->tmpFile))->ownerDocument;
         $dom->formatOutput = true;
         $formatted = $dom->saveXML();
         unset($dom, $this->xml);
         file_put_contents($this->tmpFile, $formatted);
         rename($this->tmpFile, $this->file);
     } catch (Exception $e) {
         unlink($this->tmpFile);
     }
 }
예제 #25
0
 public function resize($filename, $width, $height)
 {
     if (!is_file(DIR_IMAGE . $filename) || substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != DIR_IMAGE) {
         return;
     }
     $extension = pathinfo($filename, PATHINFO_EXTENSION);
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int) $width . 'x' . (int) $height . '.' . $extension;
     if (!is_file(DIR_IMAGE . $new_image) || filectime(DIR_IMAGE . $old_image) > filectime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname($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);
         }
     }
     $new_image = str_replace(' ', '%20', $new_image);
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1') || $this->request->server['HTTPS'] == '443') {
         return $this->config->get('config_ssl') . 'image/' . $new_image;
     } elseif (isset($this->request->server['HTTP_X_FORWARDED_PROTO']) && $this->request->server['HTTP_X_FORWARDED_PROTO'] == 'https') {
         return $this->config->get('config_ssl') . 'image/' . $new_image;
     } else {
         return $this->config->get('config_url') . 'image/' . $new_image;
     }
 }
예제 #26
0
파일: file.php 프로젝트: ASDAFF/entask.ru
 public function getCreationTime()
 {
     if (!$this->isExists()) {
         throw new FileNotFoundException($this->originalPath);
     }
     return filectime($this->getPhysicalPath());
 }
예제 #27
0
 public function deleteold($filename)
 {
     $filename = litepublisher::$paths->files . 'themegen' . DIRECTORY_SEPARATOR . $filename;
     if (@filectime($filename) + 24 * 3600 < time()) {
         unlink($filename);
     }
 }
예제 #28
0
function GetPath($path)
{
    $fullPath = system\Helper::arcGetPath(true) . "assets/" . $path . "/";
    $webPath = system\Helper::arcGetPath() . "assets" . $path;
    $files = scandir($fullPath);
    $html = "";
    foreach ($files as $file) {
        if ($file != "." && $file != "..") {
            $html .= "<tr>" . "<td style=\"width: 10px;\"><input type=\"checkbox\" id=\"{$file}\" onchange=\"mark('{$path}/{$file}')\"><label for=\"{$file}\"></label></td>";
            if (is_dir($fullPath . $file)) {
                // folder
                $fi = new FilesystemIterator($fullPath . $file, FilesystemIterator::SKIP_DOTS);
                $html .= "<td><i class=\"fa fa-folder-o\"></i> <a class=\"clickable\" onclick=\"getFolderPath('{$path}/{$file}')\">{$file}</a></td>" . "<td style=\"width: 10px;\">folder</td>" . "<td style=\"width: 10px;\">-</td>" . "<td style=\"width: 100px;\">" . iterator_count($fi) . ngettext(" item", " items", iterator_count($fi)) . "</td>" . "<td style=\"width: 100px;\">" . date("d M Y", filectime($fullPath . $file)) . "</td>";
            } else {
                // get file type
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                $filetype = finfo_file($finfo, $fullPath . $file);
                finfo_close($finfo);
                // file
                $html .= "<td><i class=\"" . GetFileTypeIcon($filetype) . "\"></i> <a class=\"clickable\" onclick=\"viewFile('{$webPath}/{$file}', '{$filetype}', '" . FileSizeConvert(filesize($fullPath . $file)) . "', '" . date("d M Y", filectime($fullPath . $file)) . "')\">{$file}<a/></td>" . "<td style=\"width: 10px;\">{$filetype}</td>" . "<td style=\"width: 10px;\"><a alt=\"Copy link to clipboard\" class=\"clickable\" onclick=\"copyToClipboard('{$webPath}/{$file}')\"><i class=\"fa fa-link\"></i></a></td>" . "<td style=\"width: 100px;\">" . FileSizeConvert(filesize($fullPath . $file)) . "</td>" . "<td style=\"width: 100px;\">" . date("d M Y", filectime($fullPath . $file)) . "</td>";
            }
            $html .= "</tr>";
        }
    }
    // no files
    if (count($files) == 2) {
        $html .= "<tr><td colspan=\"4\" class=\"text-center\">Folder is empty.</td></tr>";
    }
    return $html;
}
예제 #29
0
 function isCached($image, $cacheParams)
 {
     if (!rex_image::isValid($image)) {
         trigger_error('Given image is not a valid rex_image', E_USER_ERROR);
     }
     $original_cache_file = $this->getCacheFile($image, $cacheParams);
     $cache_files = glob($original_cache_file . '*');
     // ----- check for cache file
     if (is_array($cache_files) && count($cache_files) == 1) {
         $cache_file = $cache_files[0];
         // time of cache
         $cachetime = filectime($cache_file);
         $imagepath = $image->getFilePath();
         if ($original_cache_file != $cache_file) {
             $image->img['format'] = strtoupper(OOMedia::_getExtension($cache_file));
             $image->img['file'] = $image->img['file'] . '.' . OOMedia::_getExtension($cache_file);
         }
         // file exists?
         if (file_exists($imagepath)) {
             $filetime = filectime($imagepath);
         } else {
             // Missing original file for cache-validation!
             $image->sendErrorImage();
         }
         // cache is newer?
         if ($cachetime > $filetime) {
             return true;
         }
     }
     return false;
 }
예제 #30
0
 public function listFile($pathname, $pattern = '*')
 {
     static $_listDirs = array();
     $guid = md5($pathname . $pattern);
     if (!isset($_listDirs[$guid])) {
         $dir = array();
         $list = glob($pathname . $pattern);
         foreach ($list as $i => $file) {
             $dir[$i]['filename'] = basename($file);
             $dir[$i]['pathname'] = realpath($file);
             $dir[$i]['owner'] = fileowner($file);
             $dir[$i]['perms'] = fileperms($file);
             $dir[$i]['inode'] = fileinode($file);
             $dir[$i]['group'] = filegroup($file);
             $dir[$i]['path'] = dirname($file);
             $dir[$i]['atime'] = fileatime($file);
             $dir[$i]['ctime'] = filectime($file);
             $dir[$i]['size'] = filesize($file);
             $dir[$i]['type'] = filetype($file);
             $dir[$i]['ext'] = is_file($file) ? strtolower(substr(strrchr(basename($file), '.'), 1)) : '';
             $dir[$i]['mtime'] = filemtime($file);
             $dir[$i]['isDir'] = is_dir($file);
             $dir[$i]['isFile'] = is_file($file);
             $dir[$i]['isLink'] = is_link($file);
             $dir[$i]['isReadable'] = is_readable($file);
             $dir[$i]['isWritable'] = is_writable($file);
         }
         $cmp_func = create_function('$a,$b', '' . "\r\n" . '			$k  =  "isDir";' . "\r\n" . '			if($a[$k]  ==  $b[$k])  return  0;' . "\r\n" . '			return  $a[$k]>$b[$k]?-1:1;' . "\r\n" . '			');
         usort($dir, $cmp_func);
         $this->_values = $dir;
         $_listDirs[$guid] = $dir;
     } else {
         $this->_values = $_listDirs[$guid];
     }
 }