public function index()
 {
     $action = isset($_GET['action']) ? $_GET['action'] : 'list';
     $lang = isset($_GET['language']) ? $_GET['language'] : 'list';
     if ($action == 'add') {
         $id = $_GET['id'];
         $this->model->addProduct($id);
         header('Location: /' . $lang . '/carts/index');
     } elseif ($action == 'delete') {
         $id = $_GET['id'];
         $this->model->deleteProduct($id);
         header('Location: /' . $lang . '/carts/index');
     } elseif ($action == 'clear') {
         $this->model->clear();
         header('Location: /' . $lang . '/carts/index');
     } else {
         if ($this->model->isEmpty()) {
             Session::setFlash(__('empty_cart'));
         } else {
             $id_sql = $this->model->getProducts(true);
             if ($id_sql) {
                 $this->data['cart'] = $this->model->getCart($id_sql);
                 $this->data['sum'] = $this->model->getSum($id_sql);
             }
         }
     }
 }
 public function logoutAction($key = 'user')
 {
     Session::remove($key);
     Session::destroy();
     Session::setFlash(__t('you_logout'));
     $this->redirect("/");
 }
 function login_process()
 {
     $form = $this->load->form('login', $_POST);
     if (!$form->validate()) {
         Session::setFlash('next', $form->next->getValue());
         $this->helper->redirect->flash(UrlHelper::referer(), $form->getId(), $form->getFlashParams());
     }
     $values = $form->getValue();
     if ($form->next->getValue()) {
         #Parameters 'auth' => 'login' are passed as a flash to the next page
         $this->view->setRedirect($form->next->getValue(), 'auth', 'login');
     } else {
         $this->view->setRedirect('/');
     }
     $user_id = $this->db->Auth->getUserId($values['username'], $values['password']);
     if (!$user_id && $this->config['old_password']) {
         $user_id = $this->db->Auth->getUserIdFromOldPassword($values['username'], $form->password->getRawValue());
     }
     if (!$user_id) {
         $form->username->setErrorCode('invalid');
         $this->helper->redirect->flash(UrlHelper::referer(), $form->getId(), $form->getFlashParams());
     }
     if (!$this->db->Auth->isEnabled($user_id)) {
         $this->helper->redirect->flash(UrlHelper::referer(), $form->getId(), $form->getFlashParams());
     }
     if (!$this->db->Auth->isActivated($user_id)) {
         $this->helper->redirect->to('/auth/unconfirmed');
     }
     $this->plugin->Auth->login($user_id, $form->remember->isChecked(), $values['module']);
 }
 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $layout = self::$router->getRoute();
     if (Session::get('role') == 'user') {
         Session::setFlash('Welcome!');
     } elseif ($layout == 'admin' && Session::get('role') != 'admin') {
         if ($controller_method != 'admin_login') {
             Router::redirect('/users/admin_login');
         }
     }
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         // Controller`s action may return a view path
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Method' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
Esempio n. 5
0
 public function admin_index()
 {
     if ($_POST) {
         if (isset($_POST['delete'])) {
             $id = isset($_POST['id']) ? $_POST['id'] : 0;
             $id = (int) $id;
             $this->model->deleteNewsById($id);
         } elseif (isset($_POST['change'])) {
             $id = isset($_POST['id']) ? $_POST['id'] : 0;
             $id = (int) $id;
             $title = isset($_POST['title']) ? $_POST['title'] : 0;
             $description = isset($_POST['description']) ? $_POST['description'] : 0;
             $body = isset($_POST['body']) ? $_POST['body'] : 0;
             $is_top = 0;
             if (isset($_POST['is_top'])) {
                 $is_top = 1;
             }
             $this->model->changeNews($id, $title, $description, $body, $is_top);
             Session::setFlash("Новина змінена!");
         } elseif (isset($_POST['add'])) {
             $title = isset($_POST['title']) ? $_POST['title'] : 0;
             $description = isset($_POST['description']) ? $_POST['description'] : 0;
             $body = isset($_POST['body']) ? $_POST['body'] : 0;
             $on_date = isset($_POST['on_date']) ? $_POST['on_date'] : date("Y-m-d");
             $is_top = 0;
             if (isset($_POST['is_top'])) {
                 $is_top = 1;
             }
             $this->model->addNews($title, $description, $body, $is_top, $on_date);
             Session::setFlash("Новина додана!");
         }
     }
     $this->data['news'] = $this->model->getAllNews();
 }
Esempio n. 6
0
 public function index()
 {
     if ($_POST) {
         if ($this->model->save($_POST)) {
             Session::setFlash('Thank You! Your message was sent successfull');
         }
     }
 }
 public function index()
 {
     if ($_POST) {
         if ($this->model->save($_POST)) {
             Session::setFlash('You message successfully sant!');
         }
     }
 }
 public function add()
 {
     if ($_POST) {
         if ($this->model->newClient($_POST)) {
             Session::setFlash('You registered!');
         }
     }
 }
 public function index()
 {
     if ($_POST['name'] && $_POST['email'] && $_POST['message']) {
         if ($this->model->save($_POST)) {
             Session::setFlash("Спасибо! Ваше сообщение было отправлено");
         }
     }
 }
 public function index()
 {
     if ($_POST) {
         if ($this->model->save($_POST)) {
             Session::setFlash("Your message was send. Thanks.");
         }
     }
 }
 public function index()
 {
     if ($_POST) {
         if ($this->model->save($_POST)) {
             Session::setFlash('Ваше сообщение отправлено успешно!');
         }
     }
 }
Esempio n. 12
0
 public function user_user()
 {
     if (isset($this->params[0])) {
         $this->data = $this->model->showUser($this->params[0]);
     } else {
         Session::setFlash('Error');
     }
 }
Esempio n. 13
0
 public function show()
 {
     /*$this->data = $this->model->getList();*/
     if (isset($this->params[0])) {
         $this->data['page'] = $this->model->getById($this->params[0]);
     } else {
         Session::setFlash('Wrong page id.');
         Router::redirect('/admin/pages/');
     }
 }
Esempio n. 14
0
 public function upload()
 {
     if (isset($_FILES['myFile'])) {
         if (!$_FILES['myFile']['error']) {
             move_uploaded_file($_FILES['myFile']['tmp_name'], self::UPL_DIR . $_FILES['myFile']['name']);
             Session::setFlash('Файл успешно загружен');
         } else {
             Session::setFlash('Ошибка. Файл не был отправлен');
         }
     }
 }
Esempio n. 15
0
 public function index()
 {
     if (!is_null($_POST['name']) && !is_null($_POST['email']) && !is_null($_POST['message']) && strlen($_POST['name']) > 0 && strlen($_POST['email']) > 0 && strlen($_POST['message']) > 0) {
         if ($this->model->save($_POST)) {
             Session::setFlash('OK. Message was sent');
         }
     }
     if ($_POST['back']) {
         Router::redirect('/');
     }
 }
 public function admin_delete()
 {
     if (isset($this->params[0])) {
         $result = $this->model->delete($this->params[0]);
         if ($result) {
             Session::setFlash('good was deleted!');
         } else {
             Session::setFlash('Error');
         }
     }
     Router::redirect('/admin/goods/');
 }
Esempio n. 17
0
 public function admin_delete()
 {
     if (isset($this->params[0])) {
         $result = $this->model->delete($this->params[0]);
         if ($result) {
             Session::setFlash("Page was deleted");
         } else {
             Session::setFlash("Error deleting page. Something is wrong (");
         }
     }
     Router::redirect("/admin/pages/");
 }
Esempio n. 18
0
 public function member__login()
 {
     $username = Request::post('username');
     $password = Request::post('password');
     $return = Request::post('return');
     if (Statamic_Auth::login($username, $password)) {
         Session::setFlash('success', 'Success');
     } else {
         Session::setFlash('error', 'Failure');
     }
     URL::redirect(URL::assemble(Config::getSiteRoot(), $return));
 }
 public function admin_delete()
 {
     if (isset($this->params[0])) {
         $result = $this->model->delete($this->params[0]);
         if ($result) {
             Session::setFlash('Страница удалена');
         } else {
             Session::setFlash('Ошибка');
         }
     }
     Router::redirect('/admin/pages/');
 }
 public function index()
 {
     if ($_POST) {
         if ($this->model->save($_POST)) {
             Session::setFlash('Thank you! Your message was sent successfully!');
             echo "Спасибо, форма отправлена!";
         } else {
             echo "Ошибка!!!";
         }
         exit;
     }
 }
Esempio n. 21
0
 public function admin_delete()
 {
     if (isset($this->params[0])) {
         $result = $this->model->delete($this->params[0]);
         if ($result) {
             Session::setFlash('Page was deleted.');
         } else {
             Session::setFlash('Error.');
         }
         Router::redirect('/admin/pages');
     }
 }
Esempio n. 22
0
 public function admin_delete()
 {
     //($this->params[0]); // параметр т.е. ИД пользователя на удаление
     if (isset($this->params[0])) {
         $result = $this->model->delete($this->params[0]);
         if ($result) {
             Session::setFlash(__('user_was_delete', 'User was delete'));
         } else {
             Session::setFlash(__('user_was_not_delete', 'User was not delete'));
         }
     }
     Router::redirect('/admin/allusers/');
 }
 public static function create()
 {
     $form = self::getPostForm();
     if (Helpers::isMethod("post")) {
         $form->setValues($_POST["post"]);
         if ($form->isValid()) {
             DB::query("insert into posts set " . "posted_at = now(),    " . "title     = :title,   " . "content   = :content, " . "email     = :email,   " . "author    = :author   ", array("title" => $form->getChild("title")->getValue(), "content" => $form->getChild("content")->getValue(), "email" => $form->getChild("email")->getValueOrNull(), "author" => $form->getChild("name")->getValue()));
             $id = DB::lastId();
             Session::setFlash("highlight", $id);
             Helpers::redirect("/posts");
         }
     }
     View::set("form", $form);
     View::render("post/create");
 }
 /**
  * действие для странички с контактной формой - Contact
  *
  * @param Request $request
  * @return int
  */
 public function contactAction(Request $request)
 {
     $form = new ContactForm($request);
     if ($request->isPost()) {
         if ($form->isValid()) {
             Session::setFlash('Message sent!');
             header('Location: /contact');
             die;
         } else {
             Session::setFlash('Fail');
         }
     }
     $args = array('form' => $form);
     return $this->render('contact', $args);
 }
 function add_process()
 {
     $this->helper->filter->validate($this->args, array(0 => array('in' => $this->config['items'])));
     if (is_null($this->args[0])) {
         $this->plugin->Error->goto404();
     }
     $params = array('item_id' => 0);
     $form = $this->load->form('addcomment', $_POST, $params);
     $form->validateOrRedirect();
     $values = $form->getTargetValues('comment');
     $values['user_id'] = $this->plugin->Auth->get('user_id');
     $values['item'] = $this->args[0];
     $values['author_ip'] = $_SERVER['REMOTE_ADDR'];
     $comment_id = $this->db->into('comment')->insert($values);
     Session::setFlash('posted', true);
 }
Esempio n. 26
0
 /**
  * действие для странички с контактной формой - Contact
  *
  * @param Request $request
  * @return int
  */
 public function contactAction(Request $request)
 {
     $form = new ContactForm($request);
     if ($request->isPost()) {
         if ($form->isValid()) {
             // todo: email + insert into DB table via MessageModel
             Session::setFlash('Booya! Message sent!');
             // todo: добавить в базовый класс метод redirect($route). Тогда тут будет $this->redirect('contact')
             header('Location: /contact');
             die;
         } else {
             Session::setFlash('Fail');
         }
     }
     $args = array('form' => $form);
     return $this->render('contact', $args);
 }
 function process()
 {
     $this->form->validateOrRedirect();
     $success = true;
     $args = $this->env->getArguments();
     $back = 1;
     if (isset($args['back'])) {
         $back = $args['back'];
     }
     $component = $back == 1 ? $this->env->getComponent() : $this->name;
     $returns = array($new ? 'add' : 'edit', $success, $component);
     Session::setFlash('admin_message_form', $returns);
     if (!$new || $back == 1) {
         return $this->env->getPreviousUrl($back);
     } else {
         return $this->env->getPreviousUrl();
     }
 }
Esempio n. 28
0
 public function postEditPassword()
 {
     $data = \Data::post(array('password_current', 'password', 'password_verify'));
     $UserDataModel = new \App\data_model\User($data);
     $current_password = \App::with('User')->User->select('password')->where('id=?', \App::with('User')->userId())->first()['password'];
     if (\Crypt::hash($data['password_current']) != $current_password) {
         \Session::setFlash('edit-password-errors', array('password_current' => 'That wasn\'t your current password'));
     } else {
         if (!$UserDataModel->verifySetData()) {
             \Session::setFlash('edit-password-errors', $UserDataModel->getErrors());
         } else {
             \App::with('User')->changePassword($UserDataModel['password']);
             \Session::setFlash('edit-success', 'Password Updated!');
         }
     }
     //el
     \View::redirect('/user/edit');
 }
Esempio n. 29
0
 public function admin_edit()
 {
     if ($_POST) {
         $id = isset($_POST['id']) ? $_POST['id'] : null;
         $result = $this->model->save($_POST, $id);
         if ($result) {
             Session::setFlash('Product was saved.');
         } else {
             Session::setFlash('Error.');
         }
         Router::redirect('/admin/products/');
     }
     if (isset($this->params[0])) {
         $this->data['product'] = $this->model->getById($this->params[0]);
     } else {
         Session::setFlash('Wrong page id.');
         Router::redirect('/admin/products/');
     }
 }
Esempio n. 30
0
 /**
  * Execute the Process
  *
  * @todo execute
  * @param $callback
  * @return mixed
  */
 public function execute($callback = "")
 {
     $request = new LoginRequest($_POST);
     if ($request->validate()) {
         $attempt = User::where('username', $request->get('username'))->where('password', Hash::encode($request->get('password')))->where('active', 'yes');
         if ($attempt->exists()) {
             $user = $attempt->first();
             $user->remember_token = Token::create();
             $user->save();
             $_SESSION['user'] = $user();
             return Route::redirect('welcome');
         } else {
             Session::setFlash('flash', 'username/password is incorrect.<br><br>');
             return $callback();
         }
     } else {
         return $callback();
     }
 }