public function _connect() { if (isset($this->_profile['storage_dir']) && $this->_profile['storage_dir'] != '') { $this->_storage_dir = str_replace(array('var:', 'temp:'), array(jApp::varPath(), jApp::tempPath()), $this->_profile['storage_dir']); $this->_storage_dir = rtrim($this->_storage_dir, '\\/') . DIRECTORY_SEPARATOR; } else { $this->_storage_dir = jApp::varPath('kvfiles/'); } jFile::createDir($this->_storage_dir); if (isset($this->_profile['file_locking'])) { $this->_file_locking = $this->_profile['file_locking'] ? true : false; } if (isset($this->_profile['automatic_cleaning_factor'])) { $this->automatic_cleaning_factor = $this->_profile['automatic_cleaning_factor']; } if (isset($this->_profile['directory_level']) && $this->_profile['directory_level'] > 0) { $this->_directory_level = $this->_profile['directory_level']; if ($this->_directory_level > 16) { $this->_directory_level = 16; } } if (isset($this->_profile['directory_umask']) && is_string($this->_profile['directory_umask']) && $this->_profile['directory_umask'] != '') { $this->_directory_umask = octdec($this->_profile['directory_umask']); } if (isset($this->_profile['file_umask']) && is_string($this->_profile['file_umask']) && $this->_profile['file_umask'] != '') { $this->file_umask = octdec($this->_profile['file_umask']); } }
function testContext() { $appPath = jApp::appPath(); $varPath = jApp::varPath(); $logPath = jApp::logPath(); $configPath = jApp::configPath(); $wwwPath = jApp::wwwPath(); $scriptsPath = jApp::scriptsPath(); $tempPath = jApp::tempPath(); // first save jApp::saveContext(); // verify that we still have the current path $this->assertEquals($appPath, jApp::appPath()); $this->assertEquals($varPath, jApp::varPath()); $this->assertEquals($logPath, jApp::logPath()); $this->assertEquals($configPath, jApp::configPath()); $this->assertEquals($wwwPath, jApp::wwwPath()); $this->assertEquals($scriptsPath, jApp::scriptsPath()); $this->assertEquals($tempPath, jApp::tempPath()); // change the path jApp::initPaths('/myapp/'); $this->assertEquals('/myapp/', jApp::appPath()); $this->assertEquals('/myapp/var/', jApp::varPath()); $this->assertEquals('/myapp/var/log/', jApp::logPath()); $this->assertEquals('/myapp/var/config/', jApp::configPath()); $this->assertEquals('/myapp/www/', jApp::wwwPath()); $this->assertEquals('/myapp/scripts/', jApp::scriptsPath()); $this->assertEquals($tempPath, jApp::tempPath()); // second save jApp::saveContext(); jApp::initPaths('/myapp2/'); $this->assertEquals('/myapp2/', jApp::appPath()); $this->assertEquals('/myapp2/var/', jApp::varPath()); $this->assertEquals('/myapp2/var/log/', jApp::logPath()); $this->assertEquals('/myapp2/var/config/', jApp::configPath()); $this->assertEquals('/myapp2/www/', jApp::wwwPath()); $this->assertEquals('/myapp2/scripts/', jApp::scriptsPath()); $this->assertEquals($tempPath, jApp::tempPath()); // pop the second save, we should be with the first saved values jApp::restoreContext(); $this->assertEquals('/myapp/', jApp::appPath()); $this->assertEquals('/myapp/var/', jApp::varPath()); $this->assertEquals('/myapp/var/log/', jApp::logPath()); $this->assertEquals('/myapp/var/config/', jApp::configPath()); $this->assertEquals('/myapp/www/', jApp::wwwPath()); $this->assertEquals('/myapp/scripts/', jApp::scriptsPath()); $this->assertEquals($tempPath, jApp::tempPath()); // pop the first save, we should be with initial paths jApp::restoreContext(); $this->assertEquals($appPath, jApp::appPath()); $this->assertEquals($varPath, jApp::varPath()); $this->assertEquals($logPath, jApp::logPath()); $this->assertEquals($configPath, jApp::configPath()); $this->assertEquals($wwwPath, jApp::wwwPath()); $this->assertEquals($scriptsPath, jApp::scriptsPath()); $this->assertEquals($tempPath, jApp::tempPath()); }
public function testFlush() { parent::testFlush(); $this->assertTrue(file_exists(jApp::tempPath() . 'cache/usingfile/jelix_cache___flush1DataKey.cache')); $this->assertTrue(file_exists(jApp::tempPath() . 'cache/usingfile/jelix_cache___flush2DataKey.cache')); $this->assertTrue(file_exists(jApp::tempPath() . 'cache/usingfile/jelix_cache___flush3DataKey.cache')); $this->assertTrue(jCache::flush($this->profile)); $this->assertFalse(file_exists(jApp::tempPath() . 'cache/usingfile/jelix_cache___flush1DataKey.cache')); $this->assertFalse(file_exists(jApp::tempPath() . 'cache/usingfile/jelix_cache___flush2DataKey.cache')); $this->assertFalse(file_exists(jApp::tempPath() . 'cache/usingfile/jelix_cache___flush3DataKey.cache')); }
protected function loadProfile() { try { jProfiles::get('jcache', 'jforms', true); } catch (Exception $e) { // no profile, let's create a default profile $cacheDir = jApp::tempPath('jforms'); jFile::createDir($cacheDir); $params = array('enabled' => 1, 'driver' => 'file', 'ttl' => 3600 * 48, 'automatic_cleaning_factor' => 3, 'cache_dir' => $cacheDir, 'directory_level' => 3); jProfiles::createVirtualProfile('jcache', 'jforms', $params); } }
/** * Let use one of the available theme */ function useit() { $theme = (string) $this->param('theme'); $mainConfig = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php'); $mainConfig->setValue('theme', strtolower($theme)); $mainConfig->setValue('datepicker', strtolower($theme), 'forms'); $mainConfig->save(); jFile::removeDir(jApp::tempPath(), false); jMessage::add(jLocale::get('theme.selected'), 'information'); $rep = $this->getResponse('redirect'); $rep->action = 'default:index'; return $rep; }
function clear() { $confirm = $this->param('confirm'); if ($confirm == 'Y') { jFile::removeDir(jApp::tempPath(), false); jMessage::add(jLocale::get('jelixcache~jelixcache.cache.clear.done')); } else { jMessage::add(jLocale::get('jelixcache~jelixcache.cache.clear.canceled')); } $rep = $this->getResponse('redirect'); $rep->action = 'jelixcache~default:index'; return $rep; }
public function testFlush() { $kv = jKVDb::getConnection($this->profile); $kv->set('flush1DataKey', 'some data', 0); $kv->setWithTtl('flush2DataKey', 'data to remove', strtotime("+1 day")); $kv->setWithTtl('flush3DataKey', 'other data to remove', time() + 30); $this->assertTrue(file_exists(jApp::tempPath() . 'kvfiles/tests/b6/d7/b6d72473bc7663367d02de121871b573_flush1DataKey')); $this->assertTrue(file_exists(jApp::tempPath() . 'kvfiles/tests/e0/85/e085abf6184768075f5284e5700897c2_flush2DataKey')); $this->assertTrue(file_exists(jApp::tempPath() . 'kvfiles/tests/c8/52/c8527b170651bf375a29e9e77e867385_flush3DataKey')); $this->assertTrue($kv->flush()); $this->assertFalse(file_exists(jApp::tempPath() . 'kvfiles/tests/b6/d7/b6d72473bc7663367d02de121871b573_flush1DataKey')); $this->assertFalse(file_exists(jApp::tempPath() . 'kvfiles/tests/e0/85/e085abf6184768075f5284e5700897c2_flush2DataKey')); $this->assertFalse(file_exists(jApp::tempPath() . 'kvfiles/tests/c8/52/c8527b170651bf375a29e9e77e867385_flush3DataKey')); }
/** * set default parameters for Minify */ static function initOptions() { global $min_allowDebugFlag; global $min_errorLogger; global $min_enableBuilder; global $min_cachePath; global $min_documentRoot; global $min_cacheFileLocking; global $min_symlinks; global $min_serveOptions; global $min_uploaderHoursBehind; global $min_customConfigPaths; if (!isset($min_allowDebugFlag)) { $min_allowDebugFlag = false; } if (!isset($min_errorLogger)) { $min_errorLogger = false; } $min_enableBuilder = false; $min_cachePath = \jApp::tempPath('minify/'); if (!file_exists($min_cachePath)) { mkdir($min_cachePath, 0775); } if (!isset($min_documentRoot)) { $min_documentRoot = self::getDocumentRoot(); } if (!isset($min_cacheFileLocking)) { $min_cacheFileLocking = true; } if (!isset($min_serveOptions['bubbleCssImports'])) { $min_serveOptions['bubbleCssImports'] = false; } if (!isset($min_serveOptions['maxAge'])) { $min_serveOptions['maxAge'] = 1800; } $min_serveOptions['minApp']['groupsOnly'] = false; if (!isset($min_serveOptions['minApp']['maxFiles'])) { $min_serveOptions['minApp']['maxFiles'] = 10; } if (!isset($min_symlinks)) { $min_symlinks = array(); } if (!isset($min_uploaderHoursBehind)) { $min_uploaderHoursBehind = 0; } if (!isset($min_customConfigPaths)) { $min_customConfigPaths = array('groups' => \jApp::configPath('minifyGroupsConfig.php')); } ini_set('zlib.output_compression', '0'); }
/** * load and read the configuration of the application * The combination of all configuration files (the given file * and the mainconfig.ini.php) is stored * in a single temporary file. So it calls the jConfigCompiler * class if needed * @param string $configFile the config file name * @return object it contains all configuration options * @see jConfigCompiler */ public static function load($configFile) { $config = array(); $file = jApp::tempPath() . str_replace('/', '~', $configFile); if (BYTECODE_CACHE_EXISTS) { $file .= '.conf.php'; } else { $file .= '.resultini.php'; } self::$fromCache = true; if (!file_exists($file)) { // no cache, let's compile self::$fromCache = false; } else { $t = filemtime($file); $dc = jApp::mainConfigFile(); $lc = jApp::configPath('localconfig.ini.php'); if (file_exists($dc) && filemtime($dc) > $t || filemtime(jApp::configPath($configFile)) > $t || file_exists($lc) && filemtime($lc) > $t) { // one of the config files have been modified: let's compile self::$fromCache = false; } else { // let's read the cache file if (BYTECODE_CACHE_EXISTS) { include $file; $config = (object) $config; } else { $config = jelix_read_ini($file); } // we check all directories to see if it has been modified if ($config->compilation['checkCacheFiletime']) { foreach ($config->_allBasePath as $path) { if (!file_exists($path) || filemtime($path) > $t) { self::$fromCache = false; break; } } } } } if (!self::$fromCache) { require_once JELIX_LIB_CORE_PATH . 'jConfigCompiler.class.php'; return jConfigCompiler::readAndCache($configFile); } else { return $config; } }
public static function readAndCache($configFile, $isCli = null, $pseudoScriptName = '') { if ($isCli === null) { $isCli = jServer::isCLI(); } $config = self::read($configFile, false, $isCli, $pseudoScriptName); $tempPath = jApp::tempPath(); jFile::createDir($tempPath); if (BYTECODE_CACHE_EXISTS) { $filename = $tempPath . str_replace('/', '~', $configFile) . '.conf.php'; if ($f = @fopen($filename, 'wb')) { fwrite($f, '<?php $config = ' . var_export(get_object_vars($config), true) . ";\n?>"); fclose($f); } else { throw new Exception('Error while writing configuration cache file -- ' . $filename); } } else { jIniFile::write(get_object_vars($config), $tempPath . str_replace('/', '~', $configFile) . '.resultini.php', ";<?php die('');?>\n"); } return $config; }
public function __construct($params) { $this->profil_name = $params['_name']; if (isset($params['enabled'])) { $this->enabled = $params['enabled'] ? true : false; } if (isset($params['ttl'])) { $this->ttl = $params['ttl']; } $this->_cache_dir = jApp::tempPath('cache/') . $this->profil_name . '/'; if (isset($params['cache_dir']) && $params['cache_dir'] != '') { if (is_dir($params['cache_dir']) && is_writable($params['cache_dir'])) { $this->_cache_dir = rtrim(realpath($params['cache_dir']), '\\/') . DIRECTORY_SEPARATOR; } else { throw new jException('jelix~cache.directory.not.writable', $this->profil_name); } } else { jFile::createDir($this->_cache_dir); } if (isset($params['file_locking'])) { $this->_file_locking = $params['file_locking'] ? true : false; } if (isset($params['automatic_cleaning_factor'])) { $this->automatic_cleaning_factor = $params['automatic_cleaning_factor']; } if (isset($params['directory_level']) && $params['directory_level'] > 0) { $this->_directory_level = $params['directory_level']; } if (isset($params['directory_umask']) && is_string($params['directory_umask']) && $params['directory_umask'] != '') { $this->_directory_umask = octdec($params['directory_umask']); } if (isset($params['file_name_prefix'])) { $this->_file_name_prefix = $params['file_name_prefix']; } if (isset($params['cache_file_umask']) && is_string($params['cache_file_umask']) && $params['cache_file_umask'] != '') { $this->_cache_file_umask = octdec($params['cache_file_umask']); } }
/** * create the cache filename * @return string the filename */ private function _getCacheFile() { $module = jContext::get(); $ar = $this->_params; ksort($ar); $id = md5(serialize($ar)); return jApp::tempPath('zonecache/~' . $module . '~' . strtolower(get_class($this)) . '~' . $id . '.php'); }
function testSave() { $parser = new testIniFileModifier(''); $content = ' ; a comment foo=bar job= foo.b-a_r messageLogFormat = "%date%\\t[%code%]\\t%msg%\\t%file%\\t%line%\\n" anumber=98 afloatnumber= 5.098 [aSection] truc= true laurent=toto isvalid = on [othersection] truc=machin2 [vla] foo[]=aaa foo[]=bbb foo[]=ccc '; $result = ' ; a comment foo=bar job=foo.b-a_r messageLogFormat="%date%\\t[%code%]\\t%msg%\\t%file%\\t%line%\\n" anumber=98 afloatnumber=5.098 [aSection] truc=true laurent=toto isvalid=on [othersection] truc=machin2 [vla] foo[]=aaa foo[]=bbb foo[]=ccc '; $parser->testParse($content); $this->assertEqualOrDiff($result, $parser->generate()); file_put_contents(jApp::tempPath() . 'test_jinifilemodifier.html_cli.php', $content); $parser = new testIniFileModifier(jApp::tempPath() . 'test_jinifilemodifier.html_cli.php'); $this->assertEqualOrDiff($result, $parser->generate()); $content = str_replace("\n", "\r", $content); file_put_contents(jApp::tempPath() . 'test_jinifilemodifier.html_cli.php', $content); $parser = new testIniFileModifier(jApp::tempPath() . 'test_jinifilemodifier.html_cli.php'); $this->assertEqualOrDiff($result, $parser->generate()); $content = str_replace("\r", "\r\n", $content); file_put_contents(jApp::tempPath() . 'test_jinifilemodifier.html_cli.php', $content); $parser = new testIniFileModifier(jApp::tempPath() . 'test_jinifilemodifier.html_cli.php'); $this->assertEqualOrDiff($result, $parser->generate()); }
protected function getCachePath() { return jApp::tempPath('compiled/templates/'); }
/** * Build the WSDL cache file path */ private function _createCachePath() { $this->_cachePath = jApp::tempPath('compiled/' . $this->_dirname . '/' . $this->module . '~' . $this->controller . $this->_cacheSuffix); }
/** * returns html formated stack trace * @param array $trace * @return string */ function formatTrace($trace) { $html = '<table>'; foreach ($trace as $k => $t) { if (isset($t['file'])) { $file = $t['file']; $path = ''; $shortcut = ''; if (strpos($file, LIB_PATH) === 0) { $path = LIB_PATH; $shortcut = 'lib:'; } elseif (strpos($file, jApp::tempPath()) === 0) { $path = jApp::tempPath(); $shortcut = 'temp:'; } elseif (strpos($file, jApp::appPath()) === 0) { $path = jApp::appPath(); $shortcut = 'app:'; } else { $path = dirname(jApp::appPath()); $shortcut = 'app:'; while ($path != '.' && $path != '') { $shortcut .= '../'; if (strpos($file, $path) === 0) { break; } $path = dirname($path); } if ($path == '.') { $path = ''; } } if ($path != '') { $cut = $path[0] == '/' ? 0 : 1; $file = '<i>' . $shortcut . '</i>' . substr($file, strlen($path) + $cut); } } else { $file = '[php]'; } $html .= '<tr><td>' . $k . '</td><td>' . (isset($t['class']) ? $t['class'] . $t['type'] : '') . $t['function'] . '()</td>'; $html .= '<td>' . $file . '</td><td>' . (isset($t['line']) ? $t['line'] : '') . '</td></tr>'; } $html .= '</table>'; return $html; }
/** * replace a path with Jelix shortcuts parts (var:, temp:, www: app:, lib:) * * @param string $path the system valid path * @param string $beforeShortcut a string to be output before the Jelix shortcut * @param string $afterShortcut a string to be output after the Jelix shortcut * @return string the path with Jelix shortcuts parts */ public static function unparseJelixPath($path, $beforeShortcut = '', $afterShortcut = '') { $shortcutPath = ''; $shortcut = ''; if (strpos($path, LIB_PATH) === 0) { $shortcutPath = LIB_PATH; $shortcut = 'lib:'; } elseif (strpos($path, jApp::tempPath()) === 0) { $shortcutPath = jApp::tempPath(); $shortcut = 'temp:'; } elseif (strpos($path, jApp::wwwPath()) === 0) { $shortcutPath = jApp::wwwPath(); $shortcut = 'www:'; } elseif (strpos($path, jApp::varPath()) === 0) { $shortcutPath = jApp::varPath(); $shortcut = 'var:'; } elseif (strpos($path, jApp::appPath()) === 0) { $shortcutPath = jApp::appPath(); $shortcut = 'app:'; } else { $shortcutPath = dirname(jApp::appPath()); $shortcut = 'app:'; while ($shortcutPath != '.' && $shortcutPath != '') { $shortcut .= '../'; if (strpos($path, $shortcutPath) === 0) { break; } $shortcutPath = dirname($shortcutPath); } if ($shortcutPath == '.') { $shortcutPath = ''; } } if ($shortcutPath != '') { $cut = $shortcutPath[0] == '/' ? 0 : 1; $path = $beforeShortcut . $shortcut . $afterShortcut . substr($path, strlen($path) + $cut); } return $path; }
/** * */ public function compile($aSelector) { $sourceFile = $aSelector->getPath(); $cachefile = $aSelector->getCompiledFilePath(); $xml = simplexml_load_file($sourceFile); if (!$xml) { return false; } /* <urls> <classicentrypoint name="index" default="true"> <url pathinfo="/test/:mois/:annee" module="" action=""> <param name="mois" escape="true" regexp="\d{4}"/> <param name="annee" escape="false" /> <static name="bla" value="cequejeveux" /> </url> <url handler="" module="" action="" /> </classicentrypoint> </urls> The compiler generates two files. It generates a php file for each entrypoint. A file contains a $PARSE_URL array: $PARSE_URL = array($isDefault, $infoparser, $infoparser, ... ) where: $isDefault: true if it is the default entry point. In this case and where the url parser doesn't find a corresponding action, it will ignore else it will generate an error $infoparser = array('module','action', 'regexp_pathinfo', 'handler selector', array('secondaries','actions'), false // needs https or not ) or $infoparser = array('module','action','regexp_pathinfo', array('year','month'), // list of dynamic value included in the url, // alphabetical ascendant order array(true, false), // list of boolean which indicates for each // dynamic value, if it is an escaped value or not array('bla'=>'whatIWant' ), // list of static values array('secondaries','actions'), false // need https or not ) It generates an other file common to all entry point. It contains an array which contains informations to create urls $CREATE_URL = array( 'news~show@classic' => // the action selector array(0,'entrypoint', https true/false, 'handler selector') or array(1,'entrypoint', https true/false, array('year','month',), // list of dynamic values included in the url array(0, 1..), // list of integer which indicates for each // dynamic value: 0: urlencode, 1:urlencode except '/', 2:escape, 4: lang, 8: locale "/news/%1/%2/", // the url array('bla'=>'whatIWant' ) // list of static values ) or When there are several urls to the same action, it is an array of this kind of the previous array: array(4, array(1,...), array(1,...)...) or array(2,'entrypoint', https true/false), // for the patterns "@request" or array(3,'entrypoint', https true/false), // for the patterns "module~@request" */ $this->createUrlInfos = array(); $this->createUrlContent = "<?php \nif (jApp::config()->compilation['checkCacheFiletime'] &&( \n"; $this->createUrlContent .= "filemtime('" . $sourceFile . '\') > ' . filemtime($sourceFile); $this->createUrlContentInc = ''; $this->readProjectXml(); $this->retrieveModulePaths(jApp::configPath('defaultconfig.ini.php')); // for an app on a simple http server behind an https proxy, we shouldn't check HTTPS $this->checkHttps = jApp::config()->urlengine['checkHttpsOnParsing']; foreach ($xml->children() as $tagname => $tag) { if (!preg_match("/^(.*)entrypoint\$/", $tagname, $m)) { //TODO : error continue; } $type = $m[1]; if ($type == '') { if (isset($tag['type'])) { $type = (string) $tag['type']; } if ($type == '') { $type = 'classic'; } } $this->defaultUrl = new significantUrlInfoParsing($type, (string) $tag['name'], isset($tag['default']) ? (string) $tag['default'] == 'true' : false, isset($tag['https']) ? (string) $tag['https'] == 'true' : false); if (isset($tag['noentrypoint']) && (string) $tag['noentrypoint'] == 'true') { $this->defaultUrl->entryPointUrl = ''; } $optionalTrailingSlash = isset($tag['optionalTrailingSlash']) && $tag['optionalTrailingSlash'] == 'true'; $this->parseInfos = array($this->defaultUrl->isDefault); //let's read the modulesPath of the entry point $this->retrieveModulePaths($this->getEntryPointConfig($this->defaultUrl->entryPoint)); // if this is the default entry point for the request type, // then we add a rule which will match urls which are not // defined. if ($this->defaultUrl->isDefault) { $this->createUrlInfos['@' . $this->defaultUrl->requestType] = array(2, $this->defaultUrl->entryPoint, $this->defaultUrl->isHttps); } $createUrlInfosDedicatedModules = array(); $parseContent = "<?php \n"; foreach ($tag->children() as $tagname => $url) { $u = clone $this->defaultUrl; $u->module = (string) $url['module']; if (isset($url['https'])) { $u->isHttps = (string) $url['https'] == 'true'; } if (isset($url['noentrypoint']) && (string) $url['noentrypoint'] == 'true') { $u->entryPointUrl = ''; } if (isset($url['include'])) { $this->readInclude($url, $u); continue; } // in the case of a non default entry point, if there is just an // <url module="" />, so all actions of this module will be assigned // to this entry point. if (!$u->isDefault && !isset($url['action']) && !isset($url['handler'])) { $this->parseInfos[] = array($u->module, '', '/.*/', array(), array(), array(), false, $this->checkHttps && $u->isHttps); $createUrlInfosDedicatedModules[$u->getFullSel()] = array(3, $u->entryPointUrl, $u->isHttps, true); continue; } $u->action = (string) $url['action']; if (strpos($u->action, ':') === false) { $u->action = 'default:' . $u->action; } if (isset($url['actionoverride'])) { $u->actionOverride = preg_split("/[\\s,]+/", (string) $url['actionoverride']); foreach ($u->actionOverride as &$each) { if (strpos($each, ':') === false) { $each = 'default:' . $each; } } } // if there is an indicated handler, so, for the given module // (and optional action), we should call the given handler to // parse or create an url if (isset($url['handler'])) { $this->newHandler($u, $url); continue; } // parse dynamic parameters if (isset($url['pathinfo'])) { $path = (string) $url['pathinfo']; $regexppath = $this->extractDynamicParams($url, $path, $u); } else { $regexppath = '.*'; $path = ''; } $tempOptionalTrailingSlash = $optionalTrailingSlash; if (isset($url['optionalTrailingSlash'])) { $tempOptionalTrailingSlash = $url['optionalTrailingSlash'] == 'true'; } if ($tempOptionalTrailingSlash) { if (substr($regexppath, -1) == '/') { $regexppath .= '?'; } else { $regexppath .= '\\/?'; } } // parse static parameters foreach ($url->static as $var) { $t = ""; if (isset($var['type'])) { switch ((string) $var['type']) { case 'lang': $t = '$l'; break; case 'locale': $t = '$L'; break; default: throw new Exception('urls definition: invalid type on a <static> element'); } } $u->statics[(string) $var['name']] = $t . (string) $var['value']; } $this->parseInfos[] = array($u->module, $u->action, '!^' . $regexppath . '$!', $u->params, $u->escapes, $u->statics, $u->actionOverride, $this->checkHttps && $u->isHttps); $this->appendUrlInfo($u, $path, false); if ($u->actionOverride) { foreach ($u->actionOverride as $ao) { $u->action = $ao; $this->appendUrlInfo($u, $path, true); } } } $c = count($createUrlInfosDedicatedModules); foreach ($createUrlInfosDedicatedModules as $k => $inf) { if ($c > 1) { $inf[3] = false; } $this->createUrlInfos[$k] = $inf; } $parseContent .= '$GLOBALS[\'SIGNIFICANT_PARSEURL\'][\'' . rawurlencode($this->defaultUrl->entryPoint) . '\'] = ' . var_export($this->parseInfos, true) . ";\n?>"; jFile::write(jApp::tempPath('compiled/urlsig/' . $aSelector->file . '.' . rawurlencode($this->defaultUrl->entryPoint) . '.entrypoint.php'), $parseContent); } $this->createUrlContent .= ")) { return false; } else {\n"; $this->createUrlContent .= $this->createUrlContentInc; $this->createUrlContent .= '$GLOBALS[\'SIGNIFICANT_CREATEURL\'] =' . var_export($this->createUrlInfos, true) . ";\nreturn true;"; $this->createUrlContent .= "\n}\n"; jFile::write(jApp::tempPath('compiled/urlsig/' . $aSelector->file . '.creationinfos_15.php'), $this->createUrlContent); return true; }
static function checkTempPath() { $tempBasePath = jApp::tempBasePath(); // we always clean the temp directory. But first, let's check the temp path (see ticket #840)... if ($tempBasePath == DIRECTORY_SEPARATOR || $tempBasePath == '' || $tempBasePath == '/') { throw new Exception("Error: bad path in jApp::tempBasePath(), it is equals to '" . $tempBasePath . "' !!\n" . " Jelix cannot clear the content of the temp directory.\n" . " Correct the path for the temp directory or create the directory you\n" . " indicated with jApp in your application.init.php.\n"); } jFile::removeDir(jApp::tempPath(), false, array('.svn', '.dummy')); }
/** * Parse urls.xml and return pathinfo URLs * @return array */ protected function _parseUrlsXml() { $urls = array(); $conf =& jApp::config()->urlengine; $significantFile = $conf['significantFile']; $basePath = $conf['basePath']; $epExt = $conf['multiview'] ? '.php' : ''; $file = jApp::tempPath('compiled/urlsig/' . $significantFile . '.creationinfos_15.php'); if (file_exists($file)) { require $file; foreach ($GLOBALS['SIGNIFICANT_CREATEURL'] as $selector => $createinfo) { if ($createinfo[0] != 1 && $createinfo[0] != 4) { continue; } if ($createinfo[0] == 4) { foreach ($createinfo as $k => $createinfo2) { if ($k == 0) { continue; } if ($createinfo2[2] == true || count($createinfo2[3])) { // there are some dynamique parameters, we don't take it this we cannot guesse dynamic parameters continue; } $urls[] = $basePath . ($createinfo2[1] ? $createinfo2[1] . $epExt : '') . $createinfo2[5]; } } else { if ($createinfo[2] == true || count($createinfo[3])) { // there are some dynamique parameters, we don't take it this we cannot guesse dynamic parameters continue; } else { $urls[] = $basePath . ($createinfo[1] ? $createinfo[1] . $epExt : '') . $createinfo[5]; } } } } return $urls; }
function __construct() { $this->cachePath = jApp::tempPath('responseLatexToPdf/'); $this->body = new jTpl(); parent::__construct(); }
protected function _createCachePath() { // don't share the same cache for all the possible dirs // in case of overload removal $this->_cachePath = jApp::tempPath('compiled/daos/' . $this->_where . $this->module . '~' . $this->resource . '~' . $this->driver . '_15' . $this->_cacheSuffix); }
/** * Parse urls.xml and return pathinfo URLs * @return array */ protected function _parseUrlsXml() { global $gJConfig; $urls = array(); $significantFile = $gJConfig->urlengine['significantFile']; $entryPoint = $gJConfig->urlengine['defaultEntrypoint']; $snp = $gJConfig->urlengine['urlScriptIdenc']; $file = jApp::tempPath('compiled/urlsig/' . $significantFile . '.' . rawurlencode($entryPoint) . '.entrypoint.php'); if (file_exists($file)) { require $file; $dataParseUrl = $GLOBALS['SIGNIFICANT_PARSEURL'][$snp]; foreach ($dataParseUrl as $k => $infoparsing) { if ($k == 0) { continue; } // it is not really relevant to get URL that are not complete // but it is difficult to know automatically what are real URLs if (preg_match('/^([^\\(]*)/', substr($infoparsing[2], 2, -2), $matches)) { $urls[] = $matches[1]; } } } return $urls; }
return jApp::wwwPath(); } if (strpos(jApp::wwwPath(), $basepath) === false) { return jApp::wwwPath(); } return substr(jApp::wwwPath(), 0, -strlen($basepath)); } // ============ configuration of Minify if (!isset($min_allowDebugFlag)) { $min_allowDebugFlag = false; } if (!isset($min_errorLogger)) { $min_errorLogger = false; } $min_enableBuilder = false; $min_cachePath = jApp::tempPath('minify/'); if (!file_exists($min_cachePath)) { mkdir($min_cachePath, 0775); } if (!isset($min_documentRoot)) { $min_documentRoot = getDocumentRoot(); } if (!isset($min_cacheFileLocking)) { $min_cacheFileLocking = true; } if (!isset($min_serveOptions['bubbleCssImports'])) { $min_serveOptions['bubbleCssImports'] = false; } if (!isset($min_serveOptions['maxAge'])) { $min_serveOptions['maxAge'] = 1800; }
/** * "Connects" to the fileServer * * @return fileServer object * @access protected */ protected function _connect() { $cnx = new fileServer(jApp::tempPath('filekv')); return $cnx; }
protected function _createCachePath() { // on ne partage pas le même cache pour tous les emplacements possibles // au cas où un overload était supprimé $this->_cachePath = jApp::tempPath('compiled/daos/' . $this->_where . $this->module . '~' . $this->resource . '~' . $this->driver . $this->_cacheSuffix); }
public function getCompiledBuilderFilePath($type) { return jApp::tempPath('compiled/' . $this->_dirname . $this->_where . $this->module . '~' . $this->resource . '_builder_' . $type . $this->_cacheSuffix); }
/** * include a cache file which is the results of the compilation of multiple file sotred in multiple modules * @param array $aType * = array( * 'compilator class name', * 'relative path of the compilator class file to lib/jelix/', * 'foo.xml', // file name to compile (in each modules) * 'foo.php', //cache filename * ); */ public static function incAll($aType) { $cachefile = jApp::tempPath('compiled/' . $aType[3]); if (isset(jIncluder::$_includedFiles[$cachefile])) { return; } $config = jApp::config(); $mustCompile = $config->compilation['force'] || !file_exists($cachefile); if (!$mustCompile && $config->compilation['checkCacheFiletime']) { $compiledate = filemtime($cachefile); foreach ($config->_modulesPathList as $module => $path) { $sourcefile = $path . $aType[2]; if (is_readable($sourcefile)) { if (filemtime($sourcefile) > $compiledate) { $mustCompile = true; break; } } } } if ($mustCompile) { require_once JELIX_LIB_PATH . $aType[1]; $compiler = new $aType[0](); $compileok = true; foreach ($config->_modulesPathList as $module => $path) { $compileok = $compiler->compileItem($path . $aType[2], $module); if (!$compileok) { break; } } if ($compileok) { $compiler->endCompile($cachefile); // the require may load the file content from the // opcode cache if it is existing. // So we must invalidate the file. if (function_exists('opcache_invalidate')) { opcache_invalidate($cachefile, true); } else { if (function_exists('apc_delete_file')) { apc_delete_file($cachefile); } } require $cachefile; jIncluder::$_includedFiles[$cachefile] = true; } } else { require $cachefile; jIncluder::$_includedFiles[$cachefile] = true; } }
protected function _createCachePath() { // don't share the same cache for all the possible dirs // in case of overload removal $this->_cachePath = jApp::tempPath('compiled/templates/' . $this->_where . '_' . $this->outputType . ($this->trusted ? '_t' : '') . '_15' . $this->_cacheSuffix); }
/** * Parse some url components * @param string $scriptNamePath /path/index.php * @param string $pathinfo the path info part of the url (part between script name and query) * @param array $params url parameters (query part e.g. $_REQUEST) * @return jUrlAction */ public function parse($scriptNamePath, $pathinfo, $params) { $conf =& jApp::config()->urlengine; if ($conf['enableParser']) { $sel = new jSelectorUrlCfgSig($conf['significantFile']); jIncluder::inc($sel); $basepath = $conf['basePath']; if (strpos($scriptNamePath, $basepath) === 0) { $snp = substr($scriptNamePath, strlen($basepath)); } else { $snp = $scriptNamePath; } $pos = strrpos($snp, '.php'); if ($pos !== false) { $snp = substr($snp, 0, $pos); } $snp = rawurlencode($snp); $file = jApp::tempPath('compiled/urlsig/' . $sel->file . '.' . $snp . '.entrypoint.php'); if (file_exists($file)) { require $file; $this->dataCreateUrl =& $GLOBALS['SIGNIFICANT_CREATEURL']; // given by jIncluder line 127 $this->dataParseUrl =& $GLOBALS['SIGNIFICANT_PARSEURL'][$snp]; return $this->_parse($scriptNamePath, $pathinfo, $params, false); } } $urlact = new jUrlAction($params); return $urlact; }