|
From: Geoffrey T. D. <da...@us...> - 2001-02-10 22:14:40
|
Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv20420/lib
Modified Files:
config.php diff.php display.php editpage.php fullsearch.php
mysql.php pageinfo.php savepage.php search.php stdlib.php
transform.php ziplib.php
Added Files:
userauth.php
Removed Files:
editlinks.php
Log Message:
Jeff hacks again: LOT's of changes.
Highlights:
* Pagename in PATH_INFO support added.
* Redid the user (admin) authentication stuff.
All access now through index.php.
See HISTORY for (a few) more details.
--- NEW FILE ---
<?php rcs_id('$Id');
// It is anticipated that when userid support is added to phpwiki,
// this object will hold much more information (e-mail, home(wiki)page,
// etc.) about the user.
// There seems to be no clean way to "log out" a user when using
// HTTP authentication.
// So we'll hack around this by storing the currently logged
// in username and other state information in a cookie.
class WikiUser
{
// Arg $login_mode:
// default: Anonymous users okay.
// 'LOGOUT': Force logout.
// 'REQUIRE_AUTH': Force authenticated login.
function WikiUser ($auth_mode = '') {
// Restore from cookie.
global $WIKI_AUTH;
if (empty($WIKI_AUTH))
{
$this->userid = '';
$this->state = 'login';
$this->realm = 'PhpWiki0000';
}
else
$this = unserialize(fix_magic_quotes_gpc($WIKI_AUTH));
if ($auth_mode != 'LOGOUT')
{
$user = $this->_get_authenticated_userid();
if (!$user && $auth_mode == 'REQUIRE_AUTH')
$warning = $this->_demand_http_authentication(); //NORETURN
}
if (empty($user))
{
// Authentication failed
if ($this->state == 'authorized')
$this->realm++;
$this->state = 'loggedout';
$this->userid = get_remote_host(); // Anonymous user id is hostname.
}
else
{
// Successful authentication
$this->state = 'authorized';
$this->userid = $user;
}
// Save state to cookie.
setcookie('WIKI_AUTH', serialize($this), 0, '/');
if (isset($warning))
echo $warning;
}
function id () {
return $this->userid;
}
function is_authenticated () {
return $this->state == 'authorized';
}
function is_admin () {
return $this->is_authenticated() && $this->userid == ADMIN_USER;
}
function must_be_admin ($action = "do that") {
if (! $this->is_admin())
ExitWiki("You must be logged in as an administrator to $action.");
}
function _get_authenticated_userid () {
if ( ! ($user = $this->_get_http_authenticated_userid()) )
return false;
switch ($this->state) {
case 'login':
// Either we just asked for a password, or cookies are not enabled.
// In either case, proceed with successful login.
return $user;
case 'loggedout':
// We're logged out. Ignore http authed user.
return false;
default:
// Else, as long as the user hasn't changed, fine.
if ($user && $user != $this->userid)
return false;
return $user;
}
}
function _get_http_authenticated_userid () {
global $PHP_AUTH_USER, $PHP_AUTH_PW;
if (empty($PHP_AUTH_USER) || empty($PHP_AUTH_PW))
return false;
if (($PHP_AUTH_USER != ADMIN_USER) || ($PHP_AUTH_PW != ADMIN_PASSWD))
return false;
return $PHP_AUTH_USER;
}
function _demand_http_authentication () {
if (!defined('ADMIN_USER') || !defined('ADMIN_PASSWD')
|| ADMIN_USER == '' || ADMIN_PASSWD =='') {
return "<p><b>You must set the administrator account and password"
. "before you can log in.</b></p>\n";
}
// Request password
$this->userid = '';
$this->state = 'login';
setcookie('WIKI_AUTH', serialize($this), 0, '/');
header('WWW-Authenticate: Basic realm="' . $this->realm . '"');
header("HTTP/1.0 401 Unauthorized");
echo gettext ("You entered an invalid login or password.");
exit;
}
}
?>
Index: config.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** config.php 2001/02/08 18:19:16 1.28
--- config.php 2001/02/10 22:15:08 1.29
***************
*** 1,3 ****
--- 1,4 ----
<?php
+ rcs_id('$Id$');
// essential internal stuff -- skip it. Go down to Part One. There
***************
*** 8,18 ****
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
-
-
/////////////////////////////////////////////////////////////////////
// Part One:
--- 9,12 ----
***************
*** 24,31 ****
// 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
--- 18,21 ----
***************
*** 34,37 ****
--- 24,46 ----
$LANG="C";
+ // Define to 'true' to use PATH_INFO to pass the pagename's.
+ // e.g. http://www.some.where/index.php/FrontPage instead
+ // of http://www.some.where/index.php?pagename=FrontPage
+ define('USE_PATH_INFO', true);
+
+ // Username and password of administrator.
+ // Set these to your preferences. For heaven's sake
+ // pick a good password!
+ define('ADMIN_USER', "");
+ define('ADMIN_PASSWD', "");
+
+ // If true, only the admin user can make zip dumps, else
+ // zip dumps require no authentication.
+ define('ZIPDUMP_AUTH', false);
+
+ // If set, we will perform reverse dns lookups to try to convert the users
+ // IP number to a host name, even if the http server didn't do it for us.
+ define('ENABLE_REVERSE_DNS', true);
+
/////////////////////////////////////////////////////////////////////
// Part Two:
***************
*** 153,159 ****
define("NUM_RELATED_PAGES", 5);
- // number of user-defined external references, i.e. "[1]"
- define("NUM_LINKS", 12);
-
// allowed protocols for links - be careful not to allow "javascript:"
// within a named link [name|uri] one more protocol is defined: phpwiki
--- 162,165 ----
***************
*** 163,167 ****
$InlineImages = "png|jpg|gif";
-
// If the last edit is older than MINOR_EDIT_TIMEOUT seconds, the default
// state for the "minor edit" checkbox on the edit page form will be off
--- 169,172 ----
***************
*** 169,173 ****
define("MINOR_EDIT_TIMEOUT", 7 * 24 * 3600);
-
// Perl regexp for WikiNames
// (?<!..) & (?!...) used instead of '\b' because \b matches '_' as well
--- 174,177 ----
***************
*** 216,220 ****
"BROWSE" => gettext("templates/browse.html"),
"EDITPAGE" => gettext("templates/editpage.html"),
- "EDITLINKS" => gettext("templates/editlinks.html"),
"MESSAGE" => gettext("templates/message.html")
);
--- 220,223 ----
***************
*** 243,247 ****
-
//////////////////////////////////////////////////////////////////////
// you shouldn't have to edit anyting below this line
--- 246,249 ----
***************
*** 251,269 ****
$ScriptUrl = "http://$SERVER_NAME$port$SCRIPT_NAME";
}
! if (defined('WIKI_ADMIN') && !empty($AdminUrl))
! $ScriptUrl = $AdminUrl;
! $FieldSeparator = "\263";
!
! if (isset($PHP_AUTH_USER)) {
! $remoteuser = $PHP_AUTH_USER;
! } else {
!
! // Apache won't show REMOTE_HOST unless the admin configured it
! // properly. We'll be nice and see if it's there.
!
! getenv('REMOTE_HOST') ? ($remoteuser = getenv('REMOTE_HOST'))
! : ($remoteuser = getenv('REMOTE_ADDR'));
! }
// constants used for HTML output. HTML tags may allow nesting
--- 253,262 ----
$ScriptUrl = "http://$SERVER_NAME$port$SCRIPT_NAME";
}
! $ScriptName = preg_replace('@^.*/@', '', $ScriptUrl);
! // "\x80"-"\x9f" (and "\x00" - "\x1f") are non-printing control
! // chars in iso-8859-*
! // $FieldSeparator = "\263"; //this is a superscript 3 in ISO-8859-1.
! $FieldSeparator = "\x81";
// constants used for HTML output. HTML tags may allow nesting
Index: diff.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/diff.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** diff.php 2001/02/07 18:35:09 1.5
--- diff.php 2001/02/10 22:15:08 1.6
***************
*** 159,162 ****
--- 159,164 ----
function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
{
+ $flip = false;
+
if ($xlim - $xoff > $ylim - $yoff)
{
***************
*** 196,200 ****
reset($matches);
while (list ($junk, $y) = each($matches))
! if (! $this->in_seq[$y])
{
$k = $this->_lcs_pos($y);
--- 198,202 ----
reset($matches);
while (list ($junk, $y) = each($matches))
! if (empty($this->in_seq[$y]))
{
$k = $this->_lcs_pos($y);
***************
*** 214,218 ****
$this->in_seq[$y] = 1;
}
! else if (! $this->in_seq[$y])
{
$k = $this->_lcs_pos($y);
--- 216,220 ----
$this->in_seq[$y] = 1;
}
! else if (empty($this->in_seq[$y]))
{
$k = $this->_lcs_pos($y);
***************
*** 818,832 ****
function format ($diff, $from_lines)
{
! $html = '<table width="100%" bgcolor="black"' .
! "cellspacing=2 cellpadding=2 border=0>\n";
! $html .= $this->_format($diff->edits, $from_lines);
! $html .= "</table>\n";
!
! return $html;
}
function _format ($edits, $from_lines)
{
! $html = '';
$x = 0; $y = 0;
$xlim = sizeof($from_lines);
--- 820,835 ----
function format ($diff, $from_lines)
{
! return Element('table',
! array('width' => '100%',
! 'bgcolor' => 'black',
! 'cellspacing' => 2,
! 'cellpadding' => 2,
! 'border' => 0),
! $this->_format($diff->edits, $from_lines));
}
function _format ($edits, $from_lines)
{
! $rows = '';
$x = 0; $y = 0;
$xlim = sizeof($from_lines);
***************
*** 898,903 ****
= array($ybeg, $ylen, $xbeg, $xlen);
! $html .= $this->_emit_diff($xbeg,$xlen,$ybeg,$ylen,
! $hunks);
unset($hunks);
}
--- 901,905 ----
= array($ybeg, $ylen, $xbeg, $xlen);
! $rows .= $this->_emit_diff($xbeg,$xlen,$ybeg,$ylen, $hunks);
unset($hunks);
}
***************
*** 917,921 ****
$y += $ncopy;
}
! return $html;
}
--- 919,923 ----
$y += $ncopy;
}
! return $rows;
}
***************
*** 923,931 ****
{
$html = '';
reset($lines);
while (list ($junk, $line) = each($lines))
{
! $html .= "<tr bgcolor=\"$color\"><td><tt>$prefix</tt>";
! $html .= "<tt>" . htmlspecialchars($line) . "</tt></td></tr>\n";
}
return $html;
--- 925,936 ----
{
$html = '';
+ $prefix = Element('td', array('bgcolor' => '#cccccc'), $prefix);
reset($lines);
while (list ($junk, $line) = each($lines))
{
! $line = empty($line) ? ' ' : htmlspecialchars($line);
! $html .= Element('tr',
! $prefix . Element('td', array('bgcolor' => $color),
! Element('tt', $line)));
}
return $html;
***************
*** 934,944 ****
function _emit_diff ($xbeg,$xlen,$ybeg,$ylen,$hunks)
{
! $html = '<tr><td><table width="100%" bgcolor="white"'
! . " cellspacing=0 border=0 cellpadding=4>\n"
! . '<tr bgcolor="#cccccc"><td><tt>'
! . $this->_diff_header($xbeg, $xlen, $ybeg, $ylen)
! . "</tt></td></tr>\n<tr><td>\n"
! . "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2>\n";
!
$prefix = array('c' => $this->context_prefix,
'a' => $this->adds_prefix,
--- 939,947 ----
function _emit_diff ($xbeg,$xlen,$ybeg,$ylen,$hunks)
{
! $header = Element('tr', array('bgcolor' => '#cccccc'),
! Element('td', array('colspan' => 2),
! QElement('tt',
! $this->_diff_header($xbeg, $xlen, $ybeg, $ylen))));
!
$prefix = array('c' => $this->context_prefix,
'a' => $this->adds_prefix,
***************
*** 948,966 ****
'd' => '#ccffcc');
for (reset($hunks); $hunk = current($hunks); next($hunks))
{
if (!empty($hunk['c']))
! $html .= $this->_emit_lines($hunk['c'],
$this->context_prefix, '#ffffff');
if (!empty($hunk['d']))
! $html .= $this->_emit_lines($hunk['d'],
$this->deletes_prefix, '#ccffcc');
if (!empty($hunk['a']))
! $html .= $this->_emit_lines($hunk['a'],
$this->adds_prefix, '#ffcccc');
}
! $html .= "</table></td></tr></table></td></tr>\n";
! return $html;
}
--- 951,978 ----
'd' => '#ccffcc');
+ $diff = '';
for (reset($hunks); $hunk = current($hunks); next($hunks))
{
if (!empty($hunk['c']))
! $diff .= $this->_emit_lines($hunk['c'],
$this->context_prefix, '#ffffff');
if (!empty($hunk['d']))
! $diff .= $this->_emit_lines($hunk['d'],
$this->deletes_prefix, '#ccffcc');
if (!empty($hunk['a']))
! $diff .= $this->_emit_lines($hunk['a'],
$this->adds_prefix, '#ffcccc');
}
!
! return Element('tr', Element('td',
! Element('table',
! array('width' => '100%',
! 'bgcolor' => 'white',
! 'cellspacing' => 0,
! 'cellpadding' => 4,
! 'border' => 0),
! $header. $diff)));
!
}
***************
*** 1009,1061 ****
/////////////////////////////////////////////////////////////////
! if ($diff)
{
! if (get_magic_quotes_gpc()) {
! $diff = stripslashes($diff);
! }
!
! $pagename = $diff;
$wiki = RetrievePage($dbi, $pagename, $WikiPageStore);
- // $dba = OpenDataBase($ArchivePageStore);
$archive= RetrievePage($dbi, $pagename, $ArchivePageStore);
-
- $html = '<table><tr><td align="right">';
- $html .= gettext ("Current page:");
- $html .= '</td>';
- if (is_array($wiki)) {
- $html .= "<td>";
- $html .= sprintf(gettext ("version %s"), $wiki['version']);
- $html .= "</td><td>";
- $html .= sprintf(gettext ("last modified on %s"),
- date($datetimeformat, $wiki['lastmodified']));
- $html .= "</td><td>";
- $html .= sprintf (gettext ("by %s"), $wiki['author']);
- $html .= "</td>";
- } else {
- $html .= "<td colspan=3><em>";
- $html .= gettext ("None");
- $html .= "</em></td>";
- }
- $html .= "</tr>\n";
- $html .= '<tr><td align="right">';
- $html .= gettext ("Archived page:");
- $html .= '</td>';
- if (is_array($archive)) {
- $html .= "<td>";
- $html .= sprintf(gettext ("version %s"), $archive['version']);
- $html .= "</td><td>";
- $html .= sprintf(gettext ("last modified on %s"),
- date($datetimeformat, $archive['lastmodified']));
- $html .= "</td><td>";
- $html .= sprintf(gettext ("by %s"), $archive['author']);
- $html .= "</td>";
- } else {
- $html .= "<td colspan=3><em>";
- $html .= gettext ("None");
- $html .= "</em></td>";
- }
- $html .= "</tr></table><p>\n";
if (is_array($wiki) && is_array($archive))
{
--- 1021,1058 ----
/////////////////////////////////////////////////////////////////
! function PageInfoRow ($label, $hash)
{
! global $datetimeformat;
!
! $cols = QElement('td', array('align' => 'right'), $label);
!
!
! if (is_array($hash)) {
! extract($hash);
! $cols .= QElement('td',
! sprintf(gettext ("version %s"), $version));
! $cols .= QElement('td',
! sprintf(gettext ("last modified on %s"),
! date($datetimeformat, $lastmodified)));
! $cols .= QElement('td',
! sprintf(gettext ("by %s"), $author));
! } else {
! $cols .= QElement('td', array('colspan' => '3'),
! gettext ("None"));
! }
! return Element('tr', $cols);
! }
+ if (isset($pagename))
+ {
$wiki = RetrievePage($dbi, $pagename, $WikiPageStore);
$archive= RetrievePage($dbi, $pagename, $ArchivePageStore);
+ $html = Element('table',
+ PageInfoRow(gettext ("Current page:"), $wiki)
+ . PageInfoRow(gettext ("Archived page:"), $archive));
+
+ $html .= "<p>\n";
+
if (is_array($wiki) && is_array($archive))
{
Index: display.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/display.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** display.php 2001/02/07 21:11:46 1.6
--- display.php 2001/02/10 22:15:08 1.7
***************
*** 4,26 ****
rcs_id('$Id$');
- // if we got GET data, the first item is always a page name
- // if it wasn't this file would not have been included
-
- if (empty($QUERY_STRING) && isset($argv[0]))
- $QUERY_STRING = $argv[0];
-
- if (isset($QUERY_STRING) && preg_match('/^[-+%\w]+$/', $QUERY_STRING)) {
- $pagename = urldecode($QUERY_STRING);
- } else {
- $pagename = gettext("FrontPage");
-
- // if there is no FrontPage, create a basic set of Wiki pages
- if (! IsWikiPage($dbi, $pagename)) {
- include "lib/setupwiki.php";
- }
- }
-
$html = "";
! $enc_name = rawurlencode($pagename);
$pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
--- 4,9 ----
rcs_id('$Id$');
$html = "";
!
$pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
***************
*** 31,35 ****
} else {
$html .= sprintf(gettext("Describe %s here."),
! "$pagename<a href='$ScriptUrl?edit=$enc_name'>?</a>");
}
--- 14,18 ----
} else {
$html .= sprintf(gettext("Describe %s here."),
! LinkUnknownWikiWord($pagename));
}
Index: editpage.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/editpage.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** editpage.php 2001/02/07 22:14:35 1.9
--- editpage.php 2001/02/10 22:15:08 1.10
***************
*** 4,31 ****
// editpage relies on $pagename and $ScriptUrl
! if ($edit) {
! $pagename = rawurldecode($edit);
! if (get_magic_quotes_gpc()) {
! $pagename = stripslashes($pagename);
! }
! $banner = htmlspecialchars($pagename);
! $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
! } elseif ($copy) {
! $pagename = rawurldecode($copy);
! if (get_magic_quotes_gpc()) {
! $pagename = stripslashes($pagename);
! }
$banner = htmlspecialchars (sprintf (gettext ("Copy of %s"), $pagename));
$pagehash = RetrievePage($dbi, $pagename, $ArchivePageStore);
-
} else {
! ExitWiki(gettext ("No page name passed into editpage!"));
}
-
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.");
--- 4,21 ----
// editpage relies on $pagename and $ScriptUrl
! $currentpage = RetrievePage($dbi, $pagename, $WikiPageStore);
! $editing_copy = isset($version) && $version == 'archive';
! if ($editing_copy) {
$banner = htmlspecialchars (sprintf (gettext ("Copy of %s"), $pagename));
$pagehash = RetrievePage($dbi, $pagename, $ArchivePageStore);
} else {
! $banner = htmlspecialchars($pagename);
! $pagehash = $currentpage;
}
if (is_array($pagehash)) {
! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && $user->is_admin()) {
$html = "<p>";
$html .= gettext ("This page has been locked by the administrator and cannot be edited.");
***************
*** 38,44 ****
$textarea = implode("\n", $pagehash["content"]);
! if (isset($copy)) {
! // $cdbi = OpenDataBase($WikiPageStore);
! $currentpage = RetrievePage($dbi, $pagename, $WikiPageStore);
$pagehash["version"] = $currentpage["version"];
}
--- 28,32 ----
$textarea = implode("\n", $pagehash["content"]);
! if ($editing_copy) {
$pagehash["version"] = $currentpage["version"];
}
***************
*** 47,51 ****
$pagehash["copy"] = 1;
}
- $currentpage = $pagehash;
}
} else {
--- 35,38 ----
***************
*** 59,67 ****
}
! if ($currentpage['author'] == $remoteuser) {
$page_age = time() - $currentpage['lastmodified'];
! if ($page_age < MINOR_EDIT_TIMEOUT) {
! $pagehash['minor_edit'] = 1;
! }
}
--- 46,58 ----
}
!
! if ($user->id() == $currentpage['author'] || $user->is_admin()) {
! $ckbox = element('input', array('type' => 'checkbox',
! 'name' => 'minor_edit',
! 'value' => 'yes'));
$page_age = time() - $currentpage['lastmodified'];
! if ($user->id() == $currentpage['author'] && $page_age < MINOR_EDIT_TIMEOUT)
! $ckbox .= " checked";
! $pagehash['minor_edit_checkbox'] = $ckbox . '>';
}
Index: fullsearch.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/fullsearch.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** fullsearch.php 2000/12/30 21:09:13 1.4
--- fullsearch.php 2001/02/10 22:15:08 1.5
***************
*** 3,19 ****
rcs_id('$Id$');
! if(get_magic_quotes_gpc())
! $full = stripslashes($full);
$html = "<P><B>"
. sprintf(gettext ("Searching for \"%s\" ....."),
! htmlspecialchars($full))
. "</B></P>\n<DL>\n";
// search matching pages
! $query = InitFullSearch($dbi, $full);
// quote regexp chars (space are treated as "or" operator)
! $full = preg_replace("/\s+/", "|", preg_quote($full));
$found = 0;
--- 3,21 ----
rcs_id('$Id$');
! if (empty($searchterm))
! $searchterm = ''; // FIXME: do something better here?
+ fix_magic_quotes_gpc($searchterm);
+
$html = "<P><B>"
. sprintf(gettext ("Searching for \"%s\" ....."),
! htmlspecialchars($searchterm))
. "</B></P>\n<DL>\n";
// search matching pages
! $query = InitFullSearch($dbi, $searchterm);
// quote regexp chars (space are treated as "or" operator)
! $qterm = preg_replace("/\s+/", "|", preg_quote($searchterm));
$found = 0;
***************
*** 25,30 ****
// print out all matching lines, highlighting the match
for ($j = 0; $j < (count($pagehash["content"])); $j++) {
! if ($hits = preg_match_all("/$full/i", $pagehash["content"][$j], $dummy)) {
! $matched = preg_replace("/$full/i",
"${FieldSeparator}OT\\0${FieldSeparator}CT",
$pagehash["content"][$j]);
--- 27,32 ----
// print out all matching lines, highlighting the match
for ($j = 0; $j < (count($pagehash["content"])); $j++) {
! if ($hits = preg_match_all("/$qterm/i", $pagehash["content"][$j], $dummy)) {
! $matched = preg_replace("/$qterm/i",
"${FieldSeparator}OT\\0${FieldSeparator}CT",
$pagehash["content"][$j]);
Index: mysql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/mysql.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** mysql.php 2001/01/04 18:37:56 1.10
--- mysql.php 2001/02/10 22:15:08 1.11
***************
*** 119,125 ****
if (!mysql_query("replace into $dbi[table] ($COLUMNS) values ($VALUES)",
$dbi['dbc'])) {
! $msg = sprintf(gettext ("Error writing page '%s'"), $pagename);
$msg .= "<BR>";
! $msg .= sprintf(gettext ("MySQL error: %s"), mysql_error());
ExitWiki($msg);
}
--- 119,125 ----
if (!mysql_query("replace into $dbi[table] ($COLUMNS) values ($VALUES)",
$dbi['dbc'])) {
! $msg = htmlspecialchars(sprintf(gettext ("Error writing page '%s'"), $pagename));
$msg .= "<BR>";
! $msg .= htmlspecialchars(sprintf(gettext ("MySQL error: %s"), mysql_error()));
ExitWiki($msg);
}
***************
*** 294,298 ****
function GetWikiPageLinks($dbi, $pagename) {
global $WikiLinksStore, $WikiScoreStore, $HitCountStore;
!
$pagename = addslashes($pagename);
$res = mysql_query("select topage, score from $WikiLinksStore, $WikiScoreStore where topage=pagename and frompage='$pagename' order by score desc, topage");
--- 294,299 ----
function GetWikiPageLinks($dbi, $pagename) {
global $WikiLinksStore, $WikiScoreStore, $HitCountStore;
! $links = array();
!
$pagename = addslashes($pagename);
$res = mysql_query("select topage, score from $WikiLinksStore, $WikiScoreStore where topage=pagename and frompage='$pagename' order by score desc, topage");
Index: pageinfo.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/pageinfo.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** pageinfo.php 2000/11/01 11:31:41 1.5
--- pageinfo.php 2001/02/10 22:15:08 1.6
***************
*** 2,76 ****
<!-- Display the internal structure of a page. Steve Wainstead, June 2000 -->
<?php
- if (get_magic_quotes_gpc()) {
- $info = stripslashes($info);
- }
- $encname = htmlspecialchars($info);
- $enter = gettext ("Enter a page name");
- $go = gettext ("Go");
- $html = "<form action=\"$ScriptUrl\" METHOD=GET>\n" .
- "<input name=\"info\" value=\"$encname\">" .
- " $enter\n" .
- "<input type=submit value=$go><br>\n" .
- "<input type=checkbox name=showpagesource";
! if (isset($showpagesource) && ($showpagesource == "on")) {
! $html .= " checked";
! }
! $html .= "> ";
! $html .= gettext ("Show the page source and references");
! $html .= "\n</form>\n";
!
! // don't bother unless we were asked
! if (! $info) {
! GeneratePage('MESSAGE', $html, gettext("PageInfo"), 0);
! exit;
}
! function ViewpageProps($name, $pagestore)
! {
! global $dbi, $showpagesource, $datetimeformat, $FieldSeparator;
!
! $pagehash = RetrievePage($dbi, $name, $pagestore);
! if ($pagehash == -1) {
! $table = sprintf (gettext ("Page name '%s' is not in the database"),
! $name) . "\n";
}
! else {
! $table = "<table border=1 bgcolor=white>\n";
! while (list($key, $val) = each($pagehash)) {
! if ($key > 0 || !$key) #key is an array index
! continue;
! if ((gettype($val) == "array") && ($showpagesource == "on")) {
! $val = implode($val, "$FieldSeparator#BR#$FieldSeparator\n");
! $val = htmlspecialchars($val);
! $val = str_replace("$FieldSeparator#BR#$FieldSeparator", "<br>", $val);
! }
! elseif (($key == 'lastmodified') || ($key == 'created'))
! $val = date($datetimeformat, $val);
! else
! $val = htmlspecialchars($val);
- $table .= "<tr><td>$key</td><td>$val</td></tr>\n";
- }
! $table .= "</table>";
! }
! return $table;
! }
! $html .= "<P><B>";
! $html .= gettext ("Current version");
! $html .= "</B></p>";
! // $dbi = OpenDataBase($WikiPageStore); --- done by index.php
! $html .= ViewPageProps($info, $WikiPageStore);
!
! $html .= "<P><B>";
! $html .= gettext ("Archived version");
! $html .= "</B></p>";
! // $dbi = OpenDataBase($ArchivePageStore);
! $html .= ViewPageProps($info, $ArchivePageStore);
! GeneratePage('MESSAGE', $html, gettext("PageInfo").": '$info'", 0);
?>
--- 2,61 ----
<!-- Display the internal structure of a page. Steve Wainstead, June 2000 -->
<?php
!
! function ViewpageProps($name, $pagestore)
! {
! global $dbi, $showpagesource, $datetimeformat, $FieldSeparator;
!
! $pagehash = RetrievePage($dbi, $name, $pagestore);
! if ($pagehash == -1) {
! return QElement('p',
! sprintf (gettext ("Page name '%s' is not in the database"),
! $name));
}
! $rows = '';
! while (list($key, $val) = each($pagehash)) {
! if ($key > 0 || !$key)
! continue; //key is an array index
! $cols = QElement('td', array('align' => 'right'), $key);
!
! if (is_array($val))
! {
! if (empty($showpagesource))
! continue;
! $cols .= Element('td',
! nl2br(htmlspecialchars(join("\n", $val))));
}
! elseif (($key == 'lastmodified') || ($key == 'created'))
! $cols .= QElement('td',
! date($datetimeformat, $val));
! else
! $cols .= QElement('td', $val);
!
! $rows .= Element('tr', $cols);
! }
! return Element('table', array('border' => 1, 'bgcolor' => 'white'), $rows);
! }
! $html = '';
!
! if (empty($showpagesource))
! {
! $text = gettext ("Show the page source");
! $url = WikiURL($pagename, array('action' => 'info',
! 'showpagesource' => 'on'));
! $html .= QElement('a', array('href' => $url), $text);
! }
!
! $html .= Element('p', QElement('b', gettext ("Current version")));
! $html .= ViewPageProps($pagename, $WikiPageStore);
! $html .= Element('p', QElement('b', gettext ("Archived version")));
! $html .= ViewPageProps($pagename, $ArchivePageStore);
! GeneratePage('MESSAGE', $html, gettext("PageInfo").": '$pagename'", 0);
?>
Index: savepage.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/savepage.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** savepage.php 2001/02/08 18:19:16 1.9
--- savepage.php 2001/02/10 22:15:08 1.10
***************
*** 10,14 ****
function UpdateRecentChanges($dbi, $pagename, $isnewpage)
{
! global $remoteuser; // this is set in the config
global $dateformat;
global $WikiPageStore;
--- 10,14 ----
function UpdateRecentChanges($dbi, $pagename, $isnewpage)
{
! global $user;
global $dateformat;
global $WikiPageStore;
***************
*** 51,60 ****
: $recentchanges['content'][$i++];
// add the updated page's name to the array
if($isnewpage) {
! $newpage[$k++] = "* [$pagename] (new) ..... $remoteuser\r";
} else {
! $diffurl = "phpwiki:?diff=" . rawurlencode($pagename);
! $newpage[$k++] = "* [$pagename] ([diff|$diffurl]) ..... $remoteuser\r";
}
if ($isNewDay)
--- 51,62 ----
: $recentchanges['content'][$i++];
+ $userid = $user->id();
+
// add the updated page's name to the array
if($isnewpage) {
! $newpage[$k++] = "* [$pagename] (new) ..... $userid\r";
} else {
! $diffurl = "phpwiki:" . rawurlencode($pagename) . "?action=diff";
! $newpage[$k++] = "* [$pagename] ([diff|$diffurl]) ..... $userid\r";
}
if ($isNewDay)
***************
*** 106,111 ****
-
- $pagename = rawurldecode($post);
$pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
--- 108,111 ----
***************
*** 118,122 ****
$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.");
--- 118,122 ----
$newpage = 1;
} else {
! if (($pagehash['flags'] & FLAG_PAGE_LOCKED) && ! $user->is_admin()) {
$html = "<p>" . gettext ("This page has been locked by the administrator and cannot be edited.");
$html .= "\n<p>" . gettext ("Sorry for the inconvenience.");
***************
*** 129,136 ****
}
! // archive it if it's a new author
! if (empty($minor_edit)) {
! SaveCopyToArchive($dbi, $pagename, $pagehash);
! }
$newpage = 0;
}
--- 129,138 ----
}
! if ($user->id() != $pagehash['author'] && ! $user->is_admin())
! unset($minor_edit); // Force archive
!
! if (empty($minor_edit))
! SaveCopyToArchive($dbi, $pagename, $pagehash);
!
$newpage = 0;
}
***************
*** 139,155 ****
$pagehash['lastmodified'] = time();
$pagehash['version']++;
! $pagehash['author'] = $remoteuser;
// create page header
- $enc_url = rawurlencode($pagename);
- $enc_name = htmlspecialchars($pagename);
$html = sprintf(gettext("Thank you for editing %s."),
! "<a href=\"$ScriptUrl?$enc_url\">$enc_name</a>");
$html .= "<br>\n";
if (! empty($content)) {
// patch from Grant Morgan <gr...@ry...> for magic_quotes_gpc
! if (get_magic_quotes_gpc())
! $content = stripslashes($content);
$pagehash['content'] = preg_split('/[ \t\r]*\n/', chop($content));
--- 141,154 ----
$pagehash['lastmodified'] = time();
$pagehash['version']++;
! $pagehash['author'] = $user->id();
// create page header
$html = sprintf(gettext("Thank you for editing %s."),
! WikiURL($pagename));
$html .= "<br>\n";
if (! empty($content)) {
// patch from Grant Morgan <gr...@ry...> for magic_quotes_gpc
! fix_magic_quotes_gpc($content);
$pagehash['content'] = preg_split('/[ \t\r]*\n/', chop($content));
***************
*** 161,174 ****
}
- for ($i = 1; $i <= NUM_LINKS; $i++) {
- if (! empty(${'r'.$i})) {
- if (preg_match("#^($AllowedProtocols):#", ${'r'.$i}))
- $pagehash['refs'][$i] = ${'r'.$i};
- else
- $html .= "<P>Link [$i]: <B>unknown protocol</B>" .
- " - use one of $AllowedProtocols - link discarded.</P>\n";
- }
- }
-
InsertPage($dbi, $pagename, $pagehash);
UpdateRecentChanges($dbi, $pagename, $newpage);
--- 160,163 ----
***************
*** 186,191 ****
if (!empty($SignatureImg))
! $html .= "<P><img src=\"$SignatureImg\"></P>\n";
!
$html .= "<hr noshade><P>";
include('lib/transform.php');
--- 175,180 ----
if (!empty($SignatureImg))
! $html .= sprintf("<P><img src=\"%s\"></P>\n", MakeURLAbsolute($SignatureImg));
!
$html .= "<hr noshade><P>";
include('lib/transform.php');
Index: search.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/search.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** search.php 2001/01/02 00:10:28 1.3
--- search.php 2001/02/10 22:15:08 1.4
***************
*** 3,19 ****
rcs_id('$Id$');
! if(get_magic_quotes_gpc())
! $search = stripslashes($search);
$html = "<P><B>"
. sprintf(gettext ("Searching for \"%s\" ....."),
! htmlspecialchars($search))
. "</B></P>\n";
// quote regexp chars
! $search = preg_quote($search);
// search matching pages
! $query = InitTitleSearch($dbi, $search);
$found = 0;
while ($page = TitleSearchNextMatch($dbi, $query)) {
--- 3,21 ----
rcs_id('$Id$');
! if (empty($searchterm))
! $searchterm = ''; // FIXME: do something better here?
+ fix_magic_quotes_gpc($searchterm);
+
$html = "<P><B>"
. sprintf(gettext ("Searching for \"%s\" ....."),
! htmlspecialchars($searchterm))
. "</B></P>\n";
// quote regexp chars
! $search = preg_quote($searchterm);
// search matching pages
! $query = InitTitleSearch($dbi, $searchterm);
$found = 0;
while ($page = TitleSearchNextMatch($dbi, $query)) {
Index: stdlib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** stdlib.php 2001/02/08 18:18:10 1.26
--- stdlib.php 2001/02/10 22:15:08 1.27
***************
*** 1,7 ****
--- 1,11 ----
<?php rcs_id('$Id$');
+
/*
Standard functions for Wiki functionality
ExitWiki($errormsg)
+ MakeURLAbsolute($url, $base = false)
+ WikiURL($pagename, $args, $abs)
+
LinkExistingWikiWord($wikiword, $linktext)
LinkUnknownWikiWord($wikiword, $linktext)
***************
*** 19,22 ****
--- 23,46 ----
*/
+ function fix_magic_quotes_gpc (&$text)
+ {
+ if (get_magic_quotes_gpc()) {
+ $text = stripslashes($text);
+ }
+ return $text;
+ }
+
+
+ function get_remote_host () {
+ // Apache won't show REMOTE_HOST unless the admin configured it
+ // properly. We'll be nice and see if it's there.
+ if (getenv('REMOTE_HOST'))
+ return getenv('REMOTE_HOST');
+ $host = getenv('REMOTE_ADDR');
+ if (ENABLE_REVERSE_DNS)
+ return gethostbyaddr($host);
+ return $host;
+ }
+
function ExitWiki($errormsg)
***************
*** 39,75 ****
}
!
! function LinkExistingWikiWord($wikiword, $linktext='') {
global $ScriptUrl;
! $enc_word = rawurlencode($wikiword);
! if(empty($linktext))
! $linktext = htmlspecialchars($wikiword);
! return "<a href=\"$ScriptUrl?$enc_word\">$linktext</a>";
}
! function LinkUnknownWikiWord($wikiword, $linktext='') {
! global $ScriptUrl;
! $enc_word = rawurlencode($wikiword);
! if(empty($linktext))
! $linktext = htmlspecialchars($wikiword);
! return "<u>$linktext</u><a href=\"$ScriptUrl?edit=$enc_word\">?</a>";
}
function LinkURL($url, $linktext='') {
! global $ScriptUrl;
if(ereg("[<>\"]", $url)) {
return "<b><u>BAD URL -- remove all of <, >, "</u></b>";
}
! if(empty($linktext))
! $linktext = htmlspecialchars($url);
! return "<a href=\"$url\">$linktext</a>";
}
function LinkImage($url, $alt='[External Image]') {
! global $ScriptUrl;
if(ereg('[<>"]', $url)) {
return "<b><u>BAD URL -- remove all of <, >, "</u></b>";
}
! return "<img src=\"$url\" ALT=\"$alt\">";
}
--- 63,172 ----
}
! function MakeURLAbsolute($url, $base = false) {
global $ScriptUrl;
!
! if (preg_match('@^(\w+:|/)@', $url))
! return $url;
!
! return preg_replace('@[^/]*$@', '', empty($base) ? $ScriptUrl : $base) . $url;
}
+
! function WikiURL($pagename, $args = '', $make_abs_url = false) {
! global $ScriptName, $ScriptUrl;
!
! if (is_array($args))
! {
! reset($args);
! $enc_args = array();
! while (list ($key, $val) = each($args)) {
! $enc_args[] = urlencode($key) . '=' . urlencode($val);
! }
! $args = join('&', $enc_args);
! }
!
! if (USE_PATH_INFO) {
! $url = $make_abs_url ? "$ScriptUrl/" : '';
! $url .= rawurlencode($pagename);
! if ($args)
! $url .= "?$args";
! }
! else {
! $url = $make_abs_url ? $ScriptUrl : $ScriptName;
! $url .= "?pagename=" . rawurlencode($pagename);
! if ($args)
! $url .= "&$args";
! }
! return $url;
}
+ define('NO_END_TAG_PAT',
+ '/^' . join('|', array('area', 'base', 'basefont',
+ 'br', 'col', 'frame',
+ 'hr', 'image', 'input',
+ 'isindex', 'link', 'meta',
+ 'param')) . '$/i');
+
+ function Element($tag, $args = '', $content = '')
+ {
+ $html = "<$tag";
+ if (is_array($args))
+ {
+ while (list($key, $val) = each($args))
+ $html .= sprintf(' %s="%s"', $key, htmlspecialchars($val));
+ }
+ else
+ $content = $args;
+
+ $html .= '>';
+ if (!preg_match(NO_END_TAG_PAT, $tag))
+ {
+ $html .= $content;
+ $html .= "</$tag>";
+ }
+ return $html;
+ }
+
+ function QElement($tag, $args = '', $content = '')
+ {
+ if (is_array($args))
+ return Element($tag, $args, htmlspecialchars($content));
+ else
+ {
+ $content = $args;
+ return Element($tag, htmlspecialchars($content));
+ }
+ }
+
function LinkURL($url, $linktext='') {
! // FIXME: Is this needed (or sufficient?)
if(ereg("[<>\"]", $url)) {
return "<b><u>BAD URL -- remove all of <, >, "</u></b>";
}
! return QElement('a', array('href' => $url), ($linktext ? $linktext : $url));
}
+ function LinkExistingWikiWord($wikiword, $linktext='') {
+ return LinkURL(WikiURL($wikiword),
+ $linktext ? $linktext : $wikiword);
+ }
+
+ function LinkUnknownWikiWord($wikiword, $linktext='') {
+ if (empty($linktext))
+ $linktext = $wikiword;
+
+ return QElement('u', $linktext)
+ . QElement('a', array('href' => WikiURL($wikiword, array('action' => 'edit'))),
+ '?');
+ }
+
+
function LinkImage($url, $alt='[External Image]') {
! // FIXME: Is this needed (or sufficient?)
! // As long as the src in htmlspecialchars()ed I think it's safe.
if(ereg('[<>"]', $url)) {
return "<b><u>BAD URL -- remove all of <, >, "</u></b>";
}
! return Element('img', array('src' => $url, 'alt' => $alt));
}
***************
*** 78,102 ****
list( $wiki, $page ) = split( ":", $link );
- if(empty($linktext))
- $linktext = htmlspecialchars($link);
- $page = urlencode($page);
- return "<a href=\"$interwikimap[$wiki]$page\">$linktext</a>";
- }
-
-
- 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;
}
// converts spaces to tabs
function CookSpaces($pagearray) {
--- 175,184 ----
list( $wiki, $page ) = split( ":", $link );
! $url = $interwikimap[$wiki] . urlencode($page);
! return LinkURL($url, $linktext ? $linktext : $link);
}
+
// converts spaces to tabs
function CookSpaces($pagearray) {
***************
*** 138,141 ****
--- 220,296 ----
+ function MakeWikiForm ($pagename, $args, $button_text = '') {
+ global $ScriptUrl;
+
+ $formargs['action'] = USE_PATH_INFO ? WikiURL($pagename) : $ScriptUrl;
+ $formargs['method'] = 'post';
+ $contents = '';
+ $input_seen = 0;
+
+ while (list($key, $val) = each($args))
+ {
+ $a = array('name' => $key, 'value' => $val, 'type' => 'hidden');
+
+ if (preg_match('/^ (\d*) \( (.*) \) $/x', $val, $m))
+ {
+ $input_seen++;
+ $a['type'] = 'text';
+ $a['size'] = $m[1] ? $m[1] : 30;
+ $a['value'] = $m[2];
+ }
+
+ $contents .= Element('input', $a);
+ }
+
+ if (!empty($button_text)) {
+ if ($input_seen)
+ $contents .= ' ';
+ $contents .= Element('input', array('type' => 'submit',
+ 'value' => $button_text));
+ }
+
+ return Element('form', $formargs, $contents);
+ }
+
+ function SplitQueryArgs ($query_args = '')
+ {
+ $split_args = split('&', $query_args);
+ $args = array();
+ while (list($key, $val) = each($split_args))
+ if (preg_match('/^ ([^=]+) =? (.*) /x', $val, $m))
+ $args[$m[1]] = $m[2];
+ return $args;
+ }
+
+ function LinkPhpwikiURL($url, $text = '') {
+ global $pagename;
+ $args = array();
+ $page = $pagename;
+
+ if (!preg_match('/^ phpwiki: ([^?]*) [?]? (.*) $/x', $url, $m))
+ return "<b><u>BAD phpwiki: URL</u></b>";
+
+ if ($m[1])
+ $page = urldecode($m[1]);
+ $qargs = $m[2];
+
+ if (!$page && preg_match('/^(diff|edit|links|info|diff)=([^&]+)$/', $qargs, $m))
+ {
+ // Convert old style links (to not break diff links in RecentChanges).
+ $page = urldecode($m[2]);
+ $args = array("action" => $m[1]);
+ }
+ else
+ {
+ $args = SplitQueryArgs($qargs);
+ }
+
+ // FIXME: ug, don't like this
+ if (preg_match('/=\d*\(/', $qargs))
+ return MakeWikiForm($page, $args, $text);
+ else
+ return LinkURL(WikiURL($page, $args), $text ? $text : $url);
+ }
+
function ParseAndLink($bracketlink) {
global $dbi, $ScriptUrl, $AllowedProtocols, $InlineImages;
***************
*** 153,157 ****
// named link of the form "[some link name | http://blippy.com/]"
$URL = trim($matches[3]);
! $linkname = htmlspecialchars(trim($matches[1]));
$linktype = 'named';
} else {
--- 308,312 ----
// named link of the form "[some link name | http://blippy.com/]"
$URL = trim($matches[3]);
! $linkname = trim($matches[1]);
$linktype = 'named';
} else {
***************
*** 176,182 ****
} elseif (preg_match("#^phpwiki:(.*)#", $URL, $match)) {
$link['type'] = "url-wiki-$linktype";
! if(empty($linkname))
! $linkname = htmlspecialchars($URL);
! $link['link'] = "<a href=\"$ScriptUrl$match[1]\">$linkname</a>";
} elseif (preg_match("#^\d+$#", $URL)) {
$link['type'] = "footnote-$linktype";
--- 331,335 ----
} elseif (preg_match("#^phpwiki:(.*)#", $URL, $match)) {
$link['type'] = "url-wiki-$linktype";
! $link['link'] = LinkPhpwikiURL($URL, $linkname);
} elseif (preg_match("#^\d+$#", $URL)) {
$link['type'] = "footnote-$linktype";
***************
*** 285,289 ****
global $ScriptUrl, $AllowedProtocols, $templates;
global $datetimeformat, $dbi, $logo, $FieldSeparator;
!
if (!is_array($hash))
unset($hash);
--- 438,443 ----
global $ScriptUrl, $AllowedProtocols, $templates;
global $datetimeformat, $dbi, $logo, $FieldSeparator;
! global $user;
!
if (!is_array($hash))
unset($hash);
***************
*** 329,347 ****
_iftoken('LOCK', (isset($hash['flags']) &&
($hash['flags'] & FLAG_PAGE_LOCKED)), $page);
! _iftoken('ADMIN', defined('WIKI_ADMIN'), $page);
! _iftoken('MINOR_EDIT', isset($hash['minor_edit']), $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);
--- 483,522 ----
_iftoken('LOCK', (isset($hash['flags']) &&
($hash['flags'] & FLAG_PAGE_LOCKED)), $page);
! _iftoken('ADMIN', $user->is_admin(), $page);
! _iftoken('ANONYMOUS', !$user->is_authenticated(), $page);
! if (empty($hash['minor_edit_checkbox']))
! $hash['minor_edit_checkbox'] = '';
! _iftoken('MINOR_EDIT_CHECKBOX', $hash['minor_edit_checkbox'], $page);
!
! _dotoken('MINOR_EDIT_CHECKBOX', $hash['minor_edit_checkbox'], $page);
!
! _dotoken('USERID', htmlspecialchars($user->id()), $page);
! _dotoken('SCRIPTURL', htmlspecialchars($ScriptUrl), $page);
_dotoken('PAGE', htmlspecialchars($name), $page);
! _dotoken('LOGO', htmlspecialchars(MakeURLAbsolute($logo)), $page);
! global $RCS_IDS;
! _dotoken('RCS_IDS', join("\n", $RCS_IDS), $page);
+ // FIXME: Clean up this stuff
+ $browse_page = WikiURL($name);
+ _dotoken('BROWSE_PAGE', $browse_page, $page);
+ $arg_sep = strstr($browse_page, '?') ? '&' : '?';
+ _dotoken('ACTION', $browse_page . $arg_sep . "action=", $page);
+ _dotoken('BROWSE', WikiURL(''), $page);
+
+ // FIXME: this is possibly broken.
+ _dotoken('BASE_URL', WikiURL($name, '', 'absolute_url'), $page);
+
// invalid for messages (search results, error messages)
if ($template != 'MESSAGE') {
_dotoken('PAGEURL', rawurlencode($name), $page);
! if (!empty($hash['lastmodified']))
! _dotoken('LASTMODIFIED',
! date($datetimeformat, $hash['lastmodified']), $page);
! if (!empty($hash['author']))
! _dotoken('LASTAUTHOR', $hash['author'], $page);
! if (!empty($hash['version']))
! _dotoken('VERSION', $hash['version'], $page);
if (strstr($page, "$FieldSeparator#HITS$FieldSeparator#")) {
_dotoken('HITS', GetHitCount($dbi, $name), $page);
***************
*** 350,361 ****
_dotoken('RELATEDPAGES', LinkRelatedPages($dbi, $name), $page);
}
- }
-
- // valid only for EditLinks
- if ($template == 'EDITLINKS') {
- for ($i = 1; $i <= NUM_LINKS; $i++) {
- $ref = isset($hash['refs'][$i]) ? $hash['refs'][$i] : '';
- _dotoken("R$i", $ref, $page);
- }
}
--- 525,528 ----
Index: transform.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/transform.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** transform.php 2001/02/09 04:00:25 1.13
--- transform.php 2001/02/10 22:15:08 1.14
***************
*** 205,209 ****
$transform->register(WT_SIMPLE_MARKUP, 'wtm_htmlchars');
- $transform->register(WT_SIMPLE_MARKUP, 'wtm_hr');
$transform->register(WT_SIMPLE_MARKUP, 'wtm_linebreak');
$transform->register(WT_SIMPLE_MARKUP, 'wtm_bold_italics');
--- 205,208 ----
***************
*** 217,220 ****
--- 216,220 ----
$transform->register(WT_MODE_MARKUP, 'wtm_preformatted');
$transform->register(WT_MODE_MARKUP, 'wtm_headings');
+ $transform->register(WT_MODE_MARKUP, 'wtm_hr');
$transform->register(WT_MODE_MARKUP, 'wtm_paragraph');
***************
*** 387,394 ****
}
- // four or more dashes to <hr>
- function wtm_hr($line, &$transformer) {
- return ereg_replace("^-{4,}", '<hr>', $line);
- }
// %%% are linebreaks
--- 387,390 ----
***************
*** 411,420 ****
// wiki token: title search dialog
function wtm_title_search($line, &$transformer) {
- global $ScriptUrl;
if (strpos($line, '%%Search%%') !== false) {
! $html = "<form action=\"$ScriptUrl\">\n" .
! "<input type=text size=30 name=search>\n" .
! "<input type=submit value=\"". htmlspecialchars(gettext("Search")) .
! "\"></form>\n";
$line = str_replace('%%Search%%', $html, $line);
}
--- 407,415 ----
// wiki token: title search dialog
function wtm_title_search($line, &$transformer) {
if (strpos($line, '%%Search%%') !== false) {
! $html = LinkPhpwikiURL(
! "phpwiki:?action=search&searchterm=()&searchtype=title",
! gettext("Search"));
!
$line = str_replace('%%Search%%', $html, $line);
}
***************
*** 424,433 ****
// wiki token: fulltext search dialog
function wtm_fulltext_search($line, &$transformer) {
- global $ScriptUrl;
if (strpos($line, '%%Fullsearch%%') !== false) {
! $html = "<form action=\"$ScriptUrl\">\n" .
! "<input type=text size=30 name=full>\n" .
! "<input type=submit value=\"". htmlspecialchars(gettext("Search")) .
! "\"></form>\n";
$line = str_replace('%%Fullsearch%%', $html, $line);
}
--- 419,427 ----
// wiki token: fulltext search dialog
function wtm_fulltext_search($line, &$transformer) {
if (strpos($line, '%%Fullsearch%%') !== false) {
! $html = LinkPhpwikiURL(
! "phpwiki:?action=search&searchterm=()&searchtype=full",
! gettext("Search"));
!
$line = str_replace('%%Fullsearch%%', $html, $line);
}
***************
*** 513,516 ****
--- 507,522 ----
$line = preg_replace("/^!+/", '', $line);
$line = $trfrm->SetHTMLMode($heading, ZERO_LEVEL, 0) . $line;
+ }
+ return $line;
+ }
+
+ // four or more dashes to <hr>
+ // Note this is of type WT_MODE_MARKUP becuase <hr>'s aren't
+ // allowed within <p>'s. (e.g. "<p><hr></p>" is not valid HTML.)
+ function wtm_hr($line, &$trfrm) {
+ if (preg_match('/^-{4,}(.*)$/', $line, $m)) {
+ $line = $trfrm->SetHTMLMode('', ZERO_LEVEL, 0) . '<hr>';
+ if ($m[1])
+ $line .= $trfrm->SetHTMLMode('p', ZERO_LEVEL, 0) . $m[1];
}
return $line;
Index: ziplib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/ziplib.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** ziplib.php 2001/02/08 02:34:32 1.4
--- ziplib.php 2001/02/10 22:15:08 1.5
***************
*** 67,70 ****
--- 67,71 ----
if (!($fp = gzopen($filename, "rb")))
die("gzopen failed");
+ $unz = '';
while ($buf = gzread($fp, 4096))
$unz .= $buf;
***************
*** 265,269 ****
}
! if ($attrib['write_protected'])
$atx = (0100444 << 16) | 1; // S_IFREG + read permissions to everybody.
else
--- 266,270 ----
}
! if (!empty($attrib['write_protected']))
$atx = (0100444 << 16) | 1; // S_IFREG + read permissions to everybody.
else
***************
*** 272,276 ****
$ati = $attrib['is_ascii'] ? 1 : 0;
! if (!$attrib['mtime'])
$attrib['mtime'] = time();
list ($mod_date, $mod_time) = unixtime2dostime($attrib['mtime']);
--- 273,277 ----
$ati = $attrib['is_ascii'] ? 1 : 0;
! if (empty($attrib['mtime']))
$attrib['mtime'] = time();
list ($mod_date, $mod_time) = unixtime2dostime($attrib['mtime']);
***************
*** 278,282 ****
// Construct parts common to "Local file header" and "Central
// directory file header."
!
$head = pack("vvvvvVVVvv",
20, // Version needed to extract (FIXME: is this right?)
--- 279,287 ----
// Construct parts common to "Local file header" and "Central
// directory file header."
! if (!isset($attrib['extra_field']))
! $attrib['extra_field'] = '';
! if (!isset($attrib['file_comment']))
! $attrib['file_comment'] = '';
!
$head = pack("vvvvvVVVvv",
20, // Version needed to extract (FIXME: is this right?)
***************
*** 456,460 ****
preg_match('/^([ !-<>-~]*)(?:([!-<>-~]$)|(.))/s', $string, $match);
$quoted .= $match[1] . $match[2];
! if ($match[3])
$quoted .= sprintf("=%02X", ord($match[3]));
$string = substr($string, strlen($match[0]));
--- 461,465 ----
preg_match('/^([ !-<>-~]*)(?:([!-<>-~]$)|(.))/s', $string, $match);
$quoted .= $match[1] . $match[2];
! if (!empty($match[3]))
$quoted .= sprintf("=%02X", ord($match[3]));
$string = substr($string, strlen($match[0]));
***************
*** 522,528 ****
{
// phpwiki's with versions > 1.2.x shouldn't have references.
! for ($i = 1; $i <= NUM_LINKS; $i++)
! if ($ref = $refs[$i])
! $params["ref$i"] = rawurlencode($ref);
}
--- 527,533 ----
{
// phpwiki's with versions > 1.2.x shouldn't have references.
! for ($i = 1; $i <= 12 /*NUM_LINKS*/; $i++)
! if (!empty($refs[$i]))
! $params["ref$i"] = rawurlencode($refs[$i]);
}
***************
*** 570,575 ****
if (! preg_match("/^\r?\n/", $string, $match))
! die("No blank line after headers:\n '"
! . htmlspecialchars($string) . "'");
$string = substr($string, strlen($match[0]));
--- 575,583 ----
if (! preg_match("/^\r?\n/", $string, $match))
! {
! // No blank line after headers.
! return false;
! }
!
$string = substr($string, strlen($match[0]));
***************
*** 638,641 ****
--- 646,675 ----
}
+ function GenerateFootnotesFromRefs($params)
+ {
+ $footnotes = array();
+ reset($params);
+ while (list($p, $reference) = each($params))
+ {
+ if (preg_match('/^ref([1-9][0-9]*)$/', $p, $m))
+ $footnotes[$m[1]] = sprintf(gettext ("[%d] See [%s]"),
+ $m[1], rawurldecode($reference));
+ }
+
+ if (sizeof($footnotes) > 0)
+ {
+ ksort($footnotes);
+ return "-----\n"
+ . gettext ("!References") . "\n"
+ . join("\n%%%\n", $footnotes) . "\n";
+ }
+ else
+ return "";
+ }
+
+
+ // Convert references in meta-data to footnotes.
+ // Only zip archives generated by phpwiki 1.2.x or earlier should have
+ // references.
function ParseMimeifiedPages ($data)
{
***************
*** 677,699 ****
die("Unknown encoding type: $encoding");
! // Convert references in meta-data to footnotes.
! // Only zip archives generated by phpwiki 1.2.x or earlier should have
! // references.
! $footnotes = '';
! for ($i = 1; $i <= NUM_LINKS; $i++)
! {
! if (empty($params["ref$i"]))
! continue;
! $footnotes .= sprintf(gettext ("[%d] See [%s]"),
! $i, rawurldecode($params["ref$i"])) . "\n%%%\n";
! }
- if ($footnotes)
- {
- $data .= "-----\n";
- $data .= gettext ("!References") . "\n";
- $data .= $footnotes;
- }
-
$pagehash['content'] = preg_split('/[ \t\r]*\n/', chop($data));
--- 711,716 ----
die("Unknown encoding type: $encoding");
! $data .= GenerateFootnotesFromRefs($params);
$pagehash['content'] = preg_split('/[ \t\r]*\n/', chop($data));
--- editlinks.php DELETED ---
|