Happy 2014
[squirrelmail.git] / plugins / change_password / backend / vmailmgrd.php
index e8527d5d73684630c584987eb7b5f8aa3a00d061..2d3e2cf58efc7a8f516a312c2ecb10ce7ee59a87 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * Change password vmailmgrd backend
  *
@@ -20,7 +21,9 @@
  * Backend might require functions, that are available only in SquirrelMail
  * v.1.5.1 and v.1.4.4.
  *
- * @author Tomas Kuliavas <tokul@users.sourceforge.net>
+ * @author Tomas Kuliavas <tokul at users.sourceforge.net>
+ * @copyright 2005-2014 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @link http://www.vmailmgr.org vmailmgr site
  * @package plugins
@@ -73,15 +76,15 @@ $cpw_vmailmgrd_8bitpw=false;
 /* end of backend configuration */
 
 /** load configuration from config.php */
-if ( isset($vmailmgrd) && is_array($vmailmgrd) && !empty($vmailmgrd) ) {
-    if (isset($vmailmgrd['vmail_inc_path']))
-        $vmail_inc_path=$vmailmgrd['vmail_inc_path'];
-    if (isset($vmailmgrd['vm_tcphost']))
-        $vm_tcphost=$vmailmgrd['vm_tcphost'];
-    if (isset($vmailmgrd['vm_tcphost_port']))
-        $vm_tcphost_port=$vmailmgrd['vm_tcphost_port'];
-    if (isset($vmailmgrd['cpw_vmailmgrd_8bitpw']))
-        $cpw_vmailmgrd_8bitpw=$vmailmgrd['cpw_vmailmgrd_8bitpw'];
+if ( isset($cpw_vmailmgrd) && is_array($cpw_vmailmgrd) && !empty($cpw_vmailmgrd) ) {
+    if (isset($cpw_vmailmgrd['vmail_inc_path']))
+        $vmail_inc_path=$cpw_vmailmgrd['vmail_inc_path'];
+    if (isset($cpw_vmailmgrd['vm_tcphost']))
+        $vm_tcphost=$cpw_vmailmgrd['vm_tcphost'];
+    if (isset($cpw_vmailmgrd['vm_tcphost_port']))
+        $vm_tcphost_port=$cpw_vmailmgrd['vm_tcphost_port'];
+    if (isset($cpw_vmailmgrd['8bitpw']))
+        $cpw_vmailmgrd_8bitpw=$cpw_vmailmgrd['8bitpw'];
 }
 
 
@@ -101,24 +104,13 @@ $squirrelmail_plugin_hooks['change_password_init']['vmailmgrd'] =
  * is displayed to the user.
  */
 function cpw_vmailmgrd_init(){
-    global $vmail_inc_path, $color, $username;
-
-    /**
-     * If SM_PATH isn't defined, define it.  Required to include files.
-     * @ignore
-     */
-    if (!defined('SM_PATH'))  {
-        define('SM_PATH','../../../');
-    }
-
-    // load error_box() function
-    include_once(SM_PATH . 'functions/display_messages.php');
+    global $vmail_inc_path, $username, $oTemplate;
 
     if ($vmail_inc_path=='' || ! file_exists($vmail_inc_path)) {
         // $vmail_inc_path is not set or file does not exist
-        error_box(_("Incorrent path to vmail.inc file."),$color);
+        error_box(_("Incorrent path to vmail.inc file."));
         // close html and stop script execution
-        echo "</body></html>\n";
+        $oTemplate->display('footer.tpl');
         exit();
     }
 
@@ -126,17 +118,17 @@ function cpw_vmailmgrd_init(){
 
     if (! function_exists('vchpass')) {
         // included vmail.inc does not have required functions.
-        error_box(_("Invalid or corrupted vmail.inc file."),$color);
+        error_box(_("Invalid or corrupted vmail.inc file."));
         // close html and stop script execution
-        echo "</body></html>\n";
+        $oTemplate->display('footer.tpl');
         exit();
     }
 
     if (! preg_match("/(.*)\@(.*)/", $username)) {
         // username does not match vmailmgr syntax
-        error_box(_("Invalid user."),$color);
+        error_box(_("Invalid user."));
         // close html and stop script execution
-        echo "</body></html>\n";
+        $oTemplate->display('footer.tpl');
         exit();
     }
 }
@@ -212,7 +204,7 @@ function cpw_vmailmgrd_passwd($user,$domain,$oldpass,$newpass) {
 }
 
 /**
- * Function is used to translate messages returned by vmailmgr 
+ * Function is used to translate messages returned by vmailmgr
  * php library and vmailmgr daemon.
  * @param string $string vmailmrgd message.
  * @return string translated string.
@@ -294,4 +286,3 @@ function cpw_i18n_vmail_response($string) {
     }
     return $ret;
 }
-?>
\ No newline at end of file