1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
|
<?php
// WebSVN - Subversion repository viewing via the web using PHP
// Copyright (C) 2004 Tim Armes
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// --
//
// log.php
//
// Show the logs for the given path
require_once("include/setup.inc");
require_once("include/svnlook.inc");
require_once("include/utils.inc");
require_once("include/template.inc");
require_once("include/bugtraq.inc");
$page = (int)@$_REQUEST["page"];
$all = (@$_REQUEST["all"] == 1)?1:0;
$isDir = (@$_REQUEST["isdir"] == 1)?1:0;
$dosearch = (@$_REQUEST["logsearch"] == 1)?1:0;
$search = trim(@$_REQUEST["search"]);
$words = explode(" ", $search);
$fromRev = (int)@$_REQUEST["fr"];
// Max number of results to find at a time
$numSearchResults = 10;
if ($search == "")
$dosearch = false;
// removeAccents
//
// Remove all the accents from a string. This function doesn't seem
// ideal, but expecting everyone to install 'unac' seems a little
// excessive as well...
function removeAccents($string)
{
return strtr($string,
"",
"AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn");
}
// Normalise the search words
foreach ($words as $index => $word)
{
$words[$index] = strtolower(removeAccents($word));
// Remove empty string introduced by multiple spaces
if ($words[$index] == "")
unset($words[$index]);
}
if (empty($page)) $page = 1;
// If searching, display all the results
if ($dosearch) $all = true;
$maxperpage = 20;
// Make sure that we have a repository
if (!isset($rep))
{
echo $lang["NOREP"];
exit;
}
$svnrep = new SVNRepository($rep->path);
$passrev = $rev;
// If there's no revision info, go to the lastest revision for this path
$history = $svnrep->getHistory($path);
$youngest = $history[0]["rev"];
if (empty($rev))
$rev = $youngest;
if ($path == "" || $path{0} != "/")
$ppath = "/".$path;
else
$ppath = $path;
$vars["action"] = $lang["LOG"];
$vars["repname"] = $rep->name;
$vars["rev"] = $rev;
$vars["path"] = $ppath;
createDirLinks($rep, $ppath, $passrev, $showchanged);
$logurl = $config->getURL($rep, $path, "log");
if ($rev != $youngest)
$vars["goyoungestlink"] = "<a href=\"${logurl}sc=1\">${lang["GOYOUNGEST"]}</a>";
else
$vars["goyoungestlink"] = "";
// We get the bugtraq variable just once based on the HEAD
$bugtraq = new Bugtraq($rep, $svnrep, $ppath);
$history = $svnrep->getHistory($path, $rev);
// Get the number of separate revisions
$revisions = count($history);
if ($all)
{
$firstrevindex = 0;
$lastrevindex = $revisions - 1;
$pages = 1;
}
else
{
// Calculate the number of pages
$pages = floor($revisions / $maxperpage);
if (($revisions % $maxperpage) > 0) $pages++;
if ($page > $pages) $page = $pages;
// Word out where to start and stop
$firstrevindex = ($page - 1) * $maxperpage;
$lastrevindex = $firstrevindex + $maxperpage - 1;
if ($lastrevindex > $revisions - 1) $lastrevindex = $revisions - 1;
}
$vars["logsearch_moreresultslink"] = "";
$row = 0;
$index = 0;
$listing = array();
$found = false;
for ($n = $firstrevindex; $n <= $lastrevindex; $n++)
{
$r = $history[$n];
// Assume a good match
$match = true;
$log = $svnrep->getLogDetails($path, $r["rev"]);
// Check the log for the search words, if searching
if ($dosearch)
{
if ((empty($fromRev) || $fromRev > $r["rev"]))
{
// Turn all the HTML entities into real characters.
if (version_compare(phpversion(), "4.1.0", "<"))
$msg = html_entity_decode($log["message"]);
else
$msg = html_entity_decode($log["message"], ENT_COMPAT, $config->outputEnc);
// Make sure that each word in the search in also in the log
foreach($words as $word)
{
if (strpos(strtolower(removeAccents($msg)), $word) === false)
{
$match = false;
break;
}
}
if ($match)
{
$numSearchResults--;
$found = true;
}
}
else
$match = false;
}
if ($match)
{
// Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!)
$rpath = $r["path"];
if ($isDir && $rpath{strlen($rpath) - 1} != "/")
$rpath .= "/";
// Find the parent path (or the whole path if it's already a directory)
$pos = strrpos($rpath, "/");
$parent = substr($rpath, 0, $pos + 1);
$url = $config->getURL($rep, $parent, "dir");
$listing[$index]["compare_box"] = "<input type=\"checkbox\" name=\"compare[]\" value=\"$parent@${r["rev"]}\" onClick=\"checkCB(this)\">";
$listing[$index]["revlink"] = "<a href=\"${url}rev=${r["rev"]}&sc=1\">${r["rev"]}</a>";
if ($isDir)
{
$url = $config->getURL($rep, $rpath, "dir");
$listing[$index]["revpathlink"] = "<a href=\"${url}rev=${r["rev"]}&sc=$showchanged\">$rpath</a>";
}
else
{
$url = $config->getURL($rep, $rpath, "file");
$listing[$index]["revpathlink"] = "<a href=\"${url}rev=${r["rev"]}&sc=$showchanged\">$rpath</a>";
}
$listing[$index]["revauthor"] = $log["author"];
$listing[$index]["revage"] = $log["age"];
$listing[$index]["revlog"] = nl2br($bugtraq->replaceIDs(create_anchors($log["message"])));
$listing[$index]["rowparity"] = "$row";
$row = 1 - $row;
$index++;
}
// If we've reached the search limit, stop here...
if (!$numSearchResults)
{
$url = $config->getURL($rep, $path, "log");
$vars["logsearch_moreresultslink"] = "<a href=\"${url}rev=$revamp;&sc=$showchanged&isdir=$isDir&logsearch=1&search=$search&fr=${r["rev"]}\">${lang["MORERESULTS"]}</a>";
break;
}
}
$vars["logsearch_resultsfound"] = true;
if ($dosearch && !$found)
{
if ($fromRev == 0)
{
$vars["logsearch_nomatches"] = true;
$vars["logsearch_resultsfound"] = false;
}
else
$vars["logsearch_nomorematches"] = true;
}
else if ($dosearch && $numSearchResults > 0)
{
$vars["logsearch_nomorematches"] = true;
}
// Work out the paging options
$vars["pagelinks"] = "";
$vars["showalllink"] = "";
if ($pages > 1)
{
$prev = $page - 1;
$next = $page + 1;
echo "<p><center>";
if ($page > 1) $vars["pagelinks"] .= "<a href=\"${logurl}rev=$rev&sc=$showchanged&page=$prev\">< ${lang["PREV"]}</a> ";
for ($p = 1; $p <= $pages; $p++)
{
if ($p != $page)
$vars["pagelinks"].= "<a href=\"${logurl}rev=$rev&sc=$showchanged&page=$p\">$p</a> ";
else
$vars["pagelinks"] .= "<b>$p </b>";
}
if ($page < $pages) $vars["pagelinks"] .=" <a href=\"${logurl}rev=$rev&sc=$showchanged&page=$next\">${lang["NEXT"]} ></a>";
$vars["showalllink"] = "<a href=\"${logurl}rev=$rev&sc=$showchanged&all=1\">${lang["SHOWALL"]}</a>";
echo "</center>";
}
// Create the project change combo box
$url = $config->getURL($rep, $path, "log");
$vars["logsearch_form"] = "<form action=\"$url\" method=\"post\" name=\"logsearchform\">";
$vars["logsearch_inputbox"] = "<input name=\"search\" value=\"$search\">";
$vars["logsearch_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\">";
$vars["logsearch_endform"] = "<input type=\"hidden\" name=\"logsearch\" value=\"1\">".
"<input type=\"hidden\" name=\"op\" value=\"log\">".
"<input type=\"hidden\" name=\"rev\" value=\"$rev\">".
"<input type=\"hidden\" name=\"sc\" value=\"$showchanged\">".
"<input type=\"hidden\" name=\"isdir\" value=\"$isDir\">".
"</form>";
if ($search != "")
{
$url = $config->getURL($rep, $path, "log");
$vars["logsearch_clearloglink"] = "<a href=\"${url}rev=$rev&sc=$showchanged&isdir=$isDir\">${lang["CLEARLOG"]}</a>";
}
else
$vars["logsearch_clearloglink"] = "";
$url = $config->getURL($rep, "", "comp");
$vars["compare_form"] = "<form action=\"$url\" method=\"post\" name=\"compareform\">";
$vars["compare_submit"] = "<input name=\"comparesubmit\" type=\"submit\" value=\"${lang["COMPAREREVS"]}\">";
$vars["compare_endform"] = "<input type=\"hidden\" name=\"op\" value=\"comp\"><input type=\"hidden\" name=\"sc\" value=\"$showchanged\"></form>";
$vars["version"] = $version;
parseTemplate($config->templatePath."header.tmpl", $vars, $listing);
parseTemplate($config->templatePath."log.tmpl", $vars, $listing);
parseTemplate($config->templatePath."footer.tmpl", $vars, $listing);
?>
|