From: Roland Häder Date: Fri, 12 Sep 2008 17:33:16 +0000 (+0000) Subject: bigintval() now casts to double X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=f4ef7580792a9e424e5456369f40c75a29dbfead bigintval() now casts to double --- diff --git a/inc/databases.php b/inc/databases.php index 98acd27177..06fb5fdcca 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -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); diff --git a/inc/functions.php b/inc/functions.php index b5071b7d41..7857554a5c 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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; } diff --git a/inc/rdf.class.php b/inc/rdf.class.php index beaf027feb..36cda4dd0e 100644 --- a/inc/rdf.class.php +++ b/inc/rdf.class.php @@ -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 - ."

Exception at Line: ".__LINE__ ); + $this->_throw_exception("Unable to unlink ".$dir->path.$file."
\n
\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