Update of /cvsroot/fink/pdb/site
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2412/site

Modified Files:
        header.inc help.php memcache.inc package.php 
Added Files:
        .cvsignore functions.inc 
Log Message:
package is able to query stuff now

--- NEW FILE: .cvsignore ---
.*.swp

--- NEW FILE: functions.inc ---
<?php

$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect to the 
memcache daemon");
$debug = true;

function parse_version($version) {
        $epoch = null;
        $revision = null;

        if (strrpos($version, ':')) {
                list($epoch, $version) = split(":", $version);
        }
        if (strrpos($version, "-")) {
                list($version, $revision) = split("-", $version, 2);
        }

        return array($epoch, $version, $revision);
}

function fetch_package($name, $version = null, $distribution = null, $release = 
null, $architecture = null, $showall = false) {
        $query = new SolrQuery();

        $query->addQuery("name_e:\"$name\"", true);
        if ($version != null)
                $query->addQuery("version_e:\"$version\"", true);
        if ($distribution != null)
                $query->addQuery("dist_name:\"$distribution\"", true);
        if ($release != null)
                $query->addQuery("rel_type:\"$release\"", true);
        if ($architecture != null)
                $query->addQuery("dist_architecture:\"$architecture\"", true);
        if (!$showall)
                $query->addQuery("dist_visible:true", true);

        $response = $query->fetch();
        if ($response == null || $response == false) {
                return null;
        } elseif ($response->response->numFound == 0) {
                return null;
        } elseif ($response->response->numFound == 1) {
                return $response->response->docs[0];
        } else {
                return $response->response->docs;
        }
}

class SolrQuery {
        protected $action;
        protected $url;
        protected $type;
        protected $timeout = 3600; // 1 hour

        protected $fields = array();
        protected $sort   = array();
        protected $query  = array();

        public function __construct($action = 'select', $url = 
'http://localhost:8983/solr', $type = 'json') {
                $this->setAction($action);
                $this->setUrl($url);
                $this->setType($type);
        }

        public function getAction()          { return $this->action; }
        public function setAction($action)   { $this->action = $action; }
        public function getUrl()             { return $this->url; }
        public function setUrl($url)         { $this->url = $url; }
        public function getType()            { return $this->type; }
        public function setType($type)       { $this->type = $type; }

        public function getTimeout()         { return $this->timeout; }
        public function setTimeout($seconds) { $this->timeout = $timeout; }
        public function getFields()          { return $this->fields; }
        public function setFields($fields)   { $this->fields = $fields; }
        public function addField($field)     { array_push($this->fields, 
$field); }

        public function getSort()            { return $this->sort; }
        public function setSort($sort)       { $this->sort = $sort; }
        public function addSort($sort)       { array_push($this->sort, $sort); }

        public function getQuery()           { return $this->query; }
        public function setQuery($query)     { $this->query = $query; }

        public function addQuery($query, $required = false, $exclude = false) {
                if ($required) {
                        array_push($this->query, '+' . $query);
                } elseif ($exclude) {
                        array_push($this->query, '-' . $query);
                } else {
                        array_push($this->query, $query);
                }
        }

        public function fetch() {
                $key = "solr-query-" . $this->getAction() . "-" . md5("" . 
$this);
                global $memcache;
                global $debug;

                $result = null;

                if ($memcache && !$debug) {
                        $result = $memcache->get($key);
                }

                if ($result == null || $result == false) {
                        $result = $this->fetch_uncached();
                        if ($memcache) {
                                $memcache->set($key, $result, false, 
$this->getTimeout());
                        }
//              } else {
//                      print "result is cached ($key)<br />\n";
                }

//              print "<!-- result = ";
//              print_r($result);
//              print " -->\n";
                return $result;
        }

        public function fetch_uncached() {
                if ($this->getType() != "json") {
                        throw new Exception("This class only knows how to 
handle JSON for now");
                }

                $result = null;
                $get_result = file_get_contents($this);
                if ($this->getType() == "json") {
                        $result = json_decode($get_result);
                }

                return $result;
        }

        public function __toString() {
                $returnval = $this->url . "/" . $this->action . "?wt=" . 
$this->type;

                if (count($this->getSort()) > 0) {
                        $returnval .= "&sort=" . urlencode(join(",", 
$this->getSort()));
                }

                if (count($this->getFields()) > 0) {
                        $returnval .= "&fl=" . urlencode(join(",", 
$this->getFields()));
                } else {
                        $returnval .= "&fl=*";
                }

                $returnval .= "&q=" . urlencode(join(" ", $this->getQuery()));

                return $returnval;
        }
}

?>

Index: package.php
===================================================================
RCS file: /cvsroot/fink/pdb/site/package.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- package.php 16 Nov 2007 19:36:09 -0000      1.1.1.1
+++ package.php 30 Nov 2007 22:11:04 -0000      1.2
@@ -1,4 +1,4 @@
-<?
+<?php
 $title = "Package Database - Package ";
 $cvs_author = '$Author$';
 $cvs_date = '$Date$';
@@ -6,367 +6,353 @@
 $uses_pathinfo = 1;
 include "header.inc";
 include "memcache.inc";
+include "functions.inc";
+include "../php-lib/releases.inc";
 $package = $pispec;
-?>
-
-
-<?
-if ($package == "-") {
-?>
-<p class="attention"><b>No package specified.</b></p>
-<?
-} else { /* if (no package) */
-
 
 // Get url parameters
 list($version, $inv_p) = get_safe_param('version', '/^[0-9\-.:]+$/');
 list($distribution, $inv_p) = get_safe_param('distribution', 
'/^[a-z0-9\-.]+$/');
 list($release, $inv_p) = get_safe_param('release', 
'/^[0-9.]{3,}$|^unstable$|^stable$/');
 list($architecture, $inv_p) = get_safe_param('architecture', 
'/^powerpc$|^i386$/');
-list($rel_id, $inv_p) = get_safe_param('rel_id', '/^[0-9]+$/');
+list($rel_id, $inv_p) = get_safe_param('rel_id', '/^[[:alnum:]\-\_\.\:]+$/');
 list($showall, $inv_p) = get_safe_param('showall', '/^on$/');
+list($doc_id, $inv_p) = get_safe_param('doc_id', '/^[[:alnum:]\-\_\.\:]+$/');
 
-// TODO/FIXME: Do we really need all the params above? On the other hand --
-// if the user clicks on a specific package version, shouldn't we select
-// that version via the *pkg_id* ?
-// In particular, it seems rather ugly to search the DB with a concat...
-// A reason to keep those params would be to allow looking at a specific 
-// package version w/o knowing a pkg_id. But when would we ever be in such
-// a situation? I.e. is there *anything* that would need to do that?
+$basicQuery = new SolrQuery();
 
+$basicQuery->addSort("dist_priority desc");
+$basicQuery->addSort("rel_priority desc");
 
-// Get package data to display (use for version-nonspecific pkg metadata)
-$qtodisplay_sel = "SELECT p.*,r.*,d.*,p.version AS pkg_version ";
-$qtodisplay_sel .= "FROM `package` AS p ";
-$qtodisplay_sel .= "INNER JOIN `release` r ON r.rel_id = p.rel_id ";
-$qtodisplay_sel .= "INNER JOIN `distribution` d ON r.dist_id = d.dist_id ";
-if (!$showall)
-  $qtodisplay_sel .= "AND d.visible='1' ";
+$basicQuery->addQuery("name_e:\"$package\"", true);
+if (!$showall) {
+       $basicQuery->addQuery("dist_visible:true", true);
+}
+
+$fullQuery = clone $basicQuery;
 
-$qtodisplay_where .= "WHERE p.name='$package' ";
 if ($version) {
-  if (strrpos($version, ':'))
-    $qtodisplay_where .= "AND 
CONCAT(p.epoch,':',p.version,'-',p.revision)='$version' ";
-  else
-    $qtodisplay_where .= "AND CONCAT(p.version,'-',p.revision)='$version' ";
+       list($epoch, $version, $revision) = parse_version($version);
+       if ($epoch != null)
+               $fullQuery->addQuery("epoch:$epoch", true);
+       if ($version != null)
+               $fullQuery->addQuery("version_e:$version", true);
+       if ($revision != null)
+               $fullQuery->addQuery("revision_e:$revision", true);
 }
-if ($rel_id) {
-  $qtodisplay_where .= "AND r.rel_id='$rel_id' ";
+
+if ($doc_id) {
+       $fullQuery->addQuery("doc_id:\"$doc_id\"", true);
+} elseif ($rel_id) {
+       $fullQuery->addQuery("rel_id:\"$rel_id\"", true);
 } else { // no need to parse the other parameters
-  if ($distribution) {
-    $qtodisplay_where .= "AND d.identifier='$distribution' ";
-  }
-  if ($release) {
-    if ($release == 'unstable' || $release == 'stable') {
-      $qtodisplay_where .= "AND r.type='$release' ";
-    } else {
-      $qtodisplay_where .= "AND r.version='$release' ";
-    }
-  }
-  if ($architecture) {
-    $qtodisplay_where .= "AND d.architecture='$architecture' ";
-  }
+       if ($distribution) {
+               $fullQuery->addQuery("dist_name:\"$distribution\"", true);
+       }
+       if ($release) {
+               if ($release == 'unstable' || $release == 'stable') {
+                       $fullQuery->addQuery("rel_type:$release", true);
+               } else {
+                       $fullQuery->addQuery("rel_version:$release", true);
+               }
+       }
+       if ($architecture) {
+               $fullQuery->addQuery("dist_architecture:$architecture", true);
+       }
 }
 
-$qtodisplay_order .= "ORDER BY d.priority DESC,r.priority DESC";
-$qtodisplay = $qtodisplay_sel.$qtodisplay_where.$qtodisplay_order;
-$error_level = error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
-$qs = cachedQuery($qtodisplay);
-error_reporting($error_level);
-if ($qs) {
-  $pkg2disp = array_shift($qs);
-}
+$result = $fullQuery->fetch();
+
+// print_r($result);
+// exit(0);
 
 $warning = '';
-if (!$pkg2disp) { # No specific version found, try latest
-  $qtodisplay = $qtodisplay_sel."WHERE p.name='$package' ".$qtodisplay_order;
-  $error_level = error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
-  $qs = cachedQuery($qtodisplay);
-  error_reporting($error_level);
-  if ($qs) {
-    $pkg2disp = array_shift($qs);
-  }
-  $warning = "<b>Warning: Package $package $version not found";
-  $warning .= $distribution ? " in distribution $distribution" : '';
-  $warning .= $architecture ? "-$architecture" : '';
-  $warning .= $release ? "-$release" : '';
-  $warning .= $rel_id ? " for selected release" : '';
-  $warning .= "!</b>";
+if ($result == null || $result->response->numFound == 0) { # No specific 
version found, try latest
+       $result = $basicQuery->fetch();
+       error_reporting($error_level);
+       $warning = "<b>Warning: Package $package $version not found";
+       $warning .= $distribution ? " in distribution $distribution" : '';
+       $warning .= $architecture ? "-$architecture" : '';
+       $warning .= $release ? "-$release" : '';
+       $warning .= $rel_id ? " for selected release" : '';
+       $warning .= "!</b>";
 }
 
-if (!$pkg2disp) { # No package found
+if ($result == null || $result->response->numFound == 0) { # No package found
 ?>
 <p><b>Package '<?=$package?>' not found in Fink!</b></p>
 <?
-} else { /* if (no package found) */
-
-if ($pkg2disp["epoch"] > 0) {
-  $fullversion = 
$pkg2disp["epoch"].':'.$pkg2disp["pkg_version"]."-".$pkg2disp["revision"];
 } else {
-  $fullversion = $pkg2disp["pkg_version"]."-".$pkg2disp["revision"];
-}
+
+       $pobj = array_shift($result->response->docs);
+       $fullversion = $pobj->version . '-' . $pobj->revision;
+       if ($pobj->epoch > 0) {
+               $fullversion = $pobj->epoch . ':' . $fullversion;
+       }
 
 ?>
-<h1>Package <? print $package." ".$fullversion ?></h1>
+<h1>Package <? print $pobj->name . '-' . $fullversion ?></h1>
 <?
 
+       function avail_td($text='', $extras='', $extra_div_style='') {
+               print '<td align="center" valign="top" ' . $extras . '>';
+               print '<div style="white-space:nowrap; ' . $extra_div_style . ' 
">' . $text . '</div>';
+               print '</td>';
+       }
+       
+       function show_desc($label, $text) {
+               $text = htmlentities($text);
+               if ($text) {
+                       # Try to detect urls
+                       $text = preg_replace('/http:\/\/[^ &:]+/', '<a 
href="${0}">${0}</a>', $text);
+                       $text = str_replace("\\n", "\n", $text);
+                       $text = '<div class="desc">' . $text . '</div>';
+                       if ($label)
+                               it_item($label, '');
+                       it_item('', $text);
+               }
+       }
+       
+       function version_tags($p) {
+               global $showall;
+               global $pobj;
 
- function avail_td($text, $extras='', $extra_div_style='') {
-   print '<td align="center" valign="top" ' . $extras . '>';
-   print '<div style="white-space:nowrap; ' . $extra_div_style . ' ">' . $text 
. '</div>';
-   print '</td>';
- }
- 
- function show_desc($label, $text) {
-   $text = htmlentities($text);
-   if ($text) {
-     # Try to detect urls
-     $text = preg_replace('/http:\/\/[^ &:]+/', '<a href="${0}">${0}</a>', 
$text);
-     $text = str_replace("\\n", "\n", $text);
-     $text = '<div class="desc">' . $text . '</div>';
-     if ($label)
-       it_item($label, '');
-     it_item('', $text);
-   }
- }
- 
- function version_tags($package, $vers, $rel_id, $disp_vers, $disp_rel_id, 
$showall = false) {
-   if ($vers == $disp_vers && $rel_id == $disp_rel_id) {
-     $open_tag = '<b>';
-     $close_tag = '</b>';
-   } else {
-     $open_tag = "<a href=\"$package?version=$vers&rel_id=$rel_id";
-     if ($showall)
-       $open_tag .= '&showall=on';
-     $open_tag .= '">';
-     $close_tag = '</a>';
-   }
-   return array (
-     $open_tag,
-     $close_tag,
-   );
- }
- 
- function link_to_package($package, $vers, $rel_id, $showall = false, 
$description='') {
-   $pkg_str = '<a href="'.$package;
-   $pkg_param = '';
-   if ($vers) {
-     $pkg_param .= '?version='.$vers;
-     if ($rel_id)
-       $pkg_param .= '&rel_id='.$rel_id;
-   }
-   elseif ($rel_id)
-     $pkg_param .= '?rel_id='.$rel_id;
-   if ($showall) {
-     if ($pkg_param)
-       $pkg_param .= '&showall=on';
-     else
-       $pkg_param .= '?showall=on';
-   }
-   $pkg_str .= $pkg_param.'">'.$package.'</a> ';
-   if ($description)
-     $pkg_str .= htmlentities($description);
-   return $pkg_str;
- }
+               if ($p->version == $pobj->version && $p->rel_id == 
$pobj->rel_id) {
+                       $open_tag = '<b>';
+                       $close_tag = '</b>';
+               } else {
+                       $open_tag = "<a href=\"$package?doc_id=" . $p->doc_id;
+                       if ($showall)
+                               $open_tag .= "&showall=on";
+                       $open_tag .= '">';
+                       $close_tag = '</a>';
+               }
+               return array ( $open_tag, $close_tag );
+       }
 
+       /*
+       function version_tags($package, $vers, $rel_id, $disp_vers, 
$disp_rel_id, $showall = false) {
+               if ($vers == $disp_vers && $rel_id == $disp_rel_id) {
+                       $open_tag = '<b>';
+                       $close_tag = '</b>';
+               } else {
+                       $open_tag = "<a 
href=\"$package?version=$vers&rel_id=$rel_id";
+                       if ($showall)
+                               $open_tag .= '&showall=on';
+                       $open_tag .= '">';
+                       $close_tag = '</a>';
+               }
+               return array (
+                       $open_tag,
+                       $close_tag,
+               );
+       }
+       */
+       
+       function link_to_package($package, $vers, $rel_id, $showall = false, 
$description='') {
+               $pkg_str = '<a href="'.$package;
+               $pkg_param = '';
+               if ($vers) {
+                       $pkg_param .= '?version='.$vers;
+                       if ($rel_id)
+                               $pkg_param .= '&rel_id='.$rel_id;
+               }
+               elseif ($rel_id)
+                       $pkg_param .= '?rel_id='.$rel_id;
+               if ($showall) {
+                       if ($pkg_param)
+                               $pkg_param .= '&showall=on';
+                       else
+                               $pkg_param .= '?showall=on';
+               }
+               $pkg_str .= $pkg_param.'">'.$package.'</a> ';
+               if ($description)
+                       $pkg_str .= htmlentities($description);
+               return $pkg_str;
+       }
 
- print '<table class="pkgversion" cellspacing="2" border="0">'."\n";
 
- print '<tr bgcolor="#ffecbf">';
- print '<th width="100" align="center" valign="bottom" 
rowspan="2">System</th>';
- print '<th width="150" align="center" valign="bottom" rowspan="2">Binary 
Distributions</th>';
- print '<th width="202" align="center" colspan="2">CVS/rsync Source 
Distributions</th>';
- print "</tr>\n";
+       print '<table class="pkgversion" cellspacing="2" border="0">'."\n";
 
- print '<tr bgcolor="#ffecbf">';
- print '<th width="100" align="center"><a 
href="http://feeds.feedburner.com/FinkProjectNews-stable";><img src="' . 
$pdbroot . 'rdf.png" alt="stable RSS feed" border="0"  width="14" height="14" 
/></a> stable</th>';
- print '<th width="100" align="center"><a 
href="http://feeds.feedburner.com/FinkProjectNews-unstable";><img src="' . 
$pdbroot . 'rdf.png" alt="unstable RSS feed" border="0"  width="14" height="14" 
/></a> unstable</th>';
- print "</tr>\n";
+       print '<tr bgcolor="#ffecbf">';
+       print '<th width="100" align="center" valign="bottom" 
rowspan="2">System</th>';
+       print '<th width="150" align="center" valign="bottom" 
rowspan="2">Binary Distributions</th>';
+       print '<th width="202" align="center" colspan="2">CVS/rsync Source 
Distributions</th>';
+       print "</tr>\n";
 
- // Fetch list of all distributions
- $q = "SELECT * FROM `distribution` WHERE active='1' ";
- if (!$showall)
-   $q .= "AND visible='1' ";
- $q .= "ORDER BY priority DESC";
- $qdist = cachedQuery($q);
- if (!$qdist) {
-   die('<p class="attention"><b>Error during db query (Distributions):</b> 
'.mysql_error().'</p>');
- }
- $color_count = 0;
- $last_identifier = '';
- $has_unsupported_dists = false;
- foreach ($qdist as $dist_row) {
-   if ($last_identifier != $dist_row['identifier'])
-     $color_count++;
-   if ($color_count == 1) {
-     $row_color='bgcolor="#e3caff"';
-   } else if ($color_count == 2) {
-     $row_color='bgcolor="#f1e2ff"';
-   } else {
-     $row_color='bgcolor="#f6ecff"';
-   }
-   $last_identifier = $dist_row['identifier'];
+       print '<tr bgcolor="#ffecbf">';
+       print '<th width="100" align="center"><a 
href="http://feeds.feedburner.com/FinkProjectNews-stable";><img src="' . 
$pdbroot . 'rdf.png" alt="stable RSS feed" border="0"  width="14" height="14" 
/></a> stable</th>';
+       print '<th width="100" align="center"><a 
href="http://feeds.feedburner.com/FinkProjectNews-unstable";><img src="' . 
$pdbroot . 'rdf.png" alt="unstable RSS feed" border="0"  width="14" height="14" 
/></a> unstable</th>';
+       print "</tr>\n";
 
-   // Query all releases (typically: stable, unstable, bindist) for the given 
distribution.
-   $q = "SELECT r.type FROM `release` r WHERE r.dist_id='" . 
$dist_row['dist_id'] . "' AND r.active='1' ORDER BY r.priority ASC";
-   $qrel = cachedQuery($q);
-   if (!$qrel) {
-     die('<p class="attention"><b>Error during db query (Releases):</b> 
'.mysql_error().'</p>');
-   }
-   $has_bindist = false;
-   $has_cvs_rsync = false;
-   foreach ($qrel as $rel_row) {
-     if ($rel_row['type'] == 'bindist')
-       $has_bindist = true;
-     elseif ($rel_row['type'] == 'unstable' || $rel_row['type'] == 'stable')
-       $has_cvs_rsync = true;
-   }
+       $color_count = 0;
+       $last_identifier = '';
+       $has_unsupported_dists = false;
 
-   // Now query all pkginfo per release (typically: stable, unstable, bindist) 
for the given distribution.
-   $q = "SELECT p.*, r.type, r.version AS rel_version FROM `package` p, 
`release` r WHERE p.name = '$package' AND p.rel_id = r.rel_id AND r.dist_id='" 
. $dist_row['dist_id'] . "' AND active='1' ORDER BY r.priority ASC";
-   $qrel = cachedQuery($q);
-   
-   $pkg_release = array();
-   
-   foreach ($qrel as $rel_row) {
-     $type = $rel_row['type'];
-     $rel_version = $rel_row["version"]."-".$rel_row["revision"];
-     if($rel_row["epoch"] > 0)
-       $rel_version = $rel_row["epoch"].":".$rel_version;
-     $pkg_release[$type]["version"] = $rel_version;
-     $pkg_release[$type]["restrictive"] = 
(strcasecmp($rel_row["license"],'Restrictive')==0);
-     $pkg_release[$type]["rel_id"] = $rel_row['rel_id'];
-     $pkg_release[$type]["pkg_id"] = $rel_row['pkg_id'];
-     $pkg_release[$type]["rel_version"] = $rel_row['rel_version'];
-   }
-   // System
-   print "<tr $row_color>";
-   if ($dist_row['unsupported']) {
-     avail_td(nl2br($dist_row['description'] . ' *'), '', 'color:gray; ');
-     $has_unsupported_dists = true;
-   }
-   else {
-     avail_td(nl2br($dist_row['description']));
-   }
+       global $distributions;
+       global $releases;
+       global $dists_to_releases;
 
-    // bindist
-    if ($has_bindist) {
-      $vers = $pkg_release["bindist"]["version"];
-      list($open_tag, $close_tag) = 
-        version_tags($package, $vers, $pkg_release["bindist"]["rel_id"], 
$fullversion, $pkg2disp["rel_id"], $showall);
-      avail_td(
-        strlen($vers) && !$pkg_release["bindist"]["restrictive"]
-        ? $open_tag . $vers . $close_tag . ' (bindist 
'.$pkg_release["bindist"]["rel_version"].')'
-        : '&mdash;'
-        , $bindist_rowspan
-      );
-      // need to use specific tag for info file in fink cvs?
-      if (strlen($vers) && !$pkg_release["bindist"]["restrictive"])
-        if ($vers == $fullversion && $pkg_release["bindist"]["rel_id"] == 
$pkg2disp["rel_id"])
-          $pkg2disp['bindist'] = $pkg_release["bindist"]["rel_version"];
-    } else {
-      avail_td('<i>no binary distribution</i>',$bindist_rowspan);
-    }
+       foreach ($distributions as $dist) {
+               $dist_id = $dist->getId();
 
-    // CVS/rsync dist
-    if ($has_cvs_rsync) {
-      $vers = $pkg_release["stable"]["version"];
-      list($open_tag, $close_tag) = 
-        version_tags($package, $vers, $pkg_release["stable"]["rel_id"], 
$fullversion, $pkg2disp["rel_id"], $showall);
-      avail_td(
-        strlen($vers)
-          ? $open_tag . $vers . $close_tag
-          : '&mdash;'
-        , $bindist_rowspan
-      );
-      $vers = $pkg_release["unstable"]["version"];
-      list($open_tag, $close_tag) = 
-        version_tags($package, $vers, $pkg_release["unstable"]["rel_id"], 
$fullversion, $pkg2disp["rel_id"], $showall);
-      avail_td(
-        strlen($vers)
-          ? $open_tag . $vers . $close_tag
-          : '&mdash;'
-        , $bindist_rowspan
-      );
-    } else {
-      avail_td("<i>unsupported</i>",$bindist_rowspan.' colspan=2');
-    }
-    print "</tr>\n";
-  }
-  
-  print "</table>\n";
+               if ($last_dist_id != $dist_id)
+                       $color_count++;
 
-  print "<br>";
+               if ($color_count == 1) {
+                       $row_color='bgcolor="#e3caff"';
+               } else if ($color_count == 2) {
+                       $row_color='bgcolor="#f1e2ff"';
+               } else {
+                       $row_color='bgcolor="#f6ecff"';
+               }
 
-  it_start();
-  
-  if ($warning)
-    it_item('', $warning);
+               if (!$showall && !$dist->isVisible())
+                       continue;
 
-  it_item("Description:", htmlentities($pkg2disp[descshort]) . " (" . 
$fullversion . ")");
-  show_desc('', $pkg2disp[desclong]);
+               print "<tr $row_color>";
 
-  show_desc('Usage&nbsp;Hints:', $pkg2disp[descusage]);
+               if ($dist->isSupported()) {
+                       avail_td(nl2br($dist->getDescription()));
+                       $has_unsupported_dists = true;
+               } else {
+                       avail_td(nl2br($dist->getDescription() . ' *'), '', 
'color:gray; ');
+               }
 
-  it_item("Section:", '<a 
href="'.$pdbroot.'browse.php?section='.$pkg2disp[section].'">'.$pkg2disp[section].'</a>');
+               foreach(array("bindist", "stable", "unstable") as $rel_type) {
+                       $pack = fetch_package($package, null, $dist->getName(), 
$rel_type, $dist->getArchitecture(), $showall);
+                       if ($pack == null) {
+                               avail_td("<i>no $rel_type distribution</i>");
+                       } else {
+                               if (is_array($pack)) {
+                                       $pack = $pack[0];
+                               }
+                               list($open_tag, $close_tag) = 
version_tags($pack);
+                               avail_td($open_tag . $pack->pkg_id . $close_tag 
. ' (bindist ' . $pack->rel_version . ')');
+                       }
+               }
 
-  // Get the maintainer field, and try to parse out the email address
-  if ($pkg2disp[maintainer]) {
+               continue;
+
+               // bindist
+               if (isset($dists_to_releases[$dist_id]['bindist'])) {
+                       $vers = $pkg_release["bindist"]["version"];
+                       list($open_tag, $close_tag) = 
+                                version_tags($package, $vers, 
$pkg_release["bindist"]["rel_id"], $fullversion, $pkg2disp["rel_id"], $showall);
+                       avail_td(
+                                strlen($vers) && 
!$pkg_release["bindist"]["restrictive"]
+                                ? $open_tag . $vers . $close_tag . ' (bindist 
'.$pkg_release["bindist"]["rel_version"].')'
+                                : '&mdash;'
+                                , $bindist_rowspan
+                       );
+                       // need to use specific tag for info file in fink cvs?
+                       if (strlen($vers) && 
!$pkg_release["bindist"]["restrictive"])
+                                if ($vers == $fullversion && 
$pkg_release["bindist"]["rel_id"] == $pkg2disp["rel_id"])
+                                  $pkg2disp['bindist'] = 
$pkg_release["bindist"]["rel_version"];
+               } else {
+                       avail_td('<i>no binary 
distribution</i>',$bindist_rowspan);
+               }
+
+               // CVS/rsync dist
+               if ($has_cvs_rsync) {
+                       $vers = $pkg_release["stable"]["version"];
+                       list($open_tag, $close_tag) = 
+                                version_tags($package, $vers, 
$pkg_release["stable"]["rel_id"], $fullversion, $pkg2disp["rel_id"], $showall);
+                       avail_td(
+                                strlen($vers)
+                                  ? $open_tag . $vers . $close_tag
+                                  : '&mdash;'
+                                , $bindist_rowspan
+                       );
+                       $vers = $pkg_release["unstable"]["version"];
+                       list($open_tag, $close_tag) = 
+                                version_tags($package, $vers, 
$pkg_release["unstable"]["rel_id"], $fullversion, $pkg2disp["rel_id"], 
$showall);
+                       avail_td(
+                                strlen($vers)
+                                  ? $open_tag . $vers . $close_tag
+                                  : '&mdash;'
+                                , $bindist_rowspan
+                       );
+               } else {
+                       avail_td("<i>unsupported</i>",$bindist_rowspan.' 
colspan=2');
+               }
+               print "</tr>\n";
+
+               $last_dist_id = $dist_id;
+       }
+       
+       print "</table>\n";
+
+       print "<br>";
+
+       it_start();
+       
+       if ($warning)
+               it_item('', $warning);
+
+       it_item("Description:", htmlentities($pkg2disp[descshort]) . " (" . 
$fullversion . ")");
+       show_desc('', $pkg2disp[desclong]);
+
+       show_desc('Usage&nbsp;Hints:', $pkg2disp[descusage]);
+
+       it_item("Section:", '<a 
href="'.$pdbroot.'browse.php?section='.$pkg2disp[section].'">'.$pkg2disp[section].'</a>');
+
+       // Get the maintainer field, and try to parse out the email address
+       if ($pkg2disp[maintainer]) {
        $maintainers = $pkg2disp[maintainer];
        preg_match("/^(.+?)\s*<(\S+)>/", $maintainers, $matches);
-    $maintainer = $matches[1];
-    $email = $matches[2];
-  } else {
-    $maintainer = "unknown";
-  }
-  // If there was an email specified, make the maintainer field a mailto: link
-  if ($email) {
-    $email = str_replace(array("@","."), array("AT","DOT"), $email);
-    it_item("Maintainer:", '<a 
href="'.$pdbroot.'browse.php?maintainer='.$maintainer.'">'.$maintainer.' 
&lt;'.$email.'&gt;'.'</a>');
+               $maintainer = $matches[1];
+               $email = $matches[2];
+       } else {
+               $maintainer = "unknown";
+       }
+       // If there was an email specified, make the maintainer field a mailto: 
link
+       if ($email) {
+               $email = str_replace(array("@","."), array("AT","DOT"), $email);
+               it_item("Maintainer:", '<a 
href="'.$pdbroot.'browse.php?maintainer='.$maintainer.'">'.$maintainer.' 
&lt;'.$email.'&gt;'.'</a>');
 #    it_item("Maintainer:", '<a href="mailto:'.$email.'">'.$maintainer.'</a>');
-  } else {
-    it_item("Maintainer:", '<a 
href="'.$pdbroot.'browse.php?maintainer='.$maintainer.'">'.$maintainer.'</a>');
-  }
-  if ($pkg2disp[homepage]) {
-    it_item("Website:", '<a 
href="'.$pkg2disp[homepage].'">'.$pkg2disp[homepage].'</a>');
-  }
-  if ($pkg2disp[license]) {
-    it_item("License:", '<a 
href="http://fink.sourceforge.net/doc/packaging/policy.php#licenses";>'.$pkg2disp[license].'</a>');
-  }
-  if ($pkg2disp[parentname]) {
-    it_item("Parent:", link_to_package($pkg2disp[parentname], $version, 
$rel_id, $showall));
-  }
-  if ($pkg2disp[infofile]) {
-    # where the info file sits on a local Fink installation
-    $infofile_path = "/sw/" . str_replace('dists/', '', $pkg2disp[infofile]);
-    $infofile_cvs_url = 'http://fink.cvs.sourceforge.net/'.$pkg2disp[infofile];
-    if ($pkg2disp['bindist'])
-      $infofile_tag = '?pathrev=release_'.str_replace('.', '_', 
$pkg2disp['bindist']);
-    else
-      $infofile_tag = '';
-    $infofile_html  = '<a 
href="'.$infofile_cvs_url.$infofile_tag.($infofile_tag ? '&' : 
'?').'view=markup">'.$infofile_path.'</a><br>';
-    $infofile_html .= '<a href="'.$infofile_cvs_url.$infofile_tag.'">CVS 
log</a>, Last Changed: '.$pkg2disp[infofilechanged];
-    it_item("Info-File:", $infofile_html);
-  }
+       } else {
+               it_item("Maintainer:", '<a 
href="'.$pdbroot.'browse.php?maintainer='.$maintainer.'">'.$maintainer.'</a>');
+       }
+       if ($pkg2disp[homepage]) {
+               it_item("Website:", '<a 
href="'.$pkg2disp[homepage].'">'.$pkg2disp[homepage].'</a>');
+       }
+       if ($pkg2disp[license]) {
+               it_item("License:", '<a 
href="http://fink.sourceforge.net/doc/packaging/policy.php#licenses";>'.$pkg2disp[license].'</a>');
+       }
+       if ($pkg2disp[parentname]) {
+               it_item("Parent:", link_to_package($pkg2disp[parentname], 
$version, $rel_id, $showall));
+       }
+       if ($pkg2disp[infofile]) {
+               # where the info file sits on a local Fink installation
+               $infofile_path = "/sw/" . str_replace('dists/', '', 
$pkg2disp[infofile]);
+               $infofile_cvs_url = 
'http://fink.cvs.sourceforge.net/'.$pkg2disp[infofile];
+               if ($pkg2disp['bindist'])
+                       $infofile_tag = '?pathrev=release_'.str_replace('.', 
'_', $pkg2disp['bindist']);
+               else
+                       $infofile_tag = '';
+               $infofile_html  = '<a 
href="'.$infofile_cvs_url.$infofile_tag.($infofile_tag ? '&' : 
'?').'view=markup">'.$infofile_path.'</a><br>';
+               $infofile_html .= '<a 
href="'.$infofile_cvs_url.$infofile_tag.'">CVS log</a>, Last Changed: 
'.$pkg2disp[infofilechanged];
+               it_item("Info-File:", $infofile_html);
+       }
 
 
        // List the splitoffs of this package
 
        $q = "SELECT * FROM `package` WHERE rel_id='$pkg2disp[rel_id]' AND 
parentname='$pkg2disp[name]' ORDER BY name";
-   $rs = cachedQuery($q);
+               $rs = cachedQuery($q);
        if($row = array_shift($rs))
-         it_item("SplitOffs:", link_to_package($row["name"], $version, 
$rel_id, $showall, $row["descshort"]));
+               it_item("SplitOffs:", link_to_package($row["name"], $version, 
$rel_id, $showall, $row["descshort"]));
        foreach ($rs as $row) {
-         it_item(" ", link_to_package($row["name"], $version, $rel_id, 
$showall, $row["descshort"]));
+               it_item(" ", link_to_package($row["name"], $version, $rel_id, 
$showall, $row["descshort"]));
        }
-  it_end();
+       it_end();
 ?>
 
 
 
 <?
 } /* if (no package found) */
-} /* if (no package) */
 ?>
 
 <p><a href="<? print $pdbroot ?>sections.php">Section list</a> -

Index: header.inc
===================================================================
RCS file: /cvsroot/fink/pdb/site/header.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- header.inc  16 Nov 2007 19:36:09 -0000      1.1.1.1
+++ header.inc  30 Nov 2007 22:11:04 -0000      1.2
@@ -60,31 +60,26 @@
   $root = $fsroot;
 }
 include "hostlogo.inc";
-include $fsroot."header.inc";
+#include $fsroot."header.inc";
 
-/* connect to database */
-include $fsroot."db.inc.php";
-$error_level = error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
-try {
-  $dbh = mysql_pconnect($db_host, $db_user, $db_passwd);
-  mysql_select_db($db_name, $dbh);
-}
-catch (Exception $e) {
-}
-error_reporting($error_level);
-if (!$dbh)
-  print '<p class="attention"><b>Couldn\'t connect to database!</b></p>';
+$solrurl = 'http://localhost:8983/solr';
 
+/* connect to solr */
+#require_once("Apache/Solr/Service.php");
+#$solr = new Apache_Solr_Service("localhost", 8983, "/solr");
+#if (!$solr)
+#      print '<p class="attention"><b>Couldn\'t connect to the query 
backend!</b></p>';
 
 // Read url parameters. We use basic HTML encoding for now, and 
 // cut off very long values, to make unforseen SQL injection hacks more 
difficult.
-function get_safe_param($param_name, $valid_regexp='.*', $max_length=35) {
+function get_safe_param($param_name, $valid_regexp='.*', $max_length=120) {
   $param_name = $_GET[$param_name];
   if ($param_name) $has_param_name = true;
   if (strlen($param_name) > $max_length || !preg_match($valid_regexp, 
$param_name)) {
     $param_name = '';
   } else {
-    $param_name = mysql_real_escape_string(htmlspecialchars($param_name));
+    #$param_name = mysql_real_escape_string(htmlspecialchars($param_name));
+    $param_name = htmlspecialchars($param_name);
     if (strlen($param_name) > $max_length || !preg_match($valid_regexp, 
$param_name))
       $param_name = '';
   }

Index: memcache.inc
===================================================================
RCS file: /cvsroot/fink/pdb/site/memcache.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- memcache.inc        16 Nov 2007 19:36:09 -0000      1.1.1.1
+++ memcache.inc        30 Nov 2007 22:11:04 -0000      1.2
@@ -1,5 +1,6 @@
 <?
 
+/*
 $memcache = new Memcache();
 $memcache->connect('localhost', 11211);
 
@@ -35,5 +36,6 @@
        }
 
 }
+*/
 
 ?>

Index: help.php
===================================================================
RCS file: /cvsroot/fink/pdb/site/help.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- help.php    16 Nov 2007 19:36:09 -0000      1.1.1.1
+++ help.php    30 Nov 2007 22:11:04 -0000      1.2
@@ -1,4 +1,4 @@
-<?
+<?php
 $title = "Package Database - Help Needed";
 $cvs_author = '$Author$';
 $cvs_date = '$Date$';
@@ -37,7 +37,6 @@
 </a> of packages without maintainer.
 </p>
 
-
-<?
+<?php
 include "footer.inc";
 ?>


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Fink-commits mailing list
[email protected]
http://news.gmane.org/gmane.os.apple.fink.cvs

Reply via email to