A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / modules / admin / what-stats_mods.php
index 33e9536e1207b8ebff2518d2132bd8185b5e9e19..7180f1811c43efe4e7e1118255dd1ba3a62f7e49 100644 (file)
@@ -41,7 +41,7 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
 ADD_DESCR("admin", __FILE__);
 
 // If var is empty set it to empty
-if (!REQUEST_ISSET_GET(('mod'))) REQUEST_SET_GET('mod', "");
+if (!REQUEST_ISSET_GET('mod')) REQUEST_SET_GET('mod', "");
 
 // Check if module was selected
 if ((REQUEST_GET('mod') == "index") || (REQUEST_GET('mod') == "login")) {
@@ -50,27 +50,25 @@ if ((REQUEST_GET('mod') == "index") || (REQUEST_GET('mod') == "login")) {
        switch (REQUEST_GET('mod')) {
                case "index": $mod = "guest" ; break;
                case "login": $mod = "member"; break;
-       }
+               default: // Unknown
+                       DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown mod %s detected.", REQUEST_GET('mod')));
+                       break;
+       } // END - switch
 
        // Load module's detail statistic
        $result = SQL_QUERY_ESC("SELECT action, title, counter FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `what` != '' AND `what` IS NOT NULL ORDER BY counter DESC",
                array($mod), __FILE__, __LINE__);
-       $SW = 2; $OUT = "";
-       while (list($act, $title, $clicks) = SQL_FETCHROW($result)) {
-               // Prepare array for the template
-               $content = array(
-                       'sw'     => $SW,
-                       'title'  => $title,
-                       'action' => $act,
-                       'clicks' => $clicks,
-               );
+       $OUT = ""; $SW = 2;
+       while ($content = SQL_FETCHARRAY($result)) {
+               // Add color switch
+               $content['sw'] = $SW;
 
                // Load row template
                $OUT .= LOAD_TEMPLATE("admin_mods_stats2_row", true, $content);
 
                // Switch colors
                $SW = 3 - $SW;
-       }
+       } // END - while
 
        // Free memory
        SQL_FREERESULT($result);
@@ -81,25 +79,21 @@ if ((REQUEST_GET('mod') == "index") || (REQUEST_GET('mod') == "login")) {
 } else {
        // Load module statics
        $result = SQL_QUERY("SELECT module, title, clicks FROM `{!_MYSQL_PREFIX!}_mod_reg` ORDER BY clicks DESC, module", __FILE__, __LINE__);
-       $SW = 2; $OUT = "";
-       while (list($mod, $title, $clicks) = SQL_FETCHROW($result)) {
-               if (empty($title)) $title = "---";
-               if (($mod == "index") || ($mod == "login"))
-               {
+       $OUT = ""; $SW = 2;
+       while ($content = SQL_FETCHARRAY($result)) {
+               if (empty($content['title'])) $content['title'] = "---";
+
+               if (($content['module'] == "index") || ($content['module'] == "login")) {
                        // Add link to detail statistics
-                       $mod = "<strong><a href=\"{!URL!}/modules.php?module=admin&amp;what=stats_mods&amp;mod=".$mod."\">".$mod."</a></strong>";
-               }
-               // Prepare array for the template
-               $content = array(
-                       'sw'     => $SW,
-                       'title'  => $title,
-                       'mod'    => $mod,
-                       'clicks' => $clicks,
-               );
+                       $content['module'] = "<strong><a href=\"{!URL!}/modules.php?module=admin&amp;what=stats_mods&amp;mod=".$content['module']."\">".$content['module']."</a></strong>";
+               } // END - if
+
+               // Add color switch
+               $content['sw'] = $SW;
 
                // Load row template
                $OUT .= LOAD_TEMPLATE("admin_mods_stats_row", true, $content);
-       }
+       } // END - while
 
        // Free memory
        SQL_FREERESULT($result);