Centralized init
[squirrelmail.git] / plugins / squirrelspell / sqspell_interface.php
index 79a4f45b0b291e53456d5ddd93370c1091650da6..4d3cf5e2c83a76ca664030ac785aad70fd12fb9f 100644 (file)
@@ -5,16 +5,13 @@
  *
  * Main wrapper for the pop-up.
  *
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * This is a main wrapper for the pop-up window interface of
  * SquirrelSpell.
  *
- * $Id$
- *
- * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
- * @version $Date$
+ * @author Konstantin Riabitsev <icon at duke.edu>
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
  * @package plugins
  * @subpackage squirrelspell
  */
 $SQSPELL_DIR='plugins/squirrelspell/';
 $SQSPELL_CRYPTO=FALSE;
 
+
 /**
- * Load the stuff needed from SquirrelMail
- * @ignore
+ * Include the SquirrelMail initialization file.
  */
-define('SM_PATH','../../');
+require('../../include/init.php');
 
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'include/load_prefs.php');
-require_once(SM_PATH . $SQSPELL_DIR . 'sqspell_config.php');
-require_once(SM_PATH . $SQSPELL_DIR . 'sqspell_functions.php');
+include_once(SM_PATH . $SQSPELL_DIR . 'sqspell_functions.php');
 
 /**
  * $MOD is the name of the module to invoke.
- * If $MOD is undefined, use "init", else check for security
- * breaches.
+ * If $MOD is unspecified, assign "init" to it. Else check for
+ * security breach attempts.
  */
-if(isset($_POST['MOD'])) {
-    $MOD = $_POST['MOD'];
-} elseif (isset($_GET['MOD'])) {
-    $MOD = $_GET['MOD'];
+if(! sqgetGlobalVar('MOD',$MOD,SQ_FORM)) {
+    $MOD = 'init';
 }
+sqspell_ckMOD($MOD);
 
-if (!isset($MOD) || !$MOD){
-    $MOD='init';
+/* Load the stuff already. */
+if (file_exists(SM_PATH . $SQSPELL_DIR . "modules/$MOD.mod")) {
+    require_once(SM_PATH . $SQSPELL_DIR . "modules/$MOD.mod");
 } else {
-    sqspell_ckMOD($MOD);
+    error_box(_("Invalid SquirrelSpell module."),$color);
+    echo '</body></html>';
 }
-
-/* Include the module. */
-require_once(SM_PATH . $SQSPELL_DIR . "modules/$MOD.mod");
-
 ?>
\ No newline at end of file