/** * 获得指定分类同级的所有分类以及该分类下的子分类 * * @access public * @param integer $cat_id 分类编号 * @return array */ function get_categories_tree_pro($cat_id = 0) { if ($cat_id > 0) { $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'"; $parent_id = $GLOBALS['db']->getOne($sql); } else { $parent_id = 0; } $admin_agency_id = admin_agency_id() ? admin_agency_id() : agency_id(); if ($admin_agency_id) { // $where = " AND (FIND_IN_SET('$admin_agency_id',agency_cat) OR host_cat = 1) "; //注释2015-03-19 ccx $where = " AND (FIND_IN_SET('{$admin_agency_id}',agency_cat)) "; } else { $where = "AND host_cat = 1 "; } /* 判断当前分类中全是是否是底级分类, 如果是取出底级分类上级分类, 如果不是取当前分类及其下的子分类 */ $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$parent_id}' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $parent_id == 0) { /* 获取当前分类及其子分类 */ $sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$parent_id}' AND is_show = 1 {$where} ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($sql); foreach ($res as $row) { $cat_id = $row['cat_id']; $children = get_children($cat_id); $cat = $GLOBALS['db']->getRow('SELECT cat_name, keywords, cat_desc, style, grade, filter_attr, parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'"); /* 获取分类下文章 */ $sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type FROM ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac RIGHT JOIN ' . $GLOBALS['ecs']->table('article') . " AS a ON a.cat_id=ac.cat_id AND a.is_open = 1 WHERE ac.cat_name='{$row['cat_name']}' ORDER BY a.article_type,a.article_id DESC LIMIT 4 "; $articles = $GLOBALS['db']->getAll($sql); foreach ($articles as $key => $val) { $articles[$key]['url'] = $val['open_type'] != 1 ? build_uri('article', array('aid' => $val['article_id']), $val['title']) : trim($val['file_url']); } /* 获取分类下品牌 */ $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag " . "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, " . $GLOBALS['ecs']->table('goods') . " AS g LEFT JOIN " . $GLOBALS['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " . "WHERE g.brand_id = b.brand_id AND ({$children} OR " . 'gc.cat_id ' . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ") AND b.is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC"; //dump($sql); $brands = $GLOBALS['db']->getAll($sql); foreach ($brands as $key => $val) { $brands[$key]['brand_name'] = $val['brand_name']; $brands[$key]['url'] = build_uri('category', array('cid' => $cat_id, 'bid' => $val['brand_id'], 'price_min' => $price_min, 'price_max' => $price_max, 'filter_attr' => $filter_attr_str), $cat['cat_name']); } $cat_arr[$row['cat_id']]['brands'] = $brands; $cat_arr[$row['cat_id']]['articles'] = $articles; if ($row['is_show']) { $cat_arr[$row['cat_id']]['id'] = $row['cat_id']; $cat_arr[$row['cat_id']]['name'] = $row['cat_name']; $cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $cat_arr[$row['cat_id']]['cat_id'] = get_child_tree_pro($row['cat_id']); } } } } if (isset($cat_arr)) { return $cat_arr; } }
/** * 获得指定分类同级的所有分类以及该分类下的子分类 * * @access public * @param integer $cat_id 分类编号 * @return array */ function get_categories_tree($cat_id = 0) { if ($cat_id > 0) { $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'"; $parent_id = $GLOBALS['db']->getOne($sql); } else { $parent_id = 0; } $admin_agency_id = admin_agency_id() ? admin_agency_id() : agency_id(); if ($admin_agency_id) { //$where = " AND (FIND_IN_SET('$admin_agency_id',agency_cat) OR host_cat = 1) "; //注释2015-03-19 ccx $where = " AND (FIND_IN_SET('{$admin_agency_id}',agency_cat) ) "; } else { $where = "AND host_cat = 1 "; } //dump($where); /* 判断当前分类中全是是否是底级分类, 如果是取出底级分类上级分类, 如果不是取当前分类及其下的子分类 */ $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$parent_id}' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $parent_id == 0) { /* 获取当前分类及其子分类 */ $sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$parent_id}' AND is_show = 1 {$where} ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($sql); //dump($res); foreach ($res as $row) { if ($row['is_show']) { $cat_arr[$row['cat_id']]['id'] = $row['cat_id']; $cat_arr[$row['cat_id']]['name'] = $row['cat_name']; $cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $cat_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']); } } } } if (isset($cat_arr)) { return $cat_arr; } }
/** * 说明:删除分类 * @$cat_id 分类ID; * **/ public function del_cat($cat_id) { $admin_agency_id = admin_agency_id(); $cat_res = $GLOBALS['db']->getRow("SELECT agency_cat,host_cat FROM " . $GLOBALS['ecs']->table('category') . " WHERE cat_id = {$cat_id}"); if ($admin_agency_id) { if ($cat_res['agency_cat'] == ',' . $admin_agency_id . ',' && empty($cat_res['host_cat'])) { //删除代理商分类属性 $GLOBALS['db']->query("DELETE FROM" . $GLOBALS['ecs']->table('category_attribute') . " WHERE cat_id={$cat_id} AND admin_agency_id={$admin_agency_id}"); return true; } else { //删除代理商分类标识和分类属性 $this->agency_del_cat($cat_res['agency_cat'], $cat_id, $admin_agency_id); return false; } } else { if (empty($cat_res['agency_cat'])) { return true; } else { $GLOBALS['db']->query("UPDATE " . $GLOBALS['ecs']->table('category') . " SET host_cat = 0 WHERE cat_id = {$cat_id} "); return false; } } }
function get_newadslist() { /* 过滤查询 */ $ad_name = !empty($_REQUEST['ad_name']) ? (string) $_REQUEST['ad_name'] : ''; $filter = array(); $filter['ad_name'] = $ad_name; $filter['admin_agency_id'] = !empty($_REQUEST['admin_agency_id']) ? (int) $_REQUEST['admin_agency_id'] : '0'; $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'ad_name' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = 'WHERE 1 '; $admin_agency_id = admin_agency_id(); if ($ad_name) { $where .= ' AND ad_name like \'%' . $ad_name . '%\''; } if ($filter['admin_agency_id']) { $where .= " AND admin_agency_id = {$filter['admin_agency_id']} "; } else { $where .= " AND admin_agency_id = {$admin_agency_id} "; } /* 获得总记录数据 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('ad_new') . ' AS ad ' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获得广告数据 */ $arr = array(); $sql = 'SELECT ad.id,po.id as position_id,position_name,keyword,particulars,url,img,width,height,admin_agency_id,file,ad_name,start FROM ' . $GLOBALS['ecs']->table('ad_new') . ' AS ad left join ' . $GLOBALS['ecs']->table('ad_new_position') . ' as po on po.id = ad.position_id ' . $where . 'ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { if (strpos($rows['img'], 'http://') === false) { $rows['img'] = 'http://' . agency_url() . '/' . $rows['img']; } if ($rows['start'] == 1) { $rows['start'] = '是'; } else { $rows['start'] = 'NO'; } $arr[] = $rows; } return array('ads' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
} /** * 插入首页推荐扩展分类 * * @access public * @param array $recommend_type 推荐类型 * @param integer $cat_id 分类ID * * @return void */ function insert_cat_recommend($recommend_type, $cat_id) { $admin_agency_id = admin_agency_id(); //代理商user_id //检查分类是否为首页推荐 if (!empty($recommend_type)) { //取得之前的分类 $recommend_res = $GLOBALS['db']->getAll("SELECT recommend_type FROM " . $GLOBALS['ecs']->table("cat_recommend") . " WHERE cat_id=" . $cat_id . " AND admin_agency_id = {$admin_agency_id}"); if (empty($recommend_res)) { foreach ($recommend_type as $data) { $data = intval($data); $GLOBALS['db']->query("INSERT INTO " . $GLOBALS['ecs']->table("cat_recommend") . "(cat_id, recommend_type,admin_agency_id) VALUES ('{$cat_id}', '{$data}',{$admin_agency_id})"); } } else { $old_data = array(); foreach ($recommend_res as $data) { $old_data[] = $data['recommend_type']; } $delete_array = array_diff($old_data, $recommend_type); if (!empty($delete_array)) { $GLOBALS['db']->query("DELETE FROM " . $GLOBALS['ecs']->table("cat_recommend") . " WHERE cat_id={$cat_id} AND recommend_type " . db_create_in($delete_array) . " AND admin_agency_id = {$admin_agency_id}"); } $insert_array = array_diff($recommend_type, $old_data); if (!empty($insert_array)) { foreach ($insert_array as $data) { $data = intval($data); $GLOBALS['db']->query("INSERT INTO " . $GLOBALS['ecs']->table("cat_recommend") . "(cat_id, recommend_type,admin_agency_id) VALUES ('{$cat_id}', '{$data}',{$admin_agency_id})"); } } } } else { $GLOBALS['db']->query("DELETE FROM " . $GLOBALS['ecs']->table("cat_recommend") . " WHERE cat_id=" . $cat_id . " AND admin_agency_id = {$admin_agency_id}"); }
$smarty->assign('form_act', 'insert'); $smarty->assign('vote_arr', $vote); $smarty->assign('cfg_lang', $_CFG['lang']); /* 显示页面 */ assign_query_info(); $smarty->display('vote_info.htm'); } elseif ($_REQUEST['act'] == 'insert') { admin_priv('vote_priv'); /* 获得广告的开始时期与结束日期 */ $start_time = local_strtotime($_POST['start_time']); $end_time = local_strtotime($_POST['end_time']); /* 查看广告名称是否有重复 */ $sql = "SELECT COUNT(*) FROM " . $ecs->table('vote') . " WHERE vote_name='{$_POST['vote_name']}'"; if ($db->getOne($sql) == 0) { /* 插入数据 */ $sql = "INSERT INTO " . $ecs->table('vote') . " (vote_name, start_time, end_time, can_multi, vote_count,admin_agency_id)\r\n VALUES ('{$_POST['vote_name']}', '{$start_time}', '{$end_time}', '{$_POST['can_multi']}', '0'," . admin_agency_id() . ")"; $db->query($sql); $new_id = $db->Insert_ID(); /* 记录管理员操作 */ admin_log($_POST['vote_name'], 'add', 'vote'); /* 清除缓存 */ clear_cache_files(); /* 提示信息 */ $link[0]['text'] = $_LANG['continue_add_option']; $link[0]['href'] = 'vote.php?act=option&id=' . $new_id; $link[1]['text'] = $_LANG['continue_add_vote']; $link[1]['href'] = 'vote.php?act=add'; $link[2]['text'] = $_LANG['back_list']; $link[2]['href'] = 'vote.php?act=list'; sys_msg($_LANG['add'] . " " . $_POST['vote_name'] . " " . $_LANG['attradd_succed'], 0, $link); } else {
function agency_goods_list() { /* 过滤查询 */ $code = empty($_REQUEST['extension_code']) ? '' : trim($_REQUEST['extension_code']); $code = $code == 'virtual_card' ? 'virtual_card' : ''; $cat_id = isset($_POST['cat_id']) ? intval($_POST['cat_id']) : 0; $brand_id = isset($_POST['brand_id']) ? intval($_POST['brand_id']) : 0; $keyword = isset($_POST['keyword']) ? trim($_POST['keyword']) : ''; $GLOBALS['smarty']->assign('action_link', list_link($is_add, $code)); //$GLOBALS['smarty']->assign('cat_list', cat_list(0, $cat_id)); // 注释 2015-03-19 代理商跟主站的分类分开 /*ccx 2015-03-18 代理商显示代理商自己的商品分类 start */ $GLOBALS['smarty']->assign('cat_list', cat_list_ccx(0, $cat_id)); /*ccx 2015-03-18 代理商显示代理商自己的商品分类 end */ $GLOBALS['smarty']->assign('brand_list', get_brand_list()); $GLOBALS['smarty']->assign('search_keyword', $keyword); $GLOBALS['smarty']->assign('brand_id', $brand_id); $filter = array(); $filter['cat_id'] = $cat_id; $filter['brand_id'] = $brand_id; $filter['keyword'] = $keyword; $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'goods_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = ' WHERE is_delete = 0 and admin_agency_id = 0 '; if ($code) { $where .= " AND is_real = 0 "; } else { $where .= " AND is_real = 1 "; } if ($cat_id > 0) { $where .= " AND cat_id = '{$cat_id}' "; } if ($brand_id > 0) { $where .= " AND brand_id = '{$brand_id}' "; } if ($keyword) { $where .= ' AND goods_name like \'%' . mysql_real_escape_string($keyword) . '%\'' . ' OR goods_sn like \'%' . $keyword . '%\''; } $admin_agency_id = admin_agency_id(); if ($admin_agency_id) { $where .= " AND (SELECT goods_id FROM " . $GLOBALS['ecs']->table('goods') . " WHERE admin_agency_id = {$admin_agency_id} and host_goods_id = g.goods_id limit 1) is null"; } /* 获得总记录数据 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('goods') . ' as g' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获得商品数据 */ $arr = array(); $sql = 'SELECT goods_id,goods_name,goods_sn,shop_price,costing_price' . ' FROM ' . $GLOBALS['ecs']->table('goods') . ' as g ' . $where . ' ORDER BY goods_id desc '; $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $arr[] = $rows; } //是否已添加 foreach ($arr as $good_k => $good_v) { $goods_id_arr[] = $good_v['goods_id']; $goods_price_arr[] = $good_v['shop_price']; } $filter['goods_id_arr'] = json_encode($goods_id_arr); $filter['goods_price_arr'] = json_encode($goods_price_arr); //dump($arr); return array('goods_res' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
* 网站地址: http://www..com; * ---------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ========================================================== * $Author: liubo $ * $Id: affiliate.php 17217 2011-01-19 06:29:08Z liubo $ */ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; admin_priv('affiliate'); /*------------------------------------------------------ */ //-- 分成管理页 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { $admin_agency_id = admin_agency_id(); if (empty($_REQUEST['is_ajax'])) { $smarty->assign('full_page', 1); } $sql = 'SELECT v2_percent FROM ' . $ecs->table('split_instal') . " WHERE is_line='1'"; $split_instal = $db->getRow($sql); $smarty->assign('ur_here', $_LANG['split_instal']); $smarty->assign('split_instal', $split_instal); $smarty->display('split_instal.htm'); } elseif ($_REQUEST['act'] == 'updata') { $v2_percent = $_REQUEST['v2_percent']; $sql_1 = "DELETE FROM " . $ecs->table('split_instal') . " WHERE is_line = '1' "; $db->query($sql_1); $sql = "INSERT INTO " . $ecs->table('split_instal') . " (v2_percent, is_line) " . "VALUES ( '{$v2_percent}', '1')"; $db->query($sql, 'SILENT'); $links[] = array('text' => $_LANG['affiliate'], 'href' => 'split_instal.php?act=list');
sys_msg($_LANG['error_price_ladder']); } /* 限购数量不能小于价格阶梯中的最大数量 */ $amount_list = array_keys($price_ladder); if ($restrict_amount > 0 && max($amount_list) > $restrict_amount) { sys_msg($_LANG['error_restrict_amount']); } ksort($price_ladder); $price_ladder = array_values($price_ladder); /* 检查开始时间和结束时间是否合理 */ $start_time = local_strtotime($_POST['start_time']); $end_time = local_strtotime($_POST['end_time']); if ($start_time >= $end_time) { sys_msg($_LANG['invalid_time']); } $group_buy = array('act_name' => $act_name, 'act_desc' => $_POST['act_desc'], 'act_type' => GAT_GROUP_BUY, 'goods_id' => $goods_id, 'goods_name' => $goods_name, 'start_time' => $start_time, 'end_time' => $end_time, 'ext_info' => serialize(array('price_ladder' => $price_ladder, 'restrict_amount' => $restrict_amount, 'gift_integral' => $gift_integral, 'deposit' => $deposit)), 'admin_agency_id' => admin_agency_id(), 'oncenumber' => $_POST['oncenumber']); /* 清除缓存 */ clear_cache_files(); /* 保存数据 */ if ($group_buy_id > 0) { /* update */ $db->autoExecute($ecs->table('goods_activity'), $group_buy, 'UPDATE', "act_id = '{$group_buy_id}'"); /* log */ admin_log(addslashes($goods_name) . '[' . $group_buy_id . ']', 'edit', 'group_buy'); /* todo 更新活动表 */ /* 提示信息 */ $links = array(array('href' => 'group_buy.php?act=list&' . list_link_postfix(), 'text' => $_LANG['back_list'])); sys_msg($_LANG['edit_success'], 0, $links); } else { /* insert */ $db->autoExecute($ecs->table('goods_activity'), $group_buy, 'INSERT');
} if (empty($_POST['end_price'])) { $_POST['end_price'] = 0; } if (empty($_POST['max_price'])) { $_POST['max_price'] = 0; } if (empty($_POST['cost_points'])) { $_POST['cost_points'] = 0; } if (isset($_POST['product_id']) && empty($_POST['product_id'])) { $_POST['product_id'] = 0; } $info = array('start_price' => $_POST['start_price'], 'end_price' => $_POST['end_price'], 'max_price' => $_POST['max_price'], 'cost_points' => $_POST['cost_points']); /* 插入数据 */ $record = array('act_name' => $_POST['snatch_name'], 'act_desc' => $_POST['desc'], 'act_type' => GAT_SNATCH, 'goods_id' => $_POST['goods_id'], 'goods_name' => $_POST['goods_name'], 'start_time' => $_POST['start_time'], 'end_time' => $_POST['end_time'], 'product_id' => $_POST['product_id'], 'is_finished' => 0, 'ext_info' => serialize($info), 'admin_agency_id' => admin_agency_id()); $db->AutoExecute($ecs->table('goods_activity'), $record, 'INSERT'); admin_log($_POST['snatch_name'], 'add', 'snatch'); $link[] = array('text' => $_LANG['back_list'], 'href' => 'snatch.php?act=list'); $link[] = array('text' => $_LANG['continue_add'], 'href' => 'snatch.php?act=add'); sys_msg($_LANG['add_succeed'], 0, $link); } elseif ($_REQUEST['act'] == 'list') { $smarty->assign('ur_here', $_LANG['02_snatch_list']); $smarty->assign('action_link', array('text' => $_LANG['snatch_add'], 'href' => 'snatch.php?act=add')); $snatchs = get_snatchlist(); $smarty->assign('snatch_list', $snatchs['snatchs']); $smarty->assign('filter', $snatchs['filter']); $smarty->assign('record_count', $snatchs['record_count']); $smarty->assign('page_count', $snatchs['page_count']); $sort_flag = sort_flag($snatchs['filter']); $smarty->assign($sort_flag['tag'], $sort_flag['img']);
} /* 特殊等级会员组不判断积分限制 */ if ($special_rank == 0) { /* 检查下限制有无重复 */ if (!$exc->is_only('min_points', intval($_POST['min_points']))) { sys_msg(sprintf($_LANG['integral_min_exists'], intval($_POST['min_points']))); } } /* 特殊等级会员组不判断积分限制 */ if ($special_rank == 0) { /* 检查上限有无重复 */ if (!$exc->is_only('max_points', intval($_POST['max_points']))) { sys_msg(sprintf($_LANG['integral_max_exists'], intval($_POST['max_points']))); } } $sql = "INSERT INTO " . $ecs->table('user_rank') . "( " . "rank_name, min_points, max_points, discount, special_rank, show_price,admin_agency_id,rank_start_num" . ") VALUES (" . "'{$_POST['rank_name']}', '" . intval($_POST['min_points']) . "', '" . intval($_POST['max_points']) . "', " . "'{$_POST['discount']}', '{$special_rank}', '" . intval($_POST['show_price']) . "'," . admin_agency_id() . ",{$_POST['rank_start_num']})"; $db->query($sql); /* 管理员日志 */ admin_log(trim($_POST['rank_name']), 'add', 'user_rank'); clear_cache_files(); $lnk[] = array('text' => $_LANG['back_list'], 'href' => 'user_rank.php?act=list'); $lnk[] = array('text' => $_LANG['add_continue'], 'href' => 'user_rank.php?act=add'); sys_msg($_LANG['add_rank_success'], 0, $lnk); } elseif ($_REQUEST['act'] == 'remove') { check_authz_json('user_rank'); $rank_id = intval($_GET['id']); /*add by hg for date 2014-03-27*/ if ($rank_id == 4) { $rank_id = 0; } static_goods($rank_id, 'user_rank', 'rank_id');
function and_agency_url($agency_user_id = '') { $agency_user_id = $agency_user_id ? $agency_user_id : admin_agency_id(); return $GLOBALS['db']->getOne("select agency_url from " . $GLOBALS['ecs']->table('agency_url') . " where agency_user_id = '{$agency_user_id}'"); }
function get_info_list() { /* 过滤查询 */ $info_cat = !empty($_REQUEST['info_cat']) ? trim($_REQUEST['info_cat']) : ''; $img_spec = !empty($_REQUEST['img_spec']) ? trim($_REQUEST['img_spec']) : ''; $info_words = !empty($_REQUEST['info_words']) ? trim($_REQUEST['info_words']) : ''; $filter = array(); $filter['info_cat'] = $info_cat; $filter['img_spec'] = $img_spec; $filter['info_words'] = $info_words; $filter['admin_agency_id'] = isset($_REQUEST['admin_agency_id']) ? intval($_REQUEST['admin_agency_id']) : admin_agency_id(); $where = " WHERE 1 "; if (isset($filter['admin_agency_id'])) { $where .= " AND admin_agency_id = " . $filter['admin_agency_id']; } if ($info_cat) { $where .= " AND info_cat_id = '{$info_cat}' "; } if ($img_spec) { $where .= " AND img_spec = '{$img_spec}' "; } if ($info_words) { $where .= " AND title_describe like '%{$info_words}%' OR content_describe like '%{$info_words}%'"; } /* 获得总记录数据 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('information') . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获得广告数据 */ $info = array(); $rows = array(); $sql_info = "SELECT info_id,info_cat_id,img_spec,img_file,title_describe,content_describe,link_url,is_start FROM " . $GLOBALS['ecs']->table('information') . $where; $rows = $GLOBALS['db']->selectLimit($sql_info, $filter['page_size'], $filter['start']); while ($row = $GLOBALS['db']->fetchRow($rows)) { $sql_info_cat_name = "SELECT info_cat_name FROM " . $GLOBALS['ecs']->table('information_category') . " WHERE info_cat_id = " . $row['info_cat_id']; $row['info_cat'] = $GLOBALS['db']->getOne($sql_info_cat_name); $info[] = $row; } //dump($info); return array('info' => $info, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
function get_info_cats_list() { /* 过滤查询 */ $info_cat_word = !empty($_REQUEST['info_cat_word']) ? trim($_REQUEST['info_cat_word']) : ''; $filter = array(); $filter['info_cat_word'] = $info_cat_word; $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'info_cat_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'ASC' : trim($_REQUEST['sort_order']); $filter['admin_agency_id'] = isset($_REQUEST['admin_agency_id']) ? intval($_REQUEST['admin_agency_id']) : admin_agency_id(); //dump($filter); $where = ' WHERE 1 '; if (isset($filter['admin_agency_id'])) { $where .= " AND admin_agency_id = " . $filter['admin_agency_id']; } if ($info_cat_word) { $where .= ' AND info_cat_name like \'%' . $info_cat_word . '%\''; } /* 获得总记录数据 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('information_category') . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获得资讯类别名称数据 */ $arr = array(); $sql_info_cat = "SELECT info_cat_id,article_cat_id,info_cat_name,show_order,is_show FROM " . $GLOBALS['ecs']->table('information_category') . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $res = $GLOBALS['db']->selectLimit($sql_info_cat, $filter['page_size'], $filter['start']); while ($row = $GLOBALS['db']->fetchRow($res)) { $arr[] = $row; } //print_r($arr); return array('info_cats' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
admin_priv('auction'); /* 是否添加 */ $is_add = $_REQUEST['act'] == 'insert'; /* 检查是否选择了商品 */ $goods_id = intval($_POST['goods_id']); if ($goods_id <= 0) { sys_msg($_LANG['pls_select_goods']); } $sql = "SELECT goods_name FROM " . $ecs->table('goods') . " WHERE goods_id = '{$goods_id}'"; $row = $db->getRow($sql); if (empty($row)) { sys_msg($_LANG['goods_not_exist']); } $goods_name = $row['goods_name']; /* 提交值 */ $auction = array('act_id' => intval($_POST['id']), 'act_name' => empty($_POST['act_name']) ? $goods_name : sub_str($_POST['act_name'], 255, false), 'act_desc' => $_POST['act_desc'], 'act_type' => GAT_AUCTION, 'goods_id' => $goods_id, 'product_id' => empty($_POST['product_id']) ? 0 : $_POST['product_id'], 'goods_name' => $goods_name, 'start_time' => local_strtotime($_POST['start_time']), 'end_time' => local_strtotime($_POST['end_time']), 'admin_agency_id' => admin_agency_id(), 'ext_info' => serialize(array('deposit' => round(floatval($_POST['deposit']), 2), 'start_price' => round(floatval($_POST['start_price']), 2), 'end_price' => empty($_POST['no_top']) ? round(floatval($_POST['end_price']), 2) : 0, 'amplitude' => round(floatval($_POST['amplitude']), 2), 'no_top' => !empty($_POST['no_top']) ? intval($_POST['no_top']) : 0))); /* 保存数据 */ if ($is_add) { $auction['is_finished'] = 0; $db->autoExecute($ecs->table('goods_activity'), $auction, 'INSERT'); $auction['act_id'] = $db->insert_id(); } else { $db->autoExecute($ecs->table('goods_activity'), $auction, 'UPDATE', "act_id = '{$auction['act_id']}'"); } /* 记日志 */ if ($is_add) { admin_log($auction['act_name'], 'add', 'auction'); } else { admin_log($auction['act_name'], 'edit', 'auction'); } /* 清除缓存 */
<?php define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; $act = $_REQUEST['act']; if ($act == 'tm') { $admin_user_id = admin_agency_id(); $res = $db->getRow("SELECT user_name,password,tm_mark FROM " . $ecs->table('users') . " WHERE user_id = {$admin_user_id}"); if ((int) $res['tm_mark'] == 1) { $arr = array(); $arr['username'] = substr($res['user_name'], strlen(TMUSER)); $arr['password'] = $res['password']; $str = http_build_query($arr); $obj = new lu_compile(); //加密类 $obj_user = new tm_user(); //加密类 $data = $obj->encrypt($str); header("Location:http://taobao.ba.com/auth/login_o2o?data={$data}"); } sys_msg('统计信息不存在或请求错误,请稍后再试', 0, $links); }
if ($GLOBALS['db']->errno() == 0) { $url = 'order.php?act=query&' . str_replace('act=remove_order', '', $_SERVER['QUERY_STRING']); ecs_header("Location: {$url}\n"); exit; } else { make_json_error($GLOBALS['db']->errorMsg()); } } elseif ($_REQUEST['act'] == 'search_users') { include_once ROOT_PATH . 'includes/cls_json.php'; $json = new JSON(); $id_name = empty($_GET['id_name']) ? '' : json_str_iconv(trim($_GET['id_name'])); $result = array('error' => 0, 'message' => '', 'content' => ''); if ($id_name != '') { /* 加入会员归属条件 */ if (!if_agency()) { $top_rank = admin_agency_id(); if (!empty($top_rank)) { $where = "top_rank = {$top_rank} AND "; } } $sql = "SELECT user_id, user_name FROM " . $GLOBALS['ecs']->table('users') . " WHERE {$where} (user_id LIKE '%" . mysql_like_quote($id_name) . "%'" . " OR user_name LIKE '%" . mysql_like_quote($id_name) . "%')" . " LIMIT 20"; $res = $GLOBALS['db']->query($sql); $result['userlist'] = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { $result['userlist'][] = array('user_id' => $row['user_id'], 'user_name' => $row['user_name']); } } else { $result['error'] = 1; $result['message'] = 'NO KEYWORDS!'; } die($json->encode($result));
$smarty->assign('brand_list', get_brands()); $smarty->assign('promotion_info', get_promotion_info()); // 增加一个动态显示所有促销信息的标签栏 $smarty->assign('invoice_list', index_get_invoice_query()); // 发货查询 $smarty->assign('new_articles', index_get_new_articles()); // 最新文章 //dump(index_get_new_articles()); $smarty->assign('group_buy_goods', index_get_group_buy()); // 团购商品 $smarty->assign('auction_list', index_get_auction()); // 拍卖活动 $smarty->assign('shop_notice', $_CFG['shop_notice']); // 商店公告 //获取资讯分类及信息 $obj_info = new class_information(admin_agency_id()); $info_cats = $obj_info->get_info_cats(); $info_lists = $obj_info->get_infos_list(); $smarty->assign('info_cats', $info_cats); $smarty->assign('info_lists', $info_lists); //dump($infos_list); /* 首页主广告设置 */ $smarty->assign('index_ad', $_CFG['index_ad']); if ($_CFG['index_ad'] == 'cus') { $sql = 'SELECT ad_type, content, url FROM ' . $ecs->table("ad_custom") . ' WHERE ad_status = 1'; $ad = $db->getRow($sql, true); $smarty->assign('ad', $ad); } /* links */ $links = index_get_links(); $smarty->assign('img_links', $links['img']);
/** * ccx 2015-03-17 获取主站的商品分类 start * 获得指定分类下的子分类的数组 * * @access public * @param int $cat_id 分类的ID * @param int $selected 当前选中分类的ID * @param boolean $re_type 返回的类型: 值为真时返回下拉列表,否则返回数组 * @param int $level 限定返回的级数。为0时返回所有级数 * @param int $is_show_all 如果为true显示所有分类,如果为false隐藏不可见分类。 * @return mix */ function cat_list_host_category($cat_id = 0, $selected = 0, $re_type = true, $level = 0, $is_show_all = true) { static $res = NULL; $where = "WHERE c.host_cat = 1 "; if ($res === NULL) { $data = read_static_cache('cat_pid_releate'); $data = false; if ($data === false) { $sql = "SELECT c.host_cat,c.agency_cat,c.cat_id, c.cat_name, c.measure_unit, c.parent_id, c.is_show," . "c.show_in_nav, c.grade, c.sort_order, COUNT(s.cat_id) AS has_children " . 'FROM ' . $GLOBALS['ecs']->table('category') . " AS c " . "LEFT JOIN " . $GLOBALS['ecs']->table('category') . " AS s ON s.parent_id=c.cat_id " . " {$where} GROUP BY c.cat_id " . 'ORDER BY c.parent_id, c.sort_order ASC'; $res = $GLOBALS['db']->getAll($sql); $sql = "SELECT cat_id, COUNT(*) AS goods_num " . " FROM " . $GLOBALS['ecs']->table('goods') . " WHERE is_delete = 0 AND is_on_sale = 1 " . " GROUP BY cat_id"; $res2 = $GLOBALS['db']->getAll($sql); $sql = "SELECT gc.cat_id, COUNT(*) AS goods_num " . " FROM " . $GLOBALS['ecs']->table('goods_cat') . " AS gc , " . $GLOBALS['ecs']->table('goods') . " AS g " . " WHERE g.goods_id = gc.goods_id AND g.is_delete = 0 AND g.is_on_sale = 1 " . " GROUP BY gc.cat_id"; $res3 = $GLOBALS['db']->getAll($sql); $newres = array(); foreach ($res2 as $k => $v) { $newres[$v['cat_id']] = $v['goods_num']; foreach ($res3 as $ks => $vs) { if ($v['cat_id'] == $vs['cat_id']) { $newres[$v['cat_id']] = $v['goods_num'] + $vs['goods_num']; } } } foreach ($res as $k => $v) { $res[$k]['goods_num'] = !empty($newres[$v['cat_id']]) ? $newres[$v['cat_id']] : 0; if (admin_agency_id()) { $res[$k]['agency_state'] = strpos($v['agency_cat'], ',' . admin_agency_id() . ',') !== false ? 1 : 0; $sql = "select cat_id from " . $GLOBALS['ecs']->table('category') . " where host_cat = " . $v['cat_id'] . " AND agency_cat = '," . admin_agency_id() . ",'"; $is_lead = $GLOBALS['db']->GetOne($sql); if ($is_lead > 0) { $res[$k]['is_lead'] = 1; //该分类被引用了 } else { $res[$k]['is_lead'] = 0; //该分类未被引用 } } } //如果数组过大,不采用静态缓存方式 if (count($res) <= 1000) { //write_static_cache('cat_pid_releate', $res); } } else { $res = $data; } } if (empty($res) == true) { return $re_type ? '' : array(); } $options = cat_options($cat_id, $res); // 获得指定分类下的子分类的数组 $children_level = 99999; //大于这个分类的将被删除 if ($is_show_all == false) { foreach ($options as $key => $val) { if ($val['level'] > $children_level) { unset($options[$key]); } else { if ($val['is_show'] == 0) { unset($options[$key]); if ($children_level > $val['level']) { $children_level = $val['level']; //标记一下,这样子分类也能删除 } } else { $children_level = 99999; //恢复初始值 } } } } /* 截取到指定的缩减级别 */ if ($level > 0) { if ($cat_id == 0) { $end_level = $level; } else { $first_item = reset($options); // 获取第一个元素 $end_level = $first_item['level'] + $level; } /* 保留level小于end_level的部分 */ foreach ($options as $key => $val) { if ($val['level'] >= $end_level) { unset($options[$key]); } } } if ($re_type == true) { $select = ''; foreach ($options as $var) { $select .= '<option value="' . $var['cat_id'] . '" '; $select .= $selected == $var['cat_id'] ? "selected='ture'" : ''; $select .= '>'; if ($var['level'] > 0) { $select .= str_repeat(' ', $var['level'] * 4); } $select .= htmlspecialchars(addslashes($var['cat_name']), ENT_QUOTES) . '</option>'; } return $select; } else { foreach ($options as $key => $value) { $options[$key]['url'] = build_uri('category', array('cid' => $value['cat_id']), $value['cat_name']); //if(empty($options[$key]['host_cat'])) //{ //if(!admin_agency_id() || !strstr($options[$key]['agency_cat'],','.admin_agency_id().',')) //unset($options[$key]); //} } return $options; } }
function get_host_nav() { $result = get_filter(); if ($result === false) { $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'type DESC, vieworder' : 'type DESC, ' . trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'ASC' : trim($_REQUEST['sort_order']); $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']); /*加入代理商条件*/ //$admin_agency_id = admin_agency_id(); /* if($filter['admin_agency_id']) $where = " WHERE admin_agency_id = $filter[admin_agency_id] "; else $where = " WHERE admin_agency_id = $admin_agency_id "; */ $where = " WHERE admin_agency_id = 0 "; //$where = " WHERE 1=1 " ; $admin_agency_id = admin_agency_id(); if ($admin_agency_id) { $where .= " AND (SELECT id FROM " . $GLOBALS['ecs']->table('nav') . " WHERE admin_agency_id = {$admin_agency_id} and host_id = n.id limit 1) is null"; } $sql = "SELECT count(*) FROM " . $GLOBALS['ecs']->table('nav') . ' as n ' . $where; //echo $sql; $filter['record_count'] = $GLOBALS['db']->getOne($sql); /* 分页大小 */ $filter = page_and_size($filter); /* 查询 */ $sql = "SELECT id, name, ifshow, vieworder, opennew, url, type" . " FROM " . $GLOBALS['ecs']->table('nav') . ' as n ' . $where . " ORDER by " . $filter['sort_by'] . ' ' . $filter['sort_order'] . " LIMIT " . $filter['start'] . ',' . $filter['page_size']; set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $navdb = $GLOBALS['db']->getAll($sql); $type = ""; $navdb2 = array(); foreach ($navdb as $k => $v) { if (!empty($type) && $type != $v['type']) { $navdb2[] = array(); } $navdb2[] = $v; $type = $v['type']; } $arr = array('navdb' => $navdb2, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); return $arr; }
function get_typelist() { $result = get_filter(); if ($result === false) { $filter = array(); $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']); $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keyword'] = json_str_iconv($filter['keyword']); } $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.add_time' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = ''; if (!empty($filter['keyword'])) { $where = " AND a.remarks LIKE '%" . mysql_like_quote($filter['keyword']) . "%'"; } /*加入代理商条件*/ if (!$filter['admin_agency_id']) { $agency_where = agency_where(); if (!$agency_where) { $agency_where = "AND a.admin_agency_id = 0"; } else { $agency_where = "AND a.admin_agency_id = " . admin_agency_id(); } } else { $agency_where = " AND a.admin_agency_id = {$filter['admin_agency_id']}"; } //dump($agency_where); /* 出库类型总数 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_out_type') . ' AS a ' . 'WHERE 1 ' . $where . $agency_where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获取出库类型数据 */ $sql = 'SELECT a.* , u.user_name ' . 'FROM ' . $GLOBALS['ecs']->table('stock_out_type') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('admin_user') . ' AS u ON u.user_id = a.user_id ' . 'WHERE 1 ' . $where . $agency_where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $rows['date'] = local_date($GLOBALS['_CFG']['time_format'], $rows['add_time']); $arr[] = $rows; } return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
} if ($file_url == '') { $file_url = $_POST['file_url']; } /* 计算文章打开方式 */ if ($file_url == '') { $open_type = 0; } else { $open_type = $_POST['FCKeditor1'] == '' ? 1 : 2; } /*插入数据*/ $add_time = gmtime(); if (empty($_POST['cat_id'])) { $_POST['cat_id'] = 0; } $sql = "INSERT INTO " . $ecs->table('article') . "(title, cat_id, article_type, is_open, author, " . "author_email, keywords, content, add_time, file_url, open_type, link, description,admin_agency_id,allow,show_every) " . "VALUES ('{$_POST['title']}', '{$_POST['article_cat']}', '{$_POST['article_type']}', '{$_POST['is_open']}', " . "'{$_POST['author']}', '{$_POST['author_email']}', '{$_POST['keywords']}', '{$_POST['FCKeditor1']}', " . "'{$add_time}', '{$file_url}', '{$open_type}', '{$_POST['link_url']}', '{$_POST['description']}'," . admin_agency_id() . ",{$_POST['allow']},{$_POST['show_every']})"; $db->query($sql); /* 处理关联商品 */ $article_id = $db->insert_id(); $sql = "UPDATE " . $ecs->table('goods_article') . " SET article_id = '{$article_id}' WHERE article_id = 0"; $db->query($sql); $link[0]['text'] = $_LANG['continue_add']; $link[0]['href'] = 'article.php?act=add'; $link[1]['text'] = $_LANG['back_list']; $link[1]['href'] = 'article.php?act=list'; admin_log($_POST['title'], 'add', 'article'); clear_cache_files(); // 清除相关的缓存文件 sys_msg($_LANG['articleadd_succeed'], 0, $link); } /*------------------------------------------------------ */