static function save($savemsg, $userobj, $what)
{
global $_zp_gallery;
if ($what == 'new' && ($mail = $userobj->getEmail())) {
$ref = Zenphoto_Authority::getResetTicket($adm = $userobj->getUser(), $userobj->getPass());
$msg = "\n" . sprintf(gettext('You are receiving this e-mail because a user code (%1$s) has been created for you on the Zenphoto gallery %2$s.'), $adm, $_zp_gallery->getTitle()) . "\n" . sprintf(gettext('To set your Zenphoto User password visit: %s'), FULLWEBPATH . "/" . ZENFOLDER . "/admin-users.php?ticket={$ref}&user={$adm}") . "\n" . gettext("This ticket will automatically expire in 3 days.");
$err_msg = zp_mail(gettext("Zenphoto user created"), $msg, array($mail));
if (!empty($err_msg)) {
$savemsg .= $err_msg;
}
}
return $savemsg;
}
/**
* User authentication support
*/
function handleLogon()
{
global $_zp_current_admin_obj, $_zp_login_error, $_zp_captcha, $_zp_loggedin;
if (isset($_POST['login'])) {
$post_user = sanitize(@$_POST['user'], 0);
$post_pass = sanitize(@$_POST['pass'], 0);
$_zp_loggedin = false;
switch (@$_POST['password']) {
default:
$user = self::checkLogon($post_user, $post_pass);
if ($user) {
$_zp_loggedin = $user->getRights();
}
$_zp_loggedin = zp_apply_filter('admin_login_attempt', $_zp_loggedin, $post_user, $post_pass);
if ($_zp_loggedin) {
self::logUser($user);
$_zp_current_admin_obj = $user;
session_regenerate_id(true);
} else {
zp_clearCookie("zp_user_auth");
// Clear the cookie, just in case
$_zp_login_error = 1;
}
break;
case 'challenge':
$user = $this->getAnAdmin(array('`user`=' => $post_user, '`valid`=' => 1));
if (is_object($user)) {
$info = $user->getChallengePhraseInfo();
if ($post_pass && $info['response'] == $post_pass) {
$ref = self::getResetTicket($post_user, $user->getPass());
header('location:' . WEBPATH . '/' . ZENFOLDER . '/admin-users.php?ticket=' . $ref . '&user=' . $post_user);
exitZP();
}
}
$_zp_login_error = gettext('Sorry, that is not the answer.');
$_REQUEST['logon_step'] = 'challenge';
break;
case 'captcha':
if ($_zp_captcha->checkCaptcha(trim(@$_POST['code']), sanitize(@$_POST['code_h'], 3))) {
require_once dirname(__FILE__) . '/load_objectClasses.php';
// be sure that the plugins are loaded for the mail handler
if (empty($post_user)) {
$requestor = gettext('You are receiving this e-mail because of a password reset request on your ZenPhoto20 gallery.');
} else {
$requestor = sprintf(gettext("You are receiving this e-mail because of a password reset request on your ZenPhoto20 gallery from a user who tried to log in as %s."), $post_user);
}
$admins = $this->getAdministrators();
$mails = array();
$user = NULL;
foreach ($admins as $key => $tuser) {
if (!empty($tuser['email'])) {
if (!empty($post_user) && ($tuser['user'] == $post_user || $tuser['email'] == $post_user)) {
$name = $tuser['name'];
if (empty($name)) {
$name = $tuser['user'];
}
$mails[$name] = $tuser['email'];
$user = $tuser;
unset($admins[$key]);
// drop him from alternate list.
} else {
if (!($tuser['rights'] & ADMIN_RIGHTS)) {
unset($admins[$key]);
// eliminate any peons from the list
}
}
} else {
unset($admins[$key]);
// we want to ignore groups and users with no email address here!
}
}
$cclist = array();
foreach ($admins as $tuser) {
$name = $tuser['name'];
if (empty($name)) {
$name = $tuser['user'];
}
if (is_null($user)) {
$user = $tuser;
$mails[$name] = $tuser['email'];
} else {
$cclist[$name] = $tuser['email'];
}
}
if (is_null($user)) {
$_zp_login_error = gettext('There was no one to which to send the reset request.');
} else {
$ref = self::getResetTicket($user['user'], $user['pass']);
$msg = "\n" . $requestor . "\n" . sprintf(gettext("To reset your Admin passwords visit: %s"), FULLWEBPATH . "/" . ZENFOLDER . "/admin-users.php?ticket={$ref}&user=" . $user['user']) . "\n" . gettext("If you do not wish to reset your passwords just ignore this message. This ticket will automatically expire in 3 days.");
$err_msg = zp_mail(gettext("The ZenPhoto20 information you requested"), $msg, $mails, $cclist);
if (empty($err_msg)) {
$_zp_login_error = 2;
} else {
$_zp_login_error = $err_msg;
}
}
} else {
//.........这里部分代码省略.........
/**
* User authentication support
*/
function handleLogon()
{
global $_zp_authority, $_zp_current_admin_obj, $_zp_login_error, $_zp_captcha, $_zp_loggedin;
if (isset($_POST['login']) && isset($_POST['user']) && isset($_POST['pass'])) {
$post_user = sanitize($_POST['user']);
$post_pass = sanitize($_POST['pass'], 0);
$user = $this->checkLogon($post_user, $post_pass, true);
if ($user) {
$_zp_loggedin = $user->getRights();
} else {
$_zp_loggedin = false;
}
$_zp_loggedin = zp_apply_filter('admin_login_attempt', $_zp_loggedin, $post_user, $post_pass);
if ($_zp_loggedin) {
$this->logUser($user);
} else {
// Clear the cookie, just in case
zp_setCookie("zenphoto_auth", "", -368000);
// was it a request for a reset?
if (isset($_POST['code_h']) && $_zp_captcha->checkCaptcha(trim($post_pass), sanitize($_POST['code_h'], 3))) {
require_once dirname(__FILE__) . '/class-load.php';
// be sure that the plugins are loaded for the mail handler
if (empty($post_user)) {
$requestor = gettext('You are receiving this e-mail because of a password reset request on your Zenphoto gallery.');
} else {
$requestor = sprintf(gettext("You are receiving this e-mail because of a password reset request on your Zenphoto gallery from a user who tried to log in as %s."), $post_user);
}
$admins = $_zp_authority->getAdministrators();
$mails = array();
$user = NULL;
foreach ($admins as $key => $tuser) {
if (!empty($tuser['email'])) {
if (!empty($post_user) && ($tuser['user'] == $post_user || $tuser['email'] == $post_user)) {
$name = $tuser['name'];
if (empty($name)) {
$name = $tuser['user'];
}
$mails[$name] = $tuser['email'];
$user = $tuser;
unset($admins[$key]);
// drop him from alternate list.
} else {
if (!($tuser['rights'] & ADMIN_RIGHTS)) {
unset($admins[$key]);
// eliminate any peons from the list
}
}
} else {
unset($admins[$key]);
// we want to ignore groups and users with no email address here!
}
}
$cclist = array();
foreach ($admins as $tuser) {
$name = $tuser['name'];
if (empty($name)) {
$name = $tuser['user'];
}
if (is_null($user)) {
$user = $tuser;
$mails[$name] = $tuser['email'];
} else {
$cclist[$name] = $tuser['email'];
}
}
if (is_null($user)) {
$_zp_login_error = gettext('There was no one to which to send the reset request.');
} else {
$ref = $this->getResetTicket($user['user'], $user['pass']);
$msg = "\n" . $requestor . "\n" . sprintf(gettext("To reset your Zenphoto Admin passwords visit: %s"), FULLWEBPATH . "/" . ZENFOLDER . "/admin-users.php?ticket={$ref}&user=" . $user['user']) . "\n" . gettext("If you do not wish to reset your passwords just ignore this message. This ticket will automatically expire in 3 days.");
$err_msg = zp_mail(gettext("The Zenphoto information you requested"), $msg, $mails, $cclist);
if (empty($err_msg)) {
$_zp_login_error = 2;
} else {
$_zp_login_error = $err_msg;
}
}
} else {
$_zp_login_error = 1;
}
}
}
return $_zp_loggedin;
}
// was it a request for a reset?
if ($_zp_captcha->checkCaptcha(trim($post_pass), sanitize($_POST['code_h'], 3))) {
if (empty($post_user)) {
$requestor = 'You are receiving this e-mail because of a password reset request on your Zenphoto gallery.';
} else {
$requestor = sprintf(gettext("You are receiving this e-mail because of a password reset request on your Zenphoto gallery from a user who tried to log in as %s."), $post_user);
}
$admins = getAdministrators();
$user = array_shift($admins);
$adm = $user['user'];
$pas = $user['pass'];
setOption('admin_reset_date', time());
$req = getOption('admin_reset_date');
$ref = md5($req . $adm . $pas);
$msg = "\n" . $requestor . "\n" . sprintf(gettext("To reset your Zenphoto Admin passwords visit: %s"), FULLWEBPATH . "/" . ZENFOLDER . "/admin-options.php?ticket={$ref}") . "\n" . gettext("If you do not wish to reset your passwords just ignore this message. This ticket will automatically expire in 3 days.");
zp_mail(gettext("The Zenphoto information you requested"), $msg);
$_zp_login_error = 2;
} else {
$_zp_login_error = 1;
}
}
}
}
unset($saved_auth, $check_auth, $user, $pass);
// Handle a logout action.
if (isset($_REQUEST['logout'])) {
zp_setcookie("zenphoto_auth", "*", time() - 368000, $cookiepath);
$redirect = 'index.php';
if (isset($_GET['p'])) {
$redirect .= "?p=" . $_GET['p'];
if (isset($_GET['searchfields'])) {
请发表评论