diff --git a/doku.php b/doku.php index 0b5af8493..2ee9badc0 100644 --- a/doku.php +++ b/doku.php @@ -8,74 +8,74 @@ // xdebug_start_profiling(); - 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/events.php'); - require_once(DOKU_INC.'inc/pageutils.php'); - require_once(DOKU_INC.'inc/html.php'); - require_once(DOKU_INC.'inc/auth.php'); - require_once(DOKU_INC.'inc/actions.php'); +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/events.php'); +require_once(DOKU_INC.'inc/pageutils.php'); +require_once(DOKU_INC.'inc/html.php'); +require_once(DOKU_INC.'inc/auth.php'); +require_once(DOKU_INC.'inc/actions.php'); - //import variables - $QUERY = trim($_REQUEST['id']); - $ID = getID(); - $NS = getNS($ID); - $REV = $_REQUEST['rev']; - $ACT = $_REQUEST['do']; - $IDX = $_REQUEST['idx']; - $DATE = $_REQUEST['date']; - $RANGE = $_REQUEST['lines']; - $HIGH = $_REQUEST['s']; - if(empty($HIGH)) $HIGH = getGoogleQuery(); +//import variables +$QUERY = trim($_REQUEST['id']); +$ID = getID(); +$NS = getNS($ID); +$REV = $_REQUEST['rev']; +$ACT = $_REQUEST['do']; +$IDX = $_REQUEST['idx']; +$DATE = $_REQUEST['date']; +$RANGE = $_REQUEST['lines']; +$HIGH = $_REQUEST['s']; +if(empty($HIGH)) $HIGH = getGoogleQuery(); - $TEXT = cleanText($_POST['wikitext']); - $PRE = cleanText($_POST['prefix']); - $SUF = cleanText($_POST['suffix']); - $SUM = $_REQUEST['summary']; +$TEXT = cleanText($_POST['wikitext']); +$PRE = cleanText($_POST['prefix']); +$SUF = cleanText($_POST['suffix']); +$SUM = $_REQUEST['summary']; - //sanitize revision - $REV = preg_replace('/[^0-9]/','',$REV); +//sanitize revision +$REV = preg_replace('/[^0-9]/','',$REV); - //we accept the do param as HTTP header, too: - if(!empty($_SERVER['HTTP_X_DOKUWIKI_DO'])){ +//we accept the do param as HTTP header, too: +if(!empty($_SERVER['HTTP_X_DOKUWIKI_DO'])){ $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO'])); - } +} - if(!empty($IDX)) $ACT='index'; - //set default #FIXME not needed here? done in actions? - if(empty($ACT)) $ACT = 'show'; +if(!empty($IDX)) $ACT='index'; +//set default #FIXME not needed here? done in actions? +if(empty($ACT)) $ACT = 'show'; - //make infos about the selected page available - $INFO = pageinfo(); +//make infos about the selected page available +$INFO = pageinfo(); - // handle debugging - if($conf['allowdebug'] && $ACT == 'debug'){ +// handle debugging +if($conf['allowdebug'] && $ACT == 'debug'){ html_debug(); exit; - } +} - //send 404 for missing pages if configured or ID has special meaning to bots - if(!$INFO['exists'] && - ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/',$ID)) && - ($ACT == 'show' || substr($ACT,0,7) == 'export_') ){ +//send 404 for missing pages if configured or ID has special meaning to bots +if(!$INFO['exists'] && + ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/',$ID)) && + ($ACT == 'show' || substr($ACT,0,7) == 'export_') ){ header('HTTP/1.0 404 Not Found'); - } +} - //prepare breadcrumbs (initialize a static var) - if ($conf['breadcrumbs']) breadcrumbs(); +//prepare breadcrumbs (initialize a static var) +if ($conf['breadcrumbs']) breadcrumbs(); - // check upstream - checkUpdateMessages(); +// check upstream +checkUpdateMessages(); - trigger_event('DOKUWIKI_STARTED',$tmp=array()); +trigger_event('DOKUWIKI_STARTED',$tmp=array()); - //close session - session_write_close(); +//close session +session_write_close(); - //do the work - act_dispatch($ACT); +//do the work +act_dispatch($ACT); - trigger_event('DOKUWIKI_DONE', $tmp=array()); +trigger_event('DOKUWIKI_DONE', $tmp=array()); // xdebug_dump_function_profile(1); diff --git a/feed.php b/feed.php index 9dc96d052..cc4b08442 100644 --- a/feed.php +++ b/feed.php @@ -6,74 +6,74 @@ * @author Andreas Gohr */ - 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/events.php'); - require_once(DOKU_INC.'inc/parserutils.php'); - require_once(DOKU_INC.'inc/feedcreator.class.php'); - require_once(DOKU_INC.'inc/auth.php'); - require_once(DOKU_INC.'inc/pageutils.php'); - require_once(DOKU_INC.'inc/httputils.php'); +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/events.php'); +require_once(DOKU_INC.'inc/parserutils.php'); +require_once(DOKU_INC.'inc/feedcreator.class.php'); +require_once(DOKU_INC.'inc/auth.php'); +require_once(DOKU_INC.'inc/pageutils.php'); +require_once(DOKU_INC.'inc/httputils.php'); - //close session - session_write_close(); +//close session +session_write_close(); - // get params - $opt = rss_parseOptions(); +// get params +$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'); - $cmod = @filemtime($cache); // 0 if not exists - if ($cmod && (@filemtime(DOKU_CONF.'local.php')>$cmod || @filemtime(DOKU_CONF.'dokuwiki.php')>$cmod)) { +// 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'); +$cmod = @filemtime($cache); // 0 if not exists +if ($cmod && (@filemtime(DOKU_CONF.'local.php')>$cmod || @filemtime(DOKU_CONF.'dokuwiki.php')>$cmod)) { // ignore cache if feed prefs may have changed $cmod = 0; - } +} - // check cacheage and deliver if nothing has changed since last - // time or the update interval has not passed, also handles conditional requests - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - header('Content-Type: application/xml; charset=utf-8'); - header('X-Robots-Tag: noindex'); - if($cmod && (($cmod+$conf['rss_update']>time()) || ($cmod>@filemtime($conf['changelog'])))){ +// check cacheage and deliver if nothing has changed since last +// time or the update interval has not passed, also handles conditional requests +header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); +header('Pragma: public'); +header('Content-Type: application/xml; charset=utf-8'); +header('X-Robots-Tag: noindex'); +if($cmod && (($cmod+$conf['rss_update']>time()) || ($cmod>@filemtime($conf['changelog'])))){ http_conditionalRequest($cmod); if($conf['allowdebug']) header("X-CacheUsed: $cache"); print io_readFile($cache); exit; - } else { +} else { http_conditionalRequest(time()); - } + } - // create new feed - $rss = new DokuWikiFeedCreator(); - $rss->title = $conf['title'].(($opt['namespace']) ? ' '.$opt['namespace'] : ''); - $rss->link = DOKU_URL; - $rss->syndicationURL = DOKU_URL.'feed.php'; - $rss->cssStyleSheet = DOKU_URL.'lib/exe/css.php?s=feed'; +// create new feed +$rss = new DokuWikiFeedCreator(); +$rss->title = $conf['title'].(($opt['namespace']) ? ' '.$opt['namespace'] : ''); +$rss->link = DOKU_URL; +$rss->syndicationURL = DOKU_URL.'feed.php'; +$rss->cssStyleSheet = DOKU_URL.'lib/exe/css.php?s=feed'; - $image = new FeedImage(); - $image->title = $conf['title']; - $image->url = DOKU_URL."lib/images/favicon.ico"; - $image->link = DOKU_URL; - $rss->image = $image; +$image = new FeedImage(); +$image->title = $conf['title']; +$image->url = DOKU_URL."lib/images/favicon.ico"; +$image->link = DOKU_URL; +$rss->image = $image; - if($opt['feed_mode'] == 'list'){ +if($opt['feed_mode'] == 'list'){ rssListNamespace($rss,$opt); - }elseif($opt['feed_mode'] == 'search'){ +}elseif($opt['feed_mode'] == 'search'){ rssSearch($rss,$opt); - }else{ +}else{ rssRecentChanges($rss,$opt); - } +} - $feed = $rss->createFeed($opt['feed_type'],'utf-8'); +$feed = $rss->createFeed($opt['feed_type'],'utf-8'); - // save cachefile - io_saveFile($cache,$feed); +// save cachefile +io_saveFile($cache,$feed); - // finally deliver - print $feed; +// finally deliver +print $feed; // ---------------------------------------------------------------- // @@ -101,25 +101,25 @@ function rss_parseOptions(){ $opt['guardmail'] = ($conf['mailguard'] != '' && $conf['mailguard'] != 'none'); switch ($opt['feed_type']){ - case 'rss': - $opt['feed_type'] = 'RSS0.91'; - $opt['mime_type'] = 'text/xml'; - break; - case 'rss2': - $opt['feed_type'] = 'RSS2.0'; - $opt['mime_type'] = 'text/xml'; - break; - case 'atom': - $opt['feed_type'] = 'ATOM0.3'; - $opt['mime_type'] = 'application/xml'; - break; - case 'atom1': - $opt['feed_type'] = 'ATOM1.0'; - $opt['mime_type'] = 'application/atom+xml'; - break; - default: - $opt['feed_type'] = 'RSS1.0'; - $opt['mime_type'] = 'application/xml'; + case 'rss': + $opt['feed_type'] = 'RSS0.91'; + $opt['mime_type'] = 'text/xml'; + break; + case 'rss2': + $opt['feed_type'] = 'RSS2.0'; + $opt['mime_type'] = 'text/xml'; + break; + case 'atom': + $opt['feed_type'] = 'ATOM0.3'; + $opt['mime_type'] = 'application/xml'; + break; + case 'atom1': + $opt['feed_type'] = 'ATOM1.0'; + $opt['mime_type'] = 'application/atom+xml'; + break; + default: + $opt['feed_type'] = 'RSS1.0'; + $opt['mime_type'] = 'application/xml'; } return $opt; } @@ -229,7 +229,6 @@ function rss_buildItems(&$rss,&$data,$opt){ } $item->description = $content; //FIXME a plugin hook here could be senseful - // add user # FIXME should the user be pulled from metadata as well? $user = null; @@ -256,8 +255,8 @@ function rss_buildItems(&$rss,&$data,$opt){ if($meta['subject']){ $item->category = $meta['subject']; }else{ - $cat = getNS($id); - if($cat) $item->category = $cat; + $cat = getNS($id); + if($cat) $item->category = $cat; } // finally add the item to the feed object, after handing it to registered plugins @@ -267,7 +266,7 @@ function rss_buildItems(&$rss,&$data,$opt){ 'rss' => &$rss); $evt = new Doku_Event('FEED_ITEM_ADD', $evdata); if ($evt->advise_before()){ - $rss->addItem($item); + $rss->addItem($item); } $evt->advise_after(); // for completeness } diff --git a/inc/auth.php b/inc/auth.php index 684885890..e0b23c0e6 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -9,22 +9,22 @@ * @author Andreas Gohr */ - if(!defined('DOKU_INC')) die('meh.'); - require_once(DOKU_INC.'inc/common.php'); - require_once(DOKU_INC.'inc/io.php'); +if(!defined('DOKU_INC')) die('meh.'); +require_once(DOKU_INC.'inc/common.php'); +require_once(DOKU_INC.'inc/io.php'); - // some ACL level defines - define('AUTH_NONE',0); - define('AUTH_READ',1); - define('AUTH_EDIT',2); - define('AUTH_CREATE',4); - define('AUTH_UPLOAD',8); - define('AUTH_DELETE',16); - define('AUTH_ADMIN',255); +// some ACL level defines +define('AUTH_NONE',0); +define('AUTH_READ',1); +define('AUTH_EDIT',2); +define('AUTH_CREATE',4); +define('AUTH_UPLOAD',8); +define('AUTH_DELETE',16); +define('AUTH_ADMIN',255); - global $conf; +global $conf; - if($conf['useacl']){ +if($conf['useacl']){ require_once(DOKU_INC.'inc/blowfish.php'); require_once(DOKU_INC.'inc/mail.php'); @@ -32,87 +32,87 @@ // load the the backend auth functions and instantiate the auth object if (@file_exists(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php')) { - require_once(DOKU_INC.'inc/auth/basic.class.php'); - require_once(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php'); + require_once(DOKU_INC.'inc/auth/basic.class.php'); + require_once(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php'); - $auth_class = "auth_".$conf['authtype']; - if (class_exists($auth_class)) { - $auth = new $auth_class(); - if ($auth->success == false) { - // degrade to unauthenticated user - unset($auth); - auth_logoff(); - msg($lang['authtempfail'], -1); + $auth_class = "auth_".$conf['authtype']; + if (class_exists($auth_class)) { + $auth = new $auth_class(); + if ($auth->success == false) { + // degrade to unauthenticated user + unset($auth); + auth_logoff(); + msg($lang['authtempfail'], -1); + } + } else { + nice_die($lang['authmodfailed']); } - } else { - nice_die($lang['authmodfailed']); - } } else { - nice_die($lang['authmodfailed']); + nice_die($lang['authmodfailed']); } - } +} - // do the login either by cookie or provided credentials - if($conf['useacl']){ +// do the login either by cookie or provided credentials +if($conf['useacl']){ if($auth){ - if (!isset($_REQUEST['u'])) $_REQUEST['u'] = ''; - if (!isset($_REQUEST['p'])) $_REQUEST['p'] = ''; - if (!isset($_REQUEST['r'])) $_REQUEST['r'] = ''; - $_REQUEST['http_credentials'] = false; - if (!$conf['rememberme']) $_REQUEST['r'] = false; + if (!isset($_REQUEST['u'])) $_REQUEST['u'] = ''; + if (!isset($_REQUEST['p'])) $_REQUEST['p'] = ''; + if (!isset($_REQUEST['r'])) $_REQUEST['r'] = ''; + $_REQUEST['http_credentials'] = false; + if (!$conf['rememberme']) $_REQUEST['r'] = false; - // streamline HTTP auth credentials (IIS/rewrite -> mod_php) - if(isset($_SERVER['HTTP_AUTHORIZATION'])){ - list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = - explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); - } - - // if no credentials were given try to use HTTP auth (for SSO) - if(empty($_REQUEST['u']) && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])){ - $_REQUEST['u'] = $_SERVER['PHP_AUTH_USER']; - $_REQUEST['p'] = $_SERVER['PHP_AUTH_PW']; - $_REQUEST['http_credentials'] = true; - } - - if($_REQUEST['authtok']){ - // when an authentication token is given, trust the session - auth_validateToken($_REQUEST['authtok']); - }elseif(!is_null($auth) && $auth->canDo('external')){ - // external trust mechanism in place - $auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']); - }else{ - $evdata = array( - 'action' => $ACT, - 'user' => $_REQUEST['u'], - 'password' => $_REQUEST['p'], - 'sticky' => $_REQUEST['r'], - 'silent' => $_REQUEST['http_credentials'], - ); - $evt = new Doku_Event('AUTH_LOGIN_CHECK',$evdata); - if($evt->advise_before()){ - auth_login($evdata['user'], - $evdata['password'], - $evdata['sticky'], - $evdata['silent']); + // streamline HTTP auth credentials (IIS/rewrite -> mod_php) + if(isset($_SERVER['HTTP_AUTHORIZATION'])){ + list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = + explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); + } + + // if no credentials were given try to use HTTP auth (for SSO) + if(empty($_REQUEST['u']) && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])){ + $_REQUEST['u'] = $_SERVER['PHP_AUTH_USER']; + $_REQUEST['p'] = $_SERVER['PHP_AUTH_PW']; + $_REQUEST['http_credentials'] = true; + } + + if($_REQUEST['authtok']){ + // when an authentication token is given, trust the session + auth_validateToken($_REQUEST['authtok']); + }elseif(!is_null($auth) && $auth->canDo('external')){ + // external trust mechanism in place + $auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']); + }else{ + $evdata = array( + 'action' => $ACT, + 'user' => $_REQUEST['u'], + 'password' => $_REQUEST['p'], + 'sticky' => $_REQUEST['r'], + 'silent' => $_REQUEST['http_credentials'], + ); + $evt = new Doku_Event('AUTH_LOGIN_CHECK',$evdata); + if($evt->advise_before()){ + auth_login($evdata['user'], + $evdata['password'], + $evdata['sticky'], + $evdata['silent']); + } + $evt->advise_after(); + unset($evt); + unset($evdata); } - $evt->advise_after(); - unset($evt); - unset($evdata); - } } //load ACL into a global array global $AUTH_ACL; if(is_readable(DOKU_CONF.'acl.auth.php')){ - $AUTH_ACL = file(DOKU_CONF.'acl.auth.php'); - if(isset($_SERVER['REMOTE_USER'])){ - $AUTH_ACL = str_replace('%USER%',$_SERVER['REMOTE_USER'],$AUTH_ACL); - $AUTH_ACL = str_replace('@USER@',$_SERVER['REMOTE_USER'],$AUTH_ACL); //legacy - } + $AUTH_ACL = file(DOKU_CONF.'acl.auth.php'); + if(isset($_SERVER['REMOTE_USER'])){ + $AUTH_ACL = str_replace('%USER%',$_SERVER['REMOTE_USER'],$AUTH_ACL); + $AUTH_ACL = str_replace('@USER@',$_SERVER['REMOTE_USER'],$AUTH_ACL); //legacy + } }else{ - $AUTH_ACL = array(); + $AUTH_ACL = array(); } - } +} /** * This tries to login the user based on the sent auth credentials @@ -142,53 +142,53 @@ * @param bool $sticky Cookie should not expire * @param bool $silent Don't show error on bad auth * @return bool true on successful auth -*/ + */ function auth_login($user,$pass,$sticky=false,$silent=false){ - global $USERINFO; - global $conf; - global $lang; - global $auth; - $sticky ? $sticky = true : $sticky = false; //sanity check + global $USERINFO; + global $conf; + global $lang; + global $auth; + $sticky ? $sticky = true : $sticky = false; //sanity check - if(!empty($user)){ - //usual login - if ($auth->checkPass($user,$pass)){ - // make logininfo globally available - $_SERVER['REMOTE_USER'] = $user; - auth_setCookie($user,PMA_blowfish_encrypt($pass,auth_cookiesalt()),$sticky); - return true; + if(!empty($user)){ + //usual login + if ($auth->checkPass($user,$pass)){ + // make logininfo globally available + $_SERVER['REMOTE_USER'] = $user; + auth_setCookie($user,PMA_blowfish_encrypt($pass,auth_cookiesalt()),$sticky); + return true; + }else{ + //invalid credentials - log off + if(!$silent) msg($lang['badlogin'],-1); + auth_logoff(); + return false; + } }else{ - //invalid credentials - log off - if(!$silent) msg($lang['badlogin'],-1); - auth_logoff(); - return false; + // read cookie information + list($user,$sticky,$pass) = auth_getCookie(); + // get session info + $session = $_SESSION[DOKU_COOKIE]['auth']; + if($user && $pass){ + // we got a cookie - see if we can trust it + if(isset($session) && + $auth->useSessionCache($user) && + ($session['time'] >= time()-$conf['auth_security_timeout']) && + ($session['user'] == $user) && + ($session['pass'] == $pass) && //still crypted + ($session['buid'] == auth_browseruid()) ){ + // he has session, cookie and browser right - let him in + $_SERVER['REMOTE_USER'] = $user; + $USERINFO = $session['info']; //FIXME move all references to session + return true; + } + // no we don't trust it yet - recheck pass but silent + $pass = PMA_blowfish_decrypt($pass,auth_cookiesalt()); + return auth_login($user,$pass,$sticky,true); + } } - }else{ - // read cookie information - list($user,$sticky,$pass) = auth_getCookie(); - // get session info - $session = $_SESSION[DOKU_COOKIE]['auth']; - if($user && $pass){ - // we got a cookie - see if we can trust it - if(isset($session) && - $auth->useSessionCache($user) && - ($session['time'] >= time()-$conf['auth_security_timeout']) && - ($session['user'] == $user) && - ($session['pass'] == $pass) && //still crypted - ($session['buid'] == auth_browseruid()) ){ - // he has session, cookie and browser right - let him in - $_SERVER['REMOTE_USER'] = $user; - $USERINFO = $session['info']; //FIXME move all references to session - return true; - } - // no we don't trust it yet - recheck pass but silent - $pass = PMA_blowfish_decrypt($pass,auth_cookiesalt()); - return auth_login($user,$pass,$sticky,true); - } - } - //just to be sure - auth_logoff(true); - return false; + //just to be sure + auth_logoff(true); + return false; } /** @@ -244,14 +244,14 @@ function auth_createToken(){ * @return string a MD5 sum of various browser headers */ function auth_browseruid(){ - $ip = clientIP(true); - $uid = ''; - $uid .= $_SERVER['HTTP_USER_AGENT']; - $uid .= $_SERVER['HTTP_ACCEPT_ENCODING']; - $uid .= $_SERVER['HTTP_ACCEPT_LANGUAGE']; - $uid .= $_SERVER['HTTP_ACCEPT_CHARSET']; - $uid .= substr($ip,0,strpos($ip,'.')); - return md5($uid); + $ip = clientIP(true); + $uid = ''; + $uid .= $_SERVER['HTTP_USER_AGENT']; + $uid .= $_SERVER['HTTP_ACCEPT_ENCODING']; + $uid .= $_SERVER['HTTP_ACCEPT_LANGUAGE']; + $uid .= $_SERVER['HTTP_ACCEPT_CHARSET']; + $uid .= substr($ip,0,strpos($ip,'.')); + return md5($uid); } /** @@ -267,14 +267,14 @@ function auth_browseruid(){ * @return string */ function auth_cookiesalt(){ - global $conf; - $file = $conf['metadir'].'/_htcookiesalt'; - $salt = io_readFile($file); - if(empty($salt)){ - $salt = uniqid(rand(),true); - io_saveFile($file,$salt); - } - return $salt; + global $conf; + $file = $conf['metadir'].'/_htcookiesalt'; + $salt = io_readFile($file); + if(empty($salt)){ + $salt = uniqid(rand(),true); + io_saveFile($file,$salt); + } + return $salt; } /** @@ -287,35 +287,35 @@ function auth_cookiesalt(){ * @param bool $keepbc - when true, the breadcrumb data is not cleared */ function auth_logoff($keepbc=false){ - global $conf; - global $USERINFO; - global $INFO, $ID; - global $auth; + global $conf; + global $USERINFO; + global $INFO, $ID; + global $auth; - // make sure the session is writable (it usually is) - @session_start(); + // make sure the session is writable (it usually is) + @session_start(); - if(isset($_SESSION[DOKU_COOKIE]['auth']['user'])) - unset($_SESSION[DOKU_COOKIE]['auth']['user']); - if(isset($_SESSION[DOKU_COOKIE]['auth']['pass'])) - unset($_SESSION[DOKU_COOKIE]['auth']['pass']); - if(isset($_SESSION[DOKU_COOKIE]['auth']['info'])) - unset($_SESSION[DOKU_COOKIE]['auth']['info']); - if(!$keepbc && isset($_SESSION[DOKU_COOKIE]['bc'])) - unset($_SESSION[DOKU_COOKIE]['bc']); - if(isset($_SERVER['REMOTE_USER'])) - unset($_SERVER['REMOTE_USER']); - $USERINFO=null; //FIXME + if(isset($_SESSION[DOKU_COOKIE]['auth']['user'])) + unset($_SESSION[DOKU_COOKIE]['auth']['user']); + if(isset($_SESSION[DOKU_COOKIE]['auth']['pass'])) + unset($_SESSION[DOKU_COOKIE]['auth']['pass']); + if(isset($_SESSION[DOKU_COOKIE]['auth']['info'])) + unset($_SESSION[DOKU_COOKIE]['auth']['info']); + if(!$keepbc && isset($_SESSION[DOKU_COOKIE]['bc'])) + unset($_SESSION[DOKU_COOKIE]['bc']); + if(isset($_SERVER['REMOTE_USER'])) + unset($_SERVER['REMOTE_USER']); + $USERINFO=null; //FIXME - if (version_compare(PHP_VERSION, '5.2.0', '>')) { - setcookie(DOKU_COOKIE,'',time()-600000,DOKU_REL,'',($conf['securecookie'] && is_ssl()),true); - }else{ - setcookie(DOKU_COOKIE,'',time()-600000,DOKU_REL,'',($conf['securecookie'] && is_ssl())); - } + if (version_compare(PHP_VERSION, '5.2.0', '>')) { + setcookie(DOKU_COOKIE,'',time()-600000,DOKU_REL,'',($conf['securecookie'] && is_ssl()),true); + }else{ + setcookie(DOKU_COOKIE,'',time()-600000,DOKU_REL,'',($conf['securecookie'] && is_ssl())); + } - if($auth && $auth->canDo('logoff')){ - $auth->logOff(); - } + if($auth && $auth->canDo('logoff')){ + $auth->logOff(); + } } /** @@ -333,52 +333,52 @@ function auth_logoff($keepbc=false){ * @param bool adminonly - when true checks if user is admin */ function auth_ismanager($user=null,$groups=null,$adminonly=false){ - global $conf; - global $USERINFO; + global $conf; + global $USERINFO; - if(!$conf['useacl']) return false; - if(is_null($user)) $user = $_SERVER['REMOTE_USER']; - if(is_null($groups)) $groups = (array) $USERINFO['grps']; - $user = auth_nameencode($user); + if(!$conf['useacl']) return false; + if(is_null($user)) $user = $_SERVER['REMOTE_USER']; + if(is_null($groups)) $groups = (array) $USERINFO['grps']; + $user = auth_nameencode($user); - // check username against superuser and manager - $superusers = explode(',', $conf['superuser']); - $superusers = array_unique($superusers); - $superusers = array_map('trim', $superusers); - // prepare an array containing only true values for array_map call - $alltrue = array_fill(0, count($superusers), true); - $superusers = array_map('auth_nameencode', $superusers, $alltrue); - if(in_array($user, $superusers)) return true; - - if(!$adminonly){ - $managers = explode(',', $conf['manager']); - $managers = array_unique($managers); - $managers = array_map('trim', $managers); + // check username against superuser and manager + $superusers = explode(',', $conf['superuser']); + $superusers = array_unique($superusers); + $superusers = array_map('trim', $superusers); // prepare an array containing only true values for array_map call - $alltrue = array_fill(0, count($managers), true); - $managers = array_map('auth_nameencode', $managers, $alltrue); - if(in_array($user, $managers)) return true; - } + $alltrue = array_fill(0, count($superusers), true); + $superusers = array_map('auth_nameencode', $superusers, $alltrue); + if(in_array($user, $superusers)) return true; - // check user's groups against superuser and manager - if (!empty($groups)) { - - //prepend groups with @ and nameencode - $cnt = count($groups); - for($i=0; $i<$cnt; $i++){ - $groups[$i] = '@'.auth_nameencode($groups[$i]); - } - - // check groups against superuser and manager - foreach($superusers as $supu) - if(in_array($supu, $groups)) return true; if(!$adminonly){ - foreach($managers as $mana) - if(in_array($mana, $groups)) return true; + $managers = explode(',', $conf['manager']); + $managers = array_unique($managers); + $managers = array_map('trim', $managers); + // prepare an array containing only true values for array_map call + $alltrue = array_fill(0, count($managers), true); + $managers = array_map('auth_nameencode', $managers, $alltrue); + if(in_array($user, $managers)) return true; } - } - return false; + // check user's groups against superuser and manager + if (!empty($groups)) { + + //prepend groups with @ and nameencode + $cnt = count($groups); + for($i=0; $i<$cnt; $i++){ + $groups[$i] = '@'.auth_nameencode($groups[$i]); + } + + // check groups against superuser and manager + foreach($superusers as $supu) + if(in_array($supu, $groups)) return true; + if(!$adminonly){ + foreach($managers as $mana) + if(in_array($mana, $groups)) return true; + } + } + + return false; } /** @@ -392,7 +392,7 @@ function auth_ismanager($user=null,$groups=null,$adminonly=false){ * @see auth_ismanager */ function auth_isadmin($user=null,$groups=null){ - return auth_ismanager($user,$groups,true); + return auth_ismanager($user,$groups,true); } /** @@ -406,11 +406,11 @@ function auth_isadmin($user=null,$groups=null){ * @return int permission level */ function auth_quickaclcheck($id){ - global $conf; - global $USERINFO; - # if no ACL is used always return upload rights - if(!$conf['useacl']) return AUTH_UPLOAD; - return auth_aclcheck($id,$_SERVER['REMOTE_USER'],$USERINFO['grps']); + global $conf; + global $USERINFO; + # if no ACL is used always return upload rights + if(!$conf['useacl']) return AUTH_UPLOAD; + return auth_aclcheck($id,$_SERVER['REMOTE_USER'],$USERINFO['grps']); } /** @@ -425,96 +425,96 @@ function auth_quickaclcheck($id){ * @return int permission level */ function auth_aclcheck($id,$user,$groups){ - global $conf; - global $AUTH_ACL; + global $conf; + global $AUTH_ACL; - // if no ACL is used always return upload rights - if(!$conf['useacl']) return AUTH_UPLOAD; + // if no ACL is used always return upload rights + if(!$conf['useacl']) return AUTH_UPLOAD; - //make sure groups is an array - if(!is_array($groups)) $groups = array(); + //make sure groups is an array + if(!is_array($groups)) $groups = array(); - //if user is superuser or in superusergroup return 255 (acl_admin) - if(auth_isadmin($user,$groups)) { return AUTH_ADMIN; } + //if user is superuser or in superusergroup return 255 (acl_admin) + if(auth_isadmin($user,$groups)) { return AUTH_ADMIN; } - $user = auth_nameencode($user); + $user = auth_nameencode($user); - //prepend groups with @ and nameencode - $cnt = count($groups); - for($i=0; $i<$cnt; $i++){ - $groups[$i] = '@'.auth_nameencode($groups[$i]); - } - - $ns = getNS($id); - $perm = -1; - - if($user || count($groups)){ - //add ALL group - $groups[] = '@ALL'; - //add User - if($user) $groups[] = $user; - //build regexp - $regexp = join('|',$groups); - }else{ - $regexp = '@ALL'; - } - - //check exact match first - $matches = preg_grep('/^'.preg_quote($id,'/').'\s+('.$regexp.')\s+/',$AUTH_ACL); - if(count($matches)){ - foreach($matches as $match){ - $match = preg_replace('/#.*$/','',$match); //ignore comments - $acl = preg_split('/\s+/',$match); - if($acl[2] > AUTH_DELETE) $acl[2] = AUTH_DELETE; //no admins in the ACL! - if($acl[2] > $perm){ - $perm = $acl[2]; - } - } - if($perm > -1){ - //we had a match - return it - return $perm; - } - } - - //still here? do the namespace checks - if($ns){ - $path = $ns.':\*'; - }else{ - $path = '\*'; //root document - } - - do{ - $matches = preg_grep('/^'.$path.'\s+('.$regexp.')\s+/',$AUTH_ACL); - if(count($matches)){ - foreach($matches as $match){ - $match = preg_replace('/#.*$/','',$match); //ignore comments - $acl = preg_split('/\s+/',$match); - if($acl[2] > AUTH_DELETE) $acl[2] = AUTH_DELETE; //no admins in the ACL! - if($acl[2] > $perm){ - $perm = $acl[2]; - } - } - //we had a match - return it - return $perm; + //prepend groups with @ and nameencode + $cnt = count($groups); + for($i=0; $i<$cnt; $i++){ + $groups[$i] = '@'.auth_nameencode($groups[$i]); } - //get next higher namespace - $ns = getNS($ns); + $ns = getNS($id); + $perm = -1; - if($path != '\*'){ - $path = $ns.':\*'; - if($path == ':\*') $path = '\*'; + if($user || count($groups)){ + //add ALL group + $groups[] = '@ALL'; + //add User + if($user) $groups[] = $user; + //build regexp + $regexp = join('|',$groups); }else{ - //we did this already - //looks like there is something wrong with the ACL - //break here - msg('No ACL setup yet! Denying access to everyone.'); - return AUTH_NONE; + $regexp = '@ALL'; } - }while(1); //this should never loop endless - //still here? return no permissions - return AUTH_NONE; + //check exact match first + $matches = preg_grep('/^'.preg_quote($id,'/').'\s+('.$regexp.')\s+/',$AUTH_ACL); + if(count($matches)){ + foreach($matches as $match){ + $match = preg_replace('/#.*$/','',$match); //ignore comments + $acl = preg_split('/\s+/',$match); + if($acl[2] > AUTH_DELETE) $acl[2] = AUTH_DELETE; //no admins in the ACL! + if($acl[2] > $perm){ + $perm = $acl[2]; + } + } + if($perm > -1){ + //we had a match - return it + return $perm; + } + } + + //still here? do the namespace checks + if($ns){ + $path = $ns.':\*'; + }else{ + $path = '\*'; //root document + } + + do{ + $matches = preg_grep('/^'.$path.'\s+('.$regexp.')\s+/',$AUTH_ACL); + if(count($matches)){ + foreach($matches as $match){ + $match = preg_replace('/#.*$/','',$match); //ignore comments + $acl = preg_split('/\s+/',$match); + if($acl[2] > AUTH_DELETE) $acl[2] = AUTH_DELETE; //no admins in the ACL! + if($acl[2] > $perm){ + $perm = $acl[2]; + } + } + //we had a match - return it + return $perm; + } + + //get next higher namespace + $ns = getNS($ns); + + if($path != '\*'){ + $path = $ns.':\*'; + if($path == ':\*') $path = '\*'; + }else{ + //we did this already + //looks like there is something wrong with the ACL + //break here + msg('No ACL setup yet! Denying access to everyone.'); + return AUTH_NONE; + } + }while(1); //this should never loop endless + + //still here? return no permissions + return AUTH_NONE; } /** @@ -531,21 +531,21 @@ function auth_aclcheck($id,$user,$groups){ * @see rawurldecode() */ function auth_nameencode($name,$skip_group=false){ - global $cache_authname; - $cache =& $cache_authname; - $name = (string) $name; + global $cache_authname; + $cache =& $cache_authname; + $name = (string) $name; - if (!isset($cache[$name][$skip_group])) { - if($skip_group && $name{0} =='@'){ - $cache[$name][$skip_group] = '@'.preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e', - "'%'.dechex(ord(substr('\\1',-1)))",substr($name,1)); - }else{ - $cache[$name][$skip_group] = preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e', - "'%'.dechex(ord(substr('\\1',-1)))",$name); + if (!isset($cache[$name][$skip_group])) { + if($skip_group && $name{0} =='@'){ + $cache[$name][$skip_group] = '@'.preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e', + "'%'.dechex(ord(substr('\\1',-1)))",substr($name,1)); + }else{ + $cache[$name][$skip_group] = preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e', + "'%'.dechex(ord(substr('\\1',-1)))",$name); + } } - } - return $cache[$name][$skip_group]; + return $cache[$name][$skip_group]; } /** @@ -557,21 +557,21 @@ function auth_nameencode($name,$skip_group=false){ * @return string pronouncable password */ function auth_pwgen(){ - $pw = ''; - $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones - $v = 'aeiou'; //vowels - $a = $c.$v; //both + $pw = ''; + $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones + $v = 'aeiou'; //vowels + $a = $c.$v; //both - //use two syllables... - for($i=0;$i < 2; $i++){ - $pw .= $c[rand(0, strlen($c)-1)]; - $pw .= $v[rand(0, strlen($v)-1)]; - $pw .= $a[rand(0, strlen($a)-1)]; - } - //... and add a nice number - $pw .= rand(10,99); + //use two syllables... + for($i=0;$i < 2; $i++){ + $pw .= $c[rand(0, strlen($c)-1)]; + $pw .= $v[rand(0, strlen($v)-1)]; + $pw .= $a[rand(0, strlen($a)-1)]; + } + //... and add a nice number + $pw .= rand(10,99); - return $pw; + return $pw; } /** @@ -582,26 +582,26 @@ function auth_pwgen(){ * @return bool true on success */ function auth_sendPassword($user,$password){ - global $conf; - global $lang; - global $auth; + global $conf; + global $lang; + global $auth; - $hdrs = ''; - $userinfo = $auth->getUserData($user); + $hdrs = ''; + $userinfo = $auth->getUserData($user); - if(!$userinfo['mail']) return false; + if(!$userinfo['mail']) return false; - $text = rawLocale('password'); - $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text); - $text = str_replace('@FULLNAME@',$userinfo['name'],$text); - $text = str_replace('@LOGIN@',$user,$text); - $text = str_replace('@PASSWORD@',$password,$text); - $text = str_replace('@TITLE@',$conf['title'],$text); + $text = rawLocale('password'); + $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text); + $text = str_replace('@FULLNAME@',$userinfo['name'],$text); + $text = str_replace('@LOGIN@',$user,$text); + $text = str_replace('@PASSWORD@',$password,$text); + $text = str_replace('@TITLE@',$conf['title'],$text); - return mail_send($userinfo['name'].' <'.$userinfo['mail'].'>', - $lang['regpwmail'], - $text, - $conf['mailfrom']); + return mail_send($userinfo['name'].' <'.$userinfo['mail'].'>', + $lang['regpwmail'], + $text, + $conf['mailfrom']); } /** @@ -614,74 +614,74 @@ function auth_sendPassword($user,$password){ * @return bool true on success, false on any error */ function register(){ - global $lang; - global $conf; - global $auth; + global $lang; + global $conf; + global $auth; - if(!$_POST['save']) return false; - if(!$auth->canDo('addUser')) return false; + if(!$_POST['save']) return false; + if(!$auth->canDo('addUser')) return false; - //clean username - $_POST['login'] = preg_replace('/.*:/','',$_POST['login']); - $_POST['login'] = cleanID($_POST['login']); - //clean fullname and email - $_POST['fullname'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/','',$_POST['fullname'])); - $_POST['email'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/','',$_POST['email'])); + //clean username + $_POST['login'] = preg_replace('/.*:/','',$_POST['login']); + $_POST['login'] = cleanID($_POST['login']); + //clean fullname and email + $_POST['fullname'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/','',$_POST['fullname'])); + $_POST['email'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/','',$_POST['email'])); - if( empty($_POST['login']) || - empty($_POST['fullname']) || - empty($_POST['email']) ){ - msg($lang['regmissing'],-1); - return false; - } + if( empty($_POST['login']) || + empty($_POST['fullname']) || + empty($_POST['email']) ){ + msg($lang['regmissing'],-1); + return false; + } - if ($conf['autopasswd']) { - $pass = auth_pwgen(); // automatically generate password - } elseif (empty($_POST['pass']) || + if ($conf['autopasswd']) { + $pass = auth_pwgen(); // automatically generate password + } elseif (empty($_POST['pass']) || empty($_POST['passchk'])) { - msg($lang['regmissing'], -1); // complain about missing passwords - return false; - } elseif ($_POST['pass'] != $_POST['passchk']) { - msg($lang['regbadpass'], -1); // complain about misspelled passwords - return false; - } else { - $pass = $_POST['pass']; // accept checked and valid password - } + msg($lang['regmissing'], -1); // complain about missing passwords + return false; + } elseif ($_POST['pass'] != $_POST['passchk']) { + msg($lang['regbadpass'], -1); // complain about misspelled passwords + return false; + } else { + $pass = $_POST['pass']; // accept checked and valid password + } - //check mail - if(!mail_isvalid($_POST['email'])){ - msg($lang['regbadmail'],-1); - return false; - } + //check mail + if(!mail_isvalid($_POST['email'])){ + msg($lang['regbadmail'],-1); + return false; + } - //okay try to create the user - if(!$auth->triggerUserMod('create', array($_POST['login'],$pass,$_POST['fullname'],$_POST['email']))){ - msg($lang['reguexists'],-1); - return false; - } + //okay try to create the user + if(!$auth->triggerUserMod('create', array($_POST['login'],$pass,$_POST['fullname'],$_POST['email']))){ + msg($lang['reguexists'],-1); + return false; + } - // create substitutions for use in notification email - $substitutions = array( - 'NEWUSER' => $_POST['login'], - 'NEWNAME' => $_POST['fullname'], - 'NEWEMAIL' => $_POST['email'], - ); + // create substitutions for use in notification email + $substitutions = array( + 'NEWUSER' => $_POST['login'], + 'NEWNAME' => $_POST['fullname'], + 'NEWEMAIL' => $_POST['email'], + ); - if (!$conf['autopasswd']) { - msg($lang['regsuccess2'],1); - notify('', 'register', '', $_POST['login'], false, $substitutions); - return true; - } + if (!$conf['autopasswd']) { + msg($lang['regsuccess2'],1); + notify('', 'register', '', $_POST['login'], false, $substitutions); + return true; + } - // autogenerated password? then send him the password - if (auth_sendPassword($_POST['login'],$pass)){ - msg($lang['regsuccess'],1); - notify('', 'register', '', $_POST['login'], false, $substitutions); - return true; - }else{ - msg($lang['regmailfail'],-1); - return false; - } + // autogenerated password? then send him the password + if (auth_sendPassword($_POST['login'],$pass)){ + msg($lang['regsuccess'],1); + notify('', 'register', '', $_POST['login'], false, $substitutions); + return true; + }else{ + msg($lang['regmailfail'],-1); + return false; + } } /** @@ -690,65 +690,64 @@ function register(){ * @author Christopher Smith */ function updateprofile() { - global $conf; - global $INFO; - global $lang; - global $auth; + global $conf; + global $INFO; + global $lang; + global $auth; - if(empty($_POST['save'])) return false; - if(!checkSecurityToken()) return false; + if(empty($_POST['save'])) return false; + if(!checkSecurityToken()) return false; - // should not be able to get here without Profile being possible... - if(!$auth->canDo('Profile')) { - msg($lang['profna'],-1); - return false; - } - - if ($_POST['newpass'] != $_POST['passchk']) { - msg($lang['regbadpass'], -1); // complain about misspelled passwords - return false; - } - - //clean fullname and email - $_POST['fullname'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/','',$_POST['fullname'])); - $_POST['email'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/','',$_POST['email'])); - - if (empty($_POST['fullname']) || empty($_POST['email'])) { - msg($lang['profnoempty'],-1); - return false; - } - - if (!mail_isvalid($_POST['email'])){ - msg($lang['regbadmail'],-1); - return false; - } - - if ($_POST['fullname'] != $INFO['userinfo']['name'] && $auth->canDo('modName')) $changes['name'] = $_POST['fullname']; - if ($_POST['email'] != $INFO['userinfo']['mail'] && $auth->canDo('modMail')) $changes['mail'] = $_POST['email']; - if (!empty($_POST['newpass']) && $auth->canDo('modPass')) $changes['pass'] = $_POST['newpass']; - - - if (!count($changes)) { - msg($lang['profnochange'], -1); - return false; - } - - if ($conf['profileconfirm']) { - if (!$auth->checkPass($_SERVER['REMOTE_USER'], $_POST['oldpass'])) { - msg($lang['badlogin'],-1); - return false; + // should not be able to get here without Profile being possible... + if(!$auth->canDo('Profile')) { + msg($lang['profna'],-1); + return false; } - } - if ($result = $auth->triggerUserMod('modify', array($_SERVER['REMOTE_USER'], $changes))) { - // update cookie and session with the changed data - $cookie = base64_decode($_COOKIE[DOKU_COOKIE]); - list($user,$sticky,$pass) = explode('|',$cookie,3); - if ($changes['pass']) $pass = PMA_blowfish_encrypt($changes['pass'],auth_cookiesalt()); + if ($_POST['newpass'] != $_POST['passchk']) { + msg($lang['regbadpass'], -1); // complain about misspelled passwords + return false; + } - auth_setCookie($_SERVER['REMOTE_USER'],$pass,(bool)$sticky); - return true; - } + //clean fullname and email + $_POST['fullname'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/','',$_POST['fullname'])); + $_POST['email'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/','',$_POST['email'])); + + if (empty($_POST['fullname']) || empty($_POST['email'])) { + msg($lang['profnoempty'],-1); + return false; + } + + if (!mail_isvalid($_POST['email'])){ + msg($lang['regbadmail'],-1); + return false; + } + + if ($_POST['fullname'] != $INFO['userinfo']['name'] && $auth->canDo('modName')) $changes['name'] = $_POST['fullname']; + if ($_POST['email'] != $INFO['userinfo']['mail'] && $auth->canDo('modMail')) $changes['mail'] = $_POST['email']; + if (!empty($_POST['newpass']) && $auth->canDo('modPass')) $changes['pass'] = $_POST['newpass']; + + if (!count($changes)) { + msg($lang['profnochange'], -1); + return false; + } + + if ($conf['profileconfirm']) { + if (!$auth->checkPass($_SERVER['REMOTE_USER'], $_POST['oldpass'])) { + msg($lang['badlogin'],-1); + return false; + } + } + + if ($result = $auth->triggerUserMod('modify', array($_SERVER['REMOTE_USER'], $changes))) { + // update cookie and session with the changed data + $cookie = base64_decode($_COOKIE[DOKU_COOKIE]); + list($user,$sticky,$pass) = explode('|',$cookie,3); + if ($changes['pass']) $pass = PMA_blowfish_encrypt($changes['pass'],auth_cookiesalt()); + + auth_setCookie($_SERVER['REMOTE_USER'],$pass,(bool)$sticky); + return true; + } } /** @@ -764,7 +763,7 @@ function updateprofile() { * @author Andreas Gohr * * @return bool true on success, false on any error -*/ + */ function act_resendpwd(){ global $lang; global $conf; @@ -896,8 +895,12 @@ function auth_cryptPassword($clear,$method='',$salt=null){ $len = strlen($clear); $text = $clear.'$'.$magic.'$'.$salt; $bin = pack("H32", md5($clear.$salt.$clear)); - for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); } - for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $clear{0}; } + for($i = $len; $i > 0; $i -= 16) { + $text .= substr($bin, 0, min(16, $i)); + } + for($i = $len; $i > 0; $i >>= 1) { + $text .= ($i & 1) ? chr(0) : $clear{0}; + } $bin = pack("H32", md5($text)); for($i = 0; $i < 1000; $i++) { $new = ($i & 1) ? $clear : $bin; diff --git a/inc/html.php b/inc/html.php index 0ea72c06c..1fb5b0202 100644 --- a/inc/html.php +++ b/inc/html.php @@ -16,13 +16,13 @@ require_once(DOKU_INC.'inc/form.php'); * * @author Andreas Gohr */ -function html_wikilink($id,$name=NULL,$search=''){ - static $xhtml_renderer = NULL; - if(is_null($xhtml_renderer)){ - $xhtml_renderer = p_get_renderer('xhtml'); - } +function html_wikilink($id,$name=null,$search=''){ + static $xhtml_renderer = null; + if(is_null($xhtml_renderer)){ + $xhtml_renderer = p_get_renderer('xhtml'); + } - return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); + return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); } /** @@ -31,11 +31,11 @@ function html_wikilink($id,$name=NULL,$search=''){ * @author Andreas Gohr */ function html_attbuild($attributes){ - $ret = ''; - foreach ( $attributes as $key => $value ) { - $ret .= $key.'="'.formtext($value).'" '; - } - return trim($ret); + $ret = ''; + foreach ( $attributes as $key => $value ) { + $ret .= $key.'="'.formtext($value).'" '; + } + return trim($ret); } /** @@ -44,40 +44,40 @@ function html_attbuild($attributes){ * @author Andreas Gohr */ function html_login(){ - global $lang; - global $conf; - global $ID; - global $auth; + global $lang; + global $conf; + global $ID; + global $auth; - print p_locale_xhtml('login'); - print '
'.NL; - $form = new Doku_Form('dw__login'); - $form->startFieldset($lang['btn_login']); - $form->addHidden('id', $ID); - $form->addHidden('do', 'login'); - $form->addElement(form_makeTextField('u', ((!$_REQUEST['http_credentials']) ? $_REQUEST['u'] : ''), $lang['user'], 'focus__this', 'block')); - $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); - if($conf['rememberme']) { - $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); - } - $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); - $form->endFieldset(); - html_form('login', $form); + print p_locale_xhtml('login'); + print '
'.NL; + $form = new Doku_Form('dw__login'); + $form->startFieldset($lang['btn_login']); + $form->addHidden('id', $ID); + $form->addHidden('do', 'login'); + $form->addElement(form_makeTextField('u', ((!$_REQUEST['http_credentials']) ? $_REQUEST['u'] : ''), $lang['user'], 'focus__this', 'block')); + $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); + if($conf['rememberme']) { + $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); + } + $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); + $form->endFieldset(); + html_form('login', $form); - if($auth && $auth->canDo('addUser') && actionOK('register')){ - print '

'; - print $lang['reghere']; - print ': '.$lang['register'].''; - print '

'; - } + if($auth && $auth->canDo('addUser') && actionOK('register')){ + print '

'; + print $lang['reghere']; + print ': '.$lang['register'].''; + print '

'; + } - if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) { - print '

'; - print $lang['pwdforget']; - print ': '.$lang['btn_resendpwd'].''; - print '

'; - } - print '
'.NL; + if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) { + print '

'; + print $lang['pwdforget']; + print ': '.$lang['btn_resendpwd'].''; + print '

'; + } + print '
'.NL; } /** @@ -87,21 +87,21 @@ function html_login(){ * @author Andreas Gohr */ function html_secedit_button($matches){ - global $ID; - global $INFO; + global $ID; + global $INFO; - $section = $matches[2]; - $name = $matches[1]; + $section = $matches[2]; + $name = $matches[1]; - $secedit = ''; - $secedit .= '
'; - $secedit .= html_btn('secedit',$ID,'', - array('do' => 'edit', - 'lines' => "$section", - 'rev' => $INFO['lastmod']), - 'post', $name); - $secedit .= '
'; - return $secedit; + $secedit = ''; + $secedit .= '
'; + $secedit .= html_btn('secedit',$ID,'', + array('do' => 'edit', + 'lines' => "$section", + 'rev' => $INFO['lastmod']), + 'post', $name); + $secedit .= '
'; + return $secedit; } /** @@ -110,16 +110,16 @@ function html_secedit_button($matches){ * @author Andreas Gohr */ function html_secedit($text,$show=true){ - global $INFO; + global $INFO; - if($INFO['writable'] && $show && !$INFO['rev']){ - $text = preg_replace_callback('##', - 'html_secedit_button', $text); - }else{ - $text = preg_replace('##','',$text); - } + if($INFO['writable'] && $show && !$INFO['rev']){ + $text = preg_replace_callback('##', + 'html_secedit_button', $text); + }else{ + $text = preg_replace('##','',$text); + } - return $text; + return $text; } /** @@ -128,12 +128,12 @@ function html_secedit($text,$show=true){ * @author Andreas Gohr */ function html_topbtn(){ - global $lang; + global $lang; - $ret = ''; - $ret = ''; + $ret = ''; + $ret = ''; - return $ret; + return $ret; } /** @@ -143,53 +143,53 @@ function html_topbtn(){ * @author Andreas Gohr */ function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ - global $conf; - global $lang; + global $conf; + global $lang; - $label = $lang['btn_'.$name]; + $label = $lang['btn_'.$name]; - $ret = ''; - $tip = ''; + $ret = ''; + $tip = ''; - //filter id (without urlencoding) - $id = idfilter($id,false); + //filter id (without urlencoding) + $id = idfilter($id,false); - //make nice URLs even for buttons - if($conf['userewrite'] == 2){ - $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; - }elseif($conf['userewrite']){ - $script = DOKU_BASE.$id; - }else{ - $script = DOKU_BASE.DOKU_SCRIPT; - $params['id'] = $id; - } - - $ret .= '
'; - - if(is_array($params)){ - reset($params); - while (list($key, $val) = each($params)) { - $ret .= ''; + //make nice URLs even for buttons + if($conf['userewrite'] == 2){ + $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; + }elseif($conf['userewrite']){ + $script = DOKU_BASE.$id; + }else{ + $script = DOKU_BASE.DOKU_SCRIPT; + $params['id'] = $id; } - } - if ($tooltip!='') { - $tip = htmlspecialchars($tooltip); - }else{ - $tip = htmlspecialchars($label); - } + $ret .= '
'; - $ret .= ''; + } + } - return $ret; + if ($tooltip!='') { + $tip = htmlspecialchars($tooltip); + }else{ + $tip = htmlspecialchars($label); + } + + $ret .= ' */ function html_show($txt=''){ - global $ID; - global $REV; - global $HIGH; - global $INFO; - //disable section editing for old revisions or in preview - if($txt || $REV){ - $secedit = false; - }else{ - $secedit = true; - } + global $ID; + global $REV; + global $HIGH; + global $INFO; + //disable section editing for old revisions or in preview + if($txt || $REV){ + $secedit = false; + }else{ + $secedit = true; + } - if ($txt){ - //PreviewHeader - echo '
'; - echo p_locale_xhtml('preview'); - echo '
'; - $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); - if($INFO['prependTOC']) $html = tpl_toc(true).$html; - echo $html; - echo '
'; - echo '
'; + if ($txt){ + //PreviewHeader + echo '
'; + echo p_locale_xhtml('preview'); + echo '
'; + $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); + if($INFO['prependTOC']) $html = tpl_toc(true).$html; + echo $html; + echo '
'; + echo '
'; - }else{ - if ($REV) print p_locale_xhtml('showrev'); - $html = p_wiki_xhtml($ID,$REV,true); - $html = html_secedit($html,$secedit); - if($INFO['prependTOC']) $html = tpl_toc(true).$html; - $html = html_hilight($html,$HIGH); - echo $html; - } + }else{ + if ($REV) print p_locale_xhtml('showrev'); + $html = p_wiki_xhtml($ID,$REV,true); + $html = html_secedit($html,$secedit); + if($INFO['prependTOC']) $html = tpl_toc(true).$html; + $html = html_hilight($html,$HIGH); + echo $html; + } } /** @@ -236,25 +236,25 @@ function html_show($txt=''){ * @author Andreas Gohr */ function html_draft(){ - global $INFO; - global $ID; - global $lang; - global $conf; - $draft = unserialize(io_readFile($INFO['draft'],false)); - $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); + global $INFO; + global $ID; + global $lang; + global $conf; + $draft = unserialize(io_readFile($INFO['draft'],false)); + $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); - print p_locale_xhtml('draft'); - $form = new Doku_Form('dw__editform'); - $form->addHidden('id', $ID); - $form->addHidden('date', $draft['date']); - $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly'))); - $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); - $form->addElement($lang['draftdate'].' '. dformat(filemtime($INFO['draft']))); - $form->addElement(form_makeCloseTag('div')); - $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); - $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); - $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3'))); - html_form('draft', $form); + print p_locale_xhtml('draft'); + $form = new Doku_Form('dw__editform'); + $form->addHidden('id', $ID); + $form->addHidden('date', $draft['date']); + $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly'))); + $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); + $form->addElement($lang['draftdate'].' '. dformat(filemtime($INFO['draft']))); + $form->addElement(form_makeCloseTag('div')); + $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); + $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); + $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3'))); + html_form('draft', $form); } /** @@ -264,12 +264,12 @@ function html_draft(){ * @author Harry Fuecks */ function html_hilight($html,$phrases){ - $phrases = array_filter((array) $phrases); - $regex = join('|',array_map('preg_quote_cb',$phrases)); + $phrases = array_filter((array) $phrases); + $regex = join('|',array_map('preg_quote_cb',$phrases)); - if ($regex === '') return $html; - $html = preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html); - return $html; + if ($regex === '') return $html; + $html = preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html); + return $html; } /** @@ -278,11 +278,11 @@ function html_hilight($html,$phrases){ * @author Harry Fuecks */ function html_hilight_callback($m) { - $hlight = unslash($m[0]); - if ( !isset($m[2])) { - $hlight = ''.$hlight.''; - } - return $hlight; + $hlight = unslash($m[0]); + if ( !isset($m[2])) { + $hlight = ''.$hlight.''; + } + return $hlight; } /** @@ -291,83 +291,83 @@ function html_hilight_callback($m) { * @author Andreas Gohr */ function html_search(){ - require_once(DOKU_INC.'inc/search.php'); - require_once(DOKU_INC.'inc/fulltext.php'); - global $conf; - global $QUERY; - global $ID; - global $lang; + require_once(DOKU_INC.'inc/search.php'); + require_once(DOKU_INC.'inc/fulltext.php'); + global $conf; + global $QUERY; + global $ID; + global $lang; - print p_locale_xhtml('searchpage'); - flush(); + print p_locale_xhtml('searchpage'); + flush(); - //check if search is restricted to namespace - if(preg_match('/@([^@]*)/',$QUERY,$match)) { - $id = cleanID($match[1]); - } else { - $id = cleanID($QUERY); - } - - //show progressbar - print '
'.NL; - print ''.NL; - print '
'.NL; - flush(); - - //do quick pagesearch - $data = array(); - - if($id) $data = ft_pageLookup($id); - if(count($data)){ - print '
'; - print '

'.$lang['quickhits'].':

'; - print '
    '; - foreach($data as $id){ - print '
  • '; - $ns = getNS($id); - if($ns){ - $name = shorten(noNS($id), ' ('.$ns.')',30); - }else{ - $name = $id; - } - print html_wikilink(':'.$id,$name); - print '
  • '; + //check if search is restricted to namespace + if(preg_match('/@([^@]*)/',$QUERY,$match)) { + $id = cleanID($match[1]); + } else { + $id = cleanID($QUERY); } - print '
'; - //clear float (see http://www.complexspiral.com/publications/containing-floats/) - print '
 
'; - print '
'; - } - flush(); - //do fulltext search - $data = ft_pageSearch($QUERY,$regex); - if(count($data)){ - $num = 1; - foreach($data as $id => $cnt){ - print '
'; - print html_wikilink(':'.$id,useHeading('navigation')?NULL:$id,$regex); - if($cnt !== 0){ - print ': '.$cnt.' '.$lang['hits'].'
'; - if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? - print '
'.ft_snippet($id,$regex).'
'; + //show progressbar + print '
'.NL; + print ''.NL; + print '
'.NL; + flush(); + + //do quick pagesearch + $data = array(); + + if($id) $data = ft_pageLookup($id); + if(count($data)){ + print '
'; + print '

'.$lang['quickhits'].':

'; + print '
    '; + foreach($data as $id){ + print '
  • '; + $ns = getNS($id); + if($ns){ + $name = shorten(noNS($id), ' ('.$ns.')',30); + }else{ + $name = $id; + } + print html_wikilink(':'.$id,$name); + print '
  • '; } - $num++; - } - print '
'; - flush(); + print ' '; + //clear float (see http://www.complexspiral.com/publications/containing-floats/) + print '
 
'; + print '
'; } - }else{ - print '
'.$lang['nothingfound'].'
'; - } + flush(); - //hide progressbar - print ''.NL; - flush(); + //do fulltext search + $data = ft_pageSearch($QUERY,$regex); + if(count($data)){ + $num = 1; + foreach($data as $id => $cnt){ + print '
'; + print html_wikilink(':'.$id,useHeading('navigation')?null:$id,$regex); + if($cnt !== 0){ + print ': '.$cnt.' '.$lang['hits'].'
'; + if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? + print '
'.ft_snippet($id,$regex).'
'; + } + $num++; + } + print '
'; + flush(); + } + }else{ + print '
'.$lang['nothingfound'].'
'; + } + + //hide progressbar + print ''.NL; + flush(); } /** @@ -376,20 +376,20 @@ function html_search(){ * @author Andreas Gohr */ function html_locked(){ - global $ID; - global $conf; - global $lang; - global $INFO; + global $ID; + global $conf; + global $lang; + global $INFO; - $locktime = filemtime(wikiLockFN($ID)); - $expire = dformat($locktime + $conf['locktime']); - $min = round(($conf['locktime'] - (time() - $locktime) )/60); + $locktime = filemtime(wikiLockFN($ID)); + $expire = dformat($locktime + $conf['locktime']); + $min = round(($conf['locktime'] - (time() - $locktime) )/60); - print p_locale_xhtml('locked'); - print '
    '; - print '
  • '.$lang['lockedby'].': '.editorinfo($INFO['locked']).'
  • '; - print '
  • '.$lang['lockexpire'].': '.$expire.' ('.$min.' min)
  • '; - print '
'; + print p_locale_xhtml('locked'); + print '
    '; + print '
  • '.$lang['lockedby'].': '.editorinfo($INFO['locked']).'
  • '; + print '
  • '.$lang['lockexpire'].': '.$expire.' ('.$min.' min)
  • '; + print '
'; } /** @@ -399,159 +399,159 @@ function html_locked(){ * @author Ben Coburn */ function html_revisions($first=0){ - global $ID; - global $INFO; - global $conf; - global $lang; - /* we need to get one additionally log entry to be able to - * decide if this is the last page or is there another one. - * see html_recent() - */ - $revisions = getRevisions($ID, $first, $conf['recent']+1); - if(count($revisions)==0 && $first!=0){ - $first=0; - $revisions = getRevisions($ID, $first, $conf['recent']+1);; - } - $hasNext = false; - if (count($revisions)>$conf['recent']) { - $hasNext = true; - array_pop($revisions); // remove extra log entry - } - - $date = dformat($INFO['lastmod']); - - print p_locale_xhtml('revisions'); - - $form = new Doku_Form('page__revisions', wl($ID)); - $form->addElement(form_makeOpenTag('ul')); - if($INFO['exists'] && $first==0){ - if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) - $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); - else - $form->addElement(form_makeOpenTag('li')); - $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); - $form->addElement(form_makeTag('input', array( - 'type' => 'checkbox', - 'name' => 'rev2[]', - 'value' => 'current'))); - - $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); - $form->addElement($date); - $form->addElement(form_makeCloseTag('span')); - - $form->addElement(form_makeTag('img', array( - 'src' => DOKU_BASE.'lib/images/blank.gif', - 'width' => '15', - 'height' => '11', - 'alt' => ''))); - - $form->addElement(form_makeOpenTag('a', array( - 'class' => 'wikilink1', - 'href' => wl($ID)))); - $form->addElement($ID); - $form->addElement(form_makeCloseTag('a')); - - $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); - $form->addElement(' – '); - $form->addElement(htmlspecialchars($INFO['sum'])); - $form->addElement(form_makeCloseTag('span')); - - $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); - $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor'])); - $form->addElement(form_makeCloseTag('span')); - - $form->addElement('('.$lang['current'].')'); - $form->addElement(form_makeCloseTag('div')); - $form->addElement(form_makeCloseTag('li')); - } - - foreach($revisions as $rev){ - $date = dformat($rev); - $info = getRevisionInfo($ID,$rev,true); - $exists = page_exists($ID,$rev); - - if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) - $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); - else - $form->addElement(form_makeOpenTag('li')); - $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); - if($exists){ - $form->addElement(form_makeTag('input', array( - 'type' => 'checkbox', - 'name' => 'rev2[]', - 'value' => $rev))); - }else{ - $form->addElement(form_makeTag('img', array( - 'src' => DOKU_BASE.'lib/images/blank.gif', - 'width' => 14, - 'height' => 11, - 'alt' => ''))); + global $ID; + global $INFO; + global $conf; + global $lang; + /* we need to get one additionally log entry to be able to + * decide if this is the last page or is there another one. + * see html_recent() + */ + $revisions = getRevisions($ID, $first, $conf['recent']+1); + if(count($revisions)==0 && $first!=0){ + $first=0; + $revisions = getRevisions($ID, $first, $conf['recent']+1);; + } + $hasNext = false; + if (count($revisions)>$conf['recent']) { + $hasNext = true; + array_pop($revisions); // remove extra log entry } - $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); - $form->addElement($date); - $form->addElement(form_makeCloseTag('span')); + $date = dformat($INFO['lastmod']); - if($exists){ - $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link'))); - $form->addElement(form_makeTag('img', array( - 'src' => DOKU_BASE.'lib/images/diff.png', - 'width' => 15, - 'height' => 11, - 'title' => $lang['diff'], - 'alt' => $lang['diff']))); - $form->addElement(form_makeCloseTag('a')); + print p_locale_xhtml('revisions'); - $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev",false,'&'), 'class' => 'wikilink1'))); - $form->addElement($ID); - $form->addElement(form_makeCloseTag('a')); - }else{ - $form->addElement(form_makeTag('img', array( - 'src' => DOKU_BASE.'lib/images/blank.gif', - 'width' => '15', - 'height' => '11', - 'alt' => ''))); - $form->addElement($ID); + $form = new Doku_Form('page__revisions', wl($ID)); + $form->addElement(form_makeOpenTag('ul')); + if($INFO['exists'] && $first==0){ + if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) + $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); + else + $form->addElement(form_makeOpenTag('li')); + $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); + $form->addElement(form_makeTag('input', array( + 'type' => 'checkbox', + 'name' => 'rev2[]', + 'value' => 'current'))); + + $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); + $form->addElement($date); + $form->addElement(form_makeCloseTag('span')); + + $form->addElement(form_makeTag('img', array( + 'src' => DOKU_BASE.'lib/images/blank.gif', + 'width' => '15', + 'height' => '11', + 'alt' => ''))); + + $form->addElement(form_makeOpenTag('a', array( + 'class' => 'wikilink1', + 'href' => wl($ID)))); + $form->addElement($ID); + $form->addElement(form_makeCloseTag('a')); + + $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); + $form->addElement(' – '); + $form->addElement(htmlspecialchars($INFO['sum'])); + $form->addElement(form_makeCloseTag('span')); + + $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); + $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor'])); + $form->addElement(form_makeCloseTag('span')); + + $form->addElement('('.$lang['current'].')'); + $form->addElement(form_makeCloseTag('div')); + $form->addElement(form_makeCloseTag('li')); } - $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); - $form->addElement(' – '); - $form->addElement(htmlspecialchars($info['sum'])); - $form->addElement(form_makeCloseTag('span')); + foreach($revisions as $rev){ + $date = dformat($rev); + $info = getRevisionInfo($ID,$rev,true); + $exists = page_exists($ID,$rev); - $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); - if($info['user']){ - $form->addElement(editorinfo($info['user'])); - if(auth_ismanager()){ - $form->addElement(' ('.$info['ip'].')'); - } - }else{ - $form->addElement($info['ip']); + if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) + $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); + else + $form->addElement(form_makeOpenTag('li')); + $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); + if($exists){ + $form->addElement(form_makeTag('input', array( + 'type' => 'checkbox', + 'name' => 'rev2[]', + 'value' => $rev))); + }else{ + $form->addElement(form_makeTag('img', array( + 'src' => DOKU_BASE.'lib/images/blank.gif', + 'width' => 14, + 'height' => 11, + 'alt' => ''))); + } + + $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); + $form->addElement($date); + $form->addElement(form_makeCloseTag('span')); + + if($exists){ + $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link'))); + $form->addElement(form_makeTag('img', array( + 'src' => DOKU_BASE.'lib/images/diff.png', + 'width' => 15, + 'height' => 11, + 'title' => $lang['diff'], + 'alt' => $lang['diff']))); + $form->addElement(form_makeCloseTag('a')); + + $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev",false,'&'), 'class' => 'wikilink1'))); + $form->addElement($ID); + $form->addElement(form_makeCloseTag('a')); + }else{ + $form->addElement(form_makeTag('img', array( + 'src' => DOKU_BASE.'lib/images/blank.gif', + 'width' => '15', + 'height' => '11', + 'alt' => ''))); + $form->addElement($ID); + } + + $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); + $form->addElement(' – '); + $form->addElement(htmlspecialchars($info['sum'])); + $form->addElement(form_makeCloseTag('span')); + + $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); + if($info['user']){ + $form->addElement(editorinfo($info['user'])); + if(auth_ismanager()){ + $form->addElement(' ('.$info['ip'].')'); + } + }else{ + $form->addElement($info['ip']); + } + $form->addElement(form_makeCloseTag('span')); + + $form->addElement(form_makeCloseTag('div')); + $form->addElement(form_makeCloseTag('li')); } - $form->addElement(form_makeCloseTag('span')); + $form->addElement(form_makeCloseTag('ul')); + $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); + html_form('revisions', $form); - $form->addElement(form_makeCloseTag('div')); - $form->addElement(form_makeCloseTag('li')); - } - $form->addElement(form_makeCloseTag('ul')); - $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); - html_form('revisions', $form); - - print ''.DOKU_LF.'
'.DOKU_LF; $out .= ''.DOKU_LF; - return $out; } + return $out; +} /** * Callback for html_buildlist @@ -1484,7 +1488,7 @@ function html_list_toc($item){ } return ''. - hsc($item['title']).''; + hsc($item['title']).''; } /** @@ -1500,9 +1504,9 @@ function html_list_toc($item){ function html_mktocitem($link, $text, $level, $hash='#'){ global $conf; return array( 'link' => $hash.$link, - 'title' => $text, - 'type' => 'ul', - 'level' => $level); + 'title' => $text, + 'type' => 'ul', + 'level' => $level); } /** @@ -1512,9 +1516,9 @@ function html_mktocitem($link, $text, $level, $hash='#'){ * @author Tom N Harris */ function html_form($name, &$form) { - // Safety check in case the caller forgets. - $form->endFieldset(); - trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); + // Safety check in case the caller forgets. + $form->endFieldset(); + trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); } /** @@ -1522,7 +1526,7 @@ function html_form($name, &$form) { * Just calls printForm() on the data object. */ function html_form_output($data) { - $data->printForm(); + $data->printForm(); } /** @@ -1602,4 +1606,3 @@ function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts return $out; } -//Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/httputils.php b/inc/httputils.php index c55e9ab0d..ed5d6dfd5 100644 --- a/inc/httputils.php +++ b/inc/httputils.php @@ -19,45 +19,45 @@ define('HTTP_CHUNK_SIZE',16*1024); * @returns void or exits with previously header() commands executed */ function http_conditionalRequest($timestamp){ - // A PHP implementation of conditional get, see - // http://fishbowl.pastiche.org/archives/001132.html - $last_modified = substr(gmdate('r', $timestamp), 0, -5).'GMT'; - $etag = '"'.md5($last_modified).'"'; - // Send the headers - header("Last-Modified: $last_modified"); - header("ETag: $etag"); - // See if the client has provided the required headers - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])){ - $if_modified_since = stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']); - }else{ - $if_modified_since = false; - } + // A PHP implementation of conditional get, see + // http://fishbowl.pastiche.org/archives/001132.html + $last_modified = substr(gmdate('r', $timestamp), 0, -5).'GMT'; + $etag = '"'.md5($last_modified).'"'; + // Send the headers + header("Last-Modified: $last_modified"); + header("ETag: $etag"); + // See if the client has provided the required headers + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])){ + $if_modified_since = stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']); + }else{ + $if_modified_since = false; + } - if (isset($_SERVER['HTTP_IF_NONE_MATCH'])){ - $if_none_match = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); - }else{ - $if_none_match = false; - } + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])){ + $if_none_match = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); + }else{ + $if_none_match = false; + } - if (!$if_modified_since && !$if_none_match){ - return; - } + if (!$if_modified_since && !$if_none_match){ + return; + } - // At least one of the headers is there - check them - if ($if_none_match && $if_none_match != $etag) { - return; // etag is there but doesn't match - } + // At least one of the headers is there - check them + if ($if_none_match && $if_none_match != $etag) { + return; // etag is there but doesn't match + } - if ($if_modified_since && $if_modified_since != $last_modified) { - return; // if-modified-since is there but doesn't match - } + if ($if_modified_since && $if_modified_since != $last_modified) { + return; // if-modified-since is there but doesn't match + } - // Nothing has changed since their last request - serve a 304 and exit - header('HTTP/1.0 304 Not Modified'); + // Nothing has changed since their last request - serve a 304 and exit + header('HTTP/1.0 304 Not Modified'); - // don't produce output, even if compression is on - ob_end_clean(); - exit; + // don't produce output, even if compression is on + ob_end_clean(); + exit; } /** @@ -67,24 +67,24 @@ function http_conditionalRequest($timestamp){ * @returns void or exits with previously header() commands executed */ function http_sendfile($file) { - global $conf; + global $conf; - //use x-sendfile header to pass the delivery to compatible webservers - if($conf['xsendfile'] == 1){ - header("X-LIGHTTPD-send-file: $file"); - ob_end_clean(); - exit; - }elseif($conf['xsendfile'] == 2){ - header("X-Sendfile: $file"); - ob_end_clean(); - exit; - }elseif($conf['xsendfile'] == 3){ - header("X-Accel-Redirect: $file"); - ob_end_clean(); - exit; - } + //use x-sendfile header to pass the delivery to compatible webservers + if($conf['xsendfile'] == 1){ + header("X-LIGHTTPD-send-file: $file"); + ob_end_clean(); + exit; + }elseif($conf['xsendfile'] == 2){ + header("X-Sendfile: $file"); + ob_end_clean(); + exit; + }elseif($conf['xsendfile'] == 3){ + header("X-Accel-Redirect: $file"); + ob_end_clean(); + exit; + } - return false; + return false; } /** @@ -166,11 +166,11 @@ function http_rangeRequest($fh,$size,$mime){ fseek($fh,$start); //seek to start of range $chunk = ($len > HTTP_CHUNK_SIZE) ? HTTP_CHUNK_SIZE : $len; while (!feof($fh) && $chunk > 0) { - @set_time_limit(30); // large files can take a lot of time - print fread($fh, $chunk); - flush(); - $len -= $chunk; - $chunk = ($len > HTTP_CHUNK_SIZE) ? HTTP_CHUNK_SIZE : $len; + @set_time_limit(30); // large files can take a lot of time + print fread($fh, $chunk); + flush(); + $len -= $chunk; + $chunk = ($len > HTTP_CHUNK_SIZE) ? HTTP_CHUNK_SIZE : $len; } } if($parts > 1){ diff --git a/inc/indexer.php b/inc/indexer.php index 4b59684cd..1f2ff89e3 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -227,18 +227,18 @@ function idx_getPageWords($page){ // ensure the deaccented or romanised page names of internal links are added to the token array // (this is necessary for the backlink function -- there maybe a better way!) if ($conf['deaccent']) { - $links = p_get_metadata($page,'relation references'); + $links = p_get_metadata($page,'relation references'); - if (!empty($links)) { - $tmp = join(' ',array_keys($links)); // make a single string - $tmp = strtr($tmp, ':', ' '); // replace namespace separator with a space - $link_tokens = array_unique(explode(' ', $tmp)); // break into tokens + if (!empty($links)) { + $tmp = join(' ',array_keys($links)); // make a single string + $tmp = strtr($tmp, ':', ' '); // replace namespace separator with a space + $link_tokens = array_unique(explode(' ', $tmp)); // break into tokens - foreach ($link_tokens as $link_token) { - if (isset($tokens[$link_token])) continue; - $tokens[$link_token] = 1; + foreach ($link_tokens as $link_token) { + if (isset($tokens[$link_token])) continue; + $tokens[$link_token] = 1; + } } - } } $words = array(); @@ -537,7 +537,7 @@ function idx_getIndexWordsSorted($words,&$result){ } } } - return $wids; + return $wids; } /** @@ -664,7 +664,9 @@ function idx_upgradePageWords(){ if (empty($page_idx)) return; $pagewords = array(); $len = count($page_idx); - for ($n=0;$n<$len;$n++) $pagewords[] = array(); + for ($n=0;$n<$len;$n++){ + $pagewords[] = array(); + } unset($page_idx); $n=0; diff --git a/inc/infoutils.php b/inc/infoutils.php index c2db31f7d..a334e0942 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -49,25 +49,25 @@ function checkUpdateMessages(){ * @author Andreas Gohr */ function getVersion(){ - //import version string - if(@file_exists(DOKU_INC.'VERSION')){ - //official release - return 'Release '.trim(io_readfile(DOKU_INC.'VERSION')); - }elseif(is_dir(DOKU_INC.'_darcs')){ - //darcs checkout - read last 2000 bytes of inventory - $sz = filesize(DOKU_INC.'_darcs/inventory'); - $seek = max(0,$sz-2000); - $fh = fopen(DOKU_INC.'_darcs/inventory','rb'); - fseek($fh,$seek); - $chunk = fread($fh,2000); - fclose($fh); - $inv = preg_grep('#\*\*\d{14}[\]$]#',explode("\n",$chunk)); - $cur = array_pop($inv); - preg_match('#\*\*(\d{4})(\d{2})(\d{2})#',$cur,$matches); - return 'Darcs '.$matches[1].'-'.$matches[2].'-'.$matches[3]; - }else{ - return 'snapshot?'; - } + //import version string + if(@file_exists(DOKU_INC.'VERSION')){ + //official release + return 'Release '.trim(io_readfile(DOKU_INC.'VERSION')); + }elseif(is_dir(DOKU_INC.'_darcs')){ + //darcs checkout - read last 2000 bytes of inventory + $sz = filesize(DOKU_INC.'_darcs/inventory'); + $seek = max(0,$sz-2000); + $fh = fopen(DOKU_INC.'_darcs/inventory','rb'); + fseek($fh,$seek); + $chunk = fread($fh,2000); + fclose($fh); + $inv = preg_grep('#\*\*\d{14}[\]$]#',explode("\n",$chunk)); + $cur = array_pop($inv); + preg_match('#\*\*(\d{4})(\d{2})(\d{2})#',$cur,$matches); + return 'Darcs '.$matches[1].'-'.$matches[2].'-'.$matches[3]; + }else{ + return 'snapshot?'; + } } /** @@ -76,148 +76,147 @@ function getVersion(){ * @author Andreas Gohr */ function check(){ - global $conf; - global $INFO; + global $conf; + global $INFO; - msg('DokuWiki version: '.getVersion(),1); + msg('DokuWiki version: '.getVersion(),1); - if(version_compare(phpversion(),'5.0.0','<')){ - msg('Your PHP version is too old ('.phpversion().' vs. 5.0.0+ recommended)',-1); - }else{ - msg('PHP version '.phpversion(),1); - } - - $mem = (int) php_to_byte(ini_get('memory_limit')); - if($mem){ - if($mem < 16777216){ - msg('PHP is limited to less than 16MB RAM ('.$mem.' bytes). Increase memory_limit in php.ini',-1); - }elseif($mem < 20971520){ - msg('PHP is limited to less than 20MB RAM ('.$mem.' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini',-1); - }elseif($mem < 33554432){ - msg('PHP is limited to less than 32MB RAM ('.$mem.' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini',0); + if(version_compare(phpversion(),'5.0.0','<')){ + msg('Your PHP version is too old ('.phpversion().' vs. 5.0.0+ recommended)',-1); }else{ - msg('More than 32MB RAM ('.$mem.' bytes) available.',1); + msg('PHP version '.phpversion(),1); } - } - - if(is_writable($conf['changelog'])){ - msg('Changelog is writable',1); - }else{ - if (@file_exists($conf['changelog'])) { - msg('Changelog is not writable',-1); + $mem = (int) php_to_byte(ini_get('memory_limit')); + if($mem){ + if($mem < 16777216){ + msg('PHP is limited to less than 16MB RAM ('.$mem.' bytes). Increase memory_limit in php.ini',-1); + }elseif($mem < 20971520){ + msg('PHP is limited to less than 20MB RAM ('.$mem.' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini',-1); + }elseif($mem < 33554432){ + msg('PHP is limited to less than 32MB RAM ('.$mem.' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini',0); + }else{ + msg('More than 32MB RAM ('.$mem.' bytes) available.',1); + } } - } - if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) { - msg('Old changelog exists', 0); - } - - if (@file_exists($conf['changelog'].'_failed')) { - msg('Importing old changelog failed', -1); - } else if (@file_exists($conf['changelog'].'_importing')) { - msg('Importing old changelog now.', 0); - } else if (@file_exists($conf['changelog'].'_import_ok')) { - msg('Old changelog imported', 1); - if (!plugin_isdisabled('importoldchangelog')) { - msg('Importoldchangelog plugin not disabled after import', -1); - } - } - - if(is_writable($conf['datadir'])){ - msg('Datadir is writable',1); - }else{ - msg('Datadir is not writable',-1); - } - - if(is_writable($conf['olddir'])){ - msg('Attic is writable',1); - }else{ - msg('Attic is not writable',-1); - } - - if(is_writable($conf['mediadir'])){ - msg('Mediadir is writable',1); - }else{ - msg('Mediadir is not writable',-1); - } - - if(is_writable($conf['cachedir'])){ - msg('Cachedir is writable',1); - }else{ - msg('Cachedir is not writable',-1); - } - - if(is_writable($conf['lockdir'])){ - msg('Lockdir is writable',1); - }else{ - msg('Lockdir is not writable',-1); - } - - if($conf['authtype'] == 'plain'){ - if(is_writable(DOKU_CONF.'users.auth.php')){ - msg('conf/users.auth.php is writable',1); + if(is_writable($conf['changelog'])){ + msg('Changelog is writable',1); }else{ - msg('conf/users.auth.php is not writable',0); + if (@file_exists($conf['changelog'])) { + msg('Changelog is not writable',-1); + } } - } - if(function_exists('mb_strpos')){ - if(defined('UTF8_NOMBSTRING')){ - msg('mb_string extension is available but will not be used',0); + if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) { + msg('Old changelog exists', 0); + } + + if (@file_exists($conf['changelog'].'_failed')) { + msg('Importing old changelog failed', -1); + } else if (@file_exists($conf['changelog'].'_importing')) { + msg('Importing old changelog now.', 0); + } else if (@file_exists($conf['changelog'].'_import_ok')) { + msg('Old changelog imported', 1); + if (!plugin_isdisabled('importoldchangelog')) { + msg('Importoldchangelog plugin not disabled after import', -1); + } + } + + if(is_writable($conf['datadir'])){ + msg('Datadir is writable',1); }else{ - msg('mb_string extension is available and will be used',1); - if(ini_get('mbstring.func_overload') != 0){ - msg('mb_string function overloading is enabled, this will cause problems and should be disabled',-1); - } + msg('Datadir is not writable',-1); } - }else{ - msg('mb_string extension not available - PHP only replacements will be used',0); - } - if($conf['allowdebug']){ - msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0',-1); - }else{ - msg('Debugging support is disabled',1); - } + if(is_writable($conf['olddir'])){ + msg('Attic is writable',1); + }else{ + msg('Attic is not writable',-1); + } - if($INFO['userinfo']['name']){ - msg('You are currently logged in as '.$_SERVER['REMOTE_USER'].' ('.$INFO['userinfo']['name'].')',0); - msg('You are part of the groups '.join($INFO['userinfo']['grps'],', '),0); - }else{ - msg('You are currently not logged in',0); - } + if(is_writable($conf['mediadir'])){ + msg('Mediadir is writable',1); + }else{ + msg('Mediadir is not writable',-1); + } - msg('Your current permission for this page is '.$INFO['perm'],0); + if(is_writable($conf['cachedir'])){ + msg('Cachedir is writable',1); + }else{ + msg('Cachedir is not writable',-1); + } - if(is_writable($INFO['filepath'])){ - msg('The current page is writable by the webserver',0); - }else{ - msg('The current page is not writable by the webserver',0); - } + if(is_writable($conf['lockdir'])){ + msg('Lockdir is writable',1); + }else{ + msg('Lockdir is not writable',-1); + } - if($INFO['writable']){ - msg('The current page is writable by you',0); - }else{ - msg('The current page is not writable by you',0); - } + if($conf['authtype'] == 'plain'){ + if(is_writable(DOKU_CONF.'users.auth.php')){ + msg('conf/users.auth.php is writable',1); + }else{ + msg('conf/users.auth.php is not writable',0); + } + } - require_once(DOKU_INC.'inc/HTTPClient.php'); - $check = wl('','',true).'data/_dummy'; - $http = new DokuHTTPClient(); - $http->timeout = 6; - $res = $http->get($check); - if(strpos($res,'data directory') !== false){ - msg('It seems like the data directory is accessible from the web. - Make sure this directory is properly protected - (See security)',-1); - }elseif($http->status == 404 || $http->status == 403){ - msg('The data directory seems to be properly protected',1); - }else{ - msg('Failed to check if the data directory is accessible from the web. - Make sure this directory is properly protected - (See security)',-1); - } + if(function_exists('mb_strpos')){ + if(defined('UTF8_NOMBSTRING')){ + msg('mb_string extension is available but will not be used',0); + }else{ + msg('mb_string extension is available and will be used',1); + if(ini_get('mbstring.func_overload') != 0){ + msg('mb_string function overloading is enabled, this will cause problems and should be disabled',-1); + } + } + }else{ + msg('mb_string extension not available - PHP only replacements will be used',0); + } + + if($conf['allowdebug']){ + msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0',-1); + }else{ + msg('Debugging support is disabled',1); + } + + if($INFO['userinfo']['name']){ + msg('You are currently logged in as '.$_SERVER['REMOTE_USER'].' ('.$INFO['userinfo']['name'].')',0); + msg('You are part of the groups '.join($INFO['userinfo']['grps'],', '),0); + }else{ + msg('You are currently not logged in',0); + } + + msg('Your current permission for this page is '.$INFO['perm'],0); + + if(is_writable($INFO['filepath'])){ + msg('The current page is writable by the webserver',0); + }else{ + msg('The current page is not writable by the webserver',0); + } + + if($INFO['writable']){ + msg('The current page is writable by you',0); + }else{ + msg('The current page is not writable by you',0); + } + + require_once(DOKU_INC.'inc/HTTPClient.php'); + $check = wl('','',true).'data/_dummy'; + $http = new DokuHTTPClient(); + $http->timeout = 6; + $res = $http->get($check); + if(strpos($res,'data directory') !== false){ + msg('It seems like the data directory is accessible from the web. + Make sure this directory is properly protected + (See security)',-1); + }elseif($http->status == 404 || $http->status == 403){ + msg('The data directory seems to be properly protected',1); + }else{ + msg('Failed to check if the data directory is accessible from the web. + Make sure this directory is properly protected + (See security)',-1); + } } /** @@ -238,26 +237,26 @@ function check(){ * @see html_msgarea */ function msg($message,$lvl=0,$line='',$file=''){ - global $MSG; - $errors[-1] = 'error'; - $errors[0] = 'info'; - $errors[1] = 'success'; - $errors[2] = 'notify'; + global $MSG; + $errors[-1] = 'error'; + $errors[0] = 'info'; + $errors[1] = 'success'; + $errors[2] = 'notify'; - if($line || $file) $message.=' ['.basename($file).':'.$line.']'; + if($line || $file) $message.=' ['.basename($file).':'.$line.']'; - if(!headers_sent()){ - if(!isset($MSG)) $MSG = array(); - $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); - }else{ - $MSG = array(); - $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); - if(function_exists('html_msgarea')){ - html_msgarea(); + if(!headers_sent()){ + if(!isset($MSG)) $MSG = array(); + $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); }else{ - print "ERROR($lvl) $message"; + $MSG = array(); + $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); + if(function_exists('html_msgarea')){ + html_msgarea(); + }else{ + print "ERROR($lvl) $message"; + } } - } } /** @@ -268,9 +267,9 @@ function msg($message,$lvl=0,$line='',$file=''){ * @author Andreas Gohr */ function dbg($msg,$hidden=false){ - (!$hidden) ? print '
' : print "";
+    (!$hidden) ? print '
' : print "";
 }
 
 /**
@@ -279,19 +278,19 @@ function dbg($msg,$hidden=false){
  * @author Andreas Gohr 
  */
 function dbglog($msg,$header=''){
-  global $conf;
-  if(is_object($msg) || is_array($msg)){
-    $msg = print_r($msg,true);
-  }
+    global $conf;
+    if(is_object($msg) || is_array($msg)){
+        $msg = print_r($msg,true);
+    }
 
-  if($header) $msg = "$header\n$msg";
+    if($header) $msg = "$header\n$msg";
 
-  $file = $conf['cachedir'].'/debug.log';
-  $fh = fopen($file,'a');
-  if($fh){
-    fwrite($fh,date('H:i:s ').$_SERVER['REMOTE_ADDR'].': '.$msg."\n");
-    fclose($fh);
-  }
+    $file = $conf['cachedir'].'/debug.log';
+    $fh = fopen($file,'a');
+    if($fh){
+        fwrite($fh,date('H:i:s ').$_SERVER['REMOTE_ADDR'].': '.$msg."\n");
+        fclose($fh);
+    }
 }
 
 /**
@@ -300,44 +299,44 @@ function dbglog($msg,$header=''){
  * @author Gary Owen 
  */
 function dbg_backtrace(){
-  // Get backtrace
-  $backtrace = debug_backtrace();
+    // Get backtrace
+    $backtrace = debug_backtrace();
 
-  // Unset call to debug_print_backtrace
-  array_shift($backtrace);
+    // Unset call to debug_print_backtrace
+    array_shift($backtrace);
 
-  // Iterate backtrace
-  $calls = array();
-  $depth = count($backtrace) - 1;
-  foreach ($backtrace as $i => $call) {
-    $location = $call['file'] . ':' . $call['line'];
-    $function = (isset($call['class'])) ?
-    $call['class'] . $call['type'] . $call['function'] : $call['function'];
+    // Iterate backtrace
+    $calls = array();
+    $depth = count($backtrace) - 1;
+    foreach ($backtrace as $i => $call) {
+        $location = $call['file'] . ':' . $call['line'];
+        $function = (isset($call['class'])) ?
+            $call['class'] . $call['type'] . $call['function'] : $call['function'];
 
-    $params = array();
-    if (isset($call['args'])){
-        foreach($call['args'] as $arg){
-            if(is_object($arg)){
-                $params[] = '[Object '.get_class($arg).']';
-            }elseif(is_array($arg)){
-                $params[] = '[Array]';
-            }elseif(is_null($arg)){
-                $param[] = '[NULL]';
-            }else{
-                $params[] = (string) '"'.$arg.'"';
+        $params = array();
+        if (isset($call['args'])){
+            foreach($call['args'] as $arg){
+                if(is_object($arg)){
+                    $params[] = '[Object '.get_class($arg).']';
+                }elseif(is_array($arg)){
+                    $params[] = '[Array]';
+                }elseif(is_null($arg)){
+                    $param[] = '[NULL]';
+                }else{
+                    $params[] = (string) '"'.$arg.'"';
+                }
             }
         }
+        $params = implode(', ',$params);
+
+        $calls[$depth - $i] = sprintf('%s(%s) called at %s',
+                $function,
+                str_replace("\n", '\n', $params),
+                $location);
     }
-    $params = implode(', ',$params);
+    ksort($calls);
 
-    $calls[$depth - $i] = sprintf('%s(%s) called at %s',
-                          $function,
-                          str_replace("\n", '\n', $params),
-                          $location);
-  }
-  ksort($calls);
-
-  return implode("\n", $calls);
+    return implode("\n", $calls);
 }
 
 /**
diff --git a/inc/init.php b/inc/init.php
index 0c474e33d..58fa3e25b 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -3,292 +3,297 @@
  * Initialize some defaults needed for DokuWiki
  */
 
-  // start timing Dokuwiki execution
-  function delta_time($start=0) {
+// start timing Dokuwiki execution
+function delta_time($start=0) {
     list($usec, $sec) = explode(" ", microtime());
     return ((float)$usec+(float)$sec)-((float)$start);
-  }
-  define('DOKU_START_TIME', delta_time());
+}
+define('DOKU_START_TIME', delta_time());
 
-  global $config_cascade;
-  $config_cascade = '';
+global $config_cascade;
+$config_cascade = '';
 
-  // if available load a preload config file
-  $preload = fullpath(dirname(__FILE__)).'/preload.php';
-  if (@file_exists($preload)) include($preload);
+// if available load a preload config file
+$preload = fullpath(dirname(__FILE__)).'/preload.php';
+if (@file_exists($preload)) include($preload);
 
-  // define the include path
-  if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/');
+// define the include path
+if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/');
 
-  // define config path (packagers may want to change this to /etc/dokuwiki/)
-  if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/');
+// define config path (packagers may want to change this to /etc/dokuwiki/)
+if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/');
 
-  // check for error reporting override or set error reporting to sane values
-  if (!defined('DOKU_E_LEVEL') && @file_exists(DOKU_CONF.'report_e_all')) {
+// check for error reporting override or set error reporting to sane values
+if (!defined('DOKU_E_LEVEL') && @file_exists(DOKU_CONF.'report_e_all')) {
     define('DOKU_E_LEVEL', E_ALL);
-  }
-  if (!defined('DOKU_E_LEVEL')) {
+}
+if (!defined('DOKU_E_LEVEL')) {
     if(defined('E_DEPRECATED')){ // since php 5.3
-      error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
+        error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
     }else{
-      error_reporting(E_ALL ^ E_NOTICE);
+        error_reporting(E_ALL ^ E_NOTICE);
     }
-  } else {
+} else {
     error_reporting(DOKU_E_LEVEL);
-  }
+}
 
-  // init memory caches
-  global $cache_revinfo;  $cache_revinfo = array();
-  global $cache_wikifn;   $cache_wikifn = array();
-  global $cache_cleanid;  $cache_cleanid = array();
-  global $cache_authname; $cache_authname = array();
-  global $cache_metadata; $cache_metadata = array();
+// init memory caches
+global $cache_revinfo;
+       $cache_revinfo = array();
+global $cache_wikifn;
+       $cache_wikifn = array();
+global $cache_cleanid;
+       $cache_cleanid = array();
+global $cache_authname;
+       $cache_authname = array();
+global $cache_metadata;
+       $cache_metadata = array();
 
-  //set the configuration cascade - but only if its not already been set in preload.php
-  if (empty($config_cascade)) {
+//set the configuration cascade - but only if its not already been set in preload.php
+if (empty($config_cascade)) {
     $config_cascade = array(
-      'main' => array(
-        'default'   => array(DOKU_CONF.'dokuwiki.php'),
-        'local'     => array(DOKU_CONF.'local.php'),
-        'protected' => array(DOKU_CONF.'local.protected.php'),
-      ),
-      'acronyms'  => array(
-        'default'   => array(DOKU_CONF.'acronyms.conf'),
-        'local'     => array(DOKU_CONF.'acronyms.local.conf'),
-      ),
-      'entities'  => array(
-        'default'   => array(DOKU_CONF.'entities.conf'),
-        'local'     => array(DOKU_CONF.'entities.local.conf'),
-      ),
-      'interwiki' => array(
-        'default'   => array(DOKU_CONF.'interwiki.conf'),
-        'local'     => array(DOKU_CONF.'interwiki.local.conf'),
-      ),
-      'license' => array(
-        'default'   => array(DOKU_CONF.'license.php'),
-        'local'     => array(DOKU_CONF.'license.local.php'),
-      ),
-      'mediameta' => array(
-        'default'   => array(DOKU_CONF.'mediameta.php'),
-        'local'     => array(DOKU_CONF.'mediameta.local.php'),
-      ),
-      'mime'      => array(
-        'default'   => array(DOKU_CONF.'mime.conf'),
-        'local'     => array(DOKU_CONF.'mime.local.conf'),
-      ),
-      'scheme'    => array(
-        'default'   => array(DOKU_CONF.'scheme.conf'),
-        'local'     => array(DOKU_CONF.'scheme.local.conf'),
-      ),
-      'smileys'   => array(
-        'default'   => array(DOKU_CONF.'smileys.conf'),
-        'local'     => array(DOKU_CONF.'smileys.local.conf'),
-      ),
-      'wordblock' => array(
-        'default'   => array(DOKU_CONF.'wordblock.conf'),
-        'local'     => array(DOKU_CONF.'wordblock.local.conf'),
-      ),
-    );
-  }
+            'main' => array(
+                'default'   => array(DOKU_CONF.'dokuwiki.php'),
+                'local'     => array(DOKU_CONF.'local.php'),
+                'protected' => array(DOKU_CONF.'local.protected.php'),
+                ),
+            'acronyms'  => array(
+                'default'   => array(DOKU_CONF.'acronyms.conf'),
+                'local'     => array(DOKU_CONF.'acronyms.local.conf'),
+                ),
+            'entities'  => array(
+                'default'   => array(DOKU_CONF.'entities.conf'),
+                'local'     => array(DOKU_CONF.'entities.local.conf'),
+                ),
+            'interwiki' => array(
+                'default'   => array(DOKU_CONF.'interwiki.conf'),
+                'local'     => array(DOKU_CONF.'interwiki.local.conf'),
+                ),
+            'license' => array(
+                'default'   => array(DOKU_CONF.'license.php'),
+                'local'     => array(DOKU_CONF.'license.local.php'),
+                ),
+            'mediameta' => array(
+                    'default'   => array(DOKU_CONF.'mediameta.php'),
+                    'local'     => array(DOKU_CONF.'mediameta.local.php'),
+                    ),
+            'mime'      => array(
+                    'default'   => array(DOKU_CONF.'mime.conf'),
+                    'local'     => array(DOKU_CONF.'mime.local.conf'),
+                    ),
+            'scheme'    => array(
+                    'default'   => array(DOKU_CONF.'scheme.conf'),
+                    'local'     => array(DOKU_CONF.'scheme.local.conf'),
+                    ),
+            'smileys'   => array(
+                    'default'   => array(DOKU_CONF.'smileys.conf'),
+                    'local'     => array(DOKU_CONF.'smileys.local.conf'),
+                    ),
+            'wordblock' => array(
+                    'default'   => array(DOKU_CONF.'wordblock.conf'),
+                    'local'     => array(DOKU_CONF.'wordblock.local.conf'),
+                    ),
+            );
+}
 
-  //prepare config array()
-  global $conf;
-  $conf = array();
+//prepare config array()
+global $conf;
+$conf = array();
 
-  // load the global config file(s)
-  foreach (array('default','local','protected') as $config_group) {
+// load the global config file(s)
+foreach (array('default','local','protected') as $config_group) {
     if (empty($config_cascade['main'][$config_group])) continue;
     foreach ($config_cascade['main'][$config_group] as $config_file) {
-      if (@file_exists($config_file)) {
-        include($config_file);
-      }
+        if (@file_exists($config_file)) {
+            include($config_file);
+        }
     }
-  }
+}
 
-  //prepare language array
-  global $lang;
-  $lang = array();
+//prepare language array
+global $lang;
+$lang = array();
 
-  //load the language files
-  require_once(DOKU_INC.'inc/lang/en/lang.php');
-  if ( $conf['lang'] && $conf['lang'] != 'en' ) {
+//load the language files
+require_once(DOKU_INC.'inc/lang/en/lang.php');
+if ( $conf['lang'] && $conf['lang'] != 'en' ) {
     require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php');
-  }
+}
 
-  //prepare license array()
-  global $license;
-  $license = array();
+//prepare license array()
+global $license;
+$license = array();
 
-  // load the license file(s)
-  foreach (array('default','local') as $config_group) {
+// load the license file(s)
+foreach (array('default','local') as $config_group) {
     if (empty($config_cascade['license'][$config_group])) continue;
     foreach ($config_cascade['license'][$config_group] as $config_file) {
-      if(@file_exists($config_file)){
-        include($config_file);
-      }
+        if(@file_exists($config_file)){
+            include($config_file);
+        }
     }
-  }
+}
 
-  // define baseURL
-  if(!defined('DOKU_REL')) define('DOKU_REL',getBaseURL(false));
-  if(!defined('DOKU_URL')) define('DOKU_URL',getBaseURL(true));
-  if(!defined('DOKU_BASE')){
+// define baseURL
+if(!defined('DOKU_REL')) define('DOKU_REL',getBaseURL(false));
+if(!defined('DOKU_URL')) define('DOKU_URL',getBaseURL(true));
+if(!defined('DOKU_BASE')){
     if($conf['canonical']){
-      define('DOKU_BASE',DOKU_URL);
+        define('DOKU_BASE',DOKU_URL);
     }else{
-      define('DOKU_BASE',DOKU_REL);
+        define('DOKU_BASE',DOKU_REL);
     }
-  }
+}
 
-  // define whitespace
-  if(!defined('DOKU_LF')) define ('DOKU_LF',"\n");
-  if(!defined('DOKU_TAB')) define ('DOKU_TAB',"\t");
+// define whitespace
+if(!defined('DOKU_LF')) define ('DOKU_LF',"\n");
+if(!defined('DOKU_TAB')) define ('DOKU_TAB',"\t");
 
-  // define cookie and session id, append server port when securecookie is configured FS#1664
-  if (!defined('DOKU_COOKIE')) define('DOKU_COOKIE', 'DW'.md5(DOKU_REL.(($conf['securecookie'])?$_SERVER['SERVER_PORT']:'')));
+// define cookie and session id, append server port when securecookie is configured FS#1664
+if (!defined('DOKU_COOKIE')) define('DOKU_COOKIE', 'DW'.md5(DOKU_REL.(($conf['securecookie'])?$_SERVER['SERVER_PORT']:'')));
 
-  // define Plugin dir
-  if(!defined('DOKU_PLUGIN'))  define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
+// define Plugin dir
+if(!defined('DOKU_PLUGIN'))  define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
 
-  // define main script
-  if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT','doku.php');
+// define main script
+if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT','doku.php');
 
-  // define Template baseURL
-  if(!defined('DOKU_TPL')) define('DOKU_TPL',
-                                  DOKU_BASE.'lib/tpl/'.$conf['template'].'/');
+// define Template baseURL
+if(!defined('DOKU_TPL')) define('DOKU_TPL',
+        DOKU_BASE.'lib/tpl/'.$conf['template'].'/');
 
-  // define real Template directory
-  if(!defined('DOKU_TPLINC')) define('DOKU_TPLINC',
-                                  DOKU_INC.'lib/tpl/'.$conf['template'].'/');
+// define real Template directory
+if(!defined('DOKU_TPLINC')) define('DOKU_TPLINC',
+        DOKU_INC.'lib/tpl/'.$conf['template'].'/');
 
-  // make session rewrites XHTML compliant
-  @ini_set('arg_separator.output', '&');
+// make session rewrites XHTML compliant
+@ini_set('arg_separator.output', '&');
 
-  // make sure global zlib does not interfere FS#1132
-  @ini_set('zlib.output_compression', 'off');
+// make sure global zlib does not interfere FS#1132
+@ini_set('zlib.output_compression', 'off');
 
-  // increase PCRE backtrack limit
-  @ini_set('pcre.backtrack_limit', '20971520');
+// increase PCRE backtrack limit
+@ini_set('pcre.backtrack_limit', '20971520');
 
-  // enable gzip compression if supported
-  $conf['gzip_output'] &= (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false);
-  if ($conf['gzip_output'] &&
-      !defined('DOKU_DISABLE_GZIP_OUTPUT') &&
-      function_exists('ob_gzhandler')) {
+// enable gzip compression if supported
+$conf['gzip_output'] &= (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false);
+if ($conf['gzip_output'] &&
+        !defined('DOKU_DISABLE_GZIP_OUTPUT') &&
+        function_exists('ob_gzhandler')) {
     ob_start('ob_gzhandler');
-  }
+}
 
-  // init session
-  if (!headers_sent() && !defined('NOSESSION')){
+// init session
+if (!headers_sent() && !defined('NOSESSION')){
     session_name("DokuWiki");
     if (version_compare(PHP_VERSION, '5.2.0', '>')) {
-      session_set_cookie_params(0,DOKU_REL,'',($conf['securecookie'] && is_ssl()),true);
+        session_set_cookie_params(0,DOKU_REL,'',($conf['securecookie'] && is_ssl()),true);
     }else{
-      session_set_cookie_params(0,DOKU_REL,'',($conf['securecookie'] && is_ssl()));
+        session_set_cookie_params(0,DOKU_REL,'',($conf['securecookie'] && is_ssl()));
     }
     session_start();
 
     // load left over messages
     if(isset($_SESSION[DOKU_COOKIE]['msg'])){
-      $MSG = $_SESSION[DOKU_COOKIE]['msg'];
-      unset($_SESSION[DOKU_COOKIE]['msg']);
+        $MSG = $_SESSION[DOKU_COOKIE]['msg'];
+        unset($_SESSION[DOKU_COOKIE]['msg']);
     }
-  }
+}
 
-  // kill magic quotes
-  if (get_magic_quotes_gpc() && !defined('MAGIC_QUOTES_STRIPPED')) {
+// kill magic quotes
+if (get_magic_quotes_gpc() && !defined('MAGIC_QUOTES_STRIPPED')) {
     if (!empty($_GET))    remove_magic_quotes($_GET);
     if (!empty($_POST))   remove_magic_quotes($_POST);
     if (!empty($_COOKIE)) remove_magic_quotes($_COOKIE);
     if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST);
     @ini_set('magic_quotes_gpc', 0);
     define('MAGIC_QUOTES_STRIPPED',1);
-  }
-  @set_magic_quotes_runtime(0);
-  @ini_set('magic_quotes_sybase',0);
+}
+@set_magic_quotes_runtime(0);
+@ini_set('magic_quotes_sybase',0);
 
-  // don't let cookies ever interfere with request vars
-  $_REQUEST = array_merge($_GET,$_POST);
+// don't let cookies ever interfere with request vars
+$_REQUEST = array_merge($_GET,$_POST);
 
-  // we don't want a purge URL to be digged
-  if($_REQUEST['purge'] && $_SERVER['HTTP_REFERER']) unset($_REQUEST['purge']);
+// we don't want a purge URL to be digged
+if($_REQUEST['purge'] && $_SERVER['HTTP_REFERER']) unset($_REQUEST['purge']);
 
-  // disable gzip if not available
-  if($conf['compression'] == 'bz2' && !function_exists('bzopen')){
+// disable gzip if not available
+if($conf['compression'] == 'bz2' && !function_exists('bzopen')){
     $conf['compression'] = 'gz';
-  }
-  if($conf['compression'] == 'gz' && !function_exists('gzopen')){
+}
+if($conf['compression'] == 'gz' && !function_exists('gzopen')){
     $conf['compression'] = 0;
-  }
+}
 
-  // fix dateformat for upgraders
-  if(strpos($conf['dformat'],'%') === false){
+// fix dateformat for upgraders
+if(strpos($conf['dformat'],'%') === false){
     $conf['dformat'] = '%Y/%m/%d %H:%M';
-  }
+}
 
-  // precalculate file creation modes
-  init_creationmodes();
+// precalculate file creation modes
+init_creationmodes();
 
-  // make real paths and check them
-  init_paths();
-  init_files();
+// make real paths and check them
+init_paths();
+init_files();
 
-  // automatic upgrade to script versions of certain files
-  scriptify(DOKU_CONF.'users.auth');
-  scriptify(DOKU_CONF.'acl.auth');
+// automatic upgrade to script versions of certain files
+scriptify(DOKU_CONF.'users.auth');
+scriptify(DOKU_CONF.'acl.auth');
 
 
 /**
  * Checks paths from config file
  */
 function init_paths(){
-  global $conf;
+    global $conf;
 
-  $paths = array('datadir'   => 'pages',
-                 'olddir'    => 'attic',
-                 'mediadir'  => 'media',
-                 'metadir'   => 'meta',
-                 'cachedir'  => 'cache',
-                 'indexdir'  => 'index',
-                 'lockdir'   => 'locks',
-                 'tmpdir'    => 'tmp');
+    $paths = array('datadir'   => 'pages',
+            'olddir'    => 'attic',
+            'mediadir'  => 'media',
+            'metadir'   => 'meta',
+            'cachedir'  => 'cache',
+            'indexdir'  => 'index',
+            'lockdir'   => 'locks',
+            'tmpdir'    => 'tmp');
 
-  foreach($paths as $c => $p){
-    if(empty($conf[$c]))  $conf[$c] = $conf['savedir'].'/'.$p;
-    $conf[$c]             = init_path($conf[$c]);
-    if(empty($conf[$c]))  nice_die("The $c ('$p') does not exist, isn't accessible or writable.
-                               You should check your config and permission settings.
-                               Or maybe you want to run the
-                               installer?");
-  }
+    foreach($paths as $c => $p){
+        if(empty($conf[$c]))  $conf[$c] = $conf['savedir'].'/'.$p;
+        $conf[$c]             = init_path($conf[$c]);
+        if(empty($conf[$c]))  nice_die("The $c ('$p') does not exist, isn't accessible or writable.
+                You should check your config and permission settings.
+                Or maybe you want to run the
+                installer?");
+    }
 
-  // path to old changelog only needed for upgrading
-  $conf['changelog_old'] = init_path((isset($conf['changelog']))?($conf['changelog']):($conf['savedir'].'/changes.log'));
-  if ($conf['changelog_old']=='') { unset($conf['changelog_old']); }
-  // hardcoded changelog because it is now a cache that lives in meta
-  $conf['changelog'] = $conf['metadir'].'/_dokuwiki.changes';
-  $conf['media_changelog'] = $conf['metadir'].'/_media.changes';
+    // path to old changelog only needed for upgrading
+    $conf['changelog_old'] = init_path((isset($conf['changelog']))?($conf['changelog']):($conf['savedir'].'/changes.log'));
+    if ($conf['changelog_old']=='') { unset($conf['changelog_old']); }
+    // hardcoded changelog because it is now a cache that lives in meta
+    $conf['changelog'] = $conf['metadir'].'/_dokuwiki.changes';
+    $conf['media_changelog'] = $conf['metadir'].'/_media.changes';
 }
 
 /**
  * Checks the existance of certain files and creates them if missing.
  */
 function init_files(){
-  global $conf;
+    global $conf;
 
-  $files = array( $conf['indexdir'].'/page.idx');
+    $files = array( $conf['indexdir'].'/page.idx');
 
-  foreach($files as $file){
-    if(!@file_exists($file)){
-      $fh = @fopen($file,'a');
-      if($fh){
-        fclose($fh);
-        if($conf['fperm']) chmod($file, $conf['fperm']);
-      }else{
-        nice_die("$file is not writable. Check your permissions settings!");
-      }
+    foreach($files as $file){
+        if(!@file_exists($file)){
+            $fh = @fopen($file,'a');
+            if($fh){
+                fclose($fh);
+                if($conf['fperm']) chmod($file, $conf['fperm']);
+            }else{
+                nice_die("$file is not writable. Check your permissions settings!");
+            }
+        }
     }
-  }
 }
 
 /**
@@ -300,26 +305,26 @@ function init_files(){
  * @author Andreas Gohr 
  */
 function init_path($path){
-  // check existance
-  $p = fullpath($path);
-  if(!@file_exists($p)){
-    $p = fullpath(DOKU_INC.$path);
+    // check existance
+    $p = fullpath($path);
     if(!@file_exists($p)){
-      return '';
+        $p = fullpath(DOKU_INC.$path);
+        if(!@file_exists($p)){
+            return '';
+        }
     }
-  }
 
-  // check writability
-  if(!@is_writable($p)){
-    return '';
-  }
+    // check writability
+    if(!@is_writable($p)){
+        return '';
+    }
 
-  // check accessability (execute bit) for directories
-  if(@is_dir($p) && !@file_exists("$p/.")){
-    return '';
-  }
+    // check accessability (execute bit) for directories
+    if(@is_dir($p) && !@file_exists("$p/.")){
+        return '';
+    }
 
-  return $p;
+    return $p;
 }
 
 /**
@@ -329,28 +334,28 @@ function init_path($path){
  * setting the values only if needed.
  */
 function init_creationmodes(){
-  global $conf;
+    global $conf;
 
-  // Legacy support for old umask/dmask scheme
-  unset($conf['dmask']);
-  unset($conf['fmask']);
-  unset($conf['umask']);
-  unset($conf['fperm']);
-  unset($conf['dperm']);
+    // Legacy support for old umask/dmask scheme
+    unset($conf['dmask']);
+    unset($conf['fmask']);
+    unset($conf['umask']);
+    unset($conf['fperm']);
+    unset($conf['dperm']);
 
-  // get system umask, fallback to 0 if none available
-  $umask = @umask();
-  if(!$umask) $umask = 0000;
+    // get system umask, fallback to 0 if none available
+    $umask = @umask();
+    if(!$umask) $umask = 0000;
 
-  // check what is set automatically by the system on file creation
-  // and set the fperm param if it's not what we want
-  $auto_fmode = 0666 & ~$umask;
-  if($auto_fmode != $conf['fmode']) $conf['fperm'] = $conf['fmode'];
+    // check what is set automatically by the system on file creation
+    // and set the fperm param if it's not what we want
+    $auto_fmode = 0666 & ~$umask;
+    if($auto_fmode != $conf['fmode']) $conf['fperm'] = $conf['fmode'];
 
-  // check what is set automatically by the system on file creation
-  // and set the dperm param if it's not what we want
-  $auto_dmode = $conf['dmode'] & ~$umask;
-  if($auto_dmode != $conf['dmode']) $conf['dperm'] = $conf['dmode'];
+    // check what is set automatically by the system on file creation
+    // and set the dperm param if it's not what we want
+    $auto_dmode = $conf['dmode'] & ~$umask;
+    if($auto_dmode != $conf['dmode']) $conf['dperm'] = $conf['dmode'];
 }
 
 /**
@@ -359,22 +364,22 @@ function init_creationmodes(){
  * @author Andreas Gohr 
  */
 function remove_magic_quotes(&$array) {
-  foreach (array_keys($array) as $key) {
-      // handle magic quotes in keynames (breaks order)
-      $sk = stripslashes($key);
-      if($sk != $key){
-          $array[$sk] = $array[$key];
-          unset($array[$key]);
-          $key = $sk;
-      }
+    foreach (array_keys($array) as $key) {
+        // handle magic quotes in keynames (breaks order)
+        $sk = stripslashes($key);
+        if($sk != $key){
+            $array[$sk] = $array[$key];
+            unset($array[$key]);
+            $key = $sk;
+        }
 
-      // do recursion if needed
-      if (is_array($array[$key])) {
-          remove_magic_quotes($array[$key]);
-      }else {
-          $array[$key] = stripslashes($array[$key]);
-      }
-  }
+        // do recursion if needed
+        if (is_array($array[$key])) {
+            remove_magic_quotes($array[$key]);
+        }else {
+            $array[$key] = stripslashes($array[$key]);
+        }
+    }
 }
 
 /**
@@ -384,59 +389,59 @@ function remove_magic_quotes(&$array) {
  * @author Andreas Gohr 
  */
 function getBaseURL($abs=null){
-  global $conf;
-  //if canonical url enabled always return absolute
-  if(is_null($abs)) $abs = $conf['canonical'];
+    global $conf;
+    //if canonical url enabled always return absolute
+    if(is_null($abs)) $abs = $conf['canonical'];
 
-  if($conf['basedir']){
-    $dir = $conf['basedir'];
-  }elseif(substr($_SERVER['SCRIPT_NAME'],-4) == '.php'){
-    $dir = dirname($_SERVER['SCRIPT_NAME']);
-  }elseif(substr($_SERVER['PHP_SELF'],-4) == '.php'){
-    $dir = dirname($_SERVER['PHP_SELF']);
-  }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){
-    $dir = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','',
-                         $_SERVER['SCRIPT_FILENAME']);
-    $dir = dirname('/'.$dir);
-  }else{
-    $dir = '.'; //probably wrong
-  }
-
-  $dir = str_replace('\\','/',$dir);             // bugfix for weird WIN behaviour
-  $dir = preg_replace('#//+#','/',"/$dir/");     // ensure leading and trailing slashes
-
-  //handle script in lib/exe dir
-  $dir = preg_replace('!lib/exe/$!','',$dir);
-
-  //handle script in lib/plugins dir
-  $dir = preg_replace('!lib/plugins/.*$!','',$dir);
-
-  //finish here for relative URLs
-  if(!$abs) return $dir;
-
-  //use config option if available, trim any slash from end of baseurl to avoid multiple consecutive slashes in the path
-  if($conf['baseurl']) return rtrim($conf['baseurl'],'/').$dir;
-
-  //split hostheader into host and port
-  list($host,$port) = explode(':',$_SERVER['HTTP_HOST']);
-  if(!$port)  $port = $_SERVER['SERVER_PORT'];
-  if(!$port)  $port = 80;
-
-  if(!is_ssl()){
-    $proto = 'http://';
-    if ($port == '80') {
-      $port='';
+    if($conf['basedir']){
+        $dir = $conf['basedir'];
+    }elseif(substr($_SERVER['SCRIPT_NAME'],-4) == '.php'){
+        $dir = dirname($_SERVER['SCRIPT_NAME']);
+    }elseif(substr($_SERVER['PHP_SELF'],-4) == '.php'){
+        $dir = dirname($_SERVER['PHP_SELF']);
+    }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){
+        $dir = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','',
+                $_SERVER['SCRIPT_FILENAME']);
+        $dir = dirname('/'.$dir);
+    }else{
+        $dir = '.'; //probably wrong
     }
-  }else{
-    $proto = 'https://';
-    if ($port == '443') {
-      $port='';
+
+    $dir = str_replace('\\','/',$dir);             // bugfix for weird WIN behaviour
+    $dir = preg_replace('#//+#','/',"/$dir/");     // ensure leading and trailing slashes
+
+        //handle script in lib/exe dir
+        $dir = preg_replace('!lib/exe/$!','',$dir);
+
+    //handle script in lib/plugins dir
+    $dir = preg_replace('!lib/plugins/.*$!','',$dir);
+
+    //finish here for relative URLs
+    if(!$abs) return $dir;
+
+    //use config option if available, trim any slash from end of baseurl to avoid multiple consecutive slashes in the path
+    if($conf['baseurl']) return rtrim($conf['baseurl'],'/').$dir;
+
+    //split hostheader into host and port
+    list($host,$port) = explode(':',$_SERVER['HTTP_HOST']);
+    if(!$port)  $port = $_SERVER['SERVER_PORT'];
+    if(!$port)  $port = 80;
+
+    if(!is_ssl()){
+        $proto = 'http://';
+        if ($port == '80') {
+            $port='';
+        }
+    }else{
+        $proto = 'https://';
+        if ($port == '443') {
+            $port='';
+        }
     }
-  }
 
-  if($port) $port = ':'.$port;
+    if($port) $port = ':'.$port;
 
-  return $proto.$host.$port.$dir;
+    return $proto.$host.$port.$dir;
 }
 
 /**
@@ -465,52 +470,52 @@ function is_ssl(){
  * @author Jan Decaluwe 
  */
 function scriptify($file) {
-  // checks
-  if (!is_readable($file)) {
-    return;
-  }
-  $fn = $file.'.php';
-  if (@file_exists($fn)) {
-    return;
-  }
-  $fh = fopen($fn, 'w');
-  if (!$fh) {
-    nice_die($fn.' is not writable. Check your permission settings!');
-  }
-  // write php exit hack first
-  fwrite($fh, "# $fn\n");
-  fwrite($fh, '# '."\n");
-  fwrite($fh, "# Don't modify the lines above\n");
-  fwrite($fh, "#\n");
-  // copy existing lines
-  $lines = file($file);
-  foreach ($lines as $line){
-    fwrite($fh, $line);
-  }
-  fclose($fh);
-  //try to rename the old file
-  io_rename($file,"$file.old");
+    // checks
+    if (!is_readable($file)) {
+        return;
+    }
+    $fn = $file.'.php';
+    if (@file_exists($fn)) {
+        return;
+    }
+    $fh = fopen($fn, 'w');
+    if (!$fh) {
+        nice_die($fn.' is not writable. Check your permission settings!');
+    }
+    // write php exit hack first
+    fwrite($fh, "# $fn\n");
+    fwrite($fh, '# '."\n");
+    fwrite($fh, "# Don't modify the lines above\n");
+    fwrite($fh, "#\n");
+    // copy existing lines
+    $lines = file($file);
+    foreach ($lines as $line){
+        fwrite($fh, $line);
+    }
+    fclose($fh);
+    //try to rename the old file
+    io_rename($file,"$file.old");
 }
 
 /**
  * print a nice message even if no styles are loaded yet.
  */
 function nice_die($msg){
-  echo<<
-  
-    DokuWiki Setup Error
-    
-      
-

DokuWiki Setup Error

-

$msg

-
- - + echo<< + +DokuWiki Setup Error + +
+

DokuWiki Setup Error

+

$msg

+
+ + EOT; - exit; + exit; } @@ -560,9 +565,9 @@ function fullpath($path,$exists=false){ $newpath=array(); foreach($path as $p) { if ($p === '' || $p === '.') continue; - if ($p==='..') { - array_pop($newpath); - continue; + if ($p==='..') { + array_pop($newpath); + continue; } array_push($newpath, $p); } @@ -577,4 +582,3 @@ function fullpath($path,$exists=false){ -//Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/io.php b/inc/io.php index 2eb94db0c..32a6f7b8e 100644 --- a/inc/io.php +++ b/inc/io.php @@ -28,26 +28,26 @@ require_once(DOKU_INC.'inc/utf8.php'); * @author Ben Coburn */ function io_sweepNS($id,$basedir='datadir'){ - global $conf; - $types = array ('datadir'=>'pages', 'mediadir'=>'media'); - $ns_type = (isset($types[$basedir])?$types[$basedir]:false); + global $conf; + $types = array ('datadir'=>'pages', 'mediadir'=>'media'); + $ns_type = (isset($types[$basedir])?$types[$basedir]:false); - $delone = false; + $delone = false; - //scan all namespaces - while(($id = getNS($id)) !== false){ - $dir = $conf[$basedir].'/'.utf8_encodeFN(str_replace(':','/',$id)); + //scan all namespaces + while(($id = getNS($id)) !== false){ + $dir = $conf[$basedir].'/'.utf8_encodeFN(str_replace(':','/',$id)); - //try to delete dir else return - if(@rmdir($dir)) { - if ($ns_type!==false) { - $data = array($id, $ns_type); - $delone = true; // we deleted at least one dir - trigger_event('IO_NAMESPACE_DELETED', $data); - } - } else { return $delone; } - } - return $delone; + //try to delete dir else return + if(@rmdir($dir)) { + if ($ns_type!==false) { + $data = array($id, $ns_type); + $delone = true; // we deleted at least one dir + trigger_event('IO_NAMESPACE_DELETED', $data); + } + } else { return $delone; } + } + return $delone; } /** @@ -94,35 +94,35 @@ function _io_readWikiPage_action($data) { * @author Andreas Gohr */ function io_readFile($file,$clean=true){ - $ret = ''; - if(@file_exists($file)){ - if(substr($file,-3) == '.gz'){ - $ret = join('',gzfile($file)); - }else if(substr($file,-4) == '.bz2'){ - $ret = bzfile($file); - }else{ - $ret = file_get_contents($file); + $ret = ''; + if(@file_exists($file)){ + if(substr($file,-3) == '.gz'){ + $ret = join('',gzfile($file)); + }else if(substr($file,-4) == '.bz2'){ + $ret = bzfile($file); + }else{ + $ret = file_get_contents($file); + } + } + if($clean){ + return cleanText($ret); + }else{ + return $ret; } - } - if($clean){ - return cleanText($ret); - }else{ - return $ret; - } } /** -* Returns the content of a .bz2 compressed file as string -* @author marcel senf -*/ + * Returns the content of a .bz2 compressed file as string + * @author marcel senf + */ function bzfile($file){ - $bz = bzopen($file,"r"); - while (!feof($bz)){ - //8192 seems to be the maximum buffersize? - $str = $str . bzread($bz,8192); - } - bzclose($bz); - return $str; + $bz = bzopen($file,"r"); + while (!feof($bz)){ + //8192 seems to be the maximum buffersize? + $str = $str . bzread($bz,8192); + } + bzclose($bz); + return $str; } @@ -174,44 +174,44 @@ function _io_writeWikiPage_action($data) { * @return bool true on success */ function io_saveFile($file,$content,$append=false){ - global $conf; - $mode = ($append) ? 'ab' : 'wb'; + global $conf; + $mode = ($append) ? 'ab' : 'wb'; - $fileexists = @file_exists($file); - io_makeFileDir($file); - io_lock($file); - if(substr($file,-3) == '.gz'){ - $fh = @gzopen($file,$mode.'9'); - if(!$fh){ - msg("Writing $file failed",-1); - io_unlock($file); - return false; + $fileexists = @file_exists($file); + io_makeFileDir($file); + io_lock($file); + if(substr($file,-3) == '.gz'){ + $fh = @gzopen($file,$mode.'9'); + if(!$fh){ + msg("Writing $file failed",-1); + io_unlock($file); + return false; + } + gzwrite($fh, $content); + gzclose($fh); + }else if(substr($file,-4) == '.bz2'){ + $fh = @bzopen($file,$mode{0}); + if(!$fh){ + msg("Writing $file failed", -1); + io_unlock($file); + return false; + } + bzwrite($fh, $content); + bzclose($fh); + }else{ + $fh = @fopen($file,$mode); + if(!$fh){ + msg("Writing $file failed",-1); + io_unlock($file); + return false; + } + fwrite($fh, $content); + fclose($fh); } - gzwrite($fh, $content); - gzclose($fh); - }else if(substr($file,-4) == '.bz2'){ - $fh = @bzopen($file,$mode{0}); - if(!$fh){ - msg("Writing $file failed", -1); - io_unlock($file); - return false; - } - bzwrite($fh, $content); - bzclose($fh); - }else{ - $fh = @fopen($file,$mode); - if(!$fh){ - msg("Writing $file failed",-1); - io_unlock($file); - return false; - } - fwrite($fh, $content); - fclose($fh); - } - if(!$fileexists and !empty($conf['fperm'])) chmod($file, $conf['fperm']); - io_unlock($file); - return true; + if(!$fileexists and !empty($conf['fperm'])) chmod($file, $conf['fperm']); + io_unlock($file); + return true; } /** @@ -227,55 +227,55 @@ function io_saveFile($file,$content,$append=false){ * @return bool true on success */ function io_deleteFromFile($file,$badline,$regex=false){ - if (!@file_exists($file)) return true; + if (!@file_exists($file)) return true; - io_lock($file); + io_lock($file); - // load into array - if(substr($file,-3) == '.gz'){ - $lines = gzfile($file); - }else{ - $lines = file($file); - } - - // remove all matching lines - if ($regex) { - $lines = preg_grep($badline,$lines,PREG_GREP_INVERT); - } else { - $pos = array_search($badline,$lines); //return null or false if not found - while(is_int($pos)){ - unset($lines[$pos]); - $pos = array_search($badline,$lines); - } - } - - if(count($lines)){ - $content = join('',$lines); + // load into array if(substr($file,-3) == '.gz'){ - $fh = @gzopen($file,'wb9'); - if(!$fh){ - msg("Removing content from $file failed",-1); - io_unlock($file); - return false; - } - gzwrite($fh, $content); - gzclose($fh); + $lines = gzfile($file); }else{ - $fh = @fopen($file,'wb'); - if(!$fh){ - msg("Removing content from $file failed",-1); - io_unlock($file); - return false; - } - fwrite($fh, $content); - fclose($fh); + $lines = file($file); } - }else{ - @unlink($file); - } - io_unlock($file); - return true; + // remove all matching lines + if ($regex) { + $lines = preg_grep($badline,$lines,PREG_GREP_INVERT); + } else { + $pos = array_search($badline,$lines); //return null or false if not found + while(is_int($pos)){ + unset($lines[$pos]); + $pos = array_search($badline,$lines); + } + } + + if(count($lines)){ + $content = join('',$lines); + if(substr($file,-3) == '.gz'){ + $fh = @gzopen($file,'wb9'); + if(!$fh){ + msg("Removing content from $file failed",-1); + io_unlock($file); + return false; + } + gzwrite($fh, $content); + gzclose($fh); + }else{ + $fh = @fopen($file,'wb'); + if(!$fh){ + msg("Removing content from $file failed",-1); + io_unlock($file); + return false; + } + fwrite($fh, $content); + fclose($fh); + } + }else{ + @unlink($file); + } + + io_unlock($file); + return true; } /** @@ -290,24 +290,24 @@ function io_deleteFromFile($file,$badline,$regex=false){ * @author Andreas Gohr */ function io_lock($file){ - global $conf; - // no locking if safemode hack - if($conf['safemodehack']) return; + global $conf; + // no locking if safemode hack + if($conf['safemodehack']) return; - $lockDir = $conf['lockdir'].'/'.md5($file); - @ignore_user_abort(1); + $lockDir = $conf['lockdir'].'/'.md5($file); + @ignore_user_abort(1); - $timeStart = time(); - do { - //waited longer than 3 seconds? -> stale lock - if ((time() - $timeStart) > 3) break; - $locked = @mkdir($lockDir, $conf['dmode']); - if($locked){ - if(!empty($conf['dperm'])) chmod($lockDir, $conf['dperm']); - break; - } - usleep(50); - } while ($locked === false); + $timeStart = time(); + do { + //waited longer than 3 seconds? -> stale lock + if ((time() - $timeStart) > 3) break; + $locked = @mkdir($lockDir, $conf['dmode']); + if($locked){ + if(!empty($conf['dperm'])) chmod($lockDir, $conf['dperm']); + break; + } + usleep(50); + } while ($locked === false); } /** @@ -316,13 +316,13 @@ function io_lock($file){ * @author Andreas Gohr */ function io_unlock($file){ - global $conf; - // no locking if safemode hack - if($conf['safemodehack']) return; + global $conf; + // no locking if safemode hack + if($conf['safemodehack']) return; - $lockDir = $conf['lockdir'].'/'.md5($file); - @rmdir($lockDir); - @ignore_user_abort(0); + $lockDir = $conf['lockdir'].'/'.md5($file); + @rmdir($lockDir); + @ignore_user_abort(0); } /** @@ -370,12 +370,12 @@ function io_createNamespace($id, $ns_type='pages') { * @author Andreas Gohr */ function io_makeFileDir($file){ - global $conf; + global $conf; - $dir = dirname($file); - if(!@is_dir($dir)){ - io_mkdir_p($dir) || msg("Creating directory $dir failed",-1); - } + $dir = dirname($file); + if(!@is_dir($dir)){ + io_mkdir_p($dir) || msg("Creating directory $dir failed",-1); + } } /** @@ -386,21 +386,21 @@ function io_makeFileDir($file){ * @author Andreas Gohr */ function io_mkdir_p($target){ - global $conf; - if (@is_dir($target)||empty($target)) return 1; // best case check first - if (@file_exists($target) && !is_dir($target)) return 0; - //recursion - if (io_mkdir_p(substr($target,0,strrpos($target,'/')))){ - if($conf['safemodehack']){ - $dir = preg_replace('/^'.preg_quote(fullpath($conf['ftp']['root']),'/').'/','', $target); - return io_mkdir_ftp($dir); - }else{ - $ret = @mkdir($target,$conf['dmode']); // crawl back up & create dir tree - if($ret && $conf['dperm']) chmod($target, $conf['dperm']); - return $ret; + global $conf; + if (@is_dir($target)||empty($target)) return 1; // best case check first + if (@file_exists($target) && !is_dir($target)) return 0; + //recursion + if (io_mkdir_p(substr($target,0,strrpos($target,'/')))){ + if($conf['safemodehack']){ + $dir = preg_replace('/^'.preg_quote(fullpath($conf['ftp']['root']),'/').'/','', $target); + return io_mkdir_ftp($dir); + }else{ + $ret = @mkdir($target,$conf['dmode']); // crawl back up & create dir tree + if($ret && $conf['dperm']) chmod($target, $conf['dperm']); + return $ret; + } } - } - return 0; + return 0; } /** @@ -411,31 +411,31 @@ function io_mkdir_p($target){ * @author */ function io_mkdir_ftp($dir){ - global $conf; + global $conf; - if(!function_exists('ftp_connect')){ - msg("FTP support not found - safemode workaround not usable",-1); - return false; - } + if(!function_exists('ftp_connect')){ + msg("FTP support not found - safemode workaround not usable",-1); + return false; + } - $conn = @ftp_connect($conf['ftp']['host'],$conf['ftp']['port'],10); - if(!$conn){ - msg("FTP connection failed",-1); - return false; - } + $conn = @ftp_connect($conf['ftp']['host'],$conf['ftp']['port'],10); + if(!$conn){ + msg("FTP connection failed",-1); + return false; + } - if(!@ftp_login($conn, $conf['ftp']['user'], conf_decodeString($conf['ftp']['pass']))){ - msg("FTP login failed",-1); - return false; - } + if(!@ftp_login($conn, $conf['ftp']['user'], conf_decodeString($conf['ftp']['pass']))){ + msg("FTP login failed",-1); + return false; + } - //create directory - $ok = @ftp_mkdir($conn, $dir); - //set permissions - @ftp_site($conn,sprintf("CHMOD %04o %s",$conf['dmode'],$dir)); + //create directory + $ok = @ftp_mkdir($conn, $dir); + //set permissions + @ftp_site($conn,sprintf("CHMOD %04o %s",$conf['dmode'],$dir)); - @ftp_close($conn); - return $ok; + @ftp_close($conn); + return $ok; } /** @@ -464,7 +464,7 @@ function io_mktmpdir() { * if $useAttachment is false, * - $file is the full filename to save the file, incl. path * - if successful will return true, false otherwise - + * * if $useAttachment is true, * - $file is the directory where the file should be saved * - if successful will return the name used for the saved file, false otherwise @@ -473,43 +473,43 @@ function io_mktmpdir() { * @author Chris Smith */ function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=2097152){ - global $conf; - $http = new DokuHTTPClient(); - $http->max_bodysize = $maxSize; - $http->timeout = 25; //max. 25 sec + global $conf; + $http = new DokuHTTPClient(); + $http->max_bodysize = $maxSize; + $http->timeout = 25; //max. 25 sec - $data = $http->get($url); - if(!$data) return false; + $data = $http->get($url); + if(!$data) return false; - if ($useAttachment) { - $name = ''; - if (isset($http->resp_headers['content-disposition'])) { - $content_disposition = $http->resp_headers['content-disposition']; - $match=array(); - if (is_string($content_disposition) && - preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) { + if ($useAttachment) { + $name = ''; + if (isset($http->resp_headers['content-disposition'])) { + $content_disposition = $http->resp_headers['content-disposition']; + $match=array(); + if (is_string($content_disposition) && + preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) { - $name = basename($match[1]); - } + $name = basename($match[1]); + } + } + + if (!$name) { + if (!$defaultName) return false; + $name = $defaultName; + } + + $file = $file.$name; } - if (!$name) { - if (!$defaultName) return false; - $name = $defaultName; - } - - $file = $file.$name; - } - - $fileexists = @file_exists($file); - $fp = @fopen($file,"w"); - if(!$fp) return false; - fwrite($fp,$data); - fclose($fp); - if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']); - if ($useAttachment) return $name; - return true; + $fileexists = @file_exists($file); + $fp = @fopen($file,"w"); + if(!$fp) return false; + fwrite($fp,$data); + fclose($fp); + if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']); + if ($useAttachment) return $name; + return true; } /** @@ -519,16 +519,16 @@ function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=20 * this function will use copy/unlink instead */ function io_rename($from,$to){ - global $conf; - if(!@rename($from,$to)){ - if(@copy($from,$to)){ - if($conf['fperm']) chmod($to, $conf['fperm']); - @unlink($from); - return true; + global $conf; + if(!@rename($from,$to)){ + if(@copy($from,$to)){ + if($conf['fperm']) chmod($to, $conf['fperm']); + @unlink($from); + return true; + } + return false; } - return false; - } - return true; + return true; } @@ -540,14 +540,14 @@ function io_rename($from,$to){ * @deprecated */ function io_runcmd($cmd){ - $fh = popen($cmd, "r"); - if(!$fh) return false; - $ret = ''; - while (!feof($fh)) { - $ret .= fread($fh, 8192); - } - pclose($fh); - return $ret; + $fh = popen($cmd, "r"); + if(!$fh) return false; + $ret = ''; + while (!feof($fh)) { + $ret .= fread($fh, 8192); + } + pclose($fh); + return $ret; } /** @@ -565,30 +565,29 @@ function io_runcmd($cmd){ * @return matching lines or backref, false on error */ function io_grep($file,$pattern,$max=0,$backref=false){ - $fh = @fopen($file,'r'); - if(!$fh) return false; - $matches = array(); + $fh = @fopen($file,'r'); + if(!$fh) return false; + $matches = array(); - $cnt = 0; - $line = ''; - while (!feof($fh)) { - $line .= fgets($fh, 4096); // read full line - if(substr($line,-1) != "\n") continue; - - // check if line matches - if(preg_match($pattern,$line,$match)){ - if($backref){ - $matches[] = $match; - }else{ - $matches[] = $line; - } - $cnt++; - } - if($max && $max == $cnt) break; + $cnt = 0; $line = ''; - } - fclose($fh); - return $matches; + while (!feof($fh)) { + $line .= fgets($fh, 4096); // read full line + if(substr($line,-1) != "\n") continue; + + // check if line matches + if(preg_match($pattern,$line,$match)){ + if($backref){ + $matches[] = $match; + }else{ + $matches[] = $line; + } + $cnt++; + } + if($max && $max == $cnt) break; + $line = ''; + } + fclose($fh); + return $matches; } -//Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/mail.php b/inc/mail.php index 61d938cf8..3b0592b8b 100644 --- a/inc/mail.php +++ b/inc/mail.php @@ -27,7 +27,7 @@ if(!defined('MAILHEADER_EOL')) define('MAILHEADER_EOL',"\n"); * * @author Chris Smith * Check if a given mail address is valid -*/ + */ if (!defined('RFC2822_ATEXT')) define('RFC2822_ATEXT',"0-9a-zA-Z!#$%&'*+/=?^_`{|}~-"); if (!defined('PREG_PATTERN_VALID_EMAIL')) define('PREG_PATTERN_VALID_EMAIL', '['.RFC2822_ATEXT.']+(?:\.['.RFC2822_ATEXT.']+)*@(?i:[0-9a-z][0-9a-z-]*\.)+(?i:[a-z]{2,4}|museum|travel)'); @@ -54,59 +54,59 @@ if (!defined('PREG_PATTERN_VALID_EMAIL')) define('PREG_PATTERN_VALID_EMAIL', '[' */ function mail_send($to, $subject, $body, $from='', $cc='', $bcc='', $headers=null, $params=null){ - $message = compact('to','subject','body','from','cc','bcc','headers','params'); - return trigger_event('MAIL_MESSAGE_SEND',$message,'_mail_send_action'); + $message = compact('to','subject','body','from','cc','bcc','headers','params'); + return trigger_event('MAIL_MESSAGE_SEND',$message,'_mail_send_action'); } function _mail_send_action($data) { - // retrieve parameters from event data, $to, $subject, $body, $from, $cc, $bcc, $headers, $params - $to = $data['to']; - $subject = $data['subject']; - $body = $data['body']; + // retrieve parameters from event data, $to, $subject, $body, $from, $cc, $bcc, $headers, $params + $to = $data['to']; + $subject = $data['subject']; + $body = $data['body']; - // add robustness in case plugin removes any of these optional values - $from = isset($data['from']) ? $data['from'] : ''; - $cc = isset($data['cc']) ? $data['cc'] : ''; - $bcc = isset($data['bcc']) ? $data['bcc'] : ''; - $headers = isset($data['headers']) ? $data['headers'] : null; - $params = isset($data['params']) ? $data['params'] : null; + // add robustness in case plugin removes any of these optional values + $from = isset($data['from']) ? $data['from'] : ''; + $cc = isset($data['cc']) ? $data['cc'] : ''; + $bcc = isset($data['bcc']) ? $data['bcc'] : ''; + $headers = isset($data['headers']) ? $data['headers'] : null; + $params = isset($data['params']) ? $data['params'] : null; - // end additional code to support event ... original mail_send() code from here + // end additional code to support event ... original mail_send() code from here - if(defined('MAILHEADER_ASCIIONLY')){ - $subject = utf8_deaccent($subject); - $subject = utf8_strip($subject); - } + if(defined('MAILHEADER_ASCIIONLY')){ + $subject = utf8_deaccent($subject); + $subject = utf8_strip($subject); + } - if(!utf8_isASCII($subject)) { - $subject = '=?UTF-8?Q?'.mail_quotedprintable_encode($subject,0).'?='; - // Spaces must be encoded according to rfc2047. Use the "_" shorthand - $subject = preg_replace('/ /', '_', $subject); - } + if(!utf8_isASCII($subject)) { + $subject = '=?UTF-8?Q?'.mail_quotedprintable_encode($subject,0).'?='; + // Spaces must be encoded according to rfc2047. Use the "_" shorthand + $subject = preg_replace('/ /', '_', $subject); + } - $header = ''; + $header = ''; - // No named recipients for To: in Windows (see FS#652) - $usenames = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? false : true; + // No named recipients for To: in Windows (see FS#652) + $usenames = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? false : true; - $to = mail_encode_address($to,'',$usenames); - $header .= mail_encode_address($from,'From'); - $header .= mail_encode_address($cc,'Cc'); - $header .= mail_encode_address($bcc,'Bcc'); - $header .= 'MIME-Version: 1.0'.MAILHEADER_EOL; - $header .= 'Content-Type: text/plain; charset=UTF-8'.MAILHEADER_EOL; - $header .= 'Content-Transfer-Encoding: quoted-printable'.MAILHEADER_EOL; - $header .= $headers; - $header = trim($header); + $to = mail_encode_address($to,'',$usenames); + $header .= mail_encode_address($from,'From'); + $header .= mail_encode_address($cc,'Cc'); + $header .= mail_encode_address($bcc,'Bcc'); + $header .= 'MIME-Version: 1.0'.MAILHEADER_EOL; + $header .= 'Content-Type: text/plain; charset=UTF-8'.MAILHEADER_EOL; + $header .= 'Content-Transfer-Encoding: quoted-printable'.MAILHEADER_EOL; + $header .= $headers; + $header = trim($header); - $body = mail_quotedprintable_encode($body); + $body = mail_quotedprintable_encode($body); - if($params == null){ - return @mail($to,$subject,$body,$header); - }else{ - return @mail($to,$subject,$body,$header,$params); - } + if($params == null){ + return @mail($to,$subject,$body,$header); + }else{ + return @mail($to,$subject,$body,$header,$params); + } } /** @@ -124,66 +124,66 @@ function _mail_send_action($data) { * @param boolean $names Allow named Recipients? */ function mail_encode_address($string,$header='',$names=true){ - $headers = ''; - $parts = explode(',',$string); - foreach ($parts as $part){ - $part = trim($part); + $headers = ''; + $parts = explode(',',$string); + foreach ($parts as $part){ + $part = trim($part); - // parse address - if(preg_match('#(.*?)<(.*?)>#',$part,$matches)){ - $text = trim($matches[1]); - $addr = $matches[2]; - }else{ - $addr = $part; + // parse address + if(preg_match('#(.*?)<(.*?)>#',$part,$matches)){ + $text = trim($matches[1]); + $addr = $matches[2]; + }else{ + $addr = $part; + } + + // skip empty ones + if(empty($addr)){ + continue; + } + + // FIXME: is there a way to encode the localpart of a emailaddress? + if(!utf8_isASCII($addr)){ + msg(htmlspecialchars("E-Mail address <$addr> is not ASCII"),-1); + continue; + } + + if(!mail_isvalid($addr)){ + msg(htmlspecialchars("E-Mail address <$addr> is not valid"),-1); + continue; + } + + // text was given + if(!empty($text) && $names){ + // add address quotes + $addr = "<$addr>"; + + if(defined('MAILHEADER_ASCIIONLY')){ + $text = utf8_deaccent($text); + $text = utf8_strip($text); + } + + if(!utf8_isASCII($text)){ + $text = '=?UTF-8?Q?'.mail_quotedprintable_encode($text,0).'?='; + } + }else{ + $text = ''; + } + + // add to header comma seperated + if($headers != ''){ + $headers .= ','; + if($header) $headers .= MAILHEADER_EOL.' '; // avoid overlong mail headers + } + $headers .= $text.' '.$addr; } - // skip empty ones - if(empty($addr)){ - continue; - } + if(empty($headers)) return null; - // FIXME: is there a way to encode the localpart of a emailaddress? - if(!utf8_isASCII($addr)){ - msg(htmlspecialchars("E-Mail address <$addr> is not ASCII"),-1); - continue; - } + //if headername was given add it and close correctly + if($header) $headers = $header.': '.$headers.MAILHEADER_EOL; - if(!mail_isvalid($addr)){ - msg(htmlspecialchars("E-Mail address <$addr> is not valid"),-1); - continue; - } - - // text was given - if(!empty($text) && $names){ - // add address quotes - $addr = "<$addr>"; - - if(defined('MAILHEADER_ASCIIONLY')){ - $text = utf8_deaccent($text); - $text = utf8_strip($text); - } - - if(!utf8_isASCII($text)){ - $text = '=?UTF-8?Q?'.mail_quotedprintable_encode($text,0).'?='; - } - }else{ - $text = ''; - } - - // add to header comma seperated - if($headers != ''){ - $headers .= ','; - if($header) $headers .= MAILHEADER_EOL.' '; // avoid overlong mail headers - } - $headers .= $text.' '.$addr; - } - - if(empty($headers)) return null; - - //if headername was given add it and close correctly - if($header) $headers = $header.': '.$headers.MAILHEADER_EOL; - - return $headers; + return $headers; } /** @@ -204,64 +204,63 @@ function mail_isvalid($email){ * @link http://www.php.net/manual/en/function.imap-8bit.php#61216 */ function mail_quotedprintable_encode($sText,$maxlen=74,$bEmulate_imap_8bit=true) { - // split text into lines - $aLines= preg_split("/(?:\r\n|\r|\n)/", $sText); + // split text into lines + $aLines= preg_split("/(?:\r\n|\r|\n)/", $sText); + $cnt = count($aLines); - for ($i=0;$i'.hsc($row).''; echo '
'; }else - $hidden++; + $hidden++; } if ($hidden){ - print '
'.$lang['ref_hidden'].'
'; + print '
'.$lang['ref_hidden'].'
'; } } @@ -86,14 +86,14 @@ function media_metaform($id,$auth){ static $fields = null; if(is_null($fields)){ - foreach (array('default','local') as $config_group) { - if (empty($config_cascade['mediameta'][$config_group])) continue; - foreach ($config_cascade['mediameta'][$config_group] as $config_file) { - if(@file_exists($config_file)){ - include($config_file); - } + foreach (array('default','local') as $config_group) { + if (empty($config_cascade['mediameta'][$config_group])) continue; + foreach ($config_cascade['mediameta'][$config_group] as $config_file) { + if(@file_exists($config_file)){ + include($config_file); + } + } } - } } $src = mediaFN($id); @@ -136,9 +136,9 @@ function media_metaform($id,$auth){ echo '
'.NL; echo ''.NL; echo ''.NL; + '" title="'.$lang['btn_save'].' [S]" accesskey="s" class="button" />'.NL; echo ''.NL; + '" title="'.$lang['btn_cancel'].' [C]" accesskey="c" class="button" />'.NL; echo '
'.NL; echo '
'.NL; } @@ -446,7 +446,7 @@ function media_filelist($ns,$auth=null,$jump=''){ $dir = utf8_encodeFN(str_replace(':','/',$ns)); $data = array(); search($data,$conf['mediadir'],'search_media', - array('showmsg'=>true,'depth'=>1),$dir); + array('showmsg'=>true,'depth'=>1),$dir); if(!count($data)){ echo '
'.$lang['nothingfound'].'
'.NL; @@ -471,19 +471,19 @@ function media_searchlist($query,$ns,$auth=null){ if ($query) { $evdata = array( - 'ns' => $ns, - 'data' => array(), - 'query' => $query - ); + 'ns' => $ns, + 'data' => array(), + 'query' => $query + ); $evt = new Doku_Event('MEDIA_SEARCH', $evdata); if ($evt->advise_before()) { $dir = utf8_encodeFN(str_replace(':','/',$evdata['ns'])); $pattern = '/'.preg_quote($evdata['query'],'/').'/i'; search($evdata['data'], - $conf['mediadir'], - 'search_media', - array('showmsg'=>false,'pattern'=>$pattern), - $dir); + $conf['mediadir'], + 'search_media', + array('showmsg'=>false,'pattern'=>$pattern), + $dir); } $evt->advise_after(); unset($evt); @@ -502,8 +502,6 @@ function media_searchlist($query,$ns,$auth=null){ /** * Print action links for a file depending on filetype * and available permissions - * - * @todo contains inline javascript */ function media_fileactions($item,$auth){ global $lang; @@ -511,8 +509,7 @@ function media_fileactions($item,$auth){ // view button $link = ml($item['id'],'',true); echo ' '; - + 'alt="'.$lang['mediaview'].'" title="'.$lang['mediaview'].'" class="btn" />'; // no further actions if not writable if(!$item['writable']) return; @@ -520,16 +517,16 @@ function media_fileactions($item,$auth){ // delete button if($auth >= AUTH_DELETE){ echo ' '. - ''.$lang['btn_delete'].''; + '&sectok='.getSecurityToken().'" class="btn_media_delete" title="'.$item['id'].'">'. + ''.$lang['btn_delete'].''; } // edit button if($auth >= AUTH_UPLOAD && $item['isimg'] && $item['meta']->getField('File.Mime') == 'image/jpeg'){ echo ' '. - ''.$lang['metaedit'].''; + ''.$lang['metaedit'].''; } } @@ -622,8 +619,8 @@ function media_printimgdetail($item){ // read EXIF/IPTC data $t = $item['meta']->getField(array('IPTC.Headline','xmp.dc:title')); $d = $item['meta']->getField(array('IPTC.Caption','EXIF.UserComment', - 'EXIF.TIFFImageDescription', - 'EXIF.TIFFUserComment')); + 'EXIF.TIFFImageDescription', + 'EXIF.TIFFUserComment')); if(utf8_strlen($d) > 250) $d = utf8_substr($d,0,250).'...'; $k = $item['meta']->getField(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject')); @@ -662,47 +659,47 @@ function media_uploadform($ns, $auth){ $form->addElement(form_makeCloseTag('p')); if($auth >= AUTH_DELETE){ - $form->addElement(form_makeOpenTag('p')); - $form->addElement(form_makeCheckboxField('ow', 1, $lang['txt_overwrt'], 'dw__ow', 'check')); - $form->addElement(form_makeCloseTag('p')); + $form->addElement(form_makeOpenTag('p')); + $form->addElement(form_makeCheckboxField('ow', 1, $lang['txt_overwrt'], 'dw__ow', 'check')); + $form->addElement(form_makeCloseTag('p')); } html_form('upload', $form); // prepare flashvars for multiupload $opt = array( - 'L_gridname' => $lang['mu_gridname'] , - 'L_gridsize' => $lang['mu_gridsize'] , - 'L_gridstat' => $lang['mu_gridstat'] , - 'L_namespace' => $lang['mu_namespace'] , - 'L_overwrite' => $lang['txt_overwrt'], - 'L_browse' => $lang['mu_browse'], - 'L_upload' => $lang['btn_upload'], - 'L_toobig' => $lang['mu_toobig'], - 'L_ready' => $lang['mu_ready'], - 'L_done' => $lang['mu_done'], - 'L_fail' => $lang['mu_fail'], - 'L_authfail' => $lang['mu_authfail'], - 'L_progress' => $lang['mu_progress'], - 'L_filetypes' => $lang['mu_filetypes'], - 'L_info' => $lang['mu_info'], - 'L_lasterr' => $lang['mu_lasterr'], + 'L_gridname' => $lang['mu_gridname'] , + 'L_gridsize' => $lang['mu_gridsize'] , + 'L_gridstat' => $lang['mu_gridstat'] , + 'L_namespace' => $lang['mu_namespace'] , + 'L_overwrite' => $lang['txt_overwrt'], + 'L_browse' => $lang['mu_browse'], + 'L_upload' => $lang['btn_upload'], + 'L_toobig' => $lang['mu_toobig'], + 'L_ready' => $lang['mu_ready'], + 'L_done' => $lang['mu_done'], + 'L_fail' => $lang['mu_fail'], + 'L_authfail' => $lang['mu_authfail'], + 'L_progress' => $lang['mu_progress'], + 'L_filetypes' => $lang['mu_filetypes'], + 'L_info' => $lang['mu_info'], + 'L_lasterr' => $lang['mu_lasterr'], - 'O_ns' => ":$ns", - 'O_backend' => 'mediamanager.php?'.session_name().'='.session_id(), - 'O_maxsize' => php_to_byte(ini_get('upload_max_filesize')), - 'O_extensions'=> join('|',array_keys(getMimeTypes())), - 'O_overwrite' => ($auth >= AUTH_DELETE), - 'O_sectok' => getSecurityToken(), - 'O_authtok' => auth_createToken(), - ); + 'O_ns' => ":$ns", + 'O_backend' => 'mediamanager.php?'.session_name().'='.session_id(), + 'O_maxsize' => php_to_byte(ini_get('upload_max_filesize')), + 'O_extensions'=> join('|',array_keys(getMimeTypes())), + 'O_overwrite' => ($auth >= AUTH_DELETE), + 'O_sectok' => getSecurityToken(), + 'O_authtok' => auth_createToken(), + ); $var = buildURLparams($opt); // output the flash uploader ?> - - +
+ + + 0, 'id' => '', - 'open' =>'true', 'label' => '['.$lang['mediaroot'].']'); + 'open' =>'true', 'label' => '['.$lang['mediaroot'].']'); echo '
    '; echo media_nstree_li($item); @@ -796,7 +793,7 @@ function media_nstree_li($item){ $alt = '+'; } return '
  • '. - ''.$alt.''; + ''.$alt.''; } /** @@ -805,28 +802,28 @@ function media_nstree_li($item){ * @author Andreas Gohr */ function media_resize_image($file, $ext, $w, $h=0){ - global $conf; + global $conf; - $info = @getimagesize($file); //get original size - if($info == false) return $file; // that's no image - it's a spaceship! + $info = @getimagesize($file); //get original size + if($info == false) return $file; // that's no image - it's a spaceship! - if(!$h) $h = round(($w * $info[1]) / $info[0]); + if(!$h) $h = round(($w * $info[1]) / $info[0]); - // we wont scale up to infinity - if($w > 2000 || $h > 2000) return $file; + // we wont scale up to infinity + if($w > 2000 || $h > 2000) return $file; - //cache - $local = getCacheName($file,'.media.'.$w.'x'.$h.'.'.$ext); - $mtime = @filemtime($local); // 0 if not exists + //cache + $local = getCacheName($file,'.media.'.$w.'x'.$h.'.'.$ext); + $mtime = @filemtime($local); // 0 if not exists - if( $mtime > filemtime($file) || - media_resize_imageIM($ext,$file,$info[0],$info[1],$local,$w,$h) || - media_resize_imageGD($ext,$file,$info[0],$info[1],$local,$w,$h) ){ - if($conf['fperm']) chmod($local, $conf['fperm']); - return $local; - } - //still here? resizing failed - return $file; + if( $mtime > filemtime($file) || + media_resize_imageIM($ext,$file,$info[0],$info[1],$local,$w,$h) || + media_resize_imageGD($ext,$file,$info[0],$info[1],$local,$w,$h) ){ + if($conf['fperm']) chmod($local, $conf['fperm']); + return $local; + } + //still here? resizing failed + return $file; } /** @@ -839,49 +836,49 @@ function media_resize_image($file, $ext, $w, $h=0){ * @author Andreas Gohr */ function media_crop_image($file, $ext, $w, $h=0){ - global $conf; + global $conf; - if(!$h) $h = $w; - $info = @getimagesize($file); //get original size - if($info == false) return $file; // that's no image - it's a spaceship! + if(!$h) $h = $w; + $info = @getimagesize($file); //get original size + if($info == false) return $file; // that's no image - it's a spaceship! - // calculate crop size - $fr = $info[0]/$info[1]; - $tr = $w/$h; - if($tr >= 1){ - if($tr > $fr){ - $cw = $info[0]; - $ch = (int) $info[0]/$tr; + // calculate crop size + $fr = $info[0]/$info[1]; + $tr = $w/$h; + if($tr >= 1){ + if($tr > $fr){ + $cw = $info[0]; + $ch = (int) $info[0]/$tr; + }else{ + $cw = (int) $info[1]*$tr; + $ch = $info[1]; + } }else{ - $cw = (int) $info[1]*$tr; - $ch = $info[1]; + if($tr < $fr){ + $cw = (int) $info[1]*$tr; + $ch = $info[1]; + }else{ + $cw = $info[0]; + $ch = (int) $info[0]/$tr; + } } - }else{ - if($tr < $fr){ - $cw = (int) $info[1]*$tr; - $ch = $info[1]; - }else{ - $cw = $info[0]; - $ch = (int) $info[0]/$tr; + // calculate crop offset + $cx = (int) ($info[0]-$cw)/2; + $cy = (int) ($info[1]-$ch)/3; + + //cache + $local = getCacheName($file,'.media.'.$cw.'x'.$ch.'.crop.'.$ext); + $mtime = @filemtime($local); // 0 if not exists + + if( $mtime > filemtime($file) || + media_crop_imageIM($ext,$file,$info[0],$info[1],$local,$cw,$ch,$cx,$cy) || + media_resize_imageGD($ext,$file,$cw,$ch,$local,$cw,$ch,$cx,$cy) ){ + if($conf['fperm']) chmod($local, $conf['fperm']); + return media_resize_image($local,$ext, $w, $h); } - } - // calculate crop offset - $cx = (int) ($info[0]-$cw)/2; - $cy = (int) ($info[1]-$ch)/3; - //cache - $local = getCacheName($file,'.media.'.$cw.'x'.$ch.'.crop.'.$ext); - $mtime = @filemtime($local); // 0 if not exists - - if( $mtime > filemtime($file) || - media_crop_imageIM($ext,$file,$info[0],$info[1],$local,$cw,$ch,$cx,$cy) || - media_resize_imageGD($ext,$file,$cw,$ch,$local,$cw,$ch,$cx,$cy) ){ - if($conf['fperm']) chmod($local, $conf['fperm']); - return media_resize_image($local,$ext, $w, $h); - } - - //still here? cropping failed - return media_resize_image($file,$ext, $w, $h); + //still here? cropping failed + return media_resize_image($file,$ext, $w, $h); } /** @@ -894,31 +891,31 @@ function media_crop_image($file, $ext, $w, $h=0){ * @author Pavel Vitis */ function media_get_from_URL($url,$ext,$cache){ - global $conf; + global $conf; - // if no cache or fetchsize just redirect - if ($cache==0) return false; - if (!$conf['fetchsize']) return false; + // if no cache or fetchsize just redirect + if ($cache==0) return false; + if (!$conf['fetchsize']) return false; - $local = getCacheName(strtolower($url),".media.$ext"); - $mtime = @filemtime($local); // 0 if not exists + $local = getCacheName(strtolower($url),".media.$ext"); + $mtime = @filemtime($local); // 0 if not exists - //decide if download needed: - if( ($mtime == 0) || // cache does not exist - ($cache != -1 && $mtime < time()-$cache) // 'recache' and cache has expired - ){ - if(media_image_download($url,$local)){ - return $local; - }else{ - return false; - } - } + //decide if download needed: + if( ($mtime == 0) || // cache does not exist + ($cache != -1 && $mtime < time()-$cache) // 'recache' and cache has expired + ){ + if(media_image_download($url,$local)){ + return $local; + }else{ + return false; + } + } - //if cache exists use it else - if($mtime) return $local; + //if cache exists use it else + if($mtime) return $local; - //else return false - return false; + //else return false + return false; } /** @@ -927,30 +924,30 @@ function media_get_from_URL($url,$ext,$cache){ * @author Andreas Gohr */ function media_image_download($url,$file){ - global $conf; - $http = new DokuHTTPClient(); - $http->max_bodysize = $conf['fetchsize']; - $http->timeout = 25; //max. 25 sec - $http->header_regexp = '!\r\nContent-Type: image/(jpe?g|gif|png)!i'; + global $conf; + $http = new DokuHTTPClient(); + $http->max_bodysize = $conf['fetchsize']; + $http->timeout = 25; //max. 25 sec + $http->header_regexp = '!\r\nContent-Type: image/(jpe?g|gif|png)!i'; - $data = $http->get($url); - if(!$data) return false; + $data = $http->get($url); + if(!$data) return false; - $fileexists = @file_exists($file); - $fp = @fopen($file,"w"); - if(!$fp) return false; - fwrite($fp,$data); - fclose($fp); - if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']); + $fileexists = @file_exists($file); + $fp = @fopen($file,"w"); + if(!$fp) return false; + fwrite($fp,$data); + fclose($fp); + if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']); - // check if it is really an image - $info = @getimagesize($file); - if(!$info){ - @unlink($file); - return false; - } + // check if it is really an image + $info = @getimagesize($file); + if(!$info){ + @unlink($file); + return false; + } - return true; + return true; } /** @@ -960,22 +957,22 @@ function media_image_download($url,$file){ * @author Andreas Gohr */ function media_resize_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ - global $conf; + global $conf; - // check if convert is configured - if(!$conf['im_convert']) return false; + // check if convert is configured + if(!$conf['im_convert']) return false; - // prepare command - $cmd = $conf['im_convert']; - $cmd .= ' -resize '.$to_w.'x'.$to_h.'!'; - if ($ext == 'jpg' || $ext == 'jpeg') { - $cmd .= ' -quality '.$conf['jpg_quality']; - } - $cmd .= " $from $to"; + // prepare command + $cmd = $conf['im_convert']; + $cmd .= ' -resize '.$to_w.'x'.$to_h.'!'; + if ($ext == 'jpg' || $ext == 'jpeg') { + $cmd .= ' -quality '.$conf['jpg_quality']; + } + $cmd .= " $from $to"; - @exec($cmd,$out,$retval); - if ($retval == 0) return true; - return false; + @exec($cmd,$out,$retval); + if ($retval == 0) return true; + return false; } /** @@ -984,22 +981,22 @@ function media_resize_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ * @author Andreas Gohr */ function media_crop_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x,$ofs_y){ - global $conf; + global $conf; - // check if convert is configured - if(!$conf['im_convert']) return false; + // check if convert is configured + if(!$conf['im_convert']) return false; - // prepare command - $cmd = $conf['im_convert']; - $cmd .= ' -crop '.$to_w.'x'.$to_h.'+'.$ofs_x.'+'.$ofs_y; - if ($ext == 'jpg' || $ext == 'jpeg') { - $cmd .= ' -quality '.$conf['jpg_quality']; - } - $cmd .= " $from $to"; + // prepare command + $cmd = $conf['im_convert']; + $cmd .= ' -crop '.$to_w.'x'.$to_h.'+'.$ofs_x.'+'.$ofs_y; + if ($ext == 'jpg' || $ext == 'jpeg') { + $cmd .= ' -quality '.$conf['jpg_quality']; + } + $cmd .= " $from $to"; - @exec($cmd,$out,$retval); - if ($retval == 0) return true; - return false; + @exec($cmd,$out,$retval); + if ($retval == 0) return true; + return false; } /** @@ -1009,98 +1006,98 @@ function media_crop_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x,$o * @author Sebastian Wienecke */ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x=0,$ofs_y=0){ - global $conf; + global $conf; - if($conf['gdlib'] < 1) return false; //no GDlib available or wanted + if($conf['gdlib'] < 1) return false; //no GDlib available or wanted - // check available memory - if(!is_mem_available(($from_w * $from_h * 4) + ($to_w * $to_h * 4))){ - return false; - } - - // create an image of the given filetype - if ($ext == 'jpg' || $ext == 'jpeg'){ - if(!function_exists("imagecreatefromjpeg")) return false; - $image = @imagecreatefromjpeg($from); - }elseif($ext == 'png') { - if(!function_exists("imagecreatefrompng")) return false; - $image = @imagecreatefrompng($from); - - }elseif($ext == 'gif') { - if(!function_exists("imagecreatefromgif")) return false; - $image = @imagecreatefromgif($from); - } - if(!$image) return false; - - if(($conf['gdlib']>1) && function_exists("imagecreatetruecolor") && $ext != 'gif'){ - $newimg = @imagecreatetruecolor ($to_w, $to_h); - } - if(!$newimg) $newimg = @imagecreate($to_w, $to_h); - if(!$newimg){ - imagedestroy($image); - return false; - } - - //keep png alpha channel if possible - if($ext == 'png' && $conf['gdlib']>1 && function_exists('imagesavealpha')){ - imagealphablending($newimg, false); - imagesavealpha($newimg,true); - } - - //keep gif transparent color if possible - if($ext == 'gif' && function_exists('imagefill') && function_exists('imagecolorallocate')) { - if(function_exists('imagecolorsforindex') && function_exists('imagecolortransparent')) { - $transcolorindex = @imagecolortransparent($image); - if($transcolorindex >= 0 ) { //transparent color exists - $transcolor = @imagecolorsforindex($image, $transcolorindex); - $transcolorindex = @imagecolorallocate($newimg, $transcolor['red'], $transcolor['green'], $transcolor['blue']); - @imagefill($newimg, 0, 0, $transcolorindex); - @imagecolortransparent($newimg, $transcolorindex); - }else{ //filling with white - $whitecolorindex = @imagecolorallocate($newimg, 255, 255, 255); - @imagefill($newimg, 0, 0, $whitecolorindex); - } - }else{ //filling with white - $whitecolorindex = @imagecolorallocate($newimg, 255, 255, 255); - @imagefill($newimg, 0, 0, $whitecolorindex); + // check available memory + if(!is_mem_available(($from_w * $from_h * 4) + ($to_w * $to_h * 4))){ + return false; } - } - //try resampling first - if(function_exists("imagecopyresampled")){ - if(!@imagecopyresampled($newimg, $image, 0, 0, $ofs_x, $ofs_y, $to_w, $to_h, $from_w, $from_h)) { - imagecopyresized($newimg, $image, 0, 0, $ofs_x, $ofs_y, $to_w, $to_h, $from_w, $from_h); + // create an image of the given filetype + if ($ext == 'jpg' || $ext == 'jpeg'){ + if(!function_exists("imagecreatefromjpeg")) return false; + $image = @imagecreatefromjpeg($from); + }elseif($ext == 'png') { + if(!function_exists("imagecreatefrompng")) return false; + $image = @imagecreatefrompng($from); + + }elseif($ext == 'gif') { + if(!function_exists("imagecreatefromgif")) return false; + $image = @imagecreatefromgif($from); } - }else{ - imagecopyresized($newimg, $image, 0, 0, $ofs_x, $ofs_y, $to_w, $to_h, $from_w, $from_h); - } + if(!$image) return false; - $okay = false; - if ($ext == 'jpg' || $ext == 'jpeg'){ - if(!function_exists('imagejpeg')){ - $okay = false; + if(($conf['gdlib']>1) && function_exists("imagecreatetruecolor") && $ext != 'gif'){ + $newimg = @imagecreatetruecolor ($to_w, $to_h); + } + if(!$newimg) $newimg = @imagecreate($to_w, $to_h); + if(!$newimg){ + imagedestroy($image); + return false; + } + + //keep png alpha channel if possible + if($ext == 'png' && $conf['gdlib']>1 && function_exists('imagesavealpha')){ + imagealphablending($newimg, false); + imagesavealpha($newimg,true); + } + + //keep gif transparent color if possible + if($ext == 'gif' && function_exists('imagefill') && function_exists('imagecolorallocate')) { + if(function_exists('imagecolorsforindex') && function_exists('imagecolortransparent')) { + $transcolorindex = @imagecolortransparent($image); + if($transcolorindex >= 0 ) { //transparent color exists + $transcolor = @imagecolorsforindex($image, $transcolorindex); + $transcolorindex = @imagecolorallocate($newimg, $transcolor['red'], $transcolor['green'], $transcolor['blue']); + @imagefill($newimg, 0, 0, $transcolorindex); + @imagecolortransparent($newimg, $transcolorindex); + }else{ //filling with white + $whitecolorindex = @imagecolorallocate($newimg, 255, 255, 255); + @imagefill($newimg, 0, 0, $whitecolorindex); + } + }else{ //filling with white + $whitecolorindex = @imagecolorallocate($newimg, 255, 255, 255); + @imagefill($newimg, 0, 0, $whitecolorindex); + } + } + + //try resampling first + if(function_exists("imagecopyresampled")){ + if(!@imagecopyresampled($newimg, $image, 0, 0, $ofs_x, $ofs_y, $to_w, $to_h, $from_w, $from_h)) { + imagecopyresized($newimg, $image, 0, 0, $ofs_x, $ofs_y, $to_w, $to_h, $from_w, $from_h); + } }else{ - $okay = imagejpeg($newimg, $to, $conf['jpg_quality']); + imagecopyresized($newimg, $image, 0, 0, $ofs_x, $ofs_y, $to_w, $to_h, $from_w, $from_h); } - }elseif($ext == 'png') { - if(!function_exists('imagepng')){ - $okay = false; - }else{ - $okay = imagepng($newimg, $to); - } - }elseif($ext == 'gif') { - if(!function_exists('imagegif')){ - $okay = false; - }else{ - $okay = imagegif($newimg, $to); - } - } - // destroy GD image ressources - if($image) imagedestroy($image); - if($newimg) imagedestroy($newimg); + $okay = false; + if ($ext == 'jpg' || $ext == 'jpeg'){ + if(!function_exists('imagejpeg')){ + $okay = false; + }else{ + $okay = imagejpeg($newimg, $to, $conf['jpg_quality']); + } + }elseif($ext == 'png') { + if(!function_exists('imagepng')){ + $okay = false; + }else{ + $okay = imagepng($newimg, $to); + } + }elseif($ext == 'gif') { + if(!function_exists('imagegif')){ + $okay = false; + }else{ + $okay = imagegif($newimg, $to); + } + } - return $okay; + // destroy GD image ressources + if($image) imagedestroy($image); + if($newimg) imagedestroy($newimg); + + return $okay; } /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ diff --git a/inc/pageutils.php b/inc/pageutils.php index 65b140ea3..484516363 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -19,68 +19,68 @@ * @author Andreas Gohr */ function getID($param='id',$clean=true){ - global $conf; + global $conf; - $id = isset($_REQUEST[$param]) ? $_REQUEST[$param] : null; + $id = isset($_REQUEST[$param]) ? $_REQUEST[$param] : null; - $request = $_SERVER['REQUEST_URI']; + $request = $_SERVER['REQUEST_URI']; - //construct page id from request URI - if(empty($id) && $conf['userewrite'] == 2){ - //get the script URL - if($conf['basedir']){ - $relpath = ''; - if($param != 'id') { - $relpath = 'lib/exe/'; - } - $script = $conf['basedir'].$relpath.basename($_SERVER['SCRIPT_FILENAME']); + //construct page id from request URI + if(empty($id) && $conf['userewrite'] == 2){ + //get the script URL + if($conf['basedir']){ + $relpath = ''; + if($param != 'id') { + $relpath = 'lib/exe/'; + } + $script = $conf['basedir'].$relpath.basename($_SERVER['SCRIPT_FILENAME']); - }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['PATH_TRANSLATED']){ - $request = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','', - $_SERVER['PATH_TRANSLATED']); - }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){ - $script = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','', - $_SERVER['SCRIPT_FILENAME']); - $script = '/'.$script; - }else{ - $script = $_SERVER['SCRIPT_NAME']; + }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['PATH_TRANSLATED']){ + $request = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','', + $_SERVER['PATH_TRANSLATED']); + }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){ + $script = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','', + $_SERVER['SCRIPT_FILENAME']); + $script = '/'.$script; + }else{ + $script = $_SERVER['SCRIPT_NAME']; + } + + //clean script and request (fixes a windows problem) + $script = preg_replace('/\/\/+/','/',$script); + $request = preg_replace('/\/\/+/','/',$request); + + //remove script URL and Querystring to gain the id + if(preg_match('/^'.preg_quote($script,'/').'(.*)/',$request, $match)){ + $id = preg_replace ('/\?.*/','',$match[1]); + } + $id = urldecode($id); + //strip leading slashes + $id = preg_replace('!^/+!','',$id); } - //clean script and request (fixes a windows problem) - $script = preg_replace('/\/\/+/','/',$script); - $request = preg_replace('/\/\/+/','/',$request); - - //remove script URL and Querystring to gain the id - if(preg_match('/^'.preg_quote($script,'/').'(.*)/',$request, $match)){ - $id = preg_replace ('/\?.*/','',$match[1]); + // Namespace autolinking from URL + if(substr($id,-1) == ':' || ($conf['useslash'] && substr($id,-1) == '/')){ + if(page_exists($id.$conf['start'])){ + // start page inside namespace + $id = $id.$conf['start']; + }elseif(page_exists($id.noNS(cleanID($id)))){ + // page named like the NS inside the NS + $id = $id.noNS(cleanID($id)); + }elseif(page_exists($id)){ + // page like namespace exists + $id = substr($id,0,-1); + }else{ + // fall back to default + $id = $id.$conf['start']; + } + send_redirect(wl($id,'',true)); } - $id = urldecode($id); - //strip leading slashes - $id = preg_replace('!^/+!','',$id); - } - // Namespace autolinking from URL - if(substr($id,-1) == ':' || ($conf['useslash'] && substr($id,-1) == '/')){ - if(page_exists($id.$conf['start'])){ - // start page inside namespace - $id = $id.$conf['start']; - }elseif(page_exists($id.noNS(cleanID($id)))){ - // page named like the NS inside the NS - $id = $id.noNS(cleanID($id)); - }elseif(page_exists($id)){ - // page like namespace exists - $id = substr($id,0,-1); - }else{ - // fall back to default - $id = $id.$conf['start']; - } - send_redirect(wl($id,'',true)); - } + if($clean) $id = cleanID($id); + if(empty($id) && $param=='id') $id = $conf['start']; - if($clean) $id = cleanID($id); - if(empty($id) && $param=='id') $id = $conf['start']; - - return $id; + return $id; } /** @@ -95,49 +95,49 @@ function getID($param='id',$clean=true){ * @param boolean $media Allow leading or trailing _ for media files */ function cleanID($raw_id,$ascii=false,$media=false){ - global $conf; - global $lang; - static $sepcharpat = null; + global $conf; + global $lang; + static $sepcharpat = null; - global $cache_cleanid; - $cache = & $cache_cleanid; + global $cache_cleanid; + $cache = & $cache_cleanid; - // check if it's already in the memory cache - if (isset($cache[(string)$raw_id])) { - return $cache[(string)$raw_id]; + // check if it's already in the memory cache + if (isset($cache[(string)$raw_id])) { + return $cache[(string)$raw_id]; } - $sepchar = $conf['sepchar']; - if($sepcharpat == null) // build string only once to save clock cycles - $sepcharpat = '#\\'.$sepchar.'+#'; + $sepchar = $conf['sepchar']; + if($sepcharpat == null) // build string only once to save clock cycles + $sepcharpat = '#\\'.$sepchar.'+#'; - $id = trim((string)$raw_id); - $id = utf8_strtolower($id); + $id = trim((string)$raw_id); + $id = utf8_strtolower($id); - //alternative namespace seperator - $id = strtr($id,';',':'); - if($conf['useslash']){ - $id = strtr($id,'/',':'); - }else{ - $id = strtr($id,'/',$sepchar); - } + //alternative namespace seperator + $id = strtr($id,';',':'); + if($conf['useslash']){ + $id = strtr($id,'/',':'); + }else{ + $id = strtr($id,'/',$sepchar); + } - if($conf['deaccent'] == 2 || $ascii) $id = utf8_romanize($id); - if($conf['deaccent'] || $ascii) $id = utf8_deaccent($id,-1); + if($conf['deaccent'] == 2 || $ascii) $id = utf8_romanize($id); + if($conf['deaccent'] || $ascii) $id = utf8_deaccent($id,-1); - //remove specials - $id = utf8_stripspecials($id,$sepchar,'\*'); + //remove specials + $id = utf8_stripspecials($id,$sepchar,'\*'); - if($ascii) $id = utf8_strip($id); + if($ascii) $id = utf8_strip($id); - //clean up - $id = preg_replace($sepcharpat,$sepchar,$id); - $id = preg_replace('#:+#',':',$id); - $id = ($media ? trim($id,':.-') : trim($id,':._-')); - $id = preg_replace('#:[:\._\-]+#',':',$id); + //clean up + $id = preg_replace($sepcharpat,$sepchar,$id); + $id = preg_replace('#:+#',':',$id); + $id = ($media ? trim($id,':.-') : trim($id,':._-')); + $id = preg_replace('#:[:\._\-]+#',':',$id); - $cache[(string)$raw_id] = $id; - return($id); + $cache[(string)$raw_id] = $id; + return($id); } /** @@ -146,11 +146,11 @@ function cleanID($raw_id,$ascii=false,$media=false){ * @author Andreas Gohr */ function getNS($id){ - $pos = strrpos((string)$id,':'); - if($pos!==false){ - return substr((string)$id,0,$pos); - } - return false; + $pos = strrpos((string)$id,':'); + if($pos!==false){ + return substr((string)$id,0,$pos); + } + return false; } /** @@ -159,12 +159,12 @@ function getNS($id){ * @author Andreas Gohr */ function noNS($id) { - $pos = strrpos($id, ':'); - if ($pos!==false) { - return substr($id, $pos+1); - } else { - return $id; - } + $pos = strrpos($id, ':'); + if ($pos!==false) { + return substr($id, $pos+1); + } else { + return $id; + } } /** @@ -225,14 +225,14 @@ function sectionID($title,&$check) { /** - * Wiki page existence check + * Wiki page existence check * - * parameters as for wikiFN + * parameters as for wikiFN * - * @author Chris Smith + * @author Chris Smith */ function page_exists($id,$rev='',$clean=true) { - return @file_exists(wikiFN($id,$rev,$clean)); + return @file_exists(wikiFN($id,$rev,$clean)); } /** @@ -248,39 +248,39 @@ function page_exists($id,$rev='',$clean=true) { * @author Andreas Gohr */ function wikiFN($raw_id,$rev='',$clean=true){ - global $conf; + global $conf; - global $cache_wikifn; - $cache = & $cache_wikifn; + global $cache_wikifn; + $cache = & $cache_wikifn; - if (isset($cache[$raw_id]) && isset($cache[$raw_id][$rev])) { - return $cache[$raw_id][$rev]; - } - - $id = $raw_id; - - if ($clean) $id = cleanID($id); - $id = str_replace(':','/',$id); - if(empty($rev)){ - $fn = $conf['datadir'].'/'.utf8_encodeFN($id).'.txt'; - }else{ - $fn = $conf['olddir'].'/'.utf8_encodeFN($id).'.'.$rev.'.txt'; - if($conf['compression']){ - //test for extensions here, we want to read both compressions - if (@file_exists($fn . '.gz')){ - $fn .= '.gz'; - }else if(@file_exists($fn . '.bz2')){ - $fn .= '.bz2'; - }else{ - //file doesnt exist yet, so we take the configured extension - $fn .= '.' . $conf['compression']; - } + if (isset($cache[$raw_id]) && isset($cache[$raw_id][$rev])) { + return $cache[$raw_id][$rev]; } - } - if (!isset($cache[$raw_id])) { $cache[$raw_id] = array(); } - $cache[$raw_id][$rev] = $fn; - return $fn; + $id = $raw_id; + + if ($clean) $id = cleanID($id); + $id = str_replace(':','/',$id); + if(empty($rev)){ + $fn = $conf['datadir'].'/'.utf8_encodeFN($id).'.txt'; + }else{ + $fn = $conf['olddir'].'/'.utf8_encodeFN($id).'.'.$rev.'.txt'; + if($conf['compression']){ + //test for extensions here, we want to read both compressions + if (@file_exists($fn . '.gz')){ + $fn .= '.gz'; + }else if(@file_exists($fn . '.bz2')){ + $fn .= '.bz2'; + }else{ + //file doesnt exist yet, so we take the configured extension + $fn .= '.' . $conf['compression']; + } + } + } + + if (!isset($cache[$raw_id])) { $cache[$raw_id] = array(); } + $cache[$raw_id][$rev] = $fn; + return $fn; } /** @@ -289,8 +289,8 @@ function wikiFN($raw_id,$rev='',$clean=true){ * @author Ben Coburn */ function wikiLockFN($id) { - global $conf; - return $conf['lockdir'].'/'.md5(cleanID($id)).'.lock'; + global $conf; + return $conf['lockdir'].'/'.md5(cleanID($id)).'.lock'; } @@ -302,11 +302,11 @@ function wikiLockFN($id) { * @author Steven Danz */ function metaFN($id,$ext){ - global $conf; - $id = cleanID($id); - $id = str_replace(':','/',$id); - $fn = $conf['metadir'].'/'.utf8_encodeFN($id).$ext; - return $fn; + global $conf; + $id = cleanID($id); + $id = str_replace(':','/',$id); + $fn = $conf['metadir'].'/'.utf8_encodeFN($id).$ext; + return $fn; } /** @@ -315,20 +315,20 @@ function metaFN($id,$ext){ * @author Esther Brunner */ function metaFiles($id){ - $name = noNS($id); - $ns = getNS($id); - $dir = ($ns) ? metaFN($ns,'').'/' : metaFN($ns,''); - $files = array(); + $name = noNS($id); + $ns = getNS($id); + $dir = ($ns) ? metaFN($ns,'').'/' : metaFN($ns,''); + $files = array(); - $dh = @opendir($dir); - if(!$dh) return $files; - while(($file = readdir($dh)) !== false){ - if(strpos($file,$name.'.') === 0 && !is_dir($dir.$file)) - $files[] = $dir.$file; - } - closedir($dh); + $dh = @opendir($dir); + if(!$dh) return $files; + while(($file = readdir($dh)) !== false){ + if(strpos($file,$name.'.') === 0 && !is_dir($dir.$file)) + $files[] = $dir.$file; + } + closedir($dh); - return $files; + return $files; } /** @@ -339,11 +339,11 @@ function metaFiles($id){ * @author Andreas Gohr */ function mediaFN($id){ - global $conf; - $id = cleanID($id); - $id = str_replace(':','/',$id); + global $conf; + $id = cleanID($id); + $id = str_replace(':','/',$id); $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); - return $fn; + return $fn; } /** @@ -353,13 +353,13 @@ function mediaFN($id){ * @author Andreas Gohr */ function localeFN($id){ - global $conf; - $file = DOKU_INC.'inc/lang/'.$conf['lang'].'/'.$id.'.txt'; - if(!@file_exists($file)){ - //fall back to english - $file = DOKU_INC.'inc/lang/en/'.$id.'.txt'; - } - return $file; + global $conf; + $file = DOKU_INC.'inc/lang/'.$conf['lang'].'/'.$id.'.txt'; + if(!@file_exists($file)){ + //fall back to english + $file = DOKU_INC.'inc/lang/en/'.$id.'.txt'; + } + return $file; } /** @@ -374,43 +374,43 @@ function localeFN($id){ * @author */ function resolve_id($ns,$id,$clean=true){ - global $conf; + global $conf; - // some pre cleaning for useslash: - if($conf['useslash']) $id = str_replace('/',':',$id); + // some pre cleaning for useslash: + if($conf['useslash']) $id = str_replace('/',':',$id); - // if the id starts with a dot we need to handle the - // relative stuff - if($id{0} == '.'){ - // normalize initial dots without a colon - $id = preg_replace('/^(\.+)(?=[^:\.])/','\1:',$id); - // prepend the current namespace - $id = $ns.':'.$id; + // if the id starts with a dot we need to handle the + // relative stuff + if($id{0} == '.'){ + // normalize initial dots without a colon + $id = preg_replace('/^(\.+)(?=[^:\.])/','\1:',$id); + // prepend the current namespace + $id = $ns.':'.$id; - // cleanup relatives - $result = array(); - $pathA = explode(':', $id); - if (!$pathA[0]) $result[] = ''; - foreach ($pathA AS $key => $dir) { - if ($dir == '..') { - if (end($result) == '..') { - $result[] = '..'; - } elseif (!array_pop($result)) { - $result[] = '..'; + // cleanup relatives + $result = array(); + $pathA = explode(':', $id); + if (!$pathA[0]) $result[] = ''; + foreach ($pathA AS $key => $dir) { + if ($dir == '..') { + if (end($result) == '..') { + $result[] = '..'; + } elseif (!array_pop($result)) { + $result[] = '..'; + } + } elseif ($dir && $dir != '.') { + $result[] = $dir; + } } - } elseif ($dir && $dir != '.') { - $result[] = $dir; - } + if (!end($pathA)) $result[] = ''; + $id = implode(':', $result); + }elseif($ns !== false && strpos($id,':') === false){ + //if link contains no namespace. add current namespace (if any) + $id = $ns.':'.$id; } - if (!end($pathA)) $result[] = ''; - $id = implode(':', $result); - }elseif($ns !== false && strpos($id,':') === false){ - //if link contains no namespace. add current namespace (if any) - $id = $ns.':'.$id; - } - if($clean) $id = cleanID($id); - return $id; + if($clean) $id = cleanID($id); + return $id; } /** @@ -419,9 +419,9 @@ function resolve_id($ns,$id,$clean=true){ * @author Andreas Gohr */ function resolve_mediaid($ns,&$page,&$exists){ - $page = resolve_id($ns,$page); - $file = mediaFN($page); - $exists = @file_exists($file); + $page = resolve_id($ns,$page); + $file = mediaFN($page); + $exists = @file_exists($file); } /** @@ -430,63 +430,63 @@ function resolve_mediaid($ns,&$page,&$exists){ * @author Andreas Gohr */ function resolve_pageid($ns,&$page,&$exists){ - global $conf; - $exists = false; + global $conf; + $exists = false; - //keep hashlink if exists then clean both parts - if (strpos($page,'#')) { - list($page,$hash) = explode('#',$page,2); - } else { - $hash = ''; - } - $hash = cleanID($hash); - $page = resolve_id($ns,$page,false); // resolve but don't clean, yet - - // get filename (calls clean itself) - $file = wikiFN($page); - - // if ends with colon or slash we have a namespace link - if(substr($page,-1) == ':' || ($conf['useslash'] && substr($page,-1) == '/')){ - if(page_exists($page.$conf['start'])){ - // start page inside namespace - $page = $page.$conf['start']; - $exists = true; - }elseif(page_exists($page.noNS(cleanID($page)))){ - // page named like the NS inside the NS - $page = $page.noNS(cleanID($page)); - $exists = true; - }elseif(page_exists($page)){ - // page like namespace exists - $page = $page; - $exists = true; - }else{ - // fall back to default - $page = $page.$conf['start']; + //keep hashlink if exists then clean both parts + if (strpos($page,'#')) { + list($page,$hash) = explode('#',$page,2); + } else { + $hash = ''; } - }else{ - //check alternative plural/nonplural form - if(!@file_exists($file)){ - if( $conf['autoplural'] ){ - if(substr($page,-1) == 's'){ - $try = substr($page,0,-1); + $hash = cleanID($hash); + $page = resolve_id($ns,$page,false); // resolve but don't clean, yet + + // get filename (calls clean itself) + $file = wikiFN($page); + + // if ends with colon or slash we have a namespace link + if(substr($page,-1) == ':' || ($conf['useslash'] && substr($page,-1) == '/')){ + if(page_exists($page.$conf['start'])){ + // start page inside namespace + $page = $page.$conf['start']; + $exists = true; + }elseif(page_exists($page.noNS(cleanID($page)))){ + // page named like the NS inside the NS + $page = $page.noNS(cleanID($page)); + $exists = true; + }elseif(page_exists($page)){ + // page like namespace exists + $page = $page; + $exists = true; }else{ - $try = $page.'s'; + // fall back to default + $page = $page.$conf['start']; } - if(page_exists($try)){ - $page = $try; - $exists = true; - } - } }else{ - $exists = true; + //check alternative plural/nonplural form + if(!@file_exists($file)){ + if( $conf['autoplural'] ){ + if(substr($page,-1) == 's'){ + $try = substr($page,0,-1); + }else{ + $try = $page.'s'; + } + if(page_exists($try)){ + $page = $try; + $exists = true; + } + } + }else{ + $exists = true; + } } - } - // now make sure we have a clean page - $page = cleanID($page); + // now make sure we have a clean page + $page = cleanID($page); - //add hash if any - if(!empty($hash)) $page .= '#'.$hash; + //add hash if any + if(!empty($hash)) $page .= '#'.$hash; } /** @@ -501,11 +501,11 @@ function resolve_pageid($ns,&$page,&$exists){ * @return string The filename of the cachefile */ function getCacheName($data,$ext=''){ - global $conf; - $md5 = md5($data); - $file = $conf['cachedir'].'/'.$md5{0}.'/'.$md5.$ext; - io_makeFileDir($file); - return $file; + global $conf; + $md5 = md5($data); + $file = $conf['cachedir'].'/'.$md5{0}.'/'.$md5.$ext; + io_makeFileDir($file); + return $file; } /** @@ -514,15 +514,15 @@ function getCacheName($data,$ext=''){ * @author Andreas Gohr */ function isHiddenPage($id){ - global $conf; - global $ACT; - if(empty($conf['hidepages'])) return false; - if($ACT == 'admin') return false; + global $conf; + global $ACT; + if(empty($conf['hidepages'])) return false; + if($ACT == 'admin') return false; - if(preg_match('/'.$conf['hidepages'].'/ui',':'.$id)){ - return true; - } - return false; + if(preg_match('/'.$conf['hidepages'].'/ui',':'.$id)){ + return true; + } + return false; } /** @@ -531,8 +531,7 @@ function isHiddenPage($id){ * @author Andreas Gohr */ function isVisiblePage($id){ - return !isHiddenPage($id); + return !isHiddenPage($id); } -//Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/parserutils.php b/inc/parserutils.php index 7887e7a3e..d17ffaa43 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -22,32 +22,32 @@ require_once(DOKU_INC.'inc/cache.php'); * @author Andreas Gohr */ function p_wiki_xhtml($id, $rev='', $excuse=true){ - $file = wikiFN($id,$rev); - $ret = ''; + $file = wikiFN($id,$rev); + $ret = ''; - //ensure $id is in global $ID (needed for parsing) - global $ID; - $keep = $ID; - $ID = $id; + //ensure $id is in global $ID (needed for parsing) + global $ID; + $keep = $ID; + $ID = $id; - if($rev){ - if(@file_exists($file)){ - $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info); //no caching on old revisions - }elseif($excuse){ - $ret = p_locale_xhtml('norev'); + if($rev){ + if(@file_exists($file)){ + $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info); //no caching on old revisions + }elseif($excuse){ + $ret = p_locale_xhtml('norev'); + } + }else{ + if(@file_exists($file)){ + $ret = p_cached_output($file,'xhtml',$id); + }elseif($excuse){ + $ret = p_locale_xhtml('newpage'); + } } - }else{ - if(@file_exists($file)){ - $ret = p_cached_output($file,'xhtml',$id); - }elseif($excuse){ - $ret = p_locale_xhtml('newpage'); - } - } - //restore ID (just in case) - $ID = $keep; + //restore ID (just in case) + $ID = $keep; - return $ret; + return $ret; } /** @@ -63,48 +63,48 @@ function p_wiki_xhtml($id, $rev='', $excuse=true){ * @author Harry Fuecks */ function p_wiki_xhtml_summary($id, &$title, $rev='', $excuse=true){ - $file = wikiFN($id,$rev); - $ret = ''; + $file = wikiFN($id,$rev); + $ret = ''; - //ensure $id is in global $ID (needed for parsing) - global $ID; - $keep = $ID; - $ID = $id; + //ensure $id is in global $ID (needed for parsing) + global $ID; + $keep = $ID; + $ID = $id; - if($rev){ - if(@file_exists($file)){ - //no caching on old revisions - $ins = p_get_instructions(io_readWikiPage($file,$id,$rev)); - }elseif($excuse){ - $ret = p_locale_xhtml('norev'); - //restore ID (just in case) - $ID = $keep; - return $ret; + if($rev){ + if(@file_exists($file)){ + //no caching on old revisions + $ins = p_get_instructions(io_readWikiPage($file,$id,$rev)); + }elseif($excuse){ + $ret = p_locale_xhtml('norev'); + //restore ID (just in case) + $ID = $keep; + return $ret; + } + + }else{ + + if(@file_exists($file)){ + // The XHTML for a summary is not cached so use the instruction cache + $ins = p_cached_instructions($file); + }elseif($excuse){ + $ret = p_locale_xhtml('newpage'); + //restore ID (just in case) + $ID = $keep; + return $ret; + } } - }else{ + $ret = p_render('xhtmlsummary',$ins,$info); - if(@file_exists($file)){ - // The XHTML for a summary is not cached so use the instruction cache - $ins = p_cached_instructions($file); - }elseif($excuse){ - $ret = p_locale_xhtml('newpage'); - //restore ID (just in case) - $ID = $keep; - return $ret; + if ( $info['sum_pagetitle'] ) { + $title = $info['sum_pagetitle']; + } else { + $title = $id; } - } - $ret = p_render('xhtmlsummary',$ins,$info); - - if ( $info['sum_pagetitle'] ) { - $title = $info['sum_pagetitle']; - } else { - $title = $id; - } - - $ID = $keep; - return $ret; + $ID = $keep; + return $ret; } /** @@ -113,9 +113,9 @@ function p_wiki_xhtml_summary($id, &$title, $rev='', $excuse=true){ * @author Andreas Gohr */ function p_locale_xhtml($id){ - //fetch parsed locale - $html = p_cached_output(localeFN($id)); - return $html; + //fetch parsed locale + $html = p_cached_output(localeFN($id)); + return $html; } /** @@ -132,7 +132,7 @@ function p_locale_xhtml($id){ * @todo rewrite to use mode instead of hardcoded XHTML */ function p_cached_xhtml($file){ - return p_cached_output($file); + return p_cached_output($file); } /** @@ -142,25 +142,25 @@ function p_cached_xhtml($file){ * @author Chris Smith */ function p_cached_output($file, $format='xhtml', $id='') { - global $conf; + global $conf; - $cache = new cache_renderer($id, $file, $format); - if ($cache->useCache()) { - $parsed = $cache->retrieveCache(false); - if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; - } else { - $parsed = p_render($format, p_cached_instructions($file,false,$id), $info); + $cache = new cache_renderer($id, $file, $format); + if ($cache->useCache()) { + $parsed = $cache->retrieveCache(false); + if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; + } else { + $parsed = p_render($format, p_cached_instructions($file,false,$id), $info); - if ($info['cache']) { - $cache->storeCache($parsed); //save cachefile - if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; - }else{ - $cache->removeCache(); //try to delete cachefile - if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; + if ($info['cache']) { + $cache->storeCache($parsed); //save cachefile + if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; + }else{ + $cache->removeCache(); //try to delete cachefile + if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; + } } - } - return $parsed; + return $parsed; } /** @@ -171,26 +171,26 @@ function p_cached_output($file, $format='xhtml', $id='') { * @author Andreas Gohr */ function p_cached_instructions($file,$cacheonly=false,$id='') { - global $conf; - static $run = null; - if(is_null($run)) $run = array(); + global $conf; + static $run = null; + if(is_null($run)) $run = array(); - $cache = new cache_instructions($id, $file); + $cache = new cache_instructions($id, $file); - if ($cacheonly || $cache->useCache() || isset($run[$file])) { - return $cache->retrieveCache(); - } else if (@file_exists($file)) { - // no cache - do some work - $ins = p_get_instructions(io_readWikiPage($file,$id)); - if ($cache->storeCache($ins)) { - $run[$file] = true; // we won't rebuild these instructions in the same run again - } else { - msg('Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.',-1); + if ($cacheonly || $cache->useCache() || isset($run[$file])) { + return $cache->retrieveCache(); + } else if (@file_exists($file)) { + // no cache - do some work + $ins = p_get_instructions(io_readWikiPage($file,$id)); + if ($cache->storeCache($ins)) { + $run[$file] = true; // we won't rebuild these instructions in the same run again + } else { + msg('Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.',-1); + } + return $ins; } - return $ins; - } - return null; + return null; } /** @@ -201,24 +201,24 @@ function p_cached_instructions($file,$cacheonly=false,$id='') { */ function p_get_instructions($text){ - $modes = p_get_parsermodes(); + $modes = p_get_parsermodes(); - // Create the parser - $Parser = & new Doku_Parser(); + // Create the parser + $Parser = & new Doku_Parser(); - // Add the Handler - $Parser->Handler = & new Doku_Handler(); + // Add the Handler + $Parser->Handler = & new Doku_Handler(); - //add modes to parser - foreach($modes as $mode){ - $Parser->addMode($mode['mode'],$mode['obj']); - } + //add modes to parser + foreach($modes as $mode){ + $Parser->addMode($mode['mode'],$mode['obj']); + } - // Do the parsing - trigger_event('PARSER_WIKITEXT_PREPROCESS', $text); - $p = $Parser->parse($text); -// dbg($p); - return $p; + // Do the parsing + trigger_event('PARSER_WIKITEXT_PREPROCESS', $text); + $p = $Parser->parse($text); + // dbg($p); + return $p; } /** @@ -227,37 +227,37 @@ function p_get_instructions($text){ * @author Esther Brunner */ function p_get_metadata($id, $key=false, $render=false){ - global $ID, $INFO, $cache_metadata; + global $ID, $INFO, $cache_metadata; - // cache the current page - // Benchmarking shows the current page's metadata is generally the only page metadata - // accessed several times. This may catch a few other pages, but that shouldn't be an issue. - $cache = ($ID == $id); - $meta = p_read_metadata($id, $cache); + // cache the current page + // Benchmarking shows the current page's metadata is generally the only page metadata + // accessed several times. This may catch a few other pages, but that shouldn't be an issue. + $cache = ($ID == $id); + $meta = p_read_metadata($id, $cache); - // metadata has never been rendered before - do it! (but not for non-existent pages) - if ($render && !isset($meta['current']['description']['abstract']) && page_exists($id)){ - $meta = p_render_metadata($id, $meta); - io_saveFile(metaFN($id, '.meta'), serialize($meta)); + // metadata has never been rendered before - do it! (but not for non-existent pages) + if ($render && !isset($meta['current']['description']['abstract']) && page_exists($id)){ + $meta = p_render_metadata($id, $meta); + io_saveFile(metaFN($id, '.meta'), serialize($meta)); - // sync cached copies, including $INFO metadata - if (!empty($cache_metadata[$id])) $cache_metadata[$id] = $meta; - if (!empty($INFO) && ($id == $INFO['id'])) { $INFO['meta'] = $meta['current']; } - } - - // filter by $key - if ($key){ - list($key, $subkey) = explode(' ', $key, 2); - $subkey = trim($subkey); - - if ($subkey) { - return isset($meta['current'][$key][$subkey]) ? $meta['current'][$key][$subkey] : null; + // sync cached copies, including $INFO metadata + if (!empty($cache_metadata[$id])) $cache_metadata[$id] = $meta; + if (!empty($INFO) && ($id == $INFO['id'])) { $INFO['meta'] = $meta['current']; } } - return isset($meta['current'][$key]) ? $meta['current'][$key] : null; - } + // filter by $key + if ($key){ + list($key, $subkey) = explode(' ', $key, 2); + $subkey = trim($subkey); - return $meta['current']; + if ($subkey) { + return isset($meta['current'][$key][$subkey]) ? $meta['current'][$key][$subkey] : null; + } + + return isset($meta['current'][$key]) ? $meta['current'][$key] : null; + } + + return $meta['current']; } /** @@ -266,59 +266,59 @@ function p_get_metadata($id, $key=false, $render=false){ * @author Esther Brunner */ function p_set_metadata($id, $data, $render=false, $persistent=true){ - if (!is_array($data)) return false; + if (!is_array($data)) return false; - global $ID; + global $ID; - // cache the current page - $cache = ($ID == $id); - $orig = p_read_metadata($id, $cache); + // cache the current page + $cache = ($ID == $id); + $orig = p_read_metadata($id, $cache); - // render metadata first? - $meta = $render ? p_render_metadata($id, $orig) : $orig; + // render metadata first? + $meta = $render ? p_render_metadata($id, $orig) : $orig; - // now add the passed metadata - $protected = array('description', 'date', 'contributor'); - foreach ($data as $key => $value){ + // now add the passed metadata + $protected = array('description', 'date', 'contributor'); + foreach ($data as $key => $value){ - // be careful with sub-arrays of $meta['relation'] - if ($key == 'relation'){ + // be careful with sub-arrays of $meta['relation'] + if ($key == 'relation'){ - foreach ($value as $subkey => $subvalue){ - $meta['current'][$key][$subkey] = !empty($meta['current'][$key][$subkey]) ? array_merge($meta['current'][$key][$subkey], $subvalue) : $subvalue; - if ($persistent) - $meta['persistent'][$key][$subkey] = !empty($meta['persistent'][$key][$subkey]) ? array_merge($meta['persistent'][$key][$subkey], $subvalue) : $subvalue; - } + foreach ($value as $subkey => $subvalue){ + $meta['current'][$key][$subkey] = !empty($meta['current'][$key][$subkey]) ? array_merge($meta['current'][$key][$subkey], $subvalue) : $subvalue; + if ($persistent) + $meta['persistent'][$key][$subkey] = !empty($meta['persistent'][$key][$subkey]) ? array_merge($meta['persistent'][$key][$subkey], $subvalue) : $subvalue; + } - // be careful with some senisitive arrays of $meta - } elseif (in_array($key, $protected)){ + // be careful with some senisitive arrays of $meta + } elseif (in_array($key, $protected)){ - // these keys, must have subkeys - a legitimate value must be an array - if (is_array($value)) { - $meta['current'][$key] = !empty($meta['current'][$key]) ? array_merge($meta['current'][$key],$value) : $value; + // these keys, must have subkeys - a legitimate value must be an array + if (is_array($value)) { + $meta['current'][$key] = !empty($meta['current'][$key]) ? array_merge($meta['current'][$key],$value) : $value; - if ($persistent) { - $meta['persistent'][$key] = !empty($meta['persistent'][$key]) ? array_merge($meta['persistent'][$key],$value) : $value; + if ($persistent) { + $meta['persistent'][$key] = !empty($meta['persistent'][$key]) ? array_merge($meta['persistent'][$key],$value) : $value; + } + } + + // no special treatment for the rest + } else { + $meta['current'][$key] = $value; + if ($persistent) $meta['persistent'][$key] = $value; } - } - - // no special treatment for the rest - } else { - $meta['current'][$key] = $value; - if ($persistent) $meta['persistent'][$key] = $value; } - } - // save only if metadata changed - if ($meta == $orig) return true; + // save only if metadata changed + if ($meta == $orig) return true; - // sync cached copies, including $INFO metadata - global $cache_metadata, $INFO; + // sync cached copies, including $INFO metadata + global $cache_metadata, $INFO; - if (!empty($cache_metadata[$id])) $cache_metadata[$id] = $meta; - if (!empty($INFO) && ($id == $INFO['id'])) { $INFO['meta'] = $meta['current']; } + if (!empty($cache_metadata[$id])) $cache_metadata[$id] = $meta; + if (!empty($INFO) && ($id == $INFO['id'])) { $INFO['meta'] = $meta['current']; } - return io_saveFile(metaFN($id, '.meta'), serialize($meta)); + return io_saveFile(metaFN($id, '.meta'), serialize($meta)); } /** @@ -356,38 +356,38 @@ function p_purge_metadata($id) { * @return array metadata */ function p_read_metadata($id,$cache=false) { - global $cache_metadata; + global $cache_metadata; - if (isset($cache_metadata[(string)$id])) return $cache_metadata[(string)$id]; + if (isset($cache_metadata[(string)$id])) return $cache_metadata[(string)$id]; - $file = metaFN($id, '.meta'); - $meta = @file_exists($file) ? unserialize(io_readFile($file, false)) : array('current'=>array(),'persistent'=>array()); + $file = metaFN($id, '.meta'); + $meta = @file_exists($file) ? unserialize(io_readFile($file, false)) : array('current'=>array(),'persistent'=>array()); - // convert $meta from old format to new (current+persistent) format - if (!isset($meta['current'])) { - $meta = array('current'=>$meta,'persistent'=>$meta); + // convert $meta from old format to new (current+persistent) format + if (!isset($meta['current'])) { + $meta = array('current'=>$meta,'persistent'=>$meta); - // remove non-persistent keys - unset($meta['persistent']['title']); - unset($meta['persistent']['description']['abstract']); - unset($meta['persistent']['description']['tableofcontents']); - unset($meta['persistent']['relation']['haspart']); - unset($meta['persistent']['relation']['references']); - unset($meta['persistent']['date']['valid']); + // remove non-persistent keys + unset($meta['persistent']['title']); + unset($meta['persistent']['description']['abstract']); + unset($meta['persistent']['description']['tableofcontents']); + unset($meta['persistent']['relation']['haspart']); + unset($meta['persistent']['relation']['references']); + unset($meta['persistent']['date']['valid']); - if (empty($meta['persistent']['description'])) unset($meta['persistent']['description']); - if (empty($meta['persistent']['relation'])) unset($meta['persistent']['relation']); - if (empty($meta['persistent']['date'])) unset($meta['persistent']['date']); + if (empty($meta['persistent']['description'])) unset($meta['persistent']['description']); + if (empty($meta['persistent']['relation'])) unset($meta['persistent']['relation']); + if (empty($meta['persistent']['date'])) unset($meta['persistent']['date']); - // save converted metadata - io_saveFile($file, serialize($meta)); - } + // save converted metadata + io_saveFile($file, serialize($meta)); + } - if ($cache) { - $cache_metadata[(string)$id] = $meta; - } + if ($cache) { + $cache_metadata[(string)$id] = $meta; + } - return $meta; + return $meta; } /** @@ -396,43 +396,42 @@ function p_read_metadata($id,$cache=false) { * @author Esther Brunner */ function p_render_metadata($id, $orig){ - // make sure the correct ID is in global ID - global $ID; - $keep = $ID; - $ID = $id; + // make sure the correct ID is in global ID + global $ID; + $keep = $ID; + $ID = $id; + // add an extra key for the event - to tell event handlers the page whose metadata this is + $orig['page'] = $id; + $evt = new Doku_Event('PARSER_METADATA_RENDER', $orig); + if ($evt->advise_before()) { - // add an extra key for the event - to tell event handlers the page whose metadata this is - $orig['page'] = $id; - $evt = new Doku_Event('PARSER_METADATA_RENDER', $orig); - if ($evt->advise_before()) { + require_once DOKU_INC."inc/parser/metadata.php"; - require_once DOKU_INC."inc/parser/metadata.php"; + // get instructions + $instructions = p_cached_instructions(wikiFN($id),false,$id); + if(is_null($instructions)){ + $ID = $keep; + return null; // something went wrong with the instructions + } - // get instructions - $instructions = p_cached_instructions(wikiFN($id),false,$id); - if(is_null($instructions)){ - $ID = $keep; - return null; // something went wrong with the instructions + // set up the renderer + $renderer = & new Doku_Renderer_metadata(); + $renderer->meta = $orig['current']; + $renderer->persistent = $orig['persistent']; + + // loop through the instructions + foreach ($instructions as $instruction){ + // execute the callback against the renderer + call_user_func_array(array(&$renderer, $instruction[0]), $instruction[1]); + } + + $evt->result = array('current'=>$renderer->meta,'persistent'=>$renderer->persistent); } + $evt->advise_after(); - // set up the renderer - $renderer = & new Doku_Renderer_metadata(); - $renderer->meta = $orig['current']; - $renderer->persistent = $orig['persistent']; - - // loop through the instructions - foreach ($instructions as $instruction){ - // execute the callback against the renderer - call_user_func_array(array(&$renderer, $instruction[0]), $instruction[1]); - } - - $evt->result = array('current'=>$renderer->meta,'persistent'=>$renderer->persistent); - } - $evt->advise_after(); - - $ID = $keep; - return $evt->result; + $ID = $keep; + return $evt->result; } /** @@ -441,90 +440,89 @@ function p_render_metadata($id, $orig){ * @author Andreas Gohr */ function p_get_parsermodes(){ - global $conf; + global $conf; - //reuse old data - static $modes = null; - if($modes != null){ - return $modes; - } - - //import parser classes and mode definitions - require_once DOKU_INC . 'inc/parser/parser.php'; - - // we now collect all syntax modes and their objects, then they will - // be sorted and added to the parser in correct order - $modes = array(); - - // add syntax plugins - $pluginlist = plugin_list('syntax'); - if(count($pluginlist)){ - global $PARSER_MODES; - $obj = null; - foreach($pluginlist as $p){ - if(!$obj =& plugin_load('syntax',$p)) continue; //attempt to load plugin into $obj - $PARSER_MODES[$obj->getType()][] = "plugin_$p"; //register mode type - //add to modes - $modes[] = array( - 'sort' => $obj->getSort(), - 'mode' => "plugin_$p", - 'obj' => $obj, - ); - unset($obj); //remove the reference + //reuse old data + static $modes = null; + if($modes != null){ + return $modes; } - } - // add default modes - $std_modes = array('listblock','preformatted','notoc','nocache', - 'header','table','linebreak','footnote','hr', - 'unformatted','php','html','code','file','quote', - 'internallink','rss','media','externallink', - 'emaillink','windowssharelink','eol'); - if($conf['typography']){ - $std_modes[] = 'quotes'; - $std_modes[] = 'multiplyentity'; - } - foreach($std_modes as $m){ - $class = "Doku_Parser_Mode_$m"; - $obj = new $class(); - $modes[] = array( - 'sort' => $obj->getSort(), - 'mode' => $m, - 'obj' => $obj - ); - } + //import parser classes and mode definitions + require_once DOKU_INC . 'inc/parser/parser.php'; - // add formatting modes - $fmt_modes = array('strong','emphasis','underline','monospace', - 'subscript','superscript','deleted'); - foreach($fmt_modes as $m){ - $obj = new Doku_Parser_Mode_formatting($m); - $modes[] = array( - 'sort' => $obj->getSort(), - 'mode' => $m, - 'obj' => $obj - ); - } + // we now collect all syntax modes and their objects, then they will + // be sorted and added to the parser in correct order + $modes = array(); - // add modes which need files - $obj = new Doku_Parser_Mode_smiley(array_keys(getSmileys())); - $modes[] = array('sort' => $obj->getSort(), 'mode' => 'smiley','obj' => $obj ); - $obj = new Doku_Parser_Mode_acronym(array_keys(getAcronyms())); - $modes[] = array('sort' => $obj->getSort(), 'mode' => 'acronym','obj' => $obj ); - $obj = new Doku_Parser_Mode_entity(array_keys(getEntities())); - $modes[] = array('sort' => $obj->getSort(), 'mode' => 'entity','obj' => $obj ); + // add syntax plugins + $pluginlist = plugin_list('syntax'); + if(count($pluginlist)){ + global $PARSER_MODES; + $obj = null; + foreach($pluginlist as $p){ + if(!$obj =& plugin_load('syntax',$p)) continue; //attempt to load plugin into $obj + $PARSER_MODES[$obj->getType()][] = "plugin_$p"; //register mode type + //add to modes + $modes[] = array( + 'sort' => $obj->getSort(), + 'mode' => "plugin_$p", + 'obj' => $obj, + ); + unset($obj); //remove the reference + } + } + // add default modes + $std_modes = array('listblock','preformatted','notoc','nocache', + 'header','table','linebreak','footnote','hr', + 'unformatted','php','html','code','file','quote', + 'internallink','rss','media','externallink', + 'emaillink','windowssharelink','eol'); + if($conf['typography']){ + $std_modes[] = 'quotes'; + $std_modes[] = 'multiplyentity'; + } + foreach($std_modes as $m){ + $class = "Doku_Parser_Mode_$m"; + $obj = new $class(); + $modes[] = array( + 'sort' => $obj->getSort(), + 'mode' => $m, + 'obj' => $obj + ); + } - // add optional camelcase mode - if($conf['camelcase']){ - $obj = new Doku_Parser_Mode_camelcaselink(); - $modes[] = array('sort' => $obj->getSort(), 'mode' => 'camelcaselink','obj' => $obj ); - } + // add formatting modes + $fmt_modes = array('strong','emphasis','underline','monospace', + 'subscript','superscript','deleted'); + foreach($fmt_modes as $m){ + $obj = new Doku_Parser_Mode_formatting($m); + $modes[] = array( + 'sort' => $obj->getSort(), + 'mode' => $m, + 'obj' => $obj + ); + } - //sort modes - usort($modes,'p_sort_modes'); + // add modes which need files + $obj = new Doku_Parser_Mode_smiley(array_keys(getSmileys())); + $modes[] = array('sort' => $obj->getSort(), 'mode' => 'smiley','obj' => $obj ); + $obj = new Doku_Parser_Mode_acronym(array_keys(getAcronyms())); + $modes[] = array('sort' => $obj->getSort(), 'mode' => 'acronym','obj' => $obj ); + $obj = new Doku_Parser_Mode_entity(array_keys(getEntities())); + $modes[] = array('sort' => $obj->getSort(), 'mode' => 'entity','obj' => $obj ); - return $modes; + // add optional camelcase mode + if($conf['camelcase']){ + $obj = new Doku_Parser_Mode_camelcaselink(); + $modes[] = array('sort' => $obj->getSort(), 'mode' => 'camelcaselink','obj' => $obj ); + } + + //sort modes + usort($modes,'p_sort_modes'); + + return $modes; } /** @@ -533,8 +531,8 @@ function p_get_parsermodes(){ * @author Andreas Gohr */ function p_sort_modes($a, $b){ - if($a['sort'] == $b['sort']) return 0; - return ($a['sort'] < $b['sort']) ? -1 : 1; + if($a['sort'] == $b['sort']) return 0; + return ($a['sort'] < $b['sort']) ? -1 : 1; } /** @@ -546,64 +544,63 @@ function p_sort_modes($a, $b){ * @author Andreas Gohr */ function p_render($mode,$instructions,&$info){ - if(is_null($instructions)) return ''; + if(is_null($instructions)) return ''; - $Renderer =& p_get_renderer($mode); - if (is_null($Renderer)) return null; + $Renderer =& p_get_renderer($mode); + if (is_null($Renderer)) return null; - $Renderer->reset(); + $Renderer->reset(); - $Renderer->smileys = getSmileys(); - $Renderer->entities = getEntities(); - $Renderer->acronyms = getAcronyms(); - $Renderer->interwiki = getInterwiki(); - #$Renderer->badwords = getBadWords(); + $Renderer->smileys = getSmileys(); + $Renderer->entities = getEntities(); + $Renderer->acronyms = getAcronyms(); + $Renderer->interwiki = getInterwiki(); - // Loop through the instructions - foreach ( $instructions as $instruction ) { - // Execute the callback against the Renderer - call_user_func_array(array(&$Renderer, $instruction[0]),$instruction[1]); - } + // Loop through the instructions + foreach ( $instructions as $instruction ) { + // Execute the callback against the Renderer + call_user_func_array(array(&$Renderer, $instruction[0]),$instruction[1]); + } - //set info array - $info = $Renderer->info; + //set info array + $info = $Renderer->info; - // Post process and return the output - $data = array($mode,& $Renderer->doc); - trigger_event('RENDERER_CONTENT_POSTPROCESS',$data); - return $Renderer->doc; + // Post process and return the output + $data = array($mode,& $Renderer->doc); + trigger_event('RENDERER_CONTENT_POSTPROCESS',$data); + return $Renderer->doc; } function & p_get_renderer($mode) { - global $conf, $plugin_controller; + global $conf, $plugin_controller; - $rname = !empty($conf['renderer_'.$mode]) ? $conf['renderer_'.$mode] : $mode; + $rname = !empty($conf['renderer_'.$mode]) ? $conf['renderer_'.$mode] : $mode; - // try default renderer first: - $file = DOKU_INC."inc/parser/$rname.php"; - if(@file_exists($file)){ - require_once $file; - $rclass = "Doku_Renderer_$rname"; + // try default renderer first: + $file = DOKU_INC."inc/parser/$rname.php"; + if(@file_exists($file)){ + require_once $file; + $rclass = "Doku_Renderer_$rname"; - if ( !class_exists($rclass) ) { - trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); - msg("Renderer '$rname' for $mode not valid",-1); - return null; - } - $Renderer = & new $rclass(); - }else{ - // Maybe a plugin is available? - if (!$plugin_controller->isdisabled($rname)){ - $Renderer =& $plugin_controller->load('renderer',$rname, true); + if ( !class_exists($rclass) ) { + trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); + msg("Renderer '$rname' for $mode not valid",-1); + return null; + } + $Renderer = & new $rclass(); + }else{ + // Maybe a plugin is available? + if (!$plugin_controller->isdisabled($rname)){ + $Renderer =& $plugin_controller->load('renderer',$rname, true); + } + + if(is_null($Renderer)){ + msg("No renderer '$rname' found for mode '$mode'",-1); + return null; + } } - if(is_null($Renderer)){ - msg("No renderer '$rname' found for mode '$mode'",-1); - return null; - } - } - - return $Renderer; + return $Renderer; } /** @@ -620,7 +617,7 @@ function & p_get_renderer($mode) { * @author Andreas Gohr */ function p_get_first_heading($id, $render=true){ - return p_get_metadata($id,'title',$render); + return p_get_metadata($id,'title',$render); } /** @@ -634,42 +631,41 @@ function p_get_first_heading($id, $render=true){ * @author Andreas Gohr */ function p_xhtml_cached_geshi($code, $language, $wrapper='pre') { - global $conf, $config_cascade; - $language = strtolower($language); + global $conf, $config_cascade; + $language = strtolower($language); - // remove any leading or trailing blank lines - $code = preg_replace('/^\s*?\n|\s*?\n$/','',$code); + // remove any leading or trailing blank lines + $code = preg_replace('/^\s*?\n|\s*?\n$/','',$code); - $cache = getCacheName($language.$code,".code"); - $ctime = @filemtime($cache); - if($ctime && !$_REQUEST['purge'] && - $ctime > filemtime(DOKU_INC.'inc/geshi.php') && // geshi changed - $ctime > @filemtime(DOKU_INC.'inc/geshi/'.$language.'.php') && // language syntax definition changed - $ctime > filemtime(reset($config_cascade['main']['default']))){ // dokuwiki changed - $highlighted_code = io_readFile($cache, false); + $cache = getCacheName($language.$code,".code"); + $ctime = @filemtime($cache); + if($ctime && !$_REQUEST['purge'] && + $ctime > filemtime(DOKU_INC.'inc/geshi.php') && // geshi changed + $ctime > @filemtime(DOKU_INC.'inc/geshi/'.$language.'.php') && // language syntax definition changed + $ctime > filemtime(reset($config_cascade['main']['default']))){ // dokuwiki changed + $highlighted_code = io_readFile($cache, false); - } else { + } else { - require_once(DOKU_INC . 'inc/geshi.php'); + require_once(DOKU_INC . 'inc/geshi.php'); - $geshi = new GeSHi($code, $language, DOKU_INC . 'inc/geshi'); - $geshi->set_encoding('utf-8'); - $geshi->enable_classes(); - $geshi->set_header_type(GESHI_HEADER_PRE); - $geshi->set_link_target($conf['target']['extern']); + $geshi = new GeSHi($code, $language, DOKU_INC . 'inc/geshi'); + $geshi->set_encoding('utf-8'); + $geshi->enable_classes(); + $geshi->set_header_type(GESHI_HEADER_PRE); + $geshi->set_link_target($conf['target']['extern']); - // remove GeSHi's wrapper element (we'll replace it with our own later) - // we need to use a GeSHi wrapper to avoid
    throughout the highlighted text - $highlighted_code = trim(preg_replace('!^]*>|$!','',$geshi->parse_code()),"\n\r"); - io_saveFile($cache,$highlighted_code); - } + // remove GeSHi's wrapper element (we'll replace it with our own later) + // we need to use a GeSHi wrapper to avoid
    throughout the highlighted text + $highlighted_code = trim(preg_replace('!^]*>|$!','',$geshi->parse_code()),"\n\r"); + io_saveFile($cache,$highlighted_code); + } - // add a wrapper element if required - if ($wrapper) { - return "<$wrapper class=\"code $language\">$highlighted_code"; - } else { - return $highlighted_code; - } + // add a wrapper element if required + if ($wrapper) { + return "<$wrapper class=\"code $language\">$highlighted_code"; + } else { + return $highlighted_code; + } } -//Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/plugin.php b/inc/plugin.php index 33cb06c87..54d2580e9 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -12,222 +12,234 @@ */ class DokuWiki_Plugin { - var $localised = false; // set to true by setupLocale() after loading language dependent strings - var $lang = array(); // array to hold language dependent strings, best accessed via ->getLang() - var $configloaded = false; // set to true by loadConfig() after loading plugin configuration variables - var $conf = array(); // array to hold plugin settings, best accessed via ->getConf() + var $localised = false; // set to true by setupLocale() after loading language dependent strings + var $lang = array(); // array to hold language dependent strings, best accessed via ->getLang() + var $configloaded = false; // set to true by loadConfig() after loading plugin configuration variables + var $conf = array(); // array to hold plugin settings, best accessed via ->getConf() - /** - * General Info - * - * Needs to return a associative array with the following values: - * - * author - Author of the plugin - * email - Email address to contact the author - * date - Last modified date of the plugin in YYYY-MM-DD format - * name - Name of the plugin - * desc - Short description of the plugin (Text only) - * url - Website with more information on the plugin (eg. syntax description) - */ - function getInfo(){ - trigger_error('getInfo() not implemented in '.get_class($this), E_USER_WARNING); - } - - // plugin introspection methods - // extract from class name, format = _plugin_[_] - function getPluginType() { list($t) = explode('_', get_class($this), 2); return $t; } - function getPluginName() { list($t, $p, $n) = explode('_', get_class($this), 4); return $n; } - function getPluginComponent() { list($t, $p, $n, $c) = explode('_', get_class($this), 4); return (isset($c)?$c:''); } - - // localisation methods - /** - * getLang($id) - * use this function to access plugin language strings - * to try to minimise unnecessary loading of the strings when the plugin doesn't require them - * e.g. when info plugin is querying plugins for information about themselves. - * - * @param $id id of the string to be retrieved - * @return string string in appropriate language or english if not available - */ - function getLang($id) { - if (!$this->localised) $this->setupLocale(); - - return (isset($this->lang[$id]) ? $this->lang[$id] : ''); - } - - /** - * locale_xhtml($id) - * - * retrieve a language dependent file and pass to xhtml renderer for display - * plugin equivalent of p_locale_xhtml() - * - * @param $id id of language dependent wiki page - * @return string parsed contents of the wiki page in xhtml format - */ - function locale_xhtml($id) { - return p_cached_output($this->localFN($id)); - } - - /** - * localFN($id) - * prepends appropriate path for a language dependent filename - * plugin equivalent of localFN() - */ - function localFN($id) { - global $conf; - $plugin = $this->getPluginName(); - $file = DOKU_PLUGIN.$plugin.'/lang/'.$conf['lang'].'/'.$id.'.txt'; - if(!@file_exists($file)){ - //fall back to english - $file = DOKU_PLUGIN.$plugin.'/lang/en/'.$id.'.txt'; - } - return $file; - } - - /** - * setupLocale() - * reads all the plugins language dependent strings into $this->lang - * this function is automatically called by getLang() - */ - function setupLocale() { - if ($this->localised) return; - - global $conf; // definitely don't invoke "global $lang" - $path = DOKU_PLUGIN.$this->getPluginName().'/lang/'; - - $lang = array(); - - // don't include once, in case several plugin components require the same language file - @include($path.'en/lang.php'); - if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php'); - - $this->lang = $lang; - $this->localised = true; - } - - // configuration methods - /** - * getConf($setting) - * - * use this function to access plugin configuration variables - */ - function getConf($setting){ - - if (!$this->configloaded){ $this->loadConfig(); } - - return $this->conf[$setting]; - } - - /** - * loadConfig() - * merges the plugin's default settings with any local settings - * this function is automatically called through getConf() - */ - function loadConfig(){ - global $conf; - - $defaults = $this->readDefaultSettings(); - $plugin = $this->getPluginName(); - - foreach ($defaults as $key => $value) { - if (isset($conf['plugin'][$plugin][$key])) continue; - $conf['plugin'][$plugin][$key] = $value; + /** + * General Info + * + * Needs to return a associative array with the following values: + * + * author - Author of the plugin + * email - Email address to contact the author + * date - Last modified date of the plugin in YYYY-MM-DD format + * name - Name of the plugin + * desc - Short description of the plugin (Text only) + * url - Website with more information on the plugin (eg. syntax description) + */ + function getInfo(){ + trigger_error('getInfo() not implemented in '.get_class($this), E_USER_WARNING); } - $this->configloaded = true; - $this->conf =& $conf['plugin'][$plugin]; - } - - /** - * read the plugin's default configuration settings from conf/default.php - * this function is automatically called through getConf() - * - * @return array setting => value - */ - function readDefaultSettings() { - - $path = DOKU_PLUGIN.$this->getPluginName().'/conf/'; - $conf = array(); - - if (@file_exists($path.'default.php')) { - include($path.'default.php'); + // plugin introspection methods + // extract from class name, format = _plugin_[_] + function getPluginType() { + list($t) = explode('_', get_class($this), 2); + return $t; + } + function getPluginName() { + list($t, $p, $n) = explode('_', get_class($this), 4); + return $n; + } + function getPluginComponent() { + list($t, $p, $n, $c) = explode('_', get_class($this), 4); + return (isset($c)?$c:''); } - return $conf; - } + // localisation methods + /** + * getLang($id) + * use this function to access plugin language strings + * to try to minimise unnecessary loading of the strings when the plugin doesn't require them + * e.g. when info plugin is querying plugins for information about themselves. + * + * @param $id id of the string to be retrieved + * @return string string in appropriate language or english if not available + */ + function getLang($id) { + if (!$this->localised) $this->setupLocale(); - /** - * Loads a given helper plugin (if enabled) - * - * @author Esther Brunner - * - * @param $name name of plugin to load - * @param $msg message to display in case the plugin is not available - * - * @return object helper plugin object - */ - function loadHelper($name, $msg){ - if (!plugin_isdisabled($name)) $obj =& plugin_load('helper',$name); - else $obj = NULL; - if (is_null($obj) && $msg) msg("Helper plugin $name is not available or invalid.",-1); - return $obj; - } + return (isset($this->lang[$id]) ? $this->lang[$id] : ''); + } - // standard functions for outputing email addresses and links - // use these to avoid having to duplicate code to produce links in line with the installation configuration + /** + * locale_xhtml($id) + * + * retrieve a language dependent file and pass to xhtml renderer for display + * plugin equivalent of p_locale_xhtml() + * + * @param $id id of language dependent wiki page + * @return string parsed contents of the wiki page in xhtml format + */ + function locale_xhtml($id) { + return p_cached_output($this->localFN($id)); + } - /** - * email - * standardised function to generate an email link according to obfuscation settings - */ - function email($email, $name='', $class='', $more='') { - if (!$email) return $name; - $email = obfuscate($email); - if (!$name) $name = $email; - $class = "class='".($class ? $class : 'mail')."'"; - return "$name"; - } + /** + * localFN($id) + * prepends appropriate path for a language dependent filename + * plugin equivalent of localFN() + */ + function localFN($id) { + global $conf; + $plugin = $this->getPluginName(); + $file = DOKU_PLUGIN.$plugin.'/lang/'.$conf['lang'].'/'.$id.'.txt'; + if(!@file_exists($file)){ + //fall back to english + $file = DOKU_PLUGIN.$plugin.'/lang/en/'.$id.'.txt'; + } + return $file; + } - /** - * external_link - * standardised function to generate an external link according to conf settings - */ - function external_link($link, $title='', $class='', $target='', $more='') { - global $conf; + /** + * setupLocale() + * reads all the plugins language dependent strings into $this->lang + * this function is automatically called by getLang() + */ + function setupLocale() { + if ($this->localised) return; - $link = htmlentities($link); - if (!$title) $title = $link; - if (!$target) $target = $conf['target']['extern']; - if ($conf['relnofollow']) $more .= ' rel="nofollow"'; + global $conf; // definitely don't invoke "global $lang" + $path = DOKU_PLUGIN.$this->getPluginName().'/lang/'; - if ($class) $class = " class='$class'"; - if ($target) $target = " target='$target'"; - if ($more) $more = " ".trim($more); + $lang = array(); - return "$title"; - } + // don't include once, in case several plugin components require the same language file + @include($path.'en/lang.php'); + if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php'); - /** - * output text string through the parser, allows dokuwiki markup to be used - * very ineffecient for small pieces of data - try not to use - */ - function render($text, $format='xhtml') { - return p_render($format, p_get_instructions($text),$info); - } + $this->lang = $lang; + $this->localised = true; + } - /** - * Allow the plugin to prevent DokuWiki creating a second instance of itself - * - * @return bool true if the plugin can not be instantiated more than once - */ - function isSingleton() { - return false; - } + // configuration methods + /** + * getConf($setting) + * + * use this function to access plugin configuration variables + */ + function getConf($setting){ - // deprecated functions - function plugin_localFN($id) { return $this->localFN($id); } - function plugin_locale_xhtml($id) { return $this->locale_xhtml($id); } - function plugin_email($e, $n='', $c='', $m='') { return $this->email($e, $n, $c, $m); } - function plugin_link($l, $t='', $c='', $to='', $m='') { return $this->external_link($l, $t, $c, $to, $m); } - function plugin_render($t, $f='xhtml') { return $this->render($t, $f); } + if (!$this->configloaded){ $this->loadConfig(); } + + return $this->conf[$setting]; + } + + /** + * loadConfig() + * merges the plugin's default settings with any local settings + * this function is automatically called through getConf() + */ + function loadConfig(){ + global $conf; + + $defaults = $this->readDefaultSettings(); + $plugin = $this->getPluginName(); + + foreach ($defaults as $key => $value) { + if (isset($conf['plugin'][$plugin][$key])) continue; + $conf['plugin'][$plugin][$key] = $value; + } + + $this->configloaded = true; + $this->conf =& $conf['plugin'][$plugin]; + } + + /** + * read the plugin's default configuration settings from conf/default.php + * this function is automatically called through getConf() + * + * @return array setting => value + */ + function readDefaultSettings() { + + $path = DOKU_PLUGIN.$this->getPluginName().'/conf/'; + $conf = array(); + + if (@file_exists($path.'default.php')) { + include($path.'default.php'); + } + + return $conf; + } + + /** + * Loads a given helper plugin (if enabled) + * + * @author Esther Brunner + * + * @param $name name of plugin to load + * @param $msg message to display in case the plugin is not available + * + * @return object helper plugin object + */ + function loadHelper($name, $msg){ + if (!plugin_isdisabled($name)){ + $obj =& plugin_load('helper',$name); + }else{ + $obj = null; + } + if (is_null($obj) && $msg) msg("Helper plugin $name is not available or invalid.",-1); + return $obj; + } + + // standard functions for outputing email addresses and links + // use these to avoid having to duplicate code to produce links in line with the installation configuration + + /** + * email + * standardised function to generate an email link according to obfuscation settings + */ + function email($email, $name='', $class='', $more='') { + if (!$email) return $name; + $email = obfuscate($email); + if (!$name) $name = $email; + $class = "class='".($class ? $class : 'mail')."'"; + return "$name"; + } + + /** + * external_link + * standardised function to generate an external link according to conf settings + */ + function external_link($link, $title='', $class='', $target='', $more='') { + global $conf; + + $link = htmlentities($link); + if (!$title) $title = $link; + if (!$target) $target = $conf['target']['extern']; + if ($conf['relnofollow']) $more .= ' rel="nofollow"'; + + if ($class) $class = " class='$class'"; + if ($target) $target = " target='$target'"; + if ($more) $more = " ".trim($more); + + return "$title"; + } + + /** + * output text string through the parser, allows dokuwiki markup to be used + * very ineffecient for small pieces of data - try not to use + */ + function render($text, $format='xhtml') { + return p_render($format, p_get_instructions($text),$info); + } + + /** + * Allow the plugin to prevent DokuWiki creating a second instance of itself + * + * @return bool true if the plugin can not be instantiated more than once + */ + function isSingleton() { + return false; + } + + // deprecated functions + function plugin_localFN($id) { return $this->localFN($id); } + function plugin_locale_xhtml($id) { return $this->locale_xhtml($id); } + function plugin_email($e, $n='', $c='', $m='') { return $this->email($e, $n, $c, $m); } + function plugin_link($l, $t='', $c='', $to='', $m='') { return $this->external_link($l, $t, $c, $to, $m); } + function plugin_render($t, $f='xhtml') { return $this->render($t, $f); } } diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index 707d90856..4400a4187 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -11,162 +11,162 @@ if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); class Doku_Plugin_Controller { - var $list_enabled = array(); - var $list_disabled = array(); - var $list_bytype = array(); + var $list_enabled = array(); + var $list_disabled = array(); + var $list_bytype = array(); - function Doku_Plugin_Controller() { - $this->_populateMasterList(); - } - - /** - * Returns a list of available plugins of given type - * - * @param $type string, plugin_type name; - * the type of plugin to return, - * use empty string for all types - * @param $all bool; - * false to only return enabled plugins, - * true to return both enabled and disabled plugins - * - * @return array of plugin names - * - * @author Andreas Gohr - */ - function getList($type='',$all=false){ - - // request the complete list - if (!$type) { - return $all ? array_merge($this->list_enabled,$this->list_disabled) : $this->list_enabled; + function Doku_Plugin_Controller() { + $this->_populateMasterList(); } - if (!isset($this->list_bytype[$type]['enabled'])) { - $this->list_bytype[$type]['enabled'] = $this->_getListByType($type,true); - } - if ($all && !isset($this->list_bytype[$type]['disabled'])) { - $this->list_bytype[$type]['disabled'] = $this->_getListByType($type,false); - } + /** + * Returns a list of available plugins of given type + * + * @param $type string, plugin_type name; + * the type of plugin to return, + * use empty string for all types + * @param $all bool; + * false to only return enabled plugins, + * true to return both enabled and disabled plugins + * + * @return array of plugin names + * + * @author Andreas Gohr + */ + function getList($type='',$all=false){ - return $all ? array_merge($this->list_bytype[$type]['enabled'],$this->list_bytype[$type]['disabled']) : $this->list_bytype[$type]['enabled']; - } - - /** - * Loads the given plugin and creates an object of it - * - * @author Andreas Gohr - * - * @param $type string type of plugin to load - * @param $name string name of the plugin to load - * @param $new bool true to return a new instance of the plugin, false to use an already loaded instance - * @return objectreference the plugin object or null on failure - */ - function &load($type,$name,$new=false){ - //we keep all loaded plugins available in global scope for reuse - global $DOKU_PLUGINS; - - //plugin already loaded? - if(!empty($DOKU_PLUGINS[$type][$name])){ - if ($new && !$DOKU_PLUGINS[$type][$name]->isSingleton()) { - $class = $type.'_plugin_'.$name; - return class_exists($class) ? new $class : null; - } else { - return $DOKU_PLUGINS[$type][$name]; - } - } - - //try to load the wanted plugin file - list($plugin,$component) = $this->_splitName($name); - $dir = $this->get_directory($plugin); - $file = $component ? "$type/$component.php" : "$type.php"; - - if(!is_file(DOKU_PLUGIN."$dir/$file")){ - return null; - } - - if (!include_once(DOKU_PLUGIN."$dir/$file")) { - return null; - } - - //construct class and instantiate - $class = $type.'_plugin_'.$name; - if (!class_exists($class)) return null; - - $DOKU_PLUGINS[$type][$name] = new $class; - return $DOKU_PLUGINS[$type][$name]; - } - - function isdisabled($plugin) { - return (array_search($plugin, $this->list_enabled) === false); - } - - function enable($plugin) { - if (array_search($plugin, $this->list_disabled) !== false) { - return @unlink(DOKU_PLUGIN.$plugin.'/disabled'); - } - return false; - } - - function disable($plugin) { - if (array_search($plugin, $this->list_enabled) !== false) { - return @touch(DOKU_PLUGIN.$plugin.'/disabled'); - } - return false; - } - - function get_directory($plugin) { - return $plugin; - } - - function _populateMasterList() { - if ($dh = opendir(DOKU_PLUGIN)) { - while (false !== ($plugin = readdir($dh))) { - if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp') continue; - if (is_file(DOKU_PLUGIN.$plugin)) continue; - - if (substr($plugin,-9) == '.disabled') { - // the plugin was disabled by rc2009-01-26 - // disabling mechanism was changed back very soon again - // to keep everything simple we just skip the plugin completely - }elseif(@file_exists(DOKU_PLUGIN.$plugin.'/disabled')){ - $this->list_disabled[] = $plugin; - } else { - $this->list_enabled[] = $plugin; + // request the complete list + if (!$type) { + return $all ? array_merge($this->list_enabled,$this->list_disabled) : $this->list_enabled; } - } + + if (!isset($this->list_bytype[$type]['enabled'])) { + $this->list_bytype[$type]['enabled'] = $this->_getListByType($type,true); + } + if ($all && !isset($this->list_bytype[$type]['disabled'])) { + $this->list_bytype[$type]['disabled'] = $this->_getListByType($type,false); + } + + return $all ? array_merge($this->list_bytype[$type]['enabled'],$this->list_bytype[$type]['disabled']) : $this->list_bytype[$type]['enabled']; } - } - function _getListByType($type, $enabled) { - $master_list = $enabled ? $this->list_enabled : $this->list_disabled; + /** + * Loads the given plugin and creates an object of it + * + * @author Andreas Gohr + * + * @param $type string type of plugin to load + * @param $name string name of the plugin to load + * @param $new bool true to return a new instance of the plugin, false to use an already loaded instance + * @return objectreference the plugin object or null on failure + */ + function &load($type,$name,$new=false){ + //we keep all loaded plugins available in global scope for reuse + global $DOKU_PLUGINS; - $plugins = array(); - foreach ($master_list as $plugin) { - $dir = $this->get_directory($plugin); - - if (@file_exists(DOKU_PLUGIN."$dir/$type.php")){ - $plugins[] = $plugin; - } else { - if ($dp = @opendir(DOKU_PLUGIN."$dir/$type/")) { - while (false !== ($component = readdir($dp))) { - if (substr($component,0,1) == '.' || strtolower(substr($component, -4)) != ".php") continue; - if (is_file(DOKU_PLUGIN."$dir/$type/$component")) { - $plugins[] = $plugin.'_'.substr($component, 0, -4); + //plugin already loaded? + if(!empty($DOKU_PLUGINS[$type][$name])){ + if ($new && !$DOKU_PLUGINS[$type][$name]->isSingleton()) { + $class = $type.'_plugin_'.$name; + return class_exists($class) ? new $class : null; + } else { + return $DOKU_PLUGINS[$type][$name]; } - } - closedir($dp); } - } + + //try to load the wanted plugin file + list($plugin,$component) = $this->_splitName($name); + $dir = $this->get_directory($plugin); + $file = $component ? "$type/$component.php" : "$type.php"; + + if(!is_file(DOKU_PLUGIN."$dir/$file")){ + return null; + } + + if (!include_once(DOKU_PLUGIN."$dir/$file")) { + return null; + } + + //construct class and instantiate + $class = $type.'_plugin_'.$name; + if (!class_exists($class)) return null; + + $DOKU_PLUGINS[$type][$name] = new $class; + return $DOKU_PLUGINS[$type][$name]; } - return $plugins; - } - - function _splitName($name) { - if (array_search($name, $this->list_enabled + $this->list_disabled) === false) { - return explode('_',$name,2); + function isdisabled($plugin) { + return (array_search($plugin, $this->list_enabled) === false); } - return array($name,''); - } + function enable($plugin) { + if (array_search($plugin, $this->list_disabled) !== false) { + return @unlink(DOKU_PLUGIN.$plugin.'/disabled'); + } + return false; + } + + function disable($plugin) { + if (array_search($plugin, $this->list_enabled) !== false) { + return @touch(DOKU_PLUGIN.$plugin.'/disabled'); + } + return false; + } + + function get_directory($plugin) { + return $plugin; + } + + function _populateMasterList() { + if ($dh = opendir(DOKU_PLUGIN)) { + while (false !== ($plugin = readdir($dh))) { + if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp') continue; + if (is_file(DOKU_PLUGIN.$plugin)) continue; + + if (substr($plugin,-9) == '.disabled') { + // the plugin was disabled by rc2009-01-26 + // disabling mechanism was changed back very soon again + // to keep everything simple we just skip the plugin completely + }elseif(@file_exists(DOKU_PLUGIN.$plugin.'/disabled')){ + $this->list_disabled[] = $plugin; + } else { + $this->list_enabled[] = $plugin; + } + } + } + } + + function _getListByType($type, $enabled) { + $master_list = $enabled ? $this->list_enabled : $this->list_disabled; + + $plugins = array(); + foreach ($master_list as $plugin) { + $dir = $this->get_directory($plugin); + + if (@file_exists(DOKU_PLUGIN."$dir/$type.php")){ + $plugins[] = $plugin; + } else { + if ($dp = @opendir(DOKU_PLUGIN."$dir/$type/")) { + while (false !== ($component = readdir($dp))) { + if (substr($component,0,1) == '.' || strtolower(substr($component, -4)) != ".php") continue; + if (is_file(DOKU_PLUGIN."$dir/$type/$component")) { + $plugins[] = $plugin.'_'.substr($component, 0, -4); + } + } + closedir($dp); + } + } + } + + return $plugins; + } + + function _splitName($name) { + if (array_search($name, $this->list_enabled + $this->list_disabled) === false) { + return explode('_',$name,2); + } + + return array($name,''); + } } diff --git a/inc/pluginutils.php b/inc/pluginutils.php index db152195d..8294d1ec8 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -20,10 +20,28 @@ $plugin_controller = new $plugin_controller_class(); /** * Original plugin functions, remain for backwards compatibility */ -function plugin_list($type='',$all=false) { global $plugin_controller; return $plugin_controller->getList($type,$all); } -function &plugin_load($type,$name,$new=false) { global $plugin_controller; return $plugin_controller->load($type,$name,$new); } -function plugin_isdisabled($plugin) { global $plugin_controller; return $plugin_controller->isdisabled($plugin); } -function plugin_enable($plugin) { global $plugin_controller; return $plugin_controller->enable($plugin); } -function plugin_disable($plugin) { global $plugin_controller; return $plugin_controller->disable($plugin); } -function plugin_directory($plugin) { global $plugin_controller; return $plugin_controller->get_directory($plugin); } +function plugin_list($type='',$all=false) { + global $plugin_controller; + return $plugin_controller->getList($type,$all); +} +function &plugin_load($type,$name,$new=false) { + global $plugin_controller; + return $plugin_controller->load($type,$name,$new); +} +function plugin_isdisabled($plugin) { + global $plugin_controller; + return $plugin_controller->isdisabled($plugin); +} +function plugin_enable($plugin) { + global $plugin_controller; + return $plugin_controller->enable($plugin); +} +function plugin_disable($plugin) { + global $plugin_controller; + return $plugin_controller->disable($plugin); +} +function plugin_directory($plugin) { + global $plugin_controller; + return $plugin_controller->get_directory($plugin); +} diff --git a/inc/search.php b/inc/search.php index e29f977ad..547e15bca 100644 --- a/inc/search.php +++ b/inc/search.php @@ -23,34 +23,34 @@ require_once(DOKU_INC.'inc/common.php'); * @author Andreas Gohr */ function search(&$data,$base,$func,$opts,$dir='',$lvl=1){ - $dirs = array(); - $files = array(); + $dirs = array(); + $files = array(); - //read in directories and files - $dh = @opendir($base.'/'.$dir); - if(!$dh) return; - while(($file = readdir($dh)) !== false){ - if(preg_match('/^[\._]/',$file)) continue; //skip hidden files and upper dirs - if(is_dir($base.'/'.$dir.'/'.$file)){ - $dirs[] = $dir.'/'.$file; - continue; + //read in directories and files + $dh = @opendir($base.'/'.$dir); + if(!$dh) return; + while(($file = readdir($dh)) !== false){ + if(preg_match('/^[\._]/',$file)) continue; //skip hidden files and upper dirs + if(is_dir($base.'/'.$dir.'/'.$file)){ + $dirs[] = $dir.'/'.$file; + continue; + } + $files[] = $dir.'/'.$file; } - $files[] = $dir.'/'.$file; - } - closedir($dh); - sort($files); - sort($dirs); + closedir($dh); + sort($files); + sort($dirs); - //give directories to userfunction then recurse - foreach($dirs as $dir){ - if (call_user_func_array($func, array(&$data,$base,$dir,'d',$lvl,$opts))){ - search($data,$base,$func,$opts,$dir,$lvl+1); + //give directories to userfunction then recurse + foreach($dirs as $dir){ + if (call_user_func_array($func, array(&$data,$base,$dir,'d',$lvl,$opts))){ + search($data,$base,$func,$opts,$dir,$lvl+1); + } + } + //now handle the files + foreach($files as $file){ + call_user_func_array($func, array(&$data,$base,$file,'f',$lvl,$opts)); } - } - //now handle the files - foreach($files as $file){ - call_user_func_array($func, array(&$data,$base,$file,'f',$lvl,$opts)); - } } /** @@ -59,7 +59,7 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1){ * @deprecated */ function search_callback($func,&$data,$base,$file,$type,$lvl,$opts){ - return call_user_func_array($func, array(&$data,$base,$file,$type,$lvl,$opts)); + return call_user_func_array($func, array(&$data,$base,$file,$type,$lvl,$opts)); } /** @@ -92,10 +92,10 @@ function search_callback($func,&$data,$base,$file,$type,$lvl,$opts){ */ function search_qsearch(&$data,$base,$file,$type,$lvl,$opts){ $opts = array( - 'idmatch' => '(^|:)'.preg_quote($opts['query'],'/').'/', - 'listfiles' => true, - 'pagesonly' => true, - ); + 'idmatch' => '(^|:)'.preg_quote($opts['query'],'/').'/', + 'listfiles' => true, + 'pagesonly' => true, + ); return search_universal($data,$base,$file,$type,$lvl,$opts); } @@ -107,40 +107,40 @@ function search_qsearch(&$data,$base,$file,$type,$lvl,$opts){ * @author Andreas Gohr */ function search_index(&$data,$base,$file,$type,$lvl,$opts){ - global $conf; - $return = true; + global $conf; + $return = true; - $item = array(); + $item = array(); - if($type == 'd' && !preg_match('#^'.$file.'(/|$)#','/'.$opts['ns'])){ - //add but don't recurse - $return = false; - }elseif($type == 'f' && ($opts['nofiles'] || substr($file,-4) != '.txt')){ - //don't add - return false; - } + if($type == 'd' && !preg_match('#^'.$file.'(/|$)#','/'.$opts['ns'])){ + //add but don't recurse + $return = false; + }elseif($type == 'f' && ($opts['nofiles'] || substr($file,-4) != '.txt')){ + //don't add + return false; + } - $id = pathID($file); + $id = pathID($file); - if($type=='d' && $conf['sneaky_index'] && auth_quickaclcheck($id.':') < AUTH_READ){ - return false; - } + if($type=='d' && $conf['sneaky_index'] && auth_quickaclcheck($id.':') < AUTH_READ){ + return false; + } - //check hidden - if(isHiddenPage($id)){ - return false; - } + //check hidden + if(isHiddenPage($id)){ + return false; + } - //check ACL - if($type=='f' && auth_quickaclcheck($id) < AUTH_READ){ - return false; - } + //check ACL + if($type=='f' && auth_quickaclcheck($id) < AUTH_READ){ + return false; + } - $data[]=array( 'id' => $id, - 'type' => $type, - 'level' => $lvl, - 'open' => $return ); - return $return; + $data[]=array( 'id' => $id, + 'type' => $type, + 'level' => $lvl, + 'open' => $return ); + return $return; } /** @@ -150,8 +150,8 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){ */ function search_namespaces(&$data,$base,$file,$type,$lvl,$opts){ $opts = array( - 'listdirs' => true, - ); + 'listdirs' => true, + ); return search_universal($data,$base,$file,$type,$lvl,$opts); } @@ -215,18 +215,18 @@ function search_media(&$data,$base,$file,$type,$lvl,$opts){ * @author Andreas Gohr */ function search_list(&$data,$base,$file,$type,$lvl,$opts){ - //we do nothing with directories - if($type == 'd') return false; - //only search txt files - if(substr($file,-4) == '.txt'){ - //check ACL - $id = pathID($file); - if(auth_quickaclcheck($id) < AUTH_READ){ - return false; + //we do nothing with directories + if($type == 'd') return false; + //only search txt files + if(substr($file,-4) == '.txt'){ + //check ACL + $id = pathID($file); + if(auth_quickaclcheck($id) < AUTH_READ){ + return false; + } + $data[]['id'] = $id; } - $data[]['id'] = $id; - } - return false; + return false; } /** @@ -237,23 +237,23 @@ function search_list(&$data,$base,$file,$type,$lvl,$opts){ * @author Andreas Gohr */ function search_pagename(&$data,$base,$file,$type,$lvl,$opts){ - //we do nothing with directories - if($type == 'd') return true; - //only search txt files - if(substr($file,-4) != '.txt') return true; + //we do nothing with directories + if($type == 'd') return true; + //only search txt files + if(substr($file,-4) != '.txt') return true; - //simple stringmatching - if (!empty($opts['query'])){ - if(strpos($file,$opts['query']) !== false){ - //check ACL - $id = pathID($file); - if(auth_quickaclcheck($id) < AUTH_READ){ - return false; - } - $data[]['id'] = $id; + //simple stringmatching + if (!empty($opts['query'])){ + if(strpos($file,$opts['query']) !== false){ + //check ACL + $id = pathID($file); + if(auth_quickaclcheck($id) < AUTH_READ){ + return false; + } + $data[]['id'] = $id; + } } - } - return true; + return true; } /** @@ -279,7 +279,7 @@ function search_allpages(&$data,$base,$file,$type,$lvl,$opts){ $item['id'] = pathID($file); if(!$opts['skipacl'] && auth_quickaclcheck($item['id']) < AUTH_READ){ - return false; + return false; } $item['rev'] = filemtime($base.'/'.$file); @@ -303,42 +303,42 @@ function search_allpages(&$data,$base,$file,$type,$lvl,$opts){ * @deprecated Replaced by ft_backlinks() */ function search_backlinks(&$data,$base,$file,$type,$lvl,$opts){ - //we do nothing with directories - if($type == 'd') return true; - //only search txt files - if(substr($file,-4) != '.txt') return true; + //we do nothing with directories + if($type == 'd') return true; + //only search txt files + if(substr($file,-4) != '.txt') return true; - //absolute search id - $sid = cleanID($opts['ns'].':'.$opts['name']); + //absolute search id + $sid = cleanID($opts['ns'].':'.$opts['name']); - //current id and namespace - $cid = pathID($file); - $cns = getNS($cid); + //current id and namespace + $cid = pathID($file); + $cns = getNS($cid); - //check ACL - if(auth_quickaclcheck($cid) < AUTH_READ){ - return false; - } - - //fetch instructions - require_once(DOKU_INC.'inc/parserutils.php'); - $instructions = p_cached_instructions($base.$file,true); - if(is_null($instructions)) return false; - - //check all links for match - foreach($instructions as $ins){ - if($ins[0] == 'internallink' || ($conf['camelcase'] && $ins[0] == 'camelcaselink') ){ - $mid = $ins[1][0]; - resolve_pageid($cns,$mid,$exists); //exists is not used - if($mid == $sid){ - //we have a match - finish - $data[]['id'] = $cid; - break; - } + //check ACL + if(auth_quickaclcheck($cid) < AUTH_READ){ + return false; } - } - return false; + //fetch instructions + require_once(DOKU_INC.'inc/parserutils.php'); + $instructions = p_cached_instructions($base.$file,true); + if(is_null($instructions)) return false; + + //check all links for match + foreach($instructions as $ins){ + if($ins[0] == 'internallink' || ($conf['camelcase'] && $ins[0] == 'camelcaselink') ){ + $mid = $ins[1][0]; + resolve_pageid($cns,$mid,$exists); //exists is not used + if($mid == $sid){ + //we have a match - finish + $data[]['id'] = $cid; + break; + } + } + } + + return false; } /** @@ -350,86 +350,86 @@ function search_backlinks(&$data,$base,$file,$type,$lvl,$opts){ * @deprecated - fulltext indexer is used instead */ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){ - //we do nothing with directories - if($type == 'd') return true; - //only search txt files - if(substr($file,-4) != '.txt') return true; + //we do nothing with directories + if($type == 'd') return true; + //only search txt files + if(substr($file,-4) != '.txt') return true; - //check ACL - $id = pathID($file); - if(auth_quickaclcheck($id) < AUTH_READ){ - return false; - } - - //create regexp from queries - $poswords = array(); - $negwords = array(); - $qpreg = preg_split('/\s+/',$opts['query']); - - foreach($qpreg as $word){ - switch(substr($word,0,1)){ - case '-': - if(strlen($word) > 1){ // catch single '-' - array_push($negwords,preg_quote(substr($word,1),'#')); - } - break; - case '+': - if(strlen($word) > 1){ // catch single '+' - array_push($poswords,preg_quote(substr($word,1),'#')); - } - break; - default: - array_push($poswords,preg_quote($word,'#')); - break; + //check ACL + $id = pathID($file); + if(auth_quickaclcheck($id) < AUTH_READ){ + return false; } - } - // a search without any posword is useless - if (!count($poswords)) return true; + //create regexp from queries + $poswords = array(); + $negwords = array(); + $qpreg = preg_split('/\s+/',$opts['query']); - $reg = '^(?=.*?'.join(')(?=.*?',$poswords).')'; - $reg .= count($negwords) ? '((?!'.join('|',$negwords).').)*$' : '.*$'; - search_regex($data,$base,$file,$reg,$poswords); - return true; -} + foreach($qpreg as $word){ + switch(substr($word,0,1)){ + case '-': + if(strlen($word) > 1){ // catch single '-' + array_push($negwords,preg_quote(substr($word,1),'#')); + } + break; + case '+': + if(strlen($word) > 1){ // catch single '+' + array_push($poswords,preg_quote(substr($word,1),'#')); + } + break; + default: + array_push($poswords,preg_quote($word,'#')); + break; + } + } -/** - * Reference search - * This fuction searches for existing references to a given media file - * and returns an array with the found pages. It doesn't pay any - * attention to ACL permissions to find every reference. The caller - * must check if the user has the appropriate rights to see the found - * page and eventually have to prevent the result from displaying. - * - * @param array $data Reference to the result data structure - * @param string $base Base usually $conf['datadir'] - * @param string $file current file or directory relative to $base - * @param char $type Type either 'd' for directory or 'f' for file - * @param int $lvl Current recursion depht - * @param mixed $opts option array as given to search() - * - * $opts['query'] is the demanded media file name - * - * @author Andreas Gohr - * @author Matthias Grimm - */ + // a search without any posword is useless + if (!count($poswords)) return true; + + $reg = '^(?=.*?'.join(')(?=.*?',$poswords).')'; + $reg .= count($negwords) ? '((?!'.join('|',$negwords).').)*$' : '.*$'; + search_regex($data,$base,$file,$reg,$poswords); + return true; + } + + /** + * Reference search + * This fuction searches for existing references to a given media file + * and returns an array with the found pages. It doesn't pay any + * attention to ACL permissions to find every reference. The caller + * must check if the user has the appropriate rights to see the found + * page and eventually have to prevent the result from displaying. + * + * @param array $data Reference to the result data structure + * @param string $base Base usually $conf['datadir'] + * @param string $file current file or directory relative to $base + * @param char $type Type either 'd' for directory or 'f' for file + * @param int $lvl Current recursion depht + * @param mixed $opts option array as given to search() + * + * $opts['query'] is the demanded media file name + * + * @author Andreas Gohr + * @author Matthias Grimm + */ function search_reference(&$data,$base,$file,$type,$lvl,$opts){ - global $conf; + global $conf; - //we do nothing with directories - if($type == 'd') return true; + //we do nothing with directories + if($type == 'd') return true; - //only search txt files - if(substr($file,-4) != '.txt') return true; + //only search txt files + if(substr($file,-4) != '.txt') return true; - //we finish after 'cnt' references found. The return value - //'false' will skip subdirectories to speed search up. - $cnt = $conf['refshow'] > 0 ? $conf['refshow'] : 1; - if(count($data) >= $cnt) return false; + //we finish after 'cnt' references found. The return value + //'false' will skip subdirectories to speed search up. + $cnt = $conf['refshow'] > 0 ? $conf['refshow'] : 1; + if(count($data) >= $cnt) return false; - $reg = '\{\{ *\:?'.$opts['query'].' *(\|.*)?\}\}'; - search_regex($data,$base,$file,$reg,array($opts['query'])); - return true; + $reg = '\{\{ *\:?'.$opts['query'].' *(\|.*)?\}\}'; + search_regex($data,$base,$file,$reg,array($opts['query'])); + return true; } /* ------------- helper functions below -------------- */ @@ -453,35 +453,35 @@ function search_reference(&$data,$base,$file,$type,$lvl,$opts){ */ function search_regex(&$data,$base,$file,$reg,$words){ - //get text - $text = io_readfile($base.'/'.$file); - //lowercase text (u modifier does not help with case) - $lctext = utf8_strtolower($text); + //get text + $text = io_readfile($base.'/'.$file); + //lowercase text (u modifier does not help with case) + $lctext = utf8_strtolower($text); - //do the fulltext search - $matches = array(); - if($cnt = preg_match_all('#'.$reg.'#usi',$lctext,$matches)){ - //this is not the best way for snippet generation but the fastest I could find - $q = $words[0]; //use first word for snippet creation - $p = utf8_strpos($lctext,$q); - $f = $p - 100; - $l = utf8_strlen($q) + 200; - if($f < 0) $f = 0; - $snippet = ' ... '. - htmlspecialchars(utf8_substr($text,$f,$l)). - ' ... '; - $mark = '('.join('|', $words).')'; - $snippet = preg_replace('#'.$mark.'#si','\\1',$snippet); + //do the fulltext search + $matches = array(); + if($cnt = preg_match_all('#'.$reg.'#usi',$lctext,$matches)){ + //this is not the best way for snippet generation but the fastest I could find + $q = $words[0]; //use first word for snippet creation + $p = utf8_strpos($lctext,$q); + $f = $p - 100; + $l = utf8_strlen($q) + 200; + if($f < 0) $f = 0; + $snippet = ' ... '. + htmlspecialchars(utf8_substr($text,$f,$l)). + ' ... '; + $mark = '('.join('|', $words).')'; + $snippet = preg_replace('#'.$mark.'#si','\\1',$snippet); - $data[] = array( - 'id' => pathID($file), - 'count' => preg_match_all('#'.$mark.'#usi',$lctext,$matches), - 'poswords' => join(' ',$words), - 'snippet' => $snippet, - ); - } + $data[] = array( + 'id' => pathID($file), + 'count' => preg_match_all('#'.$mark.'#usi',$lctext,$matches), + 'poswords' => join(' ',$words), + 'snippet' => $snippet, + ); + } - return true; + return true; } @@ -494,13 +494,13 @@ function search_regex(&$data,$base,$file,$reg,$words){ * @author Andreas Gohr */ function sort_search_fulltext($a,$b){ - if($a['count'] > $b['count']){ - return -1; - }elseif($a['count'] < $b['count']){ - return 1; - }else{ - return strcmp($a['id'],$b['id']); - } + if($a['count'] > $b['count']){ + return -1; + }elseif($a['count'] < $b['count']){ + return 1; + }else{ + return strcmp($a['id'],$b['id']); + } } /** @@ -510,12 +510,12 @@ function sort_search_fulltext($a,$b){ * @todo move to pageutils */ function pathID($path,$keeptxt=false){ - $id = utf8_decodeFN($path); - $id = str_replace('/',':',$id); - if(!$keeptxt) $id = preg_replace('#\.txt$#','',$id); - $id = preg_replace('#^:+#','',$id); - $id = preg_replace('#:+$#','',$id); - return $id; + $id = utf8_decodeFN($path); + $id = str_replace('/',':',$id); + if(!$keeptxt) $id = preg_replace('#\.txt$#','',$id); + $id = preg_replace('#^:+#','',$id); + $id = preg_replace('#:+$#','',$id); + return $id; } diff --git a/inc/toolbar.php b/inc/toolbar.php index 701723b58..66945cbc4 100644 --- a/inc/toolbar.php +++ b/inc/toolbar.php @@ -13,7 +13,7 @@ require_once(DOKU_INC.'inc/JSON.php'); /** * Prepares and prints an JavaScript array with all toolbar buttons * - * @todo add toolbar plugins + * @emits TOOLBAR_DEFINE * @param string $varname Name of the JS variable to fill * @author Andreas Gohr */ @@ -209,9 +209,6 @@ function toolbar_JSdefines($varname){ 'icon' => 'sig.png', 'key' => 'y', ), - - - )); } // end event TOOLBAR_DEFINE default action $evt->advise_after(); @@ -228,17 +225,17 @@ function toolbar_JSdefines($varname){ * @author Andreas Gohr */ function toolbar_signature(){ - global $conf; - global $INFO; + global $conf; + global $INFO; - $sig = $conf['signature']; - $sig = strftime($sig); - $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig); - $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig); - $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig); - $sig = str_replace('@DATE@',dformat(),$sig); - $sig = str_replace('\\\\n','\\n',addslashes($sig)); - return $sig; + $sig = $conf['signature']; + $sig = strftime($sig); + $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig); + $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig); + $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig); + $sig = str_replace('@DATE@',dformat(),$sig); + $sig = str_replace('\\\\n','\\n',addslashes($sig)); + return $sig; } //Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/inc/utf8.php b/inc/utf8.php index a438783f7..b078540d2 100644 --- a/inc/utf8.php +++ b/inc/utf8.php @@ -10,11 +10,11 @@ * check for mb_string support */ if(!defined('UTF8_MBSTRING')){ - if(function_exists('mb_substr') && !defined('UTF8_NOMBSTRING')){ - define('UTF8_MBSTRING',1); - }else{ - define('UTF8_MBSTRING',0); - } + if(function_exists('mb_substr') && !defined('UTF8_NOMBSTRING')){ + define('UTF8_MBSTRING',1); + }else{ + define('UTF8_MBSTRING',0); + } } if(UTF8_MBSTRING){ mb_internal_encoding('UTF-8'); } @@ -34,12 +34,12 @@ if(!function_exists('utf8_encodeFN')){ * @see urlencode */ function utf8_encodeFN($file,$safe=true){ - if($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){ + if($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){ + return $file; + } + $file = urlencode($file); + $file = str_replace('%2F','/',$file); return $file; - } - $file = urlencode($file); - $file = str_replace('%2F','/',$file); - return $file; } } @@ -184,53 +184,53 @@ if(!function_exists('utf8_substr')){ // normalise -ve offsets (we could use a tail anchored pattern, but they are horribly slow!) if ($offset < 0) { - $strlen = strlen(utf8_decode($str)); // see notes - $offset = $strlen + $offset; - if ($offset < 0) $offset = 0; + $strlen = strlen(utf8_decode($str)); // see notes + $offset = $strlen + $offset; + if ($offset < 0) $offset = 0; } // establish a pattern for offset, a non-captured group equal in length to offset if ($offset > 0) { - $Ox = (int)($offset/65535); - $Oy = $offset%65535; + $Ox = (int)($offset/65535); + $Oy = $offset%65535; - if ($Ox) $offset_pattern = '(?:.{65535}){'.$Ox.'}'; - $offset_pattern = '^(?:'.$offset_pattern.'.{'.$Oy.'})'; + if ($Ox) $offset_pattern = '(?:.{65535}){'.$Ox.'}'; + $offset_pattern = '^(?:'.$offset_pattern.'.{'.$Oy.'})'; } else { - $offset_pattern = '^'; // offset == 0; just anchor the pattern + $offset_pattern = '^'; // offset == 0; just anchor the pattern } // establish a pattern for length if (is_null($length)) { - $length_pattern = '(.*)$'; // the rest of the string + $length_pattern = '(.*)$'; // the rest of the string } else { - if (!isset($strlen)) $strlen = strlen(utf8_decode($str)); // see notes - if ($offset > $strlen) return ''; // another trivial case + if (!isset($strlen)) $strlen = strlen(utf8_decode($str)); // see notes + if ($offset > $strlen) return ''; // another trivial case - if ($length > 0) { + if ($length > 0) { - $length = min($strlen-$offset, $length); // reduce any length that would go passed the end of the string + $length = min($strlen-$offset, $length); // reduce any length that would go passed the end of the string - $Lx = (int)($length/65535); - $Ly = $length%65535; + $Lx = (int)($length/65535); + $Ly = $length%65535; - // +ve length requires ... a captured group of length characters - if ($Lx) $length_pattern = '(?:.{65535}){'.$Lx.'}'; - $length_pattern = '('.$length_pattern.'.{'.$Ly.'})'; + // +ve length requires ... a captured group of length characters + if ($Lx) $length_pattern = '(?:.{65535}){'.$Lx.'}'; + $length_pattern = '('.$length_pattern.'.{'.$Ly.'})'; - } else if ($length < 0) { + } else if ($length < 0) { - if ($length < ($offset - $strlen)) return ''; + if ($length < ($offset - $strlen)) return ''; - $Lx = (int)((-$length)/65535); - $Ly = (-$length)%65535; + $Lx = (int)((-$length)/65535); + $Ly = (-$length)%65535; - // -ve length requires ... capture everything except a group of -length characters - // anchored at the tail-end of the string - if ($Lx) $length_pattern = '(?:.{65535}){'.$Lx.'}'; - $length_pattern = '(.*)(?:'.$length_pattern.'.{'.$Ly.'})$'; - } + // -ve length requires ... capture everything except a group of -length characters + // anchored at the tail-end of the string + if ($Lx) $length_pattern = '(?:.{65535}){'.$Lx.'}'; + $length_pattern = '(.*)(?:'.$length_pattern.'.{'.$Ly.'})$'; + } } if (!preg_match('#'.$offset_pattern.$length_pattern.'#us',$str,$match)) return ''; @@ -246,11 +246,11 @@ if(!function_exists('utf8_substr_replace')){ * @see substr_replace() */ function utf8_substr_replace($string, $replacement, $start , $length=0 ){ - $ret = ''; - if($start>0) $ret .= utf8_substr($string, 0, $start); - $ret .= $replacement; - $ret .= utf8_substr($string, $start+$length); - return $ret; + $ret = ''; + if($start>0) $ret .= utf8_substr($string, 0, $start); + $ret .= $replacement; + $ret .= utf8_substr($string, $start+$length); + return $ret; } } @@ -263,12 +263,12 @@ if(!function_exists('utf8_ltrim')){ * @return string */ function utf8_ltrim($str,$charlist=''){ - if($charlist == '') return ltrim($str); + if($charlist == '') return ltrim($str); - //quote charlist for use in a characterclass - $charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist); + //quote charlist for use in a characterclass + $charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist); - return preg_replace('/^['.$charlist.']+/u','',$str); + return preg_replace('/^['.$charlist.']+/u','',$str); } } @@ -281,12 +281,12 @@ if(!function_exists('utf8_rtrim')){ * @return string */ function utf8_rtrim($str,$charlist=''){ - if($charlist == '') return rtrim($str); + if($charlist == '') return rtrim($str); - //quote charlist for use in a characterclass - $charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist); + //quote charlist for use in a characterclass + $charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist); - return preg_replace('/['.$charlist.']+$/u','',$str); + return preg_replace('/['.$charlist.']+$/u','',$str); } } @@ -299,9 +299,9 @@ if(!function_exists('utf8_trim')){ * @return string */ function utf8_trim($str,$charlist='') { - if($charlist == '') return trim($str); + if($charlist == '') return trim($str); - return utf8_ltrim(utf8_rtrim($str,$charlist),$charlist); + return utf8_ltrim(utf8_rtrim($str,$charlist),$charlist); } } @@ -316,10 +316,10 @@ if(!function_exists('utf8_strtolower')){ * @see utf8_strtoupper() */ function utf8_strtolower($string){ - if(UTF8_MBSTRING) return mb_strtolower($string,'utf-8'); + if(UTF8_MBSTRING) return mb_strtolower($string,'utf-8'); - global $UTF8_UPPER_TO_LOWER; - return strtr($string,$UTF8_UPPER_TO_LOWER); + global $UTF8_UPPER_TO_LOWER; + return strtr($string,$UTF8_UPPER_TO_LOWER); } } @@ -334,10 +334,10 @@ if(!function_exists('utf8_strtoupper')){ * @see utf8_strtoupper() */ function utf8_strtoupper($string){ - if(UTF8_MBSTRING) return mb_strtoupper($string,'utf-8'); + if(UTF8_MBSTRING) return mb_strtoupper($string,'utf-8'); - global $UTF8_LOWER_TO_UPPER; - return strtr($string,$UTF8_LOWER_TO_UPPER); + global $UTF8_LOWER_TO_UPPER; + return strtr($string,$UTF8_LOWER_TO_UPPER); } } @@ -351,15 +351,15 @@ if(!function_exists('utf8_ucfirst')){ * @return string with first character as upper case (if applicable) */ function utf8_ucfirst($str){ - switch ( utf8_strlen($str) ) { - case 0: - return ''; - case 1: - return utf8_strtoupper($str); - default: - preg_match('/^(.{1})(.*)$/us', $str, $matches); - return utf8_strtoupper($matches[1]).$matches[2]; - } + switch ( utf8_strlen($str) ) { + case 0: + return ''; + case 1: + return utf8_strtoupper($str); + default: + preg_match('/^(.{1})(.*)$/us', $str, $matches); + return utf8_strtoupper($matches[1]).$matches[2]; + } } } @@ -374,12 +374,12 @@ if(!function_exists('utf8_ucwords')){ * @see http://www.php.net/ucwords */ function utf8_ucwords($str) { - // Note: [\x0c\x09\x0b\x0a\x0d\x20] matches; - // form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns - // This corresponds to the definition of a "word" defined at http://www.php.net/ucwords - $pattern = '/(^|([\x0c\x09\x0b\x0a\x0d\x20]+))([^\x0c\x09\x0b\x0a\x0d\x20]{1})[^\x0c\x09\x0b\x0a\x0d\x20]*/u'; + // Note: [\x0c\x09\x0b\x0a\x0d\x20] matches; + // form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns + // This corresponds to the definition of a "word" defined at http://www.php.net/ucwords + $pattern = '/(^|([\x0c\x09\x0b\x0a\x0d\x20]+))([^\x0c\x09\x0b\x0a\x0d\x20]{1})[^\x0c\x09\x0b\x0a\x0d\x20]*/u'; - return preg_replace_callback($pattern, 'utf8_ucwords_callback',$str); + return preg_replace_callback($pattern, 'utf8_ucwords_callback',$str); } /** @@ -393,10 +393,10 @@ if(!function_exists('utf8_ucwords')){ * @see utf8_strtoupper */ function utf8_ucwords_callback($matches) { - $leadingws = $matches[2]; - $ucfirst = utf8_strtoupper($matches[3]); - $ucword = utf8_substr_replace(ltrim($matches[0]),$ucfirst,0,1); - return $leadingws . $ucword; + $leadingws = $matches[2]; + $ucfirst = utf8_strtoupper($matches[3]); + $ucword = utf8_substr_replace(ltrim($matches[0]),$ucfirst,0,1); + return $leadingws . $ucword; } } @@ -550,13 +550,13 @@ if(!function_exists('utf8_unhtml')){ if(!function_exists('utf8_decode_numeric')){ function utf8_decode_numeric($ent) { switch ($ent[2]) { - case 'X': - case 'x': - $cp = hexdec($ent[3]); - break; - default: - $cp = intval($ent[3]); - break; + case 'X': + case 'x': + $cp = hexdec($ent[3]); + break; + default: + $cp = intval($ent[3]); + break; } return unicode_to_utf8(array($cp)); } @@ -789,24 +789,24 @@ if(!function_exists('unicode_to_utf8')){ foreach (array_keys($arr) as $k) { - # ASCII range (including control chars) if ( ($arr[$k] >= 0) && ($arr[$k] <= 0x007f) ) { + # ASCII range (including control chars) echo chr($arr[$k]); - # 2 byte sequence } else if ($arr[$k] <= 0x07ff) { + # 2 byte sequence echo chr(0xc0 | ($arr[$k] >> 6)); echo chr(0x80 | ($arr[$k] & 0x003f)); - # Byte order mark (skip) } else if($arr[$k] == 0xFEFF) { + # Byte order mark (skip) // nop -- zap the BOM - # Test for illegal surrogates } else if ($arr[$k] >= 0xD800 && $arr[$k] <= 0xDFFF) { + # Test for illegal surrogates // found a surrogate if($strict){ @@ -818,15 +818,15 @@ if(!function_exists('unicode_to_utf8')){ return false; } - # 3 byte sequence } else if ($arr[$k] <= 0xffff) { + # 3 byte sequence echo chr(0xe0 | ($arr[$k] >> 12)); echo chr(0x80 | (($arr[$k] >> 6) & 0x003f)); echo chr(0x80 | ($arr[$k] & 0x003f)); - # 4 byte sequence } else if ($arr[$k] <= 0x10ffff) { + # 4 byte sequence echo chr(0xf0 | ($arr[$k] >> 18)); echo chr(0x80 | (($arr[$k] >> 12) & 0x3f)); @@ -957,163 +957,163 @@ if(!function_exists('utf8_correctIdx')){ // only needed if no mb_string available if(!UTF8_MBSTRING){ - /** - * UTF-8 Case lookup table - * - * This lookuptable defines the upper case letters to their correspponding - * lower case letter in UTF-8 - * - * @author Andreas Gohr - */ - global $UTF8_LOWER_TO_UPPER; - if(empty($UTF8_LOWER_TO_UPPER)) $UTF8_LOWER_TO_UPPER = array( - "z"=>"Z","y"=>"Y","x"=>"X","w"=>"W","v"=>"V","u"=>"U","t"=>"T","s"=>"S","r"=>"R","q"=>"Q", - "p"=>"P","o"=>"O","n"=>"N","m"=>"M","l"=>"L","k"=>"K","j"=>"J","i"=>"I","h"=>"H","g"=>"G", - "f"=>"F","e"=>"E","d"=>"D","c"=>"C","b"=>"B","a"=>"A","ῳ"=>"ῼ","ῥ"=>"Ῥ","ῡ"=>"Ῡ","ῑ"=>"Ῑ", - "ῐ"=>"Ῐ","ῃ"=>"ῌ","ι"=>"Ι","ᾳ"=>"ᾼ","ᾱ"=>"Ᾱ","ᾰ"=>"Ᾰ","ᾧ"=>"ᾯ","ᾦ"=>"ᾮ","ᾥ"=>"ᾭ","ᾤ"=>"ᾬ", - "ᾣ"=>"ᾫ","ᾢ"=>"ᾪ","ᾡ"=>"ᾩ","ᾗ"=>"ᾟ","ᾖ"=>"ᾞ","ᾕ"=>"ᾝ","ᾔ"=>"ᾜ","ᾓ"=>"ᾛ","ᾒ"=>"ᾚ","ᾑ"=>"ᾙ", - "ᾐ"=>"ᾘ","ᾇ"=>"ᾏ","ᾆ"=>"ᾎ","ᾅ"=>"ᾍ","ᾄ"=>"ᾌ","ᾃ"=>"ᾋ","ᾂ"=>"ᾊ","ᾁ"=>"ᾉ","ᾀ"=>"ᾈ","ώ"=>"Ώ", - "ὼ"=>"Ὼ","ύ"=>"Ύ","ὺ"=>"Ὺ","ό"=>"Ό","ὸ"=>"Ὸ","ί"=>"Ί","ὶ"=>"Ὶ","ή"=>"Ή","ὴ"=>"Ὴ","έ"=>"Έ", - "ὲ"=>"Ὲ","ά"=>"Ά","ὰ"=>"Ὰ","ὧ"=>"Ὧ","ὦ"=>"Ὦ","ὥ"=>"Ὥ","ὤ"=>"Ὤ","ὣ"=>"Ὣ","ὢ"=>"Ὢ","ὡ"=>"Ὡ", - "ὗ"=>"Ὗ","ὕ"=>"Ὕ","ὓ"=>"Ὓ","ὑ"=>"Ὑ","ὅ"=>"Ὅ","ὄ"=>"Ὄ","ὃ"=>"Ὃ","ὂ"=>"Ὂ","ὁ"=>"Ὁ","ὀ"=>"Ὀ", - "ἷ"=>"Ἷ","ἶ"=>"Ἶ","ἵ"=>"Ἵ","ἴ"=>"Ἴ","ἳ"=>"Ἳ","ἲ"=>"Ἲ","ἱ"=>"Ἱ","ἰ"=>"Ἰ","ἧ"=>"Ἧ","ἦ"=>"Ἦ", - "ἥ"=>"Ἥ","ἤ"=>"Ἤ","ἣ"=>"Ἣ","ἢ"=>"Ἢ","ἡ"=>"Ἡ","ἕ"=>"Ἕ","ἔ"=>"Ἔ","ἓ"=>"Ἓ","ἒ"=>"Ἒ","ἑ"=>"Ἑ", - "ἐ"=>"Ἐ","ἇ"=>"Ἇ","ἆ"=>"Ἆ","ἅ"=>"Ἅ","ἄ"=>"Ἄ","ἃ"=>"Ἃ","ἂ"=>"Ἂ","ἁ"=>"Ἁ","ἀ"=>"Ἀ","ỹ"=>"Ỹ", - "ỷ"=>"Ỷ","ỵ"=>"Ỵ","ỳ"=>"Ỳ","ự"=>"Ự","ữ"=>"Ữ","ử"=>"Ử","ừ"=>"Ừ","ứ"=>"Ứ","ủ"=>"Ủ","ụ"=>"Ụ", - "ợ"=>"Ợ","ỡ"=>"Ỡ","ở"=>"Ở","ờ"=>"Ờ","ớ"=>"Ớ","ộ"=>"Ộ","ỗ"=>"Ỗ","ổ"=>"Ổ","ồ"=>"Ồ","ố"=>"Ố", - "ỏ"=>"Ỏ","ọ"=>"Ọ","ị"=>"Ị","ỉ"=>"Ỉ","ệ"=>"Ệ","ễ"=>"Ễ","ể"=>"Ể","ề"=>"Ề","ế"=>"Ế","ẽ"=>"Ẽ", - "ẻ"=>"Ẻ","ẹ"=>"Ẹ","ặ"=>"Ặ","ẵ"=>"Ẵ","ẳ"=>"Ẳ","ằ"=>"Ằ","ắ"=>"Ắ","ậ"=>"Ậ","ẫ"=>"Ẫ","ẩ"=>"Ẩ", - "ầ"=>"Ầ","ấ"=>"Ấ","ả"=>"Ả","ạ"=>"Ạ","ẛ"=>"Ṡ","ẕ"=>"Ẕ","ẓ"=>"Ẓ","ẑ"=>"Ẑ","ẏ"=>"Ẏ","ẍ"=>"Ẍ", - "ẋ"=>"Ẋ","ẉ"=>"Ẉ","ẇ"=>"Ẇ","ẅ"=>"Ẅ","ẃ"=>"Ẃ","ẁ"=>"Ẁ","ṿ"=>"Ṿ","ṽ"=>"Ṽ","ṻ"=>"Ṻ","ṹ"=>"Ṹ", - "ṷ"=>"Ṷ","ṵ"=>"Ṵ","ṳ"=>"Ṳ","ṱ"=>"Ṱ","ṯ"=>"Ṯ","ṭ"=>"Ṭ","ṫ"=>"Ṫ","ṩ"=>"Ṩ","ṧ"=>"Ṧ","ṥ"=>"Ṥ", - "ṣ"=>"Ṣ","ṡ"=>"Ṡ","ṟ"=>"Ṟ","ṝ"=>"Ṝ","ṛ"=>"Ṛ","ṙ"=>"Ṙ","ṗ"=>"Ṗ","ṕ"=>"Ṕ","ṓ"=>"Ṓ","ṑ"=>"Ṑ", - "ṏ"=>"Ṏ","ṍ"=>"Ṍ","ṋ"=>"Ṋ","ṉ"=>"Ṉ","ṇ"=>"Ṇ","ṅ"=>"Ṅ","ṃ"=>"Ṃ","ṁ"=>"Ṁ","ḿ"=>"Ḿ","ḽ"=>"Ḽ", - "ḻ"=>"Ḻ","ḹ"=>"Ḹ","ḷ"=>"Ḷ","ḵ"=>"Ḵ","ḳ"=>"Ḳ","ḱ"=>"Ḱ","ḯ"=>"Ḯ","ḭ"=>"Ḭ","ḫ"=>"Ḫ","ḩ"=>"Ḩ", - "ḧ"=>"Ḧ","ḥ"=>"Ḥ","ḣ"=>"Ḣ","ḡ"=>"Ḡ","ḟ"=>"Ḟ","ḝ"=>"Ḝ","ḛ"=>"Ḛ","ḙ"=>"Ḙ","ḗ"=>"Ḗ","ḕ"=>"Ḕ", - "ḓ"=>"Ḓ","ḑ"=>"Ḑ","ḏ"=>"Ḏ","ḍ"=>"Ḍ","ḋ"=>"Ḋ","ḉ"=>"Ḉ","ḇ"=>"Ḇ","ḅ"=>"Ḅ","ḃ"=>"Ḃ","ḁ"=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ŏ","ō"=>"Ō","ŋ"=>"Ŋ","ň"=>"Ň","ņ"=>"Ņ","ń"=>"Ń","ł"=>"Ł","ŀ"=>"Ŀ", - "ľ"=>"Ľ","ļ"=>"Ļ","ĺ"=>"Ĺ","ķ"=>"Ķ","ĵ"=>"Ĵ","ij"=>"IJ","ı"=>"I","į"=>"Į","ĭ"=>"Ĭ","ī"=>"Ī", - "ĩ"=>"Ĩ","ħ"=>"Ħ","ĥ"=>"Ĥ","ģ"=>"Ģ","ġ"=>"Ġ","ğ"=>"Ğ","ĝ"=>"Ĝ","ě"=>"Ě","ę"=>"Ę","ė"=>"Ė", - "ĕ"=>"Ĕ","ē"=>"Ē","đ"=>"Đ","ď"=>"Ď","č"=>"Č","ċ"=>"Ċ","ĉ"=>"Ĉ","ć"=>"Ć","ą"=>"Ą","ă"=>"Ă", - "ā"=>"Ā","ÿ"=>"Ÿ","þ"=>"Þ","ý"=>"Ý","ü"=>"Ü","û"=>"Û","ú"=>"Ú","ù"=>"Ù","ø"=>"Ø","ö"=>"Ö", - "õ"=>"Õ","ô"=>"Ô","ó"=>"Ó","ò"=>"Ò","ñ"=>"Ñ","ð"=>"Ð","ï"=>"Ï","î"=>"Î","í"=>"Í","ì"=>"Ì", - "ë"=>"Ë","ê"=>"Ê","é"=>"É","è"=>"È","ç"=>"Ç","æ"=>"Æ","å"=>"Å","ä"=>"Ä","ã"=>"Ã","â"=>"Â", - "á"=>"Á","à"=>"À","µ"=>"Μ","z"=>"Z","y"=>"Y","x"=>"X","w"=>"W","v"=>"V","u"=>"U","t"=>"T", - "s"=>"S","r"=>"R","q"=>"Q","p"=>"P","o"=>"O","n"=>"N","m"=>"M","l"=>"L","k"=>"K","j"=>"J", - "i"=>"I","h"=>"H","g"=>"G","f"=>"F","e"=>"E","d"=>"D","c"=>"C","b"=>"B","a"=>"A" - ); + /** + * UTF-8 Case lookup table + * + * This lookuptable defines the upper case letters to their correspponding + * lower case letter in UTF-8 + * + * @author Andreas Gohr + */ + global $U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"=>"Ὗ","ὕ"=>"Ὕ","ὓ"=>"Ὓ","ὑ"=>"Ὑ","ὅ"=>"Ὅ","ὄ"=>"Ὄ","ὃ"=>"Ὃ","ὂ"=>"Ὂ","ὁ"=>"Ὁ","ὀ"=>"Ὀ", + "ἷ"=>"Ἷ","ἶ"=>"Ἶ","ἵ"=>"Ἵ","ἴ"=>"Ἴ","ἳ"=>"Ἳ","ἲ"=>"Ἲ","ἱ"=>"Ἱ","ἰ"=>"Ἰ","ἧ"=>"Ἧ","ἦ"=>"Ἦ", + "ἥ"=>"Ἥ","ἤ"=>"Ἤ","ἣ"=>"Ἣ","ἢ"=>"Ἢ","ἡ"=>"Ἡ","ἕ"=>"Ἕ","ἔ"=>"Ἔ","ἓ"=>"Ἓ","ἒ"=>"Ἒ","ἑ"=>"Ἑ", + "ἐ"=>"Ἐ","ἇ"=>"Ἇ","ἆ"=>"Ἆ","ἅ"=>"Ἅ","ἄ"=>"Ἄ","ἃ"=>"Ἃ","ἂ"=>"Ἂ","ἁ"=>"Ἁ","ἀ"=>"Ἀ","ỹ"=>"Ỹ", + "ỷ"=>"Ỷ","ỵ"=>"Ỵ","ỳ"=>"Ỳ","ự"=>"Ự","ữ"=>"Ữ","ử"=>"Ử","ừ"=>"Ừ","ứ"=>"Ứ","ủ"=>"Ủ","ụ"=>"Ụ", + "ợ"=>"Ợ","ỡ"=>"Ỡ","ở"=>"Ở","ờ"=>"Ờ","ớ"=>"Ớ","ộ"=>"Ộ","ỗ"=>"Ỗ","ổ"=>"Ổ","ồ"=>"Ồ","ố"=>"Ố", + "ỏ"=>"Ỏ","ọ"=>"Ọ","ị"=>"Ị","ỉ"=>"Ỉ","ệ"=>"Ệ","ễ"=>"Ễ","ể"=>"Ể","ề"=>"Ề","ế"=>"Ế","ẽ"=>"Ẽ", + "ẻ"=>"Ẻ","ẹ"=>"Ẹ","ặ"=>"Ặ","ẵ"=>"Ẵ","ẳ"=>"Ẳ","ằ"=>"Ằ","ắ"=>"Ắ","ậ"=>"Ậ","ẫ"=>"Ẫ","ẩ"=>"Ẩ", + "ầ"=>"Ầ","ấ"=>"Ấ","ả"=>"Ả","ạ"=>"Ạ","ẛ"=>"Ṡ","ẕ"=>"Ẕ","ẓ"=>"Ẓ","ẑ"=>"Ẑ","ẏ"=>"Ẏ","ẍ"=>"Ẍ", + "ẋ"=>"Ẋ","ẉ"=>"Ẉ","ẇ"=>"Ẇ","ẅ"=>"Ẅ","ẃ"=>"Ẃ","ẁ"=>"Ẁ","ṿ"=>"Ṿ","ṽ"=>"Ṽ","ṻ"=>"Ṻ","ṹ"=>"Ṹ", + "ṷ"=>"Ṷ","ṵ"=>"Ṵ","ṳ"=>"Ṳ","ṱ"=>"Ṱ","ṯ"=>"Ṯ","ṭ"=>"Ṭ","ṫ"=>"Ṫ","ṩ"=>"Ṩ","ṧ"=>"Ṧ","ṥ"=>"Ṥ", + "ṣ"=>"Ṣ","ṡ"=>"Ṡ","ṟ"=>"Ṟ","ṝ"=>"Ṝ","ṛ"=>"Ṛ","ṙ"=>"Ṙ","ṗ"=>"Ṗ","ṕ"=>"Ṕ","ṓ"=>"Ṓ","ṑ"=>"Ṑ", + "ṏ"=>"Ṏ","ṍ"=>"Ṍ","ṋ"=>"Ṋ","ṉ"=>"Ṉ","ṇ"=>"Ṇ","ṅ"=>"Ṅ","ṃ"=>"Ṃ","ṁ"=>"Ṁ","ḿ"=>"Ḿ","ḽ"=>"Ḽ", + "ḻ"=>"Ḻ","ḹ"=>"Ḹ","ḷ"=>"Ḷ","ḵ"=>"Ḵ","ḳ"=>"Ḳ","ḱ"=>"Ḱ","ḯ"=>"Ḯ","ḭ"=>"Ḭ","ḫ"=>"Ḫ","ḩ"=>"Ḩ", + "ḧ"=>"Ḧ","ḥ"=>"Ḥ","ḣ"=>"Ḣ","ḡ"=>"Ḡ","ḟ"=>"Ḟ","ḝ"=>"Ḝ","ḛ"=>"Ḛ","ḙ"=>"Ḙ","ḗ"=>"Ḗ","ḕ"=>"Ḕ", + "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>"H","g"=>"G","f"=>"F","e"=>"E","d"=>"D","c"=>"C","b"=>"B","a"=>"A" + ); - /** - * UTF-8 Case lookup table - * - * This lookuptable defines the lower case letters to their correspponding - * upper case letter in UTF-8 - * - * @author Andreas Gohr - */ - global $UTF8_UPPER_TO_LOWER; - if(empty($UTF8_UPPER_TO_LOWER)) $UTF8_UPPER_TO_LOWER = array ( - "Z"=>"z","Y"=>"y","X"=>"x","W"=>"w","V"=>"v","U"=>"u","T"=>"t","S"=>"s","R"=>"r","Q"=>"q", - "P"=>"p","O"=>"o","N"=>"n","M"=>"m","L"=>"l","K"=>"k","J"=>"j","I"=>"i","H"=>"h","G"=>"g", - "F"=>"f","E"=>"e","D"=>"d","C"=>"c","B"=>"b","A"=>"a","ῼ"=>"ῳ","Ῥ"=>"ῥ","Ῡ"=>"ῡ","Ῑ"=>"ῑ", - "Ῐ"=>"ῐ","ῌ"=>"ῃ","Ι"=>"ι","ᾼ"=>"ᾳ","Ᾱ"=>"ᾱ","Ᾰ"=>"ᾰ","ᾯ"=>"ᾧ","ᾮ"=>"ᾦ","ᾭ"=>"ᾥ","ᾬ"=>"ᾤ", - "ᾫ"=>"ᾣ","ᾪ"=>"ᾢ","ᾩ"=>"ᾡ","ᾟ"=>"ᾗ","ᾞ"=>"ᾖ","ᾝ"=>"ᾕ","ᾜ"=>"ᾔ","ᾛ"=>"ᾓ","ᾚ"=>"ᾒ","ᾙ"=>"ᾑ", - "ᾘ"=>"ᾐ","ᾏ"=>"ᾇ","ᾎ"=>"ᾆ","ᾍ"=>"ᾅ","ᾌ"=>"ᾄ","ᾋ"=>"ᾃ","ᾊ"=>"ᾂ","ᾉ"=>"ᾁ","ᾈ"=>"ᾀ","Ώ"=>"ώ", - "Ὼ"=>"ὼ","Ύ"=>"ύ","Ὺ"=>"ὺ","Ό"=>"ό","Ὸ"=>"ὸ","Ί"=>"ί","Ὶ"=>"ὶ","Ή"=>"ή","Ὴ"=>"ὴ","Έ"=>"έ", - "Ὲ"=>"ὲ","Ά"=>"ά","Ὰ"=>"ὰ","Ὧ"=>"ὧ","Ὦ"=>"ὦ","Ὥ"=>"ὥ","Ὤ"=>"ὤ","Ὣ"=>"ὣ","Ὢ"=>"ὢ","Ὡ"=>"ὡ", - "Ὗ"=>"ὗ","Ὕ"=>"ὕ","Ὓ"=>"ὓ","Ὑ"=>"ὑ","Ὅ"=>"ὅ","Ὄ"=>"ὄ","Ὃ"=>"ὃ","Ὂ"=>"ὂ","Ὁ"=>"ὁ","Ὀ"=>"ὀ", - "Ἷ"=>"ἷ","Ἶ"=>"ἶ","Ἵ"=>"ἵ","Ἴ"=>"ἴ","Ἳ"=>"ἳ","Ἲ"=>"ἲ","Ἱ"=>"ἱ","Ἰ"=>"ἰ","Ἧ"=>"ἧ","Ἦ"=>"ἦ", - "Ἥ"=>"ἥ","Ἤ"=>"ἤ","Ἣ"=>"ἣ","Ἢ"=>"ἢ","Ἡ"=>"ἡ","Ἕ"=>"ἕ","Ἔ"=>"ἔ","Ἓ"=>"ἓ","Ἒ"=>"ἒ","Ἑ"=>"ἑ", - "Ἐ"=>"ἐ","Ἇ"=>"ἇ","Ἆ"=>"ἆ","Ἅ"=>"ἅ","Ἄ"=>"ἄ","Ἃ"=>"ἃ","Ἂ"=>"ἂ","Ἁ"=>"ἁ","Ἀ"=>"ἀ","Ỹ"=>"ỹ", - "Ỷ"=>"ỷ","Ỵ"=>"ỵ","Ỳ"=>"ỳ","Ự"=>"ự","Ữ"=>"ữ","Ử"=>"ử","Ừ"=>"ừ","Ứ"=>"ứ","Ủ"=>"ủ","Ụ"=>"ụ", - "Ợ"=>"ợ","Ỡ"=>"ỡ","Ở"=>"ở","Ờ"=>"ờ","Ớ"=>"ớ","Ộ"=>"ộ","Ỗ"=>"ỗ","Ổ"=>"ổ","Ồ"=>"ồ","Ố"=>"ố", - "Ỏ"=>"ỏ","Ọ"=>"ọ","Ị"=>"ị","Ỉ"=>"ỉ","Ệ"=>"ệ","Ễ"=>"ễ","Ể"=>"ể","Ề"=>"ề","Ế"=>"ế","Ẽ"=>"ẽ", - "Ẻ"=>"ẻ","Ẹ"=>"ẹ","Ặ"=>"ặ","Ẵ"=>"ẵ","Ẳ"=>"ẳ","Ằ"=>"ằ","Ắ"=>"ắ","Ậ"=>"ậ","Ẫ"=>"ẫ","Ẩ"=>"ẩ", - "Ầ"=>"ầ","Ấ"=>"ấ","Ả"=>"ả","Ạ"=>"ạ","Ṡ"=>"ẛ","Ẕ"=>"ẕ","Ẓ"=>"ẓ","Ẑ"=>"ẑ","Ẏ"=>"ẏ","Ẍ"=>"ẍ", - "Ẋ"=>"ẋ","Ẉ"=>"ẉ","Ẇ"=>"ẇ","Ẅ"=>"ẅ","Ẃ"=>"ẃ","Ẁ"=>"ẁ","Ṿ"=>"ṿ","Ṽ"=>"ṽ","Ṻ"=>"ṻ","Ṹ"=>"ṹ", - "Ṷ"=>"ṷ","Ṵ"=>"ṵ","Ṳ"=>"ṳ","Ṱ"=>"ṱ","Ṯ"=>"ṯ","Ṭ"=>"ṭ","Ṫ"=>"ṫ","Ṩ"=>"ṩ","Ṧ"=>"ṧ","Ṥ"=>"ṥ", - "Ṣ"=>"ṣ","Ṡ"=>"ṡ","Ṟ"=>"ṟ","Ṝ"=>"ṝ","Ṛ"=>"ṛ","Ṙ"=>"ṙ","Ṗ"=>"ṗ","Ṕ"=>"ṕ","Ṓ"=>"ṓ","Ṑ"=>"ṑ", - "Ṏ"=>"ṏ","Ṍ"=>"ṍ","Ṋ"=>"ṋ","Ṉ"=>"ṉ","Ṇ"=>"ṇ","Ṅ"=>"ṅ","Ṃ"=>"ṃ","Ṁ"=>"ṁ","Ḿ"=>"ḿ","Ḽ"=>"ḽ", - "Ḻ"=>"ḻ","Ḹ"=>"ḹ","Ḷ"=>"ḷ","Ḵ"=>"ḵ","Ḳ"=>"ḳ","Ḱ"=>"ḱ","Ḯ"=>"ḯ","Ḭ"=>"ḭ","Ḫ"=>"ḫ","Ḩ"=>"ḩ", - "Ḧ"=>"ḧ","Ḥ"=>"ḥ","Ḣ"=>"ḣ","Ḡ"=>"ḡ","Ḟ"=>"ḟ","Ḝ"=>"ḝ","Ḛ"=>"ḛ","Ḙ"=>"ḙ","Ḗ"=>"ḗ","Ḕ"=>"ḕ", - "Ḓ"=>"ḓ","Ḑ"=>"ḑ","Ḏ"=>"ḏ","Ḍ"=>"ḍ","Ḋ"=>"ḋ","Ḉ"=>"ḉ","Ḇ"=>"ḇ","Ḅ"=>"ḅ","Ḃ"=>"ḃ","Ḁ"=>"ḁ", - "Ֆ"=>"ֆ","Օ"=>"օ","Ք"=>"ք","Փ"=>"փ","Ւ"=>"ւ","Ց"=>"ց","Ր"=>"ր","Տ"=>"տ","Վ"=>"վ","Ս"=>"ս", - "Ռ"=>"ռ","Ջ"=>"ջ","Պ"=>"պ","Չ"=>"չ","Ո"=>"ո","Շ"=>"շ","Ն"=>"ն","Յ"=>"յ","Մ"=>"մ","Ճ"=>"ճ", - "Ղ"=>"ղ","Ձ"=>"ձ","Հ"=>"հ","Կ"=>"կ","Ծ"=>"ծ","Խ"=>"խ","Լ"=>"լ","Ի"=>"ի","Ժ"=>"ժ","Թ"=>"թ", - "Ը"=>"ը","Է"=>"է","Զ"=>"զ","Ե"=>"ե","Դ"=>"դ","Գ"=>"գ","Բ"=>"բ","Ա"=>"ա","Ԏ"=>"ԏ","Ԍ"=>"ԍ", - "Ԋ"=>"ԋ","Ԉ"=>"ԉ","Ԇ"=>"ԇ","Ԅ"=>"ԅ","Ԃ"=>"ԃ","Ԁ"=>"ԁ","Ӹ"=>"ӹ","Ӵ"=>"ӵ","Ӳ"=>"ӳ","Ӱ"=>"ӱ", - "Ӯ"=>"ӯ","Ӭ"=>"ӭ","Ӫ"=>"ӫ","Ө"=>"ө","Ӧ"=>"ӧ","Ӥ"=>"ӥ","Ӣ"=>"ӣ","Ӡ"=>"ӡ","Ӟ"=>"ӟ","Ӝ"=>"ӝ", - "Ӛ"=>"ӛ","Ә"=>"ә","Ӗ"=>"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=>"z","Y"=>"y","X"=>"x","W"=>"w","V"=>"v","U"=>"u","T"=>"t", - "S"=>"s","R"=>"r","Q"=>"q","P"=>"p","O"=>"o","N"=>"n","M"=>"m","L"=>"l","K"=>"k","J"=>"j", - "I"=>"i","H"=>"h","G"=>"g","F"=>"f","E"=>"e","D"=>"d","C"=>"c","B"=>"b","A"=>"a" - ); + /** + * UTF-8 Case lookup table + * + * This lookuptable defines the lower case letters to their correspponding + * upper case letter in UTF-8 + * + * @author Andreas Gohr + */ + global $UTF8_UPPER_TO_LOWER; + if(empty($UTF8_UPPER_TO_LOWER)) $UTF8_UPPER_TO_LOWER = array ( + "Z"=>"z","Y"=>"y","X"=>"x","W"=>"w","V"=>"v","U"=>"u","T"=>"t","S"=>"s","R"=>"r","Q"=>"q", + "P"=>"p","O"=>"o","N"=>"n","M"=>"m","L"=>"l","K"=>"k","J"=>"j","I"=>"i","H"=>"h","G"=>"g", + "F"=>"f","E"=>"e","D"=>"d","C"=>"c","B"=>"b","A"=>"a","ῼ"=>"ῳ","Ῥ"=>"ῥ","Ῡ"=>"ῡ","Ῑ"=>"ῑ", + "Ῐ"=>"ῐ","ῌ"=>"ῃ","Ι"=>"ι","ᾼ"=>"ᾳ","Ᾱ"=>"ᾱ","Ᾰ"=>"ᾰ","ᾯ"=>"ᾧ","ᾮ"=>"ᾦ","ᾭ"=>"ᾥ","ᾬ"=>"ᾤ", + "ᾫ"=>"ᾣ","ᾪ"=>"ᾢ","ᾩ"=>"ᾡ","ᾟ"=>"ᾗ","ᾞ"=>"ᾖ","ᾝ"=>"ᾕ","ᾜ"=>"ᾔ","ᾛ"=>"ᾓ","ᾚ"=>"ᾒ","ᾙ"=>"ᾑ", + "ᾘ"=>"ᾐ","ᾏ"=>"ᾇ","ᾎ"=>"ᾆ","ᾍ"=>"ᾅ","ᾌ"=>"ᾄ","ᾋ"=>"ᾃ","ᾊ"=>"ᾂ","ᾉ"=>"ᾁ","ᾈ"=>"ᾀ","Ώ"=>"ώ", + "Ὼ"=>"ὼ","Ύ"=>"ύ","Ὺ"=>"ὺ","Ό"=>"ό","Ὸ"=>"ὸ","Ί"=>"ί","Ὶ"=>"ὶ","Ή"=>"ή","Ὴ"=>"ὴ","Έ"=>"έ", + "Ὲ"=>"ὲ","Ά"=>"ά","Ὰ"=>"ὰ","Ὧ"=>"ὧ","Ὦ"=>"ὦ","Ὥ"=>"ὥ","Ὤ"=>"ὤ","Ὣ"=>"ὣ","Ὢ"=>"ὢ","Ὡ"=>"ὡ", + "Ὗ"=>"ὗ","Ὕ"=>"ὕ","Ὓ"=>"ὓ","Ὑ"=>"ὑ","Ὅ"=>"ὅ","Ὄ"=>"ὄ","Ὃ"=>"ὃ","Ὂ"=>"ὂ","Ὁ"=>"ὁ","Ὀ"=>"ὀ", + "Ἷ"=>"ἷ","Ἶ"=>"ἶ","Ἵ"=>"ἵ","Ἴ"=>"ἴ","Ἳ"=>"ἳ","Ἲ"=>"ἲ","Ἱ"=>"ἱ","Ἰ"=>"ἰ","Ἧ"=>"ἧ","Ἦ"=>"ἦ", + "Ἥ"=>"ἥ","Ἤ"=>"ἤ","Ἣ"=>"ἣ","Ἢ"=>"ἢ","Ἡ"=>"ἡ","Ἕ"=>"ἕ","Ἔ"=>"ἔ","Ἓ"=>"ἓ","Ἒ"=>"ἒ","Ἑ"=>"ἑ", + "Ἐ"=>"ἐ","Ἇ"=>"ἇ","Ἆ"=>"ἆ","Ἅ"=>"ἅ","Ἄ"=>"ἄ","Ἃ"=>"ἃ","Ἂ"=>"ἂ","Ἁ"=>"ἁ","Ἀ"=>"ἀ","Ỹ"=>"ỹ", + "Ỷ"=>"ỷ","Ỵ"=>"ỵ","Ỳ"=>"ỳ","Ự"=>"ự","Ữ"=>"ữ","Ử"=>"ử","Ừ"=>"ừ","Ứ"=>"ứ","Ủ"=>"ủ","Ụ"=>"ụ", + "Ợ"=>"ợ","Ỡ"=>"ỡ","Ở"=>"ở","Ờ"=>"ờ","Ớ"=>"ớ","Ộ"=>"ộ","Ỗ"=>"ỗ","Ổ"=>"ổ","Ồ"=>"ồ","Ố"=>"ố", + "Ỏ"=>"ỏ","Ọ"=>"ọ","Ị"=>"ị","Ỉ"=>"ỉ","Ệ"=>"ệ","Ễ"=>"ễ","Ể"=>"ể","Ề"=>"ề","Ế"=>"ế","Ẽ"=>"ẽ", + "Ẻ"=>"ẻ","Ẹ"=>"ẹ","Ặ"=>"ặ","Ẵ"=>"ẵ","Ẳ"=>"ẳ","Ằ"=>"ằ","Ắ"=>"ắ","Ậ"=>"ậ","Ẫ"=>"ẫ","Ẩ"=>"ẩ", + "Ầ"=>"ầ","Ấ"=>"ấ","Ả"=>"ả","Ạ"=>"ạ","Ṡ"=>"ẛ","Ẕ"=>"ẕ","Ẓ"=>"ẓ","Ẑ"=>"ẑ","Ẏ"=>"ẏ","Ẍ"=>"ẍ", + "Ẋ"=>"ẋ","Ẉ"=>"ẉ","Ẇ"=>"ẇ","Ẅ"=>"ẅ","Ẃ"=>"ẃ","Ẁ"=>"ẁ","Ṿ"=>"ṿ","Ṽ"=>"ṽ","Ṻ"=>"ṻ","Ṹ"=>"ṹ", + "Ṷ"=>"ṷ","Ṵ"=>"ṵ","Ṳ"=>"ṳ","Ṱ"=>"ṱ","Ṯ"=>"ṯ","Ṭ"=>"ṭ","Ṫ"=>"ṫ","Ṩ"=>"ṩ","Ṧ"=>"ṧ","Ṥ"=>"ṥ", + "Ṣ"=>"ṣ","Ṡ"=>"ṡ","Ṟ"=>"ṟ","Ṝ"=>"ṝ","Ṛ"=>"ṛ","Ṙ"=>"ṙ","Ṗ"=>"ṗ","Ṕ"=>"ṕ","Ṓ"=>"ṓ","Ṑ"=>"ṑ", + "Ṏ"=>"ṏ","Ṍ"=>"ṍ","Ṋ"=>"ṋ","Ṉ"=>"ṉ","Ṇ"=>"ṇ","Ṅ"=>"ṅ","Ṃ"=>"ṃ","Ṁ"=>"ṁ","Ḿ"=>"ḿ","Ḽ"=>"ḽ", + "Ḻ"=>"ḻ","Ḹ"=>"ḹ","Ḷ"=>"ḷ","Ḵ"=>"ḵ","Ḳ"=>"ḳ","Ḱ"=>"ḱ","Ḯ"=>"ḯ","Ḭ"=>"ḭ","Ḫ"=>"ḫ","Ḩ"=>"ḩ", + "Ḧ"=>"ḧ","Ḥ"=>"ḥ","Ḣ"=>"ḣ","Ḡ"=>"ḡ","Ḟ"=>"ḟ","Ḝ"=>"ḝ","Ḛ"=>"ḛ","Ḙ"=>"ḙ","Ḗ"=>"ḗ","Ḕ"=>"ḕ", + "Ḓ"=>"ḓ","Ḑ"=>"ḑ","Ḏ"=>"ḏ","Ḍ"=>"ḍ","Ḋ"=>"ḋ","Ḉ"=>"ḉ","Ḇ"=>"ḇ","Ḅ"=>"ḅ","Ḃ"=>"ḃ","Ḁ"=>"ḁ", + "Ֆ"=>"ֆ","Օ"=>"օ","Ք"=>"ք","Փ"=>"փ","Ւ"=>"ւ","Ց"=>"ց","Ր"=>"ր","Տ"=>"տ","Վ"=>"վ","Ս"=>"ս", + "Ռ"=>"ռ","Ջ"=>"ջ","Պ"=>"պ","Չ"=>"չ","Ո"=>"ո","Շ"=>"շ","Ն"=>"ն","Յ"=>"յ","Մ"=>"մ","Ճ"=>"ճ", + "Ղ"=>"ղ","Ձ"=>"ձ","Հ"=>"հ","Կ"=>"կ","Ծ"=>"ծ","Խ"=>"խ","Լ"=>"լ","Ի"=>"ի","Ժ"=>"ժ","Թ"=>"թ", + "Ը"=>"ը","Է"=>"է","Զ"=>"զ","Ե"=>"ե","Դ"=>"դ","Գ"=>"գ","Բ"=>"բ","Ա"=>"ա","Ԏ"=>"ԏ","Ԍ"=>"ԍ", + "Ԋ"=>"ԋ","Ԉ"=>"ԉ","Ԇ"=>"ԇ","Ԅ"=>"ԅ","Ԃ"=>"ԃ","Ԁ"=>"ԁ","Ӹ"=>"ӹ","Ӵ"=>"ӵ","Ӳ"=>"ӳ","Ӱ"=>"ӱ", + "Ӯ"=>"ӯ","Ӭ"=>"ӭ","Ӫ"=>"ӫ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","Ì"=>"ì", + "Ë"=>"ë","Ê"=>"ê","É"=>"é","È"=>"è","Ç"=>"ç","Æ"=>"æ","Å"=>"å","Ä"=>"ä","Ã"=>"ã","Â"=>"â", + "Á"=>"á","À"=>"à","Μ"=>"µ","Z"=>"z","Y"=>"y","X"=>"x","W"=>"w","V"=>"v","U"=>"u","T"=>"t", + "S"=>"s","R"=>"r","Q"=>"q","P"=>"p","O"=>"o","N"=>"n","M"=>"m","L"=>"l","K"=>"k","J"=>"j", + "I"=>"i","H"=>"h","G"=>"g","F"=>"f","E"=>"e","D"=>"d","C"=>"c","B"=>"b","A"=>"a" + ); }; // end of case lookup tables /** @@ -1642,7 +1642,7 @@ if(empty($UTF8_ROMANIZATION)) $UTF8_ROMANIZATION = array( '่'=>'','้'=>'','๊'=>'','๋'=>'','็'=>'', '์'=>'','๎'=>'','ํ'=>'','ฺ'=>'', 'ๆ'=>'2','๏'=>'o','ฯ'=>'-','๚'=>'-','๛'=>'-', - '๐'=>'0','๑'=>'1','๒'=>'2','๓'=>'3','๔'=>'4', + '๐'=>'0','๑'=>'1','๒'=>'2','๓'=>'3','๔'=>'4', '๕'=>'5','๖'=>'6','๗'=>'7','๘'=>'8','๙'=>'9', // Korean @@ -1654,5 +1654,4 @@ if(empty($UTF8_ROMANIZATION)) $UTF8_ROMANIZATION = array( 'ㅠ'=>'yu','ㅒ'=>'yay','ㅖ'=>'yey', ); -//Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/install.php b/install.php index 07f69f24b..e11ba1d4a 100644 --- a/install.php +++ b/install.php @@ -1,8 +1,8 @@ + * @author Chris Smith */ if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/'); @@ -286,7 +286,6 @@ EOT; } $ok = $ok && fileWrite(DOKU_LOCAL.'local.php',$output); - if ($d['acl']) { // create users.auth.php // --- user:MD5password:Real Name:email:groups,comma,seperated @@ -473,7 +472,6 @@ function langsel(){ closedir($dh); sort($langs); - echo '
    '; echo $lang['i_chooselang']; echo ':