public function getproduct() { $http = new Http(); if ($http->get('key1') == 0) { return; } $product = new \models\Product($http->get('key1')); $data['id'] = $http->get('key1'); $data['name'] = $product->getName(); $data['img'] = $product->getImage(); $data['desc'] = $product->getDescription(); $data['price'] = $product->getPrice(); echo $this->render('quickview', $data); }
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'); } }
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)); } } }
/** * Returns post data from reddit for an array of post IDs * @param array $ids Array of post IDs to fetch (type is t3) * @return object The post object returned by reddit */ public static function GetPostsByIds(array $ids) { $retVal = null; $url = 'http://www.reddit.com/by_id/t3_' . implode(',t3_', $ids) . '.json?limit=' . count($ids); $file = Lib\Http::get($url); if (strlen($file)) { $obj = json_decode($file); if (is_object($obj) && isset($obj->data) && is_array($obj->data->children)) { $retVal = $obj->data; } } return $retVal; }
public function deleteShippingMethod() { $http = new Http(); if ($http->isActive('id')) { $shipping_m = new Shippment($http->post('id')); $shipping_m->delete(); echo 1; return ''; } echo 0; }
private static function _downloadImage($url) { $retVal = null; // Account for local files or URLs if (($url[0] === '/' || $url[0] === '.') && is_readable($url) || strpos($url, 'file://') === 0) { $file = file_get_contents($url); } else { $file = Http::get($url); } if ($file) { $type = self::_getImageType($file); if (null !== $type) { $retVal = new stdClass(); $retVal->type = $type; $retVal->timestamp = time(); $retVal->data = $file; // Cache the image self::_saveCacheFile($url, $retVal); } } return $retVal; }
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'); } }
public function delete() { $http = new Http(); if ($http->isActive('yes')) { $this->eraseUser(); } if ($http->isActive('no')) { Location::To(URL . 'user/profile'); } $this->render('delete', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids)); }
protected function search($arg = null) { $http = new Http(); $search = $http->get('search'); $search_m = new Search($search); $pag = new Pagination(2, $search_m->getNumberoOfMached()); $products = $search_m->getProducts(2, $pag->page($arg[1])); $next = $pag->next(); $prev = $pag->prev(); $this->render('search', 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, 'page' => $arg[1], 'tab' => $arg[0], 'search' => $search)); }