function freshports_WatchListDDLB($dbh, $UserID, $selected = '', $size = 0, $multiple = 0, $show_active = 1, $element_id = 0) { # return the HTML which forms a dropdown list box. # optionally, select the item identified by $selected. $Debug = 0; $HTML = '<select name="wlid'; if ($multiple) { $HTML .= '[]'; } $HTML .= '" title="Select a watch list"'; if ($size) { $HTML .= ' size="' . $size . '"'; } if ($multiple) { $HTML .= ' multiple'; } $HTML .= ">\n"; $WatchLists = new WatchLists($dbh); $NumRows = $WatchLists->Fetch($UserID, $element_id); if ($Debug) { echo "{$NumRows} rows found!<br>"; echo "selected = '{$selected}'<br>"; } if ($NumRows) { for ($i = 0; $i < $NumRows; $i++) { $WatchList = $WatchLists->FetchNth($i); $HTML .= '<option value="' . htmlspecialchars(pg_escape_string($WatchList->id)) . '"'; if ($selected == '') { if ($element_id && $WatchList->watch_list_count > 0) { $HTML .= ' selected'; } } else { if ($WatchList->id == $selected) { $HTML .= ' selected'; } } $HTML .= '>' . htmlspecialchars(pg_escape_string($WatchList->name)); if ($show_active && $WatchList->in_service == 't') { $HTML .= '*'; } if ($element_id && $WatchList->watch_list_count) { $HTML .= " +"; } $HTML .= "</option>\n"; } } $HTML .= '</select>'; return $HTML; }
$WatchList = new WatchList($db); $NumRows = $WatchList->EmptyAllLists($User->id, pg_escape_string($WatchListIDToEmpty)); if (!isset($NumRows)) { die("Failed to Empty '{$WatchListIDToEmpty}' (return value '{$EmptydWatchListID}')" . pg_last_error()); } if ($Debug) { echo 'I have emptied all the watch lists.<br>'; } pg_query($db, 'COMMIT'); break; case 'set_default': if ($Debug) { echo 'I have set your default lists.<br>'; } pg_query($db, 'BEGIN'); $WatchLists = new WatchLists($db); $numrows = $WatchLists->In_Service_Set($User->id, $_POST['wlid']); if ($Debug) { echo "{$numrows} watchlists were affected by that action"; } if ($numrows >= 0) { pg_query($db, 'COMMIT'); } else { pg_query($db, 'ROLLBACK'); } break; case 'set_options': if ($Debug) { echo 'I have set options to: ' . pg_escape_string($_POST['addremove']); } $User->SetWatchListAddRemove(pg_escape_string($_POST['addremove']));
function DisplayWatchListNewsFeeds($db, $UserID) { $Debug = 0; echo '<h1>These are your newsfeeds</h1>'; $WatchLists = new WatchLists($db); $NumRows = $WatchLists->Fetch($UserID); if ($Debug) { echo "{$NumRows} rows found!<br>"; echo "selected = '{$selected}'<br>"; } $HTML = ''; if ($NumRows) { for ($i = 0; $i < $NumRows; $i++) { $WatchList = $WatchLists->FetchNth($i); $URL = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?id=' . $WatchList->token; $HTML .= '<a href="' . $URL . '">' . $WatchList->name . '</a><br>'; } } $HTML .= '</select>'; echo $HTML; }
# watch staging area against the watch list. $wlid = pg_escape_string($_REQUEST["wlid"]); if ($Debug) { echo "setting SetLastWatchListChosen => \$wlid='{$wlid}'"; } $User->SetLastWatchListChosen($wlid); if ($Debug) { echo "\$wlid='{$wlid}'"; } } else { $wlid = $User->last_watch_list_chosen; if ($Debug) { echo "\$wlid='{$wlid}'"; } if ($wlid == '') { $WatchLists = new WatchLists($db); $wlid = $WatchLists->GetDefaultWatchListID($User->id); if ($Debug) { echo "GetDefaultWatchListID => \$wlid='{$wlid}'"; } } } ?> <?php echo freshports_MainTable(); ?> <tr><td valign="top" width="100%"> <?php echo freshports_MainContentTable(NOBORDER);
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 }