diff options
author | Simo Leone <simo@archlinux.org> | 2008-02-19 00:05:06 -0800 |
---|---|---|
committer | Simo Leone <simo@archlinux.org> | 2008-03-23 03:04:16 -0500 |
commit | 196543a9e74474b4487d15f861f60401fe12ea24 (patch) | |
tree | d8c91ae1bcd58dd4abdfb96f6d6bb9ed2f7dc279 /web | |
parent | a2fe04f75121e7daeca47a38daba9c85b2dd8f6f (diff) | |
download | aurweb-196543a9e74474b4487d15f861f60401fe12ea24.tar.xz |
Make JSON interface work
Now makes sure json php module is loaded,
also fixed a few coding errors and made
the search behave like the search on the
web interface.
Signed-off-by: Simo Leone <simo@archlinux.org>
Diffstat (limited to 'web')
-rw-r--r-- | web/lib/aurjson.class.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index 2df8dd3..1d1b52d 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -8,6 +8,10 @@ * @copyright cactuswax.net, 12 October, 2007 * @package rpc **/ +if (!extension_loaded('json')) +{ + dl('json.so'); +} /** * This class defines a remote interface for fetching data @@ -78,9 +82,10 @@ class AurJSON { * @return mixed Returns an array of package matches. **/ private function search($keyword_string) { + $keyword_string = mysql_real_escape_string($keyword_string, $this->dbh); $query = sprintf( - "SELECT Name,ID FROM Packages WHERE MATCH(Name,Description) AGAINST('%s' IN BOOLEAN MODE)", - mysql_real_escape_string($keyword_string, $this->dbh) ); + "SELECT Name,ID FROM Packages WHERE Name LIKE '%%%s%%' OR Description LIKE '%%%s%%' AND DummyPkg=0", + $keyword_string, $keyword_string ); $result = db_query($query, $this->dbh); @@ -106,7 +111,7 @@ class AurJSON { * @return mixed Returns an array of value data containing the package data **/ private function info($pqdata) { - $base_query = "SELECT ID,Name,Version,Description,URL,URLPath,License,NumVotes,OutOfDate FROM Packages WHERE "; + $base_query = "SELECT ID,Name,Version,Description,URL,URLPath,License,NumVotes,OutOfDate FROM Packages WHERE DummyPkg=0 AND"; if ( is_numeric($pqdata) ) { // just using sprintf to coerce the pqd to an int @@ -118,10 +123,10 @@ class AurJSON { if(get_magic_quotes_gpc()) { $pqd = stripslashes($pqdata); } - $query_stub = sprintf("Name=%s",mysql_real_escape_string($pqdata)); + $query_stub = sprintf("Name=\"%s\"",mysql_real_escape_string($pqdata)); } - $result = db_query($query.$base_query, $this->dbh); + $result = db_query($base_query.$query_stub, $this->dbh); if ( $result && (mysql_num_rows($result) > 0) ) { $row = mysql_fetch_assoc($result); |