db = new PDO($dbhandle); } catch (Exception $exception) { die($exception->getMessage()); } } private function lazy_programmer() { die("LAZY PROGRAMMER ERROR"); } protected function getQuery($query) { try { $res = $this->db->query($query); } catch (Exception $exception) { die($exception->getMessage()); } $this->last_result = $res->fetchAll(); return $this->last_result; } public function doQuery() { $this->lazy_programmer(); } protected function htmlHeader() { return file_get_contents("header.html"); } protected function htmlFooter() { return file_get_contents("footer.html"); } protected function toHTML() { die($this->lazy_programmer()); } public function toXML() { header("Content-type: text/xml"); echo ''; } } class RepoList extends PortDb { public function doQuery() { $sql = 'select collname,maintainer,colltype,url,count(*) as tot from collections join ports on collection=collname group by collname order by collections.collid'; return $this->getQuery($sql); } public function toXML($res) { PortDb::toXML($res); $xml = "\n\n"; foreach ($res as $repo) { $xml .= "\t\n"; $xml .= "\t\t" . $repo["collname"] . "\n"; $xml .= "\t\t" . nospam($repo["maintainer"]) . "\n"; $xml .= "\t\t" . $repo["colltype"] . "\n"; $xml .= "\t\t" . $repo["url"] . "\n"; $xml .= "\t\t" . $repo["tot"] . "\n"; $xml .= "\t\n"; } $xml .= ""; return $xml; } public function toHTML($res) { $html = PortDb::htmlHeader(); $html .= "

Overview of available repositories

\n"; $html .= "\n"; $html .= "\n"; $i = 0; foreach ($res as $repo) { $name =& $repo["collname"]; $count =& $repo["tot"]; $type =& $repo["colltype"]; $maintainer =& nospam($repo["maintainer"]); if ($type == "httpup") { $url = '' . $repo["url"] . ''; } else { $url =& $repo["url"]; } $row = $i%2; $html .= "\n"; $i++; } $html .= "
Repo Name# portsTypeMaintainerRepo URL
$name $count $type $maintainer $url
\n"; $html .= PortDb::htmlFooter(); return $html; } } class PortsList extends PortDb { public function doQuery($repo) { $sql = "select * from ports join collections on collection=collname where collection = ? order by portname"; return $this->getQuery($sql); } } $portdb = new RepoList($dbhandle); $res = $portdb->doQuery(); //print_r($res[0]); echo $portdb->toHTML($res); ?>