From b08472eed43b4169c964445f9457c161d1218da4 Mon Sep 17 00:00:00 2001 From: rurban Date: Fri, 25 Jun 2004 14:29:22 +0000 Subject: [PATCH] WikiGroup refactoring: global group attached to user, code for not_current user. improved helpers for special groups (avoid double invocations) new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write()) fixed a XHTML validation error on userprefs.tmpl git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3777 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/ErrorManager.php | 25 +++- lib/HtmlElement.php | 11 +- lib/IniConfig.php | 106 +++++++++------ lib/InlineParser.php | 12 +- lib/PageList.php | 16 ++- lib/PagePerm.php | 17 ++- lib/Request.php | 17 ++- lib/Template.php | 15 ++- lib/WikiGroup.php | 172 ++++++++++++++---------- lib/WikiUserNew.php | 130 +++++++++--------- lib/display.php | 34 ++++- lib/loadsave.php | 7 +- lib/main.php | 41 +++++- lib/plugin/AllUsers.php | 15 ++- lib/plugin/WikiAdminUtils.php | 6 +- lib/plugin/_AuthInfo.php | 15 ++- lib/stdlib.php | 37 +++-- themes/default/templates/head.tmpl | 84 +----------- themes/default/templates/html.tmpl | 7 +- themes/default/templates/signin.tmpl | 41 +++--- themes/default/templates/userprefs.tmpl | 6 +- 21 files changed, 462 insertions(+), 352 deletions(-) diff --git a/lib/ErrorManager.php b/lib/ErrorManager.php index 931ad7258..aa4b9142e 100644 --- a/lib/ErrorManager.php +++ b/lib/ErrorManager.php @@ -1,4 +1,4 @@ -_noCacheHeaders(); + // Error was either fatal, or was not handled by a handler. // Handle it ourself. if ($error->isFatal()) { @@ -278,6 +280,24 @@ class ErrorManager } return $flushed; } + + function _noCacheHeaders() { + global $request; + static $already = false; + + if (isset($request) and isset($request->_validators)) { + $request->_validators->_tag = false; + $request->_validators->_mtime = false; + } + if ($already) return; + + // FIXME: Howto announce that to Request->cacheControl()? + if (!headers_sent()) { + header( "Cache-control: no-cache" ); + header( "Pragma: nocache" ); + } + $already = true; + } } /** @@ -528,6 +548,9 @@ if (!isset($GLOBALS['ErrorManager'])) { } // $Log: not supported by cvs2svn $ +// Revision 1.29 2004/06/20 15:30:04 rurban +// get_class case-sensitivity issues +// // Revision 1.28 2004/06/16 11:51:04 rurban // fixed typo: undefined object #235 // diff --git a/lib/HtmlElement.php b/lib/HtmlElement.php index 6b3e73322..d7bcfbcf5 100644 --- a/lib/HtmlElement.php +++ b/lib/HtmlElement.php @@ -1,4 +1,4 @@ -")); + new RawXml((ENABLE_XHTML_XML ? "\n//\n" : "// -->"))); } /** Conditionally display content based of whether javascript is supported. @@ -518,6 +521,10 @@ function IfJavaScript($if_content = false, $else_content = false) { /** $Log: not supported by cvs2svn $ + Revision 1.39 2004/05/17 13:36:49 rurban + Apply RFE #952323 "ExternalSearchPlugin improvement", but + with + Revision 1.38 2004/05/12 10:49:54 rurban require_once fix for those libs which are loaded before FileFinder and its automatic include_path fix, and where require_once doesn't grok diff --git a/lib/IniConfig.php b/lib/IniConfig.php index 7044916dd..351251d80 100644 --- a/lib/IniConfig.php +++ b/lib/IniConfig.php @@ -1,5 +1,5 @@ config/config.ini converter. + * + * - config.ini => config.php dumper for faster startup. + * + * - Don't use too much globals for easier integration into other projects + * (namespace pollution). (gforge, phpnuke, postnuke, phpBB2, carolina, ...) + * Use one global $phpwiki object instead which holds the cfg vars, constants + * and all other globals. + * (global $FieldSeparator, $charset, $WikiNameRegexp, $KeywordLinkRegexp; + * global $DisabledActions, $DBParams, $LANG, $AllActionPages) * * - Resurrect the larger "config object" code (in config/) so it'll aid the - * GUI config writers, and allow us to do proper validation and default - * value handling. + * GUI config writers, and allow us to do proper validation and default + * value handling. * * - Get rid of WikiNameRegexp and KeywordLinkRegexp as globals by finding - * everywhere that uses them as variables and modify the code to use - * them as constants. Will involve hacking around - * pcre_fix_posix_classes (probably with redefines()). + * everywhere that uses them as variables and modify the code to use + * them as constants. Will involve hacking around + * pcre_fix_posix_classes (probably with redefines()). */ include_once (dirname(__FILE__)."/config.php"); @@ -97,7 +109,8 @@ function IniConfig($file) { 'ALLOW_USER_LOGIN', 'ALLOW_LDAP_LOGIN', 'ALLOW_IMAP_LOGIN', 'WARN_NONPUBLIC_INTERWIKIMAP', 'USE_PATH_INFO', 'DISABLE_HTTP_REDIRECT', - 'PLUGIN_CACHED_USECACHE', 'PLUGIN_CACHED_FORCE_SYNCMAP' + 'PLUGIN_CACHED_USECACHE', 'PLUGIN_CACHED_FORCE_SYNCMAP', + 'ENABLE_XHTML_XML' ); if(!file_exists($file)){ @@ -121,9 +134,10 @@ function IniConfig($file) { //} elseif (array_key_exists($item, $rsdef)) { // define($item, $rsdef[$item]); // calculate them later or not at all: - } elseif (in_array($item,array('DATABASE_PREFIX', 'SERVER_NAME', 'SERVER_PORT', - 'SCRIPT_NAME', 'DATA_PATH', 'PHPWIKI_DIR', 'VIRTUAL_PATH', - 'LDAP_AUTH_HOST','IMAP_AUTH_HOST','POP3_AUTH_HOST'))) + } elseif (in_array($item, + array('DATABASE_PREFIX', 'SERVER_NAME', 'SERVER_PORT', + 'SCRIPT_NAME', 'DATA_PATH', 'PHPWIKI_DIR', 'VIRTUAL_PATH', + 'LDAP_AUTH_HOST','IMAP_AUTH_HOST','POP3_AUTH_HOST'))) { ; } else { @@ -196,42 +210,37 @@ function IniConfig($file) { // Expiry stuff global $ExpireParams; - $ExpireParams['major'] = array( - 'max_age' => @$rs['MAJOR_MAX_AGE'], - 'min_age' => @$rs['MAJOR_MIN_AGE'], - 'min_keep' => @$rs['MAJOR_MIN_KEEP'], - 'keep' => @$rs['MAJOR_KEEP'], - 'max_keep' => @$rs['MAJOR_MAX_KEEP'] - ); - $ExpireParams['minor'] = array( - 'max_age' => @$rs['MINOR_MAX_AGE'], - 'min_age' => @$rs['MINOR_MIN_AGE'], - 'min_keep' => @$rs['MINOR_MIN_KEEP'], - 'keep' => @$rs['MINOR_KEEP'], - 'max_keep' => @$rs['MINOR_MAX_KEEP'] - ); - $ExpireParams['author'] = array( - 'max_age' => @$rs['AUTHOR_MAX_AGE'], - 'min_age' => @$rs['AUTHOR_MIN_AGE'], - 'min_keep' => @$rs['AUTHOR_MIN_KEEP'], - 'keep' => @$rs['AUTHOR_KEEP'], - 'max_keep' => @$rs['AUTHOR_MAX_KEEP'] - ); + foreach (array('major','minor','author') as $major) { + foreach (array('max_age','min_age','min_keep','keep','max_keep') as $max) { + $item = strtoupper($major) . '_'. strtoupper($max); + if (defined($item)) $val = constant($item); + elseif (array_key_exists($item, $rs)) + $val = $rs[$item]; + elseif (array_key_exists($item, $rsdef)) + $val = $rsdef[$item]; + if (!isset($ExpireParams[$major])) + $ExpireParams[$major] = array(); + $ExpireParams[$major][$max] = $val; + } + } // User authentication if (!isset($GLOBALS['USER_AUTH_ORDER'])) if (isset($rs['USER_AUTH_ORDER'])) - $GLOBALS['USER_AUTH_ORDER'] = preg_split('/\s*:\s*/', $rs['USER_AUTH_ORDER']); + $GLOBALS['USER_AUTH_ORDER'] = preg_split('/\s*:\s*/', + $rs['USER_AUTH_ORDER']); else $GLOBALS['USER_AUTH_ORDER'] = array("PersonalPage"); // LDAP bind options global $LDAP_SET_OPTION; - if (isset($rs['LDAP_SET_OPTION'])) { - $optlist = preg_split('/\s*:\s*/', @$rs['LDAP_SET_OPTION']); + if (defined('LDAP_SET_OPTION') and LDAP_SET_OPTION) { + $optlist = preg_split('/\s*:\s*/', LDAP_SET_OPTION); foreach ($optlist as $opt) { $bits = preg_split('/\s*=\s*/', $opt, 2); if (count($bits) == 2) { + if (is_string($bits[0]) and defined($bits[0])) + $bits[0] = constant($bits[0]); $LDAP_SET_OPTION[$bits[0]] = $bits[1]; } else { @@ -294,7 +303,10 @@ function IniConfig($file) { $KeywordLinkRegexp = '(?<=' . implode('|^', $keywords) . ')[[:upper:]].*$'; global $DisabledActions; - $DisabledActions = preg_split('/\s*:\s*/', @$rs['DISABLED_ACTIONS']); + if (!array_key_exists('DISABLED_ACTIONS',$rs) and array_key_exists('DISABLED_ACTIONS',$rsdef)) + $rs['DISABLED_ACTIONS'] = @$rsdef['DISABLED_ACTIONS']; + if (array_key_exists('DISABLED_ACTIONS',$rs)) + $DisabledActions = preg_split('/\s*:\s*/', $rs['DISABLED_ACTIONS']); /*global $AllowedProtocols, $InlineImages; $AllowedProtocols = constant("ALLOWED_PROTOCOLS"); @@ -322,7 +334,7 @@ function IniConfig($file) { // moved from lib/config.php function fix_configs() { global $FieldSeparator, $charset, $WikiNameRegexp, $KeywordLinkRegexp, $AllActionPages; - global $DisabledActions, $HTTP_SERVER_VARS, $DBParams, $LANG; + global $HTTP_SERVER_VARS, $DBParams, $LANG; // init FileFinder to add proper include paths require_once(dirname(__FILE__)."/FileFinder.php"); @@ -334,8 +346,9 @@ function fix_configs() { // $FieldSeparator = "\xFF"; // this byte should never appear in utf-8 // FIXME: get rid of constant. pref is dynamic and language specific $charset = CHARSET; - if (isset($LANG) and in_array($LANG,array('ja','zh'))) - $charset = 'utf-8'; + // Disabled: Let the admin decide which charset. + //if (isset($LANG) and in_array($LANG,array('zh'))) + // $charset = 'utf-8'; if (strtolower($charset) == 'utf-8') $FieldSeparator = "\xFF"; else @@ -385,12 +398,14 @@ function fix_configs() { $WikiNameRegexp = pcre_fix_posix_classes($WikiNameRegexp); $KeywordLinkRegexp = pcre_fix_posix_classes($KeywordLinkRegexp); - $AllActionPages = explode(':','AllPages:BackLinks:DebugInfo:EditMetaData:FindPage:FullRecentChanges:' - .'FullTextSearch:FuzzyPages:InterWikiSearch:LikePages:MostPopular:' + $AllActionPages = explode(':', + 'AllPages:BackLinks:CreatePage:DebugInfo:EditMetaData:FindPage:' + .'FullRecentChanges:FullTextSearch:FuzzyPages:InterWikiSearch:' + .'LikePages:MostPopular:' .'OrphanedPages:PageDump:PageHistory:PageInfo:RandomPage:RateIt:' - .'RecentChanges:RecentEdits:RelatedChanges:TitleSearch:TranslateText:' - .'UpLoad:UserPreferences:WantedPages:WhoIsOnline:' - .'PhpWikiAdministration/Remove:' + .'RecentChanges:RecentEdits:RecentComments:RelatedChanges:TitleSearch:' + .'TranslateText:UpLoad:UserPreferences:WantedPages:WhoIsOnline:' + .'PhpWikiAdministration/Remove:PhpWikiAdministration/Chmod:' .'PhpWikiAdministration/Rename:PhpWikiAdministration/Replace:' .'PhpWikiAdministration/SetAcl:PhpWikiAdministration/Chown' ); @@ -592,6 +607,9 @@ function fix_configs() { } // $Log: not supported by cvs2svn $ +// Revision 1.40 2004/06/22 07:12:48 rurban +// removed USE_TAGLINES constant +// // Revision 1.39 2004/06/21 16:22:28 rurban // add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps, // fixed dumping buttons locally (images/buttons/), diff --git a/lib/InlineParser.php b/lib/InlineParser.php index c00c18322..90fe331a2 100644 --- a/lib/InlineParser.php +++ b/lib/InlineParser.php @@ -1,5 +1,5 @@ * Copyright (C) 2004 Reini Urban * @@ -156,7 +156,7 @@ class RegexpSet $matched = array(); $matched_ind = array(); for ($i=0; $i 2) { + assert(!empty($repeat)); + assert(!empty($regexps)); + for ($i=0; $isupportedArgs() which arguments are supported, so that the plugin - * doesn't explictly need to declare it + * doesn't explictly need to declare it + * Status: already merged in some plugins calls + * * new method: * list not as
    or table, but as simple comma-seperated list + * + * fix memory exhaustion on large pagelists. + * Status: fixed 2004-06-25 16:19:36 rurban but needs further testing. */ class _PageList_Column_base { var $_tdattr = array(); @@ -456,6 +462,7 @@ class _PageList_Column_pagename extends _PageList_Column_base { * This is a hack necessitated by the interface to usort()-- comparators * can't get information upon construction; you get a comparator by class * name, not by instance. + * @author: Dan Frankowski */ class _PageList_Page { var $_pagelist; @@ -1238,6 +1245,9 @@ extends PageList { } // $Log: not supported by cvs2svn $ +// Revision 1.92 2004/06/21 17:01:39 rurban +// fix typo and rating method call +// // Revision 1.91 2004/06/21 16:22:29 rurban // add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps, // fixed dumping buttons locally (images/buttons/), diff --git a/lib/PagePerm.php b/lib/PagePerm.php index 67823ad4b..a3b804d6b 100644 --- a/lib/PagePerm.php +++ b/lib/PagePerm.php @@ -1,5 +1,5 @@ _group = &WikiGroup::getGroup(); + $this->_group = &$GLOBALS['request']->getGroup(); if (is_array($hash) and !empty($hash)) { $accessTypes = $this->accessTypes(); foreach ($hash as $access => $requires) { @@ -358,7 +358,7 @@ class PagePermission { function isMember($user, $group) { global $request; if ($group === ACL_EVERY) return true; - if (!isset($this->_group)) $member =& WikiGroup::getGroup(); + if (!isset($this->_group)) $member =& $request->getGroup(); else $member =& $this->_group; //$user = & $request->_user; if ($group === ACL_ADMIN) // WIKI_ADMIN or member of _("Administrators") @@ -525,7 +525,7 @@ class PagePermission { function asEditableTable($type) { global $WikiTheme; if (!isset($this->_group)) { - $this->_group =& WikiGroup::getGroup(); + $this->_group =& $GLOBALS['request']->getGroup(); } $table = HTML::table(); $table->pushContent(HTML::tr( @@ -699,6 +699,15 @@ class PagePermission { } // $Log: not supported by cvs2svn $ +// Revision 1.27 2004/06/16 10:38:58 rurban +// Disallow refernces in calls if the declaration is a reference +// ("allow_call_time_pass_reference clean"). +// PhpWiki is now allow_call_time_pass_reference = Off clean, +// but several external libraries may not. +// In detail these libs look to be affected (not tested): +// * Pear_DB odbc +// * adodb oracle +// // Revision 1.26 2004/06/14 11:31:36 rurban // renamed global $Theme to $WikiTheme (gforge nameclash) // inherit PageList default options from PageList diff --git a/lib/Request.php b/lib/Request.php index f885940dc..3c8bcfc7b 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -1,5 +1,5 @@ _HomePagehandle); unset($val->_auth_dbi); + if (isset($val->_group)) { + unset($val->_group->_request); + unset($val->_group->_user); + } } } if (!function_usable('get_cfg_var') or get_cfg_var('register_globals')) { @@ -872,10 +876,10 @@ class HTTP_ETag { // Possible results from the HTTP_ValidatorSet::_check*() methods. // (Higher numerical values take precedence.) -define ('_HTTP_VAL_PASS', 0); // Test is irrelevant -define ('_HTTP_VAL_NOT_MODIFIED', 1); // Test passed, content not changed -define ('_HTTP_VAL_MODIFIED', 2); // Test failed, content changed -define ('_HTTP_VAL_FAILED', 3); // Precondition failed. +define ('_HTTP_VAL_PASS', 0); // Test is irrelevant +define ('_HTTP_VAL_NOT_MODIFIED', 1); // Test passed, content not changed +define ('_HTTP_VAL_MODIFIED', 2); // Test failed, content changed +define ('_HTTP_VAL_FAILED', 3); // Precondition failed. class HTTP_ValidatorSet { function HTTP_ValidatorSet($validators) { @@ -989,6 +993,9 @@ class HTTP_ValidatorSet { // $Log: not supported by cvs2svn $ +// Revision 1.60 2004/06/19 11:51:13 rurban +// CACHE_CONTROL: NONE => NO_CACHE +// // Revision 1.59 2004/06/13 11:34:22 rurban // fixed bug #969532 (space in uploaded filenames) // improved upload error messages diff --git a/lib/Template.php b/lib/Template.php index c95f2e943..40dc18134 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -1,5 +1,5 @@ _expandSubtemplate($val); - else + } else { PrintXML($val); + } } function _expandSubtemplate (&$template) { @@ -255,6 +256,14 @@ function GeneratePageasXML($content, $title, $page_revision = false, $args = fal } // $Log: not supported by cvs2svn $ +// Revision 1.60 2004/06/14 11:31:36 rurban +// renamed global $Theme to $WikiTheme (gforge nameclash) +// inherit PageList default options from PageList +// default sortby=pagename +// use options in PageList_Selectable (limit, sortby, ...) +// added action revert, with button at action=diff +// added option regex to WikiAdminSearchReplace +// // Revision 1.59 2004/05/18 16:23:39 rurban // rename split_pagename to SplitPagename // diff --git a/lib/WikiGroup.php b/lib/WikiGroup.php index 4c7f1bb79..33c2ab066 100644 --- a/lib/WikiGroup.php +++ b/lib/WikiGroup.php @@ -1,5 +1,5 @@ request = &$GLOBALS['request']; + function WikiGroup($not_current = false) { + $this->not_current = $not_current; + $this->request =& $GLOBALS['request']; } /** - * Gets the current username and erases $this->membership if is different than + * Gets the current username from the internal user object + * and erases $this->membership if is different than * the stored $this->username * @return string Current username. */ @@ -86,6 +90,8 @@ class WikiGroup{ $this->membership = array(); $this->username = $username; } + if (!$this->not_current) + $this->user = $user; return $username; } @@ -95,19 +101,19 @@ class WikiGroup{ * @param object $request The global WikiRequest object. * @return object Subclass of WikiGroup selected via GROUP_METHOD. */ - function getGroup(){ + function getGroup($not_current = false){ switch (GROUP_METHOD){ case "NONE": - return new GroupNone(); + return new GroupNone($not_current); break; case "WIKIPAGE": - return new GroupWikiPage(); + return new GroupWikiPage($not_current); break; case "DB": if ($GLOBALS['DBParams']['dbtype'] == 'ADODB') { - return new GroupDB_ADODB(); + return new GroupDB_ADODB($not_current); } elseif ($GLOBALS['DBParams']['dbtype'] == 'SQL') { - return new GroupDb_PearDB(); + return new GroupDb_PearDB($not_current); } else { trigger_error("GROUP_METHOD = DB: Unsupported dbtype " . $GLOBALS['DBParams']['dbtype'], @@ -115,25 +121,28 @@ class WikiGroup{ } break; case "FILE": - return new GroupFile(); + return new GroupFile($not_current); break; case "LDAP": - return new GroupLDAP(); + return new GroupLDAP($not_current); break; default: trigger_error(_("No or unsupported GROUP_METHOD defined"), E_USER_WARNING); - return new WikiGroup(); + return new WikiGroup($not_current); } } - /* ACL PagePermissions will need those special groups based on the User status only */ + /** ACL PagePermissions will need those special groups based on the User status only. + * translated + */ function specialGroup($group){ return in_array($group,$this->specialGroups()); } + /** untranslated */ function _specialGroup($group){ return in_array($group,$this->_specialGroups()); } - + /** translated */ function specialGroups(){ return array( GROUP_EVERY, @@ -143,6 +152,7 @@ class WikiGroup{ GROUP_AUTHENTICATED, GROUP_ADMIN); } + /** untranslated */ function _specialGroups(){ return array( "_EVERY", @@ -165,8 +175,20 @@ class WikiGroup{ if (isset($this->membership[$group])) return $this->membership[$group]; if ($this->specialGroup($group)) { - $user = (!empty($this->user)) ? $this->user : $this->request->getUser(); - switch ($group) { + return $this->isSpecialMember($group); + } else { + trigger_error(__sprintf("Method '%s' not implemented in this GROUP_METHOD %s", + 'isMember', GROUP_METHOD), + E_USER_WARNING); + } + return false; + } + + function isSpecialMember($group){ + if (isset($this->membership[$group])) + return $this->membership[$group]; + $user = (!empty($this->user)) ? $this->user : $this->request->getUser(); + switch ($group) { case GROUP_EVERY: return $this->membership[$group] = true; case GROUP_ANONYMOUS: @@ -184,11 +206,6 @@ class WikiGroup{ trigger_error(__sprintf("Undefined method %s for special group %s", 'isMember',$group), E_USER_WARNING); - } - } else { - trigger_error(__sprintf("Method '%s' not implemented in this GROUP_METHOD %s", - 'isMember', GROUP_METHOD), - E_USER_WARNING); } return false; } @@ -228,7 +245,7 @@ class WikiGroup{ $sql = preg_replace('/SELECT .+ FROM/i','SELECT userid FROM', $GLOBALS['DBAuthParams']['pref_select']); //don't strip WHERE, only the userid stuff. - $sql = preg_replace('/(WHERE.*?)\s+\w+\s*=\s*"\$userid"/i','\\1 AND 1',$sql); + $sql = preg_replace('/(WHERE.*?)\s+\w+\s*=\s*["\']\$userid[\'"]/i','\\1 AND 1',$sql); $sql = str_replace('WHERE AND 1','',$sql); if ($GLOBALS['DBParams']['dbtype'] == 'ADODB') { $db_result = $dbi->Execute($sql); @@ -244,7 +261,7 @@ class WikiGroup{ // Fixme: don't strip WHERE, only the userid stuff. if ($dbi and !empty($GLOBALS['DBAuthParams']['auth_user_exists'])) { //don't strip WHERE, only the userid stuff. - $sql = preg_replace('/(WHERE.*?)\s+\w+\s*=\s*"\$userid"/i','\\1 AND 1', + $sql = preg_replace('/(WHERE.*?)\s+\w+\s*=\s*["\']\$userid[\'"]/i','\\1 AND 1', $GLOBALS['DBAuthParams']['auth_user_exists']); $sql = str_replace('WHERE AND 1','',$sql); if ($GLOBALS['DBParams']['dbtype'] == 'ADODB') { @@ -276,48 +293,51 @@ class WikiGroup{ */ function getMembersOf($group){ if ($this->specialGroup($group)) { - //$request = &$this->request; - $all = $this->_allUsers(); - $users = array(); - switch ($group) { - case GROUP_EVERY: - return $all; - case GROUP_ANONYMOUS: - return $users; - case GROUP_BOGOUSER: - foreach ($all as $u) { - if (isWikiWord($user)) $users[] = $u; - } - return $users; - case GROUP_SIGNED: - foreach ($all as $u) { - $user = WikiUser($u); - if ($user->isSignedIn()) $users[] = $u; - } - return $users; - case GROUP_AUTHENTICATED: - foreach ($all as $u) { - $user = WikiUser($u); - if ($user->isAuthenticated()) $users[] = $u; - } - return $users; - case GROUP_ADMIN: - foreach ($all as $u) { - $user = WikiUser($u); - if ($user->isAdmin()) $users[] = $u; - } - return $users; - default: - trigger_error(__sprintf("Method '%s' not implemented in this GROUP_METHOD %s", - 'getMembersOf', GROUP_METHOD), - E_USER_WARNING); - } - } + return getSpecialMembersOf($group); + } trigger_error(__sprintf("Method '%s' not implemented in this GROUP_METHOD %s", 'getMembersOf', GROUP_METHOD), E_USER_WARNING); return array(); } + + function getSpecialMembersOf($group) { + //$request = &$this->request; + $all = $this->_allUsers(); + $users = array(); + switch ($group) { + case GROUP_EVERY: + return $all; + case GROUP_ANONYMOUS: + return $users; + case GROUP_BOGOUSER: + foreach ($all as $u) { + if (isWikiWord($user)) $users[] = $u; + } + return $users; + case GROUP_SIGNED: + foreach ($all as $u) { + $user = WikiUser($u); + if ($user->isSignedIn()) $users[] = $u; + } + return $users; + case GROUP_AUTHENTICATED: + foreach ($all as $u) { + $user = WikiUser($u); + if ($user->isAuthenticated()) $users[] = $u; + } + return $users; + case GROUP_ADMIN: + foreach ($all as $u) { + $user = WikiUser($u); + if ($user->isAdmin()) $users[] = $u; + } + return $users; + default: + trigger_error(__sprintf("Unknown special group '%s'", $group), + E_USER_WARNING); + } + } /** * Add the current or specified user to a group. @@ -381,7 +401,7 @@ class GroupNone extends WikiGroup{ */ function isMember($group){ if ($this->specialGroup($group)) { - return WikiGroup::isMember($group); + return $this->isSpecialMember($group); } else { return false; } @@ -455,8 +475,9 @@ class GroupWikiPage extends WikiGroup{ } $this->membership[$group] = false; // Let grouppages override certain defaults, such as members of admin - if ($this->specialGroup($group)) - return WikiGroup::isMember($group); + if ($this->specialGroup($group)) { + return $this->isSpecialMember($group); + } return false; } @@ -467,7 +488,7 @@ class GroupWikiPage extends WikiGroup{ * @return boolean True if user is a member, else false. * @access private */ - function _inGroupPage($group_page,$strict=false){ + function _inGroupPage($group_page, $strict=false){ $group_revision = $group_page->getCurrentRevision(); if ($group_revision->hasDefaultContents()) { $group = $group_page->getName(); @@ -498,7 +519,7 @@ class GroupWikiPage extends WikiGroup{ $specialgroups = $this->specialGroups(); foreach ($specialgroups as $group) { - $this->membership[$group] = $this->isMember($group); + $this->membership[$group] = $this->isSpecialMember($group); } $dbh = &$this->request->getDbh(); @@ -524,7 +545,7 @@ class GroupWikiPage extends WikiGroup{ */ function getMembersOf($group){ if ($this->specialGroup($group)) - return WikiGroup::getMembersOf($group); + return $this->getSpecialMembersOf($group); trigger_error("GroupWikiPage::getMembersOf is not yet implimented", E_USER_WARNING); @@ -625,7 +646,7 @@ class GroupDb_PearDB extends GroupDb { $this->membership[$group] = false; // Let override certain defaults, such as members of admin if ($this->specialGroup($group)) - return WikiGroup::isMember($group); + return $this->isSpecialMember($group); return false; } @@ -676,7 +697,7 @@ class GroupDb_PearDB extends GroupDb { } // add certain defaults, such as members of admin if ($this->specialGroup($group)) - $members = array_merge($members, WikiGroup::getMembersOf($group)); + $members = array_merge($members, $this->getSpecialMembersOf($group)); return $members; } } @@ -712,7 +733,7 @@ class GroupDb_ADODB extends GroupDb { } $this->membership[$group] = false; if ($this->specialGroup($group)) - return WikiGroup::isMember($group); + return $this->isSpecialMember($group); return false; } @@ -766,7 +787,7 @@ class GroupDb_ADODB extends GroupDb { $rs->Close(); // add certain defaults, such as members of admin if ($this->specialGroup($group)) - $members = array_merge($members,WikiGroup::getMembersOf($group)); + $members = array_merge($members, $this->getSpecialMembersOf($group)); return $members; } } @@ -831,7 +852,7 @@ class GroupFile extends WikiGroup { } $this->membership[$group] = false; if ($this->specialGroup($group)) - return WikiGroup::isMember($group); + return $this->isSpecialMember($group); return false; } @@ -878,7 +899,7 @@ class GroupFile extends WikiGroup { $members = explode(' ',$this->_file->users[$group]); } if ($this->specialGroup($group)) { - $members = array_merge($members,WikiGroup::getMembersOf($group)); + $members = array_merge($members, $this->getSpecialMembersOf($group)); } return $members; } @@ -931,7 +952,7 @@ class GroupLdap extends WikiGroup { */ function isMember($group) { if ($this->specialGroup($group)) - return WikiGroup::isMember($group); + return $this->isSpecialMember($group); if (isset($this->membership[$group])) { return $this->membership[$group]; @@ -1029,7 +1050,7 @@ class GroupLdap extends WikiGroup { */ function getMembersOf($group){ if ($this->specialGroup($group)) - return WikiGroup::getMembersOf($group); + return $this->getSpecialMembersOf($group); $members = array(); if ($ldap = ldap_connect(LDAP_AUTH_HOST)) { // must be a valid LDAP server! @@ -1052,6 +1073,9 @@ class GroupLdap extends WikiGroup { } // $Log: not supported by cvs2svn $ +// Revision 1.36 2004/06/16 13:21:05 rurban +// stabilize on failing ldap queries or bind +// // Revision 1.35 2004/06/16 12:08:25 rurban // better desc // diff --git a/lib/WikiUserNew.php b/lib/WikiUserNew.php index 63c30b439..d65803378 100644 --- a/lib/WikiUserNew.php +++ b/lib/WikiUserNew.php @@ -1,5 +1,5 @@ _level == WIKIAUTH_ADMIN) return true; - if (!$group) $group = &WikiGroup::getGroup(); + if (!$group) $group = &$GLOBALS['request']->getGroup(); return ($this->_level > WIKIAUTH_BOGO and $group->isMember(GROUP_ADMIN)); } @@ -584,7 +584,7 @@ class _WikiUser $class = "_" . $this->_current_method . "PassUser"; $user = new $class($userid,$this->_prefs); /*PHP5 patch*/$this = $user; - $this->_level = $authlevel; + $user->_level = $authlevel; return $user; } $this->_userid = $userid; @@ -1344,7 +1344,8 @@ extends _PassUser $stored_password = $this->_prefs->get('passwd'); if (empty($stored_password)) { trigger_error(sprintf( - _("\nYou stored an empty password in your '%s' page.\n"). + _("PersonalPage login method:\n"). + _("You stored an empty password in your '%s' page.\n"). _("Your access permissions are only for a BogoUser.\n"). _("Please set your password in UserPreferences."), $this->_userid), E_USER_WARNING); @@ -2012,8 +2013,45 @@ extends _PassUser * Preferences are handled in _PassUser */ { + + function _init() { + if ($this->_ldap = ldap_connect(LDAP_AUTH_HOST)) { // must be a valid LDAP server! + global $LDAP_SET_OPTION; + if (!empty($LDAP_SET_OPTION)) { + foreach ($LDAP_SET_OPTION as $key => $value) { + //if (is_string($key) and defined($key)) + // $key = constant($key); + ldap_set_option($this->_ldap, $key, $value); + } + } + if (LDAP_AUTH_USER) + if (LDAP_AUTH_PASSWORD) + // Windows Active Directory Server is strict + $r = ldap_bind($this->_ldap, LDAP_AUTH_USER, LDAP_AUTH_PASSWORD); + else + $r = ldap_bind($this->_ldap, LDAP_AUTH_USER); + else + $r = true; // anonymous bind allowed + if (!$r) { + $this->_free(); + trigger_error(sprintf("Unable to bind LDAP server %s", LDAP_AUTH_HOST), + E_USER_WARNING); + return false; + } + return $this->_ldap; + } else { + return false; + } + } + + function _free() { + if (is_resource($this->_sr)) ldap_free_result($this->_sr); + if (is_resource($this->_ldap)) ldap_close($this->_ldap); + unset($this->_sr); + unset($this->_ldap); + } + function checkPass($submitted_password) { - global $LDAP_SET_OPTION; $this->_authmethod = 'LDAP'; $userid = $this->_userid; @@ -2026,36 +2064,15 @@ extends _PassUser return WIKIAUTH_FORBIDDEN; } - if ($ldap = ldap_connect(LDAP_AUTH_HOST)) { // must be a valid LDAP server! - if (!empty($LDAP_SET_OPTION)) { - foreach ($LDAP_SET_OPTION as $key => $value) { - if (is_string($key) and defined($key)) - $key = constant($key); - ldap_set_option($ldap, $key, $value); - } - } - if (defined('LDAP_AUTH_USER')) - if (defined('LDAP_AUTH_PASSWORD')) - // Windows Active Directory Server is strict - $r = @ldap_bind($ldap, LDAP_AUTH_USER, LDAP_AUTH_PASSWORD); - else - $r = @ldap_bind($ldap, LDAP_AUTH_USER); - else - $r = @ldap_bind($ldap); // this is an anonymous bind - if (!$r) { - ldap_close($ldap); - trigger_error(fmt("Unable to bind LDAP server %s", LDAP_AUTH_HOST), - E_USER_WARNING); - return $this->_tryNextPass($submitted_password); - } + if ($ldap = $this->_init()) { // Need to set the right root search information. See config/config.ini - $st_search = defined('LDAP_SEARCH_FIELD') + $st_search = LDAP_SEARCH_FIELD ? LDAP_SEARCH_FIELD."=$userid" : "uid=$userid"; - $sr = ldap_search($ldap, LDAP_BASE_DN, $st_search); - $info = ldap_get_entries($ldap, $sr); + $this->_sr = ldap_search($ldap, LDAP_BASE_DN, $st_search); + $info = ldap_get_entries($ldap, $this->_sr); if (empty($info["count"])) { - ldap_close($ldap); + $this->_free(); return $this->_tryNextPass($submitted_password); } // there may be more hits with this userid. @@ -2063,70 +2080,40 @@ extends _PassUser for ($i = 0; $i < $info["count"]; $i++) { $dn = $info[$i]["dn"]; // The password is still plain text. - if ($r = @ldap_bind($ldap, $dn, $submitted_password)) { + if ($r = ldap_bind($ldap, $dn, $submitted_password)) { // ldap_bind will return TRUE if everything matches - ldap_close($ldap); + $this->_free(); $this->_level = WIKIAUTH_USER; return $this->_level; } } - } else { - trigger_error(fmt("Unable to connect to LDAP server %s", LDAP_AUTH_HOST), - E_USER_WARNING); - //return false; + $this->_free(); } return $this->_tryNextPass($submitted_password); } function userExists() { - global $LDAP_SET_OPTION; - $userid = $this->_userid; if (strstr($userid,'*')) { trigger_error(fmt("Invalid username '%s' for LDAP Auth", $userid), E_USER_WARNING); return false; } - if ($ldap = ldap_connect(LDAP_AUTH_HOST)) { // must be a valid LDAP server! - if (!empty($LDAP_SET_OPTION)) { - foreach ($LDAP_SET_OPTION as $key => $value) { - if (is_string($key) and defined($key)) - $key = constant($key); - ldap_set_option($ldap, $key, $value); - } - } - if (defined('LDAP_AUTH_USER')) - if (defined('LDAP_AUTH_PASSWORD')) - // Windows Active Directory Server is strict - $r = @ldap_bind($ldap, LDAP_AUTH_USER, LDAP_AUTH_PASSWORD); - else - $r = @ldap_bind($ldap,LDAP_AUTH_USER); - else - $r = @ldap_bind($ldap); // this is an anonymous bind - if (!$r) { - ldap_close($ldap); - trigger_error(fmt("Unable to bind LDAP server %s", LDAP_AUTH_HOST), - E_USER_WARNING); - return $this->_tryNextPass($submitted_password); - } - + if ($ldap = $this->_init()) { // Need to set the right root search information. see ../index.php - $st_search = defined('LDAP_SEARCH_FIELD') + $st_search = LDAP_SEARCH_FIELD ? LDAP_SEARCH_FIELD."=$userid" : "uid=$userid"; - $sr = ldap_search($ldap, LDAP_BASE_DN, $st_search); - $info = ldap_get_entries($ldap, $sr); + $this->_sr = ldap_search($ldap, LDAP_BASE_DN, $st_search); + $info = ldap_get_entries($ldap, $this->_sr); if ($info["count"] > 0) { - ldap_close($ldap); + $this->_free(); return true; } - } else { - trigger_error(_("Unable to connect to LDAP server "). LDAP_AUTH_HOST, - E_USER_WARNING); } - + $this->_free(); return $this->_tryNextUser(); } @@ -3045,6 +3032,9 @@ extends UserPreferences // $Log: not supported by cvs2svn $ +// Revision 1.100 2004/06/21 06:29:35 rurban +// formatting: linewrap only +// // Revision 1.99 2004/06/20 15:30:05 rurban // get_class case-sensitivity issues // diff --git a/lib/display.php b/lib/display.php index 336b295b1..4ad270031 100644 --- a/lib/display.php +++ b/lib/display.php @@ -1,6 +1,6 @@ getTransformedContent(); $template = Template('browse', array('CONTENT' => $transformedContent)); - header("Content-Type: text/html; charset=" . $GLOBALS['charset']); + if (!headers_sent()) { + //FIXME: does not work yet. document.write not supported (signout button) + // http://www.w3.org/People/mimasa/test/xhtml/media-types/results + if (ENABLE_XHTML_XML + and (!isBrowserIE() and + strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml'))) + header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']); + else + header("Content-Type: text/html; charset=" . $GLOBALS['charset']); + } GeneratePage($template, $pagetitle, $revision); $request->checkValidators(); flush(); @@ -126,9 +135,16 @@ function displayPage(&$request, $template=false) { $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime'))); - // FIXME: should probably be in a template... - if ($request->getArg('action') != 'pdf') - header("Content-Type: text/html; charset=" . $GLOBALS['charset']); // FIXME: this gets done twice? + // FIXME: This is also in the template... + if ($request->getArg('action') != 'pdf' and !headers_sent()) { + // FIXME: enable MathML/SVG/... support + if (ENABLE_XHTML_XML + and (!isBrowserIE() + and strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml'))) + header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']); + else + header("Content-Type: text/html; charset=" . $GLOBALS['charset']); + } $page_content = $revision->getTransformedContent(); @@ -154,6 +170,14 @@ function displayPage(&$request, $template=false) { flush(); } // $Log: not supported by cvs2svn $ +// Revision 1.52 2004/06/14 11:31:37 rurban +// renamed global $Theme to $WikiTheme (gforge nameclash) +// inherit PageList default options from PageList +// default sortby=pagename +// use options in PageList_Selectable (limit, sortby, ...) +// added action revert, with button at action=diff +// added option regex to WikiAdminSearchReplace +// // Revision 1.51 2004/05/18 16:23:39 rurban // rename split_pagename to SplitPagename // diff --git a/lib/loadsave.php b/lib/loadsave.php index b15a354e2..ad5b35574 100644 --- a/lib/loadsave.php +++ b/lib/loadsave.php @@ -1,5 +1,5 @@ pushErrorHandler(new WikiFunctionCb('_dump_error_handler')); } @@ -1041,6 +1041,9 @@ function LoadPostFile (&$request) /** $Log: not supported by cvs2svn $ + Revision 1.111 2004/06/21 16:38:55 rurban + fixed the StartLoadDump html argument hack. + Revision 1.110 2004/06/21 16:22:30 rurban add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps, fixed dumping buttons locally (images/buttons/), diff --git a/lib/main.php b/lib/main.php index 0603923e2..93974f425 100644 --- a/lib/main.php +++ b/lib/main.php @@ -1,5 +1,5 @@ version = phpwiki_version(); { include_once("themes/" . THEME . "/themeinfo.php"); } - if (empty($WikiTheme) and isset($user_theme)) + if (empty($WikiTheme) and isset($user_theme)) { + if (strcspn($user_theme,"./\x00]") != strlen($user_theme)) { + trigger_error(sprintf("invalid theme '%s': Invalid characetsr detected", $user_theme), + E_USER_WARNING); + $user_theme = "default"; + } include_once("themes/$user_theme/themeinfo.php"); + } if (empty($WikiTheme) and defined('THEME')) include_once("themes/" . THEME . "/themeinfo.php"); if (empty($WikiTheme)) @@ -175,6 +181,13 @@ $this->version = phpwiki_version(); else return $GLOBALS['ForbiddenUser']; } + + function & getGroup () { + if (isset($this->_user) and isset($this->_user->_group)) + return $this->_user->_group; + else + return WikiGroup::getGroup(); + } function getPrefs () { return $this->_prefs; @@ -186,7 +199,6 @@ $this->version = phpwiki_version(); return $this->_prefs->get($key); } } - function getDbh () { return $this->_dbi; } @@ -295,7 +307,6 @@ $this->version = phpwiki_version(); define('MAIN_setUser',true); $this->setCookieVar('WIKI_ID', $user->getAuthenticatedId(), COOKIE_EXPIRATION_DAYS, COOKIE_DOMAIN); - $this->setSessionVar('wiki_user', $user); if ($user->isSignedIn()) $user->_authhow = 'signin'; @@ -304,6 +315,15 @@ $this->version = phpwiki_version(); $this->_user->_prefs = $this->_user->getPreferences(); $this->_prefs =& $this->_user->_prefs; } + $this->_user->_group = $this->getGroup(); + // avoid recursive objects and session resource handles + if (isset($user->_group)) { + unset($user->_group->_request); + unset($user->_group->_user); + } + unset($user->_HomePagehandle); + unset($user->_auth_dbi); + $this->setSessionVar('wiki_user', $user); $this->_prefs->set('userid', $user->isSignedIn() ? $user->getId() : ''); $this->initializeTheme(); @@ -450,6 +470,10 @@ $this->version = phpwiki_version(); } function requiredAuthorityForAction ($action) { + global $DisabledActions; + if ($DisabledActions and in_array($action,$DisabledActions)) + return WIKIAUTH_UNOBTAINABLE; + if (ENABLE_PAGEPERM and class_exists("PagePermission")) { return requiredAuthorityForPage($action); } else { @@ -979,15 +1003,15 @@ function main () { // Postpone warnings global $ErrorManager; - $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE|E_USER_WARNING); + $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE|E_USER_WARNING|E_WARNING); $request = new WikiRequest(); $action = $request->getArg('action'); if (substr($action, 0, 3) != 'zip') { if ($action == 'pdf') $ErrorManager->setPostponedErrorMask(-1); - else // reject postponing of warnings - $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE); + //else // reject postponing of warnings + // $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE); } /* @@ -1046,6 +1070,9 @@ main(); // $Log: not supported by cvs2svn $ +// Revision 1.169 2004/06/20 14:42:54 rurban +// various php5 fixes (still broken at blockparser) +// // Revision 1.168 2004/06/17 10:39:18 rurban // fix reverse translation of possible actionpage // diff --git a/lib/plugin/AllUsers.php b/lib/plugin/AllUsers.php index c1dba15c4..13132b02f 100644 --- a/lib/plugin/AllUsers.php +++ b/lib/plugin/AllUsers.php @@ -1,5 +1,5 @@ getGroup(); $allusers = $group->_allUsers(); $args['count'] = count($allusers); // deleted pages show up as version 0. @@ -112,6 +112,15 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.13 2004/06/16 10:38:59 rurban +// Disallow refernces in calls if the declaration is a reference +// ("allow_call_time_pass_reference clean"). +// PhpWiki is now allow_call_time_pass_reference = Off clean, +// but several external libraries may not. +// In detail these libs look to be affected (not tested): +// * Pear_DB odbc +// * adodb oracle +// // Revision 1.12 2004/04/20 00:56:00 rurban // more paging support and paging fix for shorter lists // diff --git a/lib/plugin/WikiAdminUtils.php b/lib/plugin/WikiAdminUtils.php index 9cffda43e..9f48e3220 100644 --- a/lib/plugin/WikiAdminUtils.php +++ b/lib/plugin/WikiAdminUtils.php @@ -1,5 +1,5 @@ _user; if (empty($args['verify'])) { - $group = WikiGroup::getGroup(); + $group = $request->getGroup(); $allusers = $group->_allUsers(); } else { $allusers = array_keys($args['user']); diff --git a/lib/plugin/_AuthInfo.php b/lib/plugin/_AuthInfo.php index 9e173bc1a..ef10aea94 100644 --- a/lib/plugin/_AuthInfo.php +++ b/lib/plugin/_AuthInfo.php @@ -1,5 +1,5 @@ pushContent(HTML::tr(HTML::td(array('colspan' => 2)))); $userdata = obj2hash($user); $table->pushContent($this->_showhash("User: Object of ".get_class($user), $userdata)); - $group = &WikiGroup::getGroup(); + $group = &$request->getGroup(); $groups = $group->getAllGroupsIn(); $groupdata = obj2hash($group); unset($groupdata['request']); @@ -190,6 +190,15 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.15 2004/06/16 10:38:59 rurban +// Disallow refernces in calls if the declaration is a reference +// ("allow_call_time_pass_reference clean"). +// PhpWiki is now allow_call_time_pass_reference = Off clean, +// but several external libraries may not. +// In detail these libs look to be affected (not tested): +// * Pear_DB odbc +// * adodb oracle +// // Revision 1.14 2004/05/18 14:49:52 rurban // Simplified strings for easier translation // diff --git a/lib/stdlib.php b/lib/stdlib.php index a680f44be..4666e1485 100644 --- a/lib/stdlib.php +++ b/lib/stdlib.php @@ -1,4 +1,4 @@ -\[\]\"'()]*[^\s<>\[\]\"'(),.?]"; $bang_esc[] = $map->getRegexp() . ":[^\\s.,;?()]+"; // FIXME: is this really needed? @@ -688,9 +692,9 @@ function ConvertOldMarkup ($text, $markup_type = "block") { * special handling... */ + if (!$debug_skip) { // Indented blocks $blockpats[] = '[ \t]+\S(?:.*\s*\n[ \t]+\S)*'; - // Tables $blockpats[] = '\|(?:.*\n\|)*'; @@ -702,6 +706,7 @@ function ConvertOldMarkup ($text, $markup_type = "block") { // Plugins $blockpats[] = '<\?plugin(?:-form)?\b.*\?>\s*$'; + } // Section Title $blockpats[] = '!{1,3}[^!]'; @@ -719,7 +724,10 @@ function ConvertOldMarkup ($text, $markup_type = "block") { else { list ($orig, $repl) = $subs['inline']; $out = ''; - while (preg_match($block_re, $text, $m)) { + //FIXME: + // php crashes here in the 2nd paragraph of OldTextFormattingRules, + // AnciennesR%E8glesDeFormatage and more + while (preg_match($block_re, $text, $m)) { $text = substr($text, strlen($m[0])); list (,$leading_text, $block) = $m; $suffix = "\n"; @@ -772,11 +780,12 @@ function ConvertOldMarkup ($text, $markup_type = "block") { // AAck! assert(0); } - - $out .= ( preg_replace($orig, $repl, $leading_text) - . $prefix - . preg_replace($orig, $repl, $block) - . $suffix ); + if ($leading_text) $leading_text = preg_replace($orig, $repl, $leading_text); + if ($block) $leading_text = preg_replace($orig, $repl, $block); + $out .= $leading_text; + $out .= $prefix; + $out .= $block; + $out .= $suffix; } return $out . preg_replace($orig, $repl, $text); } @@ -1532,16 +1541,17 @@ function fixTitleEncoding( $s ) { '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ) : true ); */ $isutf = ($ishigh ? isUtf8String($s) : true); + $locharset = strtolower($charset); - if( (strtolower($charset) != "utf-8") and $ishigh and $isutf ) + if( $locharset != "utf-8" and $ishigh and $isutf ) // if charset == 'iso-8859-1' then simply use utf8_decode() - if (strtolower($charset) == 'iso-8859-1') + if ($locharset == 'iso-8859-1') return utf8_decode( $s ); else // TODO: check for iconv support return iconv( "UTF-8", $charset, $s ); - if( (strtolower($charset) == "utf-8") and $ishigh and !$isutf ) + if ($locharset == "utf-8" and $ishigh and !$isutf ) return utf8_encode( $s ); // Other languages can safely leave this function, or replace @@ -1594,6 +1604,9 @@ function url_get_contents( $uri ) { // $Log: not supported by cvs2svn $ +// Revision 1.189 2004/06/20 09:45:35 rurban +// php5 isa fix (wrong strtolower) +// // Revision 1.188 2004/06/16 10:38:58 rurban // Disallow refernces in calls if the declaration is a reference // ("allow_call_time_pass_reference clean"). diff --git a/themes/default/templates/head.tmpl b/themes/default/templates/head.tmpl index 8a458db02..a10c1e1c2 100644 --- a/themes/default/templates/head.tmpl +++ b/themes/default/templates/head.tmpl @@ -1,11 +1,11 @@ -get('HTTP_ACCEPT'),'application/xhtml+xml')) { ?> - +get('HTTP_ACCEPT'),'application/xhtml+xml')) { ?> + - + @@ -76,7 +76,7 @@ _("SandBox"))?>" /> _("WikiWikiWeb"))?>" /> -isadmin()) { +isAdmin()) { /* Only for the Administrator */ ?> " href="" /> @@ -111,77 +111,3 @@ _("UserPreferences"))?>" /> <?= WIKI_NAME.$pagetitle ?> getMoreHeaders() ?> - links in Mozilla/iCab were always linking -// to the english pages even when DEFAULT_LANGUAGE != 'en'. (Rewrapped -// text for a more complete xgettext string extraction: 'cd -// phpwiki/locale;make' to update po/mo files). -// -// Revision 1.10 2003/03/07 20:51:59 dairiki -// New feature: Automatic extraction of keywords (for the meta keywords tag) -// from Category* and Topic* links on each page. -// -// Revision 1.9 2003/03/07 02:45:51 dairiki -// Rename BASE_URL to PHPWIKI_BASE_URL. Lycos pre-defines BASE_URL (to -// the wrong thing). -// -// Revision 1.8 2003/03/05 21:38:15 dairiki -// More HTML comment reduction patches by "Klaus-Guenter Leiss" -// -// -// (With a few adjustments by me. Any bugs are probably my fault.) -// -// Revision 1.7 2003/02/26 22:27:17 dairiki -// Fix and refactor FrameInclude plugin (more or less). -// -// (This should now generate valid HTML. Woohoo!) -// -// The output when using the Sidebar theme is ugly enough that it should -// be considered broken. (But the Sidebar theme appears pretty broken in -// general right now.) -// -// (Personal comment (not to be taken personally): I must say that I -// remain unconvinced of the usefulness of this plugin.) -// -// Revision 1.6 2003/01/11 22:29:47 carstenklapp -// Tweak redundant bookmark title when browsing a custom home page with -// the same name as the wiki (i.e. avoid titles like "MyWiki - MyWiki" -// when HOME_PAGE==WIKI_NAME) -// -?> diff --git a/themes/default/templates/html.tmpl b/themes/default/templates/html.tmpl index 99c70edcb..993e55cfa 100644 --- a/themes/default/templates/html.tmpl +++ b/themes/default/templates/html.tmpl @@ -1,15 +1,12 @@ stuff. * * NS/MO/IE/Op Browsers before 4.0 don't like that. - * Better is IMHO: - if (strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml') or - (strstr($request->get('HTTP_ACCEPT'),'text/xml'))) */ if (browserVersion() >= 4.0) - printf("\n", CHARSET); + printf("\n", $charset); ?> diff --git a/themes/default/templates/signin.tmpl b/themes/default/templates/signin.tmpl index eb633aef6..a0228b3f0 100644 --- a/themes/default/templates/signin.tmpl +++ b/themes/default/templates/signin.tmpl @@ -1,5 +1,5 @@ isAuthenticated()) { $Sep = $WikiTheme->getButtonSeparator(); $SignOutB = $WikiTheme->makeButton(_("Sign Out"), "javascript:SignOut();", 'wikiaction'); -?> - getAuthenticatedId(), 'auto')) ?> - - + document.write(\''.AsXML($SignOutB).'\');'); +?> + getAuthenticatedId(), 'auto')) ?> + @@ -45,23 +44,21 @@ if ($user->isAuthenticated()) { 'onclick'=>'SignIn(document.forms["'.$FORMNAME.'"],"'.$userid.'");'), $userid))); } -?> - + }'); +?> + isAuthenticated()) { - + \ No newline at end of file diff --git a/themes/default/templates/userprefs.tmpl b/themes/default/templates/userprefs.tmpl index 769f1bb64..8b3340c3e 100644 --- a/themes/default/templates/userprefs.tmpl +++ b/themes/default/templates/userprefs.tmpl @@ -1,5 +1,5 @@ - + 'errors'), $errmsg),HTML::hr( -

    +

    -

    +

    -- 2.45.0