[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tep-commits
Subject:    [TEP-COMMIT] CVS: catalog/catalog/includes/functions general.php,1.233,1.234
From:       Harald Ponce de Leon <hpdl () users ! sourceforge ! net>
Date:       2003-12-28 22:29:57
[Download RAW message or body]

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
_______________________________________________
Tep-commits mailing list
Tep-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tep-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic