From 5505dd9afd380c1676d9d0cef3e10d5be06ffee2 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Sun, 27 Nov 2011 01:22:40 +0100 Subject: Fixed XML-RPC getAttachment method. Without creating an IXR_Base64 object, the file will be encoded as base64, but send as string. The client XML-RPC parser cannot detect that it is meant to be a base64 encoded file. --- lib/exe/xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index e5e3298ae..3a05c886d 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -311,7 +311,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return new IXR_Error(1, 'The requested file does not exist'); $data = io_readFile($file, false); - $base64 = base64_encode($data); + $base64 = new IXR_Base64($data); return $base64; } -- cgit v1.2.3 From 3543c6de939c52517f590300b6d4289dc3a785ff Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 28 Nov 2011 20:29:39 +0100 Subject: deprecated 3rd parameter of cleanID() FS#2377 For some reason trailing/leading underscores were allowed when uploading files. But the rest of the code (eg. listing or downloading files) never supported this. This patch removes this special case for uploading files to streamline ID cleaning of pages and media 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 f8d62cb57..8edd559d6 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -257,7 +257,7 @@ function ajax_mediaupload(){ $id = $_GET['qqfile']; } - $id = cleanID($id, false, true); + $id = cleanID($id); $NS = $_REQUEST['ns']; $ns = $NS.':'.getNS($id); -- cgit v1.2.3 From 1c122589394bb9150f09facdcd6e75d054eb69a4 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Tue, 29 Nov 2011 19:17:59 +0100 Subject: Using sensefull error codes. Since there are currently a lot of error coded returning 1, that mean completly different thing, i guess it would be very nice to change this. A client should not be forced to parse the error message, the error code should be enough to explain the error. This change suggests some error codes, that have a hierarchical structure. In the following list the categories begin with = and the error codes actually used with -. = 100 Page errors == 110 Page access errors --- 111 User is not allowed to read the requested page --- 112 User is not allowed to edit the page == 120 Page existance errors --- 121 The requested page does not exist == 130 Page edit errors --- 131 Empty page id --- 132 Empty page content --- 133 Page is locked --- 134 Positive wordblock check = 200 Media errors == 210 Media access errors --- 211 User is not allowed to read media --- 215 User is not allowed to list media == 220 Media existance errors --- 221 The requested media does not exist = 300 Search errors == 310 Argument errors --- 311 The provided value is not a valid timestamp == 320 Search result errors --- 321 No chances in specified timeframe --- lib/exe/xmlrpc.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 3a05c886d..5d19725a3 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -286,7 +286,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { function rawPage($id,$rev=''){ $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ - return new IXR_Error(1, 'You are not allowed to read this page'); + return new IXR_Error(111, 'You are not allowed to read this page'); } $text = rawWiki($id,$rev); if(!$text) { @@ -304,11 +304,11 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { function getAttachment($id){ $id = cleanID($id); if (auth_quickaclcheck(getNS($id).':*') < AUTH_READ) - return new IXR_Error(1, 'You are not allowed to read this file'); + return new IXR_Error(211, 'You are not allowed to read this file'); $file = mediaFN($id); if (!@ file_exists($file)) - return new IXR_Error(1, 'The requested file does not exist'); + return new IXR_Error(221, 'The requested file does not exist'); $data = io_readFile($file, false); $base64 = new IXR_Base64($data); @@ -342,7 +342,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { function htmlPage($id,$rev=''){ $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ - return new IXR_Error(1, 'You are not allowed to read this page'); + return new IXR_Error(111, 'You are not allowed to read this page'); } return p_wiki_xhtml($id,$rev,false); } @@ -462,7 +462,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { } return $data; } else { - return new IXR_Error(1, 'You are not allowed to list media files.'); + return new IXR_Error(215, 'You are not allowed to list media files.'); } } @@ -479,12 +479,12 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { function pageInfo($id,$rev=''){ $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ - return new IXR_Error(1, 'You are not allowed to read this page'); + return new IXR_Error(111, 'You are not allowed to read this page'); } $file = wikiFN($id,$rev); $time = @filemtime($file); if(!$time){ - return new IXR_Error(10, 'The requested page does not exist'); + return new IXR_Error(121, 'The requested page does not exist'); } $info = getRevisionInfo($id, $time, 1024); @@ -515,22 +515,22 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $minor = $params['minor']; if(empty($id)) - return new IXR_Error(1, 'Empty page ID'); + return new IXR_Error(131, 'Empty page ID'); if(!page_exists($id) && trim($TEXT) == '' ) { - return new IXR_ERROR(1, 'Refusing to write an empty new wiki page'); + return new IXR_ERROR(132, 'Refusing to write an empty new wiki page'); } if(auth_quickaclcheck($id) < AUTH_EDIT) - return new IXR_Error(1, 'You are not allowed to edit this page'); + return new IXR_Error(112, 'You are not allowed to edit this page'); // Check, if page is locked if(checklock($id)) - return new IXR_Error(1, 'The page is currently locked'); + return new IXR_Error(133, 'The page is currently locked'); // SPAM check if(checkwordblock()) - return new IXR_Error(1, 'Positive wordblock check'); + return new IXR_Error(134, 'Positive wordblock check'); // autoset summary on new pages if(!page_exists($id) && empty($sum)) { @@ -635,7 +635,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { function listLinks($id) { $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ - return new IXR_Error(1, 'You are not allowed to read this page'); + return new IXR_Error(111, 'You are not allowed to read this page'); } $links = array(); @@ -684,7 +684,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { */ function getRecentChanges($timestamp) { if(strlen($timestamp) != 10) - return new IXR_Error(20, 'The provided value is not a valid timestamp'); + return new IXR_Error(311, 'The provided value is not a valid timestamp'); $recents = getRecentsSince($timestamp); @@ -705,7 +705,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return $changes; } else { // in case we still have nothing at this point - return new IXR_Error(30, 'There are no changes in the specified timeframe'); + return new IXR_Error(321, 'There are no changes in the specified timeframe'); } } @@ -717,7 +717,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { */ function getRecentMediaChanges($timestamp) { if(strlen($timestamp) != 10) - return new IXR_Error(20, 'The provided value is not a valid timestamp'); + return new IXR_Error(311, 'The provided value is not a valid timestamp'); $recents = getRecentsSince($timestamp, null, '', RECENTS_MEDIA_CHANGES); @@ -738,7 +738,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return $changes; } else { // in case we still have nothing at this point - return new IXR_Error(30, 'There are no changes in the specified timeframe'); + return new IXR_Error(321, 'There are no changes in the specified timeframe'); } } @@ -750,14 +750,14 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { function pageVersions($id, $first) { $id = cleanID($id); if(auth_quickaclcheck($id) < AUTH_READ){ - return new IXR_Error(1, 'You are not allowed to read this page'); + return new IXR_Error(111, 'You are not allowed to read this page'); } global $conf; $versions = array(); if(empty($id)) - return new IXR_Error(1, 'Empty page ID'); + return new IXR_Error(131, 'Empty page ID'); $revisions = getRevisions($id, $first, $conf['recent']+1); -- cgit v1.2.3 From f3046d2bbd96dc9a501975392e76d6ae539cdf05 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Tue, 29 Nov 2011 20:42:35 +0100 Subject: Second part of the error codes. Forgot some :( Added the new error codes and categories: --- 212 Not allowed to delete media == 230 Media edit error --- 231 Filename not given --- 232 File is still referenced --- 233 Could not delete file --- lib/exe/xmlrpc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 5d19725a3..910271461 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -575,7 +575,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $auth = auth_quickaclcheck(getNS($id).':*'); if(!isset($id)) { - return new IXR_ERROR(1, 'Filename not given.'); + return new IXR_ERROR(231, 'Filename not given.'); } global $conf; @@ -611,11 +611,11 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { if ($res & DOKU_MEDIA_DELETED) { return 0; } elseif ($res & DOKU_MEDIA_NOT_AUTH) { - return new IXR_ERROR(1, "You don't have permissions to delete files."); + return new IXR_ERROR(212, "You don't have permissions to delete files."); } elseif ($res & DOKU_MEDIA_INUSE) { - return new IXR_ERROR(1, 'File is still referenced'); + return new IXR_ERROR(232, 'File is still referenced'); } else { - return new IXR_ERROR(1, 'Could not delete file'); + return new IXR_ERROR(233, 'Could not delete file'); } } -- cgit v1.2.3 From aafb4e36f7fdc95d371cffcf351c3611efd69945 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Thu, 1 Dec 2011 22:33:16 +0100 Subject: Fixed bug in XML-RPC search. The score was randomly transfered as string or as integer. This way it will always be transfered as an integer. --- lib/exe/xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 910271461..61e6f1e95 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -411,7 +411,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $pages[] = array( 'id' => $id, - 'score' => $score, + 'score' => intval($score), 'rev' => filemtime($file), 'mtime' => filemtime($file), 'size' => filesize($file), -- cgit v1.2.3 From 6d3ed70719f3f29ddcb490e55026c44c88a57dc3 Mon Sep 17 00:00:00 2001 From: dploeger Date: Tue, 29 Nov 2011 08:13:47 +0100 Subject: Added urldecoding of query for qsearch --- lib/exe/ajax.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 8edd559d6..b7b92cceb 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -53,6 +53,8 @@ function ajax_qsearch(){ $query = $_POST['q']; if(empty($query)) $query = $_GET['q']; if(empty($query)) return; + + $query = urldecode($query); $data = ft_pageLookup($query, true, useHeading('navigation')); -- cgit v1.2.3 From 2e646d615cc45b435080af6f34c1af04e92be3c9 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 4 Dec 2011 18:48:07 +0000 Subject: fixed whitespace error introduced with 475aa19 --- 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 b7b92cceb..46d835187 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -53,7 +53,7 @@ function ajax_qsearch(){ $query = $_POST['q']; if(empty($query)) $query = $_GET['q']; if(empty($query)) return; - + $query = urldecode($query); $data = ft_pageLookup($query, true, useHeading('navigation')); -- cgit v1.2.3 From 97a000f0551735b35606d94d59abc4ff440783a5 Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Thu, 1 Dec 2011 22:33:16 +0100 Subject: Fixed bug in XML-RPC search. The score was randomly transfered as string or as integer. This way it will always be transfered as an integer. --- lib/exe/xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index e5e3298ae..95775188f 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -411,7 +411,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $pages[] = array( 'id' => $id, - 'score' => $score, + 'score' => intval($score), 'rev' => filemtime($file), 'mtime' => filemtime($file), 'size' => filesize($file), -- cgit v1.2.3 From 29e4fe3d4e010b156d59d2ea20458f777203232a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 18 Jan 2012 11:12:11 +0100 Subject: Removed obsolete Opera fix that now causes harm FS#2429 --- lib/exe/ajax.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 46d835187..3d1584244 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -6,11 +6,6 @@ * @author Andreas Gohr */ -//fix for Opera XMLHttpRequests -if(!count($_POST) && !empty($HTTP_RAW_POST_DATA)){ - parse_str($HTTP_RAW_POST_DATA, $_POST); -} - if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); require_once(DOKU_INC.'inc/init.php'); //close session -- cgit v1.2.3 From c51f90d7a072929e2b636e986b8ea2121bc5a630 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Tue, 24 Jan 2012 11:12:44 +0100 Subject: let js.php use multiple caches --- lib/exe/js.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index b7f2fd222..c929c9ba5 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -31,8 +31,14 @@ function js_out(){ global $lang; global $config_cascade; + if (isset($_GET['cacheKey'])) { + $cacheKey = strval($_GET['cacheKey']); + } else { + $cacheKey = ''; + } + // The generated script depends on some dynamic options - $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'], + $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].$cacheKey, '.js'); // load minified version for some files -- cgit v1.2.3 From 81aca18e6e88c08386c11592dbf4650114aba04f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 1 Feb 2012 20:07:04 +0100 Subject: removed some more occurances of DOKU_TPL* --- lib/exe/css.php | 4 ++-- lib/exe/js.php | 4 ++-- lib/exe/opensearch.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index d54e2e46c..69b512205 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -41,8 +41,8 @@ function css_out(){ $tplinc = DOKU_INC.'lib/tpl/'.$tpl.'/'; $tpldir = DOKU_BASE.'lib/tpl/'.$tpl.'/'; }else{ - $tplinc = DOKU_TPLINC; - $tpldir = DOKU_TPL; + $tplinc = tpl_incdir(); + $tpldir = tpl_basedir(); } // The generated script depends on some dynamic options diff --git a/lib/exe/js.php b/lib/exe/js.php index b7f2fd222..963eebd5f 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -65,7 +65,7 @@ function js_out(){ # disabled for FS#1958 DOKU_INC.'lib/scripts/hotkeys.js', DOKU_INC.'lib/scripts/behaviour.js', DOKU_INC.'lib/scripts/page.js', - DOKU_TPLINC.'script.js', + tpl_incdir().'script.js', ); // add possible plugin scripts and userscript @@ -87,7 +87,7 @@ function js_out(){ // add some global variables print "var DOKU_BASE = '".DOKU_BASE."';"; - print "var DOKU_TPL = '".DOKU_TPL."';"; + print "var DOKU_TPL = '".tpl_basedir()."';"; // FIXME: Move those to JSINFO print "var DOKU_UHN = ".((int) useHeading('navigation')).";"; print "var DOKU_UHC = ".((int) useHeading('content')).";"; diff --git a/lib/exe/opensearch.php b/lib/exe/opensearch.php index 03a1632c4..73939c347 100644 --- a/lib/exe/opensearch.php +++ b/lib/exe/opensearch.php @@ -16,9 +16,9 @@ require_once(DOKU_INC.'inc/init.php'); // try to be clever about the favicon location if(file_exists(DOKU_INC.'favicon.ico')){ $ico = DOKU_URL.'favicon.ico'; -}elseif(file_exists(DOKU_TPLINC.'images/favicon.ico')){ +}elseif(file_exists(tpl_incdir().'images/favicon.ico')){ $ico = DOKU_URL.'lib/tpl/'.$conf['template'].'/images/favicon.ico'; -}elseif(file_exists(DOKU_TPLINC.'favicon.ico')){ +}elseif(file_exists(tpl_incdir().'favicon.ico')){ $ico = DOKU_URL.'lib/tpl/'.$conf['template'].'/favicon.ico'; }else{ $ico = DOKU_URL.'lib/tpl/default/images/favicon.ico'; -- cgit v1.2.3 From 2203da5b13d5062626a6ecd6b599fb42dc415a06 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 1 Feb 2012 20:35:23 +0100 Subject: increased XMLRPC API version for 1d667b4 --- lib/exe/xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 61e6f1e95..1264ff333 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', 6); +define('DOKU_XMLRPC_API_VERSION', 7); require_once(DOKU_INC.'inc/init.php'); session_write_close(); //close session -- cgit v1.2.3 From e67004f5b686076af0dbf00cf574ac643d003cae Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 7 Feb 2012 19:41:09 +0100 Subject: trigger JS_CACHE_USE in lib/exe/js.php This removes the cachekey parameter again and instead follows @michitux's suggestion to trigger an event for the cache usage --- lib/exe/js.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index c929c9ba5..95ca10e87 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -31,15 +31,9 @@ function js_out(){ global $lang; global $config_cascade; - if (isset($_GET['cacheKey'])) { - $cacheKey = strval($_GET['cacheKey']); - } else { - $cacheKey = ''; - } - // The generated script depends on some dynamic options - $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].$cacheKey, - '.js'); + $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.js'); + $cache->_event = 'JS_CACHE_USE'; // load minified version for some files $min = $conf['compress'] ? '.min' : ''; @@ -85,8 +79,8 @@ function js_out(){ // 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))); + $cache_ok = $cache->useCache(array('files' => $cache_files)); + http_cached($cache->cache, $cache_ok); // start output buffering and build the script ob_start(); -- cgit v1.2.3