X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fguest%2Fwhat-stats.php;h=5e5512d1583a9cc777cd5eaf52b8143230514eff;hp=2c217a39169a1d16d4e89a9c4bfb607d8f6a42a8;hb=57227d33e870ec5cd271209c4a978a52b45c2dd6;hpb=81bfbcd72e424060ea1223b49ad92fcfa150f361 diff --git a/inc/modules/guest/what-stats.php b/inc/modules/guest/what-stats.php index 2c217a3916..5e5512d158 100644 --- a/inc/modules/guest/what-stats.php +++ b/inc/modules/guest/what-stats.php @@ -1,7 +1,7 @@ %s detected.", secureString(getRequestParameter('mode')))); break; } -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 = 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 .= "\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 .= "\n"; - $r2 = ' right2'; - $l = 'll'; $r = 'lr'; - } - $SW = 3 - $SW; - } - define('__MONTH_STATS_ROWS', $OUT); +// 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 - // Generate category stats - $OUT = ''; $SW = 2; - foreach ($cat_cnt as $id => $cnt) { // Prepare data for the template - $content = array( - 'sw' => $SW, - 'cat' => $cats[$id], - 'cnt' => $cnt, - ); - - // Load row template and switch colors - $OUT .= LOAD_TEMPLATE('guest_stats_cats_row', true, $content); - $SW = 3 - $SW; - } - define('__CATS_STATS_ROWS', $OUT); - - // Load final template - LOAD_TEMPLATE('guest_stats_member'); - break; - -case 'MODULES': // TOP10 module clicks - $AND = ''; - if (!IS_ADMIN()) $AND = " AND `locked`='N' AND `visible`='Y'"; - $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 = ''; - if ((SQL_NUMROWS($guest_t10) > 0) || (SQL_NUMROWS($mem_t10) > 0)) { - // Output header - // @TODO Rewrite this to one template and $OUT .= .... - OUTPUT_HTML(" - - -"); - } - - if (SQL_NUMROWS($guest_t10) > 0) { - // Guest clicks - OUTPUT_HTML(" - -"); - $SW = 2; - while ($content = SQL_FETCHARRAY($guest_t10)) { - OUTPUT_HTML(" - - -"); + $content['total_users'] = $total; + $content['unconfirmed'] = $unconfirmed; + $content['total_males'] = $male; + $content['total_females'] = $female; + $content['tmem_count'] = $tmem; + $content['ymem_count'] = $ymem; + $content['treg_count'] = $treg; + $content['yreg_count'] = $yreg; + $content['lmode'] = $lmode; + $content['ltitle'] = $ltitle; + + // Generate monthly stats + $SW = 2; $r2 = ' right'; $l = 'll'; $r = 'lr'; $OUT = ''; + foreach ($months as $month => $cnt) { + if ($SW == 2) $OUT .= "\n"; + + // Prepare data for template + $data = array( + 'l_class' => $l, + 'm_descr' => $GLOBALS['month_descr'][$month], + 'r_class' => $r, + 'r2_class' => $r2, + 'cnt' => $cnt + ); + + // Load row template + $OUT .= loadTemplate('guest_stats_month_row', true, $data); + + if ($SW == 2) { + $r2 = ''; + $l = 'rl'; $r = 'rr'; + } else { + $OUT .= "\n"; + $r2 = ' right'; + $l = 'll'; $r = 'lr'; + } $SW = 3 - $SW; } - } - - if (SQL_NUMROWS($guest_t10) > 0) { - // Guest clicks - OUTPUT_HTML(" - -"); - $SW = 2; - while ($content = SQL_FETCHARRAY($mem_t10)) { - OUTPUT_HTML(" - - -"); + $content['month_rows'] = $OUT; + + // Generate category stats + $OUT = ''; $SW = 2; + foreach ($cat_cnt as $id => $cnt) { + // Prepare data for the template + $data = array( + 'sw' => $SW, + 'cat' => $cats[$id], + 'cnt' => $cnt, + ); + + // Load row template and switch colors + $OUT .= loadTemplate('guest_stats_cats_row', true, $data); $SW = 3 - $SW; } - } - - if ((SQL_NUMROWS($guest_t10) > 0) || (SQL_NUMROWS($mem_t10) > 0)) { - // Output footer - OUTPUT_HTML(" - - -
{--GUEST_TOPTEN_STATS--}
{--GUEST_TOP_GUEST_STATS--}
".$content['title']."  ".$content['counter']."
{--GUEST_TOP_MEMBER_STATS--}
".$content['title']."  ".$content['counter']."
- ".$ltitle." -
"); - } - break; - -case 'INACTIVE': // Deactivated stats - LOAD_TEMPLATE('admin_settings_saved', false, "{--GUEST_STATS_DEACTIVATED--}"); - break; + $content['cats_rows'] = $OUT; + + // Load final template + loadTemplate('guest_stats_member', false, $content); + break; + + case 'MODULES': // TOP10 module clicks + // Admins may see all menus + $AND = " AND `locked`='N' AND `visible`='Y'"; + 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 = ''; + + if (SQL_NUMROWS($guest_t10) > 0) { + // Guest clicks + $OUT .= loadTemplate('guest_stats_header', true, getMessage('GUEST_TOP_GUEST_STATS')); + $SW = 2; + while ($content = SQL_FETCHARRAY($guest_t10)) { + $content['sw'] = $SW; + + // Load row template + $OUT .= loadTemplate('guest_stats_row', true, $content); + $SW = 3 - $SW; + } // END - while + } // END - if + + if (SQL_NUMROWS($mem_t10) > 0) { + // Member clicks + $OUT .= loadTemplate('guest_stats_header', true, getMessage('GUEST_TOP_MEMBER_STATS')); + $SW = 2; + while ($content = SQL_FETCHARRAY($mem_t10)) { + $content['sw'] = $SW; + + // Load row template + $OUT .= loadTemplate('guest_stats_row', true, $content); + $SW = 3 - $SW; + } // END - while + } // END - if + + if ((SQL_NUMROWS($guest_t10) > 0) || (SQL_NUMROWS($mem_t10) > 0)) { + // Prepare content + $content = array( + 'rows' => $OUT, + 'lmode' => $lmode, + 'ltitle' => $ltitle + ); + + // Load final template + loadTemplate('guest_stats_table', false, $content); + } else { + // No clicks detected + loadTemplate('admin_settings_saved', false, getMessage('GUEST_STATS_NO_CLICKS')); + } + break; + + case 'INACTIVE': // Deactivated stats + loadTemplate('admin_settings_saved', false, getMessage('GUEST_STATS_DEACTIVATED')); + break; } -// +// [EOF] ?>