Possible fix for #125, applied fixes from profi-concept's branch
authorRoland Häder <roland@mxchange.org>
Tue, 28 Jul 2009 17:06:17 +0000 (17:06 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 28 Jul 2009 17:06:17 +0000 (17:06 +0000)
inc/handler.php
inc/libs/admins_functions.php
inc/modules/admin/what-adminedit.php
inc/modules/admin/what-guestedit.php
inc/modules/admin/what-list_transfer.php
inc/modules/admin/what-memedit.php
inc/modules/admin/what-refbanner.php
inc/mysql-connect.php
inc/mysql-manager.php
templates/de/html/admin/admin_next_link.tpl
templates/de/html/show_timings.tpl

index 7dd8449..344b88a 100644 (file)
@@ -45,25 +45,35 @@ if (!defined('__SECURITY')) {
 // Error handler function
 function __errorHandler ($errno, $errstr, $errfile, $errline) {
        // Construct message
-       $msg = sprintf("errno=%s,errstr=%s,errfile=%s,errline=%s",
-       $errno,
-       $errstr,
-       basename($errfile),
-       $errline
+       $message = sprintf("errno=%s,errstr=%s,errfile=%s,errline=%s",
+               $errno,
+               $errstr,
+               basename($errfile),
+               $errline
        );
 
        // Write debug log message
-       DEBUG_LOG(__FUNCTION__, __LINE__, "".$msg, true);
+       DEBUG_LOG($errfile, $errline, $message, true);
 
        // Output message to user and die
        if (EXT_IS_ACTIVE('debug')) {
                // Debug extension found! So Output a small message
-               app_die(__FUNCTION__, __LINE__, "Error message written to debug.log. Please try to call <a href=\"{!URL!}\">the main page</a> to continue.");
-       } else {
+               app_die($errfile, $errline, "Error message written to debug.log. Please try to call <a href=\"{!URL!}\">the main page</a> to continue.");
+       } elseif ($GLOBALS['error_handler']['exit_on_error'] === true) {
                // No debug extension found, so regular output
-               debug_report_bug($msg);
+               debug_report_bug($message);
        }
 }
 
+// Init error handler
+function initErrorHandler () {
+       enableExitOnError(false);
+}
+
+// Enable exit on error
+function enableExitOnError ($enable=true) {
+       $GLOBALS['error_handler']['exit_on_error'] = $enable;
+}
+
 // [EOF]
 ?>
index 5663a35..bc63f76 100644 (file)
@@ -272,7 +272,7 @@ function adminsEditAdminAccount ($POST) {
                                $content['mode']    = generateOptionList('/ARRAY/', array("allow", "deny"), array(constant('ADMINS_ALLOW_MODE'), constant('ADMINS_DENY_MODE')), $content['mode']);
                        } else {
                                // Don't allow it
-                               $content['mode'] = "&nbsp;";
+                               $content['mode'] = '&nbsp;';
                        }
                        $content['la_mode'] = generateOptionList('/ARRAY/', array("global", "OLD", "NEW"), array(ADMINS_GLOBAL_LA_SETTING, ADMINS_OLD_LA_SETTING, ADMINS_NEW_LA_SETTING), $content['la_mode']);
 
index 6db7d69..6949d19 100644 (file)
@@ -260,16 +260,16 @@ WHERE ".$AND." AND id=%s LIMIT 1",
                        }
 
                        // Fix empty elements for constant (fixes display bugs in Firefox)
-                       if (empty($content['action'])) $content['action'] = "&nbsp;";
-                       if (empty($content['what']))   $content['what']   = "&nbsp;";
-                       if (empty($content['title']))  $content['title']  = "&nbsp;";
+                       if (empty($content['action'])) $content['action'] = '&nbsp;';
+                       if (empty($content['what']))   $content['what']   = '&nbsp;';
+                       if (empty($content['title']))  $content['title']  = '&nbsp;';
 
                        // Add more data to $content
                        $content['sw']   = $SW;
                        $content['mode'] = 'admin';
 
                        // Load row template and switch colors
-                       $OUT .= LOAD_TEMPLATE("admin_menu_overview_row", true, $content);
+                       $OUT .= LOAD_TEMPLATE('admin_menu_overview_row', true, $content);
                        $SW = 3 - $SW;
                } // END - switch
 
@@ -280,7 +280,7 @@ WHERE ".$AND." AND id=%s LIMIT 1",
                define('__MENU_ROWS', $OUT);
 
                // Load template
-               LOAD_TEMPLATE("admin_amenu_edit");
+               LOAD_TEMPLATE('admin_amenu_edit');
        } else {
                // Menu entries are missing... (???)
                LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_MENUS_FOUND'));
index 96ec6ce..8552a23 100644 (file)
@@ -209,12 +209,12 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
                                        'menu'    => $menu,
                                        'sel'     => $sel,
                                        'sw'      => $SW,
-                                       'visible' => ADD_SELECTION('yn', $vis   , "visible", $sel),
-                                       'locked'  => ADD_SELECTION('yn', $locked, "locked" , $sel),
+                                       'visible' => ADD_SELECTION('yn', $vis   , 'visible', $sel),
+                                       'locked'  => ADD_SELECTION('yn', $locked, 'locked' , $sel),
                                );
 
                                // Load template
-                               $OUT .= LOAD_TEMPLATE("admin_menu_status_row", true, $content);
+                               $OUT .= LOAD_TEMPLATE('admin_menu_status_row', true, $content);
                        }
                        else
                        {
@@ -223,7 +223,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
                                        'sw'  => $SW,
                                        'sel' => $sel
                                );
-                               $OUT .= LOAD_TEMPLATE("admin_menu_404_row", true, $content);
+                               $OUT .= LOAD_TEMPLATE('admin_menu_404_row', true, $content);
                        }
                        $SW = 3 - $SW;
                }
@@ -232,7 +232,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
        define('__MENU_ROWS', $OUT);
 
        // Load template
-       LOAD_TEMPLATE("admin_gmenu_status");
+       LOAD_TEMPLATE('admin_gmenu_status');
 } else {
        if ((REQUEST_ISSET_GET(('act'))) && (REQUEST_ISSET_GET(('tid'))) && (REQUEST_ISSET_GET(('fid')))) {
                // Get IDs
@@ -303,9 +303,9 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
                                $NAVI = "<a href=\"{!URL!}/modules.php?module=admin&amp;what=guestedit&amp;sub={!__SUB_VALUE!}&amp;act=".$content['action']."&amp;w=".$content['what']."&amp;tid=".($content['sort']-1)."&amp;fid=".$content['sort']."\">{--HIGHER--}</a>/<a href=\"{!URL!}/modules.php?module=admin&amp;what=guestedit&amp;sub={!__SUB_VALUE!}&amp;act=".$content['action']."&amp;w=".$content['what']."&amp;tid=".($content['sort']+1)."&amp;fid=".$content['sort']."\">{--LOWER--}</a>";
                        }
 
-                       if (empty($content['action'])) $content['action'] = "&nbsp;";
-                       if (empty($content['what']))   $content['what']   = "&nbsp;";
-                       if (empty($content['title']))  $content['title']  = "&nbsp;";
+                       if (empty($content['action'])) $content['action'] = '&nbsp;';
+                       if (empty($content['what']))   $content['what']   = '&nbsp;';
+                       if (empty($content['title']))  $content['title']  = '&nbsp;';
 
                        $content = array(
                                'sw'     => $SW,
@@ -316,7 +316,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
                                'navi'   => $NAVI,
                                'mode'   => 'guest'
                                );
-                               $OUT .= LOAD_TEMPLATE("admin_menu_overview_row", true, $content);
+                               $OUT .= LOAD_TEMPLATE('admin_menu_overview_row', true, $content);
                                $SW = 3 - $SW;
                }
 
@@ -325,7 +325,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO()))
                define('__MENU_ROWS', $OUT);
 
                // Load template
-               LOAD_TEMPLATE("admin_gmenu_edit");
+               LOAD_TEMPLATE('admin_gmenu_edit');
        } else {
                // Menu entries are missing... (???)
                LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_MENUS_FOUND'));
index dd2a3cd..1672043 100644 (file)
@@ -48,8 +48,7 @@ ADD_DESCR('admin', __FILE__);
 // We only need outgoing transfers
 $result = SQL_QUERY("SELECT userid, to_uid, trans_id, points, reason, time_trans FROM `{!_MYSQL_PREFIX!}_user_transfers_out` ORDER BY trans_id", __FILE__, __LINE__);
 $total = 0;
-if (SQL_NUMROWS($result) > 0)
-{
+if (SQL_NUMROWS($result) > 0) {
        // Output rows
        $OUT = ''; $SW = 2;
        while ($content = SQL_FETCHARRAY($result)) {
@@ -65,15 +64,13 @@ if (SQL_NUMROWS($result) > 0)
                );
 
                // Load row template add points and switch color
-               $OUT .= LOAD_TEMPLATE("admin_list_transfer_row", true, $content);
+               $OUT .= LOAD_TEMPLATE('admin_list_transfer_row', true, $content);
                $total += $content['points']; $SW = 3 - $SW;
        }
 
        // Free memory
        SQL_FREERESULT($result);
-}
-else
-{
+} else {
        // Nothing for in and out
        $OUT = "<tr>
   <td colspan=\"6\" align=\"center\" class=\"bottom2\" height=\"70\">
@@ -96,10 +93,10 @@ define('__TRANSFER_TITLE', getMessage('TRANSFER_LIST_ALL'));
 define('__TRANSFER_SUM', getMessage('TRANSFER_TOTAL_BALANCE'));
 
 // Don't show a delete button
-define('__TRANSFER_DELETE', "&nbsp;");
+define('__TRANSFER_DELETE', '&nbsp;');
 
 // Load final template
-LOAD_TEMPLATE("admin_list_transfer");
+LOAD_TEMPLATE('admin_list_transfer');
 
 //
 ?>
index 40173a3..e629c93 100644 (file)
@@ -152,12 +152,12 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO())) {
                                        'menu'    => $menu,
                                        'sel'     => $sel,
                                        'sw'      => $SW,
-                                       'visible' => ADD_SELECTION('yn', $vis   , "visible", $sel),
-                                       'locked'  => ADD_SELECTION('yn', $locked, "locked" , $sel),
+                                       'visible' => ADD_SELECTION('yn', $vis   , 'visible', $sel),
+                                       'locked'  => ADD_SELECTION('yn', $locked, 'locked' , $sel),
                                );
 
                                // Load template
-                               $OUT .= LOAD_TEMPLATE("admin_menu_status_row", true, $content);
+                               $OUT .= LOAD_TEMPLATE('admin_menu_status_row', true, $content);
                        }
                        else
                        {
@@ -166,7 +166,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO())) {
                                        'sw'  => $SW,
                                        'sel' => $sel
                                );
-                               $OUT .= LOAD_TEMPLATE("admin_menu_404_row", true, $content);
+                               $OUT .= LOAD_TEMPLATE('admin_menu_404_row', true, $content);
                        }
                        $SW = 3 - $SW;
                }
@@ -174,7 +174,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO())) {
        define('__MENU_ROWS', $OUT);
        define('__CNT_VALUE', $cnt);
        //
-       LOAD_TEMPLATE("admin_mmenu_status");
+       LOAD_TEMPLATE('admin_mmenu_status');
 } elseif ((isFormSent()) && (!IS_DEMO())) {
        // An act is done...
        foreach (REQUEST_POST('sel') as $sel => $menu) {
@@ -269,16 +269,16 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO())) {
                        }
 
                        // Fix empty values for Firefox
-                       if (empty($content['action'])) $content['action'] = "&nbsp;";
-                       if (empty($content['what']))   $content['what']   = "&nbsp;";
-                       if (empty($content['title']))  $content['title']  = "&nbsp;";
+                       if (empty($content['action'])) $content['action'] = '&nbsp;';
+                       if (empty($content['what']))   $content['what']   = '&nbsp;';
+                       if (empty($content['title']))  $content['title']  = '&nbsp;';
 
                        // Add more entries
                        $content['sw']   = $SW;
-                       $content['mode'] = "mem";
+                       $content['mode'] = 'mem';
 
                        // Load row template and switch color
-                       $OUT .= LOAD_TEMPLATE("admin_menu_overview_row", true, $content);
+                       $OUT .= LOAD_TEMPLATE('admin_menu_overview_row', true, $content);
                        $SW = 3 - $SW;
                }
 
@@ -289,7 +289,7 @@ if ((REQUEST_ISSET_POST('edit')) && ($chk > 0) && (!IS_DEMO())) {
                define('__MENU_ROWS', $OUT);
 
                // Load main template
-               LOAD_TEMPLATE("admin_mmenu_overview");
+               LOAD_TEMPLATE('admin_mmenu_overview');
        } else {
                // Menu entries are missing... (???)
                LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_MENUS_FOUND'));
index cbeb3d5..cab32b9 100644 (file)
@@ -116,11 +116,11 @@ VALUES ('%s','%s','%s')",
                        'id'  => $id,
                        'url' => $url,
                        'alt' => $alt,
-                       'vis' => ADD_SELECTION('yn', $vis   , "visible"),
+                       'vis' => ADD_SELECTION('yn', $vis   , 'visible'),
                );
 
                // Load row template and switch color
-               $OUT .= LOAD_TEMPLATE("admin_refbanner_edit_row", true, $content);
+               $OUT .= LOAD_TEMPLATE('admin_refbanner_edit_row', true, $content);
                $SW = 3 - $SW;
        }
 
@@ -128,19 +128,20 @@ VALUES ('%s','%s','%s')",
        define('__BANNER_ROWS', $OUT);
 
        // Load main template
-       LOAD_TEMPLATE("admin_refbanner_edit");
+       LOAD_TEMPLATE('admin_refbanner_edit');
 } else {
        if (($SEL > 0) && (REQUEST_ISSET_POST('del'))) {
                // Delete banner
                foreach (REQUEST_POST('sel') as $id => $sel) {
                        SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `id`=%s LIMIT 1",
                        array(bigintval($id)), __FILE__, __LINE__);
-               }
-       }
+               } // END - foreach
+       } // END - if
 
        // Referal levels
-       $result = SQL_QUERY("SELECT id, url, alternate, visible, counter, clicks FROM `{!_MYSQL_PREFIX!}_refbanner` ORDER BY url",
-       __FILE__, __LINE__);
+       $result = SQL_QUERY("SELECT id, url, alternate, visible, counter, clicks FROM `{!_MYSQL_PREFIX!}_refbanner` ORDER BY url", __FILE__, __LINE__);
+
+       // Entries found?
        if (SQL_NUMROWS($result) > 0) {
                // Make referal banner editable and deletable
                $OUT = ''; $SW = 2;
@@ -169,11 +170,11 @@ VALUES ('%s','%s','%s')",
                define('__BANNER_ROWS', $OUT);
 
                // Load main template
-               LOAD_TEMPLATE("admin_refbanner");
+               LOAD_TEMPLATE('admin_refbanner');
        }
 
        // Form for adding new referal levels
-       LOAD_TEMPLATE("admin_add_banner");
+       LOAD_TEMPLATE('admin_add_banner');
 }
 
 //
index 4465185..5ad12fc 100644 (file)
@@ -57,6 +57,9 @@ foreach (array('request-functions', 'session-functions', 'config-functions', 'co
 // Set error handler
 set_error_handler('__errorHandler');
 
+// Init error handler
+initErrorHandler();
+
 // Init request
 initRequest();
 
@@ -87,6 +90,9 @@ if ((!isInstalling()) && (isInstalled())) {
 
                // Is the link valid?
                if (SQL_IS_LINK_UP()) {
+                       // Enable exit on error
+                       enableExitOnError();
+
                        // Is it a valid resource?
                        if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === true) {
                                // This is required for extension 'optimize' to work
index 6d8037f..84c5fd0 100644 (file)
@@ -128,7 +128,7 @@ function checkModulePermissions ($mod) {
        } // END - if
 
        // Major error in module registry is the default
-       $ret = "major";
+       $ret = 'major';
 
        // Check if script is installed if not return a 'done' to prevent some errors
        if ((!isInstalled()) || (isInstalling()) || (!isAdminRegistered())) {
@@ -147,8 +147,8 @@ function checkModulePermissions ($mod) {
        if (GET_EXT_VERSION('cache') >= '0.1.2') {
                // Is the cache there?
                if (!isset($GLOBALS['cache_array']['modules'])) {
-                       // This should normally not happen...
-                       debug_report_bug("Cache 'modules' is gone.");
+                       // This happens when a new extension is registered while ext-cache is installed
+                       $ret = 'cache_miss';
                } // END - if
 
                // Is the module cached?
@@ -164,7 +164,7 @@ function checkModulePermissions ($mod) {
                        $found = true;
                } else {
                        // No, then we have to update it!
-                       $ret = "cache_miss";
+                       $ret = 'cache_miss';
                }
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Check for module in database
@@ -188,13 +188,13 @@ function checkModulePermissions ($mod) {
                        $ret = 'done';
                } elseif ($locked == 'Y') {
                        // Module is locked
-                       $ret = "locked";
+                       $ret = 'locked';
                } elseif (($mem == 'Y') && (!IS_MEMBER())) {
                        // You have to login first!
-                       $ret = "mem_only";
+                       $ret = 'mem_only';
                } elseif (($admin == 'Y') && (!IS_ADMIN())) {
                        // Only the Admin is allowed to enter this module!
-                       $ret = "admin_only";
+                       $ret = 'admin_only';
                } else {
                        // @TODO Nothing helped???
                        DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%s,admin=%s,mem=%s",
@@ -207,7 +207,7 @@ function checkModulePermissions ($mod) {
        } // END - if
 
        // Still no luck or not found?
-       if (($ret == "cache_miss") || (!$found)) {
+       if (($ret == 'cache_miss') || (!$found)) {
                //              ----- Legacy module -----                                               ---- Module in base folder  ----                       --- Module with extension's name ---
                if ((isFileReadable(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) {
                        // Data is missing so we add it
@@ -227,11 +227,11 @@ function checkModulePermissions ($mod) {
                        // Everthing is fine?
                        if (SQL_AFFECTEDROWS() < 1) {
                                // Something bad happend!
-                               return "major";
+                               return 'major';
                        } // END - if
 
                        // Destroy cache here
-                       rebuildCacheFiles("modreg", "modreg");
+                       rebuildCacheFiles('modreg', 'modreg');
 
                        // And reload data
                        $ret = checkModulePermissions($mod_chk);
@@ -266,7 +266,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
        $AND = '';
 
        // First we have to do some analysis...
-       if (substr($file, 0, 7) == "action-") {
+       if (substr($file, 0, 7) == 'action-') {
                // This is an action file!
                $type = 'action';
                $search = substr($file, 7);
@@ -282,7 +282,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                                break;
                }
                $AND = " AND (`what`='' OR `what` IS NULL)";
-       } elseif (substr($file, 0, 5) == "what-") {
+       } elseif (substr($file, 0, 5) == 'what-') {
                // This is an admin what file!
                $type = 'what';
                $search = substr($file, 5);
index 2f6fb8b..267f380 100644 (file)
@@ -2,7 +2,7 @@
 <div align="center">
        <div class="admin_table dashed" style="width:400px;margin-bottom:5px">
        <ul style="padding:0px;margin:0px">
-               <li class="menu_blur bottom2"><a href="{!URL!}/$content['url']" title="$content['title']">$content['title']</a></li>
+               <li class="menu_blur bottom2"><a href="{!URL!}/$content[url]" title="$content[title]">$content[title]</a></li>
        </ul>
        </div>
 </div>
index 71ee3df..a3cbea3 100644 (file)
@@ -3,10 +3,10 @@
        <li class="show_timings_column" style="margin-left: 2px"><span class="show_timings_column">
                {--SHOW_TIMINGS_RUNTIME--}&nbsp;<span class="show_timings_data">$content[runtime]</span>&nbsp;{--SHOW_TIMINGS_SECS--}
        </span></li>
-       <li class="show_timings_column"" style="margin-left: 2px"><span class="show_timings_column">
+       <li class="show_timings_column" style="margin-left: 2px"><span class="show_timings_column">
                {--SHOW_TIMINGS_SQL_QUERIES--}&nbsp;<span class="show_timings_data">$content[numSQLs]</span>
        </span></li>
-       <li class="show_timings_column"" style="margin-right: 2px"><span class="show_timings_column">
+       <li class="show_timings_column" style="margin-right: 2px"><span class="show_timings_column">
                {--SHOW_TIMINGS_NUM_TEMPLATES--}&nbsp;<span class="show_timings_data">$content[numTemplates]</span>
        </span></li>
 </ul>