[TEP-COMMIT] CVS: catalog/catalog/includes/functions general.php,1.233,1.234

Harald Ponce de Leon <[email protected]>
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
Update of /cvsroot/tep/catalog/catalog/includes/functions
In directory sc8-pr-cvs1:/tmp/cvs-serv20883/includes/functions

Modified Files:
	general.php 
Log Message:
make sure the product ID string only contains integers for product ID and
attribute ID values


Index: general.php
===================================================================
RCS file: /cvsroot/tep/catalog/catalog/includes/functions/general.php,v
retrieving revision 1.233
retrieving revision 1.234
diff -u -d -r1.233 -r1.234
--- general.php	18 Dec 2003 23:52:14 -0000	1.233
+++ general.php	28 Dec 2003 22:29:55 -0000	1.234
@@ -873,10 +873,27 @@
 ////
 // Return a product ID with attributes
   function tep_get_uprid($prid, $params) {
-    $uprid = $prid;
-    if ( (is_array($params)) && (!strstr($prid, '{')) ) {
-      while (list($option, $value) = each($params)) {
-        $uprid = $uprid . '{' . $option . '}' . $value;
+    if (is_numeric($prid)) {
+      $uprid = $prid;
+
+      if (is_array($params)) {
+        reset($params);
+        while (list($option, $value) = each($params)) {
+          $uprid .= '{' . (int)$option . '}' . (int)$value;
+        }
+      }
+    } else {
+      $uprid = tep_get_prid($prid);
+
+      if (strpos($prid, '{') !== false) {
+// strpos()+1 to remove up to and including the first { which would create an empty array element in explode()
+        $attributes = explode('{', substr($prid, strpos($prid, '{')+1));
+
+        for ($i=0, $n=sizeof($attributes); $i<$n; $i++) {
+          $pair = explode('}', $attributes[$i]);
+
+          $uprid .= '{' . (int)$pair[0] . '}' . (int)$pair[1];
+        }
       }
     }
 
@@ -888,7 +905,7 @@
   function tep_get_prid($uprid) {
     $pieces = explode('{', $uprid);
 
-    return $pieces[0];
+    return (int)$pieces[0];
   }
 
 ////



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.