From 5ea211de598c1e02a9f5ccb04b83a81ed9b41117 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 15 Dec 2007 08:59:44 +0000 Subject: issue implode() instead of looping around an array, arun git-svn-id: file:///var/lib/svn/phpfspot/trunk@309 fa6a889d-dae6-447d-9e79-4ba9a3039384 --- phpfspot.class.php | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/phpfspot.class.php b/phpfspot.class.php index 61b01c0..d67c7e3 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -253,13 +253,7 @@ class PHPFSPOT { INNER JOIN tags t ON pt.tag_id=t.id WHERE p.id='". $idx ."' - AND t.name IN ( - "; - foreach($this->cfg->show_tags as $tag) { - $query_str.= "'". $tag ."',"; - } - $query_str = substr($query_str, 0, strlen($query_str)-1); - $query_str.= ")"; + AND t.name IN ('".implode("','",$this->cfg->show_tags)."')"; } else { $query_str.= " @@ -666,11 +660,7 @@ class PHPFSPOT { $query_str.= "AND ". $additional_where_cond ." "; if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) { - $query_str.= "AND t.name IN ("; - foreach($this->cfg->show_tags as $tag) { - $query_str.= "'". $tag ."',"; - } - $query_str = substr($query_str, 0, strlen($query_str)-1) . ")"; + $query_str.= "AND t.name IN ('".implode("','",$this->cfg->show_tags)."')"; } if(isset($order_str)) @@ -704,11 +694,7 @@ class PHPFSPOT { $query_str.= "AND ". $additional_where_cond ." "; if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) { - $query_str.= "AND t.name IN ("; - foreach($this->cfg->show_tags as $tag) { - $query_str.= "'". $tag ."',"; - } - $query_str = substr($query_str, 0, strlen($query_str)-1) . ")"; + $query_str.= "AND t.name IN ('".implode("','",$this->cfg->show_tags)."')"; } if(isset($order_str)) @@ -763,11 +749,7 @@ class PHPFSPOT { $query_str.= "AND ". $additional_where_cond; if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) { - $query_str.= "AND t.name IN ("; - foreach($this->cfg->show_tags as $tag) { - $query_str.= "'". $tag ."',"; - } - $query_str = substr($query_str, 0, strlen($query_str)-1) . ")"; + $query_str.= "AND t.name IN ('".implode("','",$this->cfg->show_tags). "')"; } if(isset($order_str)) @@ -795,11 +777,7 @@ class PHPFSPOT { $query_str.= "WHERE ". $additional_where_cond ." "; if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) { - $query_str.= "AND t.name IN ("; - foreach($this->cfg->show_tags as $tag) { - $query_str.= "'". $tag ."',"; - } - $query_str = substr($query_str, 0, strlen($query_str)-1) . ")"; + $query_str.= "AND t.name IN ('".implode("','",$this->cfg->show_tags). "')"; } if(isset($order_str)) @@ -1997,14 +1975,15 @@ class PHPFSPOT { */ public function get_thumb_path($width, $photo) { - $sub_path = substr($this->getMD5($photo), 0, 2); + $md5 = $this->getMD5($photo); + $sub_path = substr($md5, 0, 2); return $this->cfg->thumb_path . "/" . $sub_path . "/" . $width . "_" - . $this->getMD5($photo); + . $md5; } // get_thumb_path() -- cgit v1.2.3-18-g5258