public function setCookie(ICookie $Cookie) { $name = $Cookie->getName(); if (empty($name)) { return false; } $name = $this->getNewOrExistingKeyInArray($name, $this->cookies); $this->cookies[$name] = $Cookie; }
/** * @param ICookie $cookie * @param $key * @param $value */ protected function attachKeyValuePair(ICookie $cookie, $key, $value) { if ($key == 'max-age') { $cookie->setMaxAge(intval($value)); } else { if ($key == 'path') { $cookie->setPath($value); } else { if ($key == 'domain') { $cookie->setDomain($value); } else { if ($key == 'expires') { return; } else { $cookie->setName($key); $cookie->setValue($value); } } } } }
function delask() { $id = IFilter::act(IReq::get('id')); if (empty($id)) { $this->message('留言ID不能为空'); } $ids = is_array($id) ? join(',', $id) : $id; $adminuid = ICookie::get('adminuid'); $where = " id in({$ids})"; $this->mysql->delete(Mysite::$app->config['tablepre'] . 'ask', $where); $this->success('操作成功'); }
public function singlelist() { $this->checkshoplogin(); $shopid = ICookie::get('adminshopid'); if ($shopid <= 0) { $this->message('获取失败'); } $pageinfo = new page(); $pageinfo->setpage(IReq::get('page')); $data['list'] = $this->mysql->getarr("SELECT * FROM " . Mysite::$app->config['tablepre'] . "shop_single WHERE shop_id={$shopid} ORDER BY single_id DESC LIMIT " . $pageinfo->startnum() . ", " . $pageinfo->getsize() . " "); $shuliang = $this->mysql->counts("SELECT * FROM " . Mysite::$app->config['tablepre'] . "shop_single WHERE shop_id={$shopid}"); $pageinfo->setnum($shuliang); $data['pagecontent'] = $pageinfo->getpagebar(); Mysite::$app->setdata($data); }
function goodsupload() { $link = IUrl::creatUrl('member/login'); if ($this->member['uid'] == 0 && $this->admin['uid'] == 0) { $this->message('未登陆', $link); } $type = IReq::get('type'); $goodsid = intval(IReq::get('goodsid')); $shopid = ICookie::get('adminshopid'); if ($shopid < 0) { echo '无权限操作'; exit; } if (is_array($_FILES) && isset($_FILES['imgFile'])) { $json = new Services_JSON(); $uploadpath = 'upload/shop/'; $filepath = '/upload/shop/'; $upload = new upload($uploadpath, array('gif', 'jpg', 'jpge', 'doc', 'png')); //upload $file = $upload->getfile(); if ($upload->errno != 15 && $upload->errno != 0) { echo "<script>parent.uploaderror('" . json_encode($upload->errmsg()) . "');</script>"; } else { if ($goodsid > 0 && $shopid > 0) { $data['img'] = $filepath . $file[0]['saveName']; $this->mysql->update(Mysite::$app->config['tablepre'] . 'goods', $data, "id='" . $goodsid . "' and shopid='" . $shopid . "'"); } echo "<script>parent.uploadsucess('" . $filepath . $file[0]['saveName'] . "');</script>"; } exit; } $imgurl = ''; if ($goodsid > 0 && $type == 'goods') { $temp = $this->mysql->select_one("select img from " . Mysite::$app->config['tablepre'] . "goods where id='" . $goodsid . "' and shopid='" . $shopid . "'"); $imgurl = $temp['img']; } Mysite::$app->setdata(array('type' => $type, 'goodsid' => $goodsid, 'imgurl' => $imgurl)); }
function search_list() { $this->word = IFilter::act(IReq::get('word'), 'text'); $cat_id = IFilter::act(IReq::get('cat'), 'int'); if (preg_match("|^[\\w\\s*-�*]+\$|", $this->word)) { //搜索关键字 $tb_sear = new IModel('search'); $search_info = $tb_sear->getObj('keyword = "' . $this->word . '"', 'id'); //如果是第一页,相应关键词的被搜索数量才加1 if ($search_info && intval(IReq::get('page')) < 2) { //禁止刷新+1 $allow_sep = "30"; $flag = false; $time = ICookie::get('step'); if (isset($time)) { if (time() - $time > $allow_sep) { ICookie::set('step', time()); $flag = true; } } else { ICookie::set('step', time()); $flag = true; } if ($flag) { $tb_sear->setData(array('num' => 'num + 1')); $tb_sear->update('id=' . $search_info['id'], 'num'); } } elseif (!$search_info) { //如果数据库中没有这个词的信息,则新添 $tb_sear->setData(array('keyword' => $this->word, 'num' => 1)); $tb_sear->add(); } } else { IError::show(403, '请输入正确的查询关键词'); } $this->cat_id = $cat_id; $this->redirect('search_list'); }
public function CreateImage(&$text = '') { $ini = microtime(true); /** Initialization */ $this->ImageAllocate(); /** Text insertion */ $text = $this->GetCaptchaText(); $fontcfg = $this->fonts[array_rand($this->fonts)]; $this->WriteText($text, $fontcfg); ICookie::set('Captcha', $text, 2592000); /** Transformations */ $this->WaveImage(); if ($this->blur && function_exists('imagefilter')) { imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR); } $this->ReduceImage(); if ($this->debug) { imagestring($this->im, 1, 1, $this->height - 8, "{$text} {$fontcfg['font']} " . round((microtime(true) - $ini) * 1000) . "ms", $this->GdFgColor); } /** Output */ $this->WriteImage(); $this->Cleanup(); }
function cart() { $data['sitetitle'] = '购物车'; $gooids = $_COOKIE["market_id"]; $market_count = $_COOKIE["market_count"]; if (empty($gooids)) { $this->message('购物车商品为空'); } $gidinfo = explode(',', $gooids); $gidconut = explode(',', $market_count); $tempids = array(); foreach ($gidinfo as $key => $value) { if (intval($value) > 0) { $tempids[$value] = $gidconut[$key]; } } $cartlist = array(); $goodsshu = 0; $query = join(',', array_keys($tempids)); if (!empty($query)) { $goodsinfo = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "goods where id in(" . $query . ") and shopid =0"); foreach ($goodsinfo as $key => $value) { $value['buycount'] = $tempids[$value['id']]; $value['sum'] = $value['buycount'] * $value['cost']; $cartlist[] = $value; $goodsshu += $value['buycount']; } } $data['cartlist'] = $cartlist; //获取配送费 $checkps = $this->pscost(array('shopid' => 0), $goodsshu); if ($checkps['canps'] != 1) { $link = IUrl::creatUrl('site/guide'); $this->message('该店铺不在配送范围内', $link); } $data['pscost'] = $checkps['pscost']; $psinfo = unserialize(Mysite::$app->config['psset']); $data['areainfo'] = ''; $nowID = ICookie::get('myaddress'); $data['locationtype'] = $psinfo['locationtype']; if ($psinfo['locationtype'] == 1) { //百度地图 $data['areainfo'] = ICookie::get('mapname'); if (empty($data['areainfo'])) { $link = IUrl::creatUrl('site/guide'); $this->message('请先选择您所在区域在进行下单', $link); } } else { $data['areainfo'] = ICookie::get('mapname'); if (empty($nowID)) { $link = IUrl::creatUrl('site/guide'); $this->message('请先选择您所在区域在进行下单', $link); } } $data['myaddressslist'] = array(); $tempre = ''; if (!empty($nowID)) { $area_grade = Mysite::$app->config['area_grade']; $temp_areainfo = ''; if ($area_grade > 1) { $areainfocheck = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id=" . $nowID . ""); if (!empty($areainfocheck)) { $areainfocheck1 = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id=" . $areainfocheck['parent_id'] . ""); if (!empty($areainfocheck1)) { $temp_areainfo = $areainfocheck1['name']; if ($area_grade > 2) { $areainfocheck2 = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id=" . $areainfocheck1['parent_id'] . ""); if (!empty($areainfocheck2)) { $temp_areainfo = $areainfocheck2['name'] . $temp_areainfo; } } } $tempre = $temp_areainfo . $tempre; } } if ($this->member['uid'] > 0) { $data['myaddressslist'] = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "address where areaid" . $area_grade . "=" . $nowID . ""); } } if (isset($data['myaddressslist']['address'])) { $data['areainfo'] = $tempre . $data['myaddressslist']['address']; } else { $data['areainfo'] = $tempre . $data['areainfo']; } //获取默认配送所有地址 $data['open_acout'] = Mysite::$app->config['open_acout']; $data['paylist'] = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "paylist order by id desc "); // $data['starttime'] = Mysite::$app->config['marketstarttime']; $data['marketlong'] = Mysite::$app->config['marketlong']; $data['juanlist'] = array(); if (!empty($this->member['uid'])) { $data['juanlist'] = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "juan where uid ='" . $this->member['uid'] . "' and status = 1 and endtime > " . time() . " order by id desc limit 0,20"); } Mysite::$app->setdata($data); }
/** * 生成订单 */ function cart3() { $accept_name = IFilter::act(IReq::get('accept_name')); $province = IFilter::act(IReq::get('province'), 'int'); $city = IFilter::act(IReq::get('city'), 'int'); $area = IFilter::act(IReq::get('area'), 'int'); $address = IFilter::act(IReq::get('address')); $mobile = IFilter::act(IReq::get('mobile')); $telphone = IFilter::act(IReq::get('telphone')); $zip = IFilter::act(IReq::get('zip')); $delivery_id = IFilter::act(IReq::get('delivery_id'), 'int'); $accept_time = IFilter::act(IReq::get('accept_time')); $payment = IFilter::act(IReq::get('payment'), 'int'); $order_message = IFilter::act(IReq::get('message')); $ticket_id = IFilter::act(IReq::get('ticket_id'), 'int'); $taxes = IFilter::act(IReq::get('taxes'), 'float'); $insured = IFilter::act(IReq::get('insured'), 'float'); $tax_title = IFilter::act(IReq::get('tax_title'), 'text'); $gid = IFilter::act(IReq::get('direct_gid'), 'int'); $num = IFilter::act(IReq::get('direct_num'), 'int'); $type = IFilter::act(IReq::get('direct_type')); //商品或者货品 $promo = IFilter::act(IReq::get('direct_promo')); $active_id = IFilter::act(IReq::get('direct_active_id'), 'int'); $order_no = Order_Class::createOrderNum(); $order_type = 0; $dataArray = array(); //防止表单重复提交 if (IReq::get('timeKey') != null) { if (ISafe::get('timeKey') == IReq::get('timeKey')) { IError::show(403, '订单数据不能被重复提交'); exit; } else { ISafe::set('timeKey', IReq::get('timeKey')); } } if ($province == 0 || $city == 0 || $area == 0) { IError::show(403, '请填写收货地址的省市地区'); } if ($delivery_id == 0) { IError::show(403, '请选择配送方式'); } $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id']; //活动特殊处理 if ($promo != '' && $active_id != '') { //团购 if ($promo == 'groupon') { $hashId = $user_id ? $user_id : ICookie::get("regiment_{$active_id}"); //此团购还存在已经报名但是未付款的情况 if (regiment::hasJoined($active_id, $hashId) == true) { IError::show(403, '您已经参加过此次团购,请先完成支付'); exit; } //团购已经达到限定的人数 if (regiment::isFull($active_id) == true) { IError::show(403, '此团购的参加人数已满'); exit; } $order_type = 1; //团购开始报名 $joinUserId = $user_id ? $user_id : null; $resultData = regiment::join($active_id, $joinUserId); $is_success = ''; if ($resultData['flag'] == true) { $regimentRelationObj = new IModel('regiment_user_relation'); $regimentRelationObj->setData(array('order_no' => $order_no)); $is_success = $regimentRelationObj->update('id = ' . $resultData['relation_id']); } if ($is_success == '' || $resultData['flag'] == false) { $errorMsg = isset($resultData['data']) && $resultData['data'] != '' ? $resultData['data'] : '团购报名失败'; IError::show(403, $errorMsg); exit; } } else { if ($promo == 'time') { $order_type = 2; } } } //付款方式,判断是否为货到付款 $deliveryObj = new IModel('delivery'); $deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id); if ($deliveryRow['type'] == 0 && $payment == 0) { IError::show(403, '请选择支付方式'); } else { if ($deliveryRow['type'] == 1) { $payment = 0; } } //计算费用 $countSumObj = new CountSum(); //直接购买商品方式 if ($type != '' && $gid != 0) { //计算$gid商品 $goodsResult = $countSumObj->direct_count($gid, $type, $num, $promo, $active_id); } else { //计算购物车中的商品价格$goodsResult $goodsResult = $countSumObj->cart_count(); //清空购物车 $cartObj = new Cart(); $cartObj->clear(); } //判断商品商品是否存在 if (empty($goodsResult['goodsList']) && empty($goodsResult['productList'])) { IError::show(403, '商品数据不存在'); exit; } //获取红包减免金额 if ($ticket_id != '') { $memberObj = new IModel('member'); $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom'); if (ISafe::get('ticket_' . $ticket_id) == $ticket_id || stripos(',' . trim($memberRow['prop'], ',') . ',', ',' . $ticket_id . ',') !== false) { $propObj = new IModel('prop'); $ticketRow = $propObj->getObj('id = ' . $ticket_id . ' and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1'); if (!empty($ticketRow)) { $dataArray['prop'] = $ticket_id; } //锁定红包状态 $propObj->setData(array('is_close' => 2)); $propObj->update('id = ' . $ticket_id); } } //货到付款的方式 if ($payment == 0) { $paymentName = '货到付款'; $paymentType = 0; } else { $paymentObj = new IModel('payment'); $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,name'); $paymentName = $paymentRow['name']; $paymentType = $paymentRow['type']; } //最终订单金额计算 $orderData = $countSumObj->countOrderFee($goodsResult['sum'], $goodsResult['final_sum'], $goodsResult['weight'], $province, $delivery_id, $payment, $goodsResult['freeFreight'], $insured, $taxes); //生成的订单数据 $dataArray = array('order_no' => $order_no, 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'postscript' => $order_message, 'accept_time' => $accept_time, 'exp' => $goodsResult['exp'], 'point' => $goodsResult['point'], 'type' => $order_type, 'prop' => isset($dataArray['prop']) ? $dataArray['prop'] : null, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $orderData['deliveryOrigPrice'], 'real_freight' => $orderData['deliveryPrice'], 'pay_fee' => $orderData['paymentPrice'], 'invoice' => $taxes ? 1 : 0, 'invoice_title' => $tax_title, 'taxes' => $taxes, 'promotions' => $goodsResult['proReduce'] + $goodsResult['reduce'] + (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'order_amount' => $orderData['orderAmountPrice'] - (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'if_insured' => $insured ? 1 : 0, 'insured' => $insured); $dataArray['order_amount'] = $dataArray['order_amount'] <= 0 ? 0 : $dataArray['order_amount']; $orderObj = new IModel('order'); $orderObj->setData($dataArray); $this->order_id = $orderObj->add(); if ($this->order_id == false) { IError::show(403, '订单生成错误'); } /*将订单中的商品插入到order_goods表*/ $orderInstance = new Order_Class(); $orderInstance->insertOrderGoods($this->order_id, $goodsResult); //记录用户默认习惯的数据 if (!isset($memberRow['custom'])) { $memberObj = new IModel('member'); $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'custom'); } $memberData = array('custom' => serialize(array('payment' => $payment, 'delivery' => $delivery_id))); $memberObj->setData($memberData); $memberObj->update('user_id = ' . $user_id); //收货地址的处理 if ($user_id) { $addressObj = new IModel('address'); //如果用户之前没有收货地址,那么会自动记录此次的地址信息并且为默认 $addressRow = $addressObj->getObj('user_id = ' . $user_id); if (empty($addressRow)) { $addressData = array('default' => '1', 'user_id' => $user_id, 'accept_name' => $accept_name, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'zip' => $zip, 'telphone' => $telphone, 'mobile' => $mobile); $addressObj->setData($addressData); $addressObj->add(); } else { //如果用户有收货地址,但是没有设置默认项,那么会自动设置此次地址信息为默认 $radio_address = intval(IReq::get('radio_address')); if ($radio_address != 0) { $addressDefRow = $addressObj->getObj('user_id = ' . $user_id . ' and `default` = 1'); if (empty($addressDefRow)) { $addressData = array('default' => 1); $addressObj->setData($addressData); $addressObj->update('user_id = ' . $user_id . ' and id = ' . $radio_address); } } } } //获取备货时间 $siteConfigObj = new Config("site_config"); $site_config = $siteConfigObj->getInfo(); $this->stockup_time = isset($site_config['stockup_time']) ? $site_config['stockup_time'] : 2; //数据渲染 $this->order_num = $dataArray['order_no']; $this->final_sum = $dataArray['order_amount']; $this->payment = $paymentName; $this->paymentType = $paymentType; $this->delivery = $deliveryRow['name']; $this->tax_title = $tax_title; $this->deliveryType = $deliveryRow['type']; //订单金额为0时,订单自动完成 if ($this->final_sum <= 0) { $order_id = Order_Class::updateOrderStatus($dataArray['order_no']); if ($order_id != '') { if ($user_id) { $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货") . '/?callback=ucenter/order_detail/id/' . $order_id); } else { $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货")); } } else { IError::show(403, '订单修改失败'); } } else { $this->setRenderData($dataArray); $this->redirect('cart3'); } }
public function sendwxmsg() { $this->checkshoplogin(); $shopid = ICookie::get('adminshopid'); if ($shopid <= 0) { $this->message('操作失败'); } $openid = trim(IReq::get('openid')); $content = trim(IReq::get('content')); if (empty($content)) { $this->message('发送内容不能为空'); } $wechat = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop_wechat where shopid={$shopid}"); if (empty($wechat)) { $this->message('未设置微信基本信息'); } $wx_s = new wx_s($wechat['token'], $wechat['appid'], $wechat['secret'], $shopid); if ($wx_s->sendmsg($content, $openid)) { $this->success('操作成功'); } else { $this->message($wx_s->err()); } }
public function clear() { $cartName = $this->getCartName(); if ($this->saveType == 'session') { ISession::clear($cartName); } else { ICookie::clear($cartName); } }
function selfpayment() { $data['shopid'] = intval(IReq::get('shopid')); //店铺ID $data['content'] = '到店自助付款'; //备注 $data['paytype'] = IFilter::act(IReq::get('paytype')); //支付方式 $data['dno'] = time() . rand(1000, 9999); //订单编号 $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id = '" . $data['shopid'] . "' "); $data['shopuid'] = $shopinfo['uid']; $data['shopaddress'] = $shopinfo['address']; $data['shopphone'] = $shopinfo['phone']; $data['shopname'] = $shopinfo['shopname']; $data['buycode'] = substr(md5(time()), 9, 6); $minitime = strtotime(date('Y-m-d', time())); $tj = $this->mysql->select_one("select count(id) as shuliang from " . Mysite::$app->config['tablepre'] . "order where shopid='" . $data['shopid'] . "' and addtime > " . $minitime . " limit 0,1000"); $data['daycode'] = $tj['shuliang'] + 1; $data['buyeraddress'] = "in_shop"; //到店支付 $panduan = Mysite::$app->config['man_ispass']; $data['status'] = $panduan == 1 ? '0' : 1; $data['paystatus'] = 0; $data['ordertype'] = 5; //订单类型 $data['cxcost'] = 0; $data['yhjcost'] = 0; $ip_l = new iplocation(); $ipaddress = $ip_l->getaddress($ip_l->getIP()); if (isset($ipaddress["area1"])) { $info_ipaddress = $ipaddress['ip'] . mb_convert_encoding($ipaddress["area1"], 'UTF-8', 'GB2312'); //('GB2312','ansi',); $data['ipaddress'] = $info_ipaddress; } $data['shopcost'] = IReq::get('shopcost'); // $data['allcost'] = $data['shopcost']; $this->mysql->insert(Mysite::$app->config['tablepre'] . 'order', $data); //写主订单 $orderid = $this->mysql->insertid(); $cmd['order_id'] = $orderid; $cmd['goodsid'] = '-1'; $cmd['goodsname'] = '到店自助付款'; $cmd['goodscost'] = $data['shopcost']; $cmd['goodscount'] = 1; $cmd['shopid'] = $data['shopid']; $cmd['status'] = 0; $cmd['is_send'] = 0; $this->mysql->insert(Mysite::$app->config['tablepre'] . 'orderdet', $cmd); ICookie::set('orderid', $orderid, 86400); echo json_encode(array('success' => 'yes', 'msg' => $orderid)); exit; }
function giftlog() { $backinfo = $this->checkappMem(); if (empty($backinfo['uid'])) { $this->message('nologin'); } else { if ($this->member['uid'] == 0) { ICookie::set('email', $backinfo['email'], 86400); ICookie::set('memberpwd', ICookie::get('apppwd'), 86400); ICookie::set('membername', $backinfo['username'], 86400); ICookie::set('uid', $backinfo['uid'], 86400); } } echo '获取礼品记录'; exit; }
function ordertoday() { $firstareain = IReq::get('firstarea'); $secareain = IReq::get('secarea'); $statustype = intval(IReq::get('statustype')); $dno = IReq::get('dno'); $data['dno'] = $dno; $data['statustype'] = $statustype; $statustype = in_array($statustype, array(1, 2, 3, 4, 5)) ? $statustype : 0; $statustypearr = array('0' => '', '1' => ' and ord.status = 0 ', '2' => ' and ord.status = 1 ', '3' => ' and ord.status > 1 and ord.status < 4 ', '4' => ' and ord.is_reback in(1,2) '); ///statustype 1 待审核 //statustype 2 待发货 //statustype 3 已发货 //statustype 4 退款处理 $data['frinput'] = $firstareain; $this->setstatus(); $nowday = date('Y-m-d', time()); $where = ' where ord.posttime > ' . strtotime($nowday . ' 00:00:00') . ' and ord.posttime < ' . strtotime($nowday . ' 23:59:59'); //查询当天所有订单数据 // $where .= ' and ord.status = 0 '; if (!empty($firstareain)) { $where .= " and FIND_IN_SET('" . $firstareain . "',`areaids`)"; } $where .= $statustypearr[$statustype]; //$where .= ' and ord.status = 0 '; $where .= empty($dno) ? '' : ' and ord.dno =\'' . $dno . '\''; $orderlist = $this->mysql->getarr("select ord.*,mb.username as acountname from " . Mysite::$app->config['tablepre'] . "order as ord left join " . Mysite::$app->config['tablepre'] . "member as mb on mb.uid = ord.buyeruid " . $where . " order by ord.id desc limit 0,1000"); $shuliang = $this->mysql->counts("select ord.*,mb.username as acountname from " . Mysite::$app->config['tablepre'] . "order as ord left join " . Mysite::$app->config['tablepre'] . "member as mb on mb.uid = ord.buyeruid " . $where . " "); $data['list'] = array(); if ($orderlist) { foreach ($orderlist as $key => $value) { $value['detlist'] = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "orderdet where order_id = " . $value['id'] . " order by id desc "); $value['maijiagoumaishu'] = 0; if ($value['buyeruid'] > 0) { $value['maijiagoumaishu'] = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "order where buyeruid='" . $value['buyeruid'] . "' and status = 3 order by id desc"); } $data['list'][] = $value; } } /*构造城市*/ $areainfo = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "area order by orderid asc"); $this->getgodigui($areainfo, 0, 0); $data['arealist'] = $this->digui; $data['showdet'] = intval(IReq::get('showdet')); $data['playwave'] = ICookie::get('playwave'); //shoporderlist Mysite::$app->setdata($data); }
} } else { if ($uid > 0) { $link = IUrl::creatUrl('member/base'); /*跳转到用户中心*/ } else { $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid = '" . $oauthinfo['uid'] . "'"); if (empty($userinfo)) { $this->message('账号未查找到,关联账号是否被删除'); } $data['loginip'] = IClient::getIp(); $data['logintime'] = time(); $checktime = date('Y-m-d', time()); $checktime = strtotime($checktime); if ($userinfo['logintime'] < $checktime) { if (Mysite::$app->config['loginscore'] > 0) { $data['score'] = $userinfo['score'] + Mysite::$app->config['loginscore']; $mess['content'] = '用户登陆赠送积分' . Mysite::$app->config['loginscore'] . '总积分' . $data['score']; $this->memberCls->addlog($userinfo['uid'], 1, 1, Mysite::$app->config['loginscore'], '每天登陆', $mess['content'], $data['score']); // $this->mysql->insert(Mysite::$app->config['tablepre']."message",$mess); } } $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $data, "uid='" . $userinfo['uid'] . "'"); ICookie::set('logintype', $logintype, 86400); ICookie::set('uid', $userinfo['uid'], 86400); $link = IUrl::creatUrl('member/base'); /*跳转到用户中心*/ } } } $this->message('', $link);
public function makeorder() { $subtype = intval(IReq::get("subtype")); $info['shopid'] = intval(IReq::get("shopid")); $info['remark'] = IFilter::act(IReq::get("content")); $info['paytype'] = IFilter::act(IReq::get("paytype")); $info['username'] = IFilter::act(IReq::get("contactname")); $info['mobile'] = IFilter::act(IReq::get("phone")); $info['addressdet'] = IFilter::act(IReq::get("addressdet")); $info['senddate'] = IFilter::act(IReq::get("senddate")); $info['minit'] = IFilter::act(IReq::get("orderTime")); $info['juanid'] = intval(IReq::get("juanid")); $info['ordertype'] = 1; $peopleNum = IFilter::act(IReq::get("personcount")); $info['othercontent'] = empty($peopleNum) ? "" : serialize(array("人数" => $peopleNum)); $info['userid'] = !isset($this->member['score']) ? "0" : $this->member['uid']; if (Mysite::$app->config['allowedguestbuy'] != 1 && $info['userid'] == 0) { $this->message("member_nologin"); } $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopfast as a left join " . Mysite::$app->config['tablepre'] . "shop as b on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "' "); if (empty($shopinfo)) { $this->message("店铺不存在"); } $checksend = Mysite::$app->config['ordercheckphone']; if ($checksend == 1 && empty($this->member['uid'])) { $checkphone = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "mobile where phone ='" . $info['mobile'] . "' order by addtime desc limit 0,50"); if (empty($checkphone)) { $this->message("member_emailyan"); } if (empty($checkphone['is_send'])) { $mycode = IFilter::act(IReq::get("phonecode")); if ($mycode == $checkphone['code']) { $this->mysql->update(Mysite::$app->config['tablepre'] . "mobile", array("is_send" => 1), "phone='" . $info['mobile'] . "'"); } else { $this->message("member_emailyan"); } } } if (empty($info['username'])) { $this->message("emptycontact"); } if (!IValidate::suremobi($info['mobile'])) { $this->message("errphone"); } $info['ipaddress'] = ""; $ip_l = new iplocation(); $ipaddress = $ip_l->getaddress($ip_l->getIP()); if (isset($ipaddress['area1'])) { $info['ipaddress'] = $ipaddress['ip'] . mb_convert_encoding($ipaddress['area1'], "UTF-8", "GB2312"); } $info['cattype'] = 0; $senddate = $info['senddate']; $minit = $info['minit']; $nowpost = strtotime($senddate . " " . $minit . ":00"); $settime = time() - 600; if ($nowpost < $settime) { $this->message("提交配送时间和服务器时间相差超过10分钟下单失败"); } $temp = strtotime($minit . ":00"); $is_orderbefore = $shopinfo['is_orderbefore'] == 0 ? 0 : $shopinfo['befortime']; $tempinfo = $this->checkshopopentime($is_orderbefore, $nowpost, $shopinfo['starttime']); if (!$tempinfo) { $this->message("配送时间不在有效配送时间范围"); } if ($shopinfo['is_open'] != 1) { $this->message("店铺暂停营业"); } $info['paytype'] = $info['paytype'] == 1 ? 1 : 0; $info['areaids'] = ""; $info['shopinfo'] = $shopinfo; if ($subtype == 1) { $info['allcost'] = 0; $info['bagcost'] = 0; $info['allcount'] = 0; $info['goodslist'] = array(); } else { if (empty($info['shopid'])) { $this->message("shop_noexit"); } $Cart = new smCart(); $Cart->cartName = 'platesmcart'; $carinfo = $Cart->getMyCart(); if (!isset($carinfo['list'][$info['shopid']]['data'])) { $this->message("shop_emptycart"); } $info['allcost'] = $carinfo['list'][$info['shopid']]['sum']; $info['goodslist'] = $carinfo['list'][$info['shopid']]['data']; $info['bagcost'] = 0; $info['allcount'] = 0; } $info['shopps'] = 0; $info['pstype'] = 0; $info['cattype'] = 1; $info['is_goshop'] = 1; $info['subtype'] = $subtype; $info['sendtime'] = $nowpost; $orderclass = new orderclass($this->mysql); $orderclass->orderyuding($info); $orderid = $orderclass->getorder(); if ($info['userid'] == 0) { ICookie::set("orderid", $orderid, 86400); } if ($subtype == 2) { $Cart->delshop($info['shopid']); } $this->success($orderid); exit; }
/** * 用户报名参加团购 * * 用户可以参加本次团购的条件: * 1.本次团购还没有满员 * 2.一小时二十五分钟内,用户在本次团购中没有未完成的交易 * * regiment_user_relation表中的is_over:0代表着还没有完成,1代表着已经完成交易了 * 如果用户没有登录便参加团购,会生成一个hash存在cookie里,名字为regiment_100,其中100是相应团购的id * 并将此hash保存在regiment_user_relation表的hash字段里。在用户付账需要登录的时候应该查询这个hash并更新相应的user_id * * @static */ public static function join($id, $user_id = null) { $id = intval($id); $now = time(); $regiment = self::getRegimentById($id); $time_limit = self::time_limit(); if ($regiment === false || 0 != $regiment['store_nums'] && $regiment['user_num'] >= $regiment['store_nums'] || strtotime($regiment['end_time']) < $now || strtotime($regiment['start_time']) > $now) { return array('flag' => 'msg', 'data' => '本次团购已过期或者人满'); } $tb = new IModel("regiment_user_relation"); $data = array('user_id' => "", 'hash' => "", 'regiment_id' => $id, 'join_time' => date("Y-m-d H:i:s", $now), 'is_over' => 0); if ($user_id !== null) { $user_id = intval($user_id); $re = $tb->query("regiment_id={$id} AND user_id={$user_id} AND is_over=0"); $data['user_id'] = $user_id; } else { $hash = ICookie::get("regiment_{$id}"); if ($hash === null) { $hash = IHash::md5(serialize($_SERVER) . microtime(1)); ICookie::set("regiment_{$id}", $hash, $time = $time_limit * 60); } $re = $tb->query("regiment_id={$id} AND hash='{$hash}' AND is_over=0"); $data['hash'] = $hash; } if ($re) { $re = end($re); } if (count($re) == 0 || strtotime($re['join_time']) < $now - $time_limit * 60) { $tb->setData($data); //$relation_id是关系表的主键 if ($re) { $tb->update("id={$re['id']}"); $relation_id = $re['id']; } else { $relation_id = $tb->add(); } return array('flag' => true, 'data' => '参与成功', 'relation_id' => $relation_id); } else { return array('flag' => false, 'data' => '本次团购您存在未完成交易'); } }
function changeshop() { $id = intval(IFilter::act(IReq::get('id'))); $link = IUrl::creatUrl('site/index/'); if ($id < 1) { $this->message('获取店铺ID失败', $link); } $grade = Mysite::$app->config['area_grade']; $temp_where = ''; $doarea = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "area where parent_id in(select id from " . Mysite::$app->config['tablepre'] . "area where parent_id =0) "); if ($grade == 1) { $where = ' and areaid in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id =0)'; } elseif ($grade == 2) { $where = ' and areaid in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id =0)) '; } elseif ($grade == 3) { $where = ' and areaid in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id in(select id from ' . Mysite::$app->config['tablepre'] . 'area where parent_id =0))) '; } $checkinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "areatoadd where shopid=" . $id . " " . $where . ""); if (empty($checkinfo)) { $this->message('获取店铺区域信息失败', $link); } $arealist = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id = " . $checkinfo['areaid'] . " order by orderid asc "); if (empty($arealist)) { $this->message('获取店铺区域信息失败', $link); } ICookie::set('lng', $arealist['lng'], 2592000); ICookie::set('lat', $arealist['lat'], 2592000); ICookie::set('mapname', $arealist['name'], 2592000); ICookie::set('myaddress', $checkinfo['areaid'], 2592000); $cookmalist = ICookie::get('cookmalist'); $cooklnglist = ICookie::get('cooklnglist'); $cooklatlist = ICookie::get('cooklatlist'); $check = explode(',', $cookmalist); if (!in_array($arealist['name'], $check)) { $cookmalist = empty($cookmalist) ? $arealist['name'] . ',' : $arealist['name'] . ',' . $cookmalist; $cooklatlist = empty($cooklatlist) ? $arealist['lat'] . ',' : $arealist['lat'] . ',' . $cooklatlist; $cooklnglist = empty($cooklnglist) ? $arealist['lng'] . ',' : $arealist['lng'] . ',' . $cooklnglist; ICookie::set('cookmalist', $cookmalist, 2592000); ICookie::set('cooklatlist', $cooklatlist, 2592000); ICookie::set('cooklnglist', $cooklnglist, 2592000); } $link = IUrl::creatUrl('shop/index/id/' . $id); $this->message('', $link); }
function savemapshoplocation() { $this->checkshoplogin(); $data['lng'] = IReq::get('lng'); $data['lat'] = IReq::get('lat'); $shopid = ICookie::get('adminshopid'); if (empty($data['lng'])) { $this->message('百度地图坐标不能为空'); } if (empty($data['lat'])) { $this->message('百度坐标不能为空'); } if (empty($shopid)) { $this->message('cookies失效,请重新登陆'); } $shopid = ICookie::get('adminshopid'); $this->mysql->update(Mysite::$app->config['tablepre'] . 'shop', $data, "id='" . $shopid . "'"); $this->success('操作成功'); }
function getadmininfo() { $adminname = ICookie::get('adminname'); $adminpwd = ICookie::get('adminpwd'); $adminuid = ICookie::get('adminuid'); $userinfo = array(); if (!empty($adminuid)) { $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "admin where uid='" . $adminuid . "' and password = '******'"); $userinfo['group'] = $userinfo['groupid']; } if (empty($userinfo) || !isset($userinfo['uid'])) { $userinfo = array('uid' => 0, 'username' => 'guest', 'group' => '2'); } return $userinfo; }
function login_act() { $login_info = IFilter::act(IReq::get('login_info', 'post')); $password = IReq::get('password', 'post'); $remember = IFilter::act(IReq::get('remember', 'post')); $autoLogin = IFilter::act(IReq::get('autoLogin', 'post')); $callback = IFilter::act(IReq::get('callback'), 'text'); $message = ''; $password = md5($password); if ($login_info == '') { $message = '请填写用户名或者邮箱'; } else { if (!preg_match('|\\S{6,32}|', $password)) { $message = '密码格式不正确,请输入6-32个字符'; } else { if ($userRow = CheckRights::isValidUser($login_info, $password)) { CheckRights::loginAfter($userRow); //记住帐号 if ($remember == 1) { ICookie::set('loginName', $login_info); } //自动登录 if ($autoLogin == 1) { ICookie::set('autoLogin', $autoLogin); } //自定义跳转页面 if ($callback && !strpos($callback, 'reg') && !strpos($callback, 'login')) { $this->redirect($callback); } else { $this->redirect('/ucenter/index'); } } else { //邮箱未验证 $userDB = new IModel('user as u,member as m'); $userRow = $userDB->getObj(" (u.email = '{$login_info}' or u.username = '******') and password = '******' "); if ($userRow) { $siteConfig = new Config('site_config'); if ($userRow['status'] == 3) { if ($siteConfig->reg_option == 1) { $message = "您的邮箱还未验证,请点击下面的链接发送您的邮箱验证邮件!"; $this->redirect('/site/success?message=' . urlencode($message) . '&email=' . $userRow['email']); } else { $message = '您的账号已经被锁定'; } } } else { $message = '用户名和密码不匹配'; } } } } //错误信息 if ($message) { $this->message = $message; $_GET['callback'] = $callback; $this->redirect('login', false); } }
function login_act() { $login_info = IFilter::act(IReq::get('login_info', 'post')); $password = IReq::get('password', 'post'); $remember = IFilter::act(IReq::get('remember', 'post')); $autoLogin = IFilter::act(IReq::get('autoLogin', 'post')); $callback = IReq::get('callback'); $message = ''; if ($login_info == '') { $message = '请填写用户名或者邮箱'; } else { if (!preg_match('|\\S{6,32}|', $password)) { $message = '密码格式不正确,请输入6-32个字符'; } else { if ($userRow = CheckRights::isValidUser($login_info, md5($password))) { $this->loginAfter($userRow); //记住帐号 if ($remember == 1) { ICookie::set('loginName', $login_info); } //自动登录 if ($autoLogin == 1) { ICookie::set('autoLogin', $autoLogin); } //自定义跳转页面 if ($callback != null && $callback != '' && $callback != "/simple/reg" && $callback != "/simple/login") { $this->redirect($callback); } else { $this->redirect('/ucenter/index'); } } else { $message = '用户名和密码不匹配'; } } } //错误信息 if ($message != '') { $this->message = $message; $_GET['callback'] = $callback; $this->redirect('login', false); } }
function goodsstock() { $this->checkshoplogin(); $shopid = ICookie::get('adminshopid'); if ($shopid <= 0) { $this->message("请重新登陆"); } $gid = (int) IReq::get('gid'); $startdate = IReq::get('start_date'); $enddate = IReq::get('end_date'); //print_r($startdate);exit; $startdate = empty($startdate) ? date('Y-m-d') : $startdate; $enddate = empty($enddate) ? date('Y-m-d', strtotime("+7 day")) : $enddate; if (!($sd = @strtotime($startdate))) { $this->message("开始日期格式不正确"); } if (!($ed = @strtotime($enddate))) { $this->message("结束日期格式不正确"); } $temp_list = []; do { $temp_list[date('Y-m-d', $sd)] = 0; } while (($sd += 86400) <= $ed); $info = $this->mysql->select_one("SELECT daycount FROM " . Mysite::$app->config['tablepre'] . "goods WHERE id=" . $gid); $daycount = $info['daycount']; $daystock = $this->mysql->getarr("SELECT day, stock FROM " . Mysite::$app->config['tablepre'] . "daystock WHERE goods_id={$gid} AND day BETWEEN {$sd} AND {$ed}"); $buynum_list = []; $stock_list = []; foreach ($daystock as $v) { $buynum_list[date('Y-m-d', $v['day'])] = $v['stock']; } $buynum_list = array_merge($temp_list, $buynum_list); //print_r($buynum_list);exit; foreach ($buynum_list as $k => $buy) { $stock_list[$k] = $daycount - $buy; } $data['stock_list'] = $stock_list; $data['start_date'] = $startdate; $data['end_date'] = $enddate; $data['gid'] = $gid; Mysite::$app->setdata($data); }
/** * 列表展示 * @author keenhome@126.com * @date 2013-4-30 */ public function glist() { $word = IFilter::act(IReq::get('kw')); $ids = IFilter::act(IReq::get('ids'), 'string'); $arr_ids = $ids ? explode('_', $ids) : array(); $top_cid = isset($arr_ids[0]) ? intval($arr_ids[0]) : 0; $second_cid = isset($arr_ids[1]) ? intval($arr_ids[1]) : 0; $third_cid = isset($arr_ids[2]) ? intval($arr_ids[2]) : 0; $forth_cid = isset($arr_ids[3]) ? intval($arr_ids[3]) : 0; $bid = isset($arr_ids[4]) ? intval($arr_ids[4]) : 0; $prid = isset($arr_ids[5]) ? intval($arr_ids[5]) : 0; $prid = $prid > count($this->site_config['price_range']) - 1 ? count($this->site_config['price_range']) - 1 : $prid; $sort = isset($arr_ids[6]) ? intval($arr_ids[6]) : 0; $sort = $sort > count($this->sort_type_map) - 1 ? count($this->sort_type_map) - 1 : $sort; $page = isset($arr_ids[7]) ? intval($arr_ids[7]) : 0; $pagesize = $this->site_config['list_num']; $order_by = $this->sort_type_map[$sort] ? $this->sort_type_map[$sort] : "{$this->tablePre}goods.sort ASC"; $start = $page * $pagesize; $all_goods_list = array(); $total_num = array(); $goods_list = array(); $data = array(); $brands = array(); $subcat = array(); $cname = ''; $title = ''; $description = ''; $keywords = ''; if ($top_cid || $second_cid || $word) { $categoryObj = new IModel('category'); $where = "{$this->tablePre}goods.is_del=0"; $cids = ''; if ($third_cid) { $cids = Block::getCategroy($third_cid); } elseif ($second_cid) { $cids = Block::getCategroy($second_cid); } elseif ($top_cid) { $cids = Block::getCategroy($top_cid); } if ($cids) { $cids = substr($cids, 0, -1); $where .= " AND {$this->tablePre}category_extend.category_id IN ({$cids})"; } if ($word && $word != '%' && $word != '_') { $where .= " AND ( {$this->tablePre}goods.name LIKE '%{$word}%' OR {$this->tablePre}goods.sellernick\n LIKE '%{$word}%' ) "; // 记录搜索词频 //搜索关键字 $tb_sear = new IModel('search'); $search_info = $tb_sear->getObj('keyword = "' . $this->word . '"', 'id'); //如果是第一页,相应关键词的被搜索数量才加1 if ($search_info && $page < 2) { //禁止刷新+1 $allow_sep = "30"; $flag = false; $time = ICookie::get('step'); if (isset($time)) { if (time() - $time > $allow_sep) { ICookie::set('step', time()); $flag = true; } } else { ICookie::set('step', time()); $flag = true; } if ($flag) { $tb_sear->setData(array('num' => 'num + 1')); $tb_sear->update('id=' . $search_info['id'], 'num'); } } elseif (!$search_info) { //如果数据库中没有这个词的信息,则新添 $tb_sear->setData(array('keyword' => $this->word, 'num' => 1)); $tb_sear->add(); } } $all_where = $where; if ($bid > 0) { $where .= " AND {$this->tablePre}goods.brand_id={$bid}"; } if ($prid > 0) { $where .= " AND {$this->tablePre}goods.sell_price>=" . $this->site_config['price_range'][$prid - 1] . " AND {$this->tablePre}goods.sell_price<=" . $this->site_config['price_range'][$prid]; } // 取所有商品基本信息 $sql = "SELECT DISTINCT({$this->tablePre}goods.id),{$this->tablePre}goods.brand_id,{$this->tablePre}category.parent_id,{$this->tablePre}category.name as cname,{$this->tablePre}category.id as cid FROM {$this->tablePre}goods\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category_extend ON {$this->tablePre}category_extend.goods_id={$this->tablePre}goods.id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category ON {$this->tablePre}category.id={$this->tablePre}category_extend.category_id\n\t\t\t\t\tWHERE {$all_where}"; $all_goods_list = $categoryObj->query_sql($sql); // 取分页总数 $sql = "SELECT DISTINCT({$this->tablePre}goods.id) FROM {$this->tablePre}goods\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category_extend ON {$this->tablePre}category_extend.goods_id={$this->tablePre}goods.id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category ON {$this->tablePre}category.id={$this->tablePre}category_extend.category_id\n\t\t\t\t\tWHERE {$where}"; $total_num = $categoryObj->query_sql($sql); $fields = " DISTINCT({$this->tablePre}goods.id),\n\t\t\t\t\t\t{$this->tablePre}category.parent_id,\n\t\t\t\t\t\t{$this->tablePre}goods.*,\n\t\t\t\t\t\t{$this->tablePre}category.id as cid,\n\t\t\t\t\t\t{$this->tablePre}brand.name as bname "; if ($word && !$cids) { $fields .= ",{$this->tablePre}category.name as cname"; } if (!$cids && $third_cid) { $where .= " AND {$this->tablePre}category_extend.category_id=({$third_cid})"; } // 获取商品列表 $sql = "SELECT {$fields} FROM {$this->tablePre}goods\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category_extend ON {$this->tablePre}category_extend.goods_id={$this->tablePre}goods.id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}brand ON {$this->tablePre}brand.id={$this->tablePre}goods.brand_id\n\t\t\t\t\tLEFT JOIN {$this->tablePre}category ON {$this->tablePre}category.id={$this->tablePre}category_extend.category_id\n\t\t\t\t\tWHERE {$where}\n\t\t\t\t\tORDER BY {$order_by}\n\t\t\t\t\tLIMIT {$start},{$pagesize}"; $goods_list = $categoryObj->query_sql($sql); // 获取二级类的名称 if ($second_cid) { $sql = "SELECT id,name,title,keywords,descript \n\t\t\t\t\t\tFROM {$this->tablePre}category \n\t\t\t\t\t\tWHERE id={$second_cid} \n\t\t\t\t\t\tORDER BY {$this->tablePre}category.sort ASC"; $second_catinfo = $categoryObj->query_sql($sql); if (count($second_catinfo) > 0) { $cname = $second_catinfo[0]['name']; $title = $second_catinfo[0]['title'] ? '【' . $cname . '】' . $second_catinfo[0]['title'] : ''; $description = $second_catinfo[0]['descript']; $keywords = $second_catinfo[0]['keywords']; } // 获取3级类 $sql = "SELECT id,name FROM {$this->tablePre}category WHERE parent_id={$second_cid} ORDER BY {$this->tablePre}category.sort ASC"; $subcat = $categoryObj->query_sql($sql); } if (!$cids && count($all_goods_list) > 0) { $top_cids = array(); $top_cat_info = array(); $second_cids = array(); $second_cat_info = array(); $third_cids = array(); $third_cat_info = array(); // 取顶级类 foreach ($all_goods_list as $key => $item) { if ($item['parent_id'] == -1) { $top_cids[$item['cid']] = $item['cid']; $top_cat_info[$item['cid']] = array('name' => $item['cname'], 'id' => $item['cid']); } } foreach ($all_goods_list as $key => $item) { if (!$item['cid']) { continue; } // 取2级类 if (in_array($item['parent_id'], $top_cids)) { $second_cids[$item['cid']] = $item['cid']; $second_cat_info[$item['cid']] = array('name' => $item['cname'], 'id' => $item['cid']); } else { $third_cids[$item['cid']] = $item['cid']; $third_cat_info[$item['cid']] = array('name' => $item['cname'], 'id' => $item['cid']); } } if (count($third_cids) > 0) { $cids = implode(',', $third_cids); $subcat = $third_cat_info; } elseif (count($second_cids) > 0) { $cids = implode(',', $second_cids); $subcat = $second_cat_info; } elseif (count($top_cids) > 0) { $cids = implode(',', $top_cids); $subcat = $top_cat_info; } } $bids = array(); if (count($all_goods_list) > 0) { // 取品牌id foreach ($all_goods_list as $key => $item) { if ($item['brand_id']) { $bids[$item['brand_id']] = $item['brand_id']; } } } // 获取所有品牌 if (count($bids) > 0) { $bids_string = implode(',', $bids); $sql = "SELECT * FROM {$this->tablePre}brand WHERE id IN({$bids_string}) ORDER BY {$this->tablePre}brand.sort ASC"; $brands = $categoryObj->query_sql($sql); } } $data['goods_list'] = $goods_list; $data['cname'] = $cname; $data['top_cid'] = $top_cid; $data['second_cid'] = $second_cid; $data['third_cid'] = $third_cid; $data['forth_cid'] = $forth_cid; $data['bid'] = $bid; $data['prid'] = $prid; $data['kw'] = $word; $data['sort'] = $sort; $data['brands'] = count($brands) > 0 ? $brands : ''; $data['price_range'] = count($this->site_config['price_range']) > 0 ? $this->site_config['price_range'] : ''; $data['subcat'] = count($subcat) > 0 ? $subcat : ''; $data['page'] = $page; $data['pagesize'] = $pagesize; $data['goodsNum'] = count($total_num); $data['title'] = $title ? $title : '【' . $cname . '】' . '商品列表-优加网(ujia.info)'; $data['description'] = $description; $data['keywords'] = $keywords; $this->setRenderData($data); $this->redirect('glist'); }
public function setMyCart($goodsInfo) { $goodsInfo = str_replace(array('"', ','), array('&', '$'), JSON::encode($goodsInfo)); $cartName = $this->getCartName(); if ($this->saveType == 'session') { ISession::set($cartName, $goodsInfo); } else { ICookie::set($cartName, $goodsInfo, '7200'); } return true; }
function search_list() { $return = $this->goodsListFilter(); $this->show_type = $return['show_type']; $this->listImageWidth = $return['listImageWidth']; $this->listImageHeight = $return['listImageHeight']; $this->order = $return['order']; $this->orderArray = $return['orderArray']; $this->word = IFilter::act(IReq::get('word')); $cat_id = intval(IReq::get('cat')); if ($this->word != '' && $this->word != '%' && $this->word != '_') { if ($cat_id > 0) { $tb_goods = new IQuery('goods as go'); $tb_goods->join = "left join category_extend as ca on go.id = ca.goods_id"; $tb_goods->where = "go.name like '%{$this->word}%' and go.is_del = 0 and ca.category_id = {$cat_id}"; $tb_goods->fields = "count(*) as num"; $goodsNum = $tb_goods->find(); $this->findSum = $goodsNum[0]['num']; } else { $goodsObj = new IModel('goods'); $goodsNum = $goodsObj->getObj('name like "%' . $this->word . '%" and is_del=0', 'count(*) as num'); $this->findSum = $goodsNum['num']; } //搜索关键字 $tb_sear = new IModel('search'); $search_info = $tb_sear->getObj('keyword = "' . $this->word . '"', 'id'); //如果是第一页,相应关键词的被搜索数量才加1 if ($search_info && intval(IReq::get('page')) < 2) { //禁止刷新+1 $allow_sep = "30"; $flag = false; $time = ICookie::get('step'); if (isset($time)) { if (time() - $time > $allow_sep) { ICookie::set('step', time()); $flag = true; } } else { ICookie::set('step', time()); $flag = true; } if ($flag) { $tb_sear->setData(array('num' => 'num + 1')); $tb_sear->update('id=' . $search_info['id'], 'num'); } } elseif (!$search_info) { //如果数据库中没有这个词的信息,则新添 $tb_sear->setData(array('keyword' => $this->word, 'num' => 1)); $tb_sear->add(); } } else { IError::show(403, '请输入正确的查询关键词'); } $this->cat_id = $cat_id; $this->redirect('search_list'); }
?> <tr><td colspan="2"> <div class="prompt"><img src="<?php echo IUrl::creatUrl("") . "views/" . $this->theme . "/skin/" . $this->skin . "/images/front/error_s.gif"; ?> " width="16" height="15" /><?php echo isset($this->message) ? $this->message : ""; ?> </div> </td></tr> <?php } ?> <tr><th>用户名/邮箱:</th><td><input class="gray" type="text" name="login_info" value="<?php echo ICookie::get('loginName'); ?> " pattern='required' alt='填写用户名或邮箱' /></td></tr> <tr><th>密码:</th><td><input class="gray" type="password" name="password" pattern='^\S{6,32}$' alt='填写密码' /></td></tr> <tr class="low"><td></td> <td> <label class="attr"><input class="radio" type="checkbox" name="remember" value='1' />记住登录名</label> <label class="attr"><a class="link pwd" href="<?php echo IUrl::creatUrl("/simple/find_password"); ?> ">忘记密码</a></label> </td> </tr> <tr class="low"> <td></td> <td>
public function addCookie(ICookie $Cookie) { $key = $this->getNewOrExistingKeyInArray($Cookie->getName(), $this->cookies); $this->cookies[$key] = $Cookie; }
/** * @param $string * @param ICookie $cookie */ private function writeHttpOnly(&$string, ICookie $cookie) { if ($cookie->isHttpOnly()) { $string .= ' httpOnly'; } }
function savelunadv() { $shopid = ICookie::get('adminshopid'); $imglist = IFilter::act(IReq::get('imglist')); $links = IUrl::creatUrl('shop/shoplunadv'); if (empty($imglist)) { $this->message('图片不能为空', $links); } $data['imglist'] = join(',', $imglist); $this->mysql->update(Mysite::$app->config['tablepre'] . 'shop', $data, "id='" . $shopid . "'"); $this->success('操作成功', $links); }