bigintval() now casts to double
authorRoland Häder <roland@mxchange.org>
Fri, 12 Sep 2008 17:33:16 +0000 (17:33 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 12 Sep 2008 17:33:16 +0000 (17:33 +0000)
inc/databases.php
inc/functions.php
inc/rdf.class.php

index 98acd27177e96305c76c34c38921a7d2b63999aa..06fb5fdccad0030a93409a945ac32e6902cf8f2d 100644 (file)
@@ -114,7 +114,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "311");
+define('CURR_SVN_REVISION', "312");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index b5071b7d41e7ac2cd0aa384712fbeb09e7ab7477..7857554a5ce86d1bb13e3072cc9062fc5f410941 100644 (file)
@@ -996,7 +996,7 @@ function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) {
                        } // END - if
 
                        // Take all string elements
-                       if (("".bigintval($matches[4][$key])."" != $matches[4][$key]) && (!isset($matchesFound[$key."_".$matches[4][$key]]))) {
+                       if ((is_string($matches[4][$key])) && (!isset($matchesFound[$key."_".$matches[4][$key]]))) {
                                // Replace it in the code
                                $newMatch = str_replace("[".$matches[4][$key]."]", "['".$matches[4][$key]."']", $match);
                                $code = str_replace($match, $newMatch, $code);
@@ -1028,41 +1028,34 @@ function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) {
 function array_pk_sort(&$array, $a_sort, $primary_key = 0, $order = -1, $nums = false)
 {
        $dummy = $array;
-       while ($primary_key < count($a_sort))
-       {
-               foreach ($dummy[$a_sort[$primary_key]] as $key => $value)
-               {
-                       foreach ($dummy[$a_sort[$primary_key]] as $key2 => $value2)
-                       {
+       while ($primary_key < count($a_sort)) {
+               foreach ($dummy[$a_sort[$primary_key]] as $key => $value) {
+                       foreach ($dummy[$a_sort[$primary_key]] as $key2 => $value2) {
                                $match = false;
-                               if (!$nums)
-                               {
+                               if (!$nums) {
                                        // Sort byte-by-byte (also numbers will be interpreted as chars! E.g.: "9" > "10")
                                        if (($key != $key2) && (strcmp(strtolower($dummy[$a_sort[$primary_key]][$key]), strtolower($dummy[$a_sort[$primary_key]][$key2])) == $order)) $match = true;
-                               }
-                                elseif ($key != $key2)
-                               {
+                               } elseif ($key != $key2) {
                                        // Sort numbers (E.g.: 9 < 10)
                                        if (($dummy[$a_sort[$primary_key]][$key] < $dummy[$a_sort[$primary_key]][$key2]) && ($order == -1)) $match = true;
                                        if (($dummy[$a_sort[$primary_key]][$key] > $dummy[$a_sort[$primary_key]][$key2]) && ($order == 1))  $match = true;
                                }
-                               if ($match)
-                               {
+
+                               if ($match) {
                                        // We have found two different values, so let's sort whole array
-                                       foreach ($dummy as $sort_key => $sort_val)
-                                       {
+                                       foreach ($dummy as $sort_key => $sort_val) {
                                                $t                       = $dummy[$sort_key][$key];
                                                $dummy[$sort_key][$key]  = $dummy[$sort_key][$key2];
                                                $dummy[$sort_key][$key2] = $t;
                                                unset($t);
-                                       }
-                               }
-                       }
-               }
+                                       } // END - foreach
+                               } // END - if
+                       } // END - foreach
+               } // END - foreach
 
                // Count one up
                $primary_key++;
-       }
+       } // END - while
 
        // Write back sorted array
        $array = $dummy;
@@ -1245,6 +1238,15 @@ function bigintval($num, $castValue = true) {
        // Filter all numbers out
        $ret = preg_replace("/[^0123456789]/", "", $num);
 
+       // Shall we cast?
+       if ($castValue) $ret = (double)$ret;
+
+       // Has the whole value changed?
+       if ("".$ret."" != "".$num."") {
+               // Log the values
+               DEBUG_LOG(__FUNCTION__.": num={$num},ret={$ret}");
+       } // END - if
+
        // Return result
        return $ret;
 }
index beaf027feb99179938c2f5aec14eabba8e503833..36cda4dd0e26f5c797459455123bfc6a8856c232 100644 (file)
@@ -1162,15 +1162,13 @@ class fase4_rdf {
         $dir = dir($this->_cache_dir);
         while($file=$dir->read()) {
             // Exclude directories
-            if (is_file($dir->path.$file) && substr($file, -6, 6) != ".cache")  {
+            if (is_file($dir->path.$file) && substr($file, -6, 6) != ".cache" && substr($file, -4, 4) != ".log")  {
                 if(!@unlink($dir->path.$file)) {
-                    $this->_throw_exception(
-                    "Unable to unlink ".$dir->path.$file
-                    ."<br /><br />Exception at Line: ".__LINE__ );
+                    $this->_throw_exception("Unable to unlink ".$dir->path.$file."<br />\n<br />\nException at Line: ".__LINE__ );
                     return false;
-                }
-            }
-        }
+                } // END - if
+            } // END - if
+        } // END - while
         $dir->close();
         return true;
     }   // END clear_cache()
@@ -1186,8 +1184,8 @@ class fase4_rdf {
     function _cut_string( $string, $str_len = "30" )
     {
         if(strlen(trim($string))>$str_len) {
-        $string = substr( trim($string) , 0, $str_len - 4);
-        $string .= " ...";
+            $string = substr( trim($string) , 0, $str_len - 4);
+            $string .= " ...";
         }
         return $string;
     }   // END _cut_string()
@@ -1205,9 +1203,9 @@ class fase4_rdf {
         if (rand(1, 100) <= $this->gc_probability) {
             $dir = dir($this->_cache_dir);
             while($file=$dir->read()) {
-                if (is_file($dir->path.$file) && substr($file, -6, 6) != ".cache" && filemtime($dir->path.$file) <= time() - $this->_refresh )  {
-                       @unlink($dir->path.$file);
-                }
+                if (is_file($dir->path.$file) && substr($file, -6, 6) != ".cache" && substr($file, -4, 4) != ".log" && filemtime($dir->path.$file) <= time() - $this->_refresh )  {
+                    @unlink($dir->path.$file);
+                } // END - if
         }
         $dir->close();
         }   // END if