mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Modified to get details based on an exact package name, or based on a package id.
This commit is contained in:
parent
47e80c24af
commit
32b863203f
1 changed files with 19 additions and 8 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue