summaryrefslogtreecommitdiffstats
path: root/web/lib/aurjson.class.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-10-24 08:31:47 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-10-24 10:03:54 +0200
commit76343fb91511b9f53e58b6c01b258bfe00ddb4c6 (patch)
tree60eb4d3727bae159a1807915a58348b210ead206 /web/lib/aurjson.class.php
parenta0a523070847230565c2ad5993ee058ff475a8e1 (diff)
downloadaurweb-76343fb91511b9f53e58b6c01b258bfe00ddb4c6.tar.xz
Use an INI-style configuration file
Replace web/lib/config.inc.php with an INI-style configuration file. This allows us to get rid of several globals and makes it easier to use the same configuration file in external scripts. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/aurjson.class.php')
-rw-r--r--web/lib/aurjson.class.php13
1 files changed, 6 insertions, 7 deletions
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index b31143e..025adaf 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -192,7 +192,8 @@ class AurJSON {
}
private function process_query($type, $where_condition) {
- global $MAX_RPC_RESULTS;
+ $max_results = config_get_int('options', 'max_rpc_results');
+ $package_url = config_get('options', 'package_url');
if ($this->version == 1) {
$fields = implode(',', self::$fields_v1);
@@ -207,7 +208,7 @@ class AurJSON {
"ON Licenses.ID = PackageLicenses.LicenseID " .
"WHERE ${where_condition} " .
"GROUP BY Packages.ID " .
- "LIMIT $MAX_RPC_RESULTS";
+ "LIMIT $max_results";
} elseif ($this->version >= 2) {
$fields = implode(',', self::$fields_v2);
$query = "SELECT {$fields} " .
@@ -216,7 +217,7 @@ class AurJSON {
"LEFT JOIN Users " .
"ON PackageBases.MaintainerUID = Users.ID " .
"WHERE ${where_condition} " .
- "LIMIT $MAX_RPC_RESULTS";
+ "LIMIT $max_results";
}
$result = $this->dbh->query($query);
@@ -226,7 +227,7 @@ class AurJSON {
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$resultcount++;
$pkgbase_name = $row['PackageBase'];
- $row['URLPath'] = URL_DIR . substr($pkgbase_name, 0, 2) . "/" . $pkgbase_name . "/" . $pkgbase_name . ".tar.gz";
+ $row['URLPath'] = $package_url . substr($pkgbase_name, 0, 2) . "/" . $pkgbase_name . "/" . $pkgbase_name . ".tar.gz";
/*
* Unfortunately, mysql_fetch_assoc() returns
@@ -254,7 +255,7 @@ class AurJSON {
}
}
- if ($resultcount === $MAX_RPC_RESULTS) {
+ if ($resultcount === $max_results) {
return $this->json_error('Too many package results.');
}
@@ -303,8 +304,6 @@ class AurJSON {
* @return mixed Returns an array of package matches.
*/
private function search($keyword_string) {
- global $MAX_RPC_RESULTS;
-
if (strlen($keyword_string) < 2) {
return $this->json_error('Query arg too small');
}