<?php ob_start(); session_start(); //Получаем объект для работы с моделями. $obj = new Shop_model(); //Корзина $count = 0; //Для количества товаров у юзера в корзине. $count = $obj->basketInit(); $l = 0; if (isset($_GET['l'])) { $l = $_GET['l']; } //Проверяем куки, делаем сверку пароля, который пришел с куки и если все ок даем ссылку на личный кабинет и открываем сессию. if (!isset($_SESSION['auth'])) { if (isset($_COOKIE['auth'])) { $auth = json_decode(urldecode($_COOKIE['auth']), true); $password_cookie = $auth['password_cookie']; $id = $auth['id']; if (!$id) { echo 'Вы злосный злоумышленник. Доступ вам запрещен'; exit; } $pass_bd = $obj->get_cookie_hash($id); if ($pass_bd == $password_cookie) { $_SESSION['email'] = $auth['email']; $_SESSION['id'] = $auth['id']; $_SESSION['auth'] = 1; } }
public function add_price($i_id) { include '_checksession.php'; $this->load->helper('form'); $this->load->model(array('price_model', 'item_model', 'shop_model')); $shops = $this->shop_model->get(); $shop_dropdown = array(); foreach ($shops as $id => $shop) { $shop_dropdown[$id] = $shop->name; } $item = new Item_model(); $item->load($i_id); $this->load->library('form_validation'); $this->form_validation->set_rules(array(array('field' => 'price', 'label' => 'Price', 'rules' => 'required|numeric|callback_val_zero|max_length[6]'))); $this->form_validation->set_error_delimiters('<div class="alert alert-danger">' . '<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>', '</div>'); if (!$this->form_validation->run()) { $this->load->view('price_add', array('item' => $item, 'shop_dropdown' => $shop_dropdown)); } else { $price = new Price_model(); $price->user_id = $this->session->user_id; $price->item_id = $i_id; $price->shop_id = $this->input->post('shop'); $price->price = $this->input->post('price'); $price->datetime = date('Y-m-d H:i:s'); $price->save(); $shop = new Shop_model(); $shop->load($price->shop_id); //echo "<pre>";$v = $s;print_r($v);echo gettype($v);die; $this->load->view('price_added', array('item' => $item, 'shop' => $shop)); } }