Ejemplo n.º 1
0
 public function addadminAction()
 {
     $form = new LoginForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $admin = new Model\Admin();
         $form->setInputFilter($admin->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $admin->exchangeArray($form->getData());
             $this->getAdminTable()->saveAdmin($admin);
             var_dump($_SESSION);
             exit;
             return $this->redirect()->toRoute('admin');
         } else {
             throw new \Exception('Твоя гавноформа не проходит валидацию. Иди еби мозги');
         }
     }
     return new ViewModel(['form' => $form]);
 }
Ejemplo n.º 2
0
 public function loginajaxAction()
 {
     $username = $this->params()->fromPost('username');
     $password = $this->params()->fromPost('password');
     $data = array('username' => $username, 'password' => $password);
     if ($username != '' and $password != '') {
         $data = array('username' => $username, 'password' => $password);
         $admin = new Admin();
         $admin->exchangeArray($data);
         $k = $this->getAdminTable()->checklogin($admin);
         //$session_user = new Container('user');
         //return $session_user;
         //echo "k ---";print_r($session_user);die;
         if ($k == 1 || $k == 2) {
             echo 'Incorrect Username or password ';
             die;
         }
         if ($k == 0) {
             echo '';
             die;
             //	$this->redirect()->toUrl(WEBPATH.'/admin');
         }
     } else {
         echo "Error!";
         die;
     }
 }
Ejemplo n.º 3
0
 public function pageregisterAction()
 {
     $this->layout('layout/apoadminlogin');
     if ($this->request->isPost()) {
         $username = addslashes(trim($this->params()->fromPost('username')));
         $email = addslashes(trim($this->params()->fromPost('email')));
         $password = addslashes(trim($this->params()->fromPost('password')));
         $check_user = $this->getAdminTable()->checkuser($username);
         $check_email = $this->getAdminTable()->checkemail($email);
         if ($check_user) {
             $alert = 'This account already exists';
             return array('alert' => $alert);
         } else {
             if ($check_email) {
                 $alert = 'This Email already exists';
                 return array('alert' => $alert);
             } else {
                 $data_user = array('username' => $username, 'password' => $password, 'email' => $email);
                 $admin_model = new Admin();
                 $admin_model->exchangeArray($data_user);
                 $this->getAdminTable()->register($admin_model);
                 $alert = 'Account Registration success';
                 return array('alert' => $alert);
             }
         }
     }
 }