secImg = $sec_img;
}
function sc_fpw_username($parm='') // used when email login is disabled
{
// return "";
return e107::getForm()->text('username'); // $frm->userpicker()?
}
function sc_fpw_useremail($parm='')
{
// return '';
// return "";
return e107::getForm()->email('email', '', 200, array('placeholder' => 'Email', 'required' => 'required'));
}
function sc_fpw_submit($parm='')
{
// return '';
// return "";
$label = deftrue('LAN_FPW_102', LAN_SUBMIT);
return e107::getForm()->button('pwsubmit', $label);
}
function sc_fpw_captcha_lan($parm='')
{
return LAN_ENTER_CODE;
}
function sc_fpw_captcha_hidden($parm='')
{
return; // no longer required - included in renderInput();
}
/**
* @param string $parm
* @return mixed|null|string
*/
function sc_fpw_captcha_img($parm='')
{
if(USE_IMAGECODE)
{
return $this->secImg->renderImage();
}
return null;
}
/**
* @param string $parm
* @return mixed|null|string
*/
function sc_fpw_captcha_input($parm='')
{
if(USE_IMAGECODE)
{
return $this->secImg->renderInput();
}
return null;
}
function sc_fpw_logo($parm='')
{
// Unused at the moment.
}
function sc_fpw_text($parm='')
{
return deftrue('LAN_FPW_101',"Not to worry. Just enter your email address below and we'll send you an instruction email for recovery.");
}
}
if ($pref['membersonly_enabled'])
{
$sc = array (
'FPW_LOGIN_LOGO' => file_exists(THEME."images/login_logo.png") ? "\n" : "\n"
);
if(deftrue('BOOTSTRAP'))
{
$FPW_TABLE_HEADER = e107::getCoreTemplate('fpw','header');
$FPW_TABLE_FOOTER = e107::getCoreTemplate('fpw','footer');
}
else
{
require_once (e107::coreTemplatePath('fpw')); //correct way to load a core template.
}
define('e_IFRAME', true);
$HEAD = $tp->simpleParse($FPW_TABLE_HEADER, $sc);
$FOOT = $tp->simpleParse($FPW_TABLE_FOOTER, $sc);
define('e_IFRAME_HEADER', $HEAD);
define('e_IFRAME_FOOTER' , $FOOT);
}
$user_info = e107::getUserSession();
require_once(HEADERF);
function fpw_error($txt)
{
if(deftrue('BOOTSTRAP'))
{
e107::getMessage()->addError($txt);
e107::getRender()->tablerender(LAN_03, e107::getMessage()->render());
require_once(FOOTERF);
exit;
}
e107::getRender()->tablerender(LAN_03, "
".$txt."
", 'fpw');
require_once(FOOTERF);
exit;
}
//the separator character used
define('FPW_SEPARATOR', '#');
//$fpw_sep = '#';
// User has clicked on the emailed link
if(e_QUERY)
{
// Make sure login menu is not giving any troubles
define('FPW_ACTIVE','TRUE');
// Verify the password reset code syntax
$tmpinfo = preg_replace("#[\W_]#", "", e107::getParser()->toDB(e_QUERY, true)); // query part is a 'random' number
if ($tmpinfo != e_QUERY)
{
// Shouldn't be any characters that toDB() changes
//die();
e107::getRedirect()->redirect(SITEURL);
}
// Verify the password reset code
if ($sql->select('tmp', '*', "`tmp_ip`='pwreset' AND `tmp_info` LIKE '%".FPW_SEPARATOR.$tmpinfo."' "))
{
$row = $sql->fetch();
// Delete the record
$sql->delete('tmp', "`tmp_time` = ".$row['tmp_time']." AND `tmp_info` = '".$row['tmp_info']."' ");
list($uid, $loginName, $md5) = explode(FPW_SEPARATOR, $row['tmp_info']);
$loginName = $tp->toDB($loginName, true);
// This should never happen!
if($md5 != $tmpinfo)
{
e107::getRedirect()->redirect(SITEURL);
}
// Generate new temporary password
$pwdArray = e107::getUserSession()->resetPassword($uid,$loginName, array('return'=>'array'));
if($pwdArray === false)
{
fpw_error(LAN_214);
}
$newpw = $pwdArray['password'];
// Details for admin log
$do_log = array();
$do_log['password_action'] = LAN_FPW21;
$do_log['user_loginname'] = $loginName;
$do_log['activation_code'] = $tmpinfo;
$do_log['user_password'] = $newpw;
$do_log['user_password_hash'] = $pwdArray['hash'];
// Prepare new information to display to user
if((integer) e107::getPref('allowEmailLogin') > 0)
{
// always show email when possible
$sql->select('user', 'user_email', "user_id=".intval($uid));
$tmp = $sql->fetch();
$loginName = $tmp['user_email'];
$do_log['user_email'] = $tmp['user_email'];
unset($tmp);
}
$admin_log->user_audit(USER_AUDIT_PW_RES,$do_log,0,$do_log['user_name']);
if(getperms('0')) // Test Mode.
{
echo "