diff options
author | andi <andi@splitbrain.org> | 2005-04-14 22:52:19 +0200 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-04-14 22:52:19 +0200 |
commit | 426d8ff4dbde756dd678712847a0fc783edb75ce (patch) | |
tree | f7de0e79805907f652ce2703875265a20165b54a /inc | |
parent | 63ba0b075ea9777ce1a62d1a2c50952cde94859b (diff) | |
download | rpg-426d8ff4dbde756dd678712847a0fc783edb75ce.tar.gz rpg-426d8ff4dbde756dd678712847a0fc783edb75ce.tar.bz2 |
more fetch.php hacking
darcs-hash:20050414205219-9977f-abd598794c5261b12a89d402e481d3425851d2b9.gz
Diffstat (limited to 'inc')
-rw-r--r-- | inc/common.php | 2 | ||||
-rw-r--r-- | inc/utils.php | 36 |
2 files changed, 33 insertions, 5 deletions
diff --git a/inc/common.php b/inc/common.php index 268072cbf..871196dd5 100644 --- a/inc/common.php +++ b/inc/common.php @@ -426,7 +426,7 @@ function mediaFN($id){ global $conf; $id = cleanID($id); $id = str_replace(':','/',$id); - $fn = $conf['datadir'].'/'.utf8_encodeFN($id); + $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); return $fn; } diff --git a/inc/utils.php b/inc/utils.php index 45b9b0d23..6610c217a 100644 --- a/inc/utils.php +++ b/inc/utils.php @@ -9,6 +9,36 @@ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); /** + * Returns the (known) extension of a given filename + * + * returns false if not a known extension + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function media_extension($file){ + $exts = join('|',array_keys(getMimeTypes())); + if(preg_match('#\.('.$exts.')$#i',$file,$matches)){ + return strtolower($matches[1]); + } + + return false; +} + + +/** + * returns a hash of mimetypes + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function getMimeTypes() { + static $mime = NULL; + if ( !$mime ) { + $mime = confToHash(DOKU_INC . 'conf/mime.conf'); + } + return $mime; +} + +/** * returns a hash of acronyms * * @author Harry Fuecks <hfuecks@gmail.com> @@ -68,13 +98,11 @@ function getInterwiki() { function confToHash($file) { $conf = array(); $lines = @file( $file ); - if ( !$lines ) { - return $conf; - } + if ( !$lines ) return $conf; foreach ( $lines as $line ) { //ignore comments - $line = preg_replace('/[^&]#.*$/','',$line); + $line = preg_replace('/[^&]?#.*$/','',$line); $line = trim($line); if(empty($line)) continue; $line = preg_split('/\s+/',$line,2); |