/** * 催单 */ public function order_hurry() { $v = new \Model\Validation(); $order_id = \Core\URI::kv('id'); $order = \Db\Trade\Order::row(array('order_id' => $order_id, 'user_id' => $this->user->user_id)); $time_start = \Core\Cookie::get('time_start'); $v->required($order)->message('订单不存在', 1000); if (!$v->has_error()) { if (empty($time_start)) { \Core\Cookie::set('time_start', W_START_TIME); //@todo 更新催单时间 $order->hurry_status = 1; $order->hurry_time = W_START_TIME; $order->update(); $v->set_data(\Core\URI::a2p(array('trade' => 'order', 'id' => $order->id))); } else { if (W_START_TIME - $time_start > 600) { //@todo 更新催单时间 $order->hurry_status = 1; $order->hurry_time = W_START_TIME; $order->update(); $v->set_data(\Core\URI::a2p(array('trade' => 'order', 'id' => $order->id))); } $v->required(false)->message('已经收到,正在加急处理', 1000); } } $v->send(); }
/** * 保存 */ public function save() { $slide_pic = \Core\URI::kv('ajax_image'); $slide_target = \Core\URI::kv('slide_target'); $slide_link = \Core\URI::kv('slide_link'); $slide_title = \Core\URI::kv('slide_title'); $slide_order = \Core\URI::kv('slide_order'); $v = new \Core\Validation(); $v->required($slide_pic)->message('图片不能为空'); $v->required($slide_target)->message('打开方式不能为空'); $v->required($slide_order)->message('排序值不能为空'); if (!$v->has_error()) { $slide_id = \Core\URI::kv('slide_id', null); $link = new \DB\Mall\Slide($slide_id); $link->slide_pic = $slide_pic; $link->slide_target = $slide_target; $link->slide_link = $slide_link; $link->slide_title = $slide_title; $link->slide_order = $slide_order; $link->save(); } else { \Core\Cookie::set('message', $v->get_error('message')); } $errors = $v->get_error(); echo json_encode($errors); exit; }
function cookie($name = null, $value = null, $expire = 0) { if ($value) { return Cookie::set($name, $value, $expire); } return Cookie::get($name); }
public function create_cart() { // Generate hash of new cart for cookie $hash = sha1(microtime() . Text::random()); // Save cart into database $this->_cart_id = Arr::get(DB::insert('carts', array('hash', 'created_at'))->values(array($hash, time()))->execute(), 0); // Save cart to cookie Cookie::set('cart', $hash, 60 * 60 * 24 * 365); return true; }
public function addViewed($id) { $ids = $this->getViewedIDs(); if (!in_array($id, $ids)) { $ids[] = $id; $json = json_encode($ids); $base64 = base64_encode($json); Cookie::set('viewed', $base64, 60 * 60 * 24 * 30); setcookie('viewed', $base64, 60 * 60 * 24 * 30, '/'); } return; }
/** * 订单 详情 */ public function detail() { \Core\View::css('/manage/datetimepicker/css/bootstrap-datetimepicker.min.css'); \Core\View::script('/manage/datetimepicker/js/bootstrap-datetimepicker.js'); \Core\View::script('/manage/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js'); $this->view->content = view('order/detail.php'); $order_id = \Core\URI::kv('order_id'); $v = new \Core\Validation(); $v->required($order_id)->message('参数错误'); if ($v->has_error()) { \Core\Cookie::set('message', $v->get_error('message')); redirect(\Core\URI::a2p(array('order' => 'index'))); } $this->view->content->row = new \Db\Trade\Order($order_id); }
/** * 登录 */ public function login() { $account = \Core\URI::kv('user_account'); $password = \Core\URI::kv('user_password'); $v = new \Core\Validation(); $v->filter_var(filter_var($account, FILTER_VALIDATE_EMAIL))->message('邮箱帐号错误'); if ($v->has_error()) { \Core\Cookie::set('error', $v->get_error('message')); } else { $gen_password = \DB\Authorize\Admin::gen_password($password); $row = \DB\Authorize\Admin::row(array('admin_account' => $account, 'admin_password' => $gen_password)); //var_dump(!empty($row->admin_account));exit(); if (!empty($row->admin_account)) { \Db\Log::message('登录', '', $row->admin_name); \Core\Session::set('admin_id', $row->admin_id); redirect(\Core\URI::a2p(array('order' => 'index'))); } } redirect(\Core\URI::a2p(array('main' => 'index'))); }
/** * Check if user want to remember his password * If true - auth him */ public function is_remember() { if (User::info()) { return false; } if (!isset($_COOKIE[$this->_session])) { return false; } $cookie = Cookie::getArray($this->_session); if (!isset($cookie['remember']) || (int) $cookie['remember'] == 0) { return false; } if (!isset($cookie['id']) || (int) $cookie['id'] == 0) { return false; } if (isset($cookie['exit']) && (int) $cookie['exit'] == 1) { return false; } if (!isset($cookie['exit'])) { Cookie::set($this->_session, array('remember' => (int) $cookie['remember'], 'exit' => 0, 'id' => $cookie['id']), 60 * 60 * 24 * 7); } $user = DB::select($this->_tbl . '.*', array($this->_tbl_roles . '.alias', 'role'))->from($this->_tbl)->join($this->_tbl_roles)->on($this->_tbl . '.role_id', '=', $this->_tbl_roles . '.id')->where($this->_tbl . '.status', '=', 1)->where($this->_tbl . '.id', '=', $cookie['id']); if (APPLICATION) { $user->where($this->_tbl_roles . '.alias', '!=', 'user'); } else { $user->where($this->_tbl_roles . '.alias', '=', 'user'); } $user = $user->find(); if (!$user) { return false; } if ($this->auth($user, $cookie['remember'])) { HTTP::redirect(Arr::get($_SERVER, 'REQUEST_URI')); } return false; }