function ReplaceWatchListToken($OnWatchList, $HTML, $ElementID) { $Watch_HTML = ''; if ($this->User && $this->User->id && ($this->ShowEverything || $this->ShowWatchListStatus)) { if ($OnWatchList) { $Watch_HTML .= freshports_Watch_Link_Remove($this->User->watch_list_add_remove, $OnWatchList, $ElementID); } else { $Watch_HTML .= freshports_Watch_Link_Add($this->User->watch_list_add_remove, $OnWatchList, $ElementID); } } $Watch_HTML .= ' '; $HTML = str_replace(port_display_WATCH_LIST_ADD_REMOVE, $Watch_HTML, $HTML); return $HTML; }
function freshports_CategoryDisplay($db, $category, $PageNo = 1, $PageSize = DEFAULT_PAGE_SIZE) { global $TableWidth; global $User; header('HTTP/1.1 200 OK'); $Debug = 0; if (isset($_SERVER['REDIRECT_QUERY_STRING'])) { if (isset($_SERVER["REDIRECT_QUERY_STRING"])) { parse_str($_SERVER['REDIRECT_QUERY_STRING'], $query_parts); if (isset($query_parts['page'])) { $PageNo = $query_parts['page']; } if (isset($query_parts['page_size'])) { $PageSize = $query_parts['page_size']; } } } if (!isset($page) || $page == '') { $page = 1; } if (!isset($page_size) || $page_size == '') { $page_size = $User->page_size; } if ($Debug) { echo "\$page = '{$page}'<br>\n"; echo "\$page_size = '{$page_size}'<br>\n"; } SetType($PageNo, "integer"); SetType($PageSize, "integer"); if (!isset($PageNo) || !str_is_int("{$PageNo}") || $PageNo < 1) { $PageNo = 1; } if (!isset($PageSize) || !str_is_int("{$PageSize}") || $PageSize < 1 || $PageSize > MAX_PAGE_SIZE) { $PageSize = DEFAULT_PAGE_SIZE; } if ($Debug) { echo "\$PageNo = '{$PageNo}'<br>\n"; echo "\$PageSize = '{$PageSize}'<br>\n"; } require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/categories.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/watch_lists.php'; if ($category->IsPrimary()) { $WatchLists = new WatchLists($db); $WatchListCount = $WatchLists->IsOnWatchList($User->id, $category->element_id); } $title = $category->{'name'}; # find out how many ports are in this category $PortCount = $category->PortCount($category->name); global $User; if ($Debug) { echo "\$User->id='{$User->id}'"; } freshports_Start($title, 'freshports - new ports, applications', 'FreeBSD, index, applications, ports'); $port = new Port($db); $numrows = $port->FetchByCategoryInitialise($category->name, $User->id, $PageSize, $PageNo); ?> <?php echo freshports_MainTable(); ?> <tr><td valign="top" width="100%"> <?php echo freshports_MainContentTable(); ?> <tr> <?php echo freshports_PageBannerText('Category listing - ' . $category->{'name'}); ?> </tr> <tr><td> <?php if ($category->IsPrimary()) { if ($WatchListCount) { echo freshports_Watch_Link_Remove('', 0, $category->{'element_id'}); } else { echo freshports_Watch_Link_Add('', 0, $category->{'element_id'}); } } ?> <BIG><BIG><B><?php echo $category->{'description'}; ?> </B></BIG></BIG>- Number of ports in this category: <?php echo $PortCount; ?> <p> Ports marked with a <sup>*</sup> actually reside within another category but have <b><?php echo $category->{'name'}; ?> </b> listed as a secondary category. <?php global $ShowAds, $BannerAd; if ($ShowAds && $BannerAd) { echo "<br><center>\n" . Ad_728x90() . "\n</center>\n"; } echo '<div align="center"><br>'; freshports_CategoryNextPreviousPage($category->name, $PortCount, $PageNo, $PageSize); echo '</div>'; ?> </td></tr> <?php if ($Debug) { echo "\$CategoryID = '{$CategoryID}'<BR>\n"; echo "GlobalHideLastChange = {$GlobalHideLastChange}<BR>\n"; echo "\$numrows = {$numrows}<BR>\n"; } $ShowShortDescription = "Y"; $HTML = freshports_echo_HTML("<TR>\n<TD>\n"); require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/port-display.php'; $port_display = new port_display($db, $User); $port_display->SetDetailsCategory(); for ($i = 0; $i < $numrows; $i++) { $port->FetchNth($i); $port_display->port = $port; $Port_HTML = $port_display->Display(); $HTML .= $port_display->ReplaceWatchListToken($port->{'onwatchlist'}, $Port_HTML, $port->{'element_id'}); } // end for echo $HTML; ?> </TD></TR> <TR><TD> <div align="center"><br> <?php freshports_CategoryNextPreviousPage($category->name, $PortCount, $PageNo, $PageSize); ?> </div> </TD></TR> </TABLE> <TD VALIGN="top" WIDTH="*" ALIGN="center"> <?php echo freshports_SideBar(); ?> </td> </TR> </TABLE> <?php echo freshports_ShowFooter(); ?> </body> </html> <?php }
$NumPorts = 0; $CategoryCount = 0; $NumRows = pg_numrows($result); if ($NumRows) { for ($i = 0; $i < $NumRows; $i++) { $myrow = pg_fetch_array($result, $i); $HTML .= freshports_echo_HTML('<tr>'); $HTML .= '<td align="top" nowrap>'; if ($User->id) { if ($Primary[$myrow["is_primary"]]) { $HTML .= freshports_Watch_Icon_Empty(); } else { if (isset($CategoriesWatched[$myrow['category_id']])) { $HTML .= freshports_Watch_Link_Remove('', 0, $myrow['element_id']); } else { $HTML .= freshports_Watch_Link_Add('', 0, $myrow['element_id']); } } } $HTML .= ' '; $HTML .= freshports_echo_HTML('<a href="/' . $myrow["category"] . '/">' . $myrow["category"] . '</a>' . $Primary[$myrow["is_primary"]]); $HTML .= '</td>'; if ($AllowedToEdit) { $HTML .= freshports_echo_HTML('<td valign="top"><a href="/category-maintenance.php?category=' . $myrow["category"] . '">update</a></td>'); } $HTML .= freshports_echo_HTML('<td valign="top" ALIGN="right">' . $myrow["count"] . '</td>'); $HTML .= freshports_echo_HTML('<td valign="top">' . $myrow["description"] . '</td>'); $HTML .= freshports_echo_HTML('<td valign="top" nowrap><font size="-1">' . $myrow["lastupdate"] . '</font></td>'); $HTML .= freshports_echo_HTML("</tr>\n"); # count only the ports in primary categories # as non-primary categories contain only ports which appear in primary categories.
function CreateHTML() { global $freshports_CommitMsgMaxNumOfLinesToShow; $Debug = 0; if (!$this->result) { syslog(LOG_ERR, __FILE__ . '::' . __LINE__ . ': no result set supplied'); die("read from database failed"); exit; } $NumRows = pg_numrows($this->result); if ($this->Debug) { echo __FILE__ . ':' . __LINE__ . " Number of rows = {$NumRows}<br>\n"; } if (!$NumRows) { $this->HTML = "<TR><TD>\n<P>Sorry, nothing found in the database....</P>\n</td></tr>\n"; return $this->HTML; } # if we have a UserID, but no flagged commits, grab them # if ($this->UserID && !isset($this->FlaggedCommits)) { require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/commit_flag.php'; $FlaggedCommits = new CommitFlag($this->dbh); $NumFlaggedCommits = $FlaggedCommits->Fetch($this->UserID); for ($i = 0; $i < $NumFlaggedCommits; $i++) { $FlaggedCommits->FetchNth($i); $this->FlaggedCommits[$FlaggedCommits->commit_log_id] = $FlaggedCommits->commit_log_id; if ($this->Debug) { echo "fetching record # {$i} -> {$FlaggedCommits->commit_log_id}<br>"; } } } $GlobalHideLastChange = "N"; $this->HTML = ""; # leave it all empty as a comparison point $PreviousCommit = new CommitRecord(); $NumberOfPortsInThisCommit = 0; $MaxNumberPortsToShow = 10; $TooManyPorts = false; # we might not show all of a commit, just for the really big ones. for ($i = 0; $i < $NumRows; $i++) { $myrow = pg_fetch_array($this->result, $i); if ($Debug) { echo 'processing row ' . $i . ' ' . $myrow['commit_log_id'] . ' ' . $myrow['message_id'] . "<br>\n"; } unset($mycommit); $mycommit = new CommitRecord(); $mycommit->PopulateValues($myrow); // OK, while we have the log change log, let's put the port details here. if ($mycommit->commit_log_id != $PreviousCommit->commit_log_id) { if ($NumberOfPortsInThisCommit > $MaxNumberPortsToShow && !$this->ShowAllPorts) { $this->HTML .= '<BR>' . freshports_MorePortsToShow($PreviousCommit->message_id, $NumberOfPortsInThisCommit, $MaxNumberPortsToShow); } $TooManyPorts = false; if ($i > 0) { $this->HTML .= "\n<BLOCKQUOTE>"; $this->HTML .= freshports_CommitDescriptionPrint($PreviousCommit->commit_description, $PreviousCommit->encoding_losses, $Lines, freshports_MoreCommitMsgToShow($PreviousCommit->message_id, $Lines)); # close off the previous commit first $this->HTML .= "\n</BLOCKQUOTE>\n</TD></TR>\n\n\n"; } # count the number of ports in this commit. # first time into the loop, this will be executed. $NumberOfPortsInThisCommit = 0; $MaxNumberPortsToShow = 10; if ($mycommit->commit_date != $PreviousCommit->commit_date) { $this->HTML .= '<TR><TD COLSPAN="3" BGCOLOR="' . BACKGROUND_COLOUR . '" HEIGHT="0">' . "\n"; $this->HTML .= ' <FONT COLOR="#FFFFFF"><BIG>' . FormatTime($mycommit->commit_date, 0, "D, j M Y") . '</BIG></FONT>' . "\n"; $this->HTML .= '</TD></TR>' . "\n\n"; } global $freshports_mail_archive; $this->HTML .= "<TR><TD>\n"; $this->HTML .= '<SMALL>'; $this->HTML .= '[ ' . $mycommit->commit_time . ' ' . freshports_CommitterEmailLink($mycommit->committer) . ' ]'; $this->HTML .= '</SMALL>'; $this->HTML .= ' '; $this->HTML .= freshports_Email_Link($mycommit->message_id); $this->HTML .= ' '; if ($this->UserID) { if (isset($this->FlaggedCommits[$mycommit->commit_log_id])) { $this->HTML .= freshports_Commit_Flagged_Link($mycommit->message_id); } else { $this->HTML .= freshports_Commit_Flagged_Not_Link($mycommit->message_id); } } if ($mycommit->EncodingLosses()) { $this->HTML .= ' ' . freshports_Encoding_Errors(); } if ($mycommit->stf_message != '') { $this->HTML .= ' ' . freshports_SanityTestFailure_Link($mycommit->message_id); } # echo '<pre>' . print_r($mycommit, true) . '</pre>'; if ($mycommit->svn_revision != '') { $this->HTML .= ' ' . freshports_svnweb_ChangeSet_Link($mycommit->svn_revision, $mycommit->svn_hostname, $mycommit->path_to_repo); } $this->HTML .= "<br>\n"; } $NumberOfPortsInThisCommit++; if ($NumberOfPortsInThisCommit > $MaxNumberPortsToShow && !$this->ShowAllPorts) { $TooManyPorts = true; } if (!$TooManyPorts) { if (isset($mycommit->category) && $mycommit->category != '') { if ($this->UserID) { if ($mycommit->watch) { $this->HTML .= ' ' . freshports_Watch_Link_Remove($this->WatchListAsk, $mycommit->watch, $mycommit->element_id) . ' '; } else { $this->HTML .= ' ' . freshports_Watch_Link_Add($this->WatchListAsk, $mycommit->watch, $mycommit->element_id) . ' '; } } $this->HTML .= '<BIG><B>'; $this->HTML .= '<A HREF="/' . $mycommit->category . '/' . $mycommit->port . '/">'; $this->HTML .= $mycommit->port; $this->HTML .= '</A>'; $PackageVersion = freshports_PackageVersion($mycommit->version, $mycommit->revision, $mycommit->epoch); if (strlen($PackageVersion) > 0) { $this->HTML .= ' ' . $PackageVersion; } $this->HTML .= "</B></BIG>\n"; $this->HTML .= '<A HREF="/' . $mycommit->category . '/">'; $this->HTML .= $mycommit->category . "</A>"; $this->HTML .= ' '; // indicate if this port has been removed from cvs if ($mycommit->status == "D") { $this->HTML .= " " . freshports_Deleted_Icon_Link() . "\n"; } // indicate if this port needs refreshing from CVS if ($mycommit->needs_refresh) { $this->HTML .= " " . freshports_Refresh_Icon_Link() . "\n"; } if ($mycommit->date_added > Time() - 3600 * 24 * $this->DaysMarkedAsNew) { $MarkedAsNew = "Y"; $this->HTML .= freshports_New_Icon() . "\n"; } if ($mycommit->forbidden) { $this->HTML .= ' ' . freshports_Forbidden_Icon_Link() . "\n"; } if ($mycommit->broken) { $this->HTML .= ' ' . freshports_Broken_Icon_Link() . "\n"; } if ($mycommit->deprecated) { $this->HTML .= ' ' . freshports_Deprecated_Icon_Link() . "\n"; } if ($mycommit->expiration_date) { if (date('Y-m-d') >= $mycommit->expiration_date) { $this->HTML .= freshports_Expired_Icon_Link($mycommit->expiration_date) . "\n"; } else { $this->HTML .= freshports_Expiration_Icon_Link($mycommit->expiration_date) . "\n"; } } if ($mycommit->ignore) { $this->HTML .= ' ' . freshports_Ignore_Icon_Link() . "\n"; } $this->HTML .= freshports_Commit_Link_Port($mycommit->message_id, $mycommit->category, $mycommit->port); $this->HTML .= " "; if ($mycommit->vulnerable_current) { $this->HTML .= ' ' . freshports_VuXML_Icon() . ' '; } else { if ($mycommit->vulnerable_past) { $this->HTML .= ' ' . freshports_VuXML_Icon_Faded() . ' '; } } if ($mycommit->restricted) { $this->HTML .= freshports_Restricted_Icon_Link($mycommit->restricted) . ' '; } if ($mycommit->no_cdrom) { $this->HTML .= freshports_No_CDROM_Icon_Link($mycommit->no_cdrom) . ' '; } if ($mycommit->is_interactive) { $this->HTML .= freshports_Is_Interactive_Icon_Link($mycommit->is_interactive) . ' '; } } else { # This is a non-port element... $this->HTML .= $mycommit->revision . ' '; $this->HTML .= '<big><B>'; $PathName = preg_replace('|^/?ports/|', '', $mycommit->element_pathname); # echo "'$PathName' " . "'" . $mycommit->repo_name . "'"; switch ($mycommit->repo_name) { case 'ports': $PathName = preg_replace('|^head/|', '', $PathName); break; } if ($PathName != $mycommit->element_pathname) { $this->HTML .= '<a href="/' . str_replace('%2F', '/', urlencode($PathName)) . '">' . $PathName . '</a>'; $this->HTML .= "</B></BIG>\n"; } else { $this->HTML .= '<a href="' . FRESHPORTS_FREEBSD_CVS_URL . $PathName . '#rev' . $mycommit->revision . '">' . $PathName . '</a>'; $this->HTML .= "</B></BIG>\n"; } } $this->HTML .= htmlify(_forDisplay($mycommit->short_description)) . "\n"; $this->HTML .= "<BR>\n"; global $freshports_CommitMsgMaxNumOfLinesToShow; if ($this->ShowEntireCommit) { $Lines = 0; } else { $Lines = $freshports_CommitMsgMaxNumOfLinesToShow; } } # !$TooManyPorts $PreviousCommit = $mycommit; } if ($NumberOfPortsInThisCommit > $MaxNumberPortsToShow && !$this->ShowAllPorts) { $this->HTML .= '<BR>' . freshports_MorePortsToShow($PreviousCommit->message_id, $NumberOfPortsInThisCommit, $MaxNumberPortsToShow); } $this->HTML .= "\n<BLOCKQUOTE>"; $this->HTML .= freshports_CommitDescriptionPrint($PreviousCommit->commit_description, $PreviousCommit->encoding_losses, $Lines, freshports_MoreCommitMsgToShow($PreviousCommit->message_id, $Lines)); # close off the last commit $this->HTML .= "\n</BLOCKQUOTE>\n</TD></TR>\n\n\n"; unset($mycommit); return $this->HTML; }