From 56b0b744e40b19048e14cee4ff6caf69858d9fd6 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 18 Feb 2014 13:50:12 +0100 Subject: PHPDocs js.php --- lib/exe/js.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 04413b409..8f16f4a96 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -220,6 +220,12 @@ function js_pluginstrings() { return $pluginstrings; } +/** + * Return an two-dimensional array with strings from the language file of current active template. + * + * - $lang['js'] must be an array. + * - Nothing is returned for template without an entry for $lang['js'] + */ function js_templatestrings() { global $conf; $templatestrings = array(); -- cgit v1.2.3 From 900a9e9e56d360fa7d347304e9b0d4b691d4becc Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 20 Feb 2014 19:25:13 +0100 Subject: replace dir_delete by io_rmdir --- lib/exe/ajax.php | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 6e2011cd9..203af9c5b 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -298,26 +298,6 @@ function ajax_mediaupload(){ echo htmlspecialchars($json->encode($result), ENT_NOQUOTES); } -function dir_delete($path) { - if (!is_string($path) || $path == "") return false; - - if (is_dir($path) && !is_link($path)) { - if (!$dh = @opendir($path)) return false; - - while ($f = readdir($dh)) { - if ($f == '..' || $f == '.') continue; - dir_delete("$path/$f"); - } - - closedir($dh); - return @rmdir($path); - } else { - return @unlink($path); - } - - return false; -} - /** * Return sub index for index view * -- cgit v1.2.3 From 2472a8f6cbd2abffe712ddd42fe2ad296d03d8f2 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 20 Feb 2014 21:42:31 +0100 Subject: Removed unused vars, define undefined ones --- lib/exe/ajax.php | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 6e2011cd9..2cbcece5e 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -41,7 +41,6 @@ if(function_exists($callfn)){ * @author Andreas Gohr */ function ajax_qsearch(){ - global $conf; global $lang; global $INPUT; @@ -89,15 +88,12 @@ function ajax_qsearch(){ * @author Mike Frysinger */ function ajax_suggestions() { - global $conf; - global $lang; global $INPUT; $query = cleanID($INPUT->post->str('q')); if(empty($query)) $query = cleanID($INPUT->get->str('q')); if(empty($query)) return; - $data = array(); $data = ft_pageLookup($query); if(!count($data)) return; $data = array_keys($data); @@ -214,7 +210,6 @@ function ajax_medians(){ * @author Andreas Gohr */ function ajax_medialist(){ - global $conf; global $NS; global $INPUT; @@ -234,13 +229,15 @@ function ajax_medialist(){ * @author Kate Arzamastseva */ function ajax_mediadetails(){ - global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf, $INPUT; + global $IMG, $JUMPTO, $REV, $fullscreen, $INPUT; $fullscreen = true; require_once(DOKU_INC.'lib/exe/mediamanager.php'); + $image = ''; if ($INPUT->has('image')) $image = cleanID($INPUT->str('image')); if (isset($IMG)) $image = $IMG; if (isset($JUMPTO)) $image = $JUMPTO; + $rev = false; if (isset($REV) && !$JUMPTO) $rev = $REV; html_msgarea(); @@ -255,6 +252,7 @@ function ajax_mediadiff(){ global $NS; global $INPUT; + $image = ''; if ($INPUT->has('image')) $image = cleanID($INPUT->str('image')); $NS = $INPUT->post->str('ns'); $auth = auth_quickaclcheck("$NS:*"); @@ -264,6 +262,7 @@ function ajax_mediadiff(){ function ajax_mediaupload(){ global $NS, $MSG, $INPUT; + $id = ''; if ($_FILES['qqfile']['tmp_name']) { $id = $INPUT->post->str('mediaid', $_FILES['qqfile']['name']); } elseif ($INPUT->get->has('qqfile')) { @@ -280,19 +279,28 @@ function ajax_mediaupload(){ if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']); + $res = false; if ($_FILES['qqfile']['tmp_name']) $res = media_upload($NS, $AUTH, $_FILES['qqfile']); 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), '&'), - 'id' => $NS.':'.$id, 'ns' => $NS); - - if (!$result) { + if($res) { + $result = array( + 'success' => true, + 'link' => media_managerURL(array('ns' => $ns, 'image' => $NS . ':' . $id), '&'), + 'id' => $NS . ':' . $id, + 'ns' => $NS + ); + } else { $error = ''; - if (isset($MSG)) { - foreach($MSG as $msg) $error .= $msg['msg']; + if(isset($MSG)) { + foreach($MSG as $msg) { + $error .= $msg['msg']; + } } - $result = array('error' => $msg['msg'], 'ns' => $NS); + $result = array( + 'error' => $error, + 'ns' => $NS + ); } $json = new JSON; echo htmlspecialchars($json->encode($result), ENT_NOQUOTES); @@ -359,13 +367,11 @@ function ajax_linkwiz(){ $id = cleanID($id); $nsd = utf8_encodeFN(str_replace(':','/',$ns)); - $idd = utf8_encodeFN(str_replace(':','/',$id)); $data = array(); if($q && !$ns){ // use index to lookup matching pages - $pages = array(); $pages = ft_pageLookup($id,true); // result contains matches in pages and namespaces -- cgit v1.2.3 From fe5a50c39e9bd837f887ea7ad8335717a6c6ab92 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 5 Mar 2014 19:37:43 +0100 Subject: fix single line comments in CSS compression double slashes in url() always have to be ignored --- lib/exe/css.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index cab7384b2..0a2a5a406 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -552,7 +552,7 @@ function css_compress($css){ $css = preg_replace_callback('#(/\*)(.*?)(\*/)#s','css_comment_cb',$css); //strip (incorrect but common) one line comments - $css = preg_replace('/(? Date: Wed, 5 Mar 2014 20:06:24 +0100 Subject: fixed online comment stripping --- lib/exe/css.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index 0a2a5a406..178895e99 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -611,16 +611,11 @@ function css_onelinecomment_cb($matches) { $out .= substr($line, $i, $len-$i); break; } - if($nexturl === false) { + if($nexturl === false || $nextcom < $nexturl) { // no url anymore, strip comment and be done $out .= substr($line, $i, $nextcom-$i); break; } - if($nextcom < $nexturl) { - // that comment comments out the url - $out .= substr($line, $i, $len-$i); - break; - } // we have an upcoming url $urlclose = strpos($line, ')', $nexturl); $out .= substr($line, $i, $urlclose-$i); -- cgit v1.2.3 From 793c31f2960e132db444a6640c87d4fe5d8df49e Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 5 Mar 2014 21:03:18 +0000 Subject: fix misspelled variable name, --- lib/exe/fetch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 5f82ad0e0..933367e35 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -79,7 +79,7 @@ if (defined('SIMPLE_TEST')) { //handle image resizing/cropping if((substr($MIME, 0, 5) == 'image') && ($WIDTH || $HEIGHT)) { - if($HEIGHT && $WDITH) { + if($HEIGHT && $WIDTH) { $data['file'] = $FILE = media_crop_image($data['file'], $EXT, $WIDTH, $HEIGHT); } else { $data['file'] = $FILE = media_resize_image($data['file'], $EXT, $WIDTH, $HEIGHT); -- cgit v1.2.3 From 0e80bb5e347ff00c6f81627d8e39dafaaa923bc5 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 5 Mar 2014 21:58:46 +0000 Subject: use empty() where array values might not be set --- lib/exe/mediamanager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index d94a24c74..7044232ce 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -57,7 +57,7 @@ } // give info on PHP caught upload errors - if($_FILES['upload']['error']){ + if(!empty($_FILES['upload']['error'])){ switch($_FILES['upload']['error']){ case 1: case 2: @@ -71,7 +71,7 @@ } // handle upload - if($_FILES['upload']['tmp_name']){ + if(!empty($_FILES['upload']['tmp_name'])){ $JUMPTO = media_upload($NS,$AUTH); if($JUMPTO) $NS = getNS($JUMPTO); } -- cgit v1.2.3 From f8fb2d1811251304687b805a60b489f63cb5c4fb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Mar 2014 21:29:33 +0100 Subject: strip sourcemaps in CSS and JS #601 source maps are invalid for our dispatched sources and may even cause problems. this makes sure any sourcemap declarations are stripped from the output --- lib/exe/css.php | 3 +++ lib/exe/js.php | 3 +++ 2 files changed, 6 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index cab7384b2..9ac70905b 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -133,6 +133,9 @@ function css_out(){ $css = ob_get_contents(); ob_end_clean(); + // strip any source maps + stripsourcemaps($css); + // apply style replacements $css = css_applystyle($css, $styleini['replacements']); diff --git a/lib/exe/js.php b/lib/exe/js.php index 8f16f4a96..4d4660197 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -137,6 +137,9 @@ function js_out(){ $js = ob_get_contents(); ob_end_clean(); + // strip any source maps + stripsourcemaps($js); + // compress whitespace and comments if($conf['compress']){ $js = js_compress($js); -- cgit v1.2.3 From 259571aa7559630d429d0046aa56d1089a6eed17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Koutn=C3=BD?= Date: Sun, 16 Mar 2014 10:20:45 +0100 Subject: Fixed cache dependency for template's style.ini Web path was used instead of filesystem one. --- lib/exe/css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index cab7384b2..ab5c03f0e 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -56,7 +56,7 @@ function css_out(){ } // cache influencers - $tplinc = tpl_basedir($tpl); + $tplinc = tpl_incdir($tpl); $cache_files = getConfigFiles('main'); $cache_files[] = $tplinc.'style.ini'; $cache_files[] = $tplinc.'style.local.ini'; // @deprecated -- cgit v1.2.3