// 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])) {
debug_report_bug(__FUNCTION__, __LINE__, 'values[' . $idx . '] should not be an array! Content=<pre>'.print_r($values[$idx], true).'</pre>');
} 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]);
$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);
$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
$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
} // END - if
// Set cookie
- setSession('refid', $GLOBALS['refid']);
+ setSession('refid', bigintval($GLOBALS['refid']));
} // END - if
// Return determined refid
// 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
), __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,
// @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')) {
} // 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);