* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team *
* For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
return;
} // END - if
-// Determine which stats we want and set mode and title for the link below stats block
-if (!isGetRequestElementSet('do')) {
- setGetRequestElement('do', strtolower(getConfig('guest_stats')));
-} // END - if
+// Default mode is from config
+$do = getConfig('guest_stats');
-// Set config temporarily
-setConfigEntry('guest_stats', strtoupper(getRequestElement('do')));
+// Determine which stats are wanted and set mode and title for the link below stats block
+if (isGetRequestElementSet('do')) {
+ // Use it from get value
+ $do = strtoupper(getRequestElement('do'));
+} // END - if
-switch (getRequestElement('do')) {
- case 'members' :
- $lmode = 'modules';
+switch ($do) {
+ case 'MEMBERS' :
+ $lmode = 'MODULES';
break;
- case 'modules' :
- $lmode = 'members';
+ case 'MODULES' :
+ $lmode = 'MEMBERS';
break;
- case 'inactive':
- $lmode = 'inactive';
+ case 'INACTIVE':
+ $lmode = 'INACTIVE';
break;
default:
// Unsupported mode
- reportBug(__FILE__, __LINE__, sprintf("Unsupported mode <span class=\"data\">%s</span> detected.", secureString(getRequestElement('do'))));
+ reportBug(__FILE__, __LINE__, sprintf("Unsupported mode <span class=\"data\">%s</span> detected.", sqlEscapeString($do)));
break;
-}
+} // END - switch
// Set link title
-$ltitle = '{--GUEST_STATS_' . strtoupper($lmode) . '--}';
+$ltitle = '{--GUEST_STATS_' . $lmode . '--}';
// @TODO This can be rewritten in a dynamic include
-switch (getConfig('guest_stats')) {
+switch (strtoupper($do)) {
case 'MEMBERS': // Statistics about your members
// Only males / females
$male = countSumTotalData('M', 'user_data', 'userid', 'gender', TRUE, runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"));
} // END - for
// Members in categories
- $result = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `visible`='Y' ORDER BY `id` ASC", __FILE__, __LINE__);
+ $result = sqlQuery("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `visible`='Y' ORDER BY `id` ASC", __FILE__, __LINE__);
// Load categories first
$cats = array(); $cat_cnt = array();
// @TODO This can be somehow rewritten
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Simple...
$cats[$content['id']] = $content['cat'];
} // END - while
- // Now we have all categories loaded, count members
+ // Now all categories have been loaded, count members
foreach ($cats as $id => $dummy) {
- // We only need id and nothing more to count...
+ // Only the id needs to be counted
+ // @TODO This doesn't exclude tester accounts
$cat_cnt[$id] = countSumTotalData(bigintval($id), 'user_cats', 'id', 'cat_id', TRUE);
} // END - foreach
// Prepare data for the template
$content['total_users'] = ($male + $female);
- $content['unconfirmed'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status` != 'CONFIRMED'", __FILE__, __LINE__));
+ $content['unconfirmed'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status` != 'CONFIRMED'" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
$content['total_males'] = $male;
$content['total_females'] = $female;
- $content['tmem_count'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= {?START_TDAY?}" . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"), __FILE__, __LINE__));
- $content['ymem_count'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= {?START_YDAY?} AND `last_online` < {?START_TDAY?}" . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"), __FILE__, __LINE__));
- $content['treg_count'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= {?START_TDAY?}", __FILE__, __LINE__));
- $content['yreg_count'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= {?START_YDAY?} AND `joined` < {?START_TDAY?}", __FILE__, __LINE__));
+ $content['tmem_count'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= {?START_TDAY?}" . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"), __FILE__, __LINE__));
+ $content['ymem_count'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= {?START_YDAY?} AND `last_online` < {?START_TDAY?}" . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"), __FILE__, __LINE__));
+ $content['treg_count'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= {?START_TDAY?}" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
+ $content['yreg_count'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= {?START_YDAY?} AND `joined` < {?START_TDAY?}" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
$content['lmode'] = $lmode;
$content['ltitle'] = $ltitle;
if (isAdmin()) $AND = '';
// Query for guest and member menus
- $guest_t10 = SQL_QUERY('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__);
- $mem_t10 = SQL_QUERY('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__);
- $OUT = '';
+ $guest_t10 = sqlQuery('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__);
+ $mem_t10 = sqlQuery('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__);
+ $OUT = '';
- if (!SQL_HASZERONUMS($guest_t10)) {
+ if (!ifSqlHasZeroNums($guest_t10)) {
// Guest clicks
$OUT .= loadTemplate('guest_stats_header', TRUE, '{--GUEST_TOP_GUEST_STATS--}');
- while ($content = SQL_FETCHARRAY($guest_t10)) {
+ while ($content = sqlFetchArray($guest_t10)) {
// Load row template
$OUT .= loadTemplate('guest_stats_row', TRUE, $content);
} // END - while
} // END - if
- if (!SQL_HASZERONUMS($mem_t10)) {
+ if (!ifSqlHasZeroNums($mem_t10)) {
// Member clicks
$OUT .= loadTemplate('guest_stats_header', TRUE, '{--GUEST_TOP_MEMBER_STATS--}');
- while ($content = SQL_FETCHARRAY($mem_t10)) {
+ while ($content = sqlFetchArray($mem_t10)) {
// Load row template
$OUT .= loadTemplate('guest_stats_row', TRUE, $content);
} // END - while
} // END - if
- if ((!SQL_HASZERONUMS($guest_t10)) || (!SQL_HASZERONUMS($mem_t10))) {
+ // Is something generated?
+ if (!empty($OUT)) {
// Prepare content
$content = array(
'rows' => $OUT,