diff options
Diffstat (limited to 'lib/exe')
-rw-r--r-- | lib/exe/ajax.php | 71 | ||||
-rw-r--r-- | lib/exe/css.php | 96 | ||||
-rw-r--r-- | lib/exe/detail.php | 1 | ||||
-rw-r--r-- | lib/exe/fetch.php | 8 | ||||
-rw-r--r-- | lib/exe/index.html | 5 | ||||
-rw-r--r-- | lib/exe/indexer.php | 1 | ||||
-rw-r--r-- | lib/exe/js.php | 23 |
7 files changed, 132 insertions, 73 deletions
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 945091f34..9989269cf 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -14,10 +14,10 @@ session_write_close(); header('Content-Type: text/html; charset=utf-8'); //call the requested function -if(isset($_POST['call'])){ - $call = $_POST['call']; -}else if(isset($_GET['call'])){ - $call = $_GET['call']; +if($INPUT->post->has('call')){ + $call = $INPUT->post->str('call'); +}else if($INPUT->get->has('call')){ + $call = $INPUT->get->str('call'); }else{ exit; } @@ -43,9 +43,10 @@ if(function_exists($callfn)){ function ajax_qsearch(){ global $conf; global $lang; + global $INPUT; - $query = $_POST['q']; - if(empty($query)) $query = $_GET['q']; + $query = $INPUT->post->str('q'); + if(empty($query)) $query = $INPUT->get->str('q'); if(empty($query)) return; $query = urldecode($query); @@ -81,9 +82,10 @@ function ajax_qsearch(){ function ajax_suggestions() { global $conf; global $lang; + global $INPUT; - $query = cleanID($_POST['q']); - if(empty($query)) $query = cleanID($_GET['q']); + $query = cleanID($INPUT->post->str('q')); + if(empty($query)) $query = cleanID($INPUT->get->str('q')); if(empty($query)) return; $data = array(); @@ -121,8 +123,9 @@ function ajax_lock(){ global $lang; global $ID; global $INFO; + global $INPUT; - $ID = cleanID($_POST['id']); + $ID = cleanID($INPUT->post->str('id')); if(empty($ID)) return; $INFO = pageinfo(); @@ -137,15 +140,15 @@ function ajax_lock(){ echo 1; } - if($conf['usedraft'] && $_POST['wikitext']){ + if($conf['usedraft'] && $INPUT->post->str('wikitext')){ $client = $_SERVER['REMOTE_USER']; if(!$client) $client = clientIP(true); $draft = array('id' => $ID, - 'prefix' => substr($_POST['prefix'], 0, -1), - 'text' => $_POST['wikitext'], - 'suffix' => $_POST['suffix'], - 'date' => (int) $_POST['date'], + 'prefix' => substr($INPUT->post->str('prefix'), 0, -1), + 'text' => $INPUT->post->str('wikitext'), + 'suffix' => $INPUT->post->str('suffix'), + 'date' => $INPUT->post->int('date'), 'client' => $client, ); $cname = getCacheName($draft['client'].$ID,'.draft'); @@ -162,7 +165,8 @@ function ajax_lock(){ * @author Andreas Gohr <andi@splitbrain.org> */ function ajax_draftdel(){ - $id = cleanID($_REQUEST['id']); + global $INPUT; + $id = cleanID($INPUT->str('id')); if(empty($id)) return; $client = $_SERVER['REMOTE_USER']; @@ -179,9 +183,10 @@ function ajax_draftdel(){ */ function ajax_medians(){ global $conf; + global $INPUT; // wanted namespace - $ns = cleanID($_POST['ns']); + $ns = cleanID($INPUT->post->str('ns')); $dir = utf8_encodeFN(str_replace(':','/',$ns)); $lvl = count(explode(':',$ns)); @@ -202,9 +207,10 @@ function ajax_medians(){ function ajax_medialist(){ global $conf; global $NS; + global $INPUT; - $NS = cleanID($_POST['ns']); - if ($_POST['do'] == 'media') { + $NS = cleanID($INPUT->post->str('ns')); + if ($INPUT->post->str('do') == 'media') { tpl_mediaFileList(); } else { tpl_mediaContent(true); @@ -218,11 +224,11 @@ function ajax_medialist(){ * @author Kate Arzamastseva <pshns@ukr.net> */ function ajax_mediadetails(){ - global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf, $INPUT; $fullscreen = true; require_once(DOKU_INC.'lib/exe/mediamanager.php'); - if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); + if ($INPUT->has('image')) $image = cleanID($INPUT->str('image')); if (isset($IMG)) $image = $IMG; if (isset($JUMPTO)) $image = $JUMPTO; if (isset($REV) && !$JUMPTO) $rev = $REV; @@ -237,25 +243,26 @@ function ajax_mediadetails(){ */ function ajax_mediadiff(){ global $NS; + global $INPUT; - if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); - $NS = $_POST['ns']; - $auth = auth_quickaclcheck("$ns:*"); + if ($INPUT->has('image')) $image = cleanID($INPUT->str('image')); + $NS = $INPUT->post->str('ns'); + $auth = auth_quickaclcheck("$NS:*"); media_diff($image, $NS, $auth, true); } function ajax_mediaupload(){ - global $NS, $MSG; + global $NS, $MSG, $INPUT; if ($_FILES['qqfile']['tmp_name']) { - $id = ((empty($_POST['mediaid'])) ? $_FILES['qqfile']['name'] : $_POST['mediaid']); - } elseif (isset($_GET['qqfile'])) { - $id = $_GET['qqfile']; + $id = $INPUT->post->str('mediaid', $_FILES['qqfile']['name']); + } elseif ($INPUT->get->has('qqfile')) { + $id = $INPUT->get->str('qqfile'); } $id = cleanID($id); - $NS = $_REQUEST['ns']; + $NS = $INPUT->str('ns'); $ns = $NS.':'.getNS($id); $AUTH = auth_quickaclcheck("$ns:*"); @@ -264,7 +271,7 @@ function ajax_mediaupload(){ if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']); if ($_FILES['qqfile']['tmp_name']) $res = media_upload($NS, $AUTH, $_FILES['qqfile']); - if (isset($_GET['qqfile'])) $res = media_upload_xhr($NS, $AUTH); + if ($INPUT->get->has('qqfile')) $res = media_upload_xhr($NS, $AUTH); if ($res) $result = array('success' => true, 'link' => media_managerURL(array('ns' => $ns, 'image' => $NS.':'.$id), '&'), @@ -308,9 +315,10 @@ function dir_delete($path) { */ function ajax_index(){ global $conf; + global $INPUT; // wanted namespace - $ns = cleanID($_POST['idx']); + $ns = cleanID($INPUT->post->str('idx')); $dir = utf8_encodeFN(str_replace(':','/',$ns)); $lvl = count(explode(':',$ns)); @@ -331,8 +339,9 @@ function ajax_index(){ function ajax_linkwiz(){ global $conf; global $lang; + global $INPUT; - $q = ltrim(trim($_POST['q']),':'); + $q = ltrim(trim($INPUT->post->str('q')),':'); $id = noNS($q); $ns = getNS($q); diff --git a/lib/exe/css.php b/lib/exe/css.php index 8de3db11b..1e662c64a 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -49,44 +49,51 @@ function css_out(){ $tpldir = tpl_basedir(); } + // used style.ini file + $styleini = css_styleini($tplinc); + // The generated script depends on some dynamic options $cache = new cache('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tplinc.$type,'.css'); // load template styles $tplstyles = array(); - if(@file_exists($tplinc.'style.ini')){ - $ini = parse_ini_file($tplinc.'style.ini',true); - foreach($ini['stylesheets'] as $file => $mode){ + if ($styleini) { + foreach($styleini['stylesheets'] as $file => $mode) { $tplstyles[$mode][$tplinc.$file] = $tpldir; } } - // start output buffering - ob_start(); + // if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility + if (isset($config_cascade['userstyle']['default'])) { + $config_cascade['userstyle']['screen'] = $config_cascade['userstyle']['default']; + } + + // Array of needed files and their web locations, the latter ones + // are needed to fix relative paths in the stylesheets + $files = array(); + + $cache_files = getConfigFiles('main'); + $cache_files[] = $tplinc.'style.ini'; + $cache_files[] = $tplinc.'style.local.ini'; + $cache_files[] = __FILE__; foreach($mediatypes as $mediatype) { - // Array of needed files and their web locations, the latter ones - // are needed to fix relative paths in the stylesheets - $files = array(); + $files[$mediatype] = array(); // load core styles - $files[DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/'; + $files[$mediatype][DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/'; // load jQuery-UI theme if ($mediatype == 'screen') { - $files[DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/scripts/jquery/jquery-ui-theme/'; + $files[$mediatype][DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/scripts/jquery/jquery-ui-theme/'; } // load plugin styles - $files = array_merge($files, css_pluginstyles($mediatype)); + $files[$mediatype] = array_merge($files[$mediatype], css_pluginstyles($mediatype)); // load template styles if (isset($tplstyles[$mediatype])) { - $files = array_merge($files, $tplstyles[$mediatype]); - } - // if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility - if (isset($config_cascade['userstyle']['default'])) { - $config_cascade['userstyle']['screen'] = $config_cascade['userstyle']['default']; + $files[$mediatype] = array_merge($files[$mediatype], $tplstyles[$mediatype]); } // load user styles if(isset($config_cascade['userstyle'][$mediatype])){ - $files[$config_cascade['userstyle'][$mediatype]] = DOKU_BASE; + $files[$mediatype][$config_cascade['userstyle'][$mediatype]] = DOKU_BASE; } // load rtl styles // note: this adds the rtl styles only to the 'screen' media type @@ -94,30 +101,36 @@ function css_out(){ // please use "[dir=rtl]" in any css file in all, screen or print mode instead if ($mediatype=='screen') { if($lang['direction'] == 'rtl'){ - if (isset($tplstyles['rtl'])) $files = array_merge($files, $tplstyles['rtl']); + if (isset($tplstyles['rtl'])) $files[$mediatype] = array_merge($files[$mediatype], $tplstyles['rtl']); + if (isset($config_cascade['userstyle']['rtl'])) $files[$mediatype][$config_cascade['userstyle']['rtl']] = DOKU_BASE; } } - $cache_files = array_merge(array_keys($files), getConfigFiles('main')); - $cache_files[] = $tplinc.'style.ini'; - $cache_files[] = __FILE__; + $cache_files = array_merge($cache_files, array_keys($files[$mediatype])); + } + + // check cache age & handle conditional request + // This may exit if a cache can be used + http_cached($cache->cache, + $cache->useCache(array('files' => $cache_files))); - // check cache age & handle conditional request - // This may exit if a cache can be used - http_cached($cache->cache, - $cache->useCache(array('files' => $cache_files))); + // start output buffering + ob_start(); - // build the stylesheet + // build the stylesheet + foreach ($mediatypes as $mediatype) { // print the default classes for interwiki links and file downloads if ($mediatype == 'screen') { + print '@media screen {'; css_interwiki(); css_filetypes(); + print '}'; } // load files $css_content = ''; - foreach($files as $file => $location){ + foreach($files[$mediatype] as $file => $location){ $css_content .= css_loadfile($file, $location); } switch ($mediatype) { @@ -165,14 +178,37 @@ function css_out(){ * @author Andreas Gohr <andi@splitbrain.org> */ function css_applystyle($css,$tplinc){ - if(@file_exists($tplinc.'style.ini')){ - $ini = parse_ini_file($tplinc.'style.ini',true); - $css = strtr($css,$ini['replacements']); + $styleini = css_styleini($tplinc); + + if($styleini){ + $css = strtr($css,$styleini['replacements']); } return $css; } /** + * Get contents of merged style.ini and style.local.ini as an array. + * + * @author Anika Henke <anika@selfthinker.org> + */ +function css_styleini($tplinc) { + $styleini = array(); + + foreach (array($tplinc.'style.ini', $tplinc.'style.local.ini') as $ini) { + $tmp = (@file_exists($ini)) ? parse_ini_file($ini, true) : array(); + + foreach($tmp as $key => $value) { + if(array_key_exists($key, $styleini) && is_array($value)) { + $styleini[$key] = array_merge($styleini[$key], $tmp[$key]); + } else { + $styleini[$key] = $value; + } + } + } + return $styleini; +} + +/** * Prints classes for interwikilinks * * Interwiki links have two classes: 'interwiki' and 'iw_$name>' where diff --git a/lib/exe/detail.php b/lib/exe/detail.php index ea46bc037..e597db3a2 100644 --- a/lib/exe/detail.php +++ b/lib/exe/detail.php @@ -2,6 +2,7 @@ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); define('DOKU_MEDIADETAIL',1); require_once(DOKU_INC.'inc/init.php'); +trigger_event('DETAIL_STARTED', $tmp=array()); //close session session_write_close(); diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 60843460e..52e7ebe1e 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -122,9 +122,9 @@ function sendFile($file,$mime,$dl,$cache){ //download or display? if($dl){ - header('Content-Disposition: attachment; filename="'.basename($file).'";'); + header('Content-Disposition: attachment; filename="'.utf8_basename($file).'";'); }else{ - header('Content-Disposition: inline; filename="'.basename($file).'";'); + header('Content-Disposition: inline; filename="'.utf8_basename($file).'";'); } //use x-sendfile header to pass the delivery to compatible webservers @@ -152,12 +152,12 @@ function sendFile($file,$mime,$dl,$cache){ * @returns array(STATUS, STATUSMESSAGE) */ function checkFileStatus(&$media, &$file, $rev='') { - global $MIME, $EXT, $CACHE; + global $MIME, $EXT, $CACHE, $INPUT; //media to local file if(preg_match('#^(https?)://#i',$media)){ //check hash - if(substr(md5(auth_cookiesalt().$media),0,6) != $_REQUEST['hash']){ + if(substr(md5(auth_cookiesalt().$media),0,6) !== $INPUT->str('hash')){ return array( 412, 'Precondition Failed'); } //handle external images diff --git a/lib/exe/index.html b/lib/exe/index.html index d614603ac..977f90e10 100644 --- a/lib/exe/index.html +++ b/lib/exe/index.html @@ -1,6 +1,5 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> +<!DOCTYPE html> +<html> <head> <meta http-equiv="refresh" content="0; URL=../../" /> <meta name="robots" content="noindex" /> diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index e149770c0..1ccede923 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -175,6 +175,7 @@ function sendDigest() { } $subscriptions = subscription_find($ID, array('style' => '(digest|list)', 'escaped' => true)); + /** @var auth_basic $auth */ global $auth; global $lang; global $conf; diff --git a/lib/exe/js.php b/lib/exe/js.php index 7c54f3e2e..42979eeed 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -102,8 +102,12 @@ function js_out(){ // load files foreach($files as $file){ + $ismin = (substr($file,-7) == '.min.js'); + echo "\n\n/* XXXXXXXXXX begin of ".str_replace(DOKU_INC, '', $file) ." XXXXXXXXXX */\n\n"; + if($ismin) echo "\n/* BEGIN NOCOMPRESS */\n"; js_load($file); + if($ismin) echo "\n/* END NOCOMPRESS */\n"; echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n"; } @@ -143,7 +147,7 @@ function js_load($file){ // is it a include_once? if($match[1]){ - $base = basename($ifile); + $base = utf8_basename($ifile); if($loaded[$base]) continue; $loaded[$base] = true; } @@ -262,7 +266,18 @@ function js_compress($s){ if($ch == '/' && $s{$i+1} == '*' && $s{$i+2} != '@'){ $endC = strpos($s,'*/',$i+2); if($endC === false) trigger_error('Found invalid /*..*/ comment', E_USER_ERROR); - $i = $endC + 2; + + // check if this is a NOCOMPRESS comment + if(substr($s, $i, $endC+2-$i) == '/* BEGIN NOCOMPRESS */'){ + $endNC = strpos($s, '/* END NOCOMPRESS */', $endC+2); + if($endNC === false) trigger_error('Found invalid NOCOMPRESS comment', E_USER_ERROR); + + // verbatim copy contents, trimming but putting it on its own line + $result .= "\n".trim(substr($s, $i + 22, $endNC - ($i + 22)))."\n"; // BEGIN comment = 22 chars + $i = $endNC + 20; // END comment = 20 chars + }else{ + $i = $endC + 2; + } continue; } @@ -286,10 +301,8 @@ function js_compress($s){ // now move forward and find the end of it $j = 1; while($s{$i+$j} != '/'){ - while( ($s{$i+$j} != '\\') && ($s{$i+$j} != '/')){ - $j = $j + 1; - } if($s{$i+$j} == '\\') $j = $j + 2; + else $j++; } $result .= substr($s,$i,$j+1); $i = $i + $j + 1; |