-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 >= ".START_YDAY." AND last_online < ".START_TDAY." AND status='CONFIRMED'", __FILE__, __LINE__));
- $tmem = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!MYSQL_PREFIX!}_user_data` WHERE last_online >= ".START_TDAY." AND status='CONFIRMED'", __FILE__, __LINE__));
-
- // Yesterday / today registered
- $yreg = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!MYSQL_PREFIX!}_user_data` WHERE joined >= ".START_YDAY." AND joined < ".START_TDAY, __FILE__, __LINE__));
- $treg = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!MYSQL_PREFIX!}_user_data` WHERE joined >= ".START_TDAY, __FILE__, __LINE__));
-
- // Only males / females
- $male = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!MYSQL_PREFIX!}_user_data` WHERE gender='M' AND status='CONFIRMED'", __FILE__, __LINE__));
- $female = SQL_NUMROWS(SQL_QUERY("SELECT userid FROM `{!MYSQL_PREFIX!}_user_data` WHERE gender='F' AND status='CONFIRMED'", __FILE__, __LINE__));
-
- // 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++)
- {
- $month = $idx; if ($idx < 10) $month = "0".$idx;
- $months[$month] = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM `{!MYSQL_PREFIX!}_user_data` WHERE birth_month=%s AND status='CONFIRMED'",
- array(bigintval($month)), __FILE__, __LINE__));
- }
-
- // 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();
- while (list($id, $cat) = SQL_FETCHROW($result)) {
- // Simple...
- $cats[$id] = $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] = SQL_NUMROWS(SQL_QUERY_ESC("SELECT id FROM `{!MYSQL_PREFIX!}_user_cats` WHERE cat_id=%s",
- array(bigintval($id)), __FILE__, __LINE__));
- }
-
- // Prepare data for the template
- 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' => $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);
-
- // Generate category stats
- $SW = 2; $OUT = "";
- foreach ($cat_cnt as $id => $cnt)
- {
+// Set link title
+$ltitle = getMessage('GUEST_STATS_' . strtoupper($lmode));
+
+// @TODO This can be rewritten in a dynamic include
+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` >= ".getConfig('START_YDAY')." AND `last_online` < ".getConfig('START_TDAY')." AND `status`='CONFIRMED'", __FILE__, __LINE__));
+ $tmem = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= ".getConfig('START_TDAY')." AND `status`='CONFIRMED'", __FILE__, __LINE__));
+
+ // Yesterday / today registered
+ $yreg = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= ".getConfig('START_YDAY')." AND `joined` < ".getConfig('START_TDAY'), __FILE__, __LINE__));
+ $treg = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= ".getConfig('START_TDAY'), __FILE__, __LINE__));
+
+ // 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'");
+
+ // 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] = 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
+