Example #1
0
 /**
  * 获取城市下拉列表项目
  *
  */
 public function cityAction()
 {
     header('content-type:text/html; charset=utf-8');
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     //
     $pindex = $this->_request->getParam('pindex');
     $cityStr = '';
     if ($pindex == '-1') {
         $cityStr .= '<option value="-1">请选择城市</option>';
     } else {
         $cityArray = Plugin_Util_ProvinceAndCityFactory::getCityByProvinceArrayIndex($pindex);
         $count = count($cityArray);
         for ($i = 0; $i < $count; $i++) {
             $cityStr .= '<option value="' . $i . '">' . $cityArray[$i] . '</option>';
         }
     }
     echo $cityStr;
 }
Example #2
0
 /**
  * 用户注册Action
  *
  */
 public function registerAction()
 {
     //省份下拉列表项
     $p = Plugin_Util_ProvinceAndCityFactory::getProvince();
     $this->view->p = $p;
     //注册协议
     $agreement = file_get_contents(APPLICATION_PATH . '/resources/agreement.txt');
     $this->view->agreement = $agreement;
     //提交表单后处理用户提交的注册信息
     if ($this->_request->isPost()) {
         $request = $this->_request;
         $pName = $p[$request->getParam('p')];
         $c = Plugin_Util_ProvinceAndCityFactory::getCityByProvinceArrayIndex($request->getParam('p'));
         $cName = $c[$request->getParam('c')];
         //发送邮件
         $arraySmtpConfig = array('auth' => 'login', 'username' => $this->_config['mail']['username'], 'password' => $this->_config['mail']['password']);
         $transport = new Zend_Mail_Transport_Smtp($this->_config['mail']['host'], $arraySmtpConfig);
         $mail = new Zend_Mail('utf-8');
         $mail->setSubject($this->_config['mail']['subject']);
         $mail->setBodyHtml(file_get_contents(APPLICATION_PATH . '/resources/mailBody.txt'));
         $mail->setFrom($this->_config['mail']['from'], $this->_config['mail']['name']);
         $mail->addTo(trim($request->getParam('email')));
         try {
             $mail->send($transport);
         } catch (Zend_Exception $e) {
             $e->getMessage();
         }
         //保存注册信息
         $nowTime = date('Y-m-d H:i:s');
         $ip = $_SERVER['REMOTE_ADDR'];
         $arrayUserInfo = array('netname' => trim($request->getParam('netname')), 'password' => md5(trim($request->getParam('password'))), 'email' => trim($request->getParam('email')), 'fromcity' => $pName . '-' . $cName, 'regtime' => $nowTime, 'regip' => $ip, 'lastlogintime' => $nowTime, 'lastloginip' => $ip, 'usertype' => 0, 'score' => 0, 'friendid' => '', 'spacebrowse' => 0);
         try {
             $this->_user->insert($arrayUserInfo);
         } catch (Zend_Exception $e) {
             $e->getMessage();
         }
         //将用户名保存到session中
         $this->_sessionNamespace->netname = trim($request->getParam('netname'));
         $url = $this->_request->getParam('url');
         if ($url == null) {
             //定位到注册成功页面
             $this->_redirect('/user/success/flag/reg');
         } else {
             $url = str_replace('@', '?', str_replace('$', '&', $url));
             $this->_redirect($url);
         }
         exit;
     }
     //页面信息
     $title = '用户注册-' . $this->_config['pageInfo']['user']['title'] . '-' . $this->_config['pageInfo']['default']['title'];
     $keywords = $this->_config['pageInfo']['user']['keywords'];
     $description = $this->_config['pageInfo']['default']['title'] . '用户注册';
     $this->_setPageInfo($title, $keywords, $description);
 }