Modified to get details based on an exact package name, or based on a package id.

This commit is contained in:
eliott 2007-11-22 19:28:11 -08:00 committed by Dan McGee
parent 47e80c24af
commit 32b863203f

View file

@ -101,16 +101,27 @@ class AurJSON {
} }
/** /**
* Returns the info on a specific package id. * Returns the info on a specific package.
* @param $package_id The ID of the package to fetch info. * @param $pqdata The ID or name of the package. Package Query Data.
* @return mixed Returns an array of value data containing the package data * @return mixed Returns an array of value data containing the package data
**/ **/
private function info($package_id) { private function info($pqdata) {
// using sprintf to coerce the package_id to an int $base_query = "SELECT ID,Name,Version,Description,URL,URLPath,License,NumVotes,OutOfDate FROM Packages WHERE ";
if is_numeric($pqdata) {
// just using sprintf to coerce the pqd to an int
// should handle sql injection issues, since sprintf will // should handle sql injection issues, since sprintf will
// bork if not an int, or convert the string to a number // bork if not an int, or convert the string to a number 0
$query = sprintf("SELECT ID,Name,Version,Description,URL,URLPath,License,NumVotes,OutOfDate FROM Packages WHERE ID=%d",$package_id); $query_stub = sprintf("ID=%d",$pqdata);
$result = db_query($query, $this->dbh); }
else {
if(get_magic_quotes_gpc()) {
$pqd = stripslashes($pqdata);
}
$query_stub = sprintf("Name=%s",mysql_real_escape_string($pqdata));
}
$result = db_query($query.$base_query, $this->dbh);
if ( $result && (mysql_num_rows($result) > 0) ) { if ( $result && (mysql_num_rows($result) > 0) ) {
$row = mysql_fetch_assoc($result); $row = mysql_fetch_assoc($result);