From: Roland Häder Date: Sat, 25 Sep 2010 03:44:28 +0000 (+0000) Subject: Improvements for refid=NULL behaviour X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=74ca3a5c7b7546d96758217608ead67975d42dc3;p=mailer.git Improvements for refid=NULL behaviour --- diff --git a/inc/config-functions.php b/inc/config-functions.php index 7c0eb3ff62..a7f4ac9794 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -288,7 +288,7 @@ function updateConfiguration ($entries, $values, $updateMode='', $config = '0') // Update mode set? if (!empty($updateMode)) { // Update entry - $all .= sprintf("`%s`=`%s`%s%s,", $entry, $entry, $updateMode, (float)$values[$idx]); + $all .= sprintf("`%s`=`%s`%s%s,", $entry, $entry, $updateMode, (float) $values[$idx]); } else { // Check if string or number but no array if (is_array($values[$idx])) { @@ -296,7 +296,7 @@ function updateConfiguration ($entries, $values, $updateMode='', $config = '0') debug_report_bug(__FUNCTION__, __LINE__, 'values[' . $idx . '] should not be an array! Content=
'.print_r($values[$idx], true).'
'); } elseif (($values[$idx] + 0) === $values[$idx]) { // Number detected - $all .= sprintf("`%s`=%s,", $entry, (float)$values[$idx]); + $all .= sprintf("`%s`=%s,", $entry, (float) $values[$idx]); // Set it in config as well setConfigEntry($entry, $values[$idx]); @@ -320,13 +320,13 @@ function updateConfiguration ($entries, $values, $updateMode='', $config = '0') $entries = substr($all, 0, -1); } elseif (!empty($updateMode)) { // Update mode set - $entries = sprintf("`%s`=`%s`%s%s", $entries, $entries, $updateMode, (float)$values); + $entries = sprintf("`%s`=`%s`%s%s", $entries, $entries, $updateMode, (float) $values); } elseif (($values + 0) === $values) { // Number detected - $entries = sprintf("`%s`=%s", $entries, (float)$values); + $entries = sprintf("`%s`=%s", $entries, (float) $values); // Set it in config first - setConfigEntry($entries, (float)$values); + setConfigEntry($entries, (float) $values); } elseif ($values == 'UNIX_TIMESTAMP()') { // Function UNIX_TIMESTAMP() detected $entries = sprintf("`%s`=UNIX_TIMESTAMP()", $entries); diff --git a/inc/functions.php b/inc/functions.php index 5f3727065a..29151e81e0 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -713,10 +713,13 @@ function bigintval ($num, $castValue = true, $abortOnMismatch = true) { $ret = preg_replace('/[^0123456789]/', '', $num); // Shall we cast? - if ($castValue === true) $ret = (double)$ret; + if ($castValue === true) { + // Cast to biggest numeric type + $ret = (double) $ret; + } // END - if // Has the whole value changed? - if (('' . $ret . '' != '' . $num . '') && ($abortOnMismatch === true)) { + if (('' . $ret . '' != '' . $num . '') && ($abortOnMismatch === true) && (!is_null($num))) { // Log the values debug_report_bug(__FUNCTION__, __LINE__, 'Problem with number found. ret=' . $ret . ', num='. $num); } // END - if @@ -1946,7 +1949,7 @@ function determineReferalId () { $GLOBALS['refid'] = getConfig('def_refid'); } else { // No default id when sql_patches is not installed or none set - $GLOBALS['refid'] = '0'; + $GLOBALS['refid'] = null; } // Set cookie when default refid > 0 @@ -1970,7 +1973,7 @@ function determineReferalId () { } // END - if // Set cookie - setSession('refid', $GLOBALS['refid']); + setSession('refid', bigintval($GLOBALS['refid'])); } // END - if // Return determined refid @@ -2442,7 +2445,7 @@ if (!function_exists('http_build_query')) { // Taken from documentation on www.php.net, credits to Marco K. (Germany) and some light mods by R.Haeder function http_build_query($data, $prefix = '', $sep = '', $key = '') { $ret = array(); - foreach ((array)$data as $k => $v) { + foreach ((array) $data as $k => $v) { if (is_int($k) && $prefix != null) { $k = urlencode($prefix . $k); } // END - if diff --git a/inc/libs/online_functions.php b/inc/libs/online_functions.php index a989e1f2a2..85c04334cd 100644 --- a/inc/libs/online_functions.php +++ b/inc/libs/online_functions.php @@ -104,7 +104,7 @@ LIMIT 1", ), __FUNCTION__, __LINE__); } else { // No entry does exists so we simply add it! - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_online` (`module`, `action`, `what`, `userid`, `refid`, `is_member`, `is_admin`, `timestamp`, `sid`, `ip`) VALUES ('%s','%s','%s', %s, '%s', '%s','%s', UNIX_TIMESTAMP(), '%s','%s')", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_online` (`module`, `action`, `what`, `userid`, `refid`, `is_member`, `is_admin`, `timestamp`, `sid`, `ip`) VALUES ('%s','%s','%s', %s, %s, '%s','%s', UNIX_TIMESTAMP(), '%s','%s')", array( getModule(), $action, diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 38b1ae248e..fc9e433269 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -232,7 +232,7 @@ LIMIT 1", // @TODO Double-check configuration entry here function determineRandomReferalId () { // Default is zero refid - $refid = '0'; + $refid = null; // Is the extension version fine? if (isExtensionInstalledAndNewer('user', '0.3.4')) { diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 543b67f17c..cf76c3b12c 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -502,7 +502,7 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement } // END - if // Shall we add numbers or strings? - $test = (float)$val; + $test = (float) $val; if ('' . $val . '' == '' . $test . '') { // Add numbers $tableData[] = sprintf("`%s`=%s", $id, $test);