public function authAdmin() { if (isset($_SESSION['admlog']) && isset($_SESSION['admpass'])) { $email = $_SESSION['admlog']; $pass = $_SESSION['admpass']; $chek_admin = Model_Admin::getByField(__CLASS__, $this->table, "email", $email); if (!password_verify($pass, $chek_admin->password)) { app::redirect("/admin/auth"); exit; } return true; } else { app::redirect('/admin/auth'); exit; } }
public function actionConfig() { $this->model->authAdmin(); if ($this->isPost()) { if ($this->request->deletAdmin !== '') { $chengAdmin = Model_Admin::getByField('Model_Admin', 'admin', "email", $this->request->deletAdmin); $chengAdmin->delete(); //app::redirect($_SERVER['HTTP_REFERER']); } if ($this->request->emailAdmin !== '' && $this->request->passAdmin !== '') { $newAdmin = new Model_Admin(); $newAdmin->email = $this->request->emailAdmin; $newAdmin->password = password_hash($this->request->passAdmin, PASSWORD_BCRYPT); $newAdmin->create = time(); $newAdmin->save(); //app::redirect($_SERVER['HTTP_REFERER']); } if ($this->request->action != "") { $action = $this->request->action; switch ($action) { case "addCat": $name = $this->request->addCategory; AbstractModel::insert('category', compact('name')); //app::redirect($_SERVER['HTTP_REFERER']); break; case "delCat": $id = (int) $this->request->deletCategory; AbstractModel::deleteOnId("category", $id); //app::redirect($_SERVER['HTTP_REFERER']); break; } } } $this->view->categorys = Model_Category::getAll('Model_Category', "category"); $this->view->admins = Model_Admin::getAll('Model_Admin', "admin"); $this->view->render('config'); $this->view->display(); }