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 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'); } }
/** * 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; }
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; }
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)); }