From: Geoffrey T. D. <da...@us...> - 2001-02-14 22:01:26
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv9783/lib Modified Files: config.php diff.php interwiki.php loadsave.php main.php prepend.php stdlib.php Log Message: Various minor bug fixes and cleanups. Also added the following new minor featurelets: Comments in index.php indicating how to set the PHP include_path if necessary. New config variable $DisabledActions --- one can list actions (eg. dumpserial) which should not be allowed, even by the administrator. Index: config.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** config.php 2001/02/13 05:54:38 1.31 --- config.php 2001/02/14 22:02:05 1.32 *************** *** 27,30 **** --- 27,77 ---- // Set up localization // + + if (empty($LANG)) + $LANG = "C"; + + + // Search PHP's include_path to find file or directory. + function FindFile ($file, $missing_okay = false) + { + // FIXME: This wont work for DOS filenames. + if (ereg('^/', $file)) + { + // absolute path. + if (file_exists($file)) + return $file; + } + else + { + $include_path = ini_get('include_path'); + if (empty($include_path)) + $include_path = '.'; + // FIXME: This wont work for DOS filenames. + $path = explode(':', $include_path); + while (list($i, $dir) = each ($path)) + if (file_exists("$dir/$file")) + return "$dir/$file"; + } + + if (!$missing_okay) + ExitWiki("$file: file not found"); + return false; + } + + // Search PHP's include_path to find file or directory. + // Searches for "locale/$LANG/$file", then for "$file". + function FindLocalizedFile ($file, $missing_okay = false) + { + global $LANG; + + // FIXME: This wont work for DOS filenames. + if (!ereg('^/', $file)) + { + if ( ($path = FindFile("locale/$LANG/$file", 'missing_is_okay')) ) + return $path; + } + return FindFile($file, $missing_okay); + } + if (!function_exists ('gettext')) { *************** *** 38,42 **** } ! if ( ($lcfile = SearchPath("LC_MESSAGES/phpwiki.php", 'missing_ok')) ) { include($lcfile); --- 85,89 ---- } ! if ( ($lcfile = FindLocalizedFile("LC_MESSAGES/phpwiki.php", 'missing_ok')) ) { include($lcfile); *************** *** 69,73 **** * php script is...) */ ! define('USE_PATH_INFO', ereg('\.(php3?|cgi)$', $SCRIPT_NAME)); } if (!defined('VIRTUAL_PATH')) --- 116,123 ---- * php script is...) */ ! if (php_sapi_name() == 'apache') ! define('USE_PATH_INFO', true); ! else ! define('USE_PATH_INFO', ereg('\.(php3?|cgi)$', $SCRIPT_NAME)); } if (!defined('VIRTUAL_PATH')) Index: diff.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/diff.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** diff.php 2001/02/13 05:54:38 1.8 --- diff.php 2001/02/14 22:02:05 1.9 *************** *** 934,938 **** $line = rtrim($line); $line = empty($line) ? ' ' : htmlspecialchars($line); ! $html .= Element('tr', $prefix . Element('td', array('bgcolor' => $color), Element('tt', $line))); --- 934,938 ---- $line = rtrim($line); $line = empty($line) ? ' ' : htmlspecialchars($line); ! $html .= Element('tr', array('valign' => 'top'), $prefix . Element('td', array('bgcolor' => $color), Element('tt', $line))); *************** *** 975,979 **** 'bgcolor' => 'white', 'cellspacing' => 0, ! 'cellpadding' => 4, 'border' => 0), $header. $diff))); --- 975,979 ---- 'bgcolor' => 'white', 'cellspacing' => 0, ! 'cellpadding' => 1, 'border' => 0), $header. $diff))); Index: interwiki.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/interwiki.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** interwiki.php 2001/02/14 05:22:49 1.3 --- interwiki.php 2001/02/14 22:02:05 1.4 *************** *** 5,9 **** global $interwikimap_file, $InterWikiLinkRegexp, $interwikimap; ! $intermap_data = file(INTERWIKI_MAP_FILE); $wikiname_regexp = ""; for ($i=0; $i<count($intermap_data); $i++) --- 5,9 ---- global $interwikimap_file, $InterWikiLinkRegexp, $interwikimap; ! $intermap_data = file(INTERWIKI_MAP_FILE, 1); $wikiname_regexp = ""; for ($i=0; $i<count($intermap_data); $i++) *************** *** 25,31 **** global $interwikimap; ! list( $wiki, $page ) = split( ":", $link ); ! $url = $interwikimap[$wiki] . urlencode($page); if ($linktext) --- 25,31 ---- global $interwikimap; ! list( $wiki, $page ) = split( ":", $link, 2 ); ! $url = $interwikimap[$wiki] . rawurlencode($page); if ($linktext) *************** *** 45,50 **** function wtt_interwikilinks($match, &$trfrm) { - global $InterWikiLinkRegexp, $WikiNameRegexp; - if ($match[0] == "!") return htmlspecialchars(substr($match,1)); --- 45,48 ---- Index: loadsave.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/loadsave.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** loadsave.php 2001/02/14 05:22:49 1.3 --- loadsave.php 2001/02/14 22:02:05 1.4 *************** *** 375,381 **** $ignore = array(gettext('RecentChanges')); ! LoadAny($dbi, SearchPath(WIKI_PGSRC), false, $ignore); if ($LANG != "C") ! LoadAny($dbi, SearchPath(DEFAULT_WIKI_PGSRC), $GenericPages, $ignore); echo "</dl>\n"; --- 375,381 ---- $ignore = array(gettext('RecentChanges')); ! LoadAny($dbi, FindLocalizedFile(WIKI_PGSRC), false, $ignore); if ($LANG != "C") ! LoadAny($dbi, FindLocalizedFile(DEFAULT_WIKI_PGSRC), $GenericPages, $ignore); echo "</dl>\n"; Index: main.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/main.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** main.php 2001/02/13 05:54:38 1.2 --- main.php 2001/02/14 22:02:05 1.3 *************** *** 5,9 **** include "lib/userauth.php"; - function DeducePagename () { --- 5,8 ---- *************** *** 14,18 **** if (USE_PATH_INFO) ! if (ereg('^' . PATH_INFO_PREFIX . '(.*)$', $PATH_INFO, $m)) return $m[1]; --- 13,17 ---- if (USE_PATH_INFO) ! if (ereg('^' . PATH_INFO_PREFIX . '(..*)$', $PATH_INFO, $m)) return $m[1]; *************** *** 39,43 **** } - function IsSafeAction ($action) { --- 38,41 ---- *************** *** 82,91 **** if (!IsSafeAction($action)) $user->must_be_admin($action); ! // Enable the output of most of the warning messages. // The warnings will screw up zip files and setpref though. if ($action != 'zip' && $action != 'setprefs') PostponeErrorMessages(E_NOTICE); ! switch ($action) { case 'edit': --- 80,91 ---- if (!IsSafeAction($action)) $user->must_be_admin($action); ! if (isset($DisabledActions) && in_array($action, $DisabledActions)) ! ExitWiki(gettext("Action $action is disabled in this wiki.")); ! // Enable the output of most of the warning messages. // The warnings will screw up zip files and setpref though. if ($action != 'zip' && $action != 'setprefs') PostponeErrorMessages(E_NOTICE); ! switch ($action) { case 'edit': Index: prepend.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/prepend.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** prepend.php 2001/02/14 05:22:49 1.2 --- prepend.php 2001/02/14 22:02:05 1.3 *************** *** 114,136 **** PostponeErrorMessages(E_ALL); - - function SearchPath ($file, $missing_ok = false, $path = false) - { - if (ereg('^/', $file)) - return $file; // absolute path. - - if (!$path) - $path = $GLOBALS['DataPath']; - - while (list($i, $dir) = each($path)) - { - if (file_exists("$dir/$file")) - return "$dir/$file"; - } - if ($missing_ok) - return false; - ExitWiki("$file: file not found"); - } - // For emacs users // Local Variables: --- 114,117 ---- Index: stdlib.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** stdlib.php 2001/02/14 05:22:49 1.30 --- stdlib.php 2001/02/14 22:02:05 1.31 *************** *** 525,529 **** } ! $page = join('', file(SearchPath($templates[$template]))); $page = str_replace('###', "$FieldSeparator#", $page); --- 525,529 ---- } ! $page = join('', file(FindLocalizedFile($templates[$template]))); $page = str_replace('###', "$FieldSeparator#", $page); |