From: Arno H. <aho...@us...> - 2000-11-08 15:40:03
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18972 Modified Files: config.php stdlib.php editpage.php savepage.php transform.php Log Message: updates due to new admin structure Index: config.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** config.php 2000/11/01 10:24:58 1.14 --- config.php 2000/11/08 15:40:00 1.15 *************** *** 1,19 **** <?php if (!function_exists('rcs_id')) { function rcs_id($id) { echo "<!-- $id -->\n"; }; } rcs_id('$Id$'); ///////////////////////////////////////////////////////////////////// // Constants and settings. Edit the values below for your site. // URL of index.php e.g. http://yoursite.com/phpwiki/index.php // you can leave this empty - it will be calculated automatically $ScriptUrl = ""; // Select your language - default language "C": English // other languages available: Dutch "nl", Spanish "es" $LANG="C"; - ///////////////////////////////////////////////////////////////////// // Database section --- 1,30 ---- <?php + // essential internal stuff -- skip it + set_magic_quotes_runtime(0); + error_reporting(E_ALL ^ E_NOTICE); + if (!function_exists('rcs_id')) { function rcs_id($id) { echo "<!-- $id -->\n"; }; } rcs_id('$Id$'); + // end essential internal stuff + ///////////////////////////////////////////////////////////////////// // Constants and settings. Edit the values below for your site. + ///////////////////////////////////////////////////////////////////// + // URL of index.php e.g. http://yoursite.com/phpwiki/index.php // you can leave this empty - it will be calculated automatically $ScriptUrl = ""; + // URL of admin.php e.g. http://yoursite.com/phpwiki/admin.php + // you can leave this empty - it will be calculated automatically + // if you fill in $ScriptUrl you *MUST* fill in $AdminUrl as well! + $AdminUrl = ""; // Select your language - default language "C": English // other languages available: Dutch "nl", Spanish "es" $LANG="C"; ///////////////////////////////////////////////////////////////////// // Database section *************** *** 180,185 **** if (empty($ScriptUrl)) { ! $ScriptUrl = "http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME"; } $LogoImage = "<img src=\"$logo\" border=0 ALT=\"[PhpWiki!]\">"; --- 191,199 ---- if (empty($ScriptUrl)) { ! $port = ($SERVER_PORT == 80) ? '' : ":$SERVER_PORT"; ! $ScriptUrl = "http://$SERVER_NAME$port$SCRIPT_NAME"; } + if (defined('WIKI_ADMIN') && !empty($AdminUrl)) + $ScriptUrl = $AdminUrl; $LogoImage = "<img src=\"$logo\" border=0 ALT=\"[PhpWiki!]\">"; Index: stdlib.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** stdlib.php 2000/11/01 11:31:41 1.8 --- stdlib.php 2000/11/08 15:40:00 1.9 *************** *** 1,4 **** - <!-- $Id$ --> <?php /* Standard functions for Wiki functionality --- 1,4 ---- <?php + rcs_id('$Id$'); /* Standard functions for Wiki functionality *************** *** 38,42 **** print "\n</BODY></HTML>"; } ! exit(); } --- 38,42 ---- print "\n</BODY></HTML>"; } ! exit; } *************** *** 93,126 **** unset($hash); $page = join('', file($templates[$template])); ! $page = str_replace('###', "#$FieldSeparator#", $page); // valid for all pagetypes ! $page = str_replace("#$FieldSeparator#SCRIPTURL#$FieldSeparator#", ! $ScriptUrl, $page); ! $page = str_replace("#$FieldSeparator#PAGE#$FieldSeparator#", ! htmlspecialchars($name), $page); ! $page = str_replace("#$FieldSeparator#ALLOWEDPROTOCOLS#$FieldSeparator#", ! $AllowedProtocols, $page); ! $page = str_replace("#$FieldSeparator#LOGO#$FieldSeparator#", ! $logo, $page); ! // invalid for messages (search results, error messages) if ($template != 'MESSAGE') { ! $page = str_replace("#$FieldSeparator#PAGEURL#$FieldSeparator#", ! rawurlencode($name), $page); ! $page = str_replace("#$FieldSeparator#LASTMODIFIED#$FieldSeparator#", date($datetimeformat, $hash['lastmodified']), $page); ! $page = str_replace("#$FieldSeparator#LASTAUTHOR#$FieldSeparator#", ! $hash['author'], $page); ! $page = str_replace("#$FieldSeparator#VERSION#$FieldSeparator#", ! $hash['version'], $page); ! if (strstr($page, "#$FieldSeparator#HITS#$FieldSeparator#")) { ! $page = str_replace("#$FieldSeparator#HITS#$FieldSeparator#", ! GetHitCount($dbi, $name), $page); } ! if (strstr($page, "#$FieldSeparator#RELATEDPAGES#$FieldSeparator#")) { ! $page = str_replace("#$FieldSeparator#RELATEDPAGES#$FieldSeparator#", ! LinkRelatedPages($dbi, $name), $page); } } --- 93,155 ---- unset($hash); + function _dotoken ($id, $val, &$page) { + global $FieldSeparator; + $page = str_replace("$FieldSeparator#$id$FieldSeparator#", + $val, $page); + } + + function _iftoken ($id, $condition, &$page) { + global $FieldSeparator; + + // line based IF directive + $lineyes = "$FieldSeparator#IF $id$FieldSeparator#"; + $lineno = "$FieldSeparator#IF !$id$FieldSeparator#"; + // block based IF directive + $blockyes = "$FieldSeparator#IF:$id$FieldSeparator#"; + $blockyesend = "$FieldSeparator#ENDIF:$id$FieldSeparator#"; + $blockno = "$FieldSeparator#IF:!$id$FieldSeparator#"; + $blocknoend = "$FieldSeparator#ENDIF:!$id$FieldSeparator#"; + + if ($condition) { + $page = str_replace($lineyes, '', $page); + $page = str_replace($blockyes, '', $page); + $page = str_replace($blockyesend, '', $page); + $page = preg_replace("/$blockno(.*?)$blocknoend/s", '', $page); + $page = ereg_replace("{$lineno}[^\n]*\n", '', $page); + } else { + $page = str_replace($lineno, '', $page); + $page = str_replace($blockno, '', $page); + $page = str_replace($blocknoend, '', $page); + $page = preg_replace("/$blockyes(.*?)$blockyesend/s", '', $page); + $page = ereg_replace("{$lineyes}[^\n]*\n", '', $page); + } + } + $page = join('', file($templates[$template])); ! $page = str_replace('###', "$FieldSeparator#", $page); // valid for all pagetypes ! _iftoken('COPY', isset($hash['copy']), $page); ! _iftoken('LOCK', (isset($hash['flags']) && ! ($hash['flags'] & FLAG_PAGE_LOCKED)), $page); ! _iftoken('ADMIN', defined('WIKI_ADMIN'), $page); ! ! _dotoken('SCRIPTURL', $ScriptUrl, $page); ! _dotoken('PAGE', htmlspecialchars($name), $page); ! _dotoken('ALLOWEDPROTOCOLS', $AllowedProtocols, $page); ! _dotoken('LOGO', $logo, $page); ! // invalid for messages (search results, error messages) if ($template != 'MESSAGE') { ! _dotoken('PAGEURL', rawurlencode($name), $page); ! _dotoken('LASTMODIFIED', date($datetimeformat, $hash['lastmodified']), $page); ! _dotoken('LASTAUTHOR', $hash['author'], $page); ! _dotoken('VERSION', $hash['version'], $page); ! if (strstr($page, "$FieldSeparator#HITS$FieldSeparator#")) { ! _dotoken('HITS', GetHitCount($dbi, $name), $page); } ! if (strstr($page, "$FieldSeparator#RELATEDPAGES$FieldSeparator#")) { ! _dotoken('RELATEDPAGES', LinkRelatedPages($dbi, $name), $page); } } *************** *** 129,146 **** if ($template == 'EDITLINKS') { for ($i = 1; $i <= NUM_LINKS; $i++) ! $page = str_replace("#$FieldSeparator#R$i#$FieldSeparator#", ! $hash['refs'][$i], $page); ! } ! ! if (isset($hash['copy'])) { ! $page = str_replace("#$FieldSeparator#IFCOPY#$FieldSeparator#", ! '', $page); ! } else { ! $page = ereg_replace("#$FieldSeparator#IFCOPY#$FieldSeparator#[^\n]*", ! '', $page); } ! $page = str_replace("#$FieldSeparator#CONTENT#$FieldSeparator#", ! $content, $page); print $page; } --- 158,165 ---- if ($template == 'EDITLINKS') { for ($i = 1; $i <= NUM_LINKS; $i++) ! _dotoken("R$i", $hash['refs'][$i], $page); } ! _dotoken('CONTENT', $content, $page); print $page; } *************** *** 207,210 **** --- 226,243 ---- return $result; + } + + function ParseAdminTokens($line) { + global $ScriptUrl; + + while (preg_match("/%%ADMIN-INPUT-(.*?)-(\w+)%%/", $line, $matches)) { + $head = str_replace("_", " ", $matches[2]); + $form = "<FORM ACTION=\"$ScriptUrl\" METHOD=POST>" + ."$head: <INPUT NAME=$matches[1] SIZE=20> " + ."<INPUT TYPE=SUBMIT VALUE=\"" . gettext("Go") . "\">" + ."</FORM>"; + $line = str_replace($matches[0], $form, $line); + } + return $line; } Index: editpage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/editpage.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** editpage.php 2000/11/01 11:31:41 1.6 --- editpage.php 2000/11/08 15:40:00 1.7 *************** *** 27,31 **** if (is_array($pagehash)) { ! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && !$admin_edit) { $html = "<p>"; $html .= gettext ("This page has been locked by the administrator and cannot be edited."); --- 27,31 ---- if (is_array($pagehash)) { ! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && !defined('WIKI_ADMIN')) { $html = "<p>"; $html .= gettext ("This page has been locked by the administrator and cannot be edited."); Index: savepage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/savepage.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** savepage.php 2000/11/01 11:31:41 1.5 --- savepage.php 2000/11/08 15:40:00 1.6 *************** *** 49,53 **** $newpage = 1; } else { ! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && !$admin_edit) { $html = "<p>" . gettext ("This page has been locked by the administrator and cannot be edited."); $html .= "\n<p>" . gettext ("Sorry for the inconvenience."); --- 49,53 ---- $newpage = 1; } else { ! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && !defined('WIKI_ADMIN')) { $html = "<p>" . gettext ("This page has been locked by the administrator and cannot be edited."); $html .= "\n<p>" . gettext ("Sorry for the inconvenience."); Index: transform.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/transform.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** transform.php 2000/10/31 19:24:08 1.6 --- transform.php 2000/11/08 15:40:00 1.7 *************** *** 236,239 **** --- 236,241 ---- $tmpline = str_replace("%%Fullsearch%%", $full_search_box, $tmpline); $tmpline = str_replace("%%Mostpopular%%", $most_popular_list, $tmpline); + if(defined('WIKI_ADMIN') && strstr($tmpline, "%%ADMIN-")) + $tmpline = ParseAdminTokens($tmpline); /////////////////////////////////////////////////////// |