directory cleanup

This cleans up the directory structure as discussed on the mailning
list. Users should delete their previous _cache directories to
recover diskspace.

darcs-hash:20050626100913-9977f-83c0fdc32047db2090fc52a843ffae50cbf12248.gz
This commit is contained in:
andi 2005-06-26 12:09:13 +02:00
parent d477fdcf1c
commit 98407a7ab8
10 changed files with 60 additions and 48 deletions

View File

@ -13,10 +13,7 @@ $conf['umask'] = 0111; //set the umask for new files
$conf['dmask'] = 0000; //directory mask accordingly
$conf['lang'] = 'en'; //your language
$conf['basedir'] = ''; //absolute dir from serveroot - blank for autodetection
$conf['datadir'] = './data/pages'; //where to store the data
$conf['olddir'] = './data/attic'; //where to store old revisions
$conf['mediadir'] = './data/media'; //where to store media files
$conf['changelog'] = './data/changes.log'; //change log
$conf['savedir'] = './data'; //where to store all the files
/* Display Options */

View File

@ -1,2 +0,0 @@
order allow,deny
deny from all

View File

@ -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);

View File

@ -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{

View File

@ -66,34 +66,46 @@
// 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');
scriptify(DOKU_INC.'conf/acl.auth');
/**
* 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 '';
}

View File

@ -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"
)

View File

@ -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 :

View File

@ -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

View File

@ -101,13 +101,12 @@
function get_resized($file, $ext, $w, $h=0){
global $conf;
$md5 = md5($file);
$info = getimagesize($file);
if(!$h) $h = round(($w * $info[1]) / $info[0]);
//cache
$local = $conf['mediadir'].'/_cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext;
$local = getCacheName($file,'.media.'.$w.'x'.$h.'.'.$ext);
$mtime = @filemtime($local); // 0 if not exists
if( $mtime > filemtime($file) || resize_image($ext,$file,$info[0],$info[1],$local,$w,$h) ){
@ -144,9 +143,7 @@ function get_from_URL($url,$ext,$cache){
global $conf;
$url = strtolower($url);
$md5 = md5($url);
$local = $conf['mediadir']."/_cache/$md5.$ext";
$local = getCacheName($url,".media.$ext");
$mtime = @filemtime($local); // 0 if not exists
//decide if download needed:
@ -204,7 +201,7 @@ function resize_image($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){
}
// create cachedir
io_makeFileDir($to);
//io_makeFileDir($to); // not needed anymore, should exist
//try resampling first
if(function_exists("imagecopyresampled")){