function CreateHTML() { global $freshports_CommitMsgMaxNumOfLinesToShow; if (isset($this->Filter)) { $sql = "select * from LatestCommitsFiltered({$this->MaxNumberOfPorts}, {$this->UserID}, '" . pg_escape_string($this->Filter) . "')"; } else { # $sql = "select * from LatestCommits($this->MaxNumberOfPorts, $this->UserID)"; $sql = "\n SELECT LC.*, STF.message AS stf_message\n FROM LatestCommits({$this->MaxNumberOfPorts}, 0, '" . pg_escape_string($this->BranchName) . "') LC LEFT OUTER JOIN sanity_test_failures STF\n ON LC.commit_log_id = STF.commit_log_id\nORDER BY LC.commit_date_raw DESC, LC.category, LC.port, element_pathname"; } if ($this->Debug) { echo "\n<p>sql={$sql}</p>\n"; } $result = pg_exec($this->dbh, $sql); if (!$result) { die("read from database failed"); exit; } $DisplayCommit = new DisplayCommit($this->dbh, $result); $DisplayCommit->Debug = $this->Debug; $DisplayCommit->SetDaysMarkedAsNew($this->DaysMarkedAsNew); $DisplayCommit->SetUserID($this->UserID); $DisplayCommit->SetWatchListAsk($this->WatchListAsk); $RetVal = $DisplayCommit->CreateHTML(); $this->HTML = $DisplayCommit->HTML; return $RetVal; }
function CreateHTML() { global $freshports_CommitMsgMaxNumOfLinesToShow; if (isset($this->Filter)) { $sql = "select * from SanityTestFailures({$this->UserID}, '" . pg_escape_string($this->Filter) . "')"; } else { $sql = "set client_encoding = 'ISO-8859-15';\nSELECT S.*, STF.message as stf_message\n FROM SanityTestFailures({$this->UserID}) S LEFT OUTER JOIN sanity_test_failures STF\n ON S.commit_log_id = STF.commit_log_id"; } if ($this->MessageID != '') { $sql .= " WHERE message_id = '" . pg_escape_string($this->MessageID) . "'"; } $sql .= " ORDER BY S.commit_date_raw DESC, S.category, S.port"; if ($this->Debug) { echo "\n<p>sql={$sql}</p>\n"; } $result = pg_exec($this->dbh, $sql); if (!$result) { die("read from database failed"); exit; } $DisplayCommit = new DisplayCommit($this->dbh, $result); $DisplayCommit->Debug = $this->Debug; $DisplayCommit->SetDaysMarkedAsNew($this->DaysMarkedAsNew); $DisplayCommit->SetUserID($this->UserID); $DisplayCommit->SetWatchListAsk($this->WatchListAsk); $DisplayCommit->SanityTestFailure = true; $RetVal = $DisplayCommit->CreateHTML(); $this->HTML = $DisplayCommit->HTML; return $RetVal; }
} else { if ($NumFetches != $NumRows) { $MoreToShow = 1; } else { $MoreToShow = 0; } $NumPortsFound = 'Number of ports: ' . $NumFound; if ($NumFound > $PageSize) { $NumPortsFound .= " (showing only {$NumOnThisPage} on this page)"; } } switch ($stype) { case SEARCH_FIELD_COMMITTER: case SEARCH_FIELD_COMMITMESSAGE: case SEARCH_FIELD_PATHNAME: $DisplayCommit = new DisplayCommit($db, $Commits->LocalResult); $links = $Pager->GetLinks(); $HTML .= $NumPortsFound . ' ' . $links['all']; $HTML .= $DisplayCommit->CreateHTML(); $HTML .= '<tr><td>' . $NumPortsFound . ' ' . $links['all'] . '</td></tr>'; break; default: require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/port-display.php'; $links = $Pager->GetLinks(); $HTML .= $NumPortsFound . ' ' . $links['all']; global $User; $port_display = new port_display($db, $User); $port_display->SetDetailsSearch(); for ($i = 0; $i < $NumFetches; $i++) { $Port->FetchNth($i); $port_display->port = $Port;
$CommitsMyFlagged->UserIDSet($User->id); $NumberCommits = $CommitsMyFlagged->Fetch(); $NumberCommits = $CommitsMyFlagged->GetCountPortCommits(); if ($Debug) { echo 'number of commits = ' . $NumberCommits . "<br>\n"; } $NumFound = $NumberCommits; $params = array('mode' => 'Sliding', 'perPage' => $PageSize, 'delta' => 5, 'totalItems' => $NumFound, 'urlVar' => 'page', 'currentPage' => $PageNumber, 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1); $Pager =& Pager::factory($params); $offset = $Pager->getOffsetByPageId(); $NumOnThisPage = $offset[1] - $offset[0] + 1; if ($PageNumber > 1) { $Commits->SetOffset($offset[0] - 1); } $CommitsMyFlagged->SetLimit($PageSize); $DisplayCommit = new DisplayCommit($db, $CommitsMyFlagged->LocalResult); $DisplayCommit->Debug = $Debug; $DisplayCommit->SetUserID($User->id); $links = $Pager->GetLinks(); $HTML .= $NumPortsFound . ' ' . $links['all']; $HTML .= $DisplayCommit->CreateHTML(); if ($db) { ?> <TR><TD VALIGN="top" WIDTH="100%"> <?php echo freshports_MainContentTable(); ?> <TR> <?php
function freshports_NonPortDescription($db, $element_record) { global $TableWidth; global $FreshPortsTitle; $Debug = 1; freshports_ConditionalGet(freshports_LastModified()); header("HTTP/1.1 200 OK"); $Title = preg_replace('|^/?ports/|', '', $element_record->element_pathname); $FileName = preg_replace('|^/?ports/|', '', $element_record->element_pathname); require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php'; freshports_Start($Title, "{$FreshPortsTitle} - new ports, applications", "FreeBSD, index, applications, ports"); ?> <?php echo freshports_MainTable(); ?> <tr><td valign="top" width="100%"> <?php echo freshports_MainContentTable(); ?> <TR> <?php echo freshports_PageBannerText('non port: ' . $Title); ?> </TR> <tr><td> <a HREF="<?php echo FRESHPORTS_FREEBSD_SVN_URL . $element_record->element_pathname; ?> ?view=log">SVNWeb</a> </td></tr> <?php global $User; # these two options must be the last on the line. And as such are mutually exclusive define('BYPASSCACHE', 'bypasscache=1'); # do not read the cache for display define('REFRESHCACHE', 'refreshcache=1'); # refresh the cache $BypassCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(BYPASSCACHE)) == BYPASSCACHE; $RefreshCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(REFRESHCACHE)) == REFRESHCACHE; $PageNumber = 1; if (isset($_SERVER['REDIRECT_QUERY_STRING'])) { parse_str($_SERVER['REDIRECT_QUERY_STRING'], $query_parts); if (isset($query_parts['page']) && Is_Numeric($query_parts['page'])) { $PageNumber = intval($query_parts['page']); if ($PageNumber != $query_parts['page'] || $PageNumber < 1) { $PageNumber = 1; } } } $NumCommitsPerPage = $User->page_size; $Cache = new CacheFile(); $Cache->PageSize = $User->page_size; $result = $Cache->Retrieve($FileName, $PageNumber); if (!$result && !$BypassCache && !$RefreshCache) { if ($Debug) { echo "found something from the cache<br>\n"; } $HTML = $Cache->CacheDataGet(); # # we need to know the element_id of this port # and the whether or not it is on the person's watch list # let's create a special function for that! # $EndOfFirstLine = strpos($HTML, "\n"); if ($EndOfFirstLine == false) { die('Internal error: I was expecting an ElementID and found nothing'); } # extract the ElementID from the cache $ElementID = intval(substr($HTML, 0, $EndOfFirstLine)); if ($ElementID == 0) { syslog(LOG_ERR, "Extract of ElementID from cache failed. Is cache corrupt/deprecated? port was {$category}/{$port}"); die('sorry, I encountered a problem with the cache. Please send the URL and this message to the webmaster.'); } if ($User->id) { $OnWatchList = freshports_OnWatchList($db, $User->id, $ElementID); } else { $OnWatchList = 0; } $HTML = substr($HTML, $EndOfFirstLine + 1); } else { if ($Debug) { echo "found NOTHING in cache<br>\n"; } $HTML = ''; $Commits = new CommitsByTreeLocation($db); $Commits->SetLimit($Cache->PageSize); $Commits->Debug = $Debug; $Commits->UserIDSet($User->id); $Commits->TreePathConditionSet("= '" . $element_record->element_pathname . "'"); # # get the count without excuting the whole query # we don't want to pull back all the data. # $NumCommits = $Commits->GetCountCommits(); $params = array('mode' => 'Sliding', 'perPage' => $NumCommitsPerPage, 'delta' => 5, 'totalItems' => $NumCommits, 'urlVar' => 'page', 'currentPage' => $PageNumber, 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, 'append' => false, 'path' => '/' . preg_replace('|^/?ports/|', '', $element_record->element_pathname), 'fileName' => '?page=%d', 'altFirst' => 'First Page', 'firstPageText' => 'First Page', 'altLast' => 'Last Page', 'lastPageText' => 'Last Page'); $Pager =& Pager::factory($params); $links = $Pager->GetLinks(); $NumCommitsHTML = '<tr><td><p align="left">Number of commits found: ' . $NumCommits; $Offset = 0; $PageLinks = $links['all']; $PageLinksHTML = str_replace('/?page=1"', '"', $PageLinks); $PageLinksHTML = str_replace('/?page=', '?page=', $PageLinksHTML); if ($PageLinksHTML != '') { $offset = $Pager->getOffsetByPageId(); $NumOnThisPage = $offset[1] - $offset[0] + 1; $Offset = $offset[0] - 1; $NumCommitsHTML .= " (showing only {$NumOnThisPage} on this page)"; unset($offset); } if ($PageNumber > 1) { $Commits->SetOffset($Offset); } $NumCommitsHTML .= '</p>'; if ($PageLinksHTML != '') { $PageLinksHTML = '<p align="center">' . $PageLinksHTML . '</p>'; } $NumCommitsHTML .= $PageLinksHTML . '</td></tr>'; $HTML = $NumCommitsHTML; if ($Commits->Debug) { echo "PageNumber='{$PageNumber}'<br>Offset='{$Offset}'<br>"; } $NumFetches = $Commits->Fetch(); $DisplayCommit = new DisplayCommit($db, $Commits->LocalResult); $HTML .= $DisplayCommit->CreateHTML(); $HTML .= $NumCommitsHTML; # If we are not reading if (!$BypassCache || $RefreshCache) { $Cache->CacheDataSet($element_record->{'id'} . "\n" . $HTML); $Cache->Add($FileName, $PageNumber); } } echo $HTML; echo "</table>\n"; ?> </TD> <TD VALIGN="top" WIDTH="*" ALIGN="center"> <?php echo freshports_SideBar(); ?> </td> </TR> </TABLE> <?php echo freshports_ShowFooter(); ?> </body> </html> <?php }
$myrow = pg_fetch_array($result, 0); } else { die('could not determine the number of commit elements'); } $NumFilesTouched = $myrow['count']; } $sql = "\nSELECT FPC.*, STF.message as stf_message\n FROM freshports_commit('" . pg_escape_string($message_id) . "', {$PageSize}, ({$PageNo} - 1 ) * {$PageSize}, {$User->id}) FPC\n LEFT OUTER JOIN sanity_test_failures STF\n ON FPC.commit_log_id = STF.commit_log_id\nORDER BY port, element_pathname"; if ($Debug) { echo "\n<pre>sql={$sql}</pre>\n"; } $result = pg_exec($database, $sql); if ($result) { $numrows = pg_numrows($result); if ($numrows) { require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/display_commit.php'; $DisplayCommit = new DisplayCommit($database, $result); $DisplayCommit->Debug = $Debug; $DisplayCommit->SetShowAllPorts(true); $DisplayCommit->SetShowEntireCommit(true); $DisplayCommit->SanityTestFailure = true; $RetVal = $DisplayCommit->CreateHTML(); echo $DisplayCommit->HTML; echo '<tr><TD VALIGN="top"><p>Number of ports [& non-ports] in this commit: ' . $NumFilesTouched . '</p></td></tr>'; } else { echo '<tr><TD VALIGN="top"><P>Sorry, nothing found in the database....</P>' . "\n"; echo "</TD></tr>"; } } else { syslog(LOG_NOTICE, __FILE__ . '::' . __LINE__ . ': ' . pg_last_error()); exit; }
function ArchiveCreate($Date, $DateMessage, $db, $Use, $BranchName) { global $freshports_CommitMsgMaxNumOfLinesToShow; $commits = new Commits($db); $commits->SetBranch($BranchName); $NumRows = $commits->Fetch($Date, $User->id); #echo '<br>NumRows = ' . $NumRows; $HTML = ''; if ($NumRows == 0) { $HTML .= '<TR><TD COLSPAN="3" BGCOLOR="' . BACKGROUND_COLOUR . '" HEIGHT="0">' . "\n"; $HTML .= ' <FONT COLOR="#FFFFFF"><BIG>' . FormatTime($Date, 0, "D, j M Y") . '</BIG></FONT>' . "\n"; $HTML .= '</TD></TR>' . "\n\n"; $HTML .= '<TR><TD>No commits found for that date</TD></TR>'; } unset($ThisCommitLogID); require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/display_commit.php'; $DisplayCommit = new DisplayCommit($db, $commits->LocalResult); $DisplayCommit->SanityTestFailure = true; $RetVal = $DisplayCommit->CreateHTML(); $HTML = $DisplayCommit->HTML; return $HTML; }