/** * 删除缓存数据 */ public function dropCache() { $this->cachedData = null; $this->gcForCacheModel = null; dkcache('gc_class'); dkcache('all_categories'); }
/** * 清理缓存 */ public function clearOp() { if (!chksubmit()) { Tpl::showpage('cache.clear'); return; } $lang = Language::getLangContent(); // 清理所有缓存 if ($_POST['cls_full'] == 1) { foreach ($this->cacheItems as $i) { dkcache($i); } // 表主键 Model::dropTablePkArrayCache(); // 商品分类 dkcache('gc_class'); dkcache('all_categories'); dkcache('goods_class_seo'); dkcache('class_tag'); // 广告 Model('adv')->makeApAllCache(); // 首页 Model('web_config')->getWebHtml('index', 1); delCacheFile('index'); } else { $todo = (array) $_POST['cache']; foreach ($this->cacheItems as $i) { if (in_array($i, $todo)) { dkcache($i); } } // 表主键 if (in_array('table', $todo)) { Model::dropTablePkArrayCache(); } // 商品分类 if (in_array('goodsclass', $todo)) { dkcache('gc_class'); dkcache('all_categories'); dkcache('goods_class_seo'); dkcache('class_tag'); } // 广告 if (in_array('adv', $todo)) { Model('adv')->makeApAllCache(); } // 首页 if (in_array('index', $todo)) { Model('web_config')->getWebHtml('index', 1); delCacheFile('index'); } } $this->log(L('cache_cls_operate')); showMessage($lang['cache_cls_ok']); }
/** * ajax操作 */ public function ajaxOp() { switch ($_GET['branch']) { case 'state': $model_brand = Model('express'); $update_array = array(); $update_array['id'] = intval($_GET['id']); $update_array[$_GET['column']] = trim($_GET['value']); $model_brand->update($update_array); dkcache('express'); $this->log(L('nc_edit,express_name,express_state') . '[ID:' . intval($_GET['id']) . ']', 1); echo 'true'; exit; break; case 'order': $_GET['value'] = $_GET['value'] == 0 ? 2 : 1; $model_brand = Model('express'); $update_array = array(); $update_array['id'] = intval($_GET['id']); $update_array[$_GET['column']] = trim($_GET['value']); $model_brand->update($update_array); dkcache('express'); $this->log(L('nc_edit,express_name,express_state') . '[ID:' . intval($_GET['id']) . ']', 1); echo 'true'; exit; break; case 'e_zt_state': $model_brand = Model('express'); $update_array = array(); $update_array['id'] = intval($_GET['id']); $update_array[$_GET['column']] = trim($_GET['value']); $model_brand->update($update_array); dkcache('express'); $this->log(L('nc_edit,express_name,express_state') . '[ID:' . intval($_GET['id']) . ']', 1); echo 'true'; exit; break; } dkcache('express'); }
/** * 更新信息 * * @param array $param 更新数据 * @return bool 布尔类型的返回结果 */ public function updateSetting($param) { if (empty($param)) { return false; } if (is_array($param)) { foreach ($param as $k => $v) { $tmp = array(); $specialkeys_arr = array('statistics_code'); $tmp['value'] = in_array($k, $specialkeys_arr) ? htmlentities($v, ENT_QUOTES) : $v; $where = " name = '" . $k . "'"; $result = Db::update('setting', $tmp, $where); if ($result !== true) { return $result; } } dkcache('setting'); return true; } else { return false; } }
/** * 更新圈子成员等级缓存 */ public function update_cacheOp() { dkcache('circle_level'); showMessage(L('nc_common_op_succ'), 'index.php?act=circle_memberlevel'); }
/** * 删除缓存 * * @param string $key 缓存键 */ public function dropCachedData($key) { unset($this->cachedData[$key]); dkcache($key); }
/** * 删除等级 */ public function store_grade_delOp() { /** * 读取语言包 */ $lang = Language::getLangContent(); $model_grade = Model('store_grade'); if (intval($_GET['sg_id']) > 0) { //判断是否默认等级,默认等级不能删除 if ($_GET['sg_id'] == 1) { //showMessage('默认等级不能删除 ','index.php?act=store_grade&op=store_grade'); showMessage($lang['default_store_grade_no_del'], 'index.php?act=store_grade&op=store_grade'); } //判断该等级下是否存在店铺,存在的话不能删除 if (!$this->isable_delGrade(intval($_GET['sg_id']))) { showMessage($lang['del_gradehavestore'], 'index.php?act=store_grade&op=store_grade'); } /** * 删除分类 */ $model_grade->del(intval($_GET['sg_id'])); dkcache('store_grade'); $this->log(L('nc_del,store_grade') . '[ID:' . intval($_GET['sg_id']) . ']', 1); showMessage($lang['nc_common_del_succ'], 'index.php?act=store_grade&op=store_grade'); } else { showMessage($lang['nc_common_del_fail'], 'index.php?act=store_grade&op=store_grade'); } }
/** * 编辑保存推荐位 * */ public function rec_edit_saveOp() { if (!is_numeric($_POST['rec_id'])) { showMessage(Language::get('param_error')); } $array = array(); $data = array(); $pattern = "/^http:\\/\\/[A-Za-z0-9]+[A-Za-z0-9.]+\\.[A-Za-z0-9]+/i"; //文字类型 if ($_POST['rec_type'] == 1) { if (is_array($_POST['txt']) && is_array($_POST['urltxt'])) { foreach ($_POST['txt'] as $k => $v) { if (trim($v) == '') { continue; } $c = count($array['body']); $array['body'][$c]['title'] = $v; $array['body'][$c]['url'] = preg_match($pattern, $_POST['urltxt'][$k]) ? $_POST['urltxt'][$k] : ''; $data['pic_type'] = 0; } } else { showMessage(Language::get('param_error')); } } elseif ($_POST['rec_type'] == 2 && $_POST['pic_type'] == 1) { //本地图片上传 if (is_array($_FILES['pic']['tmp_name'])) { foreach ($_FILES['pic']['tmp_name'] as $k => $v) { //未上传新图的,还用老图 if (empty($v) && !empty($_POST['opic'][$k])) { $array['body'][$k]['title'] = str_ireplace(UPLOAD_SITE_URL . '/', '', $_POST['opic'][$k]); $array['body'][$k]['url'] = preg_match($pattern, $_POST['urlup'][$k]) ? $_POST['urlup'][$k] : ''; } $ext = strtolower(pathinfo($_FILES['pic']['name'][$k], PATHINFO_EXTENSION)); if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) { $filename = substr(md5(microtime(true)), 0, 16) . rand(100, 999) . $k . '.' . $ext; if ($_FILES['pic']['size'][$k] < 1024 * 1024) { move_uploaded_file($v, BASE_UPLOAD_PATH . '/' . ATTACH_REC_POSITION . '/' . $filename); } if ($_FILES['pic']['error'][$k] != 0) { showMessage(Language::get('nc_common_save_fail')); } //删除老图 $old_file = str_ireplace(array(UPLOAD_SITE_URL, '..'), array(BASE_UPLOAD_PATH, ''), $_POST['opic'][$k]); if (is_file($old_file)) { @unlink($old_file); } $array['body'][$k]['title'] = ATTACH_REC_POSITION . '/' . $filename; $array['body'][$k]['url'] = preg_match($pattern, $_POST['urlup'][$k]) ? $_POST['urlup'][$k] : ''; $data['pic_type'] = 1; } } //最后删除数据库里有但没有POST过来的图片 $model = Model('rec_position'); $oinfo = $model->where(array('rec_id' => $_POST['rec_id']))->find(); $oinfo = unserialize($oinfo['content']); foreach ($oinfo['body'] as $k => $v) { if (!in_array(UPLOAD_SITE_URL . '/' . $v['title'], (array) $_POST['opic'])) { if (is_file(BASE_UPLOAD_PATH . '/' . $v['title'])) { @unlink(BASE_UPLOAD_PATH . '/' . $v['title']); } } } unset($oinfo); } //如果是上传图片,则取原图片地址 if (empty($array)) { if (is_array($_POST['opic'])) { foreach ($_POST['opic'] as $k => $v) { $array['body'][$k]['title'] = $v; $array['body'][$k]['url'] = preg_match($pattern, $_POST['urlup'][$k]) ? $_POST['urlup'][$k] : ''; } } } } elseif ($_POST['rec_type'] == 2 && $_POST['pic_type'] == 2) { //远程图片 if (is_array($_POST['pic'])) { foreach ($_POST['pic'] as $k => $v) { if (!preg_match("/^(http\\:\\/\\/)/i", $v)) { continue; } $ext = strtolower(pathinfo($v, PATHINFO_EXTENSION)); if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) { $c = count($array['body']); $array['body'][$c]['title'] = $v; $array['body'][$c]['url'] = preg_match($pattern, $_POST['urlremote'][$k]) ? $_POST['urlremote'][$k] : ''; $data['pic_type'] = 2; } } } } else { showMessage(Language::get('param_error')); } if ($_POST['rec_type'] != 1) { $array['width'] = is_numeric($_POST['rwidth']) ? $_POST['rwidth'] : ''; $array['height'] = is_numeric($_POST['rheight']) ? $_POST['rheight'] : ''; } $array['target'] = intval($_POST['rtarget']); $data['title'] = $_POST['rtitle']; $data['content'] = serialize($array); $model = Model('rec_position'); //如果是把本地上传类型改为文字或远程,则先取出原来上传的图片路径,待update成功后,再删除这些图片 if ($_POST['opic_type'] == 1 && ($_POST['pic_type'] == 2 || $_POST['rec_type'] == 1)) { $oinfo = $model->where(array('rec_id' => $_POST['rec_id']))->find(); $oinfo = unserialize($oinfo['content']); } $result = $model->where(array('rec_id' => $_POST['rec_id']))->update($data); if ($result) { if ($oinfo) { foreach ($oinfo['body'] as $v) { if (is_file(BASE_UPLOAD_PATH . '/' . $v['title'])) { @unlink(BASE_UPLOAD_PATH . '/' . $v['title']); } } } dkcache("rec_position/{$_POST['rec_id']}"); showMessage(Language::get('nc_common_save_succ'), 'index.php?act=rec_position&op=rec_list'); } else { showMessage(Language::get('nc_common_save_fail'), 'index.php?act=rec_position&op=rec_list'); } }
/** * 删除缓存自营店铺的ID */ public function dropCachedOwnShopIds() { $this->ownShopIds = null; dkcache('own_shop_ids'); }
/** * 幻灯片清空 */ public function slider_clearOp() { $model_setting = Model('setting'); $update = array(); $update['live_pic1'] = ''; $update['live_link1'] = ''; $update['live_pic2'] = ''; $update['live_link2'] = ''; $update['live_pic3'] = ''; $update['live_link3'] = ''; $update['live_pic4'] = ''; $update['live_link4'] = ''; $res = $model_setting->updateSetting($update); if ($res) { dkcache('setting'); $this->log('清空抢购幻灯片设置', 1); echo json_encode(array('result' => 'true')); } else { echo json_encode(array('result' => 'false')); } exit; }
/** * 删除缓存数据 */ public function dropCache() { $this->cachedData = null; dkcache('area'); }
/** * 删除表主键缓存 */ public static function dropTablePkArrayCache() { dkcache('field/_pk'); }
/** * 编辑保存推荐位 * */ public function rec_edit_saveOp() { if (!is_numeric($_POST['rec_id'])) { showMessage(Language::get('param_error')); } $array = array(); $data = array(); $pattern = "/^http:\\/\\/[A-Za-z0-9]+[A-Za-z0-9.]+\\.[A-Za-z0-9]+/i"; //文字类型 if ($_POST['rec_type'] == 1) { if (is_array($_POST['txt']) && is_array($_POST['urltxt'])) { foreach ($_POST['txt'] as $k => $v) { if (trim($v) == '') { continue; } $c = count($array['body']); $array['body'][$c]['title'] = $v; $array['body'][$c]['url'] = preg_match($pattern, $_POST['urltxt'][$k]) ? $_POST['urltxt'][$k] : ''; $data['pic_type'] = 0; } } else { showMessage(Language::get('param_error')); } } elseif ($_POST['rec_type'] == 2 && $_POST['pic_type'] == 1) { //本地图片上传 // if (empty($_FILES['pic']['name'])) { $filename = $_REQUEST['default_pic_img']; } else { $ext = strtolower(pathinfo($_FILES['pic']['name'], PATHINFO_EXTENSION)); if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) { $filename = substr(md5(microtime(true)), 0, 16) . rand(100, 999) . '.' . $ext; if ($_FILES['pic']['size'] < 1024 * 1024) { move_uploaded_file($_FILES['pic']['tmp_name'], BASE_UPLOAD_PATH . '/' . ATTACH_REC_POSITION . '/' . $filename); } if ($_FILES['pic']['error'] != 0) { showMessage(Language::get('nc_common_op_fail')); } } } // if (is_array($_FILES['pic']['tmp_name'])){ // foreach($_FILES['pic']['tmp_name'] as $k=>$v){ // if (empty($v)) continue; // $ext = strtolower(pathinfo($_FILES['pic']['name'][$k], PATHINFO_EXTENSION)); // if (in_array($ext,array('jpg','jpeg','gif','png'))){ // $filename = substr(md5(microtime(true)),0,16).rand(100,999).$k.'.'.$ext; // if ($_FILES['pic']['size'][$k]<1024*1024){ // move_uploaded_file($v,BASE_UPLOAD_PATH.'/'.ATTACH_REC_POSITION.'/'.$filename); // } // if ($_FILES['pic']['error'][$k] != 0) showMessage(Language::get('nc_common_op_fail')); // $c = count($array['body']); $array['body']['imageurl'] = $filename; $array['body']['requesturl'] = $_POST['urlup']; $array['body']['targetid'] = ''; $regex = '@(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))@'; if (preg_match($regex, $_POST['urlup'])) { $array['body']['contenttype'] = 'url'; } else { $array['body']['contenttype'] = 'single_map'; } //} //if (empty($array)) showMessage(Language::get('param_error')); // } // } $data['content'] = serialize($array); } elseif ($_POST['rec_type'] == 2 && $_POST['pic_type'] == 2) { //文章 if (empty($_FILES['article_pic']['name'])) { $filename = $_REQUEST['default_article_img']; } else { $ext = strtolower(pathinfo($_FILES['article_pic']['name'], PATHINFO_EXTENSION)); if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) { $filename = substr(md5(microtime(true)), 0, 16) . rand(100, 999) . '.' . $ext; if ($_FILES['article_pic']['size'] < 1024 * 1024) { move_uploaded_file($_FILES['article_pic']['tmp_name'], BASE_UPLOAD_PATH . '/' . ATTACH_REC_POSITION . '/' . $filename); } if ($_FILES['article_pic']['error'] != 0) { showMessage(Language::get('nc_common_op_fail')); } } } $array['body']['targetid'] = $_REQUEST['article_id']; $array['body']['contenttype'] = 'sms_article'; $array['body']['imageurl'] = $filename; $array['body']['requesturl'] = '/cms/index.php?act=article&op=article_detail&article_id=' . $_REQUEST['article_id']; //$array['width'] = is_numeric($_POST['rwidth']) ? $_POST['rwidth'] : ''; //$array['height'] = is_numeric($_POST['rheight']) ? $_POST['rheight'] : ''; $array['body']['cat_id'] = $_REQUEST['article_class']; //} //if (empty($array)) showMessage(Language::get('param_error')); $data['content'] = serialize($array); } else { if ($_POST['rec_type'] == 2 && $_POST['pic_type'] == 3) { //showMessage(Language::get('param_error')); } else { if ($_POST['rec_type'] == 2 && $_POST['pic_type'] == 4) { //平台活动 if (empty($_FILES['actiity_pic']['name'])) { $filename = $_REQUEST['default_img']; } else { $ext = strtolower(pathinfo($_FILES['actiity_pic']['name'], PATHINFO_EXTENSION)); if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) { $filename = substr(md5(microtime(true)), 0, 16) . rand(100, 999) . '.' . $ext; if ($_FILES['actiity_pic']['size'] < 1024 * 1024) { move_uploaded_file($_FILES['actiity_pic']['tmp_name'], BASE_UPLOAD_PATH . '/' . ATTACH_REC_POSITION . '/' . $filename); } if ($_FILES['actiity_pic']['error'] != 0) { showMessage(Language::get('nc_common_op_fail')); } } } if ($_REQUEST['activity_type'] == 'pf_goods') { $activity = Model('activity'); //$act_condition['field']='item_id'; $act_condition['opening'] = true; $act_condition['activity_id'] = $_POST['activity_id']; $act_list = $activity->getJoinList($act_condition); $array1 = array(); foreach ($act_list as $key => $value) { $array1[] = $value['item_id']; } $string = implode(',', $array1); $array['body']['imageurl'] = $filename; $array['body']['contenttype'] = 'pf_goods'; $array['body']['targetid'] = $_REQUEST['activity_id']; $array['body']['goodsid'] = $string; $array['body']['requesturl'] = PG_R_PATH; } else { $array['body']['title'] = $_REQUEST['ad_title']; //$array['body']['imageurl'] = ATTACH_REC_POSITION.'/'.$_SESSION['store_id'].'/'.$filename; $array['body']['imageurl'] = $filename; $array['body']['requesturl'] = '/mobile/index.php?act=activity&op=sa_datail&activity_id=' . $_REQUEST['activity_id']; $array['body']['targetid'] = $_REQUEST['activity_id']; $array['body']['contenttype'] = $_REQUEST['activity_type']; } $data['content'] = serialize($array); } } } $data['pic_type'] = $_POST['rec_type']; $data['pic_width'] = $_POST['rwidth']; $data['pic_height'] = $_POST['rheight']; $data['rec_app'] = $_POST['rec_app']; $data['rec_state'] = $_POST['rec_state']; $data['rec_start_time'] = strtotime($_POST['stime']); $data['rec_stop_time'] = strtotime($_POST['etime']); $data['rec_position'] = $_POST['rec_position']; $data['rec_content_type'] = $_POST['pic_type']; $array['target'] = intval($_POST['rtarget']); $data['title'] = $_POST['rtitle']; $model = Model('rec_position'); //如果是把本地上传类型改为文字或远程,则先取出原来上传的图片路径,待update成功后,再删除这些图片 if ($_POST['opic_type'] == 1 && ($_POST['pic_type'] == 2 || $_POST['rec_type'] == 1)) { $oinfo = $model->where(array('rec_id' => $_POST['rec_id']))->find(); $oinfo = unserialize($oinfo['content']); } $result = $model->where(array('rec_id' => $_POST['rec_id']))->update($data); if ($result) { if ($oinfo) { foreach ($oinfo['body'] as $v) { if (is_file(BASE_UPLOAD_PATH . '/' . $v['title'])) { @unlink(BASE_UPLOAD_PATH . '/' . $v['title']); } } } dkcache("rec_position/{$_POST['rec_id']}"); showMessage(Language::get('nc_common_save_succ'), 'index.php?act=rec_position&op=rec_list'); } else { showMessage(Language::get('nc_common_save_fail'), 'index.php?act=rec_position&op=rec_list'); } }
/** * ajax操作 */ public function ajaxOp() { switch ($_GET['branch']) { /** * 页面导航 排序 */ case 'nav_sort': $model_navigation = Model('navigation'); $update_array = array(); $update_array['nav_id'] = intval($_GET['id']); $update_array[$_GET['column']] = trim($_GET['value']); $result = $model_navigation->update($update_array); dkcache('nav'); echo 'true'; exit; break; } }
/** * 删除缓存 */ public function dropApCacheByAdvIds($advIds) { $apIds = array_keys((array) Model()->table('adv')->field('ap_id')->where(array('adv_id' => array('in', (array) $advIds)))->key('ap_id')->select()); foreach ($apIds as $apId) { $apId = (int) $apId; dkcache("adv/{$apId}"); } }
/** * 分类SEO保存 * */ public function seo_categoryOp() { if (chksubmit()) { $where = array('gc_id' => intval($_POST['category'])); $input = array(); $input['gc_title'] = $_POST['cate_title']; $input['gc_keywords'] = $_POST['cate_keywords']; $input['gc_description'] = $_POST['cate_description']; if (Model('goods_class')->editGoodsClass($input, $where)) { dkcache('goods_class_seo'); showMessage(L('nc_common_save_succ')); } } showMessage(L('nc_common_save_fail')); }
/** * 编辑频道 */ public function edit_channelOp() { $model_channel = Model('web_channel'); $condition = array(); $condition['channel_id'] = intval($_GET['channel_id']); $channel_list = $model_channel->getChannelList($condition); $channel = $channel_list[0]; if (uk86_chksubmit()) { $channel_array = array(); $channel_array['channel_name'] = $_POST['channel_name']; $channel_array['channel_style'] = $_POST['channel_style']; $channel_array['keywords'] = $_POST['keywords']; $channel_array['description'] = $_POST['description']; $channel_array['channel_show'] = intval($_POST['channel_show']); //是否启用,0为否,1为是 $channel_array['update_time'] = time(); $state = $model_channel->editChannel($condition, $channel_array); if ($state) { $this->log('编辑商城频道,编号' . $condition['channel_id']); dkcache('channel'); uk86_showMessage(Uk86Language::uk86_get('nc_common_save_succ'), 'index.php?act=web_channel&op=web_channel'); } else { uk86_showMessage(Uk86Language::uk86_get('nc_common_save_fail')); } } Tpl::output('channel', $channel); Tpl::showpage('web_channel.edit'); }