<h3>Search</h3> <div id="searchdiv"> <form action="" method="get"> <input type="text" size="60" id="q" name="q"<?php print ($_GET["q"] ? " value=\"" . sanitize($_GET["q"], "text") . "\"" : ""); ?>/> <input type="submit" value="Go!"/> </form> </div> </div> <?php /* 1.1.2.x <- 1.1.0.2 = branch tag, likewise, 1.1.4.x <- 1.1.0.4 = branch tag, so dynamically rewrite a.b.c.d to a.b.0.c to find the branch tag */ $branch = "IF(`revision` LIKE '%.%.%.%', (SELECT `tagname` FROM `tags` NATURAL JOIN `filetags` WHERE `fid` = `ofid` AND `revision` = CONCAT(SUBSTRING_INDEX(`orev`, '.', 2), '.0.', SUBSTRING_INDEX(SUBSTRING_INDEX(`orev`, '.', -2), '.', 1))), 'HEAD')"; $sql = "SELECT SQL_CALC_FOUND_ROWS `cvsname`, `revision`, `date`, `author`, `message`, `keyword_subs`, `bugid`, `revision` AS `orev`, `fid` AS `ofid`, $branch AS `branch`$ec FROM `cvsfiles` NATURAL JOIN `commits` NATURAL LEFT JOIN `bugs` $where GROUP BY `fid`, `revision`, `bugid` $having $order LIMIT $offset, $pagesize"; $result = wmysql_query($sql); $count = wmysql_query("SELECT FOUND_ROWS()"); //mysql_num_rows() doesn't do what we want here $row = mysql_fetch_row($count); $rows = $row[0]; $title = "<span>$rows results total</span>Showing results " . ($offset + 1) . "-" . ($offset + $pagesize > $rows ? $rows : $offset + $pagesize) . " for " . ($_GET["q"] == "" ? "last $days days of commits" : "$et" . sanitize($_GET["q"], "text")); $title = ($rows == 0 ? "No results found for " . sanitize($_GET["q"], "text") . "" : $title); print "<div class=\"homeitem3col\">\n"; print "<h3>$title</h3>\n"; dopager($rows, $page, $pagesize); print "<ul>\n"; while ($row = mysql_fetch_assoc($result)) {
$bugs = preg_replace("/^(.+)\$/", "('{$row['0']}', '{$revs['1']}', '\$1')", $bugs); wmysql_query("INSERT INTO `bugs` (`fid`, `revision`, `bugid`) VALUES " . join($bugs, ",") . " ON DUPLICATE KEY UPDATE `bugid` = `bugid`"); } } } } wmysql_query("DROP TEMPORARY TABLE `tmptags`"); $tables = array(); mysql_select_db("INFORMATION_SCHEMA") or die(mysql_error()); $result = wmysql_query("SELECT TABLE_NAME FROM TABLES WHERE `TABLE_SCHEMA` = '{$db}' AND `TABLE_TYPE` = 'BASE TABLE'"); while ($row = mysql_fetch_row($result)) { array_push($tables, $row[0]); } mysql_select_db($db) or die(mysql_error()); wmysql_query("OPTIMIZE TABLE " . join($tables, ",")); wmysql_query("ANALYZE TABLE " . join($tables, ",")); mysql_close($connect); function fixup($str) { return "('{$str}', " . (preg_match("/^build_(\\d{12})\$/", $str, $regs) ? "STR_TO_DATE('{$regs['1']}', '%Y%m%d%k%i')" : "NULL") . ")"; } function wmysql_query($sql) { $res = mysql_query($sql) or die("{$sql}\n" . mysql_error() . "\n"); return $res; } function extract_bugs($regs) { foreach ($regs as $z) { foreach ($z as $y) { if (preg_match("/^\\d+\$/", $y)) {