db = new SQLiteDatabase($dbhandle); } catch (Exception $exception) { die($exception->getMessage()); } } private function lazy_programmer() { die("LAZY PROGRAMMER ERROR"); } protected function getQuery($query) { $res = $this->db->query($query, SQLITE_ASSOC, $query_error); if ($query_error) { die("ERROR: $query_error"); } $this->last_result = $res->fetchAll(SQLITE_ASSOC); return $this->last_result; } public function doQuery() { $this->lazy_programmer(); } protected function htmlHeader() { return ' CRUX port browser
Home :: Documentation :: Download :: Development :: Community :: Public :: Ports :: Bugs :: Links :: About
Sections: Repositories :: Search :: Register :: Duplicates'; } protected function htmlFooter() { return '
'; } 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) { if ($repo["colltype"] == "httpup") { $url = '' . $repo["url"] . ''; } else { $url = $repo["url"]; } $html .= ''; $html .= '"; $html .= ""; $html .= '"; $html .= "\n"; $i++; } $html .= "
Repo Name# portsTypeMaintainerRepo URL
' . $repo["collname"] . "" . $repo["tot"] . "' . $repo["colltype"] . '' . "" . nospam($repo["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 $dsn = "/home/lucas/dev/portdb/portdb.db"; $portdb = new RepoList($dsn); $res = $portdb->doQuery(); //print_r($res[0]); echo $portdb->toHTML($res); ?>