public function indexAction()
 {
     if ($this->request->isPost()) {
         //保存
         $userObj = new User();
         $data = array();
         $data['username'] = $this->request->getPost('username');
         $data['mobile'] = $this->request->getPost('mobile');
         $password = $this->request->getPost('password');
         $morepassword = $this->request->getPost('morepassword');
         if (empty($data['username'])) {
             return $this->flash->error('请填写用户名');
         }
         if (!preg_match('/^(13|14|15|17|18)\\d{9}$/', $data['mobile'])) {
             return $this->flash->error('电话号码格式不正确');
         }
         if (empty($password)) {
             return $this->flash->error('请填写密码');
         }
         if ($password != $morepassword) {
             return $this->flash->error('密码不一致');
         }
         $data['password'] = Hash::userPassword($password);
         $data['addTime'] = time();
         $where = array('password' => array('=', $data['password']), '__()__' => array('mobile' => array('=', $data['mobile']), '__or__' => array('username' => array('=', $data['username']))));
         $res = $userObj->getUserMsg($where);
         if ($res) {
             return $this->flash->error('用户名或电话已经被注册了亲');
         }
         //保存信息
         $resUser = $userObj->insert($data);
         //保存
         if (!$resUser) {
             $this->flash->error('注册失败');
         } else {
             $this->flash->success('注册成功');
             return $this->response->redirect('admin/login/index');
         }
     }
 }
 public function loginAction()
 {
     if ($this->request->isPost()) {
         $userObj = new User();
         $username = $this->request->getPost('username');
         $password = $this->request->getPost('password');
         if (empty($username) || empty($password)) {
             return $this->flash->error('用户名或密码不能为空');
         }
         $password = Hash::userPassword($password);
         //用户名或电话
         $where = array('password' => array('=', $password), '__()__' => array('mobile' => array('=', $username), '__or__' => array('username' => array('=', $username))));
         $res = $userObj->getUserMsg($where);
         if ($res) {
             $this->flash->success('登陆成功');
             //设置session
             $this->setUserInfoSession($res);
             return $this->response->redirect('admin/index/index');
         }
         return $this->flash->error('用户名或密码错误');
     }
     $this->view->setVars(array('title' => 'fuck11'));
 }
 /**
  * 开始安装
  */
 public function setMysqlAction()
 {
     $this->view->setVars(['style' => 'install']);
     $config = json_decode(file_get_contents(INDEX_ROOT . 'config/mysql.txt'), true);
     extract($config);
     //链接数据库$host.':'.$port, $username, $dbPassword
     $mysqliObj = new \mysqli($host . ':' . $port, $username, $dbPassword);
     //选择数据库
     $selectDb = $mysqliObj->select_db($dbName);
     $version = $mysqliObj->server_info;
     $sqlFile = INDEX_ROOT . '/application/install/sqldata/my_cms.sql';
     $content = $this->turnMysql($sqlFile);
     //$mysqliObj->query("show tables like '{$dbPrefix}%'");
     //设置字符编码
     $mysqliObj->query('set names utf8;');
     //执行数据库插入操作
     foreach ($content as $line) {
         //替换掉前缀
         $line = str_replace('`ajb_', "`{$dbPrefix}", $line);
         preg_match('/^CREATE TABLE/', $line, $lines);
         if ($lines) {
             preg_match('/`(.+)`/', $line, $res);
             $this->flash->success($res[1] . '插入成功');
         }
         if (!empty($line)) {
             $mysqliObj->query($line);
         }
     }
     //保存用户信息
     $userObj = new User();
     $setUser = array('username' => $adminName, 'password' => Hash::userPassword($password), 'addTime' => time());
     $res = $userObj->insert($setUser);
     $this->response->redirect('/install/index/final');
 }