protected function refreshCurrentUser() { $currUser = $this->getCurrentUser(); $sql = "SELECT * FROM `store` WHERE `ename`='{$currUser['ename']}' limit 1"; $currUser = BaseData::sql($sql); if (!$currUser) { $_SESSION['manage_islogin'] = 0; $_SESSION['manage_user'] = array(); } $_SESSION['manage_user'] = $currUser[0]; return $currUser[0]; }
/** * 订单详情 */ public function detailAction() { $this->mustLogin = 1; $this->mustLoginCheck(); $oid = $this->param('o', ''); $details = array(); $totalPrice = 0; if ($oid) { $oid = ComTool::escape($oid); $sql = "SELECT a.user_id,a.user_name,a.user_tel,a.user_addr,a.create_time,a.total_cost,a.`status`,b.order_id,b.good_id,b.good_name,b.amount,b.price FROM `order` a LEFT JOIN order_detail b on a.id=b.order_id where a.id='{$oid}' and a.`status`='1'"; $details = BaseData::sql($sql); if ($details) { foreach ($details as $detail) { $totalPrice += intval($detail['price'] * $detail['amount']); } } } $this->assign('totalPrice', $totalPrice); $this->assign('details', $details); $this->display(); }
static function editStoreCate($data) { $sql = "UPDATE `store_category` SET `name`='{$data['name']}',`desc`='{$data['desc']}',update_time='{$data['update_time']}' WHERE id='{$data['id']}' AND store_id='{$data['store_id']}'"; $res = BaseData::sql($sql); return $res; }
/** * 小店登录 */ public function manage_loginAction() { $cookieName = "last_login_manage_acc"; $lastLoginManageAcc = ''; //上次登录帐号 $lastLoginManageAcc = Cola_Ext_Cookie::get($cookieName); if (ComTool::isAjax()) { if (isset($_POST['captcha'])) { $captcha = trim($this->post('captcha')); if (!ComTool::checkCaptcha($captcha)) { ComTool::ajax(100001, '验证码错误'); } } //登录可使用邮箱和手机,系统自动判断登录号类型 $acc = trim($this->post('user')); $passwd = trim($this->post('passwd')); /* $token = trim ( $this->post ( 'token' ) ); //合法性检查 if (! $acc || ! $passwd || ! $token) { ComTool::ajax ( 100001, '参数错误6' ); } */ ComTool::checkMaxLen($acc, 32, '用户名最多32位'); ComTool::checkMinMaxLen($passwd, 6, 16, '密码6-16位'); $acc = ComTool::escape($acc); $sql = "SELECT * FROM `store` WHERE `ename`='{$acc}' limit 1"; $user = BaseData::sql($sql); if (empty($user)) { ComTool::ajax(100001, '帐号或密码错误'); } $user = $user[0]; /* $token = base64_decode ( $token ); */ if (md5($passwd) != $user['passwd']) { ComTool::ajax(100001, '帐号或密码错误'); } /* if ($token != $user ['secret']) { ComTool::ajax ( 100001, '参数错误1' ); } */ //上次登录帐号与本次登录帐号不同重新记录COOKIE,3600*24*30 Cola_Ext_Cookie::set($cookieName, $acc, 2592000); //成功则写session $_SESSION['manage_islogin'] = 1; //登录标识 $_SESSION['manage_user'] = $user; $returnUrl = $this->urlroot . 'shop'; ComTool::ajax(100000, '登录成功,即将跳转', $returnUrl); } /* $token = $this->get ( 'token', '' ); if (! $token) { ComTool::redirect ( ComTool::url ( 'acc/login' ) ); } */ $returnUrl = urldecode($this->get('returnUrl', '')); $this->assign('lastLoginAcc', $lastLoginManageAcc); $this->assign('returnUrl', $returnUrl); //$this->assign ( 'token', base64_encode ( $token ) ); $this->display(); }
/** * 删除商品 */ public function delGoodAction() { $currUser = $this->getCurrentUser(); if (ComTool::isAjax()) { $gid = intval($this->post('gid', 0)); $sql = "DELETE FROM `store_goods` WHERE id='{$gid}' and store_id='{$currUser['id']}';"; $res = BaseData::sql($sql); if ($res === false) { ComTool::ajax(100001, '服务器忙,请刷新重试'); } ComTool::ajax(100000, '操作成功'); } }