diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/auth.php | 4 | ||||
-rw-r--r-- | inc/common.php | 8 | ||||
-rw-r--r-- | inc/init.php | 40 | ||||
-rw-r--r-- | inc/lang/hu/semantic.cache | 15 | ||||
-rw-r--r-- | inc/pageutils.php | 19 | ||||
-rw-r--r-- | inc/parserutils.php | 6 |
6 files changed, 56 insertions, 36 deletions
diff --git a/inc/auth.php b/inc/auth.php index fdf5d17f3..da3d770d1 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -148,7 +148,7 @@ function auth_browseruid(){ * Creates a random key to encrypt the password in cookies * * This function tries to read the password for encrypting - * cookies from $conf['datadir'].'/_cache/_htcookiesalt' + * cookies from $conf['metadir'].'/_htcookiesalt' * if no such file is found a random key is created and * and stored in this file. * @@ -158,7 +158,7 @@ function auth_browseruid(){ */ function auth_cookiesalt(){ global $conf; - $file = $conf['datadir'].'/_cache/_htcookiesalt'; + $file = $conf['metadir'].'/_htcookiesalt'; $salt = io_readFile($file); if(empty($salt)){ $salt = uniqid(rand(),true); diff --git a/inc/common.php b/inc/common.php index 353b306e6..53bb73a13 100644 --- a/inc/common.php +++ b/inc/common.php @@ -593,7 +593,7 @@ function saveWikiText($id,$text,$summary){ //purge cache on add by updating the purgefile if($conf['purgeonadd'] && (!$old || $del)){ - io_saveFile($conf['datadir'].'/_cache/purgefile',time()); + io_saveFile($conf['cachedir'].'/purgefile',time()); } } @@ -809,6 +809,12 @@ function check(){ msg('Mediadir is not writable',-1); } + if(is_writable($conf['cachedir'])){ + msg('Cachedir is writable',1); + }else{ + msg('Cachedir is not writable',-1); + } + if(is_writable(DOKU_INC.'conf/users.auth.php')){ msg('conf/users.auth.php is writable',1); }else{ diff --git a/inc/init.php b/inc/init.php index ba24d7ced..370e308b7 100644 --- a/inc/init.php +++ b/inc/init.php @@ -66,18 +66,8 @@ // remember original umask $conf['oldumask'] = umask(); - // make absolute mediaweb - if(!preg_match('#^(https?://|/)#i',$conf['mediaweb'])){ - $conf['mediaweb'] = getBaseURL().$conf['mediaweb']; - } - // make real paths and check them - $conf['datadir'] = init_path($conf['datadir']); - if(!$conf['datadir']) die('Wrong datadir! Check config!'); - $conf['olddir'] = init_path($conf['olddir']); - if(!$conf['olddir']) die('Wrong olddir! Check config!'); - $conf['mediadir'] = init_path($conf['mediadir']); - if(!$conf['mediadir']) die('Wrong mediadir! Check config!'); + init_paths(); // automatic upgrade to script versions of certain files scriptify(DOKU_INC.'conf/users.auth'); @@ -85,15 +75,37 @@ /** + * Checks paths from config file + */ +function init_paths(){ + global $conf; + + $paths = array('datadir' => 'pages', + 'olddir' => 'attic', + 'mediadir' => 'media', + 'metadir' => 'meta', + 'cachedir' => 'cache', + 'lockdir' => 'locks', + 'changelog' => 'changes.log'); + + foreach($paths as $c => $p){ + + if(!$conf[$c]) $conf[$c] = $conf['savedir'].'/'.$p; + $conf[$c] = init_path($conf[$c]); + if(!$conf[$c]) die("$c does not exist or isn't writable. Check config!"); + } +} + +/** * returns absolute path * - * This tries the given past first, then checks in DOKU_INC + * This tries the given path first, then checks in DOKU_INC */ function init_path($path){ $p = realpath($path); - if(is_dir($p)) return $p; + if(@file_exists($p)) return $p; $p = realpath(DOKU_INC.$path); - if(is_dir($p)) return $p; + if(@file_exists($p)) return $p; return ''; } diff --git a/inc/lang/hu/semantic.cache b/inc/lang/hu/semantic.cache deleted file mode 100644 index 057c8e1b9..000000000 --- a/inc/lang/hu/semantic.cache +++ /dev/null @@ -1,15 +0,0 @@ -;; Object hu/ -;; SEMANTICDB Tags save file -(semanticdb-project-database-file "hu/" - :tables (list - (semanticdb-table "lang.php" - :major-mode 'php-mode - :tags 'nil - :file "lang.php" - :pointmax 4377 - ) - ) - :file "semantic.cache" - :semantic-tag-version "2.0beta3" - :semanticdb-version "2.0beta3" - ) diff --git a/inc/pageutils.php b/inc/pageutils.php index 884df9e96..8477792e0 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -231,4 +231,23 @@ function resolve_pageid($ns,&$page,&$exists){ if(!empty($hash)) $page .= '#'.$hash; } +/** + * Returns the name of a cachefile from given data + * + * The needed directory is created by this function! + * + * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $data This data is used to create a unique md5 name + * @param string $ext This is appended to the filename if given + * @return string The filename of the cachefile + */ +function getCacheName($data,$ext=''){ + global $conf; + $md5 = md5($data); + $file = $conf['cachedir'].'/'.$md5{0}.'/'.$md5.$ext; + io_makeFileDir($file); + return $file; +} + //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/parserutils.php b/inc/parserutils.php index bd5317e1b..9046cfdbe 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -67,8 +67,7 @@ function p_locale_xhtml($id){ */ function p_cached_xhtml($file){ global $conf; - $cache = $conf['datadir'].'/_cache/xhtml/'; - $cache .= md5($file.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT']); + $cache = getCacheName($file.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.xhtml'); $purge = $conf['datadir'].'/_cache/purgefile'; // check if cache can be used @@ -112,8 +111,7 @@ function p_cached_xhtml($file){ */ function p_cached_instructions($file,$cacheonly=false){ global $conf; - $cache = $conf['datadir'].'/_cache/instructions/'; - $cache .= md5($file.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT']); + $cache = getCacheName($file.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.i'); // check if cache can be used $cachetime = @filemtime($cache); // 0 if not exists |