diff options
author | Arun Persaud <arun@nubati.net> | 2011-11-29 21:27:26 -0800 |
---|---|---|
committer | Arun Persaud <apersaud@lbl.gov> | 2011-11-29 21:27:26 -0800 |
commit | 710c7defb7a4a4de3830c4beff12c7da0c8c3391 (patch) | |
tree | bf9fd4205842e53f04235316c6272ca6a4a64f61 | |
parent | b03d63d5006a71307d4f04b22170bdeddc8d8746 (diff) | |
download | photo-tags-710c7defb7a4a4de3830c4beff12c7da0c8c3391.tar.gz photo-tags-710c7defb7a4a4de3830c4beff12c7da0c8c3391.tar.bz2 photo-tags-710c7defb7a4a4de3830c4beff12c7da0c8c3391.zip |
add support to query multiple tags, use "," as a separation character
-rw-r--r-- | .htaccess_template | 6 | ||||
-rw-r--r-- | getjson.php | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/.htaccess_template b/.htaccess_template index 203ba4c..f5e86c5 100644 --- a/.htaccess_template +++ b/.htaccess_template @@ -7,13 +7,13 @@ RewriteBase /<insert web base url here> # make the url nice and clean; the comments shows an url that should be matched # web_base/tag/me+berlin/pic/id -RewriteRule tag/([-_a-zA-Z0-9+]*)/pic/([0-9]*) index.php?tag=$1&pic=$2 [L] +RewriteRule tag/([-_\s,a-zA-Z0-9+]*)/pic/([0-9]*) index.php?tag=$1&pic=$2 [L] # web_base/tag/tag1+tag2/page/4 -RewriteRule tag/([-_a-zA-Z0-9+]*)/page/([0-9]*) index.php?tag=$1&page=$2 [L] +RewriteRule tag/([-_\s,a-zA-Z0-9+]*)/page/([0-9]*) index.php?tag=$1&page=$2 [L] # web_base/tag/tag1+tag2 -RewriteRule tag/([-_a-zA-Z0-9+]*) index.php?tag=$1 [L] +RewriteRule tag/([-_\s,a-zA-Z0-9+]*) index.php?tag=$1 [L] # web_base/pic/17 RewriteRule pic/([0-9]*) index.php?pic=$1 [L] diff --git a/getjson.php b/getjson.php index 007ef7c..97f8c49 100644 --- a/getjson.php +++ b/getjson.php @@ -34,11 +34,13 @@ else if (isset($_REQUEST["T"])) { /* single tag or part of tag */ - $tags = sqlite_escape_string($_REQUEST["T"]); - $tags = explode("+",$tags); + $tags = $_REQUEST["T"]; + $tags = explode(",",$tags); + foreach ($tags as $key => $value) + $tags[$key]=sqlite_escape_string(trim($value)); $tags = "'".implode("','",$tags)."'"; - /* individual tags are seperated by '+' */ + /* individual tags are seperated by ',' */ $result = $DB->query("SELECT base_uri, filename FROM photos ". " left join photo_tags on photos.id=photo_tags.photo_id ". " left join tags on tags.id=photo_tags.tag_id ". |