public function index() { $data['title'] = 'Admin'; View::renderadmintemplate('header', $data); View::render('admin/admin', $data); View::renderadmintemplate('footer', $data); }
public function edit($id) { $data['title'] = 'Edit User'; $data['row'] = $this->_model->getuser($id); if (isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; if ($username == '') { $error[] = 'Username is required'; } if ($password == '') { $error[] = 'Password is required'; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error[] = 'Email is not valid'; } if (!$error) { $postdata = array('username' => $username, 'password' => \helpers\password::make($password), 'email' => $email); $where = array('memberID' => $id); $this->_model->update_user($postdata, $where); Session::set('message', 'User Updated'); Url::redirect('admin/users'); } } View::renderadmintemplate('header', $data); View::render('admin/edituser', $data, $error); View::renderadmintemplate('footer', $data); }
public function login() { if (Session::get('loggedin')) { Url::redirect('admin'); } $model = new \models\admin\auth(); $data['title'] = 'Login'; if (isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; if (Password::verify($password, $model->getHash($_POST['username'])) == 0) { $error[] = 'Wrong username of password'; } else { Session::set('loggedin', true); Url::redirect('admin'); } } View::renderadmintemplate('loginheader', $data); View::render('admin/login', $data, $error); View::renderadmintemplate('footer', $data); }
public function edit($id) { $data['title'] = 'Edit Category'; $data['row'] = $this->_model->getcat($id); if (isset($_POST['submit'])) { $catTitle = $_POST['catTitle']; if ($catTitle == '') { $error[] = 'Title is required'; } if (!$error) { $slug = Url::generateSafeSlug($catTitle); $data = array('catTitle' => $catTitle, 'catSlug' => $slug); $where = array('catID' => $id); $this->_model->update_cat($data, $where); Session::set('message', 'Category Updated'); Url::redirect('admin/cats'); } } View::renderadmintemplate('header', $data); View::render('admin/editcat', $data, $error); View::renderadmintemplate('footer', $data); }
public function edit($id) { $data['title'] = 'Edit Post'; $data['row'] = $this->_model->getpost($id); $data['cats'] = $this->_catsmodel->getcats(); if (isset($_POST['submit'])) { $postTitle = $_POST['postTitle']; $postDesc = $_POST['postDesc']; $postCont = $_POST['postCont']; $catID = $_POST['catID']; if ($postTitle == '') { $error[] = 'Title is required'; } if ($postDesc == '') { $error[] = 'Description is required'; } if ($postCont == '') { $error[] = 'Content is required'; } if ($catID == '') { $error[] = 'Select a category'; } if (!$error) { $slug = Url::generateSafeSlug($postTitle); $data = array('postTitle' => $postTitle, 'postSlug' => $slug, 'postDesc' => $postDesc, 'postCont' => $postCont, 'catID' => $catID); if ($_FILES['image']['size'] > 0) { $file = 'images/' . $_FILES['image']['name']; move_uploaded_file($_FILES['image']['tmp_name'], $file); $data['postImg'] = $file; } $where = array('postID' => $id); $this->_model->update_post($data, $where); Session::set('message', 'Post Updated'); Url::redirect('admin/posts'); } } View::renderadmintemplate('header', $data); View::render('admin/editpost', $data, $error); View::renderadmintemplate('footer', $data); }