X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fguest%2Fwhat-stats.php;h=81acf6ecdff4d084e6590da34d7efe93eab435bb;hp=c66524f7ca36ae9afe2400fd1d54077a8f31655c;hb=596c8ab32594401ca84abfbfe35513ddfff31bec;hpb=09f5758c42a33a56bdd461c946ffe759a59c54aa diff --git a/inc/modules/guest/what-stats.php b/inc/modules/guest/what-stats.php index c66524f7ca..81acf6ecdf 100644 --- a/inc/modules/guest/what-stats.php +++ b/inc/modules/guest/what-stats.php @@ -14,12 +14,10 @@ * $Date:: $ * * $Tag:: 0.2.1-FINAL $ * * $Author:: $ * - * Needs to be in all Files and every File needs "svn propset * - * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -39,19 +37,27 @@ // Some security stuff... if (!defined('__SECURITY')) { - die(); + exit(); } // END - if // Add description as navigation point -addMenuDescription('guest', __FILE__); +addYouAreHereLink('guest', __FILE__); -// Derterminate which stats we want and set mode and title for the link below stats block -if (!isGetRequestParameterSet('mode')) setGetRequestParameter('mode', strtolower(getConfig('guest_stats'))); +// This part only works if ext-user is active +if ((!isExtensionActive('user')) && (!isAdmin())) { + displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}'); + 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 // Set config temporarily -setConfigEntry('guest_stats', strtoupper(getRequestParameter('mode'))); +setConfigEntry('guest_stats', strtoupper(getRequestElement('do'))); -switch (getRequestParameter('mode')) { +switch (getRequestElement('do')) { case 'members' : $lmode = 'modules'; break; @@ -66,33 +72,19 @@ switch (getRequestParameter('mode')) { default: // Unsupported mode - debug_report_bug(sprintf("Unsupported mode %s detected.", secureString(getRequestParameter('mode')))); + reportBug(__FILE__, __LINE__, sprintf("Unsupported mode %s detected.", secureString(getRequestElement('do')))); break; } // Set link title -$ltitle = getMessage('GUEST_STATS_' . strtoupper($lmode)); +$ltitle = '{--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; + $male = countSumTotalData('M', 'user_data', 'userid', 'gender', TRUE, runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'")); + $female = countSumTotalData('F', 'user_data', 'userid', 'gender', TRUE, runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'")); // List every month $months = array(); @@ -101,10 +93,12 @@ switch (getConfig('guest_stats')) { $month = $idx; // Append leading zero - if ($idx < 10) $month = '0' . $idx; + if ($idx < 10) { + $month = '0' . $idx; + } // END - if // Count months - $months[$month] = countSumTotalData(bigintval($month), 'user_data', 'userid', 'birth_month', true, " AND `status`='CONFIRMED'"); + $months[$month] = countSumTotalData(bigintval($month), 'user_data', 'userid', 'birth_month', TRUE, runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'")); } // END - for // Members in categories @@ -122,68 +116,66 @@ switch (getConfig('guest_stats')) { // 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); + $cat_cnt[$id] = countSumTotalData(bigintval($id), 'user_cats', 'id', 'cat_id', TRUE); } // END - foreach // Prepare data for the template - $content['total_users'] = $total; - $content['unconfirmed'] = $unconfirmed; + $content['total_users'] = ($male + $female); + $content['unconfirmed'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status` != 'CONFIRMED'", __FILE__, __LINE__)); $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['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['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"; + foreach ($months as $month => $count) { + if ($SW == 2) $OUT .= ''; // Prepare data for template - $data = array( + $row = array( 'l_class' => $l, 'm_descr' => $GLOBALS['month_descr'][$month], 'r_class' => $r, 'r2_class' => $r2, - 'cnt' => $cnt + 'count' => $count ); // Load row template - $OUT .= loadTemplate('guest_stats_month_row', true, $data); + $OUT .= loadTemplate('guest_stats_month_row', TRUE, $row); if ($SW == 2) { $r2 = ''; $l = 'rl'; $r = 'rr'; } else { - $OUT .= "\n"; + $OUT .= ''; $r2 = ' right'; $l = 'll'; $r = 'lr'; } $SW = 3 - $SW; - } + } // END - foreach $content['month_rows'] = $OUT; // Generate category stats - $OUT = ''; $SW = 2; - foreach ($cat_cnt as $id => $cnt) { + $OUT = ''; + foreach ($cat_cnt as $id => $count) { // Prepare data for the template - $data = array( - 'sw' => $SW, - 'cat' => $cats[$id], - 'cnt' => $cnt, + $row = array( + 'cat' => $cats[$id], + 'count' => $count, ); // Load row template and switch colors - $OUT .= loadTemplate('guest_stats_cats_row', true, $data); - $SW = 3 - $SW; - } + $OUT .= loadTemplate('guest_stats_cats_row', TRUE, $row); + } // END - foreach $content['cats_rows'] = $OUT; // Load final template - loadTemplate('guest_stats_member', false, $content); + loadTemplate('guest_stats_member', FALSE, $content); break; case 'MODULES': // TOP10 module clicks @@ -192,37 +184,29 @@ switch (getConfig('guest_stats')) { 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__); + $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) { + if (!SQL_HASZERONUMS($guest_t10)) { // Guest clicks - $OUT .= loadTemplate('guest_stats_header', true, getMessage('GUEST_TOP_GUEST_STATS')); - $SW = 2; + $OUT .= loadTemplate('guest_stats_header', TRUE, '{--GUEST_TOP_GUEST_STATS--}'); while ($content = SQL_FETCHARRAY($guest_t10)) { - $content['sw'] = $SW; - // Load row template - $OUT .= loadTemplate('guest_stats_row', true, $content); - $SW = 3 - $SW; + $OUT .= loadTemplate('guest_stats_row', TRUE, $content); } // END - while } // END - if - if (SQL_NUMROWS($mem_t10) > 0) { + if (!SQL_HASZERONUMS($mem_t10)) { // Member clicks - $OUT .= loadTemplate('guest_stats_header', true, getMessage('GUEST_TOP_MEMBER_STATS')); - $SW = 2; + $OUT .= loadTemplate('guest_stats_header', TRUE, '{--GUEST_TOP_MEMBER_STATS--}'); while ($content = SQL_FETCHARRAY($mem_t10)) { - $content['sw'] = $SW; - // Load row template - $OUT .= loadTemplate('guest_stats_row', true, $content); - $SW = 3 - $SW; + $OUT .= loadTemplate('guest_stats_row', TRUE, $content); } // END - while } // END - if - if ((SQL_NUMROWS($guest_t10) > 0) || (SQL_NUMROWS($mem_t10) > 0)) { + if ((!SQL_HASZERONUMS($guest_t10)) || (!SQL_HASZERONUMS($mem_t10))) { // Prepare content $content = array( 'rows' => $OUT, @@ -231,17 +215,17 @@ switch (getConfig('guest_stats')) { ); // Load final template - loadTemplate('guest_stats_table', false, $content); + loadTemplate('guest_stats_table', FALSE, $content); } else { // No clicks detected - loadTemplate('admin_settings_saved', false, getMessage('GUEST_STATS_NO_CLICKS')); + displayMessage('{--GUEST_STATS_NO_CLICKS--}'); } break; case 'INACTIVE': // Deactivated stats - loadTemplate('admin_settings_saved', false, getMessage('GUEST_STATS_DEACTIVATED')); + displayMessage('{--GUEST_STATS_DEACTIVATED--}'); break; -} +} // END - switch // [EOF] ?>