public function page($arg) { $page = new Page($arg[0]); $page_args['title'] = "<title>" . $page->getTitle() . "</title>"; $page_args['header'] = $page->getHeader(); $page_args['style'] = "<style>" . $page->getStyle() . "</style>"; $page_args['content'] = $page->getContent(); if (empty($page_args['content'])) { Location::To(URL . 'error'); } $this->render('page', array('categories' => $this->categories, 'd_product' => $this->d_product, 'page' => $page_args)); }
public function activate() { $http = new Http(); $id = $http->get('id'); $date = $http->get('register'); if (!empty($id) && !empty($date)) { $activation = new \models\Activation(); if ($activation->check($id, $date)) { $user = new Users($id); $user->setActive(); $user->writeData(true); Location::To(URL . 'success/success/Aktywacja powiodła się możesz teraz się zalogować.'); } else { Location::To(URL . 'error'); } } else { Location::To(URL . 'error'); } }
private function check() { $admin = \Lib\Session::get('admin'); $id = \Lib\Session::get('id'); $login = \Lib\Session::get('login'); $admin_mode = $this->http->post('admin'); if (!$admin) { if ($this->http->isActive('login') && $admin_mode) { $login = $this->http->post('login'); $password = $this->http->post('password'); if ($login == ADMIN_LOGIN && $password == ADMIN_PASSWORD) { \Lib\Session::set('admin', true); Location::To(URL . 'admin'); } else { $this->render('Login', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids, 'error' => 'Nieprawidłowa nazwa użytkownika lub hasło.')); } } } else { Location::To(URL . 'admin'); } if (empty($id) || empty($login)) { if ($this->http->isActive('login') && !$admin_mode) { $this->m_login = new \Models\Login(); if ($this->m_login->login($this->http->post('login'), $this->http->post('password'))) { if ($this->m_login->isActivated($this->http->post('login'))) { \Lib\Session::set('id', $this->m_login->getId()); \Lib\Session::set('login', $this->m_login->getLogin()); Location::intended(URL . 'user'); } else { $this->render('Login', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids, 'error' => 'Konto jest nieaktywne.')); } } else { $this->render('Login', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids, 'error' => 'Nieprawidłowa nazwa użytkownika lub hasło.')); } } else { $this->render('login', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids)); } } else { Location::To(URL . 'user'); } }
public function __construct() { if (\Lib\LoginVal::isLogged()) { Location::To(URL . 'user'); } parent::__construct(); $http = new Http(); $this->categories_m = new \models\Categories(); $this->categories = $this->categories_m->getCategories(); $this->products_m = new \models\Products(); $this->d_product = $this->products_m->getDayProduct(); $this->category_ids = $this->categories_m->getCategoriesIds(); if (!$http->isActive('login')) { $this->render('register', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids)); } else { $passVal = new \lib\PassVal("Nieprawidłowe hasło", "Hasła nie są takie same.", 5, 15); $validator = new Validator(array('login' => new \lib\LoginVal("Podana nazwa użytkownika jest zajęta.", "Nieprawidłowa nazaw użytkownika.", 5, 15), 'email' => new \lib\EmailVal("Nieprawidłowy email."), 'password' => $passVal, 'password_2' => $passVal, 'accept' => new \lib\CheckBoxVal("Nie zaznaczono pola z akceptacją regulaminu."))); if ($validator->validate($http->post())) { $this->register($http->post()); $user = new \models\User($this->id); $date = $user->getRegistrationDate(); $subject = 'Aktywacja Konta'; $message = 'W celu aktywowania Konta kliknij <a href="' . URL . 'activation/activate?id=' . $this->id . '®ister=' . $date . '">Tutaj</a>'; $altmessage = 'W celu aktywacji konta odwiedź podany adres:' . URL . 'activation/activate?id=' . $id . '®ister=' . $date; $email = new Email(); if ($email->send($http->post('email'), $subject, $message, $altmessage)) { Location::To(URL . 'success/success/Sprawdź email w celu aktywacji konta.'); } else { Location::To(URL . 'error'); } } else { $this->errors = $validator->getErrors(); $this->render('register', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids, 'errors' => $this->errors)); } } }
private function finalize() { $user = new User(\Lib\Session::get('id')); $name = $user->getFirstName(); $surname = $user->getSurname(); $country = $user->getCountry(); $zipcode = $user->getZipCode(); $city = $user->getCity(); $street = $user->getStreet(); $house = $user->getHousNr(); $appartment = $user->getAppartmentNr(); $order_details = new Order_details(); $order_details->setAddress('Imie: ' . $user->getFirstName() . ' Nazwisko: ' . $user->getSurname() . ' Kraj: ' . $user->getCountry() . ' Kod-Pocztowy: ' . $user->getZipCode() . ' Miasto: ' . $user->getCity() . ' Ulica : ' . $user->getStreet() . ' Nr domu: ' . $user->getHousNr() . ' Nr mieszkania: ' . $user->getAppartmentNr()); $time = time(); $id = \Lib\Session::get('id'); $rand = rand(1, 100); $nr = $id . $time . $rand; $order_details->setOrderNr($nr); $order_details->setDisplaySeller(true); $order_details->setDisplayUser(true); $sm = $this->http->get('shipping_method'); if (empty($sm)) { Location::To(URL . 'cart/show'); } $order_details->setShippingMethodId($sm); $order_details->setDate(); $order_details->setStatus(1); $cart = \Lib\Session::get('cart'); if (!empty($cart)) { $db = Register::get('db'); $db->query('START TRANSACTION'); $id = $order_details->writeData(); foreach ($cart as $product) { $order = new Order($product['order_id']); $order->setActive(1); $order->setOrderDetailsId($id); $order->writeData(true); if (!$order->writeData(true)) { $db->query('ROLLBACK'); return false; } } if ($id) { $db->query('COMMIT'); } else { $db->query('ROLLBACK'); return false; } $mess = $this->http->get('message'); if (!empty($mess)) { $mesage = new Message(); $mesage->setUserId(\lib\Register::get('id')); $mesage->setReaded(false); $mesage->setSeller(false); $mesage->setMessage($order_details->getOrderNr() . ': ' . $this->http->get('message')); $mesage->setDate(); $mesage->setDisplayUser(true); $mesage->setDisplaySeller(true); $mesage->writeData(); } \Lib\Session::delete('cart'); $this->ActNumberOfProducts(); return true; } }
public function complete() { $http = new Http(); $id = $http->get('id'); $rand = $http->get('rand'); $email = $http->get('email'); if ($http->isActive('change')) { $id = $http->post('id'); $rand = $http->post('rand'); $email = $http->post('email'); } if (!empty($id) && !empty($rand) && $email) { $pass = new \models\PasswordRecovery($email); if ($pass->checkUserToChange($id, $rand)) { if ($http->isActive('change')) { $pass_1 = $http->post('password'); $pass_2 = $http->post('password_2'); $passVal = new \lib\PassVal("Nieprawidłowe hasło", "Hasła nie są takie same.", 5, 15); $validator = new \lib\Validator(array('password' => $passVal, 'password_2' => $passVal)); if ($validator->validate($http->post())) { $user = new Users($id); $user->setPassword($pass_1); $user->writeData(true); $pass->deleteUserToChange($id); $message = 'Twoje hało zostalo zmienione .'; Location::To(URL . 'success/success/' . $message); } else { $this->errors = $validator->getErrors(); $this->render('changepassword', array('categories' => $this->categories, 'd_product' => $this->d_product, 'id' => $id, 'rand' => $rand, 'email' => $email, 'errors' => $this->errors)); } } $this->render('changepassword', array('categories' => $this->categories, 'd_product' => $this->d_product, 'id' => $id, 'rand' => $rand, 'email' => $email)); } else { Location::To(URL . 'error'); } } else { Location::To(URL . 'error'); } }
private function eraseUser() { $message_m = new \Models\Messages(\lib\Register::get('id')); $messages = $message_m->getMessages(); if (!empty($messages)) { foreach ($messages as $message) { $message_m->deleteMessages($message->getId()); } } $user_e = new \models\User(\lib\Register::get('id')); $user_e->delete(); $user = new \models\Users(\lib\Register::get('id')); $user->delete(); Location::To(URL . 'logout'); }
private function logout() { \Lib\Session::deleteAll(); Location::To(URL . 'home'); }
protected function productlist($arg = null) { $tab = $this->checkArg($arg); $http = new Http(); if ($http->isActive('sub_cat')) { $arg[2] = $http->get('sub_cat'); $arg[3] = $http->get('sort'); Location::To(URL . 'product/productlist/' . $arg[0] . '/' . $arg[1] . '/' . $arg[2] . '/' . $arg[3] . '/0'); } $pagination = $this->sort($arg); $pag = $pagination['pagination']; $sub_categories_m = new SubCategories(); $sub_cats = $sub_categories_m->getSubCategories(); $sub_cats_array = array(); if (!empty($sub_cats)) { foreach ($sub_cats as $key => $c) { $sub_cats_array[$key]['name'] = $c->getSubCategoryName(); $sub_cats_array[$key]['id'] = $c->getSubCategoryId(); } } $products = $pagination['products']; $next = $pag->next(); $prev = $pag->prev(); $this->render('products', array('categories' => $this->categories, 'products' => $products, 'ids' => $this->category_ids, 'slider' => $this->slider, 'd_product' => $this->d_product, 'next' => $next, 'prev' => $prev, 'action' => $this->action, 'promo' => true, 'sub_categories' => $sub_cats_array, 'category' => $arg[1], 'sub_category' => $arg[2], 'order' => $arg[3], 'page' => $arg[4], 'tab' => $tab)); }