diff --git a/sip_login_reminder.phtml b/sip_login_reminder.phtml index 21526ab..9e32d0e 100644 --- a/sip_login_reminder.phtml +++ b/sip_login_reminder.phtml @@ -1,233 +1,231 @@ 'admin'); $SoapEngine = new SoapEngine('sip_accounts', $soapEngines, $login_credentials); $_class = $SoapEngine->records_class; $RECORDS = new $_class($SoapEngine); $login_credentials['sip_engine'] = $RECORDS->SoapEngine->sip_engine; if ($_REQUEST['id']) { $id = $_REQUEST['id']; $db = new DB_CDRTool(); $query="delete from memcache where `key` LIKE 'email_%' and NOW() >= `expire`"; if (!$db->query($query)) { $log = sprintf("Database error for query %s: %s (%s)\n", $query, $db->Error, $db->Errno); syslog(LOG_NOTICE, $log); } else { $log = sprintf("Purged %d records from memcache\n", $db->affected_rows()); syslog(LOG_NOTICE, $log); } $query = sprintf( "select * from memcache where `key`='email_%s'", addslashes($id) ); if (!$db->query($query)) return false; if ($db->num_rows()) { $db->next_record(); $account = json_decode($db->f('value'), true); if (!($_REQUEST['sip_password'] || $_REQUEST['web_password'])) { $RECORDS->showPasswordReminderUpdateFormEncrypted($_REQUEST['id'], $account['sip_account']); } else { $SipSettings = new SipSettings($account['sip_account'], $login_credentials, $soapEngines); dprint_r($SipSettings->result); if ($_REQUEST['sip_password']) { //print "$SipSettings->password"; if ($SipSettings->store_clear_text_passwords) { $SipSettings->result->password = $_REQUEST['sip_password']; } else { $md1 = strtolower($SipSettings->result->id->username).':'.strtolower($SipSettings->result->id->domain).':'.$REQUEST['sip_password']; dprint($md1); dprint(md5($md1)); $md2 = strtolower($SipSettings->result->id->username).'@'.strtolower($SipSettings->result->id->domain).':'.strtolower($SipSettings->result->id->domain).':'.$_REQUEST['sip_password']; $SipSettings->result->password = md5($md1).':'.md5($md2); } } if ($_REQUEST['web_password']) { //dprint_r($SipSettings->result->properties); if ($SipSettings->store_clear_text_passwords) { $web_password_new = $_REQUEST['web_password']; } else { $md1 = strtolower($SipSettings->result->id->username).':'.strtolower($SipSettings->result->id->domain).':'.$_REQUEST['web_password']; $md2 = strtolower($SipSettings->result->id->username).'@'.strtolower($SipSettings->result->id->domain).':'.strtolower($SipSettings->result->id->domain).':'.$_REQUEST['web_password']; $web_password_new = md5($md1).':'.md5($md2); } foreach (array_keys($SipSettings->result->properties) as $_key) { $_prop = $SipSettings->result->properties[$_key]; if ($_prop->name == 'web_password') { $newProperties[] = array( 'name'=> 'web_password', 'value' => $web_password_new ); $found = 1; } else { $newProperties[] = $_prop; } } if (!$found) { $newProperties[] = array( 'name' => 'web_password', 'value' => $web_password_new ); } //if ($SipSettings->result->properties!=$newProperties) $this->somethingChanged=1; if (!$newProperties) $newProperties = array(); $SipSettings->result->properties=$newProperties; //setPreference1('web_password',$_REQUEST['web_password']); } dprint_r($SipSettings->result); $SipSettings->SipPort->addHeader($SipSettings->SoapAuth); $result = $SipSettings->SipPort->updateAccount($SipSettings->result); dprint_r($SipSettings->result); print "

"; print _("Update passwords"); print "

"; if ((new PEAR)->isError($result)) { $error_msg = $result->getMessage(); $error_fault= $result->getFault(); $error_code = $result->getCode(); echo "
"; printf( "Error (SipPort):
%s (%s): %s
", $error_msg, $error_fault->detail->exception->errorcode, $error_fault->detail->exception->errorstring ); return false; } else { echo "
"; print _("Success"); print "
"; print _("The password(s) have been updated"); print "
"; $query = "delete from memcache where `key` LIKE 'email_$id'"; if (!$db->query($query)) { $log = sprintf("Database error for query %s: %s (%s)\n", $query, $db->Error, $db->Errno); syslog(LOG_NOTICE, $log); } flush(); } unset($SipSettings); } } else { echo "

"; print _("Update passwords"); print "

"; echo "
"; print _("Error"); print "
"; print _("ID not found in the database"); print "
"; print _("or the password changing session has expired"); print "
"; flush(); } print "

Found a SIP account having email address set to '%s':

", trim($email_filter)); } else { printf("

Found multiple SIP accounts having email address set to '%s':

", trim($email_filter)); } //printf ("

Found a SIP account having email address set to '%s'",trim($_REQUEST['email_filter'])); print ""; print "

Processing...

"; print "
    "; print "
  • "; foreach ($accounts as $_account) { $account = $_account['username'].'@'.$_account['domain']; //if ($account == $_REQUEST['sip_filter']) { $SipSettings = new SipSettings($account, $login_credentials, $soapEngines); $success = $success + $SipSettings->sendEmail(true); //print "$sucess"; sleep(1); flush(); //} } if ($success >= "1") { if ($success > "1") { print "Login reminders and password resets have been sent to "; } else { print "Login reminder and password reset have been sent to "; } print $email_filter; print "
  • "; print ""; } print "
"; } } print "

Back to login page"; } echo ""; - -?>