From 98dba5ad053f051c0291c9ac9b291c783ebed372 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 19 Nov 2009 15:28:45 +0100 Subject: Allow hyphens and underscores in javascript include filenames darcs-hash:20091119142845-e4919-5394617fd83d4de22673491b868f7040c25fb290.gz --- 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 ab67288cd..5be4d2b6b 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -151,7 +151,7 @@ function js_load($file){ static $loaded = array(); $data = io_readFile($file); - while(preg_match('#/\*\s*DOKUWIKI:include(_once)?\s+([\w\./]+)\s*\*/#',$data,$match)){ + while(preg_match('#/\*\s*DOKUWIKI:include(_once)?\s+([\w\.\-_/]+)\s*\*/#',$data,$match)){ $ifile = $match[2]; // is it a include_once? -- cgit v1.2.3 From 21ed602531cbceff3e92e4ac33484f44ed2b6848 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 1 Dec 2009 12:50:19 +0100 Subject: Factor out timer and delay management darcs-hash:20091201115019-e4919-fe83e3d69eb997d0c04064b46117690824fe4daf.gz --- 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 5be4d2b6b..38fda1789 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -41,6 +41,7 @@ function js_out(){ $files = array( 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', DOKU_INC.'lib/scripts/tw-sack.js', @@ -106,7 +107,6 @@ function js_out(){ // init stuff - js_runonstart("ajax_qsearch.init('qsearch__in','qsearch__out')"); js_runonstart("addEvent(document,'click',closePopups)"); js_runonstart('addTocToggle()'); js_runonstart("initSizeCtl('size__ctl','wiki__text')"); -- cgit v1.2.3 From 5b75cd1f5c479ada468fbf62a733c54edad152f1 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 5 Jan 2010 14:14:00 +0100 Subject: New mail subscription with digest --- lib/exe/indexer.php | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/exe/js.php | 1 + 2 files changed, 71 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 1c4128eb7..eb1556e1d 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -37,6 +37,7 @@ if ($evt->advise_before()) { runIndexer() or metaUpdate() or runSitemapper() or + sendDigest() or runTrimRecentChanges() or runTrimRecentChanges(true) or $evt->advise_after(); @@ -334,6 +335,75 @@ function runSitemapper(){ return true; } +/** + * Send digest and list mails for all subscriptions which are in effect for the + * current page + * + * @author Adrian Lang + */ +function sendDigest() { + require_once DOKU_INC . 'inc/subscription.php'; + echo 'sendDigest(): start'.NL; + global $ID; + global $conf; + if (!$conf['subscribers']) { + return; + } + + $subscriptions = subscription_find($ID, array('style' => '(digest|list)', + 'escaped' => true)); + global $auth; + global $lang; + global $conf; + foreach($subscriptions as $id => $users) { + foreach($users as $data) { + list($user, $style, $lastupdate) = $data; + $lastupdate = (int) $lastupdate; + if ($lastupdate + $conf['subscribe_interval'] > time()) { + // Less than a day passed since last update. + continue; + } + // TODO: Does that suffice for namespaces? + $info = $auth->getUserData($user); + if ($info === false) { + continue; + } + $level = auth_aclcheck($id, $user, $info['grps']); + if ($level < AUTH_READ) { + continue; + } + + if (substr($id, -1, 1) === ':') { + // The subscription target is a namespace + $changes = getRecentsSince($lastupdate, null, getNS($id)); + if (count($changes) === 0) { + continue; + } + if ($style === 'digest') { + foreach($changes as $change) { + subscription_send_digest($info['mail'], $change, + $lastupdate); + } + } elseif ($style === 'list') { + subscription_send_list($info['mail'], $changes, $id); + } + // TODO: Handle duplicate subscriptions. + } else { + $meta = p_get_metadata($id); + $rev = $meta['last_change']['date']; + if ($rev < $lastupdate) { + // There is no new revision. + continue; + } + subscription_send_digest($info['mail'], $meta['last_change'], + $lastupdate); + } + // Update notification time. + subscription_set($id, $user, $style, true); + } + } +} + /** * Formats a timestamp as ISO 8601 date * diff --git a/lib/exe/js.php b/lib/exe/js.php index 38fda1789..8648bf18f 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -53,6 +53,7 @@ function js_out(){ DOKU_INC.'lib/scripts/edit.js', DOKU_INC.'lib/scripts/linkwiz.js', DOKU_INC.'lib/scripts/media.js', + DOKU_INC.'lib/scripts/subscriptions.js', DOKU_TPLINC.'script.js', ); -- cgit v1.2.3 From 8881fcc99a05f20da8fdd0f1c52f801fd84a8bb7 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 19 Nov 2009 15:25:25 +0100 Subject: Add events to subscription. --- lib/exe/indexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index eb1556e1d..70aa607a9 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -399,7 +399,7 @@ function sendDigest() { $lastupdate); } // Update notification time. - subscription_set($id, $user, $style, true); + subscription_set($user, $id, $style, time(), true); } } } -- cgit v1.2.3 From 3a5a6f4fe4a9f768f5c6418ba0694d67594ed701 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 23 Nov 2009 17:16:03 +0100 Subject: correctly handle permissions in digest mailer Ignore-this: c34455078907459a846cf7f00e2b586b darcs-hash:20091123161603-6e07b-927477d6ca50e665228487eb0d3ce9787dbe455b.gz --- lib/exe/indexer.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 70aa607a9..1766c54f1 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -342,19 +342,24 @@ function runSitemapper(){ * @author Adrian Lang */ function sendDigest() { - require_once DOKU_INC . 'inc/subscription.php'; echo 'sendDigest(): start'.NL; global $ID; global $conf; if (!$conf['subscribers']) { return; } - + require_once DOKU_INC . 'inc/subscription.php'; $subscriptions = subscription_find($ID, array('style' => '(digest|list)', 'escaped' => true)); global $auth; global $lang; global $conf; + global $USERINFO; + + // remember current user info + $olduinfo = $USERINFO; + $olduser = $_SERVER['REMOTE_USER']; + foreach($subscriptions as $id => $users) { foreach($users as $data) { list($user, $style, $lastupdate) = $data; @@ -363,13 +368,11 @@ function sendDigest() { // Less than a day passed since last update. continue; } - // TODO: Does that suffice for namespaces? - $info = $auth->getUserData($user); - if ($info === false) { - continue; - } - $level = auth_aclcheck($id, $user, $info['grps']); - if ($level < AUTH_READ) { + + // Work as the user to make sure ACLs apply correctly + $USERINFO = $auth->getUserData($user); + $_SERVER['REMOTE_USER'] = $user; + if ($USERINFO === false) { continue; } @@ -389,6 +392,8 @@ function sendDigest() { } // TODO: Handle duplicate subscriptions. } else { + if(auth_quickacl($id) < AUTH_READ) continue; + $meta = p_get_metadata($id); $rev = $meta['last_change']['date']; if ($rev < $lastupdate) { @@ -402,6 +407,10 @@ function sendDigest() { subscription_set($user, $id, $style, time(), true); } } + + // restore current user info + $USERINFO = $olduinfo; + $_SERVER['REMOTE_USER'] = $olduser; } /** -- cgit v1.2.3 From 2f27189ab6f07352f435e91bab0c28dfc4899583 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 24 Nov 2009 12:58:05 +0100 Subject: wrong function name fixed Ignore-this: b74163181c2e41d3be022a6185f3e1c1 darcs-hash:20091124115805-6e07b-e808cf44a00a65ff8c70cc7e8de4dfedadf96cbd.gz --- lib/exe/indexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 1766c54f1..53f2c129d 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -392,7 +392,7 @@ function sendDigest() { } // TODO: Handle duplicate subscriptions. } else { - if(auth_quickacl($id) < AUTH_READ) continue; + if(auth_quickaclcheck($id) < AUTH_READ) continue; $meta = p_get_metadata($id); $rev = $meta['last_change']['date']; -- cgit v1.2.3 From 34240a5903c7499900c8ecf0a5592d28f67aaf46 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 30 Nov 2009 14:50:40 +0100 Subject: Fix $info var reference in digest send darcs-hash:20091130135040-e4919-40b6614fe28ea07dc5796661ddda6d005264ddbc.gz --- lib/exe/indexer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 53f2c129d..84eb9d482 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -384,11 +384,11 @@ function sendDigest() { } if ($style === 'digest') { foreach($changes as $change) { - subscription_send_digest($info['mail'], $change, + subscription_send_digest($USERINFO['mail'], $change, $lastupdate); } } elseif ($style === 'list') { - subscription_send_list($info['mail'], $changes, $id); + subscription_send_list($USERINFO['mail'], $changes, $id); } // TODO: Handle duplicate subscriptions. } else { @@ -400,7 +400,7 @@ function sendDigest() { // There is no new revision. continue; } - subscription_send_digest($info['mail'], $meta['last_change'], + subscription_send_digest($USERINFO['mail'], $meta['last_change'], $lastupdate); } // Update notification time. -- cgit v1.2.3 From 24b3cb1ac0784ffa2acabf021fdd06c6d49cc7b1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 1 Feb 2010 16:20:40 +0100 Subject: removed require's in lib/exe/* --- lib/exe/ajax.php | 23 +---------------------- lib/exe/css.php | 4 ---- lib/exe/detail.php | 7 ------- lib/exe/fetch.php | 10 ++-------- lib/exe/indexer.php | 8 -------- lib/exe/js.php | 5 ----- lib/exe/mediamanager.php | 7 ------- lib/exe/xmlrpc.php | 23 ----------------------- 8 files changed, 3 insertions(+), 84 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 4618abd71..22de2f0f0 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -13,10 +13,7 @@ if(!count($_POST) && $HTTP_RAW_POST_DATA){ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); require_once(DOKU_INC.'inc/init.php'); -require_once(DOKU_INC.'inc/common.php'); -require_once(DOKU_INC.'inc/pageutils.php'); -require_once(DOKU_INC.'inc/auth.php'); -//close sesseion +//close session session_write_close(); header('Content-Type: text/html; charset=utf-8'); @@ -57,9 +54,6 @@ function ajax_qsearch(){ if(empty($query)) $query = cleanID($_GET['q']); if(empty($query)) return; - require_once(DOKU_INC.'inc/html.php'); - require_once(DOKU_INC.'inc/fulltext.php'); - $data = array(); $data = ft_pageLookup($query); @@ -95,10 +89,6 @@ function ajax_suggestions() { if(empty($query)) $query = cleanID($_GET['q']); if(empty($query)) return; - require_once(DOKU_INC.'inc/html.php'); - require_once(DOKU_INC.'inc/fulltext.php'); - require_once(DOKU_INC.'inc/JSON.php'); - $data = array(); $data = ft_pageLookup($query); if(!count($data)) return; @@ -181,8 +171,6 @@ function ajax_draftdel(){ */ function ajax_medians(){ global $conf; - require_once(DOKU_INC.'inc/search.php'); - require_once(DOKU_INC.'inc/media.php'); // wanted namespace $ns = cleanID($_POST['ns']); @@ -208,8 +196,6 @@ function ajax_medians(){ function ajax_medialist(){ global $conf; global $NS; - require_once(DOKU_INC.'inc/media.php'); - require_once(DOKU_INC.'inc/template.php'); $NS = $_POST['ns']; tpl_mediaContent(true); @@ -222,7 +208,6 @@ function ajax_medialist(){ */ function ajax_mediasearchlist(){ global $conf; - require_once(DOKU_INC.'inc/media.php'); media_searchlist($_POST['ns']); } @@ -234,8 +219,6 @@ function ajax_mediasearchlist(){ */ function ajax_index(){ global $conf; - require_once(DOKU_INC.'inc/search.php'); - require_once(DOKU_INC.'inc/html.php'); // wanted namespace $ns = cleanID($_POST['idx']); @@ -263,7 +246,6 @@ function ajax_index(){ function ajax_linkwiz(){ global $conf; global $lang; - require_once(DOKU_INC.'inc/html.php'); $q = ltrim($_POST['q'],':'); $id = noNS($q); @@ -279,8 +261,6 @@ function ajax_linkwiz(){ if($q && !$ns){ // use index to lookup matching pages - require_once(DOKU_INC.'inc/fulltext.php'); - require_once(DOKU_INC.'inc/parserutils.php'); $pages = array(); $pages = ft_pageLookup($id,false); @@ -312,7 +292,6 @@ function ajax_linkwiz(){ }else{ - require_once(DOKU_INC.'inc/search.php'); $opts = array( 'depth' => 1, 'listfiles' => true, diff --git a/lib/exe/css.php b/lib/exe/css.php index cb689d015..38017af9d 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -10,10 +10,6 @@ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching) if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT',1); // we gzip ourself here require_once(DOKU_INC.'inc/init.php'); -require_once(DOKU_INC.'inc/pageutils.php'); -require_once(DOKU_INC.'inc/httputils.php'); -require_once(DOKU_INC.'inc/io.php'); -require_once(DOKU_INC.'inc/confutils.php'); // Main (don't run when UNIT test) if(!defined('SIMPLE_TEST')){ diff --git a/lib/exe/detail.php b/lib/exe/detail.php index f30e039d4..3a04b7b09 100644 --- a/lib/exe/detail.php +++ b/lib/exe/detail.php @@ -2,13 +2,6 @@ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); define('DOKU_MEDIADETAIL',1); require_once(DOKU_INC.'inc/init.php'); - require_once(DOKU_INC.'inc/common.php'); - require_once(DOKU_INC.'inc/lang/en/lang.php'); - require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php'); - require_once(DOKU_INC.'inc/JpegMeta.php'); - require_once(DOKU_INC.'inc/html.php'); - require_once(DOKU_INC.'inc/template.php'); - require_once(DOKU_INC.'inc/auth.php'); //close session session_write_close(); diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 11877ef36..78de3188b 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -9,14 +9,8 @@ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); define('DOKU_DISABLE_GZIP_OUTPUT', 1); require_once(DOKU_INC.'inc/init.php'); - require_once(DOKU_INC.'inc/common.php'); - require_once(DOKU_INC.'inc/media.php'); - require_once(DOKU_INC.'inc/pageutils.php'); - require_once(DOKU_INC.'inc/httputils.php'); - require_once(DOKU_INC.'inc/confutils.php'); - require_once(DOKU_INC.'inc/auth.php'); - - //close sesseion + + //close session session_write_close(); $mimetypes = getMimeTypes(); diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 84eb9d482..828834c86 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -8,8 +8,6 @@ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); define('DOKU_DISABLE_GZIP_OUTPUT',1); require_once(DOKU_INC.'inc/init.php'); -require_once(DOKU_INC.'inc/auth.php'); -require_once(DOKU_INC.'inc/events.php'); session_write_close(); //close session if(!defined('NL')) define('NL',"\n"); @@ -177,8 +175,6 @@ function runIndexer(){ } if($conf['dperm']) chmod($lock, $conf['dperm']); - require_once(DOKU_INC.'inc/indexer.php'); - // upgrade to version 2 if (!@file_exists($conf['indexdir'].'/pageword.idx')) idx_upgradePageWords(); @@ -211,11 +207,8 @@ function metaUpdate(){ if (@file_exists($file)) return false; if (!@file_exists(wikiFN($ID))) return false; - require_once(DOKU_INC.'inc/common.php'); - require_once(DOKU_INC.'inc/parserutils.php'); global $conf; - // gather some additional info from changelog $info = io_grep($conf['changelog'], '/^(\d+)\t(\d+\.\d+\.\d+\.\d+)\t'.preg_quote($ID,'/').'\t([^\t]+)\t([^\t\n]+)/', @@ -348,7 +341,6 @@ function sendDigest() { if (!$conf['subscribers']) { return; } - require_once DOKU_INC . 'inc/subscription.php'; $subscriptions = subscription_find($ID, array('style' => '(digest|list)', 'escaped' => true)); global $auth; diff --git a/lib/exe/js.php b/lib/exe/js.php index 8648bf18f..044342187 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -11,10 +11,6 @@ if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session o if(!defined('NL')) define('NL',"\n"); if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT',1); // we gzip ourself here require_once(DOKU_INC.'inc/init.php'); -require_once(DOKU_INC.'inc/pageutils.php'); -require_once(DOKU_INC.'inc/httputils.php'); -require_once(DOKU_INC.'inc/io.php'); -require_once(DOKU_INC.'inc/JSON.php'); // Main (don't run when UNIT test) if(!defined('SIMPLE_TEST')){ @@ -96,7 +92,6 @@ function js_out(){ echo 'LANG = '.$json->encode($lang['js']).";\n"; // load toolbar - require_once(DOKU_INC.'inc/toolbar.php'); toolbar_JSdefines('toolbar'); // load files diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index f6e91b858..1fe363985 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -6,13 +6,6 @@ @ini_set('session.use_only_cookies',0); require_once(DOKU_INC.'inc/init.php'); - require_once(DOKU_INC.'inc/lang/en/lang.php'); - require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php'); - require_once(DOKU_INC.'inc/media.php'); - require_once(DOKU_INC.'inc/common.php'); - require_once(DOKU_INC.'inc/search.php'); - require_once(DOKU_INC.'inc/template.php'); - require_once(DOKU_INC.'inc/auth.php'); trigger_event('MEDIAMANAGER_STARTED',$tmp=array()); session_write_close(); //close session diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index d3913482f..fb6b79cf3 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -10,15 +10,10 @@ if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); define('DOKU_XMLRPC_API_VERSION',2); require_once(DOKU_INC.'inc/init.php'); -require_once(DOKU_INC.'inc/common.php'); -require_once(DOKU_INC.'inc/auth.php'); session_write_close(); //close session if(!$conf['xmlrpc']) die('XML-RPC server not enabled.'); -require_once(DOKU_INC.'inc/IXR_Library.php'); - - /** * Contains needed wrapper functions and registers all available * XMLRPC functions. @@ -378,7 +373,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $ns = cleanID($ns); $dir = utf8_encodeFN(str_replace(':', '/', $ns)); $data = array(); - require_once(DOKU_INC.'inc/search.php'); $opts['skipacl'] = 0; // no ACL skipping for XMLRPC search($data, $conf['datadir'], 'search_allpages', $opts, $dir); return $data; @@ -407,7 +401,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $dir = utf8_encodeFN(str_replace(':', '/', $ns)); $data = array(); - require_once(DOKU_INC.'inc/search.php'); search($data, $conf['mediadir'], 'search_media', $options, $dir); $len = count($data); if(!$len) return array(); @@ -426,7 +419,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Return a list of backlinks */ function listBackLinks($id){ - require_once(DOKU_INC.'inc/fulltext.php'); return ft_backlinks($id); } @@ -519,8 +511,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { } if($conf['dperm']) chmod($lock, $conf['dperm']); - require_once(DOKU_INC.'inc/indexer.php'); - // do the work idx_addPage($id); @@ -572,7 +562,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return new IXR_ERROR(1, $lang['uploadexist'].'1'); } // check for valid content - @require_once(DOKU_INC.'inc/media.php'); $ok = media_contentcheck($ftmp, $imime); if($ok == -1) { return new IXR_ERROR(1, sprintf($lang['uploadexist'].'2', ".$iext")); @@ -590,7 +579,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $data[4] = $overwrite; // trigger event - require_once(DOKU_INC.'inc/events.php'); return trigger_event('MEDIA_UPLOAD_FINISH', $data, array($this, '_media_upload_action'), true); } else { @@ -615,14 +603,12 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { // check for references if needed $mediareferences = array(); if($conf['refcheck']){ - require_once(DOKU_INC.'inc/fulltext.php'); $mediareferences = ft_mediause($id,$conf['refshow']); } if(!count($mediareferences)){ $file = mediaFN($id); if(@unlink($file)){ - require_once(DOKU_INC.'inc/changelog.php'); addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE); io_sweepNS($id,'mediadir'); return 0; @@ -648,7 +634,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { chmod($data[1], $conf['fmode']); media_notify($data[2], $data[1], $data[3]); // add a log entry to the media changelog - require_once(DOKU_INC.'inc/changelog.php'); if ($data[4]) { addMediaLogEntry(time(), $data[2], DOKU_CHANGE_TYPE_EDIT); } else { @@ -728,9 +713,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { if(strlen($timestamp) != 10) return new IXR_Error(20, 'The provided value is not a valid timestamp'); - require_once(DOKU_INC.'inc/changelog.php'); - require_once(DOKU_INC.'inc/pageutils.php'); - $recents = getRecentsSince($timestamp); $changes = array(); @@ -764,9 +746,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { if(strlen($timestamp) != 10) return new IXR_Error(20, 'The provided value is not a valid timestamp'); - require_once(DOKU_INC.'inc/changelog.php'); - require_once(DOKU_INC.'inc/pageutils.php'); - $recents = getRecentsSince($timestamp, null, '', RECENTS_MEDIA_CHANGES); $changes = array(); @@ -803,8 +782,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { if(empty($id)) return new IXR_Error(1, 'Empty page ID'); - require_once(DOKU_INC.'inc/changelog.php'); - $revisions = getRevisions($id, $first, $conf['recent']+1); if(count($revisions)==0 && $first!=0) { -- cgit v1.2.3 From 25fabd1de0b6421edfdfb47904354a7b8bff16e0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 5 Feb 2010 10:03:19 +0100 Subject: Fix documentation for subscribe_time --- lib/exe/indexer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 84eb9d482..35aa1beef 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -365,7 +365,8 @@ function sendDigest() { list($user, $style, $lastupdate) = $data; $lastupdate = (int) $lastupdate; if ($lastupdate + $conf['subscribe_interval'] > time()) { - // Less than a day passed since last update. + // Less than the configured time period passed since last + // update. continue; } -- cgit v1.2.3 From 70421c96f055e574aa6e9602492ca4b35a33b9f2 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 8 Feb 2010 15:44:26 +0100 Subject: Correct subscribe config parameter name --- lib/exe/indexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 35aa1beef..821163473 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -364,7 +364,7 @@ function sendDigest() { foreach($users as $data) { list($user, $style, $lastupdate) = $data; $lastupdate = (int) $lastupdate; - if ($lastupdate + $conf['subscribe_interval'] > time()) { + if ($lastupdate + $conf['subscribe_time'] > time()) { // Less than the configured time period passed since last // update. continue; -- cgit v1.2.3 From 544ed901ab29fc8b73d559c5cc89b7c57f643fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Mon, 15 Feb 2010 21:04:13 +0100 Subject: Disable locking when locktime is zero --- lib/exe/js.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 8648bf18f..5d93a69a4 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -113,7 +113,9 @@ function js_out(){ js_runonstart("initSizeCtl('size__ctl','wiki__text')"); js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); js_runonstart("initChangeCheck('".js_escape($lang['notsavedyet'])."')"); - js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].")"); + if($conf['locktime'] != 0){ + js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].")"); + } js_runonstart('scrollToMarker()'); js_runonstart('focusMarker()'); -- cgit v1.2.3 From cd98d9c31101cdf9637104f6d1b31ff8c27c1d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Tue, 23 Feb 2010 21:51:54 +0100 Subject: Added FETCH_MEDIA_4XERROR event --- lib/exe/fetch.php | 132 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 53 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 11877ef36..100b0cc37 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -32,73 +32,49 @@ $MIME = 'application/octet-stream'; $DL = true; } - - //media to local file - if(preg_match('#^(https?)://#i',$MEDIA)){ - //check hash - if(substr(md5(auth_cookiesalt().$MEDIA),0,6) != $_REQUEST['hash']){ - header("HTTP/1.0 412 Precondition Failed"); - print 'Precondition Failed'; - exit; - } - //handle external images - if(strncmp($MIME,'image/',6) == 0) $FILE = media_get_from_URL($MEDIA,$EXT,$CACHE); - if(!$FILE){ - //download failed - redirect to original URL - header('Location: '.$MEDIA); - exit; - } - }else{ - $MEDIA = cleanID($MEDIA); - if(empty($MEDIA)){ - header("HTTP/1.0 400 Bad Request"); - print 'Bad request'; + + // prepare data for error handling / clean download handling + list($STATUS, $STATUSMESSAGE) = check4XErrors($MEDIA, $FILE); // here goes the old 4X error checking + $data = array('media' => $MEDIA, + 'file' => $FILE, + 'orig' => $FILE, + 'mime' => $MIME, + 'download' => $DL, + 'cache' => $CACHE, + 'ext' => $EXT, + 'width' => $WIDTH, + 'height' => $HEIGHT, + 'status' => $STATUS, + 'statusmessage' => $STATUSMESSAGE, + ); + + // handle any 4XX status messages + if ( $STATUS >= 400 && $STATUSMESSAGE < 500 ) { + $evt = new Doku_Event('FETCH_MEDIA_4XERROR', $data); + if ( $evt->advise_before() ) { + header('HTTP/1.0 ' . $data['status'] . ' ' . $data['statusmessage']); + print $data['statusmessage']; exit; - } - - //check permissions (namespace only) - if(auth_quickaclcheck(getNS($MEDIA).':X') < AUTH_READ){ - header("HTTP/1.0 401 Unauthorized"); - //fixme add some image for imagefiles - print 'Unauthorized'; - exit; - } - $FILE = mediaFN($MEDIA); + } + unset($evt); } - //check file existance - if(!@file_exists($FILE)){ - header("HTTP/1.0 404 Not Found"); - //FIXME add some default broken image - print 'Not Found'; - exit; - } - - $ORIG = $FILE; - //handle image resizing/cropping if((substr($MIME,0,5) == 'image') && $WIDTH){ if($HEIGHT){ - $FILE = media_crop_image($FILE,$EXT,$WIDTH,$HEIGHT); + $data['file'] = $FILE = media_crop_image($data['file'],$EXT,$WIDTH,$HEIGHT); }else{ - $FILE = media_resize_image($FILE,$EXT,$WIDTH,$HEIGHT); + $data['file'] = $FILE = media_resize_image($data['file'],$EXT,$WIDTH,$HEIGHT); } } - + // finally send the file to the client - $data = array('file' => $FILE, - 'mime' => $MIME, - 'download' => $DL, - 'cache' => $CACHE, - 'orig' => $ORIG, - 'ext' => $EXT, - 'width' => $WIDTH, - 'height' => $HEIGHT); - $evt = new Doku_Event('MEDIA_SENDFILE', $data); if ($evt->advise_before()) { sendFile($data['file'],$data['mime'],$data['download'],$data['cache']); } + // Do something after the download finished. + $evt->advise_after(); /* ------------------------------------------------------------------------ */ @@ -155,6 +131,56 @@ function sendFile($file,$mime,$dl,$cache){ } } +/* + * File fetch 4XX error checker + * + * Check for preconditions and return 4XX errors if needed + * READ: MEDIA, MIME, EXT, CACHE + * WRITE: MEDIA, FILE, array( STATUS, STATUSMESSAGE ) + * + * @author Gerry Weissbach + * @param $media reference to the media id + * @param $file reference to the file variable + * @returns array(STATUS, STATUSMESSAGE) + */ +function check4XErrors(&$media, &$file) { + global $MIME, $EXT, $CACHE; + + //media to local file + if(preg_match('#^(https?)://#i',$media)){ + //check hash + if(substr(md5(auth_cookiesalt().$media),0,6) != $_REQUEST['hash']){ + return array( 412, 'Precondition Failed'); + } + //handle external images + if(strncmp($MIME,'image/',6) == 0) $file = media_get_from_URL($media,$EXT,$CACHE); + if(!$file){ + //download failed - redirect to original URL + header('Location: '.$media); + exit; + } + }else{ + $media = cleanID($media); + if(empty($media)){ + return array( 400, 'Bad request' ); + } + + //check permissions (namespace only) + if(auth_quickaclcheck(getNS($media).':X') < AUTH_READ){ + return array( 401, 'Unauthorized' ); + } + $file = mediaFN($media); + } + + //check file existance + if(!@file_exists($file)){ + // FIXME add some default broken image + return array( 404, 'Not Found' ); + } + + return array(null, null); +} + /** * Returns the wanted cachetime in seconds * -- cgit v1.2.3 From 032933052326cab7864caafa674a9253814e1a17 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 23 Feb 2010 22:20:10 +0100 Subject: Changed FETCH_MEDIA_4XERROR to FETCH_MEDIA_STATUS --- lib/exe/fetch.php | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 100b0cc37..81a8903c9 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -32,9 +32,11 @@ $MIME = 'application/octet-stream'; $DL = true; } - - // prepare data for error handling / clean download handling - list($STATUS, $STATUSMESSAGE) = check4XErrors($MEDIA, $FILE); // here goes the old 4X error checking + + // check for permissions, preconditions and cache external files + list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE); + + // prepare data for plugin events $data = array('media' => $MEDIA, 'file' => $FILE, 'orig' => $FILE, @@ -47,17 +49,26 @@ 'status' => $STATUS, 'statusmessage' => $STATUSMESSAGE, ); - - // handle any 4XX status messages - if ( $STATUS >= 400 && $STATUSMESSAGE < 500 ) { - $evt = new Doku_Event('FETCH_MEDIA_4XERROR', $data); - if ( $evt->advise_before() ) { + + // handle the file status + $evt = new Doku_Event('FETCH_MEDIA_STATUS', $data); + if ( $evt->advise_before() ) { + // redirects + if($data['status'] > 300 && $data['status'] <= 304){ + send_redirect($data['statusmessage']); + } + // send any non 200 status + if($data['status'] != 200){ header('HTTP/1.0 ' . $data['status'] . ' ' . $data['statusmessage']); + } + // die on errors + if($data['status'] > 203){ print $data['statusmessage']; exit; - } - unset($evt); + } } + $evt->advise_after(); + unset($evt); //handle image resizing/cropping if((substr($MIME,0,5) == 'image') && $WIDTH){ @@ -67,7 +78,7 @@ $data['file'] = $FILE = media_resize_image($data['file'],$EXT,$WIDTH,$HEIGHT); } } - + // finally send the file to the client $evt = new Doku_Event('MEDIA_SENDFILE', $data); if ($evt->advise_before()) { @@ -131,21 +142,20 @@ function sendFile($file,$mime,$dl,$cache){ } } -/* - * File fetch 4XX error checker - * - * Check for preconditions and return 4XX errors if needed +/** + * Check for media for preconditions and return correct status code + * * READ: MEDIA, MIME, EXT, CACHE * WRITE: MEDIA, FILE, array( STATUS, STATUSMESSAGE ) - * + * * @author Gerry Weissbach * @param $media reference to the media id * @param $file reference to the file variable * @returns array(STATUS, STATUSMESSAGE) */ -function check4XErrors(&$media, &$file) { +function checkFileStatus(&$media, &$file) { global $MIME, $EXT, $CACHE; - + //media to local file if(preg_match('#^(https?)://#i',$media)){ //check hash @@ -156,8 +166,7 @@ function check4XErrors(&$media, &$file) { if(strncmp($MIME,'image/',6) == 0) $file = media_get_from_URL($media,$EXT,$CACHE); if(!$file){ //download failed - redirect to original URL - header('Location: '.$media); - exit; + return array( 302, $media ); } }else{ $media = cleanID($media); @@ -174,11 +183,10 @@ function check4XErrors(&$media, &$file) { //check file existance if(!@file_exists($file)){ - // FIXME add some default broken image return array( 404, 'Not Found' ); } - - return array(null, null); + + return array(200, null); } /** -- cgit v1.2.3 From c6f610ef3c4f586d8f535f2a30e29c310bb9b125 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 24 Feb 2010 20:34:32 +0100 Subject: Send 403 instead of 401 in fetch.php FS#1904 --- 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 81a8903c9..968ee9436 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -176,7 +176,7 @@ function checkFileStatus(&$media, &$file) { //check permissions (namespace only) if(auth_quickaclcheck(getNS($media).':X') < AUTH_READ){ - return array( 401, 'Unauthorized' ); + return array( 403, 'Forbidden' ); } $file = mediaFN($media); } -- cgit v1.2.3 From 9dde1138fb3e544fd2614b77833a76f7ed9f7f81 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 28 Feb 2010 12:03:57 +0100 Subject: honor sneaky_index config in link manager FS#1907 --- lib/exe/ajax.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 4618abd71..465bd1846 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -319,6 +319,7 @@ function ajax_linkwiz(){ 'listdirs' => true, 'pagesonly' => true, 'firsthead' => true, + 'sneakyacl' => $conf['sneaky_index'], ); if($id) $opts['filematch'] = '^.*\/'.$id; if($id) $opts['dirmatch'] = '^.*\/'.$id; -- cgit v1.2.3 From f71f4f5359fe234960829868bf22081bf1f2d947 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 28 Feb 2010 12:32:01 +0100 Subject: added dokuwiki.search XMLRPC call FS#1882 --- lib/exe/xmlrpc.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index d3913482f..a29a40612 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',2); +define('DOKU_XMLRPC_API_VERSION',3); require_once(DOKU_INC.'inc/init.php'); require_once(DOKU_INC.'inc/common.php'); @@ -118,6 +118,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 'List all pages within the given namespace.' ); + $this->addCallback( + 'dokuwiki.search', + 'this:search', + array('struct','string'), + 'Perform a fulltext search and return a list of matching pages' + ); + $this->addCallback( 'dokuwiki.getTime', 'time', @@ -384,6 +391,41 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return $data; } + /** + * List all pages in the given namespace (and below) + */ + function search($query){ + require_once(DOKU_INC.'inc/fulltext.php'); + + $regex = ''; + $data = ft_pageSearch($query,$regex); + $pages = array(); + + // prepare additional data + $idx = 0; + foreach($data as $id => $score){ + $file = wikiFN($id); + + if($idx < FT_SNIPPET_NUMBER){ + $snippet = ft_snippet($id,$regex); + $idx++; + }else{ + $snippet = ''; + } + + $pages[] = array( + 'id' => $id, + 'score' => $score, + 'rev' => filemtime($file), + 'mtime' => filemtime($file), + 'size' => filesize($file), + 'snippet' => $snippet, + ); + } + return $data; + } + + /** * List all media files. * -- cgit v1.2.3 From fe17917e7668864526ec0f0ae65dd0787831d8a4 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 10 Mar 2010 10:41:32 +0100 Subject: Move & rename HTML_PAGE_FROMTEMPLATE to common.php The new COMMON_PAGE_FROMTEMPLATE is triggered by pageTemplate AFTER the template has been read but before performing the template replacements. --- lib/exe/xmlrpc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index a29a40612..155812d22 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -290,8 +290,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { } $text = rawWiki($id,$rev); if(!$text) { - $data = array($id); - return trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); + return pageTemplate($id); } else { return $text; } -- cgit v1.2.3 From a958c48cfeaefd8e8c1aeebcd04e9c862f014a6d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 12 Mar 2010 14:35:43 +0100 Subject: removed dead leftover code from media search --- lib/exe/ajax.php | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 4c74709b8..a402c236f 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -201,17 +201,6 @@ function ajax_medialist(){ tpl_mediaContent(true); } -/** - * Return list of search result for the Mediamanager - * - * @author Tobias Sarnowski - */ -function ajax_mediasearchlist(){ - global $conf; - - media_searchlist($_POST['ns']); -} - /** * Return sub index for index view * -- cgit v1.2.3 From c77fa67b50d49455e3b518eeb2bcbd0531d07165 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 16 Mar 2010 15:33:58 +0100 Subject: Use md5sum of id and client ip as temporary filename in XML-RPC Before this patch the temporary filename was the uncleaned id. This allowed everyone with upload-privileges (on the whole wiki) and XML-RPC privileges on a XML-RPC-enabled DokuWiki to (over)write any file PHP is allowed to write with any content he wants. If you have XML-RPC enabled and users with XML-RPC and upload privileges you don't trust in a way you would allow them to write any file PHP may write, consider this as an important security fix. By default XML-RPC is disabled, so if you don't know what I'm talking about you are probably not affected by the problem. --- 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 670ab5d7e..b6b9f0e52 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -578,7 +578,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return new IXR_ERROR(1, 'Filename not given.'); } - $ftmp = $conf['tmpdir'] . '/' . $id; + $ftmp = $conf['tmpdir'] . '/' . md5($id.clientIP()); // save temporary file @unlink($ftmp); -- cgit v1.2.3 From 26ee1edf9c1750df399baebcb70afb49778b4a92 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 25 Mar 2010 15:01:25 +0100 Subject: Rewrite JavaScript change check --- 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 0eb43b246..05965ba02 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -107,7 +107,6 @@ function js_out(){ js_runonstart('addTocToggle()'); js_runonstart("initSizeCtl('size__ctl','wiki__text')"); js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); - js_runonstart("initChangeCheck('".js_escape($lang['notsavedyet'])."')"); if($conf['locktime'] != 0){ js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].")"); } -- cgit v1.2.3 From ac1ffdde2b4e44e5eb2434a5df8ef6a04bb4ff29 Mon Sep 17 00:00:00 2001 From: Georges-Etienne Legendre Date: Sat, 17 Apr 2010 21:45:21 +0800 Subject: Fix #1943: full text search XML-RPC call should return the $pages instead of $data --- 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 b6b9f0e52..743d3eedb 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -415,7 +415,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 'snippet' => $snippet, ); } - return $data; + return $pages; } -- cgit v1.2.3 From e6f4c9d492a59d555873548a77c477870f6cdcd8 Mon Sep 17 00:00:00 2001 From: Georges-Etienne Legendre Date: Sat, 17 Apr 2010 21:58:17 +0800 Subject: Adding getTitle to the XML-RPC API --- lib/exe/xmlrpc.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 743d3eedb..a4dc56f0f 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',3); +define('DOKU_XMLRPC_API_VERSION',4); require_once(DOKU_INC.'inc/init.php'); session_write_close(); //close session @@ -134,6 +134,15 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 'Lock or unlock pages.' ); + + $this->addCallback( + 'dokuwiki.getTitle', + 'this:getTitle', + array('string'), + 'Returns the wiki title.', + true + ); + /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */ $this->addCallback( 'wiki.getRPCVersionSupported', @@ -418,6 +427,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return $pages; } + /** + * Returns the wiki title. + */ + function getTitle(){ + global $conf; + return $conf['title']; + } /** * List all media files. -- cgit v1.2.3 From 3e0c7aa328ac721b3bcf17822f9ed3659ad93d14 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 4 May 2010 12:07:35 +0200 Subject: Add locking for indexer-based notifications --- lib/exe/indexer.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index eb5670005..7e55915f4 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -353,6 +353,9 @@ function sendDigest() { $olduser = $_SERVER['REMOTE_USER']; foreach($subscriptions as $id => $users) { + if (!subscription_lock($id)) { + continue; + } foreach($users as $data) { list($user, $style, $lastupdate) = $data; $lastupdate = (int) $lastupdate; @@ -399,6 +402,7 @@ function sendDigest() { // Update notification time. subscription_set($user, $id, $style, time(), true); } + subscription_unlock($id); } // restore current user info -- cgit v1.2.3 From 7ea8e5925d4d2e18975712870d48912761ea1503 Mon Sep 17 00:00:00 2001 From: Marek Sacha Date: Tue, 27 Apr 2010 00:40:25 +0200 Subject: Reimplementation of Accesskeys in JavaScript (FS#1809) --- 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 05965ba02..f1ac86c82 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -50,6 +50,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/hotkeys.js', DOKU_TPLINC.'script.js', ); -- cgit v1.2.3 From 4062d3d5c0c566751a1f098495e9aa836e8db9de Mon Sep 17 00:00:00 2001 From: Marek Sacha Date: Fri, 30 Apr 2010 17:18:40 +0200 Subject: Reimplementation of Accesskeys in javascript (FS#1809), toolbar accesskyes fix. --- lib/exe/js.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index f1ac86c82..f2f9dfe6b 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -113,6 +113,8 @@ function js_out(){ } js_runonstart('scrollToMarker()'); js_runonstart('focusMarker()'); + // init hotkeys - must have been done after init of toolbar + js_runonstart('initializeHotkeys()'); // end output buffering and get contents $js = ob_get_contents(); -- cgit v1.2.3 From 86228f109464404b30ea74164e855ef146c87249 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Mon, 24 May 2010 21:44:35 +0200 Subject: added cleanID to xmlrpc call wiki.getBackLinks --- 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 a4dc56f0f..377003cf1 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -476,7 +476,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Return a list of backlinks */ function listBackLinks($id){ - return ft_backlinks($id); + return ft_backlinks(cleanID($id)); } /** -- cgit v1.2.3 From 80423ab626c72923f347e2196ce660957dcc216f Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 16 Jun 2010 14:41:59 +0200 Subject: Perform quick search in title as well --- lib/exe/ajax.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index a402c236f..9c10ca548 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -50,27 +50,28 @@ function ajax_qsearch(){ global $conf; global $lang; - $query = cleanID($_POST['q']); - if(empty($query)) $query = cleanID($_GET['q']); + $query = $_POST['q']; + if(empty($query)) $query = $_GET['q']; if(empty($query)) return; - $data = array(); - $data = ft_pageLookup($query); + $data = ft_pageLookup($query, true, false); if(!count($data)) return; print ''.$lang['quickhits'].''; print '
    '; - foreach($data as $id){ - print '
  • '; - $ns = getNS($id); - if($ns){ - $name = shorten(noNS($id), ' ('.$ns.')',30); - }else{ - $name = $id; + foreach($data as $id => $title){ + if (useHeading('navigation')) { + $name = $title; + } else { + $ns = getNS($id); + if($ns){ + $name = shorten(noNS($id), ' ('.$ns.')',30); + }else{ + $name = $id; + } } - print html_wikilink(':'.$id,$name); - print '
  • '; + echo '
  • ' . html_wikilink(':'.$id,$name) . '
  • '; } print '
'; } -- cgit v1.2.3 From 159ef5962053a685e348239dfa0b3648ed516962 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 16 Jun 2010 16:09:06 +0200 Subject: Remove temp indexer upgrade stuff from 579b0f7e --- lib/exe/indexer.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 7e55915f4..1e6eb5685 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -134,18 +134,6 @@ function runIndexer(){ global $conf; print "runIndexer(): started".NL; - // Move index files (if needed) - // Uses the importoldindex plugin to upgrade the index automatically. - // FIXME: Remove this from runIndexer when it is no longer needed. - if (@file_exists($conf['cachedir'].'/page.idx') && - (!@file_exists($conf['indexdir'].'/page.idx') || - !filesize($conf['indexdir'].'/page.idx')) && - !@file_exists($conf['indexdir'].'/index_importing')) { - echo "trigger TEMPORARY_INDEX_UPGRADE_EVENT\n"; - $tmp = array(); // no event data - trigger_event('TEMPORARY_INDEX_UPGRADE_EVENT', $tmp); - } - if(!$ID) return false; // check if indexing needed -- cgit v1.2.3 From a0070b52bbd24f6972b819fa8ff4bdbfe81b5bbc Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 16 Jun 2010 16:15:28 +0200 Subject: Add title index to the indexer files, improve indexer calls --- lib/exe/indexer.php | 2 +- lib/exe/xmlrpc.php | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 1e6eb5685..75228779e 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -255,7 +255,7 @@ function runSitemapper(){ return false; } - $pages = file($conf['indexdir'].'/page.idx'); + $pages = idx_getIndex('page', ''); print 'runSitemapper(): creating sitemap using '.count($pages).' pages'.NL; // build the sitemap diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 377003cf1..f06792361 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -354,24 +354,22 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * List all pages - we use the indexer list here */ function listPages(){ - global $conf; - $list = array(); - $pages = file($conf['indexdir'] . '/page.idx'); - $pages = array_filter($pages, 'isVisiblePage'); + $pages = array_filter(array_filter(idx_getIndex('page', ''), + 'isVisiblePage'), + 'page_exists'); foreach(array_keys($pages) as $idx) { - if(page_exists($pages[$idx])) { - $perm = auth_quickaclcheck($pages[$idx]); - if($perm >= AUTH_READ) { - $page = array(); - $page['id'] = trim($pages[$idx]); - $page['perms'] = $perm; - $page['size'] = @filesize(wikiFN($pages[$idx])); - $page['lastModified'] = new IXR_Date(@filemtime(wikiFN($pages[$idx]))); - $list[] = $page; - } + $perm = auth_quickaclcheck($pages[$idx]); + if($perm < AUTH_READ) { + continue; } + $page = array(); + $page['id'] = trim($pages[$idx]); + $page['perms'] = $perm; + $page['size'] = @filesize(wikiFN($pages[$idx])); + $page['lastModified'] = new IXR_Date(@filemtime(wikiFN($pages[$idx]))); + $list[] = $page; } return $list; -- cgit v1.2.3 From fa61423c0443cfa720938bd4ed01184c05678e97 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 22 Jun 2010 18:59:27 +0200 Subject: temporary disable hotkey JS for FS#1958 --- 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 f2f9dfe6b..669afb96c 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -114,7 +114,7 @@ function js_out(){ js_runonstart('scrollToMarker()'); js_runonstart('focusMarker()'); // init hotkeys - must have been done after init of toolbar - js_runonstart('initializeHotkeys()'); +#FIXME disabled for FS#1958 js_runonstart('initializeHotkeys()'); // end output buffering and get contents $js = ob_get_contents(); -- cgit v1.2.3 From 8d22f1e96be5aa2c65ecb6ee934debbfe0f8f4cc Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 26 Jun 2010 13:38:10 +0200 Subject: Changes to the ft_pageLookup and related event FS#1978 This patch changes the ft_pageLookup function to always return the title of pages with the result. This makes it easier to work with the array, as it no longer changes between numeric and key indexes depending on useheading. This also means that action plugins subscribed to SEARCH_QUERY_PAGELOOKUP need to be adjusted. The event contains a new data field called 'has_titles' which plugins can use to check for backwards compatibility. --- lib/exe/ajax.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 9c10ca548..8b03bb07c 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -54,7 +54,7 @@ function ajax_qsearch(){ if(empty($query)) $query = $_GET['q']; if(empty($query)) return; - $data = ft_pageLookup($query, true, false); + $data = ft_pageLookup($query, true, useHeading('navigation')); if(!count($data)) return; @@ -93,6 +93,7 @@ function ajax_suggestions() { $data = array(); $data = ft_pageLookup($query); if(!count($data)) return; + $data = array_keys($data); // limit results to 15 hits $data = array_slice($data, 0, 15); @@ -252,26 +253,27 @@ function ajax_linkwiz(){ // use index to lookup matching pages $pages = array(); - $pages = ft_pageLookup($id,false); + $pages = ft_pageLookup($id,true); // result contains matches in pages and namespaces // we now extract the matching namespaces to show // them seperately $dirs = array(); - $count = count($pages); - for($i=0; $i<$count; $i++){ - if(strpos(noNS($pages[$i]),$id) === false){ + + + foreach($pages as $pid => $title){ + if(strpos(noNS($pid),$id) === false){ // match was in the namespace - $dirs[getNS($pages[$i])] = 1; // assoc array avoids dupes + $dirs[getNS($pid)] = 1; // assoc array avoids dupes }else{ // it is a matching page, add it to the result $data[] = array( - 'id' => $pages[$i], - 'title' => p_get_first_heading($pages[$i],false), + 'id' => $pid, + 'title' => $title, 'type' => 'f', ); } - unset($pages[$i]); + unset($pages[$pid]); } foreach($dirs as $dir => $junk){ $data[] = array( -- cgit v1.2.3 From 7e1f9fd36044e5c651c71348897a3a3dc103d15a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 26 Jun 2010 13:54:29 +0200 Subject: Hotkey trigger is now CTRL-ALT FS#1958 Tests and feedbacks please! --- 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 669afb96c..f2f9dfe6b 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -114,7 +114,7 @@ function js_out(){ js_runonstart('scrollToMarker()'); js_runonstart('focusMarker()'); // init hotkeys - must have been done after init of toolbar -#FIXME disabled for FS#1958 js_runonstart('initializeHotkeys()'); + js_runonstart('initializeHotkeys()'); // end output buffering and get contents $js = ob_get_contents(); -- cgit v1.2.3 From 40f3c0b59813d467030d51948d518069141fd998 Mon Sep 17 00:00:00 2001 From: Gina Haeussge Date: Sun, 27 Jun 2010 12:25:15 +0200 Subject: FS#433: Editor now uses onbeforeunload event to capture ANY leaving of it besides via Save or Preview button. This has been successfully tested in FF, Chrome and IE6/7/8. Opera does not support onbeforeunload, therefore the draft is kept if the user navigates away from the editor. Please test this. --- 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 8b03bb07c..582be90e5 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -156,7 +156,7 @@ function ajax_lock(){ * @author Andreas Gohr */ function ajax_draftdel(){ - $id = cleanID($_POST['id']); + $id = cleanID($_REQUEST['id']); if(empty($id)) return; $client = $_SERVER['REMOTE_USER']; -- cgit v1.2.3 From 0b34c70fcb312d38e6110e2ca1432779ffb73a8a Mon Sep 17 00:00:00 2001 From: Gina Haeussge Date: Sun, 27 Jun 2010 14:50:49 +0200 Subject: FS#1795: Restrict media manager to users with at least read access on the supplied namespace. --- 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 1fe363985..c79a25c08 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -34,6 +34,12 @@ // check auth $AUTH = auth_quickaclcheck("$NS:*"); + // do not display the manager if user does not have read access + if($AUTH < AUTH_READ) { + header('HTTP/1.0 403 Forbidden'); + die($lang['accessdenied']); + } + // create the given namespace (just for beautification) if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } -- cgit v1.2.3 From 339bd727f11b2879121b67a65741bf1350e195e4 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 27 Jun 2010 15:02:06 +0100 Subject: Wrap $HTTP_RAW_POST_DATA in !empty() to avoid NOTICE in error logs --- 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 582be90e5..2945cca32 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -7,7 +7,7 @@ */ //fix for Opera XMLHttpRequests -if(!count($_POST) && $HTTP_RAW_POST_DATA){ +if(!count($_POST) && !empty($HTTP_RAW_POST_DATA)){ parse_str($HTTP_RAW_POST_DATA, $_POST); } -- cgit v1.2.3 From 09edb7113c19b07ca11a79c2b0571f45ed2cc2eb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 27 Jun 2010 18:44:23 +0200 Subject: use config cascade for userscripts and styles FS#1678 --- lib/exe/css.php | 11 +++++++++-- lib/exe/js.php | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/css.php b/lib/exe/css.php index 38017af9d..76f40c7bb 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -28,6 +28,8 @@ if(!defined('SIMPLE_TEST')){ function css_out(){ global $conf; global $lang; + global $config_cascade; + $style = ''; if (isset($_REQUEST['s']) && in_array($_REQUEST['s'], array('all', 'print', 'feed'))) { @@ -64,7 +66,10 @@ function css_out(){ // load plugin, template, user styles $files = array_merge($files, css_pluginstyles($style)); if (isset($tplstyles[$style])) $files = array_merge($files, $tplstyles[$style]); - $files[DOKU_CONF.'user'.$style.'.css'] = DOKU_BASE; + + if(isset($config_cascade['userstyle'][$style])){ + $files[$config_cascade['userstyle'][$style]] = DOKU_BASE; + } }else{ $files[DOKU_INC.'lib/styles/style.css'] = DOKU_BASE.'lib/styles/'; // load plugin, template, user styles @@ -73,7 +78,9 @@ function css_out(){ if($lang['direction'] == 'rtl'){ if (isset($tplstyles['rtl'])) $files = array_merge($files, $tplstyles['rtl']); } - $files[DOKU_CONF.'userstyle.css'] = DOKU_BASE; + if(isset($config_cascade['userstyle']['default'])){ + $files[$config_cascade['userstyle']['default']] = DOKU_BASE; + } } // check cache age & handle conditional request diff --git a/lib/exe/js.php b/lib/exe/js.php index f2f9dfe6b..3756c43b9 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -29,6 +29,7 @@ if(!defined('SIMPLE_TEST')){ function js_out(){ global $conf; global $lang; + global $config_cascade; // The generated script depends on some dynamic options $cache = getCacheName('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.js'); @@ -56,7 +57,9 @@ function js_out(){ // add possible plugin scripts and userscript $files = array_merge($files,js_pluginscripts()); - $files[] = DOKU_CONF.'userscript.js'; + if(isset($config_cascade['userscript']['default'])){ + $files[] = $config_cascade['userscript']['default']; + } // check cache age & handle conditional request header('Cache-Control: public, max-age=3600'); -- cgit v1.2.3 From 41c141178e9733bbf38f8e937d3dea63058af0dc Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 10 Aug 2010 12:26:19 +0200 Subject: Ignore small & own changes in digest & list mails --- lib/exe/indexer.php | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 75228779e..f8e2f7981 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -363,30 +363,40 @@ function sendDigest() { if (substr($id, -1, 1) === ':') { // The subscription target is a namespace $changes = getRecentsSince($lastupdate, null, getNS($id)); - if (count($changes) === 0) { - continue; - } - if ($style === 'digest') { - foreach($changes as $change) { - subscription_send_digest($USERINFO['mail'], $change, - $lastupdate); - } - } elseif ($style === 'list') { - subscription_send_list($USERINFO['mail'], $changes, $id); - } - // TODO: Handle duplicate subscriptions. } else { if(auth_quickaclcheck($id) < AUTH_READ) continue; $meta = p_get_metadata($id); - $rev = $meta['last_change']['date']; - if ($rev < $lastupdate) { - // There is no new revision. - continue; + $changes = array($meta['last_change']); + } + + // Filter out pages only changed in small and own edits + $change_ids = array(); + foreach($changes as $rev) { + $n = 0; + while (!is_null($rev) && $rev['date'] >= $lastupdate && + ($_SERVER['REMOTE_USER'] === $rev['user'] || + $rev['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT)) { + $rev = getRevisions($rev['id'], $n++, 1); + $rev = (count($rev) > 0) ? $rev[0] : null; + } + + if (!is_null($rev) && $rev['date'] >= $lastupdate) { + // Some change was not a minor one and not by myself + $change_ids[] = $rev['id']; } - subscription_send_digest($USERINFO['mail'], $meta['last_change'], - $lastupdate); } + + if ($style === 'digest') { + foreach($change_ids as $change_id) { + subscription_send_digest($USERINFO['mail'], $change_id, + $lastupdate); + } + } elseif ($style === 'list') { + subscription_send_list($USERINFO['mail'], $change_ids, $id); + } + // TODO: Handle duplicate subscriptions. + // Update notification time. subscription_set($user, $id, $style, time(), true); } -- cgit v1.2.3 From d259f728f887b2ad76a2531705eac51b7dda8676 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 11 Aug 2010 14:01:40 +0200 Subject: fixed locktimer/draft saving on new pages When creating new pages, no date field is added in the edit form. --- 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 2945cca32..533b8f91c 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -139,7 +139,7 @@ function ajax_lock(){ 'prefix' => $_POST['prefix'], 'text' => $_POST['wikitext'], 'suffix' => $_POST['suffix'], - 'date' => $_POST['date'], + 'date' => (int) $_POST['date'], 'client' => $client, ); $cname = getCacheName($draft['client'].$id,'.draft'); -- cgit v1.2.3