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';
if ($by == 'name') {
$criteria = 'p.name LIKE \'%' . mysql_real_escape_string($substr) . '%\'';
}
if ($by == 'category') {
$tables .= ', ' . $portsdb_name . '.categories AS c';
$criteria = 'c.portfile = p.name AND c.category = \'' . mysql_real_escape_string($substr) . '\'';
}
if ($by == 'maintainer') {
$tables .= ', ' . $portsdb_name . '.maintainers AS m';
$criteria = 'm.portfile = p.name AND m.maintainer LIKE \'%' . mysql_real_escape_string($substr) . '%\'';
}
if ($by == 'library') {
$criteria = 'p.name = \'' . mysql_real_escape_string($substr) . '\'';
}
if ($by == 'variant') {
$tables .= ', ' . $portsdb_name . '.variants AS v';
$criteria = 'v.portfile = p.name AND v.variant = \'' . mysql_real_escape_string($substr) . '\'';
}
if ($by == 'platform') {
$tables .= ', ' . $portsdb_name . '.platforms AS pl';
$criteria = 'pl.portfile = p.name AND pl.platform = \'' . mysql_real_escape_string($substr) . '\'';
}
if ($criteria == '') {
$where = '';
} else {
$where = 'WHERE ' . $criteria;
}
$query = 'SELECT DISTINCT ' . $fields . ' FROM ' . $tables . ' ' . $where . 'ORDER BY name';
$result = mysql_query($query);
/* Main query sent to the DB */
if ($result) {
print 'Query Results
' . mysql_num_rows($result) . ' ' . (mysql_num_rows($result) == 1 ? 'Portfile' : 'Portfiles')
. ' Selected
';
print '';
/* Iterate over the entire set of returned ports */
while ($row = mysql_fetch_assoc($result)) {
/* 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_array($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_assoc($nresult)) {
if ($primary) { print ' '; }
else { print ' '; }
print ''
. htmlspecialchars($nrow['category']) . '';
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 && mysql_num_rows($nresult) > 0) {
print '
Platforms: ';
while ($nrow = mysql_fetch_array($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_array($nresult)) {
// lib:libpng.3:libpng -> libpng
// might need adapting to the new port: depspec
$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_array($nresult)) {
print ''
. htmlspecialchars($nrow[0]) . ' ';
}
}
print '
';
} /* while (listing of macthing ports) */
print '
';
/* 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) */
?>