From 2d05123e911309b41249ad7215bbe0fd56653108 Mon Sep 17 00:00:00 2001 From: ahollosi Date: Wed, 1 Nov 2000 11:31:41 +0000 Subject: [PATCH] fixed E_NOTICE warnings git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@298 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- index.php | 23 ++++++++++++----------- lib/dbmlib.php | 21 +++++---------------- lib/diff.php | 47 ++++++++++++++++++++++++++++------------------- lib/display.php | 4 ++-- lib/editpage.php | 4 ++-- lib/pageinfo.php | 8 ++++---- lib/savepage.php | 4 ++-- lib/stdlib.php | 21 ++++++++++++--------- 8 files changed, 67 insertions(+), 65 deletions(-) diff --git a/index.php b/index.php index 1fb0404a1..f592afce7 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ - + MAX_DBM_ATTEMPTS) { ExitWiki("Cannot open database '$key' : '$file', giving up."); } - $numattempts++; sleep(1); } } - return $dbi; } function CloseDataBase($dbi) { - - ksort($dbi); reset($dbi); while (list($dbmfile, $dbihandle) = each($dbi)) { - dbmclose($dbi[$dbihandle]); + dbmclose($dbihandle); } return; } @@ -201,19 +196,13 @@ } } - function cmp($a,$b) { - if ($a == $b) return 0; - return ($a > $b) ? -1 : 1; - } function InitMostPopular($dbi, $limit) { - // iterate through the whole dbm file for hit counts // sort the results highest to lowest, and return // n..$limit results $pagename = dbmfirstkey($dbi['hitcount']); - $res[$pagename] = dbmfetch($dbi['hitcount'], $pagename); while ($pagename = dbmnextkey($dbi['hitcount'], $pagename)) { @@ -221,7 +210,7 @@ //echo "got $pagename with value " . $res[$pagename] . "
\n"; } - uasort($res, cmp); + arsort($res); return($res); } @@ -240,7 +229,7 @@ "hits" => $hits, "pagename" => $pagename ); - $dbm_mostpopular_cntr++; + // $dbm_mostpopular_cntr++; return $nextpage; } else { return 0; diff --git a/lib/diff.php b/lib/diff.php index 4d019d9e8..3123ab5a9 100644 --- a/lib/diff.php +++ b/lib/diff.php @@ -1,4 +1,4 @@ - + ychanged[$y] = ! $xhash[$line]) ) + if ( ($this->ychanged[$y] = empty($xhash[$line])) ) continue; $yhash[$line] = 1; $this->yv[] = $line; @@ -66,8 +70,9 @@ class _WikiDiffEngine { $line = $from_lines[$x + $skip]; $xlines[] = $line; - if ( ($this->xchanged[$x] = ! $yhash[$line]) ) - continue; + if ( ($this->xchanged[$x] = empty($yhash[$line])) ) + continue; // fixme? what happens to yhash/xhash when + // there are two identical lines?? $this->xv[] = $line; $this->xind[] = $x; } @@ -97,6 +102,7 @@ class _WikiDiffEngine // Skip matching "snake". $x0 = $x; + $ncopy = 0; while ( $x < $n_from && $y < $n_to && !$this->xchanged[$x] && !$this->ychanged[$y]) { @@ -109,6 +115,7 @@ class _WikiDiffEngine // Find deletes. $x0 = $x; + $ndelete = 0; while ($x < $n_from && $this->xchanged[$x]) { ++$x; @@ -126,7 +133,7 @@ class _WikiDiffEngine $this->edits[] = $adds; } } - if ($endskip) + if (!empty($endskip)) $this->edits[] = $endskip; } @@ -353,7 +360,7 @@ class _WikiDiffEngine $start = $i; // Find the end of this run of changes. - while ($changed[++$i]) + while (isset($changed[++$i])) continue; while ($other_changed[$j]) $j++; @@ -386,7 +393,7 @@ class _WikiDiffEngine * point where it corresponds to a changed run in the other file. * CORRESPONDING == LEN means no such point has been found. */ - $corresponding = $other_changed[$j - 1] ? $i : $len; + $corresponding = empty($other_changed[$j - 1]) ? $len : $i; /* * Move the changed region forward, so long as the @@ -793,6 +800,7 @@ class WikiDiffFormatter function _format ($edits, $from_lines) { + $html = ''; $x = 0; $y = 0; $xlim = sizeof($from_lines); @@ -806,7 +814,7 @@ class WikiDiffFormatter else { $ncopy = 0; - if (!$hunk) + if (empty($hunk)) { // Start of an output hunk. $xoff = max(0, $x - $this->context_lines); @@ -835,7 +843,7 @@ class WikiDiffFormatter } $next = next($edits); - if ($hunk) + if (!empty($hunk)) { if ( !$next || $ncopy > 2 * $this->context_lines) { @@ -886,6 +894,7 @@ class WikiDiffFormatter function _emit_lines($lines, $prefix, $color) { + $html = ''; reset($lines); while (list ($junk, $line) = each($lines)) { @@ -913,14 +922,14 @@ class WikiDiffFormatter for (reset($hunks); $hunk = current($hunks); next($hunks)) { - if ($lines = $hunk['c']) - $html .= $this->_emit_lines($lines, + if (!empty($hunk['c'])) + $html .= $this->_emit_lines($hunk['c'], $this->context_prefix, '#ffffff'); - if ($lines = $hunk['d']) - $html .= $this->_emit_lines($lines, + if (!empty($hunk['d'])) + $html .= $this->_emit_lines($hunk['d'], $this->deletes_prefix, '#ccffcc'); - if ($lines = $hunk['a']) - $html .= $this->_emit_lines($lines, + if (!empty($hunk['a'])) + $html .= $this->_emit_lines($hunk['a'], $this->adds_prefix, '#ffcccc'); } @@ -989,12 +998,12 @@ if ($diff) $html .= ''; if (is_array($wiki)) { $html .= ""; - $html .= sprintf(gettext ("version %s"), $wiki[version]); + $html .= sprintf(gettext ("version %s"), $wiki['version']); $html .= ""; $html .= sprintf(gettext ("last modified on %s"), date($datetimeformat, $wiki['lastmodified'])); $html .= ""; - $html .= sprintf (gettext ("by %s"), $wiki[author]); + $html .= sprintf (gettext ("by %s"), $wiki['author']); $html .= ""; } else { $html .= ""; @@ -1007,12 +1016,12 @@ if ($diff) $html .= ''; if (is_array($archive)) { $html .= ""; - $html .= sprintf(gettext ("version %s"), $archive[version]); + $html .= sprintf(gettext ("version %s"), $archive['version']); $html .= ""; $html .= sprintf(gettext ("last modified on %s"), date($datetimeformat, $archive['lastmodified'])); $html .= ""; - $html .= sprintf(gettext ("by %s"), $archive[author]); + $html .= sprintf(gettext ("by %s"), $archive['author']); $html .= ""; } else { $html .= ""; diff --git a/lib/display.php b/lib/display.php index 6fc3c6dea..0cefa6c32 100644 --- a/lib/display.php +++ b/lib/display.php @@ -1,4 +1,4 @@ - + + + \n" . "" . @@ -14,7 +14,7 @@ "
\n" . " + + items[$this->size - 1]; + if($this->size) + return $this->items[$this->size - 1]; + else + return ''; } } @@ -395,7 +398,7 @@ // copy the rest of the page into the new array $pagename = preg_quote($pagename); - for (; $i < ($numlines + 1); $i++) { + for (; $i < $numlines; $i++) { // skip previous entry for $pagename if (preg_match("|\[$pagename\]|", $recentchanges["content"][$i])) { continue; @@ -492,16 +495,16 @@ for ($i = 0; $i < $numBracketLinks; $i++) { $link = ParseAndLink($brktlinks[0][$i]); if($link['type'] == 'wiki' || $link['type'] == 'wiki-unknown') - $wikilinks[$brktlinks[1][$i]]++; + $wikilinks[$brktlinks[1][$i]] = 1; $brktlink = preg_quote($brktlinks[0][$i]); $line = preg_replace("|$brktlink|", '', $line); } if (preg_match_all("/!?$WikiNameRegexp/", $line, $link)) { - for ($i = 0; $link[0][$i]; $i++) { + for ($i = 0; isset($link[0][$i]); $i++) { if($link[0][$i][0] <> '!') - $wikilinks[$link[0][$i]]++; + $wikilinks[$link[0][$i]] = 1; } } } -- 2.45.0