/**
* Change password PearDB backend
*
- * @copyright © 2005 The SquirrelMail Project Team
+ * @copyright 2005-2009 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package plugins
* @subpackage change_password
*/
-/** load Pear DB.
- * Global is needed because library must be loaded before configuration
+/** load Pear DB.
+ * Global is needed because library must be loaded before configuration
* in order to use DB constants.
*/
global $cpw_peardb_detect;
$cpw_peardb_detect=@include_once('DB.php');
/** declare configuration globals */
-global $cpw_peardb_dsn, $cpw_peardb_connect_opts, $cpw_peardb_table,
+global $cpw_peardb_dsn, $cpw_peardb_connect_opts, $cpw_peardb_table,
$cpw_peardb_uid_field, $cpw_peardb_domain_field, $cpw_peardb_passwd_field,
$cpw_peardb_crypted_passwd, $cpw_peardb_debug;
if (isset($cpw_peardb['dsn']))
$cpw_peardb_dsn=$cpw_peardb['dsn'];
if (isset($cpw_peardb['connect_opts']))
- $cpw_peardb_connect_opts=$cpw_peaddb['connect_opts'];
+ $cpw_peardb_connect_opts=$cpw_peardb['connect_opts'];
if (isset($cpw_peardb['table']))
$cpw_peardb_table=$cpw_peardb['table'];
if (isset($cpw_peardb['uid_field']))
* Checks if configuration is correct
*/
function cpw_peardb_init() {
- global $color, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table;
-
- /**
- * 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 $oTemplate, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table;
if (! $cpw_peardb_detect) {
- error_box(_("Plugin is unable to use PHP Pear DB libraries. PHP Pear includes must be available in your PHP include_path setting."),$color);
- echo "</body></html>\n";
+ error_box(_("Plugin is unable to use PHP Pear DB libraries. PHP Pear includes must be available in your PHP include_path setting."));
+ $oTemplate->display('footer.tpl');
exit();
}
// Test required settings
- if ((is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn)=='')
+ if ((is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn)=='')
|| trim($cpw_peardb_table)=='' ) {
- error_box(_("Required change password backend configuration options are missing."),$color);
- echo "</body></html>\n";
+ error_box(_("Required change password backend configuration options are missing."));
+ $oTemplate->display('footer.tpl');
exit();
}
}
*/
function cpw_peardb_dochange($data) {
global $cpw_peardb_dsn, $cpw_peardb_table, $cpw_peardb_connect_opts, $cpw_peardb_debug,
- $cpw_peardb_uid_field, $cpw_peardb_passwd_field, $cpw_peardb_domain_field,
+ $cpw_peardb_uid_field, $cpw_peardb_passwd_field, $cpw_peardb_domain_field,
$cpw_peardb_crypted_passwd, $domain;
$username = $data['username'];
$user=$username;
$user_domain=$domain;
}
-
+
// connect to database and make sure that table exists
$cpw_db = DB::connect($cpw_peardb_dsn, $cpw_peardb_connect_opts);
if (PEAR::isError($cpw_db)) {
$cpw_peardb_passwd_check=false;
$cpw_peardb_domain_check=(($cpw_peardb_domain_field=='')? true : false);
foreach($table_info as $key => $field_data) {
- if ($field_data['name']==$cpw_peardb_uid_field)
+ if ($field_data['name']==$cpw_peardb_uid_field)
$cpw_peardb_uid_check=true;
- if ($field_data['name']==$cpw_peardb_passwd_field)
+ if ($field_data['name']==$cpw_peardb_passwd_field)
$cpw_peardb_passwd_check=true;
if ($cpw_peardb_domain_field!='' && $field_data['name']==$cpw_peardb_domain_field)
$cpw_peardb_domain_check=true;
.' FROM '.$cpw_db->quoteIdentifier($cpw_peardb_table)
.' WHERE '
.$cpw_db->quoteIdentifier($cpw_peardb_uid_field).'='.$cpw_db->quoteSmart($user)
- .(($cpw_peardb_domain_field!='') ?
+ .(($cpw_peardb_domain_field!='') ?
' AND '.$cpw_db->quoteIdentifier($cpw_peardb_domain_field).'='.$cpw_db->quoteSmart($user_domain):
'');
$cpw_res=$cpw_db->query($query);
.'='.$cpw_db->quoteSmart($hashed_passwd)
.' WHERE '.$cpw_db->quoteIdentifier($cpw_peardb_uid_field)
.'='.$cpw_db->quoteSmart($user)
- .(($cpw_peardb_domain_field!='') ?
+ .(($cpw_peardb_domain_field!='') ?
' AND '.$cpw_db->quoteIdentifier($cpw_peardb_domain_field).'='.$cpw_db->quoteSmart($user_domain) :
'');
}
return $ret;
}
-?>
\ No newline at end of file