merge heihedata branch to trunk from r4153 to r4159
This commit is contained in:
parent
ee4d32a372
commit
6db4162f06
|
@ -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;
|
||||
|
||||
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()) {
|
||||
|
||||
//注册邮件
|
||||
$mail_template = "member-register";
|
||||
$mail_data = array(
|
||||
'name'=>$formData['username'],
|
||||
);
|
||||
|
||||
$mail = new Mail();
|
||||
|
||||
$mail->loadTemplate($mail_template,$mail_data);
|
||||
$mail->addTo($formData['email'],$formData['username']);
|
||||
$mail->send();
|
||||
|
||||
//自动登录系统
|
||||
$this->login($formData['username'],$formData['password']);
|
||||
$this->_redirect('/');
|
||||
}
|
||||
} else {
|
||||
$form->populate($formData);
|
||||
}
|
||||
}
|
||||
$order = new \Order\Order();
|
||||
|
||||
$this->view->projectType = array_merge(array("无"=>""),$order->projectType);
|
||||
|
||||
$submit = $this->_getParam("submit");
|
||||
|
||||
if(!empty($submit))
|
||||
{
|
||||
$account = new Account();
|
||||
$this->view->data = $data = $account->getRegisterParam();
|
||||
$status = $account->register($data);
|
||||
|
||||
if(isset($status['error']))
|
||||
{
|
||||
$this->view->error = view::Error($status['error']);
|
||||
if(isset($status['place']))
|
||||
{
|
||||
$this->view->place = $status['place'];
|
||||
}
|
||||
}else{
|
||||
view::Post($this,"注册成功!","/");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 = view::Error("验证码错误");
|
||||
$this->view->captcha = $captcha->setCaptcha();
|
||||
return true;
|
||||
}
|
||||
|
||||
$account = new Account();
|
||||
$status = $account->login(array(
|
||||
'username' => $username,
|
||||
|
@ -336,23 +330,18 @@ class AccountController extends Zend_Controller_Action
|
|||
|
||||
if(isset($status['error']))
|
||||
{
|
||||
$this->view->error = $status;
|
||||
$this->view->captcha = $captcha->setCaptcha();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!$captcha->isValid($captchaword))
|
||||
{
|
||||
$this->view->error = "验证码错误";
|
||||
$this->view->error = view::Error($status['error']);
|
||||
$this->view->captcha = $captcha->setCaptcha();
|
||||
return true;
|
||||
}
|
||||
|
||||
view::Post($this,"登录成功,正在跳转",$tohref);
|
||||
return true;
|
||||
}else{
|
||||
$this->view->captcha = $captcha->setCaptcha();
|
||||
}
|
||||
|
||||
$this->view->captcha = $captcha->setCaptcha();
|
||||
|
||||
}
|
||||
|
||||
public function captchaAction()
|
||||
|
|
|
@ -6,21 +6,6 @@
|
|||
$this->breadcrumb('<a href="/account/login">用户登录</a>');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<style>
|
||||
.login_box {
|
||||
max-width: 300px;
|
||||
padding: 19px 29px 29px;
|
||||
margin: 0 auto 20px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #e5e5e5;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
|
||||
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,.05);
|
||||
}
|
||||
</style>
|
||||
<div class="row-fluid">
|
||||
<form class="form-horizontal" method="post">
|
||||
<?php if(empty($this->error)) { ?>
|
||||
|
@ -28,9 +13,7 @@
|
|||
请输入用户名和密码登录
|
||||
</div>
|
||||
<? }else{ ?>
|
||||
<div class="alert alert-error alert-login">
|
||||
<?= $this->error['error'] ?>
|
||||
</div>
|
||||
<?= $this->error ?>
|
||||
<?php } ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="username">用户名</label>
|
||||
|
|
|
@ -1,19 +1,141 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle('用户注册');
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headLink()->appendStylesheet('/css/register.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/account/register">用户注册</a>');
|
||||
$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>
|
||||
</div>
|
||||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle('用户注册');
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headLink()->appendStylesheet('/css/register.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/account/register">用户注册</a>');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<div class="row-fluit">
|
||||
<form class="form-horizontal" method="post" id="register">
|
||||
<?php if(empty($this->error)) { ?>
|
||||
<div class="alert alert-info alert-login">
|
||||
请输入您的基本信息进行注册
|
||||
</div>
|
||||
<? }else{ ?>
|
||||
<?= $this->error ?>
|
||||
<?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 } ?>
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
|
||||
use Users\Member;
|
||||
use Users\Account;
|
||||
use Helpers\View as view;
|
||||
class CustomControllerAclManager extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
// default user role if not logged or (or invalid role found)
|
||||
|
@ -72,31 +76,23 @@
|
|||
|
||||
if(!$this->auth->hasIdentity())
|
||||
{
|
||||
$mb = new member();
|
||||
$mb->db=$this->db;
|
||||
if($mb->checkcookie())
|
||||
$member = new Member();
|
||||
|
||||
if($member->checkcookie())
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$authAdapter = new Zend_Auth_Adapter_DbTable($this->db);
|
||||
$authAdapter->setTableName('users')
|
||||
->setIdentityColumn('username')
|
||||
->setCredentialColumn('password');
|
||||
$authAdapter->setIdentity($mb->user)->setCredential($mb->srpwd);
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
if ($result->isValid()) {
|
||||
$data = $authAdapter->getResultRowObject(null,'password');
|
||||
//头像
|
||||
include_once("Avatar.php");
|
||||
$avatar = new Avatar();
|
||||
$data->avatar = $avatar->Get($data->email,40);
|
||||
|
||||
//组ID
|
||||
include_once("Users.php");
|
||||
$usr = new Users($this->db);
|
||||
$data->gid = $usr->getGroup($data->id);
|
||||
|
||||
$auth->getStorage()->write($data);
|
||||
$this->db->query("update users set ts_last_login=now() where username=?",array($mb->user));
|
||||
$data = array(
|
||||
'username' => $member->user,
|
||||
'password' => $member->srpwd
|
||||
);
|
||||
|
||||
$account = new Account();
|
||||
$status = $account->storeLogin($data,false);
|
||||
|
||||
if(isset($status['error']))
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$auth->clearIdentity();
|
||||
Member::flushcookie();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class View extends \Zend_Controller_Plugin_Abstract
|
|||
$html = '<div class="alert alert-block fade in '.$AlertType.'" id="Alert-error-box">'."\r\n";
|
||||
$html.= '<a class="close" data-dismiss="alert" href="#">×</a>'."\r\n";
|
||||
if(!is_array($content)) {
|
||||
$html.= '<h4 class="alert-heading">'.$content.'</h4>'."\r\n";
|
||||
$html.= ''.$content.''."\r\n";
|
||||
}else{
|
||||
$html.= '<ul>'."\r\n";
|
||||
foreach($content as $v) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ namespace Users;
|
|||
|
||||
class Member
|
||||
{
|
||||
var $ck='DCC3ER4T8L2EFX94OPDF';
|
||||
var $db; //传入PDO对象
|
||||
var $mid; //会员ID
|
||||
public $ck='DCC3ER4T8L2EFX94OPDF';
|
||||
public $db; //传入PDO对象
|
||||
public $mid; //会员ID
|
||||
|
||||
public $scr; //cookie 安全码 $_COOKIE['scr']
|
||||
public $user;//cookie User $_COOKIE['user']
|
||||
|
|
|
@ -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("/[0-9a-zA-Z\xa0-\xff_]{2,25}/",$data['username']))
|
||||
{
|
||||
return array('error'=>"用户名应当以字母开头,由字母数字和下划线组成,并且长度在5到16个字符之间",'place'=>'username');
|
||||
return array('error'=>"用户名只能包含字母汉字数字和下划线,并且长度在2到26个字符之间",'place'=>'username');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,17 +83,15 @@ class RegisterOperate implements \Users\Event\RegisterEvent
|
|||
|
||||
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$data['email']))
|
||||
{
|
||||
return array('error'=>"请输入正确的电子邮件,推荐使用QQ邮箱和Gmail邮箱",'place'=>'email');
|
||||
return array('error'=>"请输入正确的电子邮件地址",'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