CONFIGURATION
Edit the file config.php to set the backend you want to use.
-Probably, you need to set some config vars in the backend too
-(backend/<yourbackend>.php).
+
+Backends can use special arrays that override default values set
+in backend/<yourbackend>.php. Check description of backend that
+you use.
BACKENDS
- ldap
Default settings are supplied in backends/mysql.php.
You do not have to change any configuration vars in
- backend/mysql.php - instead, create an array in config.php
- containing the variable you want to override, for example:
+ backend/mysql.php - instead, create an $cpw_mysql array in
+ config.php containing the variable you want to override,
+ for example:
To override the server name ($mysql_server), you would add
- $mysql['server'] = 'remote_servername';
+ $cpw_mysql['server'] = 'remote_servername';
to config.php.
+ See more information in "About mysql backend" chapter.
- merak
Default settings are supplied in backends/merak.php.
+ Site configuration is controlled in config.php $cpw_merak
+ array. You can use 'url','selfpage' and 'action' array
+ keys to override default values.
+
+ * 'url'
+ override sets address of merak interface. URL is used
+ by webserver's libraries. If it points at localhost,
+ plugin tries to connect to administrative interface on
+ same machine that hosts squirrelmail scripts.
+ Defaults to 'http://localhost:32000/'.
+
+ * 'selfpage'
+ override sets page that is used to change password.
+ Defaults to 'self.html'.
+
+ * 'action'
+ override sets action that is used during password change.
+ Defaults to 'self_edit'.
+
+ For example:
+ $cpw_merak['url']='http://example.com:32000';
+
- poppassd
Default settings are supplied in backends/poppassd.php.
+ Site configuration is controlled in config.php $cpw_poppassd
+ array. You can use 'server' array key to override address
+ of poppassd server. Backend uses address of imap server, if
+ variable is set to empty string. It uses address of imap
+ server by default.
+
+ For example:
+ $cpw_poppassd['server'] = 'remote_servername';
- vmailmgrd
Default settings are supplied in backends/vmailmgrd.php.
- Site configuration is controlled in config.php $vmailmgrd
+ Site configuration is controlled in config.php $cpw_vmailmgrd
array. Backend uses 'vmail_inc_path', 'vm_tcphost',
- 'vm_tcphost_port' and 'cpw_vmailmgrd_8bitpw' array keys.
+ 'vm_tcphost_port' and '8bitpw' array keys.
'vmail_inc_path' sets path to vmail.inc. 'vm_tcphost' sets
vmailmgrd tcp service ip address or dns name. Plugin uses
vmailmgrd socket, if it is not set. 'vm_tcphost_port' sets
port of vmailmrgd service. Plugin uses port 322, if it is
- not set. 'cpw_vmailmgrd_8bitpw' controls use of 8bit
- passwords. If it is not set, interface does not allow new
- passwords with 8bit symbols.
+ not set. '8bitpw' controls use of 8bit passwords. If it
+ is not set, interface does not allow new passwords with
+ 8bit symbols.
- $vmailmgrd['vmail_inc_path'] setting is required.
+ $cpw_vmailmgrd['vmail_inc_path'] setting is required.
AUTHORS:
overrides port of ldap server. Defaults to 389.
* 'basedn'
- (required) ldap basedn used for binding to ldap server. Empty
- string blocks use of backend. Defaults to empty string.
+ (required) ldap basedn used for binding to ldap server. If set to
+ empty string, blocks use of backend. Defaults to empty string.
* 'connect_opts'
controls LDAP_OPT_* settings that are set with ldap_set_option()
- smd5 - used name 'smd5'. Implemented in php mhash extension functions.
Minimal php version = 4.0.4.
- sha - used name 'sha'. Implemented in php mhash extension functions
- and php 4.3.0+ sha1() function. mhash extension is used only wheh
+ and php 4.3.0+ sha1() function. mhash extension is used only when
sha1() function is unavailable.
- ssha - used name 'ssha'. Implemented in php mhash extension functions.
Minimal php version = 4.0.4.
$cpw_ldap['base_dn']='ou=users,dc=example,dc=com'; // sets base dn
$cpw_ldap['connect_opts']['PROTOCOL_VERSION']=3; // forces v3 bind protocol
+-------------------
+ABOUT MYSQL BACKEND
+------------_------
+ List of supported overrides:
+ * 'server'
+ address of MySQL server. Defaults to localhost.
+
+ * 'database'
+ database that stores user information. Defaults to 'email'.
+
+ * 'table'
+ database table that stores user information. Defaults to 'users'.
+
+ * 'userid_field'
+ field that stores user's ID. Defaults to 'id'.
+
+ * 'password_field'
+ field that stores password. Defaults to 'password'.
+
+ * 'manager_id'
+ username that is used to log into MySQL with (must have rights).
+ Defaults to 'email_admin'.
+
+ * 'manager_pw'
+ password that is used to log into MySQL.
+
+ * 'saslcrypt'
+ boolean value that controls use of SASL (MySQL) crypt in passwords.
+ It is not enabled by default.
+
+ * 'unixcrypt'
+ boolean value that controls use of unix crypt() in passwords.
+ Setting is ignored, if saslcrypt is enabled. It is not enabled
+ by default.
+
+If saslcrypt and unixcrypt are not enabled, plugin defaults to plaintext
+passwords.
$Id$
$merak_selfpage = "self.html";
$merak_action = "self_edit";
-// NO NEED TO CHANGE ANYTHING BELOW THIS LINE
+// get overrides from config.
+if ( isset($cpw_merak) && is_array($cpw_merak) && !empty($cpw_merak) ) {
+ foreach ( $cpw_merak as $key => $value ) {
+ if ( isset(${'merak_'.$key}) )
+ ${'merak_'.$key} = $value;
+ }
+}
global $squirrelmail_plugin_hooks;
$squirrelmail_plugin_hooks['change_password_dochange']['merak'] =
'cpw_merak_dochange';
+$squirrelmail_plugin_hooks['change_password_init']['merak'] =
+ 'cpw_merak_init';
+
+/**
+ * Check if php install has all required extensions.
+ */
+function cpw_merak_init() {
+ global $color;
+
+ /**
+ * 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');
+
+ if (!function_exists('curl_init')) {
+ // user_error('Curl module NOT available!', E_USER_ERROR);
+ error_box(_("PHP Curl extension is NOT available! Unable to change password!"),$color);
+ // close html and stop script execution
+ echo "</body></html>\n";
+ exit();
+ }
+}
/**
* This is the function that is specific to your backend. It takes
global $merak_url, $merak_selfpage, $merak_action;
- if (!function_exists('curl_init')) {
-
- // user_error('Curl module NOT available!', E_USER_ERROR);
- array_push($msgs, _("Curl module NOT available! Unable to change password!"));
- return $msgs;
- }
-
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $merak_url . $merak_selfpage);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
global $mysql_server, $mysql_database, $mysql_table, $mysql_userid_field,
$mysql_password_field, $mysql_manager_id, $mysql_manager_pw,
- $mysql_saslcrypt, $mysql_unixcrypt, $mysql;
+ $mysql_saslcrypt, $mysql_unixcrypt, $cpw_mysql;
// Initialize defaults
$mysql_server = 'localhost';
$mysql_saslcrypt = 0; // use MySQL password() function
$mysql_unixcrypt = 0; // use UNIX crypt() function
-if ( isset($mysql) && is_array($mysql) && !empty($mysql) )
+// get overrides from config.
+if ( isset($cpw_mysql) && is_array($cpw_mysql) && !empty($cpw_mysql) )
{
- foreach ( $mysql as $key => $value )
+ foreach ( $cpw_mysql as $key => $value )
{
if ( isset(${'mysql_'.$key}) )
${'mysql_'.$key} = $value;
}
}
-// NO NEED TO CHANGE ANYTHING BELOW THIS LINE
-
global $squirrelmail_plugin_hooks;
$squirrelmail_plugin_hooks['change_password_dochange']['mysql'] =
'cpw_mysql_dochange';
$mysql_password_field, $mysql_manager_id, $mysql_manager_pw,
$mysql_saslcrypt, $mysql_unixcrypt;
+ // TODO: allow to choose between mysql_connect() and mysql_pconnect() functions.
$ds = mysql_pconnect($mysql_server, $mysql_manager_id, $mysql_manager_pw);
if (! $ds) {
array_push($msgs, _("Cannot connect to Database Server, please try later!"));
if ($mysql_saslcrypt) {
$query_string .= '=password("'.mysql_escape_string($curpw).'")';
} elseif ($mysql_unixcrypt) {
+ // FIXME: why password field name is used for salting
$query_string .= '=encrypt("'.mysql_escape_string($curpw).'", '.$mysql_password_field . ')';
} else {
$query_string .= '="' . mysql_escape_string($curpw) . '"';
if ($mysql_saslcrypt) {
$update_string .= '=password("'.mysql_escape_string($newpw).'")';
} elseif ($mysql_unixcrypt) {
+ // FIXME: use random salt when you create new password
$update_string .= '=encrypt("'.mysql_escape_string($newpw).'", '.$mysql_password_field . ')';
} else {
$update_string .= '="' . mysql_escape_string($newpw) . '"';
$poppassd_server = '';
+/* get overrides from config.php */
+if (isset($cpw_poppassd['server'])) $poppassd_server=$cpw_poppassd['server'];
+
/**
* Define here the name of your password changing function.
*/
global $squirrelmail_plugin_hooks;
$squirrelmail_plugin_hooks['change_password_dochange']['poppassd'] = 'cpw_poppassd_dochange';
-$squirrelmail_plugin_hooks['change_password_init']['template'] = 'cpw_poppassd_init';
-
-
-/**
- * Use this function to do any backend-specific initialization,
- * e.g. checking requirements, before the password change form
- * is displayed to the user.
- */
-function cpw_poppassd_init() {
-}
/**
* This is the function that is specific to your backend. It takes
/* 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'];
}
/** @ignore */
define('SM_PATH','../../');
-require_once (SM_PATH . 'include/validate.php');
-require_once (SM_PATH . 'functions/page_header.php');
-require_once (SM_PATH . 'plugins/change_password/functions.php');
-require_once (SM_PATH . 'plugins/change_password/config.php');
-require_once (SM_PATH . 'functions/forms.php');
+include_once (SM_PATH . 'include/validate.php');
+include_once (SM_PATH . 'plugins/change_password/functions.php');
+include_once (SM_PATH . 'functions/forms.php');
-// you must load backend configuration here in order to get working change_password_init hook.
+/** load default config */
+if (file_exists(SM_PATH . 'plugins/change_password/config_default.php')) {
+ include_once (SM_PATH . 'plugins/change_password/config_default.php');
+} else {
+ // somebody decided to remove default config
+ $cpw_backend = 'template';
+ $cpw_pass_min_length = 4;
+ $cpw_pass_max_length = 25;
+ $cpw_require_ssl = FALSE;
+}
+
+/**
+ * prevent possible corruption of configuration overrides in
+ * register_globals=on and preloaded php scripts.
+ */
+$cpw_ldap=array();
+$cpw_merak=array();
+$cpw_mysql=array();
+$cpw_poppassd=array();
+$cpw_vmailmgrd=array();
+
+/** load site config */
+if (file_exists(SM_PATH . 'config/change_password_config.php')) {
+ include_once (SM_PATH . 'config/change_password_config.php');
+} elseif (file_exists(SM_PATH . 'plugins/change_password/config.php')) {
+ include_once (SM_PATH . 'plugins/change_password/config.php');
+}
+
+// must load backend libraries here in order to get working change_password_init hook.
if (file_exists(SM_PATH . 'plugins/change_password/backend/'.$cpw_backend.'.php')) {
include_once(SM_PATH . 'plugins/change_password/backend/'.$cpw_backend.'.php');
}
/* the form was submitted, go for it */
if(sqgetGlobalVar('cpw_go', $cpw_go, SQ_POST)) {
+ // SM14 code: use change_password gettext domain binding for 1.4.x
+ if (! check_sm_version(1,5,0)) {
+ bindtextdomain('change_password',SM_PATH . 'locale');
+ textdomain('change_password');
+ }
+
/* perform basic checks */
$Messages = cpw_check_input();
if(count($Messages) == 0) {
$Messages = cpw_do_change();
}
+
+ // SM14 code: use change_password gettext domain binding for 1.4.x
+ if (! check_sm_version(1,5,0)) {
+ bindtextdomain('squirrelmail',SM_PATH . 'locale');
+ textdomain('squirrelmail');
+ }
}
displayPageHeader($color, 'None');
+// SM14 code: use change_password gettext domain binding for 1.4.x
+if (! check_sm_version(1,5,0)) {
+ bindtextdomain('change_password',SM_PATH . 'locale');
+ textdomain('change_password');
+}
+
do_hook('change_password_init');
?>
function change_password_optpage() {
global $optpage_blocks;
+ // SM14 code: use change_password gettext domain binding for 1.4.x
+ if (! check_sm_version(1,5,0)) {
+ bindtextdomain('change_password',SM_PATH . 'locale');
+ textdomain('change_password');
+ }
+
$optpage_blocks[] = array(
'name' => _("Change Password"),
'url' => '../plugins/change_password/options.php',
'desc' => _("Use this to change your email password."),
'js' => FALSE
);
+
+ // SM14 code: revert to squirrelmail domain for 1.4.x
+ if (! check_sm_version(1,5,0)) {
+ bindtextdomain('squirrelmail',SM_PATH . 'locale');
+ textdomain('squirrelmail');
+ }
}
/**
function change_password_loadinfo() {
global $optpage, $optpage_name;
if ($optpage=='change_password') {
+ // SM14 code: use change_password gettext domain binding for 1.4.x
+ if (! check_sm_version(1,5,0)) {
+ bindtextdomain('change_password',SM_PATH . 'locale');
+ textdomain('change_password');
+ }
+
// i18n: is displayed after "Successfully Saved Options:"
$optpage_name=_("User's Password");
- }
+ // SM14 code: revert to squirrelmail domain for 1.4.x
+ if (! check_sm_version(1,5,0)) {
+ bindtextdomain('squirrelmail',SM_PATH . 'locale');
+ textdomain('squirrelmail');
+ }
+ }
}
/**