some more coding standard compliance updates

This commit is contained in:
Andreas Gohr 2010-01-15 19:50:13 +01:00
parent 33e0cc3c97
commit 49eb6e3806
14 changed files with 2962 additions and 3015 deletions

View File

@ -25,7 +25,7 @@ $opt = rss_parseOptions();
// the feed is dynamic - we need a cache for each combo
// (but most people just use the default feed so it's still effective)
$cache = getCacheName(join('',array_values($opt)).$_SERVER['REMOTE_USER'],'.feed');
$key = join('', array_values($opt)) . $_SERVER['REMOTE_USER'];
$key = join('', array_values($opt)) . $_SERVER['REMOTE_USER'];
$cache = new cache($key, '.feed');
// prepare cache depends

View File

@ -279,7 +279,6 @@ class HTTPClient {
$written += $ret;
}
// read headers from socket
$r_headers = '';
do{

View File

@ -300,7 +300,7 @@ class IXR_Server {
if (!$data) {
global $HTTP_RAW_POST_DATA;
if (!$HTTP_RAW_POST_DATA) {
die('XML-RPC server accepts POST requests only.');
die('XML-RPC server accepts POST requests only.');
}
$data = $HTTP_RAW_POST_DATA;
}
@ -342,14 +342,13 @@ EOD;
$method = $this->callbacks[$methodname];
// Perform the callback and send the response
# Removed for DokuWiki to have a more consistent interface
# if (count($args) == 1) {
# // If only one paramater just send that instead of the whole array
# $args = $args[0];
# }
# Removed for DokuWiki to have a more consistent interface
# if (count($args) == 1) {
# // If only one paramater just send that instead of the whole array
# $args = $args[0];
# }
# Adjusted for DokuWiki to use call_user_func_array
# Adjusted for DokuWiki to use call_user_func_array
// args need to be an array
$args = (array) $args;

File diff suppressed because it is too large Load Diff

View File

@ -18,149 +18,149 @@ require_once(DOKU_INC.'inc/template.php');
* @triggers ACTION_HEADERS_SEND
*/
function act_dispatch(){
global $INFO;
global $ACT;
global $ID;
global $QUERY;
global $lang;
global $conf;
global $license;
global $INFO;
global $ACT;
global $ID;
global $QUERY;
global $lang;
global $conf;
global $license;
$preact = $ACT;
$preact = $ACT;
// give plugins an opportunity to process the action
$evt = new Doku_Event('ACTION_ACT_PREPROCESS',$ACT);
if ($evt->advise_before()) {
// give plugins an opportunity to process the action
$evt = new Doku_Event('ACTION_ACT_PREPROCESS',$ACT);
if ($evt->advise_before()) {
//sanitize $ACT
$ACT = act_clean($ACT);
//sanitize $ACT
$ACT = act_clean($ACT);
//check if searchword was given - else just show
$s = cleanID($QUERY);
if($ACT == 'search' && empty($s)){
$ACT = 'show';
}
//login stuff
if(in_array($ACT,array('login','logout'))){
$ACT = act_auth($ACT);
}
//check if user is asking to (un)subscribe a page
if($ACT == 'subscribe' || $ACT == 'unsubscribe')
$ACT = act_subscription($ACT);
//check if user is asking to (un)subscribe a namespace
if($ACT == 'subscribens' || $ACT == 'unsubscribens')
$ACT = act_subscriptionns($ACT);
//check permissions
$ACT = act_permcheck($ACT);
//register
$nil = array();
if($ACT == 'register' && $_POST['save'] && register()){
$ACT = 'login';
}
if ($ACT == 'resendpwd' && act_resendpwd()) {
$ACT = 'login';
}
//update user profile
if ($ACT == 'profile') {
if(!$_SERVER['REMOTE_USER']) {
$ACT = 'login';
} else {
if(updateprofile()) {
msg($lang['profchanged'],1);
$ACT = 'show';
//check if searchword was given - else just show
$s = cleanID($QUERY);
if($ACT == 'search' && empty($s)){
$ACT = 'show';
}
}
//login stuff
if(in_array($ACT,array('login','logout'))){
$ACT = act_auth($ACT);
}
//check if user is asking to (un)subscribe a page
if($ACT == 'subscribe' || $ACT == 'unsubscribe')
$ACT = act_subscription($ACT);
//check if user is asking to (un)subscribe a namespace
if($ACT == 'subscribens' || $ACT == 'unsubscribens')
$ACT = act_subscriptionns($ACT);
//check permissions
$ACT = act_permcheck($ACT);
//register
$nil = array();
if($ACT == 'register' && $_POST['save'] && register()){
$ACT = 'login';
}
if ($ACT == 'resendpwd' && act_resendpwd()) {
$ACT = 'login';
}
//update user profile
if ($ACT == 'profile') {
if(!$_SERVER['REMOTE_USER']) {
$ACT = 'login';
} else {
if(updateprofile()) {
msg($lang['profchanged'],1);
$ACT = 'show';
}
}
}
//revert
if($ACT == 'revert'){
if(checkSecurityToken()){
$ACT = act_revert($ACT);
}else{
$ACT = 'show';
}
}
//save
if($ACT == 'save'){
if(checkSecurityToken()){
$ACT = act_save($ACT);
}else{
$ACT = 'show';
}
}
//cancel conflicting edit
if($ACT == 'cancel')
$ACT = 'show';
//draft deletion
if($ACT == 'draftdel')
$ACT = act_draftdel($ACT);
//draft saving on preview
if($ACT == 'preview')
$ACT = act_draftsave($ACT);
//edit
if(($ACT == 'edit' || $ACT == 'preview') && $INFO['editable']){
$ACT = act_edit($ACT);
}else{
unlock($ID); //try to unlock
}
//handle export
if(substr($ACT,0,7) == 'export_')
$ACT = act_export($ACT);
//display some infos
if($ACT == 'check'){
check();
$ACT = 'show';
}
//handle admin tasks
if($ACT == 'admin'){
// retrieve admin plugin name from $_REQUEST['page']
if (!empty($_REQUEST['page'])) {
$pluginlist = plugin_list('admin');
if (in_array($_REQUEST['page'], $pluginlist)) {
// attempt to load the plugin
if ($plugin =& plugin_load('admin',$_REQUEST['page']) !== null)
$plugin->handle();
}
}
}
// check permissions again - the action may have changed
$ACT = act_permcheck($ACT);
} // end event ACTION_ACT_PREPROCESS default action
$evt->advise_after();
unset($evt);
// when action 'show', the intial not 'show' and POST, do a redirect
if($ACT == 'show' && $preact != 'show' && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
act_redirect($ID,$preact);
}
//revert
if($ACT == 'revert'){
if(checkSecurityToken()){
$ACT = act_revert($ACT);
}else{
$ACT = 'show';
}
}
//call template FIXME: all needed vars available?
$headers[] = 'Content-Type: text/html; charset=utf-8';
trigger_event('ACTION_HEADERS_SEND',$headers,'act_sendheaders');
//save
if($ACT == 'save'){
if(checkSecurityToken()){
$ACT = act_save($ACT);
}else{
$ACT = 'show';
}
}
//cancel conflicting edit
if($ACT == 'cancel')
$ACT = 'show';
//draft deletion
if($ACT == 'draftdel')
$ACT = act_draftdel($ACT);
//draft saving on preview
if($ACT == 'preview')
$ACT = act_draftsave($ACT);
//edit
if(($ACT == 'edit' || $ACT == 'preview') && $INFO['editable']){
$ACT = act_edit($ACT);
}else{
unlock($ID); //try to unlock
}
//handle export
if(substr($ACT,0,7) == 'export_')
$ACT = act_export($ACT);
//display some infos
if($ACT == 'check'){
check();
$ACT = 'show';
}
//handle admin tasks
if($ACT == 'admin'){
// retrieve admin plugin name from $_REQUEST['page']
if (!empty($_REQUEST['page'])) {
$pluginlist = plugin_list('admin');
if (in_array($_REQUEST['page'], $pluginlist)) {
// attempt to load the plugin
if ($plugin =& plugin_load('admin',$_REQUEST['page']) !== NULL)
$plugin->handle();
}
}
}
// check permissions again - the action may have changed
$ACT = act_permcheck($ACT);
} // end event ACTION_ACT_PREPROCESS default action
$evt->advise_after();
unset($evt);
// when action 'show', the intial not 'show' and POST, do a redirect
if($ACT == 'show' && $preact != 'show' && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
act_redirect($ID,$preact);
}
//call template FIXME: all needed vars available?
$headers[] = 'Content-Type: text/html; charset=utf-8';
trigger_event('ACTION_HEADERS_SEND',$headers,'act_sendheaders');
include(template('main.php'));
// output for the commands is now handled in inc/templates.php
// in function tpl_content()
include(template('main.php'));
// output for the commands is now handled in inc/templates.php
// in function tpl_content()
}
function act_sendheaders($headers) {
foreach ($headers as $hdr) header($hdr);
foreach ($headers as $hdr) header($hdr);
}
/**
@ -171,44 +171,44 @@ function act_sendheaders($headers) {
* @author Andreas Gohr <andi@splitbrain.org>
*/
function act_clean($act){
global $lang;
global $conf;
global $lang;
global $conf;
// check if the action was given as array key
if(is_array($act)){
list($act) = array_keys($act);
}
// check if the action was given as array key
if(is_array($act)){
list($act) = array_keys($act);
}
//remove all bad chars
$act = strtolower($act);
$act = preg_replace('/[^1-9a-z_]+/','',$act);
//remove all bad chars
$act = strtolower($act);
$act = preg_replace('/[^1-9a-z_]+/','',$act);
if($act == 'export_html') $act = 'export_xhtml';
if($act == 'export_htmlbody') $act = 'export_xhtmlbody';
if($act == 'export_html') $act = 'export_xhtml';
if($act == 'export_htmlbody') $act = 'export_xhtmlbody';
// check if action is disabled
if(!actionOK($act)){
msg('Command disabled: '.htmlspecialchars($act),-1);
return 'show';
}
// check if action is disabled
if(!actionOK($act)){
msg('Command disabled: '.htmlspecialchars($act),-1);
return 'show';
}
//disable all acl related commands if ACL is disabled
if(!$conf['useacl'] && in_array($act,array('login','logout','register','admin',
'subscribe','unsubscribe','profile','revert',
'resendpwd','subscribens','unsubscribens',))){
msg('Command unavailable: '.htmlspecialchars($act),-1);
return 'show';
}
//disable all acl related commands if ACL is disabled
if(!$conf['useacl'] && in_array($act,array('login','logout','register','admin',
'subscribe','unsubscribe','profile','revert',
'resendpwd','subscribens','unsubscribens',))){
msg('Command unavailable: '.htmlspecialchars($act),-1);
return 'show';
}
if(!in_array($act,array('login','logout','register','save','cancel','edit','draft',
'preview','search','show','check','index','revisions',
'diff','recent','backlink','admin','subscribe','revert',
'unsubscribe','profile','resendpwd','recover','wordblock',
'draftdel','subscribens','unsubscribens',)) && substr($act,0,7) != 'export_' ) {
msg('Command unknown: '.htmlspecialchars($act),-1);
return 'show';
}
return $act;
if(!in_array($act,array('login','logout','register','save','cancel','edit','draft',
'preview','search','show','check','index','revisions',
'diff','recent','backlink','admin','subscribe','revert',
'unsubscribe','profile','resendpwd','recover','wordblock',
'draftdel','subscribens','unsubscribens',)) && substr($act,0,7) != 'export_' ) {
msg('Command unknown: '.htmlspecialchars($act),-1);
return 'show';
}
return $act;
}
/**
@ -217,44 +217,44 @@ function act_clean($act){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function act_permcheck($act){
global $INFO;
global $conf;
global $INFO;
global $conf;
if(in_array($act,array('save','preview','edit','recover'))){
if($INFO['exists']){
if($act == 'edit'){
//the edit function will check again and do a source show
//when no AUTH_EDIT available
if(in_array($act,array('save','preview','edit','recover'))){
if($INFO['exists']){
if($act == 'edit'){
//the edit function will check again and do a source show
//when no AUTH_EDIT available
$permneed = AUTH_READ;
}else{
$permneed = AUTH_EDIT;
}
}else{
$permneed = AUTH_CREATE;
}
}elseif(in_array($act,array('login','search','recent','profile'))){
$permneed = AUTH_NONE;
}elseif($act == 'revert'){
$permneed = AUTH_ADMIN;
if($INFO['ismanager']) $permneed = AUTH_EDIT;
}elseif($act == 'register'){
$permneed = AUTH_NONE;
}elseif($act == 'resendpwd'){
$permneed = AUTH_NONE;
}elseif($act == 'admin'){
if($INFO['ismanager']){
// if the manager has the needed permissions for a certain admin
// action is checked later
$permneed = AUTH_READ;
}else{
$permneed = AUTH_ADMIN;
}
}else{
$permneed = AUTH_READ;
}else{
$permneed = AUTH_EDIT;
}
}else{
$permneed = AUTH_CREATE;
}
}elseif(in_array($act,array('login','search','recent','profile'))){
$permneed = AUTH_NONE;
}elseif($act == 'revert'){
$permneed = AUTH_ADMIN;
if($INFO['ismanager']) $permneed = AUTH_EDIT;
}elseif($act == 'register'){
$permneed = AUTH_NONE;
}elseif($act == 'resendpwd'){
$permneed = AUTH_NONE;
}elseif($act == 'admin'){
if($INFO['ismanager']){
// if the manager has the needed permissions for a certain admin
// action is checked later
$permneed = AUTH_READ;
}else{
$permneed = AUTH_ADMIN;
}
}else{
$permneed = AUTH_READ;
}
if($INFO['perm'] >= $permneed) return $act;
if($INFO['perm'] >= $permneed) return $act;
return 'denied';
return 'denied';
}
/**
@ -263,10 +263,10 @@ function act_permcheck($act){
* Deletes the draft for the current page and user
*/
function act_draftdel($act){
global $INFO;
@unlink($INFO['draft']);
$INFO['draft'] = null;
return 'show';
global $INFO;
@unlink($INFO['draft']);
$INFO['draft'] = null;
return 'show';
}
/**
@ -275,23 +275,23 @@ function act_draftdel($act){
* @todo this currently duplicates code from ajax.php :-/
*/
function act_draftsave($act){
global $INFO;
global $ID;
global $conf;
if($conf['usedraft'] && $_POST['wikitext']){
$draft = array('id' => $ID,
'prefix' => $_POST['prefix'],
'text' => $_POST['wikitext'],
'suffix' => $_POST['suffix'],
'date' => $_POST['date'],
'client' => $INFO['client'],
);
$cname = getCacheName($draft['client'].$ID,'.draft');
if(io_saveFile($cname,serialize($draft))){
$INFO['draft'] = $cname;
global $INFO;
global $ID;
global $conf;
if($conf['usedraft'] && $_POST['wikitext']){
$draft = array('id' => $ID,
'prefix' => $_POST['prefix'],
'text' => $_POST['wikitext'],
'suffix' => $_POST['suffix'],
'date' => $_POST['date'],
'client' => $INFO['client'],
);
$cname = getCacheName($draft['client'].$ID,'.draft');
if(io_saveFile($cname,serialize($draft))){
$INFO['draft'] = $cname;
}
}
}
return $act;
return $act;
}
/**
@ -304,31 +304,31 @@ function act_draftsave($act){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function act_save($act){
global $ID;
global $DATE;
global $PRE;
global $TEXT;
global $SUF;
global $SUM;
global $ID;
global $DATE;
global $PRE;
global $TEXT;
global $SUF;
global $SUM;
//spam check
if(checkwordblock())
return 'wordblock';
//conflict check //FIXME use INFO
if($DATE != 0 && @filemtime(wikiFN($ID)) > $DATE )
return 'conflict';
//spam check
if(checkwordblock())
return 'wordblock';
//conflict check //FIXME use INFO
if($DATE != 0 && @filemtime(wikiFN($ID)) > $DATE )
return 'conflict';
//save it
saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM,$_REQUEST['minor']); //use pretty mode for con
//unlock it
unlock($ID);
//save it
saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM,$_REQUEST['minor']); //use pretty mode for con
//unlock it
unlock($ID);
//delete draft
act_draftdel($act);
session_write_close();
//delete draft
act_draftdel($act);
session_write_close();
// when done, show page
return 'show';
// when done, show page
return 'show';
}
/**
@ -374,38 +374,38 @@ function act_revert($act){
* Tries to add the section id as hash mark after section editing
*/
function act_redirect($id,$preact){
global $PRE;
global $TEXT;
global $MSG;
global $PRE;
global $TEXT;
global $MSG;
//are there any undisplayed messages? keep them in session for display
//on the next page
if(isset($MSG) && count($MSG)){
//reopen session, store data and close session again
@session_start();
$_SESSION[DOKU_COOKIE]['msg'] = $MSG;
session_write_close();
}
//are there any undisplayed messages? keep them in session for display
//on the next page
if(isset($MSG) && count($MSG)){
//reopen session, store data and close session again
@session_start();
$_SESSION[DOKU_COOKIE]['msg'] = $MSG;
session_write_close();
}
$opts = array(
'id' => $id,
'preact' => $preact
);
//get section name when coming from section edit
if($PRE && preg_match('/^\s*==+([^=\n]+)/',$TEXT,$match)){
$check = false; //Byref
$opts['fragment'] = sectionID($match[0], $check);
}
$opts = array(
'id' => $id,
'preact' => $preact
);
//get section name when coming from section edit
if($PRE && preg_match('/^\s*==+([^=\n]+)/',$TEXT,$match)){
$check = false; //Byref
$opts['fragment'] = sectionID($match[0], $check);
}
trigger_event('ACTION_SHOW_REDIRECT',$opts,'act_redirect_execute');
trigger_event('ACTION_SHOW_REDIRECT',$opts,'act_redirect_execute');
}
function act_redirect_execute($opts){
$go = wl($opts['id'],'',true);
if(isset($opts['fragment'])) $go .= '#'.$opts['fragment'];
$go = wl($opts['id'],'',true);
if(isset($opts['fragment'])) $go .= '#'.$opts['fragment'];
//show it
send_redirect($go);
//show it
send_redirect($go);
}
/**
@ -414,30 +414,30 @@ function act_redirect_execute($opts){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function act_auth($act){
global $ID;
global $INFO;
global $ID;
global $INFO;
//already logged in?
if(isset($_SERVER['REMOTE_USER']) && $act=='login'){
return 'show';
}
//already logged in?
if(isset($_SERVER['REMOTE_USER']) && $act=='login'){
return 'show';
}
//handle logout
if($act=='logout'){
$lockedby = checklock($ID); //page still locked?
if($lockedby == $_SERVER['REMOTE_USER'])
unlock($ID); //try to unlock
//handle logout
if($act=='logout'){
$lockedby = checklock($ID); //page still locked?
if($lockedby == $_SERVER['REMOTE_USER'])
unlock($ID); //try to unlock
// do the logout stuff
auth_logoff();
// do the logout stuff
auth_logoff();
// rebuild info array
$INFO = pageinfo();
// rebuild info array
$INFO = pageinfo();
act_redirect($ID,'login');
}
act_redirect($ID,'login');
}
return $act;
return $act;
}
/**
@ -446,15 +446,15 @@ function act_auth($act){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function act_edit($act){
global $ID;
global $INFO;
global $ID;
global $INFO;
//check if locked by anyone - if not lock for my self
$lockedby = checklock($ID);
if($lockedby) return 'locked';
//check if locked by anyone - if not lock for my self
$lockedby = checklock($ID);
if($lockedby) return 'locked';
lock($ID);
return $act;
lock($ID);
return $act;
}
/**
@ -472,81 +472,81 @@ function act_edit($act){
* @author Michael Klier <chi@chimeric.de>
*/
function act_export($act){
global $ID;
global $REV;
global $conf;
global $lang;
global $ID;
global $REV;
global $conf;
global $lang;
$pre = '';
$post = '';
$output = '';
$headers = array();
$pre = '';
$post = '';
$output = '';
$headers = array();
// search engines: never cache exported docs! (Google only currently)
$headers['X-Robots-Tag'] = 'noindex';
// search engines: never cache exported docs! (Google only currently)
$headers['X-Robots-Tag'] = 'noindex';
$mode = substr($act,7);
switch($mode) {
case 'raw':
$headers['Content-Type'] = 'text/plain; charset=utf-8';
$headers['Content-Disposition'] = 'attachment; filename='.noNS($ID).'.txt';
$output = rawWiki($ID,$REV);
break;
case 'xhtml':
$pre .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' . DOKU_LF;
$pre .= ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . DOKU_LF;
$pre .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$conf['lang'].'"' . DOKU_LF;
$pre .= ' lang="'.$conf['lang'].'" dir="'.$lang['direction'].'">' . DOKU_LF;
$pre .= '<head>' . DOKU_LF;
$pre .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . DOKU_LF;
$pre .= ' <title>'.$ID.'</title>' . DOKU_LF;
$mode = substr($act,7);
switch($mode) {
case 'raw':
$headers['Content-Type'] = 'text/plain; charset=utf-8';
$headers['Content-Disposition'] = 'attachment; filename='.noNS($ID).'.txt';
$output = rawWiki($ID,$REV);
break;
case 'xhtml':
$pre .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' . DOKU_LF;
$pre .= ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . DOKU_LF;
$pre .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$conf['lang'].'"' . DOKU_LF;
$pre .= ' lang="'.$conf['lang'].'" dir="'.$lang['direction'].'">' . DOKU_LF;
$pre .= '<head>' . DOKU_LF;
$pre .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . DOKU_LF;
$pre .= ' <title>'.$ID.'</title>' . DOKU_LF;
// get metaheaders
ob_start();
tpl_metaheaders();
$pre .= ob_get_clean();
// get metaheaders
ob_start();
tpl_metaheaders();
$pre .= ob_get_clean();
$pre .= '</head>' . DOKU_LF;
$pre .= '<body>' . DOKU_LF;
$pre .= '<div class="dokuwiki export">' . DOKU_LF;
$pre .= '</head>' . DOKU_LF;
$pre .= '<body>' . DOKU_LF;
$pre .= '<div class="dokuwiki export">' . DOKU_LF;
// get toc
$pre .= tpl_toc(true);
// get toc
$pre .= tpl_toc(true);
$headers['Content-Type'] = 'text/html; charset=utf-8';
$output = p_wiki_xhtml($ID,$REV,false);
$headers['Content-Type'] = 'text/html; charset=utf-8';
$output = p_wiki_xhtml($ID,$REV,false);
$post .= '</div>' . DOKU_LF;
$post .= '</body>' . DOKU_LF;
$post .= '</html>' . DOKU_LF;
break;
case 'xhtmlbody':
$headers['Content-Type'] = 'text/html; charset=utf-8';
$output = p_wiki_xhtml($ID,$REV,false);
break;
default:
$output = p_cached_output(wikiFN($ID,$REV), $mode);
$headers = p_get_metadata($ID,"format $mode");
break;
}
// prepare event data
$data = array();
$data['id'] = $ID;
$data['mode'] = $mode;
$data['headers'] = $headers;
$data['output'] =& $output;
trigger_event('ACTION_EXPORT_POSTPROCESS', $data);
if(!empty($data['output'])){
if(is_array($data['headers'])) foreach($data['headers'] as $key => $val){
header("$key: $val");
$post .= '</div>' . DOKU_LF;
$post .= '</body>' . DOKU_LF;
$post .= '</html>' . DOKU_LF;
break;
case 'xhtmlbody':
$headers['Content-Type'] = 'text/html; charset=utf-8';
$output = p_wiki_xhtml($ID,$REV,false);
break;
default:
$output = p_cached_output(wikiFN($ID,$REV), $mode);
$headers = p_get_metadata($ID,"format $mode");
break;
}
print $pre.$data['output'].$post;
exit;
}
return 'show';
// prepare event data
$data = array();
$data['id'] = $ID;
$data['mode'] = $mode;
$data['headers'] = $headers;
$data['output'] =& $output;
trigger_event('ACTION_EXPORT_POSTPROCESS', $data);
if(!empty($data['output'])){
if(is_array($data['headers'])) foreach($data['headers'] as $key => $val){
header("$key: $val");
}
print $pre.$data['output'].$post;
exit;
}
return 'show';
}
/**
@ -556,32 +556,32 @@ function act_export($act){
* @todo localize
*/
function act_subscription($act){
global $ID;
global $INFO;
global $lang;
global $ID;
global $INFO;
global $lang;
$file=metaFN($ID,'.mlist');
if ($act=='subscribe' && !$INFO['subscribed']){
if ($INFO['userinfo']['mail']){
if (io_saveFile($file,$_SERVER['REMOTE_USER']."\n",true)) {
$INFO['subscribed'] = true;
msg(sprintf($lang[$act.'_success'], $INFO['userinfo']['name'], $ID),1);
} else {
msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1);
}
} else {
msg($lang['subscribe_noaddress']);
$file=metaFN($ID,'.mlist');
if ($act=='subscribe' && !$INFO['subscribed']){
if ($INFO['userinfo']['mail']){
if (io_saveFile($file,$_SERVER['REMOTE_USER']."\n",true)) {
$INFO['subscribed'] = true;
msg(sprintf($lang[$act.'_success'], $INFO['userinfo']['name'], $ID),1);
} else {
msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1);
}
} else {
msg($lang['subscribe_noaddress']);
}
} elseif ($act=='unsubscribe' && $INFO['subscribed']){
if (io_deleteFromFile($file,$_SERVER['REMOTE_USER']."\n")) {
$INFO['subscribed'] = false;
msg(sprintf($lang[$act.'_success'], $INFO['userinfo']['name'], $ID),1);
} else {
msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1);
}
}
} elseif ($act=='unsubscribe' && $INFO['subscribed']){
if (io_deleteFromFile($file,$_SERVER['REMOTE_USER']."\n")) {
$INFO['subscribed'] = false;
msg(sprintf($lang[$act.'_success'], $INFO['userinfo']['name'], $ID),1);
} else {
msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1);
}
}
return 'show';
return 'show';
}
/**
@ -589,42 +589,42 @@ function act_subscription($act){
*
*/
function act_subscriptionns($act){
global $ID;
global $INFO;
global $lang;
global $ID;
global $INFO;
global $lang;
if(!getNS($ID)) {
$file = metaFN(getNS($ID),'.mlist');
$ns = "root";
} else {
$file = metaFN(getNS($ID),'/.mlist');
$ns = getNS($ID);
}
// reuse strings used to display the status of the subscribe action
$act_msg = rtrim($act, 'ns');
if ($act=='subscribens' && !$INFO['subscribedns']){
if ($INFO['userinfo']['mail']){
if (io_saveFile($file,$_SERVER['REMOTE_USER']."\n",true)) {
$INFO['subscribedns'] = true;
msg(sprintf($lang[$act_msg.'_success'], $INFO['userinfo']['name'], $ns),1);
} else {
msg(sprintf($lang[$act_msg.'_error'], $INFO['userinfo']['name'], $ns),1);
}
if(!getNS($ID)) {
$file = metaFN(getNS($ID),'.mlist');
$ns = "root";
} else {
msg($lang['subscribe_noaddress']);
$file = metaFN(getNS($ID),'/.mlist');
$ns = getNS($ID);
}
} elseif ($act=='unsubscribens' && $INFO['subscribedns']){
if (io_deleteFromFile($file,$_SERVER['REMOTE_USER']."\n")) {
$INFO['subscribedns'] = false;
msg(sprintf($lang[$act_msg.'_success'], $INFO['userinfo']['name'], $ns),1);
} else {
msg(sprintf($lang[$act_msg.'_error'], $INFO['userinfo']['name'], $ns),1);
}
}
return 'show';
// reuse strings used to display the status of the subscribe action
$act_msg = rtrim($act, 'ns');
if ($act=='subscribens' && !$INFO['subscribedns']){
if ($INFO['userinfo']['mail']){
if (io_saveFile($file,$_SERVER['REMOTE_USER']."\n",true)) {
$INFO['subscribedns'] = true;
msg(sprintf($lang[$act_msg.'_success'], $INFO['userinfo']['name'], $ns),1);
} else {
msg(sprintf($lang[$act_msg.'_error'], $INFO['userinfo']['name'], $ns),1);
}
} else {
msg($lang['subscribe_noaddress']);
}
} elseif ($act=='unsubscribens' && $INFO['subscribedns']){
if (io_deleteFromFile($file,$_SERVER['REMOTE_USER']."\n")) {
$INFO['subscribedns'] = false;
msg(sprintf($lang[$act_msg.'_success'], $INFO['userinfo']['name'], $ns),1);
} else {
msg(sprintf($lang[$act_msg.'_error'], $INFO['userinfo']['name'], $ns),1);
}
}
return 'show';
}
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@ -12,281 +12,281 @@ require_once(DOKU_INC.'inc/pageutils.php');
require_once(DOKU_INC.'inc/parserutils.php');
class cache {
var $key = ''; // primary identifier for this item
var $ext = ''; // file ext for cache data, secondary identifier for this item
var $cache = ''; // cache file name
var $depends = array(); // array containing cache dependency information,
// used by _useCache to determine cache validity
var $key = ''; // primary identifier for this item
var $ext = ''; // file ext for cache data, secondary identifier for this item
var $cache = ''; // cache file name
var $depends = array(); // array containing cache dependency information,
// used by _useCache to determine cache validity
var $_event = ''; // event to be triggered during useCache
var $_event = ''; // event to be triggered during useCache
function cache($key,$ext) {
$this->key = $key;
$this->ext = $ext;
$this->cache = getCacheName($key,$ext);
}
/**
* public method to determine whether the cache can be used
*
* to assist in cetralisation of event triggering and calculation of cache statistics,
* don't override this function override _useCache()
*
* @param array $depends array of cache dependencies, support dependecies:
* 'age' => max age of the cache in seconds
* 'files' => cache must be younger than mtime of each file
* (nb. dependency passes if file doesn't exist)
*
* @return bool true if cache can be used, false otherwise
*/
function useCache($depends=array()) {
$this->depends = $depends;
$this->_addDependencies();
if ($this->_event) {
return $this->_stats(trigger_event($this->_event,$this,array($this,'_useCache')));
} else {
return $this->_stats($this->_useCache());
}
}
/**
* private method containing cache use decision logic
*
* this function processes the following keys in the depends array
* purge - force a purge on any non empty value
* age - expire cache if older than age (seconds)
* files - expire cache if any file in this array was updated more recently than the cache
*
* can be overridden
*
* @return bool see useCache()
*/
function _useCache() {
if (!empty($this->depends['purge'])) return false; // purge requested?
if (!($this->_time = @filemtime($this->cache))) return false; // cache exists?
// cache too old?
if (!empty($this->depends['age']) && ((time() - $this->_time) > $this->depends['age'])) return false;
if (!empty($this->depends['files'])) {
foreach ($this->depends['files'] as $file) {
if ($this->_time < @filemtime($file)) return false; // cache older than files it depends on?
}
function cache($key,$ext) {
$this->key = $key;
$this->ext = $ext;
$this->cache = getCacheName($key,$ext);
}
return true;
}
/**
* public method to determine whether the cache can be used
*
* to assist in cetralisation of event triggering and calculation of cache statistics,
* don't override this function override _useCache()
*
* @param array $depends array of cache dependencies, support dependecies:
* 'age' => max age of the cache in seconds
* 'files' => cache must be younger than mtime of each file
* (nb. dependency passes if file doesn't exist)
*
* @return bool true if cache can be used, false otherwise
*/
function useCache($depends=array()) {
$this->depends = $depends;
$this->_addDependencies();
/**
* add dependencies to the depends array
*
* this method should only add dependencies,
* it should not remove any existing dependencies and
* it should only overwrite a dependency when the new value is more stringent than the old
*/
function _addDependencies() {
if (isset($_REQUEST['purge'])) $this->depends['purge'] = true; // purge requested
}
/**
* retrieve the cached data
*
* @param bool $clean true to clean line endings, false to leave line endings alone
* @return string cache contents
*/
function retrieveCache($clean=true) {
return io_readFile($this->cache, $clean);
}
/**
* cache $data
*
* @param string $data the data to be cached
* @return bool true on success, false otherwise
*/
function storeCache($data) {
return io_savefile($this->cache, $data);
}
/**
* remove any cached data associated with this cache instance
*/
function removeCache() {
@unlink($this->cache);
}
/**
* Record cache hits statistics.
* (Only when debugging allowed, to reduce overhead.)
*
* @param bool $success result of this cache use attempt
* @return bool pass-thru $success value
*/
function _stats($success) {
global $conf;
static $stats = NULL;
static $file;
if (!$conf['allowdebug']) { return $success; }
if (is_null($stats)) {
$file = $conf['cachedir'].'/cache_stats.txt';
$lines = explode("\n",io_readFile($file));
foreach ($lines as $line) {
$i = strpos($line,',');
$stats[substr($line,0,$i)] = $line;
}
if ($this->_event) {
return $this->_stats(trigger_event($this->_event,$this,array($this,'_useCache')));
} else {
return $this->_stats($this->_useCache());
}
}
if (isset($stats[$this->ext])) {
list($ext,$count,$hits) = explode(',',$stats[$this->ext]);
} else {
$ext = $this->ext;
$count = 0;
$hits = 0;
/**
* private method containing cache use decision logic
*
* this function processes the following keys in the depends array
* purge - force a purge on any non empty value
* age - expire cache if older than age (seconds)
* files - expire cache if any file in this array was updated more recently than the cache
*
* can be overridden
*
* @return bool see useCache()
*/
function _useCache() {
if (!empty($this->depends['purge'])) return false; // purge requested?
if (!($this->_time = @filemtime($this->cache))) return false; // cache exists?
// cache too old?
if (!empty($this->depends['age']) && ((time() - $this->_time) > $this->depends['age'])) return false;
if (!empty($this->depends['files'])) {
foreach ($this->depends['files'] as $file) {
if ($this->_time < @filemtime($file)) return false; // cache older than files it depends on?
}
}
return true;
}
$count++;
if ($success) $hits++;
$stats[$this->ext] = "$ext,$count,$hits";
/**
* add dependencies to the depends array
*
* this method should only add dependencies,
* it should not remove any existing dependencies and
* it should only overwrite a dependency when the new value is more stringent than the old
*/
function _addDependencies() {
if (isset($_REQUEST['purge'])) $this->depends['purge'] = true; // purge requested
}
io_saveFile($file,join("\n",$stats));
/**
* retrieve the cached data
*
* @param bool $clean true to clean line endings, false to leave line endings alone
* @return string cache contents
*/
function retrieveCache($clean=true) {
return io_readFile($this->cache, $clean);
}
return $success;
}
/**
* cache $data
*
* @param string $data the data to be cached
* @return bool true on success, false otherwise
*/
function storeCache($data) {
return io_savefile($this->cache, $data);
}
/**
* remove any cached data associated with this cache instance
*/
function removeCache() {
@unlink($this->cache);
}
/**
* Record cache hits statistics.
* (Only when debugging allowed, to reduce overhead.)
*
* @param bool $success result of this cache use attempt
* @return bool pass-thru $success value
*/
function _stats($success) {
global $conf;
static $stats = null;
static $file;
if (!$conf['allowdebug']) { return $success; }
if (is_null($stats)) {
$file = $conf['cachedir'].'/cache_stats.txt';
$lines = explode("\n",io_readFile($file));
foreach ($lines as $line) {
$i = strpos($line,',');
$stats[substr($line,0,$i)] = $line;
}
}
if (isset($stats[$this->ext])) {
list($ext,$count,$hits) = explode(',',$stats[$this->ext]);
} else {
$ext = $this->ext;
$count = 0;
$hits = 0;
}
$count++;
if ($success) $hits++;
$stats[$this->ext] = "$ext,$count,$hits";
io_saveFile($file,join("\n",$stats));
return $success;
}
}
class cache_parser extends cache {
var $file = ''; // source file for cache
var $mode = ''; // input mode (represents the processing the input file will undergo)
var $file = ''; // source file for cache
var $mode = ''; // input mode (represents the processing the input file will undergo)
var $_event = 'PARSER_CACHE_USE';
var $_event = 'PARSER_CACHE_USE';
function cache_parser($id, $file, $mode) {
if ($id) $this->page = $id;
$this->file = $file;
$this->mode = $mode;
function cache_parser($id, $file, $mode) {
if ($id) $this->page = $id;
$this->file = $file;
$this->mode = $mode;
parent::cache($file.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.'.$mode);
}
parent::cache($file.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.'.$mode);
}
function _useCache() {
function _useCache() {
if (!@file_exists($this->file)) return false; // source exists?
return parent::_useCache();
}
if (!@file_exists($this->file)) return false; // source exists?
return parent::_useCache();
}
function _addDependencies() {
global $conf, $config_cascade;
function _addDependencies() {
global $conf, $config_cascade;
$this->depends['age'] = isset($this->depends['age']) ?
min($this->depends['age'],$conf['cachetime']) : $conf['cachetime'];
$this->depends['age'] = isset($this->depends['age']) ?
min($this->depends['age'],$conf['cachetime']) : $conf['cachetime'];
// parser cache file dependencies ...
$files = array($this->file, // ... source
DOKU_INC.'inc/parser/parser.php', // ... parser
DOKU_INC.'inc/parser/handler.php', // ... handler
);
$files = array_merge($files, getConfigFiles('main')); // ... wiki settings
// parser cache file dependencies ...
$files = array($this->file, // ... source
DOKU_INC.'inc/parser/parser.php', // ... parser
DOKU_INC.'inc/parser/handler.php', // ... handler
);
$files = array_merge($files, getConfigFiles('main')); // ... wiki settings
$this->depends['files'] = !empty($this->depends['files']) ? array_merge($files, $this->depends['files']) : $files;
parent::_addDependencies();
}
$this->depends['files'] = !empty($this->depends['files']) ? array_merge($files, $this->depends['files']) : $files;
parent::_addDependencies();
}
}
class cache_renderer extends cache_parser {
function useCache($depends=array()) {
$use = parent::useCache($depends);
function useCache($depends=array()) {
$use = parent::useCache($depends);
// meta data needs to be kept in step with the cache
if (!$use && isset($this->page)) {
p_set_metadata($this->page,array(),true);
}
return $use;
}
function _useCache() {
global $conf;
if (!parent::_useCache()) return false;
if (!isset($this->page)) {
return true;
}
// check current link existence is consistent with cache version
// first check the purgefile
// - if the cache is more recent than the purgefile we know no links can have been updated
if ($this->_time >= @filemtime($conf['cachedir'].'/purgefile')) {
return true;
}
// for wiki pages, check metadata dependencies
$metadata = p_get_metadata($this->page);
if (!isset($metadata['relation']['references']) ||
empty($metadata['relation']['references'])) {
return true;
}
foreach ($metadata['relation']['references'] as $id => $exists) {
if ($exists != page_exists($id,'',false)) return false;
}
return true;
}
function _addDependencies() {
// renderer cache file dependencies ...
$files = array(
DOKU_INC.'inc/parser/'.$this->mode.'.php', // ... the renderer
);
// page implies metadata and possibly some other dependencies
if (isset($this->page)) {
$metafile = metaFN($this->page,'.meta');
if (@file_exists($metafile)) {
$files[] = $metafile; // ... the page's own metadata
$files[] = DOKU_INC.'inc/parser/metadata.php'; // ... the metadata renderer
$valid = p_get_metadata($this->page, 'date valid');
if (!empty($valid['age'])) {
$this->depends['age'] = isset($this->depends['age']) ?
min($this->depends['age'],$valid['age']) : $valid['age'];
// meta data needs to be kept in step with the cache
if (!$use && isset($this->page)) {
p_set_metadata($this->page,array(),true);
}
} else {
$this->depends['purge'] = true; // ... purging cache will generate metadata
return;
}
return $use;
}
$this->depends['files'] = !empty($this->depends['files']) ? array_merge($files, $this->depends['files']) : $files;
parent::_addDependencies();
}
function _useCache() {
global $conf;
if (!parent::_useCache()) return false;
if (!isset($this->page)) {
return true;
}
// check current link existence is consistent with cache version
// first check the purgefile
// - if the cache is more recent than the purgefile we know no links can have been updated
if ($this->_time >= @filemtime($conf['cachedir'].'/purgefile')) {
return true;
}
// for wiki pages, check metadata dependencies
$metadata = p_get_metadata($this->page);
if (!isset($metadata['relation']['references']) ||
empty($metadata['relation']['references'])) {
return true;
}
foreach ($metadata['relation']['references'] as $id => $exists) {
if ($exists != page_exists($id,'',false)) return false;
}
return true;
}
function _addDependencies() {
// renderer cache file dependencies ...
$files = array(
DOKU_INC.'inc/parser/'.$this->mode.'.php', // ... the renderer
);
// page implies metadata and possibly some other dependencies
if (isset($this->page)) {
$metafile = metaFN($this->page,'.meta');
if (@file_exists($metafile)) {
$files[] = $metafile; // ... the page's own metadata
$files[] = DOKU_INC.'inc/parser/metadata.php'; // ... the metadata renderer
$valid = p_get_metadata($this->page, 'date valid');
if (!empty($valid['age'])) {
$this->depends['age'] = isset($this->depends['age']) ?
min($this->depends['age'],$valid['age']) : $valid['age'];
}
} else {
$this->depends['purge'] = true; // ... purging cache will generate metadata
return;
}
}
$this->depends['files'] = !empty($this->depends['files']) ? array_merge($files, $this->depends['files']) : $files;
parent::_addDependencies();
}
}
class cache_instructions extends cache_parser {
function cache_instructions($id, $file) {
parent::cache_parser($id, $file, 'i');
}
function cache_instructions($id, $file) {
parent::cache_parser($id, $file, 'i');
}
function retrieveCache($clean=true) {
$contents = io_readFile($this->cache, false);
return !empty($contents) ? unserialize($contents) : array();
}
function retrieveCache($clean=true) {
$contents = io_readFile($this->cache, false);
return !empty($contents) ? unserialize($contents) : array();
}
function storeCache($instructions) {
return io_savefile($this->cache,serialize($instructions));
}
function storeCache($instructions) {
return io_savefile($this->cache,serialize($instructions));
}
}

View File

@ -20,18 +20,18 @@ define('DOKU_CHANGE_TYPE_REVERT', 'R');
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function parseChangelogLine($line) {
$tmp = explode("\t", $line);
$tmp = explode("\t", $line);
if ($tmp!==false && count($tmp)>1) {
$info = array();
$info['date'] = (int)$tmp[0]; // unix timestamp
$info['ip'] = $tmp[1]; // IPv4 address (127.0.0.1)
$info['type'] = $tmp[2]; // log line type
$info['id'] = $tmp[3]; // page id
$info['user'] = $tmp[4]; // user name
$info['sum'] = $tmp[5]; // edit summary (or action reason)
$info['extra'] = rtrim($tmp[6], "\n"); // extra data (varies by line type)
return $info;
} else { return false; }
$info = array();
$info['date'] = (int)$tmp[0]; // unix timestamp
$info['ip'] = $tmp[1]; // IPv4 address (127.0.0.1)
$info['type'] = $tmp[2]; // log line type
$info['id'] = $tmp[3]; // page id
$info['user'] = $tmp[4]; // user name
$info['sum'] = $tmp[5]; // edit summary (or action reason)
$info['extra'] = rtrim($tmp[6], "\n"); // extra data (varies by line type)
return $info;
} else { return false; }
}
/**
@ -42,57 +42,57 @@ function parseChangelogLine($line) {
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function addLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extra='', $flags=null){
global $conf, $INFO;
global $conf, $INFO;
// check for special flags as keys
if (!is_array($flags)) { $flags = array(); }
$flagExternalEdit = isset($flags['ExternalEdit']);
// check for special flags as keys
if (!is_array($flags)) { $flags = array(); }
$flagExternalEdit = isset($flags['ExternalEdit']);
$id = cleanid($id);
$file = wikiFN($id);
$created = @filectime($file);
$minor = ($type===DOKU_CHANGE_TYPE_MINOR_EDIT);
$wasRemoved = ($type===DOKU_CHANGE_TYPE_DELETE);
$id = cleanid($id);
$file = wikiFN($id);
$created = @filectime($file);
$minor = ($type===DOKU_CHANGE_TYPE_MINOR_EDIT);
$wasRemoved = ($type===DOKU_CHANGE_TYPE_DELETE);
if(!$date) $date = time(); //use current time if none supplied
$remote = (!$flagExternalEdit)?clientIP(true):'127.0.0.1';
$user = (!$flagExternalEdit)?$_SERVER['REMOTE_USER']:'';
if(!$date) $date = time(); //use current time if none supplied
$remote = (!$flagExternalEdit)?clientIP(true):'127.0.0.1';
$user = (!$flagExternalEdit)?$_SERVER['REMOTE_USER']:'';
$strip = array("\t", "\n");
$logline = array(
'date' => $date,
'ip' => $remote,
'type' => str_replace($strip, '', $type),
'id' => $id,
'user' => $user,
'sum' => str_replace($strip, '', $summary),
'extra' => str_replace($strip, '', $extra)
);
$strip = array("\t", "\n");
$logline = array(
'date' => $date,
'ip' => $remote,
'type' => str_replace($strip, '', $type),
'id' => $id,
'user' => $user,
'sum' => str_replace($strip, '', $summary),
'extra' => str_replace($strip, '', $extra)
);
// update metadata
if (!$wasRemoved) {
$oldmeta = p_read_metadata($id);
$meta = array();
if (!$INFO['exists'] && empty($oldmeta['persistent']['date']['created'])){ // newly created
$meta['date']['created'] = $created;
if ($user) $meta['creator'] = $INFO['userinfo']['name'];
} elseif (!$INFO['exists'] && !empty($oldmeta['persistent']['date']['created'])) { // re-created / restored
$meta['date']['created'] = $oldmeta['persistent']['date']['created'];
$meta['date']['modified'] = $created; // use the files ctime here
$meta['creator'] = $oldmeta['persistent']['creator'];
if ($user) $meta['contributor'][$user] = $INFO['userinfo']['name'];
} elseif (!$minor) { // non-minor modification
$meta['date']['modified'] = $date;
if ($user) $meta['contributor'][$user] = $INFO['userinfo']['name'];
// update metadata
if (!$wasRemoved) {
$oldmeta = p_read_metadata($id);
$meta = array();
if (!$INFO['exists'] && empty($oldmeta['persistent']['date']['created'])){ // newly created
$meta['date']['created'] = $created;
if ($user) $meta['creator'] = $INFO['userinfo']['name'];
} elseif (!$INFO['exists'] && !empty($oldmeta['persistent']['date']['created'])) { // re-created / restored
$meta['date']['created'] = $oldmeta['persistent']['date']['created'];
$meta['date']['modified'] = $created; // use the files ctime here
$meta['creator'] = $oldmeta['persistent']['creator'];
if ($user) $meta['contributor'][$user] = $INFO['userinfo']['name'];
} elseif (!$minor) { // non-minor modification
$meta['date']['modified'] = $date;
if ($user) $meta['contributor'][$user] = $INFO['userinfo']['name'];
}
$meta['last_change'] = $logline;
p_set_metadata($id, $meta, true);
}
$meta['last_change'] = $logline;
p_set_metadata($id, $meta, true);
}
// add changelog lines
$logline = implode("\t", $logline)."\n";
io_saveFile(metaFN($id,'.changes'),$logline,true); //page changelog
io_saveFile($conf['changelog'],$logline,true); //global changelog cache
// add changelog lines
$logline = implode("\t", $logline)."\n";
io_saveFile(metaFN($id,'.changes'),$logline,true); //page changelog
io_saveFile($conf['changelog'],$logline,true); //global changelog cache
}
/**
@ -104,28 +104,28 @@ function addLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extr
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extra='', $flags=null){
global $conf, $INFO;
global $conf, $INFO;
$id = cleanid($id);
$id = cleanid($id);
if(!$date) $date = time(); //use current time if none supplied
$remote = clientIP(true);
$user = $_SERVER['REMOTE_USER'];
if(!$date) $date = time(); //use current time if none supplied
$remote = clientIP(true);
$user = $_SERVER['REMOTE_USER'];
$strip = array("\t", "\n");
$logline = array(
'date' => $date,
'ip' => $remote,
'type' => str_replace($strip, '', $type),
'id' => $id,
'user' => $user,
'sum' => str_replace($strip, '', $summary),
'extra' => str_replace($strip, '', $extra)
);
$strip = array("\t", "\n");
$logline = array(
'date' => $date,
'ip' => $remote,
'type' => str_replace($strip, '', $type),
'id' => $id,
'user' => $user,
'sum' => str_replace($strip, '', $summary),
'extra' => str_replace($strip, '', $extra)
);
// add changelog lines
$logline = implode("\t", $logline)."\n";
io_saveFile($conf['media_changelog'],$logline,true); //global media changelog cache
// add changelog lines
$logline = implode("\t", $logline)."\n";
io_saveFile($conf['media_changelog'],$logline,true); //global media changelog cache
}
/**
@ -148,35 +148,34 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='',
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function getRecents($first,$num,$ns='',$flags=0){
global $conf;
$recent = array();
$count = 0;
global $conf;
$recent = array();
$count = 0;
if(!$num)
return $recent;
if(!$num)
return $recent;
// read all recent changes. (kept short)
if ($flags & RECENTS_MEDIA_CHANGES) {
$lines = @file($conf['media_changelog']);
} else {
$lines = @file($conf['changelog']);
}
// handle lines
$seen = array(); // caches seen lines, _handleRecent() skips them
for($i = count($lines)-1; $i >= 0; $i--){
$rec = _handleRecent($lines[$i], $ns, $flags, $seen);
if($rec !== false) {
if(--$first >= 0) continue; // skip first entries
$recent[] = $rec;
$count++;
// break when we have enough entries
if($count >= $num){ break; }
// read all recent changes. (kept short)
if ($flags & RECENTS_MEDIA_CHANGES) {
$lines = @file($conf['media_changelog']);
} else {
$lines = @file($conf['changelog']);
}
}
return $recent;
// handle lines
$seen = array(); // caches seen lines, _handleRecent() skips them
for($i = count($lines)-1; $i >= 0; $i--){
$rec = _handleRecent($lines[$i], $ns, $flags, $seen);
if($rec !== false) {
if(--$first >= 0) continue; // skip first entries
$recent[] = $rec;
$count++;
// break when we have enough entries
if($count >= $num){ break; }
}
}
return $recent;
}
/**
@ -200,39 +199,39 @@ function getRecents($first,$num,$ns='',$flags=0){
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function getRecentsSince($from,$to=null,$ns='',$flags=0){
global $conf;
$recent = array();
global $conf;
$recent = array();
if($to && $to < $from)
return $recent;
if($to && $to < $from)
return $recent;
// read all recent changes. (kept short)
if ($flags & RECENTS_MEDIA_CHANGES) {
$lines = @file($conf['media_changelog']);
} else {
$lines = @file($conf['changelog']);
}
// we start searching at the end of the list
$lines = array_reverse($lines);
// handle lines
$seen = array(); // caches seen lines, _handleRecent() skips them
foreach($lines as $line){
$rec = _handleRecent($line, $ns, $flags, $seen);
if($rec !== false) {
if ($rec['date'] >= $from) {
if (!$to || $rec['date'] <= $to) {
$recent[] = $rec;
}
} else {
break;
}
// read all recent changes. (kept short)
if ($flags & RECENTS_MEDIA_CHANGES) {
$lines = @file($conf['media_changelog']);
} else {
$lines = @file($conf['changelog']);
}
}
return array_reverse($recent);
// we start searching at the end of the list
$lines = array_reverse($lines);
// handle lines
$seen = array(); // caches seen lines, _handleRecent() skips them
foreach($lines as $line){
$rec = _handleRecent($line, $ns, $flags, $seen);
if($rec !== false) {
if ($rec['date'] >= $from) {
if (!$to || $rec['date'] <= $to) {
$recent[] = $rec;
}
} else {
break;
}
}
}
return array_reverse($recent);
}
/**
@ -245,39 +244,39 @@ function getRecentsSince($from,$to=null,$ns='',$flags=0){
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function _handleRecent($line,$ns,$flags,&$seen){
if(empty($line)) return false; //skip empty lines
if(empty($line)) return false; //skip empty lines
// split the line into parts
$recent = parseChangelogLine($line);
if ($recent===false) { return false; }
// split the line into parts
$recent = parseChangelogLine($line);
if ($recent===false) { return false; }
// skip seen ones
if(isset($seen[$recent['id']])) return false;
// skip seen ones
if(isset($seen[$recent['id']])) return false;
// skip minors
if($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT && ($flags & RECENTS_SKIP_MINORS)) return false;
// skip minors
if($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT && ($flags & RECENTS_SKIP_MINORS)) return false;
// remember in seen to skip additional sights
$seen[$recent['id']] = 1;
// remember in seen to skip additional sights
$seen[$recent['id']] = 1;
// check if it's a hidden page
if(isHiddenPage($recent['id'])) return false;
// check if it's a hidden page
if(isHiddenPage($recent['id'])) return false;
// filter namespace
if (($ns) && (strpos($recent['id'],$ns.':') !== 0)) return false;
// filter namespace
if (($ns) && (strpos($recent['id'],$ns.':') !== 0)) return false;
// exclude subnamespaces
if (($flags & RECENTS_SKIP_SUBSPACES) && (getNS($recent['id']) != $ns)) return false;
// exclude subnamespaces
if (($flags & RECENTS_SKIP_SUBSPACES) && (getNS($recent['id']) != $ns)) return false;
// check ACL
$recent['perms'] = auth_quickaclcheck($recent['id']);
if ($recent['perms'] < AUTH_READ) return false;
// check ACL
$recent['perms'] = auth_quickaclcheck($recent['id']);
if ($recent['perms'] < AUTH_READ) return false;
// check existance
$fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id']));
if((!@file_exists($fn)) && ($flags & RECENTS_SKIP_DELETED)) return false;
// check existance
$fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id']));
if((!@file_exists($fn)) && ($flags & RECENTS_SKIP_DELETED)) return false;
return $recent;
return $recent;
}
/**
@ -291,80 +290,80 @@ function _handleRecent($line,$ns,$flags,&$seen){
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function getRevisionInfo($id, $rev, $chunk_size=8192) {
global $cache_revinfo;
$cache =& $cache_revinfo;
if (!isset($cache[$id])) { $cache[$id] = array(); }
$rev = max($rev, 0);
global $cache_revinfo;
$cache =& $cache_revinfo;
if (!isset($cache[$id])) { $cache[$id] = array(); }
$rev = max($rev, 0);
// check if it's already in the memory cache
if (isset($cache[$id]) && isset($cache[$id][$rev])) {
// check if it's already in the memory cache
if (isset($cache[$id]) && isset($cache[$id][$rev])) {
return $cache[$id][$rev];
}
$file = metaFN($id, '.changes');
if (!@file_exists($file)) { return false; }
if (filesize($file)<$chunk_size || $chunk_size==0) {
// read whole file
$lines = file($file);
if ($lines===false) { return false; }
} else {
// read by chunk
$fp = fopen($file, 'rb'); // "file pointer"
if ($fp===false) { return false; }
$head = 0;
fseek($fp, 0, SEEK_END);
$tail = ftell($fp);
$finger = 0;
$finger_rev = 0;
// find chunk
while ($tail-$head>$chunk_size) {
$finger = $head+floor(($tail-$head)/2.0);
fseek($fp, $finger);
fgets($fp); // slip the finger forward to a new line
$finger = ftell($fp);
$tmp = fgets($fp); // then read at that location
$tmp = parseChangelogLine($tmp);
$finger_rev = $tmp['date'];
if ($finger==$head || $finger==$tail) { break; }
if ($finger_rev>$rev) {
$tail = $finger;
} else {
$head = $finger;
}
}
if ($tail-$head<1) {
// cound not find chunk, assume requested rev is missing
fclose($fp);
return false;
}
// read chunk
$chunk = '';
$chunk_size = max($tail-$head, 0); // found chunk size
$got = 0;
fseek($fp, $head);
while ($got<$chunk_size && !feof($fp)) {
$tmp = @fread($fp, max($chunk_size-$got, 0));
if ($tmp===false) { break; } //error state
$got += strlen($tmp);
$chunk .= $tmp;
}
$lines = explode("\n", $chunk);
array_pop($lines); // remove trailing newline
fclose($fp);
}
// parse and cache changelog lines
foreach ($lines as $value) {
$tmp = parseChangelogLine($value);
if ($tmp!==false) {
$cache[$id][$tmp['date']] = $tmp;
}
}
if (!isset($cache[$id][$rev])) { return false; }
return $cache[$id][$rev];
}
$file = metaFN($id, '.changes');
if (!@file_exists($file)) { return false; }
if (filesize($file)<$chunk_size || $chunk_size==0) {
// read whole file
$lines = file($file);
if ($lines===false) { return false; }
} else {
// read by chunk
$fp = fopen($file, 'rb'); // "file pointer"
if ($fp===false) { return false; }
$head = 0;
fseek($fp, 0, SEEK_END);
$tail = ftell($fp);
$finger = 0;
$finger_rev = 0;
// find chunk
while ($tail-$head>$chunk_size) {
$finger = $head+floor(($tail-$head)/2.0);
fseek($fp, $finger);
fgets($fp); // slip the finger forward to a new line
$finger = ftell($fp);
$tmp = fgets($fp); // then read at that location
$tmp = parseChangelogLine($tmp);
$finger_rev = $tmp['date'];
if ($finger==$head || $finger==$tail) { break; }
if ($finger_rev>$rev) {
$tail = $finger;
} else {
$head = $finger;
}
}
if ($tail-$head<1) {
// cound not find chunk, assume requested rev is missing
fclose($fp);
return false;
}
// read chunk
$chunk = '';
$chunk_size = max($tail-$head, 0); // found chunk size
$got = 0;
fseek($fp, $head);
while ($got<$chunk_size && !feof($fp)) {
$tmp = @fread($fp, max($chunk_size-$got, 0));
if ($tmp===false) { break; } //error state
$got += strlen($tmp);
$chunk .= $tmp;
}
$lines = explode("\n", $chunk);
array_pop($lines); // remove trailing newline
fclose($fp);
}
// parse and cache changelog lines
foreach ($lines as $value) {
$tmp = parseChangelogLine($value);
if ($tmp!==false) {
$cache[$id][$tmp['date']] = $tmp;
}
}
if (!isset($cache[$id][$rev])) { return false; }
return $cache[$id][$rev];
}
/**
@ -388,87 +387,87 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) {
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function getRevisions($id, $first, $num, $chunk_size=8192) {
global $cache_revinfo;
$cache =& $cache_revinfo;
if (!isset($cache[$id])) { $cache[$id] = array(); }
global $cache_revinfo;
$cache =& $cache_revinfo;
if (!isset($cache[$id])) { $cache[$id] = array(); }
$revs = array();
$lines = array();
$count = 0;
$file = metaFN($id, '.changes');
$num = max($num, 0);
$chunk_size = max($chunk_size, 0);
if ($first<0) { $first = 0; }
else if (@file_exists(wikiFN($id))) {
// skip current revision if the page exists
$first = max($first+1, 0);
}
$revs = array();
$lines = array();
$count = 0;
$file = metaFN($id, '.changes');
$num = max($num, 0);
$chunk_size = max($chunk_size, 0);
if ($first<0) { $first = 0; }
else if (@file_exists(wikiFN($id))) {
// skip current revision if the page exists
$first = max($first+1, 0);
}
if (!@file_exists($file)) { return $revs; }
if (filesize($file)<$chunk_size || $chunk_size==0) {
// read whole file
$lines = file($file);
if ($lines===false) { return $revs; }
} else {
// read chunks backwards
$fp = fopen($file, 'rb'); // "file pointer"
if ($fp===false) { return $revs; }
fseek($fp, 0, SEEK_END);
$tail = ftell($fp);
if (!@file_exists($file)) { return $revs; }
if (filesize($file)<$chunk_size || $chunk_size==0) {
// read whole file
$lines = file($file);
if ($lines===false) { return $revs; }
} else {
// read chunks backwards
$fp = fopen($file, 'rb'); // "file pointer"
if ($fp===false) { return $revs; }
fseek($fp, 0, SEEK_END);
$tail = ftell($fp);
// chunk backwards
$finger = max($tail-$chunk_size, 0);
while ($count<$num+$first) {
fseek($fp, $finger);
if ($finger>0) {
fgets($fp); // slip the finger forward to a new line
$finger = ftell($fp);
}
// read chunk
if ($tail<=$finger) { break; }
$chunk = '';
$read_size = max($tail-$finger, 0); // found chunk size
$got = 0;
while ($got<$read_size && !feof($fp)) {
$tmp = @fread($fp, max($read_size-$got, 0));
if ($tmp===false) { break; } //error state
$got += strlen($tmp);
$chunk .= $tmp;
}
$tmp = explode("\n", $chunk);
array_pop($tmp); // remove trailing newline
// combine with previous chunk
$count += count($tmp);
$lines = array_merge($tmp, $lines);
// next chunk
if ($finger==0) { break; } // already read all the lines
else {
$tail = $finger;
// chunk backwards
$finger = max($tail-$chunk_size, 0);
}
while ($count<$num+$first) {
fseek($fp, $finger);
if ($finger>0) {
fgets($fp); // slip the finger forward to a new line
$finger = ftell($fp);
}
// read chunk
if ($tail<=$finger) { break; }
$chunk = '';
$read_size = max($tail-$finger, 0); // found chunk size
$got = 0;
while ($got<$read_size && !feof($fp)) {
$tmp = @fread($fp, max($read_size-$got, 0));
if ($tmp===false) { break; } //error state
$got += strlen($tmp);
$chunk .= $tmp;
}
$tmp = explode("\n", $chunk);
array_pop($tmp); // remove trailing newline
// combine with previous chunk
$count += count($tmp);
$lines = array_merge($tmp, $lines);
// next chunk
if ($finger==0) { break; } // already read all the lines
else {
$tail = $finger;
$finger = max($tail-$chunk_size, 0);
}
}
fclose($fp);
}
fclose($fp);
}
// skip parsing extra lines
$num = max(min(count($lines)-$first, $num), 0);
if ($first>0 && $num>0) { $lines = array_slice($lines, max(count($lines)-$first-$num, 0), $num); }
else if ($first>0 && $num==0) { $lines = array_slice($lines, 0, max(count($lines)-$first, 0)); }
else if ($first==0 && $num>0) { $lines = array_slice($lines, max(count($lines)-$num, 0)); }
// skip parsing extra lines
$num = max(min(count($lines)-$first, $num), 0);
if ($first>0 && $num>0) { $lines = array_slice($lines, max(count($lines)-$first-$num, 0), $num); }
else if ($first>0 && $num==0) { $lines = array_slice($lines, 0, max(count($lines)-$first, 0)); }
else if ($first==0 && $num>0) { $lines = array_slice($lines, max(count($lines)-$num, 0)); }
// handle lines in reverse order
for ($i = count($lines)-1; $i >= 0; $i--) {
$tmp = parseChangelogLine($lines[$i]);
if ($tmp!==false) {
$cache[$id][$tmp['date']] = $tmp;
$revs[] = $tmp['date'];
// handle lines in reverse order
for ($i = count($lines)-1; $i >= 0; $i--) {
$tmp = parseChangelogLine($lines[$i]);
if ($tmp!==false) {
$cache[$id][$tmp['date']] = $tmp;
$revs[] = $tmp['date'];
}
}
}
return $revs;
return $revs;
}

View File

@ -1,7 +1,7 @@
<?php
/**
* Brutally chopped and modified from http://pear.php.net/package/Console_Getopts
*/
* Brutally chopped and modified from http://pear.php.net/package/Console_Getopts
*/
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
@ -23,10 +23,10 @@
//------------------------------------------------------------------------------
/**
* Sets up CLI environment based on SAPI and PHP version
* Helps resolve some issues between the CGI and CLI SAPIs
* as well is inconsistencies between PHP 4.3+ and older versions
*/
* Sets up CLI environment based on SAPI and PHP version
* Helps resolve some issues between the CGI and CLI SAPIs
* as well is inconsistencies between PHP 4.3+ and older versions
*/
if (version_compare(phpversion(), '4.3.0', '<') || php_sapi_name() == 'cgi') {
// Handle output buffering
@ob_end_flush();
@ -67,16 +67,16 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
* @author Andrei Zmievski <andrei@php.net>
*
*/
class Doku_Cli_Opts {
class Doku_Cli_Opts {
/**
* <?php ?>
* @see http://www.sitepoint.com/article/php-command-line-1/3
* @param string executing file name - this MUST be passed the __FILE__ constant
* @param string short options
* @param array (optional) long options
* @return Doku_Cli_Opts_Container or Doku_Cli_Opts_Error
*/
* <?php ?>
* @see http://www.sitepoint.com/article/php-command-line-1/3
* @param string executing file name - this MUST be passed the __FILE__ constant
* @param string short options
* @param array (optional) long options
* @return Doku_Cli_Opts_Container or Doku_Cli_Opts_Error
*/
function & getOptions($bin_file, $short_options, $long_options = null) {
$args = Doku_Cli_Opts::readPHPArgv();
@ -168,7 +168,8 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
}
function _parseShortOption($arg, $short_options, &$opts, &$args) {
for ($i = 0; $i < strlen($arg); $i++) {
$len = strlen($arg);
for ($i = 0; $i < $len; $i++) {
$opt = $arg{$i};
$opt_arg = null;
@ -212,8 +213,9 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
function _parseLongOption($arg, $long_options, &$opts, &$args) {
@list($opt, $opt_arg) = explode('=', $arg);
$opt_len = strlen($opt);
$opt_cnt = count($long_options);
for ($i = 0; $i < count($long_options); $i++) {
for ($i = 0; $i < $opt_cnt; $i++) {
$long_opt = $long_options[$i];
$opt_start = substr($long_opt, 0, $opt_len);
@ -226,7 +228,7 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
/* Check that the options uniquely matches one of the allowed
options. */
if ($opt_rest != '' && $opt{0} != '=' &&
$i + 1 < count($long_options) &&
$i + 1 < $opt_cnt &&
$opt == substr($long_options[$i+1], 0, $opt_len)) {
return Doku_Cli_Opts::raiseError(
DOKU_CLI_OPTS_OPT_ABIGUOUS,
@ -326,7 +328,6 @@ class Doku_Cli_Opts_Container {
$this->options[$opt_name] = $option[1];
}
$this->args = $options[1];
}

File diff suppressed because it is too large Load Diff

View File

@ -16,29 +16,29 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
function mimetype($file, $knownonly=true){
$ret = array(false,false,false); // return array
$mtypes = getMimeTypes(); // known mimetypes
$exts = join('|',array_keys($mtypes)); // known extensions (regexp)
if(!$knownonly){
$exts = $exts.'|[_\-A-Za-z0-9]+'; // any extension
}
if(preg_match('#\.('.$exts.')$#i',$file,$matches)){
$ext = strtolower($matches[1]);
}
if($ext){
if (isset($mtypes[$ext])){
if($mtypes[$ext][0] == '!'){
$ret = array($ext, substr($mtypes[$ext],1), true);
}else{
$ret = array($ext, $mtypes[$ext], false);
}
}elseif(!$knownonly){
$ret = array($ext, 'application/octet-stream', true);
$ret = array(false,false,false); // return array
$mtypes = getMimeTypes(); // known mimetypes
$exts = join('|',array_keys($mtypes)); // known extensions (regexp)
if(!$knownonly){
$exts = $exts.'|[_\-A-Za-z0-9]+'; // any extension
}
if(preg_match('#\.('.$exts.')$#i',$file,$matches)){
$ext = strtolower($matches[1]);
}
}
return $ret;
if($ext){
if (isset($mtypes[$ext])){
if($mtypes[$ext][0] == '!'){
$ret = array($ext, substr($mtypes[$ext],1), true);
}else{
$ret = array($ext, $mtypes[$ext], false);
}
}elseif(!$knownonly){
$ret = array($ext, 'application/octet-stream', true);
}
}
return $ret;
}
/**
@ -47,11 +47,11 @@ function mimetype($file, $knownonly=true){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function getMimeTypes() {
static $mime = NULL;
if ( !$mime ) {
$mime = retrieveConfig('mime','confToHash');
}
return $mime;
static $mime = null;
if ( !$mime ) {
$mime = retrieveConfig('mime','confToHash');
}
return $mime;
}
/**
@ -60,11 +60,11 @@ function getMimeTypes() {
* @author Harry Fuecks <hfuecks@gmail.com>
*/
function getAcronyms() {
static $acronyms = NULL;
if ( !$acronyms ) {
$acronyms = retrieveConfig('acronyms','confToHash');
}
return $acronyms;
static $acronyms = null;
if ( !$acronyms ) {
$acronyms = retrieveConfig('acronyms','confToHash');
}
return $acronyms;
}
/**
@ -73,11 +73,11 @@ function getAcronyms() {
* @author Harry Fuecks <hfuecks@gmail.com>
*/
function getSmileys() {
static $smileys = NULL;
if ( !$smileys ) {
$smileys = retrieveConfig('smileys','confToHash');
}
return $smileys;
static $smileys = null;
if ( !$smileys ) {
$smileys = retrieveConfig('smileys','confToHash');
}
return $smileys;
}
/**
@ -86,11 +86,11 @@ function getSmileys() {
* @author Harry Fuecks <hfuecks@gmail.com>
*/
function getEntities() {
static $entities = NULL;
if ( !$entities ) {
$entities = retrieveConfig('entities','confToHash');
}
return $entities;
static $entities = null;
if ( !$entities ) {
$entities = retrieveConfig('entities','confToHash');
}
return $entities;
}
/**
@ -99,13 +99,13 @@ function getEntities() {
* @author Harry Fuecks <hfuecks@gmail.com>
*/
function getInterwiki() {
static $wikis = NULL;
if ( !$wikis ) {
$wikis = retrieveConfig('interwiki','confToHash',array(true));
}
//add sepecial case 'this'
$wikis['this'] = DOKU_URL.'{NAME}';
return $wikis;
static $wikis = null;
if ( !$wikis ) {
$wikis = retrieveConfig('interwiki','confToHash',array(true));
}
//add sepecial case 'this'
$wikis['this'] = DOKU_URL.'{NAME}';
return $wikis;
}
/**
@ -113,23 +113,23 @@ function getInterwiki() {
*
*/
function getWordblocks() {
static $wordblocks = NULL;
if ( !$wordblocks ) {
$wordblocks = retrieveConfig('wordblock','file');
}
return $wordblocks;
static $wordblocks = null;
if ( !$wordblocks ) {
$wordblocks = retrieveConfig('wordblock','file');
}
return $wordblocks;
}
function getSchemes() {
static $schemes = NULL;
if ( !$schemes ) {
$schemes = retrieveConfig('scheme','file');
}
$schemes = array_map('trim', $schemes);
$schemes = preg_replace('/^#.*/', '', $schemes);
$schemes = array_filter($schemes);
return $schemes;
static $schemes = null;
if ( !$schemes ) {
$schemes = retrieveConfig('scheme','file');
}
$schemes = array_map('trim', $schemes);
$schemes = preg_replace('/^#.*/', '', $schemes);
$schemes = array_filter($schemes);
return $schemes;
}
/**
@ -143,22 +143,22 @@ function getSchemes() {
* @author Gina Haeussge <gina@foosel.net>
*/
function linesToHash($lines, $lower=false) {
foreach ( $lines as $line ) {
//ignore comments (except escaped ones)
$line = preg_replace('/(?<![&\\\\])#.*$/','',$line);
$line = str_replace('\\#','#',$line);
$line = trim($line);
if(empty($line)) continue;
$line = preg_split('/\s+/',$line,2);
// Build the associative array
if($lower){
$conf[strtolower($line[0])] = $line[1];
}else{
$conf[$line[0]] = $line[1];
foreach ( $lines as $line ) {
//ignore comments (except escaped ones)
$line = preg_replace('/(?<![&\\\\])#.*$/','',$line);
$line = str_replace('\\#','#',$line);
$line = trim($line);
if(empty($line)) continue;
$line = preg_split('/\s+/',$line,2);
// Build the associative array
if($lower){
$conf[strtolower($line[0])] = $line[1];
}else{
$conf[$line[0]] = $line[1];
}
}
}
return $conf;
return $conf;
}
/**
@ -172,11 +172,11 @@ function linesToHash($lines, $lower=false) {
* @author Gina Haeussge <gina@foosel.net>
*/
function confToHash($file,$lower=false) {
$conf = array();
$lines = @file( $file );
if ( !$lines ) return $conf;
$conf = array();
$lines = @file( $file );
if ( !$lines ) return $conf;
return linesToHash($lines, $lower);
return linesToHash($lines, $lower);
}
/**
@ -190,23 +190,23 @@ function confToHash($file,$lower=false) {
* @return array configuration values
*/
function retrieveConfig($type,$fn,$params=null) {
global $config_cascade;
global $config_cascade;
if(!is_array($params)) $params = array();
if(!is_array($params)) $params = array();
$combined = array();
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING);
foreach (array('default','local','protected') as $config_group) {
if (empty($config_cascade[$type][$config_group])) continue;
foreach ($config_cascade[$type][$config_group] as $file) {
if (@file_exists($file)) {
$config = call_user_func_array($fn,array_merge(array($file),$params));
$combined = array_merge($combined, $config);
}
$combined = array();
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING);
foreach (array('default','local','protected') as $config_group) {
if (empty($config_cascade[$type][$config_group])) continue;
foreach ($config_cascade[$type][$config_group] as $file) {
if (@file_exists($file)) {
$config = call_user_func_array($fn,array_merge(array($file),$params));
$combined = array_merge($combined, $config);
}
}
}
}
return $combined;
return $combined;
}
/**
@ -218,16 +218,16 @@ function retrieveConfig($type,$fn,$params=null) {
* @return array list of files, default before local before protected
*/
function getConfigFiles($type) {
global $config_cascade;
$files = array();
global $config_cascade;
$files = array();
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING);
foreach (array('default','local','protected') as $config_group) {
if (empty($config_cascade[$type][$config_group])) continue;
$files = array_merge($files, $config_cascade[$type][$config_group]);
}
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING);
foreach (array('default','local','protected') as $config_group) {
if (empty($config_cascade[$type][$config_group])) continue;
$files = array_merge($files, $config_cascade[$type][$config_group]);
}
return $files;
return $files;
}
/**
@ -237,23 +237,23 @@ function getConfigFiles($type) {
* @returns boolean true if enabled, false if disabled
*/
function actionOK($action){
static $disabled = null;
if(is_null($disabled)){
global $conf;
static $disabled = null;
if(is_null($disabled)){
global $conf;
// prepare disabled actions array and handle legacy options
$disabled = explode(',',$conf['disableactions']);
$disabled = array_map('trim',$disabled);
if(isset($conf['openregister']) && !$conf['openregister']) $disabled[] = 'register';
if(isset($conf['resendpasswd']) && !$conf['resendpasswd']) $disabled[] = 'resendpwd';
if(isset($conf['subscribers']) && !$conf['subscribers']) {
$disabled[] = 'subscribe';
$disabled[] = 'subscribens';
// prepare disabled actions array and handle legacy options
$disabled = explode(',',$conf['disableactions']);
$disabled = array_map('trim',$disabled);
if(isset($conf['openregister']) && !$conf['openregister']) $disabled[] = 'register';
if(isset($conf['resendpasswd']) && !$conf['resendpasswd']) $disabled[] = 'resendpwd';
if(isset($conf['subscribers']) && !$conf['subscribers']) {
$disabled[] = 'subscribe';
$disabled[] = 'subscribens';
}
$disabled = array_unique($disabled);
}
$disabled = array_unique($disabled);
}
return !in_array($action,$disabled);
return !in_array($action,$disabled);
}
/**
@ -266,25 +266,30 @@ function actionOK($action){
* @returns boolean true if headings should be used for $linktype, false otherwise
*/
function useHeading($linktype) {
static $useHeading = null;
static $useHeading = null;
if (is_null($useHeading)) {
global $conf;
if (is_null($useHeading)) {
global $conf;
if (!empty($conf['useheading'])) {
switch ($conf['useheading']) {
case 'content' : $useHeading['content'] = true; break;
case 'navigation' : $useHeading['navigation'] = true; break;
default:
$useHeading['content'] = true;
$useHeading['navigation'] = true;
}
} else {
$useHeading = array();
if (!empty($conf['useheading'])) {
switch ($conf['useheading']) {
case 'content':
$useHeading['content'] = true;
break;
case 'navigation':
$useHeading['navigation'] = true;
break;
default:
$useHeading['content'] = true;
$useHeading['navigation'] = true;
}
} else {
$useHeading = array();
}
}
}
return (!empty($useHeading[$linktype]));
return (!empty($useHeading[$linktype]));
}
/**
@ -295,13 +300,13 @@ function useHeading($linktype) {
* @return string the encoded value
*/
function conf_encodeString($str,$code) {
switch ($code) {
case 'base64' : return '<b>'.base64_encode($str);
case 'uuencode' : return '<u>'.convert_uuencode($str);
case 'plain':
default:
return $str;
}
switch ($code) {
case 'base64' : return '<b>'.base64_encode($str);
case 'uuencode' : return '<u>'.convert_uuencode($str);
case 'plain':
default:
return $str;
}
}
/**
* return obscured data as plain text
@ -310,11 +315,11 @@ function conf_encodeString($str,$code) {
* @return string plain text
*/
function conf_decodeString($str) {
switch (substr($str,0,3)) {
case '<b>' : return base64_decode(substr($str,3));
case '<u>' : return convert_uudecode(substr($str,3));
default: // not encode (or unknown)
return $str;
}
switch (substr($str,0,3)) {
case '<b>' : return base64_decode(substr($str,3));
case '<u>' : return convert_uudecode(substr($str,3));
default: // not encode (or unknown)
return $str;
}
}
//Setup VIM: ex: et ts=2 enc=utf-8 :
//Setup VIM: ex: et ts=4 enc=utf-8 :

View File

@ -11,190 +11,190 @@ require_once(DOKU_INC.'inc/pluginutils.php');
class Doku_Event {
// public properties
var $name = ''; // READONLY event name, objects must register against this name to see the event
var $data = NULL; // READWRITE data relevant to the event, no standardised format (YET!)
var $result = NULL; // READWRITE the results of the event action, only relevant in "_AFTER" advise
// event handlers may modify this if they are preventing the default action
// to provide the after event handlers with event results
var $canPreventDefault = true; // READONLY if true, event handlers can prevent the events default action
// public properties
var $name = ''; // READONLY event name, objects must register against this name to see the event
var $data = null; // READWRITE data relevant to the event, no standardised format (YET!)
var $result = null; // READWRITE the results of the event action, only relevant in "_AFTER" advise
// event handlers may modify this if they are preventing the default action
// to provide the after event handlers with event results
var $canPreventDefault = true; // READONLY if true, event handlers can prevent the events default action
// private properties, event handlers can effect these through the provided methods
var $_default = true; // whether or not to carry out the default action associated with the event
var $_continue = true; // whether or not to continue propagating the event to other handlers
// private properties, event handlers can effect these through the provided methods
var $_default = true; // whether or not to carry out the default action associated with the event
var $_continue = true; // whether or not to continue propagating the event to other handlers
/**
* event constructor
*/
function Doku_Event($name, &$data) {
/**
* event constructor
*/
function Doku_Event($name, &$data) {
$this->name = $name;
$this->data =& $data;
$this->name = $name;
$this->data =& $data;
}
/**
* advise functions
*
* advise all registered handlers of this event
*
* if these methods are used by functions outside of this object, they must
* properly handle correct processing of any default action and issue an
* advise_after() signal. e.g.
* $evt = new Doku_Event(name, data);
* if ($evt->advise_before(canPreventDefault) {
* // default action code block
* }
* $evt->advise_after();
* unset($evt);
*
* @return results of processing the event, usually $this->_default
*/
function advise_before($enablePreventDefault=true) {
global $EVENT_HANDLER;
$this->canPreventDefault = $enablePreventDefault;
$EVENT_HANDLER->process_event($this,'BEFORE');
return (!$enablePreventDefault || $this->_default);
}
function advise_after() {
global $EVENT_HANDLER;
$this->_continue = true;
$EVENT_HANDLER->process_event($this,'AFTER');
}
/**
* trigger
*
* - advise all registered (<event>_BEFORE) handlers that this event is about to take place
* - carry out the default action using $this->data based on $enablePrevent and
* $this->_default, all of which may have been modified by the event handlers.
* - advise all registered (<event>_AFTER) handlers that the event has taken place
*
* @return $event->results
* the value set by any <event>_before or <event> handlers if the default action is prevented
* or the results of the default action (as modified by <event>_after handlers)
* or NULL no action took place and no handler modified the value
*/
function trigger($action=NULL, $enablePrevent=true) {
if (!is_callable($action)) $enablePrevent = false;
if ($this->advise_before($enablePrevent) && is_callable($action)) {
if (is_array($action)) {
list($obj,$method) = $action;
$this->result = $obj->$method($this->data);
} else {
$this->result = $action($this->data);
}
}
$this->advise_after();
/**
* advise functions
*
* advise all registered handlers of this event
*
* if these methods are used by functions outside of this object, they must
* properly handle correct processing of any default action and issue an
* advise_after() signal. e.g.
* $evt = new Doku_Event(name, data);
* if ($evt->advise_before(canPreventDefault) {
* // default action code block
* }
* $evt->advise_after();
* unset($evt);
*
* @return results of processing the event, usually $this->_default
*/
function advise_before($enablePreventDefault=true) {
global $EVENT_HANDLER;
return $this->result;
}
$this->canPreventDefault = $enablePreventDefault;
$EVENT_HANDLER->process_event($this,'BEFORE');
/**
* stopPropagation
*
* stop any further processing of the event by event handlers
* this function does not prevent the default action taking place
*/
function stopPropagation() { $this->_continue = false; }
return (!$enablePreventDefault || $this->_default);
}
/**
* preventDefault
*
* prevent the default action taking place
*/
function preventDefault() { $this->_default = false; }
function advise_after() {
global $EVENT_HANDLER;
$this->_continue = true;
$EVENT_HANDLER->process_event($this,'AFTER');
}
/**
* trigger
*
* - advise all registered (<event>_BEFORE) handlers that this event is about to take place
* - carry out the default action using $this->data based on $enablePrevent and
* $this->_default, all of which may have been modified by the event handlers.
* - advise all registered (<event>_AFTER) handlers that the event has taken place
*
* @return $event->results
* the value set by any <event>_before or <event> handlers if the default action is prevented
* or the results of the default action (as modified by <event>_after handlers)
* or NULL no action took place and no handler modified the value
*/
function trigger($action=null, $enablePrevent=true) {
if (!is_callable($action)) $enablePrevent = false;
if ($this->advise_before($enablePrevent) && is_callable($action)) {
if (is_array($action)) {
list($obj,$method) = $action;
$this->result = $obj->$method($this->data);
} else {
$this->result = $action($this->data);
}
}
$this->advise_after();
return $this->result;
}
/**
* stopPropagation
*
* stop any further processing of the event by event handlers
* this function does not prevent the default action taking place
*/
function stopPropagation() { $this->_continue = false; }
/**
* preventDefault
*
* prevent the default action taking place
*/
function preventDefault() { $this->_default = false; }
}
class Doku_Event_Handler {
// public properties: none
// public properties: none
// private properties
var $_hooks = array(); // array of events and their registered handlers
// private properties
var $_hooks = array(); // array of events and their registered handlers
/**
* event_handler
*
* constructor, loads all action plugins and calls their register() method giving them
* an opportunity to register any hooks they require
*/
function Doku_Event_Handler() {
/**
* event_handler
*
* constructor, loads all action plugins and calls their register() method giving them
* an opportunity to register any hooks they require
*/
function Doku_Event_Handler() {
// load action plugins
$plugin = NULL;
$pluginlist = plugin_list('action');
// load action plugins
$plugin = null;
$pluginlist = plugin_list('action');
foreach ($pluginlist as $plugin_name) {
$plugin =& plugin_load('action',$plugin_name);
foreach ($pluginlist as $plugin_name) {
$plugin =& plugin_load('action',$plugin_name);
if ($plugin !== NULL) $plugin->register($this);
}
}
/**
* register_hook
*
* register a hook for an event
*
* @PARAM $event (string) name used by the event, (incl '_before' or '_after' for triggers)
* @PARAM $obj (obj) object in whose scope method is to be executed,
* if NULL, method is assumed to be a globally available function
* @PARAM $method (function) event handler function
* @PARAM $param (mixed) data passed to the event handler
*/
function register_hook($event, $advise, &$obj, $method, $param=NULL) {
$this->_hooks[$event.'_'.$advise][] = array(&$obj, $method, $param);
}
function process_event(&$event,$advise='') {
$evt_name = $event->name . ($advise ? '_'.$advise : '_BEFORE');
if (!empty($this->_hooks[$evt_name])) {
$hook = reset($this->_hooks[$evt_name]);
do {
// list($obj, $method, $param) = $hook;
$obj =& $hook[0];
$method = $hook[1];
$param = $hook[2];
if (is_null($obj)) {
$method($event, $param);
} else {
$obj->$method($event, $param);
if ($plugin !== null) $plugin->register($this);
}
}
/**
* register_hook
*
* register a hook for an event
*
* @param $event (string) name used by the event, (incl '_before' or '_after' for triggers)
* @param $obj (obj) object in whose scope method is to be executed,
* if NULL, method is assumed to be a globally available function
* @param $method (function) event handler function
* @param $param (mixed) data passed to the event handler
*/
function register_hook($event, $advise, &$obj, $method, $param=null) {
$this->_hooks[$event.'_'.$advise][] = array(&$obj, $method, $param);
}
function process_event(&$event,$advise='') {
$evt_name = $event->name . ($advise ? '_'.$advise : '_BEFORE');
if (!empty($this->_hooks[$evt_name])) {
$hook = reset($this->_hooks[$evt_name]);
do {
// list($obj, $method, $param) = $hook;
$obj =& $hook[0];
$method = $hook[1];
$param = $hook[2];
if (is_null($obj)) {
$method($event, $param);
} else {
$obj->$method($event, $param);
}
} while ($event->_continue && $hook = next($this->_hooks[$evt_name]));
}
} while ($event->_continue && $hook = next($this->_hooks[$evt_name]));
}
}
}
/**
* trigger_event
* trigger_event
*
* function wrapper to process (create, trigger and destroy) an event
* function wrapper to process (create, trigger and destroy) an event
*
* @PARAM $name (string) name for the event
* @PARAM $data (mixed) event data
* @PARAM $action (callback) (optional, default=NULL) default action, a php callback function
* @PARAM $canPreventDefault (bool) (optional, default=true) can hooks prevent the default action
* @param $name (string) name for the event
* @param $data (mixed) event data
* @param $action (callback) (optional, default=NULL) default action, a php callback function
* @param $canPreventDefault (bool) (optional, default=true) can hooks prevent the default action
*
* @RETURN (mixed) the event results value after all event processing is complete
* @return (mixed) the event results value after all event processing is complete
* by default this is the return value of the default action however
* it can be set or modified by event handler hooks
*/
function trigger_event($name, &$data, $action=NULL, $canPreventDefault=true) {
function trigger_event($name, &$data, $action=null, $canPreventDefault=true) {
$evt = new Doku_Event($name, $data);
return $evt->trigger($action, $canPreventDefault);
$evt = new Doku_Event($name, $data);
return $evt->trigger($action, $canPreventDefault);
}
// create the event handler

View File

@ -859,7 +859,9 @@ function form_menufield($attrs) {
$s .= ' <select '.buildAttributes($attrs,true).'>'.DOKU_LF;
if (!empty($attrs['_options'])) {
$selected = false;
for($n=0;$n<count($attrs['_options']);$n++){
$cnt = count($attrs['_options']);
for($n=0; $n < $cnt; $n++){
@list($value,$text,$select) = $attrs['_options'][$n];
$p = '';
if (!is_null($text))

View File

@ -20,10 +20,10 @@ require_once(DOKU_INC.'inc/indexer.php');
*/
function ft_pageSearch($query,&$highlight){
$data['query'] = $query;
$data['highlight'] =& $highlight;
$data['query'] = $query;
$data['highlight'] =& $highlight;
return trigger_event('SEARCH_QUERY_FULLPAGE', $data, '_ft_pageSearch');
return trigger_event('SEARCH_QUERY_FULLPAGE', $data, '_ft_pageSearch');
}
/**
@ -189,7 +189,7 @@ function ft_mediause($id,$max){
foreach($matches[1] as $img){
$img = trim($img);
if(preg_match('/^https?:\/\//i',$img)) continue; // skip external images
list($img) = explode('?',$img); // remove any parameters
list($img) = explode('?',$img); // remove any parameters
resolve_mediaid($ns,$img,$exists); // resolve the possibly relative img
if($img == $id){ // we have a match
@ -286,11 +286,11 @@ function ft_pagesorter($a, $b){
function ft_snippet($id,$highlight){
$text = rawWiki($id);
$evdata = array(
'id' => $id,
'text' => &$text,
'highlight' => &$highlight,
'snippet' => '',
);
'id' => $id,
'text' => &$text,
'highlight' => &$highlight,
'snippet' => '',
);
$evt = new Doku_Event('FULLTEXT_SNIPPET_CREATE',$evdata);
if ($evt->advise_before()) {
@ -305,60 +305,60 @@ function ft_snippet($id,$highlight){
$re3 = "$re1.{0,45}(?!\\1)$re1.{0,45}(?!\\1)(?!\\2)$re1";
for ($cnt=4; $cnt--;) {
if (0) {
} else if (preg_match('/'.$re3.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) {
} else if (preg_match('/'.$re2.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) {
} else if (preg_match('/'.$re1.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) {
} else {
break;
}
if (0) {
} else if (preg_match('/'.$re3.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) {
} else if (preg_match('/'.$re2.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) {
} else if (preg_match('/'.$re1.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) {
} else {
break;
}
list($str,$idx) = $match[0];
list($str,$idx) = $match[0];
// convert $idx (a byte offset) into a utf8 character offset
$utf8_idx = utf8_strlen(substr($text,0,$idx));
$utf8_len = utf8_strlen($str);
// convert $idx (a byte offset) into a utf8 character offset
$utf8_idx = utf8_strlen(substr($text,0,$idx));
$utf8_len = utf8_strlen($str);
// establish context, 100 bytes surrounding the match string
// first look to see if we can go 100 either side,
// then drop to 50 adding any excess if the other side can't go to 50,
$pre = min($utf8_idx-$utf8_offset,100);
$post = min($len-$utf8_idx-$utf8_len,100);
// establish context, 100 bytes surrounding the match string
// first look to see if we can go 100 either side,
// then drop to 50 adding any excess if the other side can't go to 50,
$pre = min($utf8_idx-$utf8_offset,100);
$post = min($len-$utf8_idx-$utf8_len,100);
if ($pre>50 && $post>50) {
$pre = $post = 50;
} else if ($pre>50) {
$pre = min($pre,100-$post);
} else if ($post>50) {
$post = min($post, 100-$pre);
} else {
// both are less than 50, means the context is the whole string
// make it so and break out of this loop - there is no need for the
// complex snippet calculations
$snippets = array($text);
break;
}
if ($pre>50 && $post>50) {
$pre = $post = 50;
} else if ($pre>50) {
$pre = min($pre,100-$post);
} else if ($post>50) {
$post = min($post, 100-$pre);
} else {
// both are less than 50, means the context is the whole string
// make it so and break out of this loop - there is no need for the
// complex snippet calculations
$snippets = array($text);
break;
}
// establish context start and end points, try to append to previous
// context if possible
$start = $utf8_idx - $pre;
$append = ($start < $end) ? $end : false; // still the end of the previous context snippet
$end = $utf8_idx + $utf8_len + $post; // now set it to the end of this context
// establish context start and end points, try to append to previous
// context if possible
$start = $utf8_idx - $pre;
$append = ($start < $end) ? $end : false; // still the end of the previous context snippet
$end = $utf8_idx + $utf8_len + $post; // now set it to the end of this context
if ($append) {
$snippets[count($snippets)-1] .= utf8_substr($text,$append,$end-$append);
} else {
$snippets[] = utf8_substr($text,$start,$end-$start);
}
if ($append) {
$snippets[count($snippets)-1] .= utf8_substr($text,$append,$end-$append);
} else {
$snippets[] = utf8_substr($text,$start,$end-$start);
}
// set $offset for next match attempt
// substract strlen to avoid splitting a potential search success,
// this is an approximation as the search pattern may match strings
// of varying length and it will fail if the context snippet
// boundary breaks a matching string longer than the current match
$utf8_offset = $utf8_idx + $post;
$offset = $idx + strlen(utf8_substr($text,$utf8_idx,$post));
$offset = utf8_correctIdx($text,$offset);
// set $offset for next match attempt
// substract strlen to avoid splitting a potential search success,
// this is an approximation as the search pattern may match strings
// of varying length and it will fail if the context snippet
// boundary breaks a matching string longer than the current match
$utf8_offset = $utf8_idx + $post;
$offset = $idx + strlen(utf8_substr($text,$utf8_idx,$post));
$offset = utf8_correctIdx($text,$offset);
}
$m = "\1";
@ -391,16 +391,16 @@ function ft_resultCombine($args){
$result = array();
if ($array_count > 1) {
foreach ($args[0] as $key => $value) {
$result[$key] = $value;
for ($i = 1; $i !== $array_count; $i++) {
if (!isset($args[$i][$key])) {
unset($result[$key]);
break;
foreach ($args[0] as $key => $value) {
$result[$key] = $value;
for ($i = 1; $i !== $array_count; $i++) {
if (!isset($args[$i][$key])) {
unset($result[$key]);
break;
}
$result[$key] += $args[$i][$key];
}
$result[$key] += $args[$i][$key];
}
}
}
return $result;
}
@ -651,30 +651,30 @@ function ft_queryParser($query){
switch (substr($token, 0, 3)) {
case 'N+:':
$q['ns'][] = $body; // for backward compatibility
break;
$q['ns'][] = $body; // for backward compatibility
break;
case 'N-:':
$q['notns'][] = $body; // for backward compatibility
break;
$q['notns'][] = $body; // for backward compatibility
break;
case 'W_:':
$q['words'][] = $body;
break;
$q['words'][] = $body;
break;
case 'W-:':
$q['words'][] = $body;
$q['not'][] = $body; // for backward compatibility
break;
$q['words'][] = $body;
$q['not'][] = $body; // for backward compatibility
break;
case 'W+:':
$q['words'][] = $body;
$q['highlight'][] = str_replace('*', '', $body);
$q['and'][] = $body; // for backward compatibility
break;
$q['words'][] = $body;
$q['highlight'][] = str_replace('*', '', $body);
$q['and'][] = $body; // for backward compatibility
break;
case 'P-:':
$q['phrases'][] = $body;
break;
$q['phrases'][] = $body;
break;
case 'P+:':
$q['phrases'][] = $body;
$q['highlight'][] = str_replace('*', '', $body);
break;
$q['phrases'][] = $body;
$q['highlight'][] = str_replace('*', '', $body);
break;
}
}
foreach (array('words', 'phrases', 'highlight', 'ns', 'notns', 'and', 'not') as $key) {

View File

@ -202,16 +202,16 @@ function print_form($d){
}
function print_retry() {
global $lang;
global $LC;
?>
global $lang;
global $LC;
?>
<form action="" method="get">
<fieldset>
<input type="hidden" name="l" value="<?php echo $LC ?>" />
<input class="button" type="submit" value="<?php echo $lang['i_retry'];?>" />
</fieldset>
</form>
<?php
<?php
}
/**
@ -360,7 +360,6 @@ function check_configs(){
'auth' => DOKU_LOCAL.'acl.auth.php'
);
// main dokuwiki config file (conf/dokuwiki.php) must not have been modified
$installation_hash = md5(preg_replace("/(\015\012)|(\015)/","\012",
@file_get_contents(DOKU_CONF.'dokuwiki.php')));
@ -437,8 +436,8 @@ function check_functions(){
'preg_replace file_get_contents htmlspecialchars_decode');
if (!function_exists('mb_substr')) {
$funcs[] = 'utf8_encode';
$funcs[] = 'utf8_decode';
$funcs[] = 'utf8_encode';
$funcs[] = 'utf8_decode';
}
foreach($funcs as $func){
@ -505,12 +504,12 @@ function print_errors(){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function remove_magic_quotes(&$array) {
foreach (array_keys($array) as $key) {
if (is_array($array[$key])) {
remove_magic_quotes($array[$key]);
}else {
$array[$key] = stripslashes($array[$key]);
foreach (array_keys($array) as $key) {
if (is_array($array[$key])) {
remove_magic_quotes($array[$key]);
}else {
$array[$key] = stripslashes($array[$key]);
}
}
}
}