修改用户注册界面
This commit is contained in:
parent
0288b30ab6
commit
1822a361cf
|
@ -66,7 +66,7 @@ class AccountController extends Zend_Controller_Action
|
|||
"国家级国家自然科学基金" => "国家级国家自然科学基金",
|
||||
"国际合作项目"=>"国际合作项目",
|
||||
"省部级项目" => "省部级项目",
|
||||
"其他项目工程" => "其他项目工程"
|
||||
"其他项目工程" => "其他项目工程",
|
||||
);
|
||||
|
||||
$submit = $this->_getParam('submit');
|
||||
|
@ -250,44 +250,31 @@ class AccountController extends Zend_Controller_Action
|
|||
|
||||
function registerAction()
|
||||
{
|
||||
$form = new RegisterForm();
|
||||
$this->view->form = $form;
|
||||
$order = new \Order\Order();
|
||||
|
||||
if ($this->_request->isPost()) {
|
||||
$formData = $this->_request->getPost();
|
||||
if ($form->isValid($formData)) {
|
||||
$ut = new UsersTable();
|
||||
$u = $ut->createRow();
|
||||
$u->username = $form->getValue('username');
|
||||
$u->password = $form->getValue('password');
|
||||
$u->email=$form->getValue('email');
|
||||
if ($form->getValue('realname')) $u->realname=$form->getValue('realname');
|
||||
if ($form->getValue('phone')) $u->phone=$form->getValue('phone');
|
||||
if ($form->getValue('address')) $u->address=$form->getValue('address');
|
||||
if ($form->getValue('unit')) $u->unit=$form->getValue('unit');
|
||||
if ($form->getValue('project')) $u->project=$form->getValue('project');
|
||||
if ($u->save()) {
|
||||
$this->view->projectType = array_merge(array("无"=>""),$order->projectType);
|
||||
|
||||
//注册邮件
|
||||
$mail_template = "member-register";
|
||||
$mail_data = array(
|
||||
'name'=>$formData['username'],
|
||||
);
|
||||
$submit = $this->_getParam("submit");
|
||||
|
||||
$mail = new Mail();
|
||||
if(!empty($submit))
|
||||
{
|
||||
$account = new Account();
|
||||
$this->view->data = $data = $account->getRegisterParam();
|
||||
$status = $account->register($data);
|
||||
|
||||
$mail->loadTemplate($mail_template,$mail_data);
|
||||
$mail->addTo($formData['email'],$formData['username']);
|
||||
$mail->send();
|
||||
if(isset($status['error']))
|
||||
{
|
||||
$this->view->error = $status['error'];
|
||||
if(isset($status['place']))
|
||||
{
|
||||
$this->view->place = $status['place'];
|
||||
}
|
||||
}else{
|
||||
view::Post($this,"注册成功!","/");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//自动登录系统
|
||||
$this->login($formData['username'],$formData['password']);
|
||||
$this->_redirect('/');
|
||||
}
|
||||
} else {
|
||||
$form->populate($formData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loginAction()
|
||||
|
@ -328,6 +315,13 @@ class AccountController extends Zend_Controller_Action
|
|||
$password = trim($this->_request->getParam('password'));
|
||||
$captchaword = trim($this->_request->getParam('captcha'));
|
||||
|
||||
if($captcha->isValid($captchaword) !== true)
|
||||
{
|
||||
$this->view->error = "验证码错误";
|
||||
$this->view->captcha = $captcha->setCaptcha();
|
||||
return true;
|
||||
}
|
||||
|
||||
$account = new Account();
|
||||
$status = $account->login(array(
|
||||
'username' => $username,
|
||||
|
@ -341,13 +335,6 @@ class AccountController extends Zend_Controller_Action
|
|||
return true;
|
||||
}
|
||||
|
||||
if(!$captcha->isValid($captchaword))
|
||||
{
|
||||
$this->view->error = "验证码错误";
|
||||
$this->view->captcha = $captcha->setCaptcha();
|
||||
return true;
|
||||
}
|
||||
|
||||
view::Post($this,"登录成功,正在跳转",$tohref);
|
||||
return true;
|
||||
}else{
|
||||
|
|
|
@ -8,12 +8,136 @@
|
|||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<div class="row-fluit">
|
||||
<div class="span12">
|
||||
<img src="/images/pass_login1.gif" /> 确认服务条款
|
||||
<img src="/images/pass_pic_arrowhead_2.gif" />
|
||||
<img src="/images/pass_login2.gif" /> 填写基本信息
|
||||
<img src="/images/pass_pic_arrowhead_2.gif" />
|
||||
<img src="/images/pass_login3.gif" /> 注册完成
|
||||
<?php echo $this->form;?>
|
||||
</div>
|
||||
<form class="form-horizontal" method="post" id="register">
|
||||
<?php if(empty($this->error)) { ?>
|
||||
<div class="alert alert-info alert-login">
|
||||
请输入您的基本信息进行注册
|
||||
</div>
|
||||
<? }else{ ?>
|
||||
<div class="alert alert-error alert-login">
|
||||
<?= isset($this->error['error'])? $this->error['error'] : $this->error ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="username">用户名</label>
|
||||
<div class="controls">
|
||||
<input id="username" type="text" value="<?= isset($this->data['username']) ? $this->data['username']:"" ?>" name="username" />
|
||||
<span class="help-inline">(必填)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="password">密码</label>
|
||||
<div class="controls">
|
||||
<input id="password" type="password" value="" name="password" />
|
||||
<span class="help-inline">(必填)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="confirm_password">确认密码</label>
|
||||
<div class="controls">
|
||||
<input id="confirm_password" type="password" value="" name="confirm_password" />
|
||||
<span class="help-inline">(必填)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="email">E-Mail</label>
|
||||
<div class="controls">
|
||||
<input id="email" type="text" value="<?= isset($this->data['email']) ? $this->data['email']:"" ?>" name="email" />
|
||||
<span class="help-inline">(必填)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="realname">真实姓名</label>
|
||||
<div class="controls">
|
||||
<input id="realname" type="text" value="<?= isset($this->data['realname']) ? $this->data['realname']:"" ?>" name="realname" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="phone">电话</label>
|
||||
<div class="controls">
|
||||
<input id="phone" type="text" value="<?= isset($this->data['phone']) ? $this->data['phone']:"" ?>" name="phone" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="unit">单位</label>
|
||||
<div class="controls">
|
||||
<input id="unit" type="text" value="<?= isset($this->data['unit']) ? $this->data['unit']:"" ?>" name="unit" class="input-block-level" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="address">联系地址</label>
|
||||
<div class="controls">
|
||||
<input id="address" type="text" value="<?= isset($this->data['address']) ? $this->data['address']:"" ?>" name="address" class="input-block-level" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="project_id">项目编号</label>
|
||||
<div class="controls">
|
||||
<input id="project_id" type="text" value="<?= isset($this->data['project_id']) ? $this->data['project_id']:"" ?>" name="project_id" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="project_leader">项目负责人</label>
|
||||
<div class="controls">
|
||||
<input id="project_leader" type="text" value="<?= isset($this->data['project_leader']) ? $this->data['project_leader']:"" ?>" name="project_leader" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="project_type">项目类型</label>
|
||||
<div class="controls">
|
||||
<select id="project_type" name="project_type">
|
||||
<?php if(!empty($this->projectType)) { ?>
|
||||
<?php foreach($this->projectType as $k=>$v) { ?>
|
||||
<?php if(empty($this->data['project_type'])) {?>
|
||||
<?php if($v == "") { ?>
|
||||
<option value="<?= $v ?>" selected="selected"><?= $k ?></option>
|
||||
<?php }else { ?>
|
||||
<option value="<?= $v ?>"><?= $k ?></option>
|
||||
<?php }
|
||||
} else {?>
|
||||
<?php if($v == $this->data['project_type']) { ?>
|
||||
<option value="<?= $v ?>" selected="selected"><?= $k ?></option>
|
||||
<?php }else { ?>
|
||||
<option value="<?= $v ?>"><?= $k ?></option>
|
||||
<?php }
|
||||
}?>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="project_title">项目名称</label>
|
||||
<div class="controls">
|
||||
<input id="project_title" type="text" value="<?= isset($this->data['project_title']) ? $this->data['project_title']:"" ?>" name="project_title" class="input-block-level" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="project">项目介绍</label>
|
||||
<div class="controls">
|
||||
<input id="project" type="text" value="<?= isset($this->data['project']) ? $this->data['project']:"" ?>" name="project" class="input-block-level" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<input type="hidden" name="submit" value="1" />
|
||||
<?php if(!empty($this->href)){?>
|
||||
<input type="hidden" name="href" value="<?= $this->href ?>" />
|
||||
<?php }?>
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
<a href="/account/fetchpwd">忘记密码?</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php if(!empty($this->place)){ ?>
|
||||
<script>
|
||||
var input = $("#register input[name=<?= $this->place ?>]");
|
||||
input.parent('div').parent('div.control-group').addClass('error');
|
||||
input.focus();
|
||||
input.blur(function(e){
|
||||
if(input.val() != '')
|
||||
{
|
||||
input.parent('div').parent('div.control-group').removeClass('error');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
|
@ -216,14 +216,27 @@ class Account extends \Zend_Controller_Plugin_Abstract
|
|||
}
|
||||
|
||||
//注册信息参数
|
||||
public function getParam(\Zend_Controller_Request_Abstract $request)
|
||||
public function getRegisterParam(\Zend_Controller_Request_Abstract $request = NULL)
|
||||
{
|
||||
if(empty($request))
|
||||
{
|
||||
$request = new \Zend_Controller_Request_Http();
|
||||
}
|
||||
$data = array(
|
||||
'username'=>$request->getParam('username'),
|
||||
'password'=>$request->getParam('password'),
|
||||
'confirm_password'=>$request->getParam('confirm_password'),
|
||||
'email'=>$request->getParam('email'),
|
||||
'realname'=>$request->getParam('realname')
|
||||
'username'=>trim($request->getParam('username')),
|
||||
'password'=>trim($request->getParam('password')),
|
||||
'confirm_password'=>trim($request->getParam('confirm_password')),
|
||||
'email' => trim($request->getParam('email')),
|
||||
'realname' => trim($request->getParam('realname')),
|
||||
'phone' => trim($request->getParam('phone')),
|
||||
'unit' => trim($request->getParam('unit')),
|
||||
'address' => trim($request->getParam('address')),
|
||||
'project' => trim($request->getParam('project')),
|
||||
'project_id' => trim($request->getParam('project_id')),
|
||||
'project_type' => trim($request->getParam('project_type')),
|
||||
'project_title' => trim($request->getParam('project_title')),
|
||||
'project_leader'=> trim($request->getParam('project_leader')),
|
||||
'postcode' => trim($request->getParam('postcode')),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use \Helpers\View as view;
|
|||
class RegisterOperate implements \Users\Event\RegisterEvent
|
||||
{
|
||||
private $db; //传入PDO对象
|
||||
public $tbl_member = "tbl_member";
|
||||
public $tbl_member = "users";
|
||||
public $FieldUsername = "username";
|
||||
public $FieldPasword = "password";
|
||||
public $FieldLastlogin = "ts_last_login";
|
||||
|
@ -45,9 +45,9 @@ class RegisterOperate implements \Users\Event\RegisterEvent
|
|||
|
||||
if(!empty($data['username']))
|
||||
{
|
||||
if(!preg_match("/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/",$data['username']))
|
||||
if(!preg_match("/^[a-zA-Z\xa0-\xff_][0-9a-zA-Z\xa0-\xff_]{2,25}$/",$data['username']))
|
||||
{
|
||||
return array('error'=>"用户名应当以字母开头,由字母数字和下划线组成,并且长度在5到16个字符之间",'place'=>'username');
|
||||
return array('error'=>"用户名只能包含字母汉字数字和下划线,并且长度在2到26个字符之间",'place'=>'username');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,14 +86,12 @@ class RegisterOperate implements \Users\Event\RegisterEvent
|
|||
return array('error'=>"请输入正确的电子邮件,推荐使用QQ邮箱和Gmail邮箱",'place'=>'email');
|
||||
}
|
||||
|
||||
if(empty($data['realname']))
|
||||
if(!empty($data['realname']))
|
||||
{
|
||||
return array('error'=>"请输入姓名",'place'=>'realname');
|
||||
}
|
||||
|
||||
if(mb_strlen($data['realname'],"UTF-8")>10 )
|
||||
{
|
||||
return array('error'=>"真实姓名请不要超过10个字",'place'=>'realname');
|
||||
if(mb_strlen($data['realname'],"UTF-8")>10 )
|
||||
{
|
||||
return array('error'=>"真实姓名请不要超过10个字",'place'=>'realname');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -118,7 +116,7 @@ class RegisterOperate implements \Users\Event\RegisterEvent
|
|||
{
|
||||
if($row[$this->FieldUsername] == $data['username'])
|
||||
{
|
||||
return array('error'=>'您的用户名已经注册过账号,您是否<a href="/account/forgotpassword">忘记了密码?</a>','place'=>'username');
|
||||
return array('error'=>'您的用户名已经注册过账号,您是否<a href="/account/fetchpwd">忘记了密码?</a>','place'=>'username');
|
||||
}
|
||||
|
||||
if($row[$this->FieldEmail] == $data['email'])
|
||||
|
@ -148,10 +146,9 @@ class RegisterOperate implements \Users\Event\RegisterEvent
|
|||
return false;
|
||||
}
|
||||
|
||||
$mail_template = "register";
|
||||
$mail_template = "member-register";
|
||||
$mail_data = array(
|
||||
'name'=>$data['realname'],
|
||||
'content'=>$this->getMailContent()
|
||||
);
|
||||
|
||||
$mail = new Mail();
|
||||
|
@ -166,25 +163,11 @@ class RegisterOperate implements \Users\Event\RegisterEvent
|
|||
//邮件内容
|
||||
public function getMailContent()
|
||||
{
|
||||
$sql = "SELECT v.id,v.title,v.thumb,v.status,v.content,m.realname,m.username FROM tbl_voice v
|
||||
LEFT JOIN tbl_member m ON v.userid = m.id
|
||||
WHERE v.status > 0
|
||||
ORDER BY v.id DESC
|
||||
LIMIT 5";
|
||||
$rs = $this->db->query($sql);
|
||||
$latest = $rs->fetchAll();
|
||||
|
||||
|
||||
$content = "";
|
||||
|
||||
foreach($latest as $k=>$v)
|
||||
{
|
||||
if($v['thumb'] != '[]')
|
||||
{
|
||||
$thumb = json_decode($v['thumb'],true);
|
||||
$text = mb_strlen($v['content'],"UTF-8") > 100 ? mb_substr($v['content'],0,100,"UTF-8") : $v['content'];
|
||||
$content .= '<p style="width:100%;overflow:hidden;"><img src="http://www.msgfm.com'.$this->config->upload->urlbase.$thumb[0]['thumb'][400]['url'].'" height="100" style="float:left;margin-right:10px;" />'.$v['title']. ' / ' .$v['realname'].'<br />'.$text.'<br /><a href="http://www.msgfm.com/voice/'.$v['id'].'.html">查看播放</a></p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $content;
|
||||
}//getMailContent();
|
||||
|
|
Loading…
Reference in New Issue