From 2d6262c1145c5937afa14d66b5203c84393df679 Mon Sep 17 00:00:00 2001 From: Pierre Spring Date: Fri, 17 Sep 2010 15:13:37 +0200 Subject: loading jQuery and putting it into noConflict mode --- lib/exe/js.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 3756c43b9..c916bf85d 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -34,8 +34,16 @@ function js_out(){ // The generated script depends on some dynamic options $cache = getCacheName('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.js'); + // load jQuery, minified if compression is eanbled. + $jquery_file_path = DOKU_INC.'lib/scripts/jquery/jquery'; + if($conf['compress']) { + $jquery_file_path .= '.min'; + } + $jquery_file_path .= '.js'; + // array of core files $files = array( + $jquery_file_path, DOKU_INC.'lib/scripts/helpers.js', DOKU_INC.'lib/scripts/events.js', DOKU_INC.'lib/scripts/delay.js', -- cgit v1.2.3 From c4bb7947fcb2d4a5e5f8a15d9e3bbec333e44e13 Mon Sep 17 00:00:00 2001 From: Pierre Spring Date: Sun, 10 Oct 2010 23:42:56 +0200 Subject: Got rid of drag.js and added jQuery UI instead. --- lib/exe/js.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index c916bf85d..59d1ded2c 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -44,6 +44,8 @@ function js_out(){ // array of core files $files = array( $jquery_file_path, + DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.core.min.js', + DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.interactions.min.js', DOKU_INC.'lib/scripts/helpers.js', DOKU_INC.'lib/scripts/events.js', DOKU_INC.'lib/scripts/delay.js', @@ -52,7 +54,6 @@ function js_out(){ DOKU_INC.'lib/scripts/tw-sack.js', DOKU_INC.'lib/scripts/ajax.js', DOKU_INC.'lib/scripts/index.js', - DOKU_INC.'lib/scripts/drag.js', DOKU_INC.'lib/scripts/textselection.js', DOKU_INC.'lib/scripts/toolbar.js', DOKU_INC.'lib/scripts/edit.js', -- cgit v1.2.3 From 80997d21e0aee9b8f27153000742ecd781f429f8 Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Sat, 26 Mar 2011 12:46:37 +0100 Subject: locktimer.js is jQueryfied --- lib/exe/js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index f953aae9e..b0b722a2e 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -122,7 +122,7 @@ function js_out(){ js_runonstart("initSizeCtl('size__ctl','wiki__text')"); js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); if($conf['locktime'] != 0){ - js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].")"); + js_runonstart("initLocktimer(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].")"); } js_runonstart('scrollToMarker()'); js_runonstart('focusMarker()'); -- cgit v1.2.3 From fdfb9c6a2877dcbadeab697aad779bea76780965 Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Sat, 26 Mar 2011 15:42:22 +0100 Subject: cookie.js is jQueryfied, added jQuery-cookie-plugin --- lib/exe/js.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index b0b722a2e..d3377fb0b 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -44,6 +44,7 @@ function js_out(){ // array of core files $files = array( $jquery_file_path, + DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.core.min.js', DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.interactions.min.js', DOKU_INC.'lib/scripts/helpers.js', -- cgit v1.2.3 From 11bf24d856a6a4cb606bc6fe10ebcbd844f4127f Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Sun, 27 Mar 2011 13:57:35 +0200 Subject: helpers.js was removed - it basically contained functions they are implemented in jQuery library --- lib/exe/js.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index d3377fb0b..4aa2851c8 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -47,7 +47,6 @@ function js_out(){ DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.core.min.js', DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.interactions.min.js', - DOKU_INC.'lib/scripts/helpers.js', DOKU_INC.'lib/scripts/events.js', DOKU_INC.'lib/scripts/delay.js', DOKU_INC.'lib/scripts/cookie.js', -- cgit v1.2.3 From 2ed49e2ac1bc9ed8a9d514d3ea9515e455768152 Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Mon, 28 Mar 2011 23:09:13 +0200 Subject: JS API is corrected to the original state --- lib/exe/js.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 4aa2851c8..169803658 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -47,6 +47,7 @@ function js_out(){ DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.core.min.js', DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.interactions.min.js', + DOKU_INC.'lib/scripts/helpers.js', DOKU_INC.'lib/scripts/events.js', DOKU_INC.'lib/scripts/delay.js', DOKU_INC.'lib/scripts/cookie.js', @@ -122,7 +123,7 @@ function js_out(){ js_runonstart("initSizeCtl('size__ctl','wiki__text')"); js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); if($conf['locktime'] != 0){ - js_runonstart("initLocktimer(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].")"); + js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].")"); } js_runonstart('scrollToMarker()'); js_runonstart('focusMarker()'); -- cgit v1.2.3 From ff482cae0f5a620704d845037d60ae13ab851410 Mon Sep 17 00:00:00 2001 From: Michal Rezler Date: Wed, 30 Mar 2011 23:08:13 +0200 Subject: fixed import for drag.js and started a rewrite of edit.js --- lib/exe/js.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 169803658..183ae6d4c 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -55,6 +55,7 @@ function js_out(){ DOKU_INC.'lib/scripts/tw-sack.js', DOKU_INC.'lib/scripts/ajax.js', DOKU_INC.'lib/scripts/index.js', + DOKU_INC.'lib/scripts/drag.js', DOKU_INC.'lib/scripts/textselection.js', DOKU_INC.'lib/scripts/toolbar.js', DOKU_INC.'lib/scripts/edit.js', -- cgit v1.2.3 From fc4aefb978d8bb0aba588ef2ae2734619ff75ee5 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 4 Jun 2011 19:16:24 +0300 Subject: fetch.php with rev parameter --- lib/exe/fetch.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 3ad4f1937..143d40f22 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -20,6 +20,10 @@ $CACHE = calc_cache($_REQUEST['cache']); $WIDTH = (int) $_REQUEST['w']; $HEIGHT = (int) $_REQUEST['h']; + $REV = (int) @$_REQUEST['rev']; + //sanitize revision + $REV = preg_replace('/[^0-9]/','',$REV); + list($EXT,$MIME,$DL) = mimetype($MEDIA,false); if($EXT === false){ $EXT = 'unknown'; @@ -28,7 +32,7 @@ } // check for permissions, preconditions and cache external files - list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE); + list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE, $REV); // prepare data for plugin events $data = array('media' => $MEDIA, @@ -147,7 +151,7 @@ function sendFile($file,$mime,$dl,$cache){ * @param $file reference to the file variable * @returns array(STATUS, STATUSMESSAGE) */ -function checkFileStatus(&$media, &$file) { +function checkFileStatus(&$media, &$file, $rev='') { global $MIME, $EXT, $CACHE; //media to local file @@ -172,7 +176,7 @@ function checkFileStatus(&$media, &$file) { if(auth_quickaclcheck(getNS($media).':X') < AUTH_READ){ return array( 403, 'Forbidden' ); } - $file = mediaFN($media); + $file = mediaFN($media, $rev); } //check file existance -- cgit v1.2.3 From 17582ec6bab09e9d9faf53a93d22ecb4fbf2bb47 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 5 Jun 2011 10:21:08 +0200 Subject: Add a newline when loading JavaScript files This avoids problems when the files are concatenated later. --- lib/exe/js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index a3efff700..5ef3b5801 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -185,7 +185,7 @@ function js_load($file){ } $data = str_replace($match[0],$idata,$data); } - echo $data; + echo "$data\n"; } /** -- cgit v1.2.3 From 43576758311bd64506284b15a3a12f153a1c1bc2 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 5 Jun 2011 11:28:43 +0200 Subject: Updated jQuery-UI, added jQuery updater, load theme in CSS dispatcher This patch adds a simple shell script to easily update the jQuery/jQuery-UI+theme bundle to the latest available version. The jQuery-UI CSS theme is now loaded in lib/exe/css.php (before plugin and template styles - 3rd party authors can override the styles). --- lib/exe/css.php | 2 ++ lib/exe/js.php | 13 ++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index 03f900034..e4105b427 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -62,6 +62,8 @@ function css_out(){ $files = array(); // load core styles $files[DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/'; + // load jQuery-UI theme + $files[DOKU_INC.'lib/js/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/js/jquery/jquery-ui-theme/'; // load plugin styles $files = array_merge($files, css_pluginstyles($mediatype)); // load template styles diff --git a/lib/exe/js.php b/lib/exe/js.php index 5ef3b5801..69bc730ac 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -34,19 +34,14 @@ function js_out(){ // The generated script depends on some dynamic options $cache = getCacheName('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.js'); - // load jQuery, minified if compression is eanbled. - $jquery_file_path = DOKU_INC.'lib/scripts/jquery/jquery'; - if($conf['compress']) { - $jquery_file_path .= '.min'; - } - $jquery_file_path .= '.js'; + // load minified version for some files + $min = $conf['compress'] ? '.min' : ''; // array of core files $files = array( - $jquery_file_path, + DOKU_INC."lib/scripts/jquery/jquery$min.js"; DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', - DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.core.min.js', - DOKU_INC.'lib/scripts/jquery-ui/jquery-ui.interactions.min.js', + DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", DOKU_INC.'lib/scripts/helpers.js', DOKU_INC.'lib/scripts/events.js', DOKU_INC.'lib/scripts/delay.js', -- cgit v1.2.3 From 303d4f1470333e1ba613083310ab52b886f3d68c Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 5 Jun 2011 12:15:18 +0200 Subject: fixed typo --- lib/exe/js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 69bc730ac..b0618dc4c 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -39,7 +39,7 @@ function js_out(){ // array of core files $files = array( - DOKU_INC."lib/scripts/jquery/jquery$min.js"; + DOKU_INC."lib/scripts/jquery/jquery$min.js", DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", DOKU_INC.'lib/scripts/helpers.js', -- cgit v1.2.3 From 6992ea08420671362032b795cd2972cfc0ef5f01 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 5 Jun 2011 13:15:56 +0200 Subject: fixed JavaScript compressor for certain regexes This fixes a problem with running the minified jQuery through the compressor. --- lib/exe/js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index b0618dc4c..e4c5c2ab8 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -294,7 +294,7 @@ function js_compress($s){ // items that don't need spaces next to them $chars = "^&|!+\-*\/%=\?:;,{}()<>% \t\n\r'\"[]"; - $regex_starters = array("(", "=", "[", "," , ":"); + $regex_starters = array("(", "=", "[", "," , ":", "!"); $whitespaces_chars = array(" ", "\t", "\n", "\r", "\0", "\x0B"); -- cgit v1.2.3 From d9162c6cd87643d7e7af8e37cd93aa48b8aecb96 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 9 Jun 2011 14:04:50 +0300 Subject: fullscreen media manager --- lib/exe/mediamanager.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 02fde5a8d..d4ebc2d38 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -76,7 +76,11 @@ } // handle meta saving - if($IMG && $_REQUEST['do']['save']){ + if($IMG && @array_key_exists('save', $_REQUEST['do'])){ + $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); + } + + if($IMG && @array_key_exists('save', $_REQUEST['mediado'])){ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } @@ -102,9 +106,11 @@ msg(sprintf($lang['deletefail'],noNS($DEL)),-1); } } - // finished - start output - header('Content-Type: text/html; charset=utf-8'); - include(template('mediamanager.php')); + + if (!($_REQUEST['do'] == 'media')) { + header('Content-Type: text/html; charset=utf-8'); + include(template('mediamanager.php')); + } /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ -- cgit v1.2.3 From 17e2e2545f2fd3607a14238ecee25eb7a605ce84 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 10 Jun 2011 20:26:04 +0200 Subject: Moved behavioural functions into it's own object and file JavaScript functions adding behaviours based on IDs or class names where moved to their own object into behaviour.js and where jQueryized. --- lib/exe/js.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index e4c5c2ab8..0d4a08ebd 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -60,6 +60,7 @@ function js_out(){ DOKU_INC.'lib/scripts/subscriptions.js', # disabled for FS#1958 DOKU_INC.'lib/scripts/hotkeys.js', DOKU_TPLINC.'script.js', + DOKU_INC.'lib/scripts/behaviour.js', ); // add possible plugin scripts and userscript @@ -121,8 +122,6 @@ function js_out(){ if($conf['locktime'] != 0){ js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].", 'wiki__text')"); } - js_runonstart('scrollToMarker()'); - js_runonstart('focusMarker()'); // init hotkeys - must have been done after init of toolbar # disabled for FS#1958 js_runonstart('initializeHotkeys()'); -- cgit v1.2.3 From 809d3ba53bea8b34155cb8d009d7fa4b8a7bbdaf Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 17 Jun 2011 00:20:48 +0200 Subject: Use data uris for small image files in CSS This patch adds a new config option 'cssdatauri'. When enabled, the CSS patcher will automatically convert all occurances of small (<600 byte) PNG and GIF images in the CSS to embedded, base64 encoded data uris. This reduces the number of needed HTTP requests and avoids the HTTP header overhead. --- lib/exe/css.php | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index e4105b427..02ed169c4 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -135,6 +135,12 @@ function css_out(){ $css = css_compress($css); } + // embed small images right into the stylesheet + if($conf['cssdatauri']){ + $base = preg_quote(DOKU_BASE,'#'); + $css = preg_replace_callback('#(url\([ \'"]*)('.$base.')(.*?(?:\.(png|gif)))#i','css_datauri',$css); + } + // save cache file io_saveFile($cache,$css); if(function_exists('gzopen')) io_saveFile("$cache.gz",$css); @@ -271,11 +277,36 @@ function css_loadfile($file,$location=''){ $css = io_readFile($file); if(!$location) return $css; - $css = preg_replace('#(url\([ \'"]*)(?!/|http://|https://| |\'|")#','\\1'.$location,$css); - $css = preg_replace('#(@import\s+[\'"])(?!/|http://|https://)#', '\\1'.$location, $css); + $css = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$css); + $css = preg_replace('#(@import\s+[\'"])(?!/|data:|http://|https://)#', '\\1'.$location, $css); + return $css; } +/** + * Converte local image URLs to data URLs if the filesize is small + * + * Callback for preg_replace_callback + */ +function css_datauri($match){ + $pre = unslash($match[1]); + $base = unslash($match[2]); + $url = unslash($match[3]); + $ext = unslash($match[4]); + + $local = DOKU_INC.$url; + $size = @filesize($local); + if($size && $size < 600){ + $data = base64_encode(file_get_contents($local)); + } + if($data){ + $url = 'data:image/'.$ext.';base64,'.$data; + }else{ + $url = $base.$url; + } + return $pre.$url; +} + /** * Returns a list of possible Plugin Styles (no existance check here) -- cgit v1.2.3 From 28f4004c937cfc11f16e6cc7c0eb7da1a61dfcbe Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 18 Jun 2011 10:16:47 +0200 Subject: Made the maximum embed size for datauris configurable The feature is now disabled by default. Metadata for config manager was added. --- lib/exe/css.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index 02ed169c4..92d198e19 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -289,6 +289,8 @@ function css_loadfile($file,$location=''){ * Callback for preg_replace_callback */ function css_datauri($match){ + global $conf; + $pre = unslash($match[1]); $base = unslash($match[2]); $url = unslash($match[3]); @@ -296,7 +298,7 @@ function css_datauri($match){ $local = DOKU_INC.$url; $size = @filesize($local); - if($size && $size < 600){ + if($size && $size < $conf['cssdatauri']){ $data = base64_encode(file_get_contents($local)); } if($data){ -- cgit v1.2.3 From cd06d16faa924afeb14f864b058e01ce8867057c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 21 Jun 2011 13:30:18 +0200 Subject: Fix index Javascript, introduce compatibility.js * Removed "use strict" statement, since it does not work with our script file joining (the statement has to be the first in a file or function) * Make index a global object again to allow overriding and enhancing * Use prefix dw_ for index object * Reintroduce index.treeattach * Support deprecated index.toggle calling convention * Add $ prefix for jQuery variables * Use slide animation for freshly loaded sublists as well * Fix various errors --- lib/exe/js.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 0d4a08ebd..25dc8496a 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -58,6 +58,7 @@ function js_out(){ DOKU_INC.'lib/scripts/linkwiz.js', DOKU_INC.'lib/scripts/media.js', DOKU_INC.'lib/scripts/subscriptions.js', + DOKU_INC.'lib/scripts/compatibility.js', # disabled for FS#1958 DOKU_INC.'lib/scripts/hotkeys.js', DOKU_TPLINC.'script.js', DOKU_INC.'lib/scripts/behaviour.js', -- cgit v1.2.3 From 88a71175e3de9e3ad8b20ca9eb710aaf773cb788 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 23 Jun 2011 14:16:15 +0300 Subject: media manager auth fix --- 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 d4ebc2d38..24dd5f911 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -35,7 +35,7 @@ $AUTH = auth_quickaclcheck("$NS:*"); // do not display the manager if user does not have read access - if($AUTH < AUTH_READ) { + if($AUTH < AUTH_READ && !$fullscreen) { header('HTTP/1.0 403 Forbidden'); die($lang['accessdenied']); } @@ -108,7 +108,7 @@ } // finished - start output - if (!($_REQUEST['do'] == 'media')) { + if (!$fullscreen) { header('Content-Type: text/html; charset=utf-8'); include(template('mediamanager.php')); } -- cgit v1.2.3 From c949174a2e8c324e3e463a9d10e9e6dc07b0ba9e Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 22 Jun 2011 21:05:17 +0200 Subject: Fix and refactor ajax.js * Move file to qsearch.js * Rename object to dw_qsearch * Remove unnecessary usage of Delay * Use $ prefix for jQuery objects * Fix result list hiding on click * Fix namespace shorting --- lib/exe/js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 25dc8496a..28894ffc6 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -48,7 +48,7 @@ function js_out(){ DOKU_INC.'lib/scripts/cookie.js', DOKU_INC.'lib/scripts/script.js', DOKU_INC.'lib/scripts/tw-sack.js', - DOKU_INC.'lib/scripts/ajax.js', + DOKU_INC.'lib/scripts/qsearch.js', DOKU_INC.'lib/scripts/index.js', DOKU_INC.'lib/scripts/drag.js', DOKU_INC.'lib/scripts/textselection.js', -- cgit v1.2.3 From 9c1bd4bc9aa4b9ac3b9981543a14508091cd639a Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 30 Jun 2011 19:44:31 +0300 Subject: restoring old media revisions --- lib/exe/mediamanager.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 24dd5f911..46257a9a7 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -84,6 +84,12 @@ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } + if ($_REQUEST['rev']) $REV = (int) $_REQUEST['rev']; + + if($_REQUEST['mediado'] == 'restore'){ + $JUMPTO = media_restore($_REQUEST['image'], $REV, $AUTH); + } + // handle deletion if($DEL) { $res = 0; -- cgit v1.2.3 From 6619f42eb475ad91a0b73d1aa6268ff41c6129a2 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 1 Jul 2011 16:49:28 +0200 Subject: Refactor CSS and JS caching * Increase HTTP cache time since the resources are timestamped on request anyway * Check userscript.js only once for JS cache validation * Use cache class --- lib/exe/css.php | 68 ++++++++------------------------------------------------- lib/exe/js.php | 67 ++++++++------------------------------------------------ 2 files changed, 18 insertions(+), 117 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index e4105b427..9751b5be4 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -46,7 +46,7 @@ function css_out(){ } // The generated script depends on some dynamic options - $cache = getCacheName('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tplinc.$mediatype,'.css'); + $cache = new cache('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tplinc.$mediatype,'.css'); // load template styles $tplstyles = array(); @@ -87,26 +87,14 @@ function css_out(){ } } - // check cache age & handle conditional request - header('Cache-Control: public, max-age=3600'); - header('Pragma: public'); - if(css_cacheok($cache,array_keys($files),$tplinc)){ - http_conditionalRequest(filemtime($cache)); - if($conf['allowdebug']) header("X-CacheUsed: $cache"); - - // finally send output - if ($conf['gzip_output'] && http_gzip_valid($cache)) { - header('Vary: Accept-Encoding'); - header('Content-Encoding: gzip'); - readfile($cache.".gz"); - } else { - if (!http_sendfile($cache)) readfile($cache); - } + $cache_files = array_merge(array_keys($files), getConfigFiles('main')); + $cache_files[] = $tplinc.'style.ini'; + $cache_files[] = __FILE__; - return; - } else { - http_conditionalRequest(time()); - } + // 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 and build the stylesheet ob_start(); @@ -135,45 +123,7 @@ function css_out(){ $css = css_compress($css); } - // save cache file - io_saveFile($cache,$css); - if(function_exists('gzopen')) io_saveFile("$cache.gz",$css); - - // finally send output - if ($conf['gzip_output']) { - header('Vary: Accept-Encoding'); - header('Content-Encoding: gzip'); - print gzencode($css,9,FORCE_GZIP); - } else { - print $css; - } -} - -/** - * Checks if a CSS Cache file still is valid - * - * @author Andreas Gohr - */ -function css_cacheok($cache,$files,$tplinc){ - global $config_cascade; - - if(isset($_REQUEST['purge'])) return false; //support purge request - - $ctime = @filemtime($cache); - if(!$ctime) return false; //There is no cache - - // some additional files to check - $files = array_merge($files, getConfigFiles('main')); - $files[] = $tplinc.'style.ini'; - $files[] = __FILE__; - - // now walk the files - foreach($files as $file){ - if(@filemtime($file) > $ctime){ - return false; - } - } - return true; + http_cached_finish($cache->cache, $css); } /** diff --git a/lib/exe/js.php b/lib/exe/js.php index 28894ffc6..0688825c6 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -32,7 +32,8 @@ function js_out(){ global $config_cascade; // The generated script depends on some dynamic options - $cache = getCacheName('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.js'); + $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'], + '.js'); // load minified version for some files $min = $conf['compress'] ? '.min' : ''; @@ -70,25 +71,13 @@ function js_out(){ $files[] = $config_cascade['userscript']['default']; } + $cache_files = array_merge($files, getConfigFiles('main')); + $cache_files[] = __FILE__; + // check cache age & handle conditional request - header('Cache-Control: public, max-age=3600'); - header('Pragma: public'); - if(js_cacheok($cache,$files)){ - http_conditionalRequest(filemtime($cache)); - if($conf['allowdebug']) header("X-CacheUsed: $cache"); - - // finally send output - if ($conf['gzip_output'] && http_gzip_valid($cache)) { - header('Vary: Accept-Encoding'); - header('Content-Encoding: gzip'); - readfile($cache.".gz"); - } else { - if (!http_sendfile($cache)) readfile($cache); - } - return; - } else { - http_conditionalRequest(time()); - } + // This may exit if a cache can be used + http_cached($cache->cache, + $cache->useCache(array('files' => $cache_files))); // start output buffering and build the script ob_start(); @@ -137,18 +126,7 @@ function js_out(){ $js .= "\n"; // https://bugzilla.mozilla.org/show_bug.cgi?id=316033 - // save cache file - io_saveFile($cache,$js); - if(function_exists('gzopen')) io_saveFile("$cache.gz",$js); - - // finally send output - if ($conf['gzip_output']) { - header('Vary: Accept-Encoding'); - header('Content-Encoding: gzip'); - print gzencode($js,9,FORCE_GZIP); - } else { - print $js; - } + http_cached_finish($cache->cache, $js); } /** @@ -183,33 +161,6 @@ function js_load($file){ echo "$data\n"; } -/** - * Checks if a JavaScript Cache file still is valid - * - * @author Andreas Gohr - */ -function js_cacheok($cache,$files){ - if(isset($_REQUEST['purge'])) return false; //support purge request - - $ctime = @filemtime($cache); - if(!$ctime) return false; //There is no cache - - global $config_cascade; - - // some additional files to check - $files = array_merge($files, getConfigFiles('main')); - $files[] = $config_cascade['userscript']['default']; - $files[] = __FILE__; - - // now walk the files - foreach($files as $file){ - if(@filemtime($file) > $ctime){ - return false; - } - } - return true; -} - /** * Returns a list of possible Plugin Scripts (no existance check here) * -- cgit v1.2.3 From 23846a98488bec2aaade6d983b4c0b0db13af80c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 3 Jul 2011 19:00:54 +0300 Subject: ajax mediamanager --- lib/exe/ajax.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 1056a05f8..16efd9ac7 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -210,7 +210,30 @@ function ajax_medialist(){ global $NS; $NS = $_POST['ns']; - tpl_mediaContent(true); + if ($_POST['do'] == 'media') { + tpl_fileList(true); + } else { + tpl_mediaContent(true); + } +} + +/** + * Return the content of the right column + * (image details) for the Mediamanager + * + * @author Kate Arzamastseva + */ +function ajax_mediadetails(){ + global $conf; + global $NS; + + $NS = $_POST['ns']; + $image = $_POST['image']; + if (isset($_POST['full'])) { + tpl_fileDetails($image, false); + } else { + tpl_fileDetails($image, false, true); + } } /** -- cgit v1.2.3 From ed69a2ae06c0707fdd5634e18d569c25f0cda6d5 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 3 Jul 2011 23:56:26 +0300 Subject: ajax mediamanager fix --- lib/exe/ajax.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 16efd9ac7..8ff0f8eda 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -211,7 +211,7 @@ function ajax_medialist(){ $NS = $_POST['ns']; if ($_POST['do'] == 'media') { - tpl_fileList(true); + tpl_fileList(); } else { tpl_mediaContent(true); } @@ -229,11 +229,7 @@ function ajax_mediadetails(){ $NS = $_POST['ns']; $image = $_POST['image']; - if (isset($_POST['full'])) { - tpl_fileDetails($image, false); - } else { - tpl_fileDetails($image, false, true); - } + tpl_fileDetails($image, false); } /** -- cgit v1.2.3 From 7d7ab775ac0252d50835987b276a95b790cd1434 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 4 Jul 2011 22:35:44 +0300 Subject: mediamanager ajax forms --- lib/exe/ajax.php | 15 ++++++++++----- lib/exe/mediamanager.php | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 8ff0f8eda..59953ddc3 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -224,12 +224,17 @@ function ajax_medialist(){ * @author Kate Arzamastseva */ function ajax_mediadetails(){ - global $conf; - global $NS; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen; + $fullscreen = true; + require_once(DOKU_INC.'lib/exe/mediamanager.php'); - $NS = $_POST['ns']; - $image = $_POST['image']; - tpl_fileDetails($image, false); + if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); + if (isset($IMG)) $image = $IMG; + if (isset($JUMPTO)) $image = $JUMPTO; + if (isset($REV) && !$JUMPTO) $rev = $REV; + + html_msgarea(); + tpl_fileDetails($image, $rev); } /** diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 46257a9a7..77eb2facb 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -80,7 +80,7 @@ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } - if($IMG && @array_key_exists('save', $_REQUEST['mediado'])){ + if($IMG && $_REQUEST['mediado'] == 'save') { $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } @@ -98,7 +98,7 @@ } if ($res & DOKU_MEDIA_DELETED) { $msg = sprintf($lang['deletesucc'], noNS($DEL)); - if ($res & DOKU_MEDIA_EMPTY_NS) { + if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) { // current namespace was removed. redirecting to root ns passing msg along send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='. rawurlencode($msg).'&edid='.$_REQUEST['edid']); -- cgit v1.2.3 From f46c377bfc514cbaac6dda38078587088ab3f200 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 5 Jul 2011 21:38:31 +0200 Subject: fixed loading of the jQuery-UI style sheet --- 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 9751b5be4..ece8affb7 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -63,7 +63,7 @@ function css_out(){ // load core styles $files[DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/'; // load jQuery-UI theme - $files[DOKU_INC.'lib/js/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/js/jquery/jquery-ui-theme/'; + $files[DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/js/jquery/jquery-ui-theme/'; // load plugin styles $files = array_merge($files, css_pluginstyles($mediatype)); // load template styles -- cgit v1.2.3 From bf1ec6525db0b131d051d4e0023afb87e36f584b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 5 Jul 2011 21:48:37 +0200 Subject: another fix for the jQuery-UI theme --- 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 ece8affb7..03fe6ad90 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -63,7 +63,7 @@ function css_out(){ // load core styles $files[DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/'; // load jQuery-UI theme - $files[DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/js/jquery/jquery-ui-theme/'; + $files[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)); // load template styles -- cgit v1.2.3 From ddf8a04fe3281e871c5311235b08185a5ceab797 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 8 Jul 2011 12:20:02 +0200 Subject: moved some editor functions to a new dw_editor object There are probably more functions that should go in here --- lib/exe/js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 0688825c6..720e34577 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -55,6 +55,7 @@ function js_out(){ DOKU_INC.'lib/scripts/textselection.js', DOKU_INC.'lib/scripts/toolbar.js', DOKU_INC.'lib/scripts/edit.js', + DOKU_INC.'lib/scripts/editor.js', DOKU_INC.'lib/scripts/locktimer.js', DOKU_INC.'lib/scripts/linkwiz.js', DOKU_INC.'lib/scripts/media.js', @@ -107,7 +108,6 @@ function js_out(){ // init stuff js_runonstart("addEvent(document,'click',closePopups)"); js_runonstart('addTocToggle()'); - js_runonstart("initSizeCtl('size__ctl','wiki__text')"); js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); if($conf['locktime'] != 0){ js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].", 'wiki__text')"); -- cgit v1.2.3 From 6183fb05112cd318d9a6885d9405cff9917ee82f Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 8 Jul 2011 13:54:15 +0300 Subject: mediamanager fix --- lib/exe/mediamanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 77eb2facb..939b5a053 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -80,7 +80,7 @@ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } - if($IMG && $_REQUEST['mediado'] == 'save') { + if($IMG && ($_REQUEST['mediado'] == 'save' || @array_key_exists('save', $_REQUEST['mediado']))) { $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } -- cgit v1.2.3 From 32cb905a0339607a7acfef6488bec0015bae6b8b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 8 Jul 2011 13:04:59 +0200 Subject: moved the TOC toggling to dw_behaviour --- lib/exe/js.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 720e34577..308c1b534 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -107,7 +107,6 @@ function js_out(){ // init stuff js_runonstart("addEvent(document,'click',closePopups)"); - js_runonstart('addTocToggle()'); js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); if($conf['locktime'] != 0){ js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].", 'wiki__text')"); -- cgit v1.2.3 From d10c9a7424d1ef0aace2fd34e1008196d111a88c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 7 Jul 2011 16:08:05 +0200 Subject: Rewrite mediamanager JavaScript Make it faster, prettier, less wrong, add UI effects, use jQuery UI Dialog, Abstract tree view stuff away into jQuery.dw_tree --- lib/exe/js.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 308c1b534..44ab2d5ca 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -50,6 +50,7 @@ function js_out(){ DOKU_INC.'lib/scripts/script.js', DOKU_INC.'lib/scripts/tw-sack.js', DOKU_INC.'lib/scripts/qsearch.js', + DOKU_INC.'lib/scripts/tree.js', DOKU_INC.'lib/scripts/index.js', DOKU_INC.'lib/scripts/drag.js', DOKU_INC.'lib/scripts/textselection.js', -- cgit v1.2.3 From 992ded5a7e2cbd2c8092ded03d035d0cbeade327 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 10 Jul 2011 13:14:07 +0200 Subject: make use of auth_isMember() in XMLRPC authentication check FS#2287 --- lib/exe/xmlrpc.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 108dd8fd1..8b572d213 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -30,26 +30,9 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { global $USERINFO; if(!$conf['useacl']) return true; //no ACL - then no checks + if(trim($conf['xmlrpcuser']) == '') return true; //no restrictions - $allowed = explode(',',$conf['xmlrpcuser']); - $allowed = array_map('trim', $allowed); - $allowed = array_unique($allowed); - $allowed = array_filter($allowed); - - if(!count($allowed)) return true; //no restrictions - - $user = $_SERVER['REMOTE_USER']; - $groups = (array) $USERINFO['grps']; - - if(in_array($user,$allowed)) return true; //user explicitly mentioned - - //check group memberships - foreach($groups as $group){ - if(in_array('@'.$group,$allowed)) return true; - } - - //still here? no access! - return false; + return auth_isMember($conf['xmlrpcuser'],$_SERVER['REMOTE_USER'],(array) $USERINFO['grps']); } /** -- cgit v1.2.3 From a1dee2b998bc3dc8436bb076435d405ec412e054 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 11 Jul 2011 22:17:27 +0200 Subject: Fix some bugs and glitches in (mediamanager) tree * Fix selector in subtree loading callback * Remove HTML inconsistencies between AJAX and plain PHP lists * Unify icon and CSS class switching in dw_tree and dw_mediamanager --- lib/exe/ajax.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 1056a05f8..2bfa3680c 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -192,12 +192,10 @@ function ajax_medians(){ $data = array(); search($data,$conf['mediadir'],'search_index',array('nofiles' => true),$dir); - foreach($data as $item){ - $item['level'] = $lvl+1; - echo media_nstree_li($item); - echo media_nstree_item($item); - echo ''; + foreach(array_keys($data) as $item){ + $data[$item]['level'] = $lvl+1; } + echo html_buildlist($data, 'idx', 'media_nstree_item', 'media_nstree_li'); } /** @@ -229,14 +227,10 @@ function ajax_index(){ $data = array(); search($data,$conf['datadir'],'search_index',array('ns' => $ns),$dir); - foreach($data as $item){ - $item['level'] = $lvl+1; - echo html_li_index($item); - echo '
'; - echo html_list_index($item); - echo '
'; - echo ''; + foreach(array_keys($data) as $item){ + $data[$item]['level'] = $lvl+1; } + echo html_buildlist($data, 'idx', 'html_list_index', 'html_li_index'); } /** -- cgit v1.2.3 From 4ee1558545059fa73700709a9ef4c0ab22ce8f92 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Tue, 26 Jul 2011 11:55:38 +0300 Subject: image diffs fixes --- lib/exe/ajax.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 483d65cff..300fb8acb 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -235,6 +235,19 @@ function ajax_mediadetails(){ tpl_fileDetails($image, $rev); } +/** + * Returns image diff representation for mediamanager + * @author Kate Arzamastseva + */ +function ajax_mediadiff(){ + global $NS; + + if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); + $NS = $_POST['ns']; + $auth = auth_quickaclcheck("$ns:*"); + media_diff($image, $NS, $auth); +} + /** * Return sub index for index view * -- cgit v1.2.3 From e5d185e17e613b7a9737fc76310f1e78008f71ec Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Tue, 2 Aug 2011 20:25:17 +0300 Subject: issue #9 config option to disable media revisions, auth --- 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 939b5a053..5f09fe1f8 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -84,9 +84,9 @@ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } - if ($_REQUEST['rev']) $REV = (int) $_REQUEST['rev']; + if ($_REQUEST['rev'] && $conf['mediarevisions']) $REV = (int) $_REQUEST['rev']; - if($_REQUEST['mediado'] == 'restore'){ + if($_REQUEST['mediado'] == 'restore' && $conf['mediarevisions']){ $JUMPTO = media_restore($_REQUEST['image'], $REV, $AUTH); } -- cgit v1.2.3 From 92cac9a97ee63d9c3c9bb8b0da1e3eb0604ba04f Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 3 Aug 2011 15:19:52 +0300 Subject: issue #38 diff links only if diff available; deleted files --- lib/exe/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 300fb8acb..20fc99de4 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -222,7 +222,7 @@ function ajax_medialist(){ * @author Kate Arzamastseva */ function ajax_mediadetails(){ - global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf; $fullscreen = true; require_once(DOKU_INC.'lib/exe/mediamanager.php'); -- cgit v1.2.3 From 09063cc66339d6e5daa12af4896a2457c03cfaf3 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 4 Aug 2011 20:32:16 +0300 Subject: issue #44 multi file uploader --- lib/exe/ajax.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/exe/js.php | 1 + 2 files changed, 83 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 20fc99de4..391e951e5 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -248,6 +248,88 @@ function ajax_mediadiff(){ media_diff($image, $NS, $auth); } +function ajax_mediaupload(){ + global $NS; + $NS = $_REQUEST['ns']; + $AUTH = auth_quickaclcheck("$NS:*"); + if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } + + if($_FILES['qqfile']['error']){ + unset($_FILES['qqfile']); + } + + if($_FILES['qqfile']['tmp_name']){ + $id = $_FILES['qqfile']['name']; + $file = $_FILES['qqfile']['tmp_name']; + list($ext,$mime,$dl) = mimetype($id); + + $res = media_save( + array('name' => $file, + 'mime' => $mime, + 'ext' => $ext), + $NS.':'.$id, + false, + $AUTH, + 'move_uploaded_file' + ); + if (!is_array($res)) { + $result = array('success'=>true); + } + } + + if (isset($_GET['qqfile'])) { + $id = $_GET['qqfile']; + list($ext,$mime,$dl) = mimetype($id); + $input = fopen("php://input", "r"); + $temp = tmpfile(); + $realSize = stream_copy_to_stream($input, $temp); + fclose($input); + if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]) return false; + if (!($tmp = io_mktmpdir())) return false; + $path = $tmp.'/'.$id; + $target = fopen($path, "w"); + fseek($temp, 0, SEEK_SET); + stream_copy_to_stream($temp, $target); + fclose($target); + $res = media_save( + array('name' => $path, + 'mime' => $mime, + 'ext' => $ext), + $NS.':'.$id, + false, + $AUTH, + 'copy' + ); + unlink($path); + if ($tmp) dir_delete($tmp); + if (!is_array($res)) { + $result = array('success'=>true); + } + } + if (!$result) $result = array('error'=> 'Could not save uploaded file.'); + 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 * diff --git a/lib/exe/js.php b/lib/exe/js.php index 44ab2d5ca..fd8b74947 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -43,6 +43,7 @@ function js_out(){ DOKU_INC."lib/scripts/jquery/jquery$min.js", DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", + DOKU_INC."lib/scripts/fileuploader.js", DOKU_INC.'lib/scripts/helpers.js', DOKU_INC.'lib/scripts/events.js', DOKU_INC.'lib/scripts/delay.js', -- cgit v1.2.3 From 8d7448594cb00e995bed9b6e6db6e7f9280da24d Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 7 Aug 2011 13:54:36 +0300 Subject: issue #44 fileuploader specific changes made in inheriting class --- lib/exe/js.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index fd8b74947..1ca4fef98 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -44,6 +44,7 @@ function js_out(){ DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", DOKU_INC."lib/scripts/fileuploader.js", + DOKU_INC."lib/scripts/fileuploaderextended.js", DOKU_INC.'lib/scripts/helpers.js', DOKU_INC.'lib/scripts/events.js', DOKU_INC.'lib/scripts/delay.js', -- cgit v1.2.3 From 6bdff0836f4bc1eee19aa8c30d03ba4bfc876733 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 8 Aug 2011 19:37:09 +0300 Subject: issue #44 overwrite checkbox added to uploader --- lib/exe/ajax.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 391e951e5..7a4cea360 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -245,7 +245,7 @@ function ajax_mediadiff(){ if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); $NS = $_POST['ns']; $auth = auth_quickaclcheck("$ns:*"); - media_diff($image, $NS, $auth); + media_diff($image, $NS, $auth, true); } function ajax_mediaupload(){ @@ -259,7 +259,8 @@ function ajax_mediaupload(){ } if($_FILES['qqfile']['tmp_name']){ - $id = $_FILES['qqfile']['name']; + $id = $_REQUEST['file_name']; + if (!$id) $id = $_FILES['qqfile']['name']; $file = $_FILES['qqfile']['tmp_name']; list($ext,$mime,$dl) = mimetype($id); @@ -268,7 +269,7 @@ function ajax_mediaupload(){ 'mime' => $mime, 'ext' => $ext), $NS.':'.$id, - false, + $_REQUEST['ow'], $AUTH, 'move_uploaded_file' ); @@ -296,7 +297,7 @@ function ajax_mediaupload(){ 'mime' => $mime, 'ext' => $ext), $NS.':'.$id, - false, + (($_REQUEST['ow'] == 'true') ? true : false), $AUTH, 'copy' ); -- cgit v1.2.3 From 2d6cc64fdb73879f54aa25b2122f36631c654e3c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 12 Aug 2011 12:50:34 +0300 Subject: issue #44, #52 media_upload reused, error handling --- lib/exe/ajax.php | 63 ++++++++++---------------------------------------------- 1 file changed, 11 insertions(+), 52 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 7a4cea360..aa07fe7b0 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -249,65 +249,24 @@ function ajax_mediadiff(){ } function ajax_mediaupload(){ - global $NS; + global $NS, $MSG; + $NS = $_REQUEST['ns']; $AUTH = auth_quickaclcheck("$NS:*"); if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } - if($_FILES['qqfile']['error']){ - unset($_FILES['qqfile']); - } - - if($_FILES['qqfile']['tmp_name']){ - $id = $_REQUEST['file_name']; - if (!$id) $id = $_FILES['qqfile']['name']; - $file = $_FILES['qqfile']['tmp_name']; - list($ext,$mime,$dl) = mimetype($id); - - $res = media_save( - array('name' => $file, - 'mime' => $mime, - 'ext' => $ext), - $NS.':'.$id, - $_REQUEST['ow'], - $AUTH, - 'move_uploaded_file' - ); - if (!is_array($res)) { - $result = array('success'=>true); - } - } + 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 ($res) $result = array('success'=>true); - if (isset($_GET['qqfile'])) { - $id = $_GET['qqfile']; - list($ext,$mime,$dl) = mimetype($id); - $input = fopen("php://input", "r"); - $temp = tmpfile(); - $realSize = stream_copy_to_stream($input, $temp); - fclose($input); - if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]) return false; - if (!($tmp = io_mktmpdir())) return false; - $path = $tmp.'/'.$id; - $target = fopen($path, "w"); - fseek($temp, 0, SEEK_SET); - stream_copy_to_stream($temp, $target); - fclose($target); - $res = media_save( - array('name' => $path, - 'mime' => $mime, - 'ext' => $ext), - $NS.':'.$id, - (($_REQUEST['ow'] == 'true') ? true : false), - $AUTH, - 'copy' - ); - unlink($path); - if ($tmp) dir_delete($tmp); - if (!is_array($res)) { - $result = array('success'=>true); + if (!$result) { + $error = ''; + if (isset($MSG)) { + foreach($MSG as $msg) $error .= $msg['msg']; } + $result = array('error'=> $msg['msg']); } - if (!$result) $result = array('error'=> 'Could not save uploaded file.'); echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); } -- cgit v1.2.3 From 873cd06e1bda38e0decce16d6ec7d3bdaece612e Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 15 Aug 2011 14:22:19 +0300 Subject: issue #50 styling the new uploader --- lib/exe/ajax.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index aa07fe7b0..52131d864 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -256,16 +256,25 @@ function ajax_mediaupload(){ if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } 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 ($res) $result = array('success'=>true); + + if ($_FILES['qqfile']['tmp_name']) { + $res = media_upload($NS, $AUTH, $_FILES['qqfile']); + $id = ((empty($_POST['mediaid'])) ? $_FILES['qqfile']['name'] : $_POST['mediaid']); + } + if (isset($_GET['qqfile'])) { + $res = media_upload_xhr($NS, $AUTH); + $id = $_GET['qqfile']; + } + + if ($res) $result = array('success' => true, + 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&')); if (!$result) { $error = ''; if (isset($MSG)) { foreach($MSG as $msg) $error .= $msg['msg']; } - $result = array('error'=> $msg['msg']); + $result = array('error' => $msg['msg']); } echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); } -- cgit v1.2.3 From b2a330ca75f1ceec063a08029abb0204110e3601 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 6 Aug 2011 13:56:57 +0200 Subject: removed events.js --- lib/exe/js.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 44ab2d5ca..4355cbfd7 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -44,7 +44,6 @@ function js_out(){ DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", DOKU_INC.'lib/scripts/helpers.js', - DOKU_INC.'lib/scripts/events.js', DOKU_INC.'lib/scripts/delay.js', DOKU_INC.'lib/scripts/cookie.js', DOKU_INC.'lib/scripts/script.js', -- cgit v1.2.3 From 02782d1287173f3981a008755958543c178de296 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 18 Aug 2011 12:24:43 +0200 Subject: moved subscription javascript into behaviour --- lib/exe/js.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 4355cbfd7..93d5439e0 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -59,7 +59,6 @@ function js_out(){ DOKU_INC.'lib/scripts/locktimer.js', DOKU_INC.'lib/scripts/linkwiz.js', DOKU_INC.'lib/scripts/media.js', - DOKU_INC.'lib/scripts/subscriptions.js', DOKU_INC.'lib/scripts/compatibility.js', # disabled for FS#1958 DOKU_INC.'lib/scripts/hotkeys.js', DOKU_TPLINC.'script.js', -- cgit v1.2.3 From fbedf1265a6551391cbb7442ec5f9360328ff508 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 18 Aug 2011 15:17:54 +0200 Subject: moved footnotes and section highlighting to ne file jquerized --- lib/exe/js.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 93d5439e0..0e0a22d42 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -61,8 +61,9 @@ function js_out(){ DOKU_INC.'lib/scripts/media.js', DOKU_INC.'lib/scripts/compatibility.js', # disabled for FS#1958 DOKU_INC.'lib/scripts/hotkeys.js', - DOKU_TPLINC.'script.js', DOKU_INC.'lib/scripts/behaviour.js', + DOKU_INC.'lib/scripts/page.js', + DOKU_TPLINC.'script.js', ); // add possible plugin scripts and userscript -- cgit v1.2.3 From 99e7bfd4c733d81cd01dd2d97e10bb4dda62df66 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 19 Aug 2011 11:35:58 +0200 Subject: jqueryized locktimer --- lib/exe/js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 0e0a22d42..e96d45ee6 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -109,7 +109,7 @@ function js_out(){ js_runonstart("addEvent(document,'click',closePopups)"); js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); if($conf['locktime'] != 0){ - js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].", 'wiki__text')"); + js_runonstart("dw_locktimer.init(".($conf['locktime'] - 60).",".$conf['usedraft'].")"); } // init hotkeys - must have been done after init of toolbar # disabled for FS#1958 js_runonstart('initializeHotkeys()'); -- cgit v1.2.3 From c472bad9de398442c30ec1410d07284f0db8b821 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 19 Aug 2011 20:56:43 +0300 Subject: issue #44 new uploader in the media popup --- lib/exe/ajax.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 52131d864..d8754b875 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -265,9 +265,11 @@ function ajax_mediaupload(){ $res = media_upload_xhr($NS, $AUTH); $id = $_GET['qqfile']; } + $id = cleanID($id, false, true); if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&')); + 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&'), + 'id' => $id); if (!$result) { $error = ''; -- cgit v1.2.3 From 9de3b5710719658ef75740c0bd930423cc7c209c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 21 Aug 2011 02:16:39 +0300 Subject: issue #44 uploader fixes, #45 browser testing --- lib/exe/ajax.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index d8754b875..7fcccd4d9 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -268,15 +268,15 @@ function ajax_mediaupload(){ $id = cleanID($id, false, true); if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&'), - 'id' => $id); + 'link' => media_managerURL(array('ns' => $NS, 'image' => $id), '&'), + 'id' => $NS.':'.$id, 'ns' => $NS); if (!$result) { $error = ''; if (isset($MSG)) { foreach($MSG as $msg) $error .= $msg['msg']; } - $result = array('error' => $msg['msg']); + $result = array('error' => $msg['msg'], 'ns' => $NS); } echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); } -- cgit v1.2.3 From 035e07f1301d5d7a13de017640d80db14d300ac3 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 24 Aug 2011 22:34:06 +0300 Subject: issue #57, function names, params, html fixes --- lib/exe/ajax.php | 6 +++--- lib/exe/css.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 7fcccd4d9..a6e45c4de 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -209,7 +209,7 @@ function ajax_medialist(){ $NS = $_POST['ns']; if ($_POST['do'] == 'media') { - tpl_fileList(); + tpl_mediaFileList(); } else { tpl_mediaContent(true); } @@ -232,7 +232,7 @@ function ajax_mediadetails(){ if (isset($REV) && !$JUMPTO) $rev = $REV; html_msgarea(); - tpl_fileDetails($image, $rev); + tpl_mediaFileDetails($image, $rev); } /** @@ -268,7 +268,7 @@ function ajax_mediaupload(){ $id = cleanID($id, false, true); if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => $NS, 'image' => $id), '&'), + 'link' => media_managerURL(array('ns' => $NS, 'image' => $NS.':'.$id), '&'), 'id' => $NS.':'.$id, 'ns' => $NS); if (!$result) { diff --git a/lib/exe/css.php b/lib/exe/css.php index 8f86f2433..81f47d8fa 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -189,7 +189,7 @@ function css_interwiki(){ function css_filetypes(){ // default style - echo 'a.mediafile {'; + echo '.mediafile {'; echo ' background: transparent url('.DOKU_BASE.'lib/images/fileicons/file.png) 0px 1px no-repeat;'; echo ' padding-left: 18px;'; echo ' padding-bottom: 1px;'; @@ -212,7 +212,7 @@ function css_filetypes(){ } foreach($exts as $ext=>$type){ $class = preg_replace('/[^_\-a-z0-9]+/','_',$ext); - echo "a.mf_$class {"; + echo ".mf_$class {"; echo ' background-image: url('.DOKU_BASE.'lib/images/fileicons/'.$ext.$type.')'; echo '}'; } -- cgit v1.2.3 From 30fd72fbc3c8bd3fbcae4f7041aa0e001a719c6a Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 2 Sep 2011 14:50:19 +0300 Subject: issue #47 Changes to old media manager popup: removing edit and delete functionality --- lib/exe/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index a6e45c4de..4f627e995 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -268,7 +268,7 @@ function ajax_mediaupload(){ $id = cleanID($id, false, true); if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => $NS, 'image' => $NS.':'.$id), '&'), + 'link' => media_managerURL(array('ns' => $NS.':'.getNS($id), 'image' => $NS.':'.$id), '&'), 'id' => $NS.':'.$id, 'ns' => $NS); if (!$result) { -- cgit v1.2.3 From cc2c0b9d6af82732ed79eeb85c22b7c3192a4e55 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Tue, 6 Sep 2011 19:22:07 +0300 Subject: issue #61 security fix --- lib/exe/ajax.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 4f627e995..d4ef8dc11 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -251,24 +251,27 @@ function ajax_mediadiff(){ function ajax_mediaupload(){ global $NS, $MSG; - $NS = $_REQUEST['ns']; - $AUTH = auth_quickaclcheck("$NS:*"); - if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } - - if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']); - if ($_FILES['qqfile']['tmp_name']) { - $res = media_upload($NS, $AUTH, $_FILES['qqfile']); $id = ((empty($_POST['mediaid'])) ? $_FILES['qqfile']['name'] : $_POST['mediaid']); - } - if (isset($_GET['qqfile'])) { - $res = media_upload_xhr($NS, $AUTH); + } elseif (isset($_GET['qqfile'])) { $id = $_GET['qqfile']; } + $id = cleanID($id, false, true); + $NS = $_REQUEST['ns']; + $ns = $NS.':'.getNS($id); + + $AUTH = auth_quickaclcheck("$ns:*"); + if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$ns:xxx", 'media'); } + + 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 ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => $NS.':'.getNS($id), 'image' => $NS.':'.$id), '&'), + 'link' => media_managerURL(array('ns' => $ns, 'image' => $NS.':'.$id), '&'), 'id' => $NS.':'.$id, 'ns' => $NS); if (!$result) { -- cgit v1.2.3 From 5e7a292691951a0fa0a18f06c8b9bcfb509a032d Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 9 Sep 2011 22:26:16 +0200 Subject: Various JavaScript improvements, JSLint, jQuery --- lib/exe/js.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 33f8c695d..b7f2fd222 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -88,6 +88,7 @@ function js_out(){ // add some global variables print "var DOKU_BASE = '".DOKU_BASE."';"; print "var DOKU_TPL = '".DOKU_TPL."';"; + // FIXME: Move those to JSINFO print "var DOKU_UHN = ".((int) useHeading('navigation')).";"; print "var DOKU_UHC = ".((int) useHeading('content')).";"; @@ -106,10 +107,7 @@ function js_out(){ echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n"; } - // init stuff - js_runonstart("addEvent(document,'click',closePopups)"); - js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); if($conf['locktime'] != 0){ js_runonstart("dw_locktimer.init(".($conf['locktime'] - 60).",".$conf['usedraft'].")"); } @@ -220,7 +218,7 @@ function js_escape($string){ * @author Andreas Gohr */ function js_runonstart($func){ - echo "addInitEvent(function(){ $func; });".NL; + echo "jQuery(function(){ $func; });".NL; } /** -- cgit v1.2.3 From 6f0b0dd1609f2a253b48f1b9347168dd2d5a61d7 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sat, 15 Oct 2011 10:35:25 +0100 Subject: removed remnants of old flash uploader (FS#2335) --- lib/exe/multipleUpload.swf | Bin 64561 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 lib/exe/multipleUpload.swf (limited to 'lib/exe') diff --git a/lib/exe/multipleUpload.swf b/lib/exe/multipleUpload.swf deleted file mode 100644 index 888aab045..000000000 Binary files a/lib/exe/multipleUpload.swf and /dev/null differ -- cgit v1.2.3 From b760af946cf29d1bee05a5cb33cfc6e357df441f Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 15 Oct 2011 14:54:10 +0200 Subject: Send a 401 Unauthorized header in XML-RPC when access is denied This is far from perfect but should solve most issues in the recommended configuration where only authorized users have access. Sending proper status codes should be implemented when the API implementation refactoring is done. --- lib/exe/xmlrpc.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 8b572d213..93d7c70ba 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -53,6 +53,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { */ function call($methodname, $args){ if(!in_array($methodname,$this->public_methods) && !$this->checkAuth()){ + header('HTTP/1.1 401 Unauthorized'); return new IXR_Error(-32603, 'server error. not authorized to call method "'.$methodname.'".'); } return parent::call($methodname, $args); -- cgit v1.2.3 From 794fc9db8fe6b243f202c740cea5a677b683341b Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 15 Oct 2011 15:06:35 +0200 Subject: Only send 401 if user is not logged in in XML-RPC FS#2133 If the user is already logged in, a 403 is sent instead now. --- lib/exe/xmlrpc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 93d7c70ba..6553d043f 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -53,7 +53,11 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { */ function call($methodname, $args){ if(!in_array($methodname,$this->public_methods) && !$this->checkAuth()){ - header('HTTP/1.1 401 Unauthorized'); + if (!isset($_SERVER['REMOTE_USER'])) { + header('HTTP/1.1 401 Unauthorized'); + } else { + header('HTTP/1.1 403 Forbidden'); + } return new IXR_Error(-32603, 'server error. not authorized to call method "'.$methodname.'".'); } return parent::call($methodname, $args); -- cgit v1.2.3 From fe13bd81bd93d84c12b23f8daa1f60c8a003d30b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Oct 2011 16:30:15 +0200 Subject: Fix XML-RPC login method FS#2324 The login wasn't able to modify the session as it was already closed earlier. This patch also executes the correct event when logins via XMLRPC are done. --- lib/exe/xmlrpc.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 6553d043f..8e4141d4e 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -858,11 +858,22 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { global $auth; if(!$conf['useacl']) return 0; if(!$auth) return 0; + + @session_start(); // reopen session for login if($auth->canDo('external')){ - return $auth->trustExternal($user,$pass,false); + $ok = $auth->trustExternal($user,$pass,false); }else{ - return auth_login($user,$pass,false,true); + $evdata = array( + 'user' => $user, + 'password' => $pass, + 'sticky' => false, + 'silent' => true, + ); + $ok = trigger_event('AUTH_LOGIN_CHECK', $evdata, 'auth_login_wrapper'); } + session_write_close(); // we're done with the session + + return $ok; } -- cgit v1.2.3 From f53795891c8f08acc7ad03adf236f82d6e108c38 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sat, 15 Oct 2011 16:09:02 +0100 Subject: FS#2317 fix CSS compress for generic pseudo classes/pseudo elements --- lib/exe/css.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index 81f47d8fa..d54e2e46c 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -319,7 +319,8 @@ function css_compress($css){ // strip whitespaces $css = preg_replace('![\r\n\t ]+!',' ',$css); - $css = preg_replace('/ ?([:;,{}\/]) ?/','\\1',$css); + $css = preg_replace('/ ?([;,{}\/]) ?/','\\1',$css); + $css = preg_replace('/ ?: /',':',$css); // shorten colors $css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3/", "#\\1\\2\\3",$css); -- cgit v1.2.3 From 6fd41509f28290d217a2c9995341215944d31916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?schplurtz=20le=20d=C3=A9boulonn=C3=A9?= Date: Thu, 27 Oct 2011 14:14:19 +0200 Subject: Use JSON wrapper in image upload (FS#2345) --- lib/exe/ajax.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index d4ef8dc11..f8d62cb57 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -281,7 +281,8 @@ function ajax_mediaupload(){ } $result = array('error' => $msg['msg'], 'ns' => $NS); } - echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); + $json = new JSON; + echo htmlspecialchars($json->encode($result), ENT_NOQUOTES); } function dir_delete($path) { -- cgit v1.2.3 From 80d6fbc300b7e423fe0d2373cf3888c80ac94a41 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 30 Oct 2011 11:02:44 +0100 Subject: Fix double-decoding in XMLRPC putAttachment --- lib/exe/xmlrpc.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 8e4141d4e..e5e3298ae 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -7,7 +7,7 @@ if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); /** * Increased whenever the API is changed */ -define('DOKU_XMLRPC_API_VERSION',5); +define('DOKU_XMLRPC_API_VERSION', 6); require_once(DOKU_INC.'inc/init.php'); session_write_close(); //close session @@ -584,8 +584,12 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { // save temporary file @unlink($ftmp); - $buff = base64_decode($file); - io_saveFile($ftmp, $buff); + if (preg_match('/^[A-Za-z0-9\+\/]*={0,2}$/', $file) === 1) { + // DEPRECATED: Double-decode file if it still looks like base64 + // after first decoding (which is done by the library) + $file = base64_decode($file); + } + io_saveFile($ftmp, $file); $res = media_save(array('name' => $ftmp), $id, $params['ow'], $auth, 'rename'); if (is_array($res)) { -- cgit v1.2.3