|
From: Geoffrey T. D. <da...@us...> - 2001-02-13 05:54:03
|
Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv13838/lib
Modified Files:
config.php diff.php editpage.php loadsave.php main.php
msql.php pageinfo.php pgsql.php savepage.php stdlib.php
userauth.php ziplib.php
Added Files:
prepend.php
Log Message:
log
***** Error reading new file: [Errno 2] No such file or directory: 'prepend.php'
Index: config.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** config.php 2001/02/12 01:43:10 1.30
--- config.php 2001/02/13 05:54:38 1.31
***************
*** 102,115 ****
// Select database
//
! if (!defined('DBTYPE'))
{
if ( floor(phpversion()) == 3) {
! define('DBTYPE', 'dbm');
} else {
! define('DBTYPE', 'dba');
}
}
! switch (DBTYPE)
{
case 'dbm':
--- 102,115 ----
// Select database
//
! if (empty($DBParams['dbtype']))
{
if ( floor(phpversion()) == 3) {
! $DBParams['dbtype'] = 'dbm';
} else {
! $DBParams['dbtype'] = 'dba';
}
}
! switch ($DBParams['dbtype'])
{
case 'dbm':
***************
*** 132,136 ****
break;
default:
! die(DBTYPE . ": unknown DBTYPE");
}
--- 132,136 ----
break;
default:
! ExitWiki($DBParams['dbtype'] . ": unknown DBTYPE");
}
Index: diff.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/diff.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** diff.php 2001/02/12 01:43:10 1.7
--- diff.php 2001/02/13 05:54:38 1.8
***************
*** 1,4 ****
- <!-- $Id$ -->
<?php
// diff.php
//
--- 1,4 ----
<?php
+ rcs_id('$Id$');
// diff.php
//
***************
*** 60,64 ****
$xlines = array();
$ylines = array();
!
// Ignore lines which do not exist in both files.
for ($x = 0; $x < $n_from; $x++)
--- 60,66 ----
$xlines = array();
$ylines = array();
! $this->xchanged = array();
! $this->ychanged = array();
!
// Ignore lines which do not exist in both files.
for ($x = 0; $x < $n_from; $x++)
***************
*** 83,87 ****
$this->xind[] = $x;
}
!
// Find the LCS.
$this->_compareseq(0, sizeof($this->xv), 0, sizeof($this->yv));
--- 85,89 ----
$this->xind[] = $x;
}
!
// Find the LCS.
$this->_compareseq(0, sizeof($this->xv), 0, sizeof($this->yv));
***************
*** 129,133 ****
// Find adds.
! if ($this->ychanged[$y])
{
$adds = array();
--- 131,135 ----
// Find adds.
! if (!empty($this->ychanged[$y]))
{
$adds = array();
***************
*** 526,530 ****
$edit[] = "" . $from_lines[$x++];
}
! else die("assertion error");
$rev->edits[] = $edit;
--- 528,533 ----
$edit[] = "" . $from_lines[$x++];
}
! else
! trigger_error("assertion error", E_USER_ERROR);
$rev->edits[] = $edit;
***************
*** 568,572 ****
}
else if (!$left || !$right)
! die ("assertion error");
else if (!is_array($left) && $left > 0)
{ // Left op is a copy.
--- 571,575 ----
}
else if (!$left || !$right)
! trigger_error("assertion error", E_USER_ERROR);
else if (!is_array($left) && $left > 0)
{ // Left op is a copy.
***************
*** 588,592 ****
else
{ // Left op is an add.
! if (!is_array($left)) die('assertion error');
$nleft = sizeof($left);
if ($nleft <= abs($right))
--- 591,595 ----
else
{ // Left op is an add.
! assert('is_array($left)');
$nleft = sizeof($left);
if ($nleft <= abs($right))
***************
*** 671,675 ****
}
else
! die("assertion error");
}
echo "</ol>";
--- 674,678 ----
}
else
! trigger_error("assertion error", E_USER_ERROR);
}
echo "</ol>";
***************
*** 925,932 ****
{
$html = '';
! $prefix = Element('td', array('bgcolor' => '#cccccc'), $prefix);
reset($lines);
while (list ($junk, $line) = each($lines))
{
$line = empty($line) ? ' ' : htmlspecialchars($line);
$html .= Element('tr',
--- 928,936 ----
{
$html = '';
! $prefix = Element('td', array('bgcolor' => '#cccccc', 'width' => "1%"), $prefix);
reset($lines);
while (list ($junk, $line) = each($lines))
{
+ $line = rtrim($line);
$line = empty($line) ? ' ' : htmlspecialchars($line);
$html .= Element('tr',
Index: editpage.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/editpage.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** editpage.php 2001/02/12 01:43:10 1.11
--- editpage.php 2001/02/13 05:54:38 1.12
***************
*** 1,4 ****
- <!-- $Id$ -->
<?php
// editpage relies on $pagename, $version
--- 1,4 ----
<?php
+ rcs_id('$Id$');
// editpage relies on $pagename, $version
Index: loadsave.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/loadsave.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** loadsave.php 2001/02/12 01:43:10 1.1
--- loadsave.php 2001/02/13 05:54:38 1.2
***************
*** 168,171 ****
--- 168,173 ----
$mesg = array();
$version = $page['version'];
+ $isnew = true;
+
if ($version)
$mesg[] = sprintf(gettext("version %s"), $version);
***************
*** 175,180 ****
if (is_array($current = RetrievePage($dbi, $pagename, $WikiPageStore)))
{
! // FIXME: should compare author, flags ... as well!
! if (arrays_equal($current['content'], $page['content']))
{
$mesg[] = sprintf(gettext("is identical to current version %d"),
--- 177,185 ----
if (is_array($current = RetrievePage($dbi, $pagename, $WikiPageStore)))
{
! $isnew = false;
!
! if (arrays_equal($current['content'], $page['content'])
! && $current['author'] == $page['author']
! && $current['flags'] == $page['flags'])
{
$mesg[] = sprintf(gettext("is identical to current version %d"),
***************
*** 202,206 ****
{
InsertPage($dbi, $pagename, $page);
!
$mesg[] = gettext("- saved");
if ($version != $page['version'])
--- 207,212 ----
{
InsertPage($dbi, $pagename, $page);
! UpdateRecentChanges($dbi, $pagename, $isnew);
!
$mesg[] = gettext("- saved");
if ($version != $page['version'])
***************
*** 243,247 ****
$mtime = time(); // Last resort.
! $defaults = array('author' => 'The PhpWiki programming team',
'pagename' => rawurldecode($basename),
'flags' => 0,
--- 249,253 ----
$mtime = time(); // Last resort.
! $defaults = array('author' => $GLOBALS['user']->id(),
'pagename' => rawurldecode($basename),
'flags' => 0,
***************
*** 268,278 ****
}
! function LoadZip ($dbi, $zipfile, $files = false)
{
$zip = new ZipReader($zipfile);
while (list ($fn, $data, $attrib) = $zip->readFile())
{
! if ($files && !in_array(basename($fn), $files))
continue;
LoadFile($dbi, $fn, $data, $attrib['mtime']);
--- 274,290 ----
}
! function LoadZip ($dbi, $zipfile, $files = false, $exclude = false)
{
$zip = new ZipReader($zipfile);
while (list ($fn, $data, $attrib) = $zip->readFile())
{
! // FIXME: basename("filewithnoslashes") seems to return garbage sometimes.
! $fn = basename("/dummy/" . $fn);
! if ( ($files && !in_array($fn, $files))
! || ($exclude && in_array($fn, $exclude)) )
! {
! print Element('dt', LinkExistingWikiWord($fn)) . QElement('dd', 'Skipping');
continue;
+ }
LoadFile($dbi, $fn, $data, $attrib['mtime']);
***************
*** 280,292 ****
}
! function LoadDir ($dbi, $dirname, $files = false)
{
$handle = opendir($dir = $dirname);
while ($fn = readdir($handle))
{
- if ($files && !in_array($fn, $files))
- continue;
if (filetype("$dir/$fn") != 'file')
continue;
LoadFile($dbi, "$dir/$fn");
}
--- 292,310 ----
}
! function LoadDir ($dbi, $dirname, $files = false, $exclude = false)
{
$handle = opendir($dir = $dirname);
while ($fn = readdir($handle))
{
if (filetype("$dir/$fn") != 'file')
continue;
+
+ if ( ($files && !in_array($fn, $files))
+ || ($exclude && in_array($fn, $exclude)) )
+ {
+ print Element('dt', LinkExistingWikiWord($fn)) . QElement('dd', 'Skipping');
+ continue;
+ }
+
LoadFile($dbi, "$dir/$fn");
}
***************
*** 314,318 ****
! function LoadAny ($dbi, $file_or_dir, $files = false)
{
$type = filetype($file_or_dir);
--- 332,336 ----
! function LoadAny ($dbi, $file_or_dir, $files = false, $exclude = false)
{
$type = filetype($file_or_dir);
***************
*** 320,334 ****
if ($type == 'dir')
{
! LoadDir($dbi, $file_or_dir, $files);
}
else if ($type != 'file' && !preg_match('/^(http|ftp):/', $file_or_dir))
{
! die("Bad file type: $type");
}
else if (IsZipFile($file_or_dir))
{
! LoadZip($dbi, $file_or_dir, $files);
}
! else if (!$files || in_array(basename($file_or_dir), $files))
{
LoadFile($dbi, $file_or_dir);
--- 338,352 ----
if ($type == 'dir')
{
! LoadDir($dbi, $file_or_dir, $files, $exclude);
}
else if ($type != 'file' && !preg_match('/^(http|ftp):/', $file_or_dir))
{
! ExitWiki("Bad file type: $type");
}
else if (IsZipFile($file_or_dir))
{
! LoadZip($dbi, $file_or_dir, $files, $exclude);
}
! else /* if (!$files || in_array(basename($file_or_dir), $files)) */
{
LoadFile($dbi, $file_or_dir);
***************
*** 340,344 ****
StartLoadDump("Loading '$source'");
echo "<dl>\n";
! LoadAny($dbi, $source);
echo "</dl>\n";
EndLoadDump();
--- 358,362 ----
StartLoadDump("Loading '$source'");
echo "<dl>\n";
! LoadAny($dbi, $source, false, array(gettext('RecentChanges')));
echo "</dl>\n";
EndLoadDump();
***************
*** 347,351 ****
function SetupWiki ($dbi)
{
! global $GenericPages, $LANG;
StartLoadDump('Loading up virgin wiki');
--- 365,372 ----
function SetupWiki ($dbi)
{
! global $GenericPages, $LANG, $user;
!
! //FIXME: This is a hack
! $user->userid = 'The PhpWiki programming team';
StartLoadDump('Loading up virgin wiki');
***************
*** 369,373 ****
if (!is_uploaded_file($tmp_name))
! die('Bad zipfile'); // Possible malicious attack.
// Dump http headers.
--- 390,394 ----
if (!is_uploaded_file($tmp_name))
! ExitWiki('Bad file post'); // Possible malicious attack.
// Dump http headers.
***************
*** 381,385 ****
if (IsZipFile($fd))
! LoadZip($dbi, $fd);
else
Loadfile($dbi, $name, fread($fd, MAX_UPLOAD_SIZE));
--- 402,406 ----
if (IsZipFile($fd))
! LoadZip($dbi, $fd, false, array(gettext('RecentChanges')));
else
Loadfile($dbi, $name, fread($fd, MAX_UPLOAD_SIZE));
Index: main.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/main.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** main.php 2001/02/12 01:43:10 1.1
--- main.php 2001/02/13 05:54:38 1.2
***************
*** 1,4 ****
! <?php $RCS_IDS[] = '$Id$';
! function rcs_id($id) { $GLOBALS['RCS_IDS'][] = $id; }
include "lib/config.php";
include "lib/stdlib.php";
--- 1,4 ----
! <?php
! rcs_id('$Id$');
include "lib/config.php";
include "lib/stdlib.php";
***************
*** 47,51 ****
'info', 'diff', 'search',
'edit', 'save',
! 'login', 'logout') );
}
--- 47,52 ----
'info', 'diff', 'search',
'edit', 'save',
! 'login', 'logout',
! 'setprefs') );
}
***************
*** 75,80 ****
include_once("lib/loadsave.php");
SetupWiki($dbi);
! CloseDataBase($dbi);
! exit;
}
--- 76,80 ----
include_once("lib/loadsave.php");
SetupWiki($dbi);
! ExitWiki();
}
***************
*** 83,87 ****
$user->must_be_admin($action);
!
switch ($action) {
case 'edit':
--- 83,91 ----
$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':
***************
*** 111,114 ****
--- 115,121 ----
include_once("lib/loadsave.php");
MakeWikiZip($dbi, isset($include) && $include == 'all');
+ // I don't think it hurts to add cruft at the end of the zip file.
+ echo "\n========================================================\n";
+ echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$RCS_IDS\n";
break;
***************
*** 144,151 ****
break;
case 'browse':
case 'login':
case 'logout':
! include "lib/display.php"; // defaults to FrontPage
break;
--- 151,171 ----
break;
+ case 'setprefs':
+ $prefs = $user->getPreferences($GLOBALS);
+ if (!empty($edit_area_width))
+ $prefs['edit_area.width'] = $edit_area_width;
+ if (!empty($edit_area_height))
+ $prefs['edit_area.height'] = $edit_area_height;
+ $user->setPreferences($prefs);
+
+ PostponeErrorMessages(E_ALL & ~E_NOTICE);
+
+ include "lib/display.php";
+ break;
+
case 'browse':
case 'login':
case 'logout':
! include "lib/display.php";
break;
***************
*** 154,159 ****
break;
}
- CloseDataBase($dbi);
// For emacs users
// Local Variables:
--- 174,180 ----
break;
}
+
+ ExitWiki();
// For emacs users
// Local Variables:
Index: msql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/msql.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** msql.php 2001/02/12 01:43:10 1.7
--- msql.php 2001/02/13 05:54:38 1.8
***************
*** 1,4 ****
- <!-- $Id$ -->
<?php
/*
--- 1,4 ----
<?php
+ rcs_id('$Id$');
/*
Index: pageinfo.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/pageinfo.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** pageinfo.php 2001/02/12 01:43:10 1.7
--- pageinfo.php 2001/02/13 05:54:38 1.8
***************
*** 1,5 ****
- <!-- $Id$ -->
- <!-- Display the internal structure of a page. Steve Wainstead, June 2000 -->
<?php
--- 1,5 ----
<?php
+ rcs_id('$Id$');
+ // Display the internal structure of a page. Steve Wainstead, June 2000
Index: pgsql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/pgsql.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** pgsql.php 2001/02/12 01:43:10 1.5
--- pgsql.php 2001/02/13 05:54:38 1.6
***************
*** 1,4 ****
- <!-- $Id$ -->
<?php
/*
--- 1,4 ----
<?php
+ rcs_id('$Id$');
/*
***************
*** 49,54 ****
if (!($dbc = pg_pconnect(join(' ', $args)))) {
! echo "Cannot establish connection to database, giving up.";
! exit();
}
--- 49,53 ----
if (!($dbc = pg_pconnect(join(' ', $args)))) {
! ExitWiki("Cannot establish connection to database, giving up.");
}
Index: savepage.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/savepage.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** savepage.php 2001/02/12 01:43:10 1.11
--- savepage.php 2001/02/13 05:54:38 1.12
***************
*** 8,80 ****
*/
- function UpdateRecentChanges($dbi, $pagename, $isnewpage)
- {
- global $user;
- global $dateformat;
- global $WikiPageStore;
-
- $recentchanges = RetrievePage($dbi, gettext ("RecentChanges"), $WikiPageStore);
-
- // this shouldn't be necessary, since PhpWiki loads
- // default pages if this is a new baby Wiki
- if ($recentchanges == -1) {
- $recentchanges = array();
- }
-
- $now = time();
- $today = date($dateformat, $now);
-
- if (date($dateformat, $recentchanges['lastmodified']) != $today) {
- $isNewDay = TRUE;
- $recentchanges['lastmodified'] = $now;
- } else {
- $isNewDay = FALSE;
- }
-
- $numlines = sizeof($recentchanges['content']);
- $newpage = array();
- $k = 0;
-
- // scroll through the page to the first date and break
- // dates are marked with "____" at the beginning of the line
- for ($i = 0; $i < $numlines; $i++) {
- if (preg_match("/^____/",
- $recentchanges['content'][$i])) {
- break;
- } else {
- $newpage[$k++] = $recentchanges['content'][$i];
- }
- }
-
- // if it's a new date, insert it
- $newpage[$k++] = $isNewDay ? "____$today\r"
- : $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)
- $newpage[$k++] = "\r";
-
- // copy the rest of the page into the new array
- // and skip previous entry for $pagename
- $pagename = preg_quote($pagename);
- for (; $i < $numlines; $i++) {
- if (!preg_match("|\[$pagename\]|", $recentchanges['content'][$i])) {
- $newpage[$k++] = $recentchanges['content'][$i];
- }
- }
-
- $recentchanges['content'] = $newpage;
-
- InsertPage($dbi, gettext ("RecentChanges"), $recentchanges);
- }
-
function ConcurrentUpdates($pagename)
--- 8,11 ----
***************
*** 104,108 ****
echo GeneratePage('MESSAGE', $html,
sprintf (gettext ("Problem while updating %s"), $pagename), 0);
! exit;
}
--- 35,39 ----
echo GeneratePage('MESSAGE', $html,
sprintf (gettext ("Problem while updating %s"), $pagename), 0);
! ExitWiki();
}
Index: stdlib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** stdlib.php 2001/02/12 01:43:10 1.28
--- stdlib.php 2001/02/13 05:54:38 1.29
***************
*** 57,61 ****
if ($missing_ok)
return false;
! die("$file: file not found");
}
--- 57,61 ----
if ($missing_ok)
return false;
! ExitWiki("$file: file not found");
}
***************
*** 73,95 ****
- function ExitWiki($errormsg)
- {
- static $exitwiki = 0;
- global $dbi;
-
- if($exitwiki) // just in case CloseDataBase calls us
- exit();
- $exitwiki = 1;
- CloseDataBase($dbi);
-
- if($errormsg <> '') {
- print "<P><hr noshade><h2>" . gettext("WikiFatalError") . "</h2>\n";
- print $errormsg;
- print "\n</BODY></HTML>";
- }
- exit;
- }
-
function DataURL($url) {
if (preg_match('@^(\w+:|/)@', $url))
--- 73,77 ----
***************
*** 175,190 ****
}
! 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'))),
! '?');
}
--- 157,176 ----
}
! function LinkExistingWikiWord($wikiword, $linktext='', $class = 'wikiword') {
! return Element('a', array('href' => WikiURL($wikiword),
! 'class' => $class),
$linktext ? $linktext : $wikiword);
}
! function LinkUnknownWikiWord($wikiword, $linktext='', $class = 'unknownwikiword') {
if (empty($linktext))
$linktext = $wikiword;
! return Element('span', array('class' => 'unknownwikiword'),
! QElement('u', array('class' => 'unknownwikiword'), $linktext) .
! QElement('a',
! array('href' => WikiURL($wikiword, array('action' => 'edit')),
! 'class' => 'unknownwikiword'),
! '?'));
}
***************
*** 534,540 ****
_dotoken('PAGE', htmlspecialchars($name), $page);
_dotoken('LOGO', htmlspecialchars(DataURL($logo)), $page);
! global $RCS_IDS;
! _dotoken('RCS_IDS', join("\n", $RCS_IDS), $page);
!
// FIXME: Clean up this stuff
$browse_page = WikiURL($name);
--- 520,530 ----
_dotoken('PAGE', htmlspecialchars($name), $page);
_dotoken('LOGO', htmlspecialchars(DataURL($logo)), $page);
!
! _dotoken('RCS_IDS', $GLOBALS['RCS_IDS'], $page);
!
! $prefs = $user->getPreferences();
! _dotoken('EDIT_AREA_WIDTH', $prefs['edit_area.width'], $page);
! _dotoken('EDIT_AREA_HEIGHT', $prefs['edit_area.height'], $page);
!
// FIXME: Clean up this stuff
$browse_page = WikiURL($name);
***************
*** 571,574 ****
--- 561,634 ----
return $page;
}
+
+ function UpdateRecentChanges($dbi, $pagename, $isnewpage)
+ {
+ global $user;
+ global $dateformat;
+ global $WikiPageStore;
+
+ $recentchanges = RetrievePage($dbi, gettext ("RecentChanges"), $WikiPageStore);
+
+ // this shouldn't be necessary, since PhpWiki loads
+ // default pages if this is a new baby Wiki
+ if ($recentchanges == -1) {
+ $recentchanges = array();
+ }
+
+ $now = time();
+ $today = date($dateformat, $now);
+
+ if (date($dateformat, $recentchanges['lastmodified']) != $today) {
+ $isNewDay = TRUE;
+ $recentchanges['lastmodified'] = $now;
+ } else {
+ $isNewDay = FALSE;
+ }
+
+ $numlines = sizeof($recentchanges['content']);
+ $newpage = array();
+ $k = 0;
+
+ // scroll through the page to the first date and break
+ // dates are marked with "____" at the beginning of the line
+ for ($i = 0; $i < $numlines; $i++) {
+ if (preg_match("/^____/",
+ $recentchanges['content'][$i])) {
+ break;
+ } else {
+ $newpage[$k++] = $recentchanges['content'][$i];
+ }
+ }
+
+ // if it's a new date, insert it
+ $newpage[$k++] = $isNewDay ? "____$today\r"
+ : $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)
+ $newpage[$k++] = "\r";
+
+ // copy the rest of the page into the new array
+ // and skip previous entry for $pagename
+ $pagename = preg_quote($pagename);
+ for (; $i < $numlines; $i++) {
+ if (!preg_match("|\[$pagename\]|", $recentchanges['content'][$i])) {
+ $newpage[$k++] = $recentchanges['content'][$i];
+ }
+ }
+
+ $recentchanges['content'] = $newpage;
+
+ InsertPage($dbi, gettext ("RecentChanges"), $recentchanges);
+ }
+
// For emacs users
// Local Variables:
Index: userauth.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/userauth.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** userauth.php 2001/02/12 01:43:10 1.2
--- userauth.php 2001/02/13 05:54:38 1.3
***************
*** 1,3 ****
! <?php rcs_id('$Id');
// It is anticipated that when userid support is added to phpwiki,
--- 1,3 ----
! <?php rcs_id('$Id$');
// It is anticipated that when userid support is added to phpwiki,
***************
*** 82,85 ****
--- 82,111 ----
}
+
+ // This is a bit of a hack:
+ function setPreferences ($prefs) {
+ global $WIKI_PREFS;
+ $WIKI_PREFS = serialize($prefs);
+ $expires = time() + 365 * 24 * 3600; // expire in a year
+ setcookie('WIKI_PREFS', $WIKI_PREFS, $expires, '/');
+ }
+
+ function getPreferences () {
+ $prefs = array('edit_area.width' => 80,
+ 'edit_area.height' => 22);
+
+ $prefcookie = unserialize(fix_magic_quotes_gpc($GLOBALS['WIKI_PREFS']));
+
+ while (list($k, $v) = each($prefs))
+ if (!empty($prefcookie[$k]))
+ $prefs[$k] = $prefcookie[$k];
+
+ // Some sanity checks. (FIXME: should move somewhere else)
+ if (!($prefs['edit_area.width'] >= 30 && $prefs['edit_area.width'] <= 150))
+ $prefs['edit_area.width'] = 80;
+ if (!($prefs['edit_area.height'] >= 5 && $prefs['edit_area.height'] <= 80))
+ $prefs['edit_area.height'] = 22;
+ return $prefs;
+ }
function _get_authenticated_userid () {
***************
*** 129,133 ****
header("HTTP/1.0 401 Unauthorized");
echo gettext ("You entered an invalid login or password.");
! exit;
}
}
--- 155,159 ----
header("HTTP/1.0 401 Unauthorized");
echo gettext ("You entered an invalid login or password.");
! ExitWiki();
}
}
Index: ziplib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/ziplib.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** ziplib.php 2001/02/12 01:43:10 1.6
--- ziplib.php 2001/02/13 05:54:38 1.7
***************
*** 39,55 ****
$filename = gzip_tempnam();
if (!($fp = gzopen($filename, "wb")))
! die("gzopen failed");
gzwrite($fp, $data, strlen($data));
if (!gzclose($fp))
! die("gzclose failed");
$size = filesize($filename);
if (!($fp = fopen($filename, "rb")))
! die("fopen failed");
if (!($z = fread($fp, $size)) || strlen($z) != $size)
! die("fread failed");
if (!fclose($fp))
! die("fclose failed");
unlink($filename);
--- 39,55 ----
$filename = gzip_tempnam();
if (!($fp = gzopen($filename, "wb")))
! ExitWiki("gzopen failed");
gzwrite($fp, $data, strlen($data));
if (!gzclose($fp))
! ExitWiki("gzclose failed");
$size = filesize($filename);
if (!($fp = fopen($filename, "rb")))
! ExitWiki("fopen failed");
if (!($z = fread($fp, $size)) || strlen($z) != $size)
! ExitWiki("fread failed");
if (!fclose($fp))
! ExitWiki("fclose failed");
unlink($filename);
***************
*** 60,75 ****
$filename = gzip_tempnam();
if (!($fp = fopen($filename, "wb")))
! die("fopen failed");
fwrite($fp, $data, strlen($data));
if (!fclose($fp))
! die("fclose failed");
if (!($fp = gzopen($filename, "rb")))
! die("gzopen failed");
$unz = '';
while ($buf = gzread($fp, 4096))
$unz .= $buf;
if (!gzclose($fp))
! die("gzclose failed");
unlink($filename);
--- 60,75 ----
$filename = gzip_tempnam();
if (!($fp = fopen($filename, "wb")))
! ExitWiki("fopen failed");
fwrite($fp, $data, strlen($data));
if (!fclose($fp))
! ExitWiki("fclose failed");
if (!($fp = gzopen($filename, "rb")))
! ExitWiki("gzopen failed");
$unz = '';
while ($buf = gzread($fp, 4096))
$unz .= $buf;
if (!gzclose($fp))
! ExitWiki("gzclose failed");
unlink($filename);
***************
*** 161,174 ****
if ($magic != GZIP_MAGIC)
! die("Bad gzip magic");
if ($comp_type != GZIP_DEFLATE)
! die("Bad gzip comp type");
if (($flags & 0x3e) != 0)
! die(sprintf("Bad flags (0x%02x)", $flags));
$gz_header_len = 10;
$gz_data_len = strlen($z) - $gz_header_len - 8;
if ($gz_data_len < 0)
! die("not enough gzip output?");
extract(unpack("Vcrc32", substr($z, $gz_header_len + $gz_data_len)));
--- 161,174 ----
if ($magic != GZIP_MAGIC)
! ExitWiki("Bad gzip magic");
if ($comp_type != GZIP_DEFLATE)
! ExitWiki("Bad gzip comp type");
if (($flags & 0x3e) != 0)
! ExitWiki(sprintf("Bad flags (0x%02x)", $flags));
$gz_header_len = 10;
$gz_data_len = strlen($z) - $gz_header_len - 8;
if ($gz_data_len < 0)
! ExitWiki("not enough gzip output?");
extract(unpack("Vcrc32", substr($z, $gz_header_len + $gz_data_len)));
***************
*** 183,187 ****
{
if (!function_exists('gzopen'))
! die("Can't inflate data: zlib support not enabled in this PHP");
// Reconstruct gzip header and ungzip the data.
--- 183,187 ----
{
if (!function_exists('gzopen'))
! ExitWiki("Can't inflate data: zlib support not enabled in this PHP");
// Reconstruct gzip header and ungzip the data.
***************
*** 345,349 ****
* BUGS:
*
! * Many of the die()'s should probably be warn()'s (eg. CRC mismatch).
*
* Only a subset of zip formats is recognized. (I think that unsupported
--- 345,349 ----
* BUGS:
*
! * Many of the ExitWiki()'s should probably be warn()'s (eg. CRC mismatch).
*
* Only a subset of zip formats is recognized. (I think that unsupported
***************
*** 361,365 ****
$this->fp = $zipfile; // File already open
else if (!($this->fp = fopen($zipfile, "rb")))
! die("Can't open zip file '$zipfile' for reading");
}
--- 361,365 ----
$this->fp = $zipfile; // File already open
else if (!($this->fp = fopen($zipfile, "rb")))
! ExitWiki("Can't open zip file '$zipfile' for reading");
}
***************
*** 367,371 ****
$chunk = fread($this->fp, $nbytes);
if (strlen($chunk) != $nbytes)
! die("Unexpected EOF in zip file");
return $chunk;
}
--- 367,371 ----
$chunk = fread($this->fp, $nbytes);
if (strlen($chunk) != $nbytes)
! ExitWiki("Unexpected EOF in zip file");
return $chunk;
}
***************
*** 391,401 ****
{
if ($magic != ZIP_CENTHEAD_MAGIC)
! die("Bad header type: " . htmlspecialchars($magic)); // FIXME: better message?
return $this->done();
}
if (($flags & 0x21) != 0)
! die("Encryption and/or zip patches not supported.");
if (($flags & 0x08) != 0)
! die("Postponed CRC not yet supported."); // FIXME: ???
$filename = $this->_read($filename_len);
--- 391,401 ----
{
if ($magic != ZIP_CENTHEAD_MAGIC)
! ExitWiki("Bad header type: " . htmlspecialchars($magic)); // FIXME: better message?
return $this->done();
}
if (($flags & 0x21) != 0)
! ExitWiki("Encryption and/or zip patches not supported.");
if (($flags & 0x08) != 0)
! ExitWiki("Postponed CRC not yet supported."); // FIXME: ???
$filename = $this->_read($filename_len);
***************
*** 413,423 ****
$crc = zip_crc32($data);
if ($crc32 != $crc)
! die(sprintf("CRC mismatch %x != %x", $crc, $crc32));
}
else
! die("Compression method $comp_method unsupported");
if (strlen($data) != $uncomp_size)
! die(sprintf("Uncompressed size mismatch %d != %d",
strlen($data), $uncomp_size));
--- 413,423 ----
$crc = zip_crc32($data);
if ($crc32 != $crc)
! ExitWiki(sprintf("CRC mismatch %x != %x", $crc, $crc32));
}
else
! ExitWiki("Compression method $comp_method unsupported");
if (strlen($data) != $uncomp_size)
! ExitWiki(sprintf("Uncompressed size mismatch %d != %d",
strlen($data), $uncomp_size));
***************
*** 597,601 ****
. '\s*(' . MIME_TOKEN_REGEXP . ')\s*:x',
$string, $match))
! die ("Bad MIME content-type");
$type = strtolower($match[1]);
--- 597,601 ----
. '\s*(' . MIME_TOKEN_REGEXP . ')\s*:x',
$string, $match))
! ExitWiki ("Bad MIME content-type");
$type = strtolower($match[1]);
***************
*** 625,629 ****
{
if (!$boundary)
! die("No boundary?");
$boundary = preg_quote($boundary);
--- 625,629 ----
{
if (!$boundary)
! ExitWiki("No boundary?");
$boundary = preg_quote($boundary);
***************
*** 645,649 ****
return $parts; // End boundary found.
}
! die("No end boundary?");
}
--- 645,649 ----
return $parts; // End boundary found.
}
! ExitWiki("No end boundary?");
}
***************
*** 677,685 ****
{
if (!($headers = ParseRFC822Headers($data))
! || !($typeheader = $headers['content-type']))
{
//warn("Can't find content-type header");
return false;
}
if (!(list ($type, $subtype, $params) = ParseMimeContentType($typeheader)))
--- 677,686 ----
{
if (!($headers = ParseRFC822Headers($data))
! || empty($headers['content-type']))
{
//warn("Can't find content-type header");
return false;
}
+ $typeheader = $headers['content-type'];
if (!(list ($type, $subtype, $params) = ParseMimeContentType($typeheader)))
***************
*** 718,722 ****
$data = QuotedPrintableDecode($data);
else if ($encoding && $encoding != 'binary')
! die("Unknown encoding type: $encoding");
$data .= GenerateFootnotesFromRefs($params);
--- 719,723 ----
$data = QuotedPrintableDecode($data);
else if ($encoding && $encoding != 'binary')
! ExitWiki("Unknown encoding type: $encoding");
$data .= GenerateFootnotesFromRefs($params);
|