MacPorts Portfiles
The MacPorts Project currently distributes ports, organized across
different categories and available below for viewing. This form allows
you to search the MacPorts software index, last updated on ' . $date . ' at ' . $time . ''; ?>.
Or view the complete ports list (
ports).
Port Categories';
while ($columns < 4) {
$entries_per_colum = 0;
print '';
$columns++;
}
print '
';
}
}
/* If valid criteria is specified (by set and a valid substring, or by set to all) we poll the db and display the results */
if ($by && ($substr || $by == 'all')) {
$fields = 'name, path, version, description';
$tables = "$portsdb_name.portfiles AS p";
switch ($by) {
case 'name':
$criteria = "p.name LIKE '%" . mysql_real_escape_string($substr) . "%'";
break;
case 'category':
$tables .= ", $portsdb_name.categories AS c";
$criteria = "c.portfile = p.name AND c.category = '" . mysql_real_escape_string($substr) . "'";
break;
case 'maintainer':
$tables .= ", $portsdb_name.maintainers AS m";
$criteria = "m.portfile = p.name AND m.maintainer LIKE '%" . mysql_real_escape_string($substr) . "%'";
break;
case 'library':
$criteria = "p.name = '" . mysql_real_escape_string($substr) . "'";
break;
case 'variant':
$tables .= ", $portsdb_name.variants AS v";
$criteria = "v.portfile = p.name AND v.variant = '" . mysql_real_escape_string($substr) . "'";
break;
case 'platform':
$tables .= ", $portsdb_name.platforms AS pl";
$criteria = "pl.portfile = p.name AND pl.platform = '" . mysql_real_escape_string($substr) . "'";
break;
case 'all':
$criteria = '';
break;
default:
$criteria = '0';
break;
}
$where = ($criteria == '' ? '' : "WHERE $criteria");
$query = "SELECT DISTINCT $fields FROM $tables $where ORDER BY name";
$result = mysql_query($query);
/* Main query sent to the DB */
if ($result) {
$numrows = mysql_num_rows($result);
if ($numrows > $pagesize) {
$paging = true;
$pagecount = ceil($numrows / $pagesize);
$page = min($page, $pagecount);
$offset = $pagesize * ($page-1);
$curpagesize = min($pagesize, $numrows - $offset);
# generate a paging control and cache it so we can show it twice
$pagecontrol = "Page ";
for ($i = 1; $i <= $pagecount; $i++) {
if ($i != 1) {
$pagecontrol .= " | ";
}
if ($i == $page) {
$pagecontrol .= "$i";
} else {
$pagecontrol .= "$i";
}
}
$pagecontrol .= "
";
# seek the data pointer
mysql_data_seek($result, $offset);
}
print 'Query Results
';
if ($paging) {
print $pagecontrol;
$numrowtext = ($offset+1) . "-" . ($offset + $curpagesize) . " of $numrows Portfile" . ($curpagesize == 1 ? '' : 's');
} else {
$numrowtext = "$numrows Portfile" . ($numrows == 1 ? '' : 's');
}
print "$numrowtext Selected
";
print '';
/* Iterate over the entire set of returned ports */
for ($row = mysql_fetch_assoc($result), $i = 0;
$row && (!$paging || $i < $curpagesize);
$row = mysql_fetch_assoc($result), $i++) {
/* Port name and Portfile URL */
print "- " . htmlspecialchars($row['name'])
. ' ' . htmlspecialchars($row['version']) . '
';
print '- ';
/* Port short description */
print htmlspecialchars($row['description']) . '
';
/* Maintainers */
$nquery = "SELECT maintainer FROM $portsdb_name.maintainers WHERE portfile='" . mysql_real_escape_string($row['name']) .
"' ORDER BY is_primary DESC, maintainer";
$nresult = mysql_query($nquery);
if ($nresult) {
$primary = 1;
print 'Maintained by:';
while ($nrow = mysql_fetch_row($nresult)) {
if ($primary) { print ' '; }
else { print ' '; }
print obfuscate_email($nrow[0]);
if ($primary) { print ''; }
$primary = 0;
}
}
/* Categories */
$nquery = "SELECT category FROM $portsdb_name.categories WHERE portfile='" . mysql_real_escape_string($row['name']) .
"' ORDER BY is_primary DESC, category";
$nresult = mysql_query($nquery);
if ($nresult) {
$primary = 1;
print '
Categories:';
while ($nrow = mysql_fetch_row($nresult)) {
if ($primary) { print ' '; }
else { print ' '; }
print "'
. htmlspecialchars($nrow[0]) . '';
if ($primary) { print ''; }
$primary = 0;
}
}
/* Platforms */
$nquery = "SELECT platform FROM $portsdb_name.platforms WHERE portfile='" . mysql_real_escape_string($row['name']) .
"' ORDER BY platform";
$nresult = mysql_query($nquery);
if ($nresult) {
print '
Platforms: ';
while ($nrow = mysql_fetch_row($nresult)) {
print "'
. htmlspecialchars($nrow[0]) . ' ';
}
}
/* Dependencies */
$nquery = "SELECT library FROM $portsdb_name.dependencies WHERE portfile='" . mysql_real_escape_string($row['name']) .
"' ORDER BY library";
$nresult = mysql_query($nquery);
if ($nresult && mysql_num_rows($nresult) > 0) {
print '
Dependencies: ';
while ($nrow = mysql_fetch_row($nresult)) {
$library = eregi_replace('^([^:]*:[^:]*:|[^:]*:)', '', $nrow[0]);
print "'
. htmlspecialchars($library) . ' ';
}
}
/* Variants */
$nquery = "SELECT variant FROM $portsdb_name.variants WHERE portfile='" . mysql_real_escape_string($row['name']) .
"' ORDER BY variant";
$nresult = mysql_query($nquery);
if ($nresult && mysql_num_rows($nresult) > 0) {
print '
Variants: ';
while ($nrow = mysql_fetch_row($nresult)) {
print "'
. htmlspecialchars($nrow[0]) . ' ';
}
}
print '
';
} /* while (listing of macthing ports) */
print '
';
if ($paging) {
print $pagecontrol;
}
/* When we hit this else, the query failed for some reason */
} else {
print 'An Error Occurred: '. mysql_error($portsdb_info['connection_handler']) . '
';
}
} /* if (main query sent to the DB) */
?>