本文整理汇总了PHP中getCacheName函数的典型用法代码示例。如果您正苦于以下问题:PHP getCacheName函数的具体用法?PHP getCacheName怎么用?PHP getCacheName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getCacheName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: after_action
/**
* Executed after performing the action hooks
*
* Increases counter and purge cache
*/
public function after_action()
{
if ($this->autoinc) {
global $ID;
p_set_metadata($ID, array('bureaucracy' => array($this->get_key() => $this->opt['value'] + 1)));
// Force rerendering by removing the instructions cache file
$cache_fn = getCacheName(wikiFN($ID) . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.' . 'i');
if (file_exists($cache_fn)) {
unlink($cache_fn);
}
}
}
示例2: __construct
/**
* Constructor
*
* Loads the cache
*/
public function __construct()
{
global $conf;
$this->logfile = fullpath($conf['metadir'] . '/' . $this->getConf('accesslog'));
// file not found? assume absolute path
if (!file_exists($this->logfile)) {
$this->logfile = $this->getConf('accesslog');
}
// load the cache file
$this->logcache = getCacheName($this->getConf('accesslog'), '.statdisplay');
if (file_exists($this->logcache)) {
$this->logdata = unserialize(io_readFile($this->logcache, false));
}
}
示例3: _purgecache
/**
* Check for pages changes and eventually purge cache.
*
* @author Samuele Tognini <samuele@samuele.netsons.org>
*
* @param Doku_Event $event
* @param mixed $param not defined
*/
function _purgecache(&$event, $param)
{
global $ID;
global $conf;
/** @var cache_parser $cache */
$cache =& $event->data;
if (!isset($cache->page)) {
return;
}
//purge only xhtml cache
if ($cache->mode != "xhtml") {
return;
}
//Check if it is an pagequery page
if (!p_get_metadata($ID, 'pagequery')) {
return;
}
$aclcache = $this->getConf('aclcache');
if ($conf['useacl']) {
$newkey = false;
if ($aclcache == 'user') {
//Cache per user
if ($_SERVER['REMOTE_USER']) {
$newkey = $_SERVER['REMOTE_USER'];
}
} else {
if ($aclcache == 'groups') {
//Cache per groups
global $INFO;
if ($INFO['userinfo']['grps']) {
$newkey = implode('#', $INFO['userinfo']['grps']);
}
}
}
if ($newkey) {
$cache->key .= "#" . $newkey;
$cache->cache = getCacheName($cache->key, $cache->ext);
}
}
//Check if a page is more recent than purgefile.
if (@filemtime($cache->cache) < @filemtime($conf['cachedir'] . '/purgefile')) {
$event->preventDefault();
$event->stopPropagation();
$event->result = false;
}
}
示例4: handle_cache_aggregation
/**
* For pages containing an aggregation, add the last modified date of the database itself
* to the cache dependencies
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return bool
*/
public function handle_cache_aggregation(Doku_Event $event, $param)
{
global $INPUT;
/** @var \cache_parser $cache */
$cache = $event->data;
if ($cache->mode != 'xhtml') {
return true;
}
if (!$cache->page) {
return true;
}
// not a page cache
$meta = p_get_metadata($cache->page, 'plugin struct');
if (isset($meta['hasaggregation'])) {
/** @var helper_plugin_struct_db $db */
$db = plugin_load('helper', 'struct_db');
// cache depends on last database save
$cache->depends['files'][] = $db->getDB()->getAdapter()->getDbFile();
// dynamic renders should never overwrite the default page cache
// we need this in additon to handle_cache_dynamic() below because we can only
// influence if a cache is used, not that it will be written
if ($INPUT->has(SearchConfigParameters::$PARAM_FILTER) || $INPUT->has(SearchConfigParameters::$PARAM_OFFSET) || $INPUT->has(SearchConfigParameters::$PARAM_SORT)) {
$cache->key .= 'dynamic';
}
// cache depends on today's date
if ($meta['hasaggregation'] & SearchConfig::$CACHE_DATE) {
$oldage = $cache->depends['age'];
$newage = time() - mktime(0, 0, 1);
// time since first second today
$cache->depends['age'] = min($oldage, $newage);
}
// cache depends on current user
if ($meta['hasaggregation'] & SearchConfig::$CACHE_USER) {
$cache->key .= ';' . $INPUT->server->str('REMOTE_USER');
}
// rebuild cachename
$cache->cache = getCacheName($cache->key, $cache->ext);
}
return true;
}
示例5: checkUpdateMessages
/**
* Check for new messages from upstream
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function checkUpdateMessages()
{
global $conf;
global $INFO;
global $updateVersion;
if (!$conf['updatecheck']) {
return;
}
if ($conf['useacl'] && !$INFO['ismanager']) {
return;
}
$cf = getCacheName($updateVersion, '.updmsg');
$lm = @filemtime($cf);
// check if new messages needs to be fetched
if ($lm < time() - 60 * 60 * 24 || $lm < @filemtime(DOKU_INC . DOKU_SCRIPT)) {
@touch($cf);
dbglog("checkUpdateMessages(): downloading messages to " . $cf);
$http = new DokuHTTPClient();
$http->timeout = 12;
$resp = $http->get(DOKU_MESSAGEURL . $updateVersion);
if (is_string($resp) && ($resp == "" || substr(trim($resp), -1) == '%')) {
// basic sanity check that this is either an empty string response (ie "no messages")
// or it looks like one of our messages, not WiFi login or other interposed response
io_saveFile($cf, $resp);
} else {
dbglog("checkUpdateMessages(): unexpected HTTP response received");
}
} else {
dbglog("checkUpdateMessages(): messages up to date");
}
$data = io_readFile($cf);
// show messages through the usual message mechanism
$msgs = explode("\n%\n", $data);
foreach ($msgs as $msg) {
if ($msg) {
msg($msg, 2);
}
}
}
示例6: getAdjustedSVG
/**
* Gets a local scalable copy of the SVG with its dimensions
*
* @param $id
* @param int $cachetime
* @return bool|array either array($file, $width, $height) or false if no cache available
*/
public function getAdjustedSVG($id, $cachetime = -1)
{
$info = $this->getInfo();
$cachefile = getCacheName($id . $info['date'], '.svg');
$cachedate = @filemtime($cachefile);
if ($cachedate && $cachetime < time() - $cachedate) {
list($width, $height) = $this->readSVGsize($cachefile);
return array($cachefile, $width, $height);
}
// still here, create a new cache file
if (preg_match('/^https?:\\/\\//i', $id)) {
io_download($id, $cachefile);
#FIXME make max size configurable
} else {
@copy(mediaFN($id), $cachefile);
}
clearstatcache(false, $cachefile);
// adjust the size in the cache file
if (file_exists($cachefile)) {
list($width, $height) = $this->readSVGsize($cachefile, true);
return array($cachefile, $width, $height);
}
return false;
}
示例7: js_out
/**
* Output all needed JavaScript
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function js_out()
{
global $conf;
global $lang;
global $config_cascade;
// The generated script depends on some dynamic options
$cache = getCacheName('scripts' . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.js');
// array of core files
$files = array(DOKU_INC . 'lib/scripts/helpers.js', DOKU_INC . 'lib/scripts/events.js', DOKU_INC . 'lib/scripts/delay.js', DOKU_INC . 'lib/scripts/cookie.js', DOKU_INC . 'lib/scripts/script.js', DOKU_INC . 'lib/scripts/tw-sack.js', DOKU_INC . 'lib/scripts/ajax.js', DOKU_INC . 'lib/scripts/index.js', DOKU_INC . 'lib/scripts/drag.js', DOKU_INC . 'lib/scripts/textselection.js', DOKU_INC . 'lib/scripts/toolbar.js', DOKU_INC . 'lib/scripts/edit.js', DOKU_INC . 'lib/scripts/linkwiz.js', DOKU_INC . 'lib/scripts/media.js', DOKU_INC . 'lib/scripts/subscriptions.js', DOKU_TPLINC . 'script.js');
// add possible plugin scripts and userscript
$files = array_merge($files, js_pluginscripts());
if (isset($config_cascade['userscript']['default'])) {
$files[] = $config_cascade['userscript']['default'];
}
// check cache age & handle conditional request
header('Cache-Control: public, max-age=3600');
header('Pragma: public');
if (js_cacheok($cache, $files)) {
http_conditionalRequest(filemtime($cache));
if ($conf['allowdebug']) {
header("X-CacheUsed: {$cache}");
}
// finally send output
if ($conf['gzip_output'] && http_gzip_valid($cache)) {
header('Vary: Accept-Encoding');
header('Content-Encoding: gzip');
readfile($cache . ".gz");
} else {
if (!http_sendfile($cache)) {
readfile($cache);
}
}
return;
} else {
http_conditionalRequest(time());
}
// start output buffering and build the script
ob_start();
// add some global variables
print "var DOKU_BASE = '" . DOKU_BASE . "';";
print "var DOKU_TPL = '" . DOKU_TPL . "';";
print "var DOKU_UHN = " . (int) useHeading('navigation') . ";";
print "var DOKU_UHC = " . (int) useHeading('content') . ";";
// load JS specific translations
$json = new JSON();
$lang['js']['plugins'] = js_pluginstrings();
echo 'LANG = ' . $json->encode($lang['js']) . ";\n";
// load toolbar
toolbar_JSdefines('toolbar');
// load files
foreach ($files as $file) {
echo "\n\n/* XXXXXXXXXX begin of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
js_load($file);
echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
}
// init stuff
js_runonstart("addEvent(document,'click',closePopups)");
js_runonstart('addTocToggle()');
js_runonstart("initSizeCtl('size__ctl','wiki__text')");
js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)");
if ($conf['locktime'] != 0) {
js_runonstart("locktimer.init(" . ($conf['locktime'] - 60) . ",'" . js_escape($lang['willexpire']) . "'," . $conf['usedraft'] . ")");
}
js_runonstart('scrollToMarker()');
js_runonstart('focusMarker()');
// init hotkeys - must have been done after init of toolbar
# disabled for FS#1958 js_runonstart('initializeHotkeys()');
// end output buffering and get contents
$js = ob_get_contents();
ob_end_clean();
// compress whitespace and comments
if ($conf['compress']) {
$js = js_compress($js);
}
$js .= "\n";
// https://bugzilla.mozilla.org/show_bug.cgi?id=316033
// save cache file
io_saveFile($cache, $js);
if (function_exists('gzopen')) {
io_saveFile("{$cache}.gz", $js);
}
// finally send output
if ($conf['gzip_output']) {
header('Vary: Accept-Encoding');
header('Content-Encoding: gzip');
print gzencode($js, 9, FORCE_GZIP);
} else {
print $js;
}
}
示例8: ajax_draftdel
/**
* Delete a draft
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function ajax_draftdel()
{
$id = cleanID($_REQUEST['id']);
if (empty($id)) {
return;
}
$client = $_SERVER['REMOTE_USER'];
if (!$client) {
$client = clientIP(true);
}
$cname = getCacheName($client . $id, '.draft');
@unlink($cname);
}
示例9: p_xhtml_cached_geshi
/**
* Wrapper for GeSHi Code Highlighter, provides caching of its output
*
* @author Christopher Smith <chris@jalakai.co.uk>
*/
function p_xhtml_cached_geshi($code, $language)
{
$cache = getCacheName($language . $code, ".code");
if (@file_exists($cache) && !$_REQUEST['purge'] && filemtime($cache) > filemtime(DOKU_INC . 'inc/geshi.php')) {
$highlighted_code = io_readFile($cache, false);
@touch($cache);
} else {
require_once DOKU_INC . 'inc/geshi.php';
$geshi = new GeSHi($code, strtolower($language), DOKU_INC . 'inc/geshi');
$geshi->set_encoding('utf-8');
$geshi->enable_classes();
$geshi->set_header_type(GESHI_HEADER_PRE);
$geshi->set_overall_class("code {$language}");
$geshi->set_link_target($conf['target']['extern']);
$highlighted_code = $geshi->parse_code();
io_saveFile($cache, $highlighted_code);
}
return $highlighted_code;
}
示例10: pageinfo
/**
* Return info about the current document as associative
* array.
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function pageinfo()
{
global $ID;
global $REV;
global $USERINFO;
global $conf;
// include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml
// FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary
$info['id'] = $ID;
$info['rev'] = $REV;
if ($_SERVER['REMOTE_USER']) {
$info['userinfo'] = $USERINFO;
$info['perm'] = auth_quickaclcheck($ID);
$info['subscribed'] = is_subscribed($ID, $_SERVER['REMOTE_USER']);
$info['client'] = $_SERVER['REMOTE_USER'];
// if some outside auth were used only REMOTE_USER is set
if (!$info['userinfo']['name']) {
$info['userinfo']['name'] = $_SERVER['REMOTE_USER'];
}
} else {
$info['perm'] = auth_aclcheck($ID, '', null);
$info['subscribed'] = false;
$info['client'] = clientIP(true);
}
$info['namespace'] = getNS($ID);
$info['locked'] = checklock($ID);
$info['filepath'] = realpath(wikiFN($ID));
$info['exists'] = @file_exists($info['filepath']);
if ($REV) {
//check if current revision was meant
if ($info['exists'] && @filemtime($info['filepath']) == $REV) {
$REV = '';
} else {
//really use old revision
$info['filepath'] = realpath(wikiFN($ID, $REV));
$info['exists'] = @file_exists($info['filepath']);
}
}
$info['rev'] = $REV;
if ($info['exists']) {
$info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT;
} else {
$info['writable'] = $info['perm'] >= AUTH_CREATE;
}
$info['editable'] = $info['writable'] && empty($info['lock']);
$info['lastmod'] = @filemtime($info['filepath']);
//load page meta data
$info['meta'] = p_get_metadata($ID);
//who's the editor
if ($REV) {
$revinfo = getRevisionInfo($ID, $REV, 1024);
} else {
$revinfo = isset($info['meta']['last_change']) ? $info['meta']['last_change'] : getRevisionInfo($ID, $info['lastmod'], 1024);
}
$info['ip'] = $revinfo['ip'];
$info['user'] = $revinfo['user'];
$info['sum'] = $revinfo['sum'];
// See also $INFO['meta']['last_change'] which is the most recent log line for page $ID.
// Use $INFO['meta']['last_change']['type']==='e' in place of $info['minor'].
if ($revinfo['user']) {
$info['editor'] = $revinfo['user'];
} else {
$info['editor'] = $revinfo['ip'];
}
// draft
$draft = getCacheName($info['client'] . $ID, '.draft');
if (@file_exists($draft)) {
if (@filemtime($draft) < @filemtime(wikiFN($ID))) {
// remove stale draft
@unlink($draft);
} else {
$info['draft'] = $draft;
}
}
return $info;
}
示例11: pageinfo
/**
* Return info about the current document as associative
* array.
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @return array with info about current document
*/
function pageinfo()
{
global $ID;
global $REV;
global $RANGE;
global $lang;
/* @var Input $INPUT */
global $INPUT;
$info = basicinfo($ID);
// include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml
// FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary
$info['id'] = $ID;
$info['rev'] = $REV;
if ($INPUT->server->has('REMOTE_USER')) {
$sub = new Subscription();
$info['subscribed'] = $sub->user_subscription();
} else {
$info['subscribed'] = false;
}
$info['locked'] = checklock($ID);
$info['filepath'] = fullpath(wikiFN($ID));
$info['exists'] = file_exists($info['filepath']);
$info['currentrev'] = @filemtime($info['filepath']);
if ($REV) {
//check if current revision was meant
if ($info['exists'] && $info['currentrev'] == $REV) {
$REV = '';
} elseif ($RANGE) {
//section editing does not work with old revisions!
$REV = '';
$RANGE = '';
msg($lang['nosecedit'], 0);
} else {
//really use old revision
$info['filepath'] = fullpath(wikiFN($ID, $REV));
$info['exists'] = file_exists($info['filepath']);
}
}
$info['rev'] = $REV;
if ($info['exists']) {
$info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT;
} else {
$info['writable'] = $info['perm'] >= AUTH_CREATE;
}
$info['editable'] = $info['writable'] && empty($info['locked']);
$info['lastmod'] = @filemtime($info['filepath']);
//load page meta data
$info['meta'] = p_get_metadata($ID);
//who's the editor
$pagelog = new PageChangeLog($ID, 1024);
if ($REV) {
$revinfo = $pagelog->getRevisionInfo($REV);
} else {
if (!empty($info['meta']['last_change']) && is_array($info['meta']['last_change'])) {
$revinfo = $info['meta']['last_change'];
} else {
$revinfo = $pagelog->getRevisionInfo($info['lastmod']);
// cache most recent changelog line in metadata if missing and still valid
if ($revinfo !== false) {
$info['meta']['last_change'] = $revinfo;
p_set_metadata($ID, array('last_change' => $revinfo));
}
}
}
//and check for an external edit
if ($revinfo !== false && $revinfo['date'] != $info['lastmod']) {
// cached changelog line no longer valid
$revinfo = false;
$info['meta']['last_change'] = $revinfo;
p_set_metadata($ID, array('last_change' => $revinfo));
}
$info['ip'] = $revinfo['ip'];
$info['user'] = $revinfo['user'];
$info['sum'] = $revinfo['sum'];
// See also $INFO['meta']['last_change'] which is the most recent log line for page $ID.
// Use $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT in place of $info['minor'].
if ($revinfo['user']) {
$info['editor'] = $revinfo['user'];
} else {
$info['editor'] = $revinfo['ip'];
}
// draft
$draft = getCacheName($info['client'] . $ID, '.draft');
if (file_exists($draft)) {
if (@filemtime($draft) < @filemtime(wikiFN($ID))) {
// remove stale draft
@unlink($draft);
} else {
$info['draft'] = $draft;
}
}
return $info;
//.........这里部分代码省略.........
示例12: __construct
/**
* @param string $key primary identifier
* @param string $ext file extension
*/
public function __construct($key, $ext)
{
$this->key = $key;
$this->ext = $ext;
$this->cache = getCacheName($key, $ext);
}
示例13: registerOnLoad
function registerOnLoad($js)
{
global $ID;
global $lang;
$preview_button = $lang['btn_preview'];
$fckg_conf_direction = $this->getConf('direction');
if ($fckg_conf_direction == "dokuwiki") {
$fckg_lang_direction = $lang['direction'];
} else {
$fckg_lang_direction = $fckg_conf_direction;
}
$media_tmp_ns = preg_match('/:/', $ID) ? preg_replace('/:\\w+$/', "", $ID, 1) : "";
$locktimer_msg = "Your lock for editing this page is about to expire in a minute.\\n" . "You can reset the timer by clicking the Back-up button.";
$meta_fn = metaFN($ID, '.fckg');
$meta_id = 'meta/' . str_replace(':', '/', $ID) . '.fckg';
global $INFO;
global $conf;
global $USERINFO;
$_OS = strtolower(PHP_OS);
$cname = getCacheName($INFO['client'] . $ID, '.draft');
$open_upload = $this->getConf('open_upload');
$editor_backup = $this->getConf('editor_bak');
$create_folder = $this->getConf('create_folder');
if (!isset($INFO['userinfo']) && !$open_upload) {
$user_type = 'visitor';
} else {
$user_type = 'user';
}
// if no ACL is used always return upload rights
if ($conf['useacl']) {
$client = $_SERVER['REMOTE_USER'];
} else {
$client = "";
}
$fnencode = isset($conf['fnencode']) ? $conf['fnencode'] : 'url';
$user_groups = $USERINFO['grps'];
if (!$user_groups) {
$user_groups = array();
}
if (@in_array("guest", $user_groups)) {
$create_folder = 'n';
$user_type = 'visitor';
}
$user_groups = implode(";;", $user_groups);
if ($INFO['isadmin'] || $INFO['ismanager']) {
$client = "";
}
$user_name = $USERINFO['name'];
$user_email = $USERINFO['mail'];
$ver_anteater = mktime(0, 0, 0, 11, 7, 2010);
$dwiki_version = mktime(0, 0, 0, 01, 01, 2008);
if (isset($conf['fnencode'])) {
$ver_anteater = mktime(0, 0, 0, 11, 7, 2010);
$dwiki_version = mktime(0, 0, 0, 11, 7, 2010);
} else {
if (function_exists('getVersionData')) {
$verdata = getVersionData();
if (isset($verdata) && preg_match('/(\\d+)-(\\d+)-(\\d+)/', $verdata['date'], $ver_date)) {
if ($ver_date[1] >= 2005 && ($ver_date[3] > 0 && $ver_date[3] < 31) && ($ver_date[2] > 0 && $ver_date[2] <= 12)) {
// month day year
$dwiki_version = @mktime(0, 0, 0, $ver_date[2], $ver_date[3], $ver_date[1]);
if (!$dwiki_version) {
$dwiki_version = mktime(0, 0, 0, 01, 01, 2008);
}
$ver_anteater = mktime(0, 0, 0, 11, 7, 2010);
}
}
}
}
$default_fb = $this->getConf('default_fb');
if ($default_fb == 'none') {
$client = "";
}
$doku_base = DOKU_BASE;
return <<<end_of_string
<script type='text/javascript'>
//<![CDATA[
if(window.dw_locktimer) {
var locktimer = dw_locktimer;
}
var FCKRecovery = "";
var oldonload = window.onload;
var ourLockTimerINI = false;
var oldBeforeunload;
var fckg_onload = function() { {$js} };
jQuery(window).bind('load',{},fckg_onload);
function fckgEditorTextChanged() {
window.textChanged = false;
oldBeforeunload();
if(window.dwfckTextChanged) {
return LANG.notsavedyet;
}
}
//.........这里部分代码省略.........
示例14: get_resized_image
function get_resized_image($width, $height, $override_sizetype = '', $filetype = '')
{
global $ihConf;
$sizetype = $override_sizetype == '' ? $this->sizetype : $override_sizetype;
switch ($sizetype) {
case 'large':
$file_extension = $ihConf['large']['filetype'] == 'no_change' ? $this->extension : '.' . $ihConf['large']['filetype'];
$background = $ihConf['large']['bg'];
$quality = $ihConf['large']['quality'];
$width = $ihConf['large']['width'];
$height = $ihConf['large']['height'];
break;
case 'medium':
$file_extension = $ihConf['medium']['filetype'] == 'no_change' ? $this->extension : '.' . $ihConf['medium']['filetype'];
$background = $ihConf['medium']['bg'];
$quality = $ihConf['medium']['quality'];
break;
case 'small':
$file_extension = $ihConf['small']['filetype'] == 'no_change' ? $this->extension : '.' . $ihConf['small']['filetype'];
$background = $ihConf['small']['bg'];
$quality = $ihConf['small']['quality'];
break;
default:
$file_extension = $this->extension;
$background = $ihConf['default']['bg'];
$quality = $ihConf['default']['quality'];
break;
}
list($newwidth, $newheight, $resize) = $this->calculate_size($width, $height);
// set canvas dimensions
if ($newwidth > 0 && $newheight > 0) {
$this->canvas['width'] = $newwidth;
$this->canvas['height'] = $newheight;
}
$this->initialize_overlays($sizetype);
// override filetype?
$file_extension = $filetype == '' ? $file_extension : $filetype;
// Do we need to resize, watermark, zoom or convert to another filetype?
if ($resize || $this->watermark['file'] != '' || $this->zoom['file'] != '' || $file_extension != $this->extension) {
$local = getCacheName($this->src . $this->watermark['file'] . $this->zoom['file'] . $quality . $background . $ihConf['watermark']['gravity'] . $ihConf['zoom']['gravity'], '.image.' . $newwidth . 'x' . $newheight . $file_extension);
//echo $local . '<br />';
$mtime = @filemtime($local);
// 0 if not exists
if ($mtime > @filemtime($this->filename) && $mtime > @filemtime($this->watermark['file']) && $mtime > @filemtime($this->zoom['file']) || $this->resize_imageIM($file_extension, $local, $background, $quality) || $this->resize_imageGD($file_extension, $local, $background, $quality)) {
return str_replace($ihConf['dir']['docroot'], '', $local);
}
//still here? resizing failed
}
return $this->src;
}
示例15: getLocalBinary
/**
* Returns the local binary to use
*
* Downloads it if necessary
*
* @return bool|string
*/
protected function getLocalBinary()
{
global $conf;
$bin = $this->getBinaryName();
if (!$bin) {
return false;
}
// check distributed files first
if (file_exists(__DIR__ . '/ditaa/' . $bin)) {
return __DIR__ . '/ditaa/' . $bin;
}
$info = $this->getInfo();
$cache = getCacheName($info['date'], ".{$bin}");
if (file_exists($cache)) {
return $cache;
}
$url = 'https://github.com/akavel/ditaa/releases/download/g1.0.0/' . $bin;
if (io_download($url, $cache, false, '', 0)) {
@chmod($cache, $conf['dmode']);
return $cache;
}
return false;
}