-switch (getConfig('guest_stats'))
-{
-case 'MEMBERS': // Statistics about your members
- // Members yesterday / today online
- $ymem = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE last_online >= ".constant('START_YDAY')." AND `last_online` < ".constant('START_TDAY')." AND `status`='CONFIRMED'", __FILE__, __LINE__));
- $tmem = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE last_online >= ".constant('START_TDAY')." AND `status`='CONFIRMED'", __FILE__, __LINE__));
-
- // Yesterday / today registered
- $yreg = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE joined >= ".constant('START_YDAY')." AND joined < ".constant('START_TDAY'), __FILE__, __LINE__));
- $treg = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE joined >= ".constant('START_TDAY'), __FILE__, __LINE__));
-
- // Only males / females
- $male = GET_TOTAL_DATA('M', 'user_data', 'userid', 'gender', true, " AND `status`='CONFIRMED'");
- $female = GET_TOTAL_DATA('F', 'user_data', 'userid', 'gender', true, " AND `status`='CONFIRMED'");
-
- // Unconfirmed accounts
- $unconfirmed = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE status != 'CONFIRMED'", __FILE__, __LINE__));
-
- // Total members
- $total = $male + $female;
-
- // List every month
- $months = array();
- for ($idx = 1; $idx < 13; $idx++) {
- // Copy it so we don't touch the for() loop index
- $month = $idx;
-
- // Append leading zero
- if ($idx < 10) $month = '0'.$idx;
-
- // Count months
- $months[$month] = GET_TOTAL_DATA(bigintval($month), 'user_data', 'userid', 'birth_month', true, " AND `status`='CONFIRMED'");
- }
-
- // Members in categories
- $result = SQL_QUERY("SELECT id, cat FROM `{!_MYSQL_PREFIX!}_cats` WHERE `visible`='Y' ORDER BY `id`", __FILE__, __LINE__);
-
- // Load categories first
- $cats = array(); $cat_cnt = array();
- // @TODO This can be somehow rewritten
- while ($content = SQL_FETCHARRAY($result)) {
- // Simple...
- $cats[$content['id']] = $content['cat'];
- }
-
- // Now we have all categories loaded, count members
- foreach ($cats as $id => $dummy) {
- // We only need id and nothing more to count...
- $cat_cnt[$id] = GET_TOTAL_DATA(bigintval($id), 'user_cats', 'id', 'cat_id', true);
- }
-
- // Prepare data for the template
- // @TODO Rewrite all these constants
- define('__TOTAL_USERS' , $total);
- define('__UNCONFIRMED' , $unconfirmed);
- define('__MALE_COUNT' , $male);
- define('__FEMALE_COUNT', $female);
- define('__TMEM_COUNT' , $tmem);
- define('__YMEM_COUNT' , $ymem);
- define('__TREG_COUNT' , $treg);
- define('__YREG_COUNT' , $yreg);
- define('__LMODE_VALUE' , $lmode);
- define('__LINK_TITLE' , $ltitle);
-
- // Generate monthly stats
- $SW = 2; $r2 = ' right2'; $l = 'll'; $r = 'lr'; $OUT = '';
- foreach ($months as $month => $cnt) {
- if ($SW == 2) $OUT .= "<tr>\n";
-
- // Prepare data for template
- $content = array(
- 'l_class' => $l,
- 'm_descr' => $GLOBALS['month_descr'][$month],
- 'r_class' => $r,
- 'r2_class' => $r2,
- 'cnt' => $cnt
- );
-
- // Load row template
- $OUT .= LOAD_TEMPLATE("guest_stats_month_row", true, $content);
-
- if ($SW == 2) {
- $r2 = '';
- $l = 'rl'; $r = 'rr';
- } else {
- $OUT .= "</tr>\n";
- $r2 = ' right2';
- $l = 'll'; $r = 'lr';
- }
- $SW = 3 - $SW;
- }
- define('__MONTH_STATS_ROWS', $OUT);
+// Set link title
+$ltitle = '{--GUEST_STATS_' . strtoupper($lmode) . '--}';
+
+// @TODO This can be rewritten in a dynamic include
+switch (getConfig('guest_stats')) {
+ case 'MEMBERS': // Statistics about your members
+ // Only males / females
+ $male = countSumTotalData('M', 'user_data', 'userid', 'gender', true, " AND `status`='CONFIRMED'");
+ $female = countSumTotalData('F', 'user_data', 'userid', 'gender', true, " AND `status`='CONFIRMED'");
+
+ // List every month
+ $months = array();
+ for ($idx = 1; $idx < 13; $idx++) {
+ // Copy it so we don't touch the for() loop index
+ $month = $idx;
+
+ // Append leading zero
+ if ($idx < 10) $month = '0' . $idx;
+
+ // Count months
+ $months[$month] = countSumTotalData(bigintval($month), 'user_data', 'userid', 'birth_month', true, " 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__);
+
+ // Load categories first
+ $cats = array(); $cat_cnt = array();
+
+ // @TODO This can be somehow rewritten
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Simple...
+ $cats[$content['id']] = $content['cat'];
+ } // END - while
+
+ // Now we have all categories loaded, count members
+ foreach ($cats as $id => $dummy) {
+ // We only need id and nothing more to count...
+ $cat_cnt[$id] = countSumTotalData(bigintval($id), 'user_cats', 'id', 'cat_id', true);
+ } // END - foreach