diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php index d5cf52af..a2fb8f50 100755 --- a/application/default/controllers/AccountController.php +++ b/application/default/controllers/AccountController.php @@ -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 = $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 = "验证码错误"; + $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{ diff --git a/application/default/views/scripts/account/register.phtml b/application/default/views/scripts/account/register.phtml index cf161a9b..7d6bded9 100755 --- a/application/default/views/scripts/account/register.phtml +++ b/application/default/views/scripts/account/register.phtml @@ -1,19 +1,143 @@ -headTitle($this->config->title->site); - $this->headTitle('用户注册'); - $this->headTitle()->setSeparator(' - '); - $this->headLink()->appendStylesheet('/css/register.css'); - $this->breadcrumb('首页'); - $this->breadcrumb('用户注册'); - $this->breadcrumb()->setSeparator(' > '); -?> -
-
-  确认服务条款   -    -  填写基本信息   -    -  注册完成 - form;?> -
-
\ No newline at end of file +headTitle($this->config->title->site); + $this->headTitle('用户注册'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/register.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('用户注册'); + $this->breadcrumb()->setSeparator(' > '); +?> +
+
+ error)) { ?> + + + + +
+ +
+ " name="username" /> + (必填) +
+
+
+ +
+ + (必填) +
+
+
+ +
+ + (必填) +
+
+
+ +
+ " name="email" /> + (必填) +
+
+
+ +
+ " name="realname" /> +
+
+
+ +
+ " name="phone" /> +
+
+
+ +
+ " name="unit" class="input-block-level" /> +
+
+
+ +
+ " name="address" class="input-block-level" /> +
+
+
+ +
+ " name="project_id" /> +
+
+
+ +
+ " name="project_leader" /> +
+
+
+ +
+ +
+
+
+ +
+ " name="project_title" class="input-block-level" /> +
+
+
+ +
+ " name="project" class="input-block-level" /> +
+
+
+ + href)){?> + + + + 忘记密码? +
+
+
+place)){ ?> + + \ No newline at end of file diff --git a/application/module/Users/Account.php b/application/module/Users/Account.php index e5679992..0f94658e 100644 --- a/application/module/Users/Account.php +++ b/application/module/Users/Account.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; } diff --git a/application/module/Users/Operation/RegisterOperate.php b/application/module/Users/Operation/RegisterOperate.php index 9d3c006a..8c98724a 100644 --- a/application/module/Users/Operation/RegisterOperate.php +++ b/application/module/Users/Operation/RegisterOperate.php @@ -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'=>'您的用户名已经注册过账号,您是否忘记了密码?','place'=>'username'); + return array('error'=>'您的用户名已经注册过账号,您是否忘记了密码?','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 .= '

'.$v['title']. ' / ' .$v['realname'].'
'.$text.'
查看播放

'; - } - } + return $content; }//getMailContent();