// Non-admin shall not see all menus
if (!IS_ADMIN()) {
- $AND = "AND visible='Y' AND locked='N'";
+ $AND = " AND visible='Y' AND locked='N'";
}
// Load SQL data and add the menu to the output stream...
- $result_main = SQL_QUERY_ESC("SELECT title, action FROM "._MYSQL_PREFIX."_%s_menu WHERE (what='' OR what IS NULL) ".$AND." ORDER BY sort",
+ $result_main = SQL_QUERY_ESC("SELECT title, action FROM "._MYSQL_PREFIX."_%s_menu WHERE (what='' OR what IS NULL)".$AND." ORDER BY sort",
array($MODE), __FILE__, __LINE__);
//* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
if (SQL_NUMROWS($result_main) > 0) {
}
// Calculate sum (default) or count records of given criteria
-function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false, $add="") {
+function GET_TOTAL_DATA ($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false, $add="") {
$ret = 0;
- if ($onlyRows) {
+ //* DEBUG: */ echo $search."/".$tableName."/".$lookFor."/".$whereStatement."/".$add."<br />\n";
+ if (($onlyRows) || ($lookFor == "userid")) {
// Count rows
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'%s",
- array($lookFor, $tableName, $whereStatement, $search, $add), __FILE__, __LINE__);
+ //* DEBUG: */ echo "COUNT!<br />\n";
+ $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'".$add,
+ array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__);
} else {
// Add all rows
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'%s",
- array($lookFor, $tableName, $whereStatement, $search, $add), __FILE__, __LINE__);
+ //* DEBUG: */ echo "SUM!<br />\n";
+ $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'".$add,
+ array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__);
}
// Load row
// Fix empty values
if ((empty($ret)) && ($lookFor != "counter") && ($lookFor != "id") && ($lookFor != "userid")) {
+ // Float number
$ret = "0.00000";
- } // END - if
+ } elseif ("".$ret."" == "") {
+ // Fix empty result
+ $ret = "0";
+ }
// Return value
return $ret;
}
// Run database update
- //DEBUG_LOG(__FUNCTION__.":entries={$entries}");
+ //DEBUG_LOG(__FUNCTION__, __LINE__, "entries={$entries}");
SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET ".$entries." WHERE config=0 LIMIT 1", __FILE__, __LINE__);
// Get affected rows
array(bigintval($uid), $type, $data), __FILE__, __LINE__);
} elseif (is_array($data)) {
// Invalid data!
- DEBUG_LOG(__FUNCTION__."(".__LINE__."): uid={$uid},type={$type},data={".gettype($data).": Invalid statistics data type!");
+ DEBUG_LOG(__FUNCTION__, __LINE__, " uid={$uid},type={$type},data={".gettype($data).": Invalid statistics data type!");
}
}