فهرست منبع

strings.php should be loaded before output starts. forearch cycle produced
errors if no plugins were installed.

tokul 22 سال پیش
والد
کامیت
adf5ace99e
1فایلهای تغییر یافته به همراه34 افزوده شده و 25 حذف شده
  1. 34 25
      config/configtest.php

+ 34 - 25
config/configtest.php

@@ -5,7 +5,7 @@
  * Copyright (c) 2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
- * $Id $
+ * $Id$
  */
 
 /************************************************************
@@ -13,6 +13,29 @@
  * If it throws errors you need to adjust your config.      *
  ************************************************************/
 
+function do_err($str, $exit = TRUE) {
+    echo '<p><font color="red"><b>ERROR:</b></font> ' .$str. "</p>\n";
+    if($exit) {
+         echo '</body></html>';
+         exit;
+    }
+}
+
+$IND = str_repeat('&nbsp;',4);
+
+ob_implicit_flush();
+define('SM_PATH', '../');
+
+/*
+ * Load config before output begins. functions/strings.php depends on 
+ * functions/globals.php. functions/global.php needs to be run before
+ * any html output starts. If config.php is missing, error will be displayed 
+ * later.
+ */
+if (file_exists(SM_PATH . 'config/config.php')) {
+    include(SM_PATH . 'config/config.php');
+    include(SM_PATH . 'functions/strings.php');
+}
 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
@@ -27,21 +50,6 @@ in this directory first before you run this script.</p>
 
 <?php
 
-function do_err($str, $exit = TRUE) {
-    echo '<p><font color="red"><b>ERROR:</b></font> ' .$str. "</p>\n";
-    if($exit) {
-         echo '</body></html>';
-         exit;
-    }
-}
-
-$IND = str_repeat('&nbsp;',4);
-
-ob_implicit_flush();
-define('SM_PATH', '../');
-
-include(SM_PATH . 'config/config.php');
-include(SM_PATH . 'functions/strings.php');
 
 $included = array_map('basename', get_included_files() );
 if(!in_array('config.php', $included)) {
@@ -120,17 +128,18 @@ if($data_dir == $attachment_dir) {
 
 
 /* check plugins and themes */
-
-foreach($plugins as $plugin) {
-    if(!file_exists(SM_PATH .'plugins/'.$plugin)) {
-        do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot find it.', FALSE);
-    } elseif (!is_readable(SM_PATH .'plugins/'.$plugin.'/setup.php')) {
-        do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot read its setup.php file.', FALSE);
+if (isset($plugins[0])) {
+    foreach($plugins as $plugin) {
+        if(!file_exists(SM_PATH .'plugins/'.$plugin)) {
+            do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot find it.', FALSE);
+        } elseif (!is_readable(SM_PATH .'plugins/'.$plugin.'/setup.php')) {
+            do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot read its setup.php file.', FALSE);
+        }
     }
+    echo $IND . "Plugins OK.<br />\n";
+} else {
+    echo $IND . "Plugins are not enabled in config.<br />\n";
 }
-
-echo $IND . "Plugins OK.<br />\n";
-
 foreach($theme as $thm) {
     if(!file_exists($thm['PATH'])) {
         do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').', FALSE);