<?php
include_once 'tgydapicommon.php';
include_once 'cons.php';
isset($_GET['code'])?$_GET['code']:exit("链接验证码不能为空！");
$codes=$_GET['code'];
$code=authcode(base64_decode($_GET['code']),'DECODE',$syskey);
$arr=explode('||||',$code);
$user=$arr[0];
$timestamp=$arr[1];
if($timestamp+3600*24*2<time()){
exit("<script language='javascript'>alert('此链接已失效！');window.location.href='/findpwd.php';</script>");
}
if($_GET['sub']){
	session_start();
	$_code = $_SESSION['klsf_code'];
	$code = $_POST['code'];
	if(empty($code) || $code!=$_code){
		exit("<script language='javascript'>alert('验证码不正确！');history.go(-1);</script>");
	}
$pwd = isset($_POST['pwd'])?$_POST['pwd']:exit("新密码不能为空");
$pwds = isset($_POST['pwds'])?$_POST['pwds']:exit("确认密码不能为空");
if($pwds != $pwd){
	exit("<script language='javascript'>alert('两次输入的密码不匹配！');history.go(-1);</script>");
}else{
	$pwd=md5(md5($pwd).md5('815856515'));
	if($db->query("update ".C('DB_PREFIX')."users set pwd='$pwd' where user='$user' "))
	exit("<script language='javascript'>alert('重置密码成功！请重新登录。');window.location.href='/login.php';</script>");
	else
	exit("<script language='javascript'>alert('未知错误，请联系管理员。');window.location.href='/index.php';</script>");
	}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link href="/indexs/css/pace-theme-flash.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="/indexs/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/animate.min.css" rel="stylesheet" type="text/css"/>
<!-- END CORE CSS FRAMEWORK -->
<!-- BEGIN CSS TEMPLATE -->
<link href="/indexs/css/style.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/responsive.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/magic_space.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/custom-icon-set.css" rel="stylesheet" type="text/css"/>
<body class="error-body no-top lazy" style="background: url(/index/img/hero-bg.jpg);background-size: cover;"> 
<title>密码重置 - <?=C('webname')?></title>
<div class="container">
  <div class="row login-container animated fadeInUp">  
        <div class="col-md-8 col-md-offset-2 tiles white no-padding">
		 <div class="p-t-30 p-l-40 p-b-20 xs-p-t-10 xs-p-l-10 xs-p-b-10"> 
         <h2 class="normal"><?php if($msg){?><?=$msg?><?php }else{echo '<h2 class="normal">密码重置';}?></h2>
					<div class="checkbox checkbox check-success"> <a href="/login.php">已经找回成功?点击登录</a>&nbsp;&nbsp;
					</div>

		  </div>
		<div class="tiles grey p-t-20 p-b-20 text-black">
			<form method="post" class="animated fadeIn" action="?type=findpwd&code=<?=$codes?>&sub=1">
			<div class="row form-row m-l-20 m-r-20 xs-m-l-10 xs-m-r-10">
                      <div class="col-md-12">
                        <input name="pwd" type="text" tabindex="1" class="form-control" placeholder="输入新密码">
                      </div>
            </div>
			<div class="row form-row m-l-20 m-r-20 xs-m-l-10 xs-m-r-10">
                      <div class="col-md-12">
                        <input name="pwds" type="text" class="form-control" placeholder="确认新密码">
                      </div>
            </div>
			<div class="row form-row m-l-20 m-r-20 xs-m-l-10 xs-m-r-10">
                      <div class="col-md-6 col-sm-6">
                        <input name="code" type="text" class="form-control" placeholder="输入验证码">
                      </div>
                      <div class="col-md-6 col-sm-6">
                        <img src="/code.php" onclick="javascript:this.src='/code.php?'+Math.random();" style="height:33px" />
                      </div>
					  <div class="col-md-10">
					    <button class="btn btn-primary btn-cons pull-right" type="submit">重置密码</button>
					  </div>
                    </div>
			</form>
             
		</div>
		