public function index() { $sql_list = strim($GLOBALS['request']['sql_list']); $clear_cache = $GLOBALS['request']['clear_cache']; $sql_list = explode(";", $sql_list); //logutils::log_obj( $sql_list ); foreach ($sql_list as $sql) { //logutils::log_str( $sql ); $sync_item = array(); $sync_item['succ'] = $GLOBALS['db']->query($sql, 'SILENT'); if ($sync_item['succ'] == false) { $sync_item['data'] = $sql; $sync_item['errmsg'] = $GLOBALS['db']->error(); $syncitems[] = $sync_item; break; } $syncitems[] = $sync_item; } if ($clear_cache == true) { clear_cache_files(); } $root = array("succ" => true, "items" => $syncitems); output($root); }
/* 高度值必须是数字 */ if (!preg_match("/^[\.0-9]+$/",$ad_height)) { make_json_error($_LANG['height_number']); } /* 广告位宽度应在1-1024之间 */ if ($ad_height > 2000 || $ad_height < 1) { make_json_error($_LANG['height_value']); } if ($exc->edit("ad_height = '$ad_height'", $id)) { clear_cache_files(); // 清除模版缓存 admin_log($ad_height, 'edit', 'ads_position'); make_json_result(stripslashes($ad_height)); } else { make_json_error($db->error()); } } /*------------------------------------------------------ */ //-- 删除广告位置 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'remove') { check_authz_json('ad_manage');
$smarty->display('user_transaction.dwt'); } } elseif ($action == 'add_tag') { include_once 'includes/cls_json.php'; include_once 'includes/lib_clips.php'; $result = array('error' => 0, 'message' => '', 'content' => ''); $id = isset($_POST['id']) ? intval($_POST['id']) : 0; $tag = isset($_POST['tag']) ? json_str_iconv(trim($_POST['tag'])) : ''; if ($user_id == 0) { /* 用户没有登录 */ $result['error'] = 1; $result['message'] = $_LANG['tag_anonymous']; } else { add_tag($id, $tag); // 添加tag clear_cache_files('goods'); // 删除缓存 /* 重新获得该商品的所有缓存 */ $arr = get_tags($id); foreach ($arr as $row) { $result['content'][] = array('word' => htmlspecialchars($row['tag_words']), 'count' => $row['tag_count']); } } $json = new JSON(); echo $json->encode($result); exit; } elseif ($action == 'collect') { include_once ROOT_PATH . 'includes/cls_json.php'; $json = new JSON(); $result = array('error' => 0, 'message' => ''); $goods_id = $_GET['id'];
/** * 添加评论内容 * * @access public * @param object $cmt * @return void */ function add_comment($cmt) { /* 评论是否需要审核 */ $status = 1 - $GLOBALS['_CFG']['comment_check']; $user_id = empty($_SESSION['user_id']) ? 0 : $_SESSION['user_id']; $email = empty($cmt->email) ? $_SESSION['email'] : trim($cmt->email); $user_name = empty($cmt->username) ? $_SESSION['user_name'] : ''; $email = htmlspecialchars($email); $user_name = htmlspecialchars($user_name); /* 保存评论内容 */ $sql = "INSERT INTO " . $GLOBALS['ecs']->table('comment') . "(comment_type, id_value, email, user_name, content, comment_rank, add_time, ip_address, status, parent_id, user_id) VALUES " . "('" . $cmt->type . "', '" . $cmt->id . "', '{$email}', '{$user_name}', '" . $cmt->content . "', '" . $cmt->rank . "', " . gmtime() . ", '" . real_ip() . "', '{$status}', '0', '{$user_id}')"; $result = $GLOBALS['db']->query($sql); $goods_id = $cmt->id; $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('comment') . " WHERE id_value = '{$goods_id}' AND comment_type = 0 AND status = 1 AND parent_id = 0 "; $count = $GLOBALS['db']->getOne($sql); if (empty($count)) { $count = 0; } $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET comments_number = '{$count}' WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); clear_cache_files(); //clear_cache_files('comments_list.lbi'); /*if ($status > 0) { add_feed($GLOBALS['db']->insert_id(), COMMENT_GOODS); }*/ return $result; }
/** * 添加评论内容. * * @param object $cmt */ function add_comment($cmt) { /* 评论是否需要审核 */ $status = 1 - $GLOBALS['_CFG']['comment_check']; $user_id = empty($_SESSION['user_id']) ? 0 : $_SESSION['user_id']; $email = empty($cmt->email) ? $_SESSION['email'] : trim($cmt->email); $user_name = empty($cmt->username) ? $_SESSION['user_name'] : ''; $email = htmlspecialchars($email); $user_name = htmlspecialchars($user_name); /* 保存评论内容 */ $sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('comment') . '(comment_type, id_value, email, user_name, content, comment_rank, add_time, ip_address, status, parent_id, user_id) VALUES ' . "('" . $cmt->type . "', '" . $cmt->id . "', '{$email}', '{$user_name}', '" . $cmt->content . "', '" . $cmt->rank . "', " . gmtime() . ", '" . real_ip() . "', '{$status}', '0', '{$user_id}')"; $result = $GLOBALS['db']->query($sql); clear_cache_files('comments_list.lbi'); /*if ($status > 0) { add_feed($GLOBALS['db']->insert_id(), COMMENT_GOODS); }*/ return $result; }
/** * 从回收站删除多个商品 * @param mix $goods_id 商品id列表:可以逗号格开,也可以是数组 * @return void */ function delete_goods($goods_id) { if (empty($goods_id)) { return; } /* 取得有效商品id */ $sql = "SELECT DISTINCT goods_id FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id " . db_create_in($goods_id) . " AND is_delete = 1"; $goods_id = $GLOBALS['db']->getCol($sql); if (empty($goods_id)) { return; } /* 删除商品图片和轮播图片文件 */ $sql = "SELECT goods_thumb, goods_img, original_img " . "FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id " . db_create_in($goods_id); $res = $GLOBALS['db']->query($sql); while ($goods = $GLOBALS['db']->fetchRow($res)) { if (!empty($goods['goods_thumb'])) { @unlink('../' . $goods['goods_thumb']); } if (!empty($goods['goods_img'])) { @unlink('../' . $goods['goods_img']); } if (!empty($goods['original_img'])) { @unlink('../' . $goods['original_img']); } } /* 删除商品 */ $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); /* 删除商品的货品记录 */ $sql = "DELETE FROM " . $GLOBALS['ecs']->table('products') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); /* 删除商品相册的图片文件 */ $sql = "SELECT img_url, thumb_url, img_original " . "FROM " . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id " . db_create_in($goods_id); $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { if (!empty($row['img_url'])) { @unlink('../' . $row['img_url']); } if (!empty($row['thumb_url'])) { @unlink('../' . $row['thumb_url']); } if (!empty($row['img_original'])) { @unlink('../' . $row['img_original']); } } /* 删除商品相册 */ $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); /* 删除相关表记录 */ $sql = "DELETE FROM " . $GLOBALS['ecs']->table('collect_goods') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_article') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_attr') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_cat') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('member_price') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('group_goods') . " WHERE parent_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('group_goods') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('link_goods') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('link_goods') . " WHERE link_goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('tag') . " WHERE goods_id " . db_create_in($goods_id); $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('comment') . " WHERE comment_type = 0 AND id_value " . db_create_in($goods_id); $GLOBALS['db']->query($sql); /* 删除相应虚拟商品记录 */ $sql = "DELETE FROM " . $GLOBALS['ecs']->table('virtual_card') . " WHERE goods_id " . db_create_in($goods_id); if (!$GLOBALS['db']->query($sql, 'SILENT') && $GLOBALS['db']->errno() != 1146) { die($GLOBALS['db']->error()); } /* 清除缓存 */ clear_cache_files(); }
function cancel_delivery($order_id, $delivery_id) { global $db, $ecs; /* 取得参数 */ $delivery = ''; /* 根据发货单id查询发货单信息 */ if (!empty($delivery_id)) { $delivery_order = delivery_order_info($delivery_id); } else { sys_msg('订单号不能为空!', 1); } /* 查询订单信息 */ $order = order_info($order_id); /* 取消当前发货单物流单号 */ $_delivery['invoice_no'] = ''; $_delivery['status'] = 2; $query = $db->autoExecute($ecs->table('delivery_order'), $_delivery, 'UPDATE', "delivery_id = {$delivery_id}", 'SILENT'); if (!$query) { /* 操作失败 */ $links[] = array('text' => $GLOBALS['_LANG']['delivery_sn'] . $GLOBALS['_LANG']['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id); sys_msg($GLOBALS['_LANG']['act_false'], 1, $links); exit; } /* 修改定单发货单号 */ $invoice_no_order = explode('<br>', $order['invoice_no']); $invoice_no_delivery = explode('<br>', $delivery_order['invoice_no']); foreach ($invoice_no_order as $key => $value) { $delivery_key = array_search($value, $invoice_no_delivery); if ($delivery_key !== false) { unset($invoice_no_order[$key], $invoice_no_delivery[$delivery_key]); if (count($invoice_no_delivery) == 0) { break; } } } $_order['invoice_no'] = implode('<br>', $invoice_no_order); /* 更新配送状态 */ $order_finish = get_all_delivery_finish($order_id); $shipping_status = $order_finish == -1 ? SS_SHIPPED_PART : SS_SHIPPED_ING; $arr['shipping_status'] = $shipping_status; if ($shipping_status == SS_SHIPPED_ING) { $arr['shipping_time'] = ''; // 发货时间 } $arr['invoice_no'] = $_order['invoice_no']; update_order($order_id, $arr); /* 发货单取消发货记录log */ order_action($order['order_sn'], $order['order_status'], $shipping_status, $order['pay_status'], $action_note, null, 1); /* 如果使用库存,则增加库存 */ if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_SHIP) { // 检查此单发货商品数量 $virtual_goods = array(); $delivery_stock_sql = "SELECT DG.goods_id, DG.product_id, DG.is_real, SUM(DG.send_number) AS sums\r\n FROM " . $GLOBALS['ecs']->table('delivery_goods') . " AS DG\r\n WHERE DG.delivery_id = '{$delivery_id}'\r\n GROUP BY DG.goods_id "; $delivery_stock_result = $GLOBALS['db']->getAll($delivery_stock_sql); foreach ($delivery_stock_result as $key => $value) { /* 虚拟商品 */ if ($value['is_real'] == 0) { continue; } //(货品) if (!empty($value['product_id'])) { $minus_stock_sql = "UPDATE " . $GLOBALS['ecs']->table('products') . "\r\n SET product_number = product_number + " . $value['sums'] . "\r\n WHERE product_id = " . $value['product_id']; $GLOBALS['db']->query($minus_stock_sql, 'SILENT'); } $minus_stock_sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . "\r\n SET goods_number = goods_number + " . $value['sums'] . "\r\n WHERE goods_id = " . $value['goods_id']; $GLOBALS['db']->query($minus_stock_sql, 'SILENT'); } } /* 发货单全退回时,退回其它 */ if ($order['order_status'] == SS_SHIPPED_ING) { /* 如果订单用户不为空,计算积分,并退回 */ if ($order['user_id'] > 0) { /* 取得用户信息 */ $user = user_info($order['user_id']); /* 计算并退回积分 */ $integral = integral_to_give($order); log_account_change($order['user_id'], 0, 0, -1 * intval($integral['rank_points']), -1 * intval($integral['custom_points']), sprintf($GLOBALS['_LANG']['return_order_gift_integral'], $order['order_sn'])); /* todo 计算并退回红包 */ return_order_bonus($order_id); } } /* 清除缓存 */ clear_cache_files(); /* 操作成功 */ $links[] = array('text' => $GLOBALS['_LANG']['delivery_sn'] . $GLOBALS['_LANG']['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id); sys_msg($GLOBALS['_LANG']['act_ok'], 0, $links); }
/** * 添加评论内容 * * @access public * @param object $cmt * @return void */ function add_comment($cmt) { /* 评论是否需要审核 */ $status = 1 - C('comment_check'); $user_id = empty($_SESSION['user_id']) ? 0 : $_SESSION['user_id']; $email = empty($cmt->email) ? $_SESSION['email'] : trim($cmt->email); $user_name = empty($cmt->username) ? $_SESSION['user_name'] : ''; $email = htmlspecialchars($email); $user_name = htmlspecialchars($user_name); /* 保存评论内容 */ $sql = "INSERT INTO " . $this->pre . "comment(comment_type, id_value, email, user_name, content, comment_rank, add_time, ip_address, status, parent_id, user_id) VALUES " . "('" . $cmt->type . "', '" . $cmt->id . "', '{$email}', '{$user_name}', '" . $cmt->content . "', '" . $cmt->rank . "', " . gmtime() . ", '" . real_ip() . "', '{$status}', '0', '{$user_id}')"; $result = $this->query($sql); clear_cache_files('comments_list.lbi'); return $result; }
/** * 功能:license 注册 * * @param array $certi_added 配置信息补充数组 array_key 登录信息的key;array_key => array_value; * @return array $return_array['flag'] = reg_succ、reg_fail、reg_ping_fail; * $return_array['request']; */ function license_reg($certi_added = '') { // 登录信息配置 $certi['certi_app'] = ''; // 证书方法 $certi['app_id'] = 'ectouch_free'; // 说明客户端来源 $certi['app_instance_id'] = ''; // 应用服务ID $certi['version'] = LICENSE_VERSION; // license接口版本号 $certi['shop_version'] = VERSION . '#' . RELEASE; // 网店软件版本号 $certi['certi_url'] = sprintf(__URL__); // 网店URL $certi['certi_session'] = ECTouch::sess()->get_session_id(); // 网店SESSION标识 $certi['certi_validate_url'] = sprintf(__URL__ . url('api/certi')); // 网店提供于官方反查接口 $certi['format'] = 'json'; // 官方返回数据格式 $certi['certificate_id'] = ''; // 网店证书ID // 标识 $certi_back['succ'] = 'succ'; $certi_back['fail'] = 'fail'; // return 返回数组 $return_array = array(); if (is_array($certi_added)) { foreach ($certi_added as $key => $value) { $certi[$key] = $value; } } // 取出网店 license $license = model('LicenseBase')->get_shop_license(); // 注册 $certi['certi_app'] = 'certi.reg'; // 证书方法 $certi['certi_ac'] = make_shopex_ac($certi, ''); // 网店验证字符串 unset($certi['certificate_id']); $request_arr = exchange_shop_license($certi, $license); if (is_array($request_arr) && $request_arr['res'] == $certi_back['succ']) { // 注册信息入库 $data['value'] = $request_arr['info']['certificate_id']; $condition['code'] = 'certificate_id'; model('Base')->table('touch_shop_config')->data($data)->where($condition)->update(); $data['value'] = $request_arr['info']['token']; $condition['code'] = 'certificate_id'; model('Base')->table('touch_shop_config')->data($data)->where($condition)->update(); $return_array['flag'] = 'reg_succ'; $return_array['request'] = $request_arr; clear_cache_files(); } elseif (is_array($request_arr) && $request_arr['res'] == $certi_back['fail']) { $return_array['flag'] = 'reg_fail'; $return_array['request'] = $request_arr; } else { $return_array['flag'] = 'reg_ping_fail'; $return_array['request'] = array('res' => 'fail'); } return $return_array; }
public function index() { clear_cache_files(); output($root); }
function cancel_delivery($order_id, $delivery_id) { global $db, $ecs, $_CFG; /* 取得参数 */ $delivery = ''; /* 根据发货单id查询发货单信息 */ if (!empty($delivery_id)) { $delivery_order = delivery_order_info($delivery_id); } else { sys_msg('订单号不能为空!', 1); } /* 查询订单信息 */ $order = order_info($order_id); /* 取消当前发货单物流单号 */ $_delivery['invoice_no'] = ''; $_delivery['status'] = 2; $query = $db->autoExecute($ecs->table('delivery_order'), $_delivery, 'UPDATE', "delivery_id = {$delivery_id}", 'SILENT'); if (!$query) { /* 操作失败 */ $links[] = array('text' => $GLOBALS['_LANG']['delivery_sn'] . $GLOBALS['_LANG']['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id); sys_msg($GLOBALS['_LANG']['act_false'], 1, $links); exit; } /* 修改定单发货单号 */ $invoice_no_order = explode('<br>', $order['invoice_no']); $invoice_no_delivery = explode('<br>', $delivery_order['invoice_no']); foreach ($invoice_no_order as $key => $value) { $delivery_key = array_search($value, $invoice_no_delivery); if ($delivery_key !== false) { unset($invoice_no_order[$key], $invoice_no_delivery[$delivery_key]); if (count($invoice_no_delivery) == 0) { break; } } } $_order['invoice_no'] = implode('<br>', $invoice_no_order); /* 更新配送状态 */ $order_finish = get_all_delivery_finish($order_id); $shipping_status = $order_finish == -1 ? SS_SHIPPED_PART : SS_SHIPPED_ING; $arr['shipping_status'] = $shipping_status; if ($shipping_status == SS_SHIPPED_ING) { $arr['shipping_time'] = ''; // 发货时间 } $arr['invoice_no'] = $_order['invoice_no']; update_order($order_id, $arr); /* 发货单取消发货记录log */ order_action($order['order_sn'], $order['order_status'], $shipping_status, $order['pay_status'], $action_note, null, 1); /* 如果使用库存,则增加库存 */ /* 代码增加_start By morestock_morecity */ if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_SHIP) { $delivery_stock_sql = "SELECT * FROM " . $GLOBALS['ecs']->table('delivery_goods') . " WHERE delivery_id = '{$delivery_id}' "; $delivery_stock_result = $GLOBALS['db']->getAll($delivery_stock_sql); $store_error = ''; //$goods_attr_id = get_goods_attr_id($value['goods_id'], $value['goods_attr']); $store_id_zhyh = get_storeid_by_ssq($order['province'], $order['city'], $order['district'], $order['xiangcun'], $order['supplier_id']); if (!$store_id_zhyh) { $store_error = '该发货单没有对应仓库!'; } if ($store_error) { sys_msg($store_error); } else { foreach ($delivery_stock_result as $key => $value) { $goods_attr_id = get_goods_attr_id($value['goods_id'], $value['goods_attr']); $store_row = get_storeid_youhuo($order['province'], $order['city'], $order['district'], $order['xiangcun'], $value['goods_id'], $goods_attr_id, $order['supplier_id'], $order_id); $add_time = gmtime(); $add_date = local_date('Ymd'); $sql = "select max(today_sn) from " . $ecs->table('store_inout_list') . " where inout_mode=2 and add_date='{$add_date}' "; $inout_count = $db->getOne($sql); $inout_sn = $inout_count ? intval($inout_count + 1) : 1; $today_sn = $inout_sn; $inout_sn = str_pad($inout_sn, 4, "0", STR_PAD_LEFT); $inout_sn = 'rk' . $add_date . $inout_sn; $stock_type_id = 0; if ($order['supplier_id'] > 0) { $stock_type_id = $db->getOne('select type from ' . $ecs->table('store_type') . " where supplier_id=" . $order['supplier_id']); } $sql = "insert into " . $ecs->table('store_inout_list') . "(inout_sn, inout_status, store_id, adminer_id, inout_type, inout_mode, order_sn, " . "takegoods_man, today_sn, add_date, add_time, supplier_id, store_type_id) " . "values('{$inout_sn}', '3', '{$store_row['store_id']}', '{$_SESSION['supplier_user_id']}', '5', '2', '{$order['order_sn']}', " . "'{$_SESSION['supplier_name']}', '{$today_sn}' , '{$add_date}', '{$add_time}','{$order['supplier_id']}', '{$stock_type_id}' ) "; $db->query($sql); $inout_rec_id = $db->insert_id(); $sql = "insert into " . $ecs->table('store_inout_goods') . "(inout_rec_id, goods_id, goods_sn, attr_value, inout_mode, number_yingshou, number_shishou, supplier_id, store_type_id) " . "values('{$inout_rec_id}', '{$value['goods_id']}', '{$value['goods_sn']}', '{$goods_attr_id}', '2', '{$value['send_number']}', '{$value['send_number']}','{$order['supplier_id']}', '{$stock_type_id}') "; $db->query($sql); $upre = update_stock_in($inout_rec_id, $store_row['store_id']); //更新库存表 } } } /* 代码增加_end By morestock_morecity */ /* 发货单全退回时,退回其它 */ if ($order['order_status'] == SS_SHIPPED_ING) { /* 如果订单用户不为空,计算积分,并退回 */ if ($order['user_id'] > 0) { /* 取得用户信息 */ $user = user_info($order['user_id']); /* 计算并退回积分 */ $integral = integral_to_give($order); log_account_change($order['user_id'], 0, 0, -1 * intval($integral['rank_points']), -1 * intval($integral['custom_points']), sprintf($GLOBALS['_LANG']['return_order_gift_integral'], $order['order_sn'])); /* todo 计算并退回红包 */ return_order_bonus($order_id); } } /* 清除缓存 */ clear_cache_files(); /* 操作成功 */ $links[] = array('text' => $GLOBALS['_LANG']['delivery_sn'] . $GLOBALS['_LANG']['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id); sys_msg($GLOBALS['_LANG']['act_ok'], 0, $links); }
function drop_goods($username, $password, $goods_ids) { if (!checkLogin($username, $password)) { return false; //login_faild } $goods_ids = base64_decode($goods_ids); $goods_id_arr = explode(',', $goods_ids); //check table exist $tableExist = array(); $tableExist['collect_goods'] = checkTableExist('collect_goods'); $tableExist['goods_article'] = checkTableExist('goods_article'); $tableExist['goods_activity'] = checkTableExist('goods_activity'); $tableExist['goods_attr'] = checkTableExist('goods_attr'); $tableExist['goods_cat'] = checkTableExist('goods_cat'); $tableExist['member_price'] = checkTableExist('member_price'); $tableExist['group_goods'] = checkTableExist('group_goods'); $tableExist['link_goods'] = checkTableExist('link_goods'); $tableExist['tag'] = checkTableExist('tag'); $tableExist['comment'] = checkTableExist('comment'); $tableExist['booking_goods'] = checkTableExist('booking_goods'); $tableExist['volume_price'] = checkTableExist('volume_price'); $tableExist['virtual_card'] = checkTableExist('virtual_card'); foreach ($goods_id_arr as $goods_id) { $sql = "SELECT goods_id, goods_name, is_delete, is_real, goods_thumb, " . "goods_img, original_img " . "FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id = '{$goods_id}'"; $goods = $GLOBALS['db']->getRow($sql); if (!empty($goods['goods_id'])) { if (!empty($goods['goods_thumb'])) { @unlink('../' . $goods['goods_thumb']); } if (!empty($goods['goods_img'])) { @unlink('../' . $goods['goods_img']); } if (!empty($goods['original_img'])) { @unlink('../' . $goods['original_img']); } $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); $sql = "SELECT img_url, thumb_url, img_original " . "FROM " . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id = '{$goods_id}'"; $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { if (!empty($row['img_url'])) { @unlink('../' . $row['img_url']); } if (!empty($row['thumb_url'])) { @unlink('../' . $row['thumb_url']); } if (!empty($row['img_original'])) { @unlink('../' . $row['img_original']); } } $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_gallery') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); if ($tableExist['collect_goods']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('collect_goods') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['goods_article']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_article') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['goods_activity']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['goods_attr']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_attr') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['goods_cat']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_cat') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['member_price']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('member_price') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['group_goods']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('group_goods') . " WHERE parent_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('group_goods') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['link_goods']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('link_goods') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); $sql = "DELETE FROM " . $GLOBALS['ecs']->table('link_goods') . " WHERE link_goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['tag']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('tag') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['comment']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('comment') . " WHERE comment_type = 0 AND id_value = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['booking_goods']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('booking_goods') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($tableExist['volume_price']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('volume_price') . " WHERE price_type = '1' AND goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } if ($goods['is_real'] != 1 && $tableExist['virtual_card']) { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('virtual_card') . " WHERE goods_id = '{$goods_id}'"; $GLOBALS['db']->query($sql); } } $sync_item = array(); $sync_item['table'] = "ecs_goods"; $sync_item['guid'] = $goods_id; $sync_item['succ'] = true; //$sync_item['errmsg'] = base64_encode($tmp); $syncitems[] = $sync_item; } clear_cache_files(); $pack = array("succ" => true, "items" => $syncitems); return $pack; }
function action_remove() { // 全局变量 // $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $exc = $GLOBALS['exc']; check_authz_json('admin_drop'); $id = intval($_GET['id']); /* 获得管理员用户名 */ $action_list = $db->getOne('SELECT action_list FROM ' . $ecs->table('supplier_admin_user') . " WHERE user_id='{$id}' AND supplier_id='{$_SESSION['supplier_id']}'"); /* 总管理员这个管理员不允许删除 */ if ($action_list == 'all') { // make_json_error($_LANG['edit_remove_cannot']); make_json_error($_LANG['remove_cannot']); } /* ID为1的不允许删除 */ // if ($id == 1) // { // make_json_error($_LANG['remove_cannot']); // } /* 管理员不能删除自己 */ if ($id == $_SESSION['supplier_user_id']) { make_json_error($_LANG['remove_self_cannot']); } if ($exc->drop($id)) { // $sess->delete_spec_admin_session($id); // 删除session中该管理员的记录 // admin_log(addslashes($admin_name), 'remove', 'privilege'); clear_cache_files(); } $url = 'privilege.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']); ecs_header("Location: {$url}\n"); exit; }
<?php set_time_limit(0); include_once "config.php"; include_once "include/utils/utils.php"; global $mod_strings; $count = clear_cache_files(); create_tab_data_file(); create_parenttab_data_file(); RecalculateSharingRules(); //echo "<center><font siez=15><b>".$mod_strings["LBL_CLEAR_DATABASE_CACHE"]."</b></font></center>"; $category = getParentTab(); echo "<script language=javascript>alert('" . $mod_strings["LBL_CLEARED_DATABASE_CACHE"] . "');document.location.href='index.php?module=Settings&action=index&parenttab=" . $category . "';</script>";
/** * 功能:license 注册 * * @param array $certi_added 配置信息补充数组 array_key 登录信息的key;array_key => array_value; * @return array $return_array['flag'] = reg_succ、reg_fail、reg_ping_fail; * $return_array['request']; */ function license_reg($certi_added = '') { // 登录信息配置 $certi['certi_app'] = ''; // 证书方法 $certi['app_id'] = 'ecshop_b2c'; // 说明客户端来源 $certi['app_instance_id'] = ''; // 应用服务ID $certi['version'] = LICENSE_VERSION; // license接口版本号 $certi['shop_version'] = VERSION . '#' . RELEASE; // 网店软件版本号 $certi['certi_url'] = sprintf($GLOBALS['ecs']->url()); // 网店URL $certi['certi_session'] = $GLOBALS['sess']->get_session_id(); // 网店SESSION标识 $certi['certi_validate_url'] = sprintf($GLOBALS['ecs']->url() . 'certi.php'); // 网店提供于官方反查接口 $certi['format'] = 'json'; // 官方返回数据格式 $certi['certificate_id'] = ''; // 网店证书ID // 标识 $certi_back['succ'] = 'succ'; $certi_back['fail'] = 'fail'; // return 返回数组 $return_array = array(); if (is_array($certi_added)) { foreach ($certi_added as $key => $value) { $certi[$key] = $value; } } // 取出网店 license $license = get_shop_license(); // 注册 $certi['certi_app'] = 'certi.reg'; // 证书方法 $certi['certi_ac'] = make_shopex_ac($certi, ''); // 网店验证字符串 unset($certi['certificate_id']); $request_arr = exchange_shop_license($certi, $license); if (is_array($request_arr) && $request_arr['res'] == $certi_back['succ']) { // 注册信息入库 $sql = "UPDATE " . $GLOBALS['ecs']->table('shop_config') . "\n SET value = '" . $request_arr['info']['certificate_id'] . "' WHERE code = 'certificate_id'"; $GLOBALS['db']->query($sql); $sql = "UPDATE " . $GLOBALS['ecs']->table('shop_config') . "\n SET value = '" . $request_arr['info']['token'] . "' WHERE code = 'token'"; $GLOBALS['db']->query($sql); $return_array['flag'] = 'reg_succ'; $return_array['request'] = $request_arr; clear_cache_files(); } elseif (is_array($request_arr) && $request_arr['res'] == $certi_back['fail']) { $return_array['flag'] = 'reg_fail'; $return_array['request'] = $request_arr; } else { $return_array['flag'] = 'reg_ping_fail'; $return_array['request'] = array('res' => 'fail'); } return $return_array; }
$randnum = rand(1, $pro); if ($randnum == $winnum) { //先检查库存,再减少库存 $num = ReduceNumber($id, $user_id); if ($num == "0") { $randnum = $randnum + 1; //$content = "你的号码:".$randnum."<br/>"; $result['error'] = 1; $content = "没有中奖唉~"; } else { //$content = "你的号码:".$randnum."<br/>"; $result['error'] = 0; $result['wid'] = $num; $content = "恭喜您中奖了!!写下您获奖感言索取奖品吧..<br/>\n\t\t\t\t\t"; } clear_cache_files('lottery'); } else { //$content = "你的号码:".$randnum."<br/>"; $result['error'] = 1; $content = "没有中奖唉~"; } $content .= "<br/>"; $sql = "update " . $GLOBALS['ecs']->table('lottery') . " set click=click+1 where id='" . $id . "'"; $GLOBALS['db']->query($sql); } $result['credit'] = getusercredit($user_id); // $result['content'] = $content; $result['message'] = $content; $result['id'] = $id; } die($json->encode($result));
function API_EditBrand($post) { /* 加载后台主操作函数 */ require_once ROOT_PATH . ADMIN_PATH . '/includes/lib_main.php'; require_once ROOT_PATH . ADMIN_PATH . '/includes/cls_exchange.php'; require_once ROOT_PATH . 'includes/cls_image.php'; /* 检查权限 */ admin_privilege('brand_manage'); $is_show = isset($_POST['is_show']) ? 1 : 0; $brand_id = !empty($_POST['brand_id']) ? intval($_POST['brand_id']) : 0; /*检查品牌名是否重复*/ $exc = new exchange($GLOBALS['ecs']->table("brand"), $GLOBALS['db'], 'brand_id', 'brand_name'); $is_only = $exc->is_only('brand_name', $_POST['brand_name'], '', ''); if (!$is_only) { client_show_message(301); } $param = "brand_name = '{$_POST['brand_name']}', site_url='{$_POST['site_url']}', brand_desc='{$_POST['brand_desc']}', is_show='{$is_show}', sort_order='{$_POST['sort_order']}' "; /* 处理图片 */ $img_name = upload_image($_POST['brand_logo'], 'brandlogo'); if ($img_name !== false) { $param .= " ,brand_logo = '" . basename($img_name) . "' "; } /* 更新数据 */ if ($exc->edit($param, $brand_id, '')) { /* 清除缓存 */ clear_cache_files(); admin_log($_POST['brand_name'], 'edit', 'brand'); client_show_message(0, true); } else { client_show_message(302); } }
function set_show_in_nav($type, $id, $val) { if ($type == 'c') { $tablename = $GLOBALS['ecs']->table('supplier_category'); } else { //目前用不到 $tablename = $GLOBALS['ecs']->table('article_cat'); } $GLOBALS['db']->query("UPDATE {$tablename} SET show_in_nav = '{$val}' WHERE cat_id = '{$id}' AND supplier_id=" . $_SESSION['supplier_id']); clear_cache_files(); }
function renameuser($get, $post) { $uid = $get['uid']; $usernameold = $get['oldusername']; $usernamenew = $get['newusername']; if (!API_RENAMEUSER) { return API_RETURN_FORBIDDEN; } $this->db->query("UPDATE " . $GLOBALS['ecs']->table("users") . " SET user_name='{$usernamenew}' WHERE user_id='{$uid}'"); $this->db->query("UPDATE " . $GLOBALS['ecs']->table("affiliate_log") . " SET user_name='{$usernamenew}' WHERE user_name='{$usernameold}'"); $this->db->query("UPDATE " . $GLOBALS['ecs']->table("comment") . " SET user_name='{$usernamenew}' WHERE user_name='{$usernameold}'"); $this->db->query("UPDATE " . $GLOBALS['ecs']->table("feedback") . " SET user_name='{$usernamenew}' WHERE user_name='{$usernameold}'"); clear_cache_files(); return API_RETURN_SUCCEED; }
function action_add_tag() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $GLOBALS['user_id']; include_once 'includes/cls_json.php'; include_once 'includes/lib_clips.php'; $result = array('error' => 0, 'message' => '', 'content' => ''); $id = isset($_POST['id']) ? intval($_POST['id']) : 0; $tag = isset($_POST['tag']) ? json_str_iconv(trim($_POST['tag'])) : ''; if ($user_id == 0) { /* 用户没有登录 */ $result['error'] = 1; $result['message'] = $_LANG['tag_anonymous']; } else { add_tag($id, $tag); // 添加tag clear_cache_files('goods'); // 删除缓存 /* 重新获得该商品的所有缓存 */ $arr = get_tags($id); foreach ($arr as $row) { $result['content'][] = array('word' => htmlspecialchars($row['tag_words']), 'count' => $row['tag_count']); } } $json = new JSON(); echo $json->encode($result); exit; }
function renameuser($get, $post) { $uid = $get['uid']; $usernameold = $get['oldusername']; $usernamenew = $get['newusername']; if (! API_RENAMEUSER) { return API_RETURN_FORBIDDEN; } $this->db->query("UPDATE {pre}users SET user_name='$usernamenew' WHERE user_id='$uid'"); $this->db->query("UPDATE {pre}affiliate_log SET user_name='$usernamenew' WHERE user_name='$usernameold'"); $this->db->query("UPDATE {pre}comment SET user_name='$usernamenew' WHERE user_name='$usernameold'"); $this->db->query("UPDATE {pre}feedback SET user_name='$usernamenew' WHERE user_name='$usernameold'"); clear_cache_files(); return API_RETURN_SUCCEED; }
/** * 添加咨询内容 * * @access public * @param object $cmt * @return void */ function add_question($cmt) { /* 咨询是否需要审核 */ $status = 1 - $GLOBALS['_CFG']['comment_check']; $user_id = empty($_SESSION['user_id']) ? 0 : $_SESSION['user_id']; $email = empty($cmt->email) ? $_SESSION['email'] : trim($cmt->email); $user_name = empty($cmt->username) ? $_SESSION['user_name'] : trim($cmt->username); $email = htmlspecialchars($email); $question_type = empty($cmt->question_type) ? 0 : intval($cmt->question_type); $user_name = htmlspecialchars($user_name); /* 保存咨询内容 */ $sql = "INSERT INTO " . $GLOBALS['ecs']->table('question') . "( id_value, question_type, email, user_name, content, add_time, ip_address, status, parent_id, user_id) VALUES " . "('" . $cmt->id . "', '{$question_type}', '{$email}', '{$user_name}', '" . $cmt->content . "', " . gmtime() . ", '" . real_ip() . "', '{$status}', '0', '{$user_id}')"; $result = $GLOBALS['db']->query($sql); clear_cache_files('question_list.lbi'); return $result; }
function set_show_in_nav($type, $id, $val) { if ($type == 'c') { $tablename = $GLOBALS['ecs']->table('category'); } else { $tablename = $GLOBALS['ecs']->table('article_cat'); } $GLOBALS['db']->query("UPDATE {$tablename} SET show_in_nav = '{$val}' WHERE cat_id = '{$id}'"); clear_cache_files(); }
public function edit() { /* 语言项的路径 */ $lang_file = isset($_POST['file_path']) ? trim($_POST['file_path']) : ''; /* 替换前的语言项 */ $src_items = !empty($_POST['item']) ? stripslashes_deep($_POST['item']) : ''; /* 修改过后的语言项 */ $dst_items = array(); $_POST['item_id'] = stripslashes_deep($_POST['item_id']); for ($i = 0; $i < count($_POST['item_id']); $i++) { /* 语言项内容如果为空,不修改 */ if (trim($_POST['item_content'][$i]) == '') { unset($src_items[$i]); } else { $_POST['item_content'][$i] = str_replace('\\\\n', '\\n', $_POST['item_content'][$i]); $dst_items[$i] = $_POST['item_id'][$i] . ' = ' . '"' . $_POST['item_content'][$i] . '";'; } } /* 调用函数编辑语言项 */ $result = $this->set_language_items($lang_file, $src_items, $dst_items); if ($result === false) { /* 修改失败提示信息 */ $link[] = array('text' => L('back_list'), 'href' => 'javascript:history.back(-1)'); $this->message(L('edit_languages_false'), NULL, $link); } else { /* 记录管理员操作 */ // admin_log('', 'edit', 'languages'); /* 清除缓存 */ clear_cache_files(); /* 成功提示信息 */ $this->message(L('edit_languages_success'), url('editlanguages/index')); } }
/** * 修改商品库存 * @param string $goods_id 商品编号,可以为多个,用 ',' 隔开 * @param string $value 字段值 * @return bool */ function update_goods_stock($goods_id, $value) { if ($goods_id) { /* $res = $goods_number - $old_product_number + $product_number; */ $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . "\r\n SET goods_number = goods_number + {$value},\r\n last_update = '" . gmtime() . "'\r\n WHERE goods_id = '{$goods_id}'"; $result = $GLOBALS['db']->query($sql); /* 清除缓存 */ clear_cache_files(); return $result; } else { return false; } }
function action_batch_drop() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; if (isset($_POST['checkboxes'])) { $del_count = 0; // 初始化删除数量 foreach ($_POST['checkboxes'] as $key => $id) { /* 取得预售活动信息 */ $pre_sale = pre_sale_info($id); /* 如果预售活动已经有订单,不能删除 */ if ($pre_sale['valid_order'] <= 0) { /* 删除预售活动 */ $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_id = '{$id}' LIMIT 1"; $GLOBALS['db']->query($sql, 'SILENT'); admin_log(addslashes($pre_sale['goods_name']) . '[' . $id . ']', 'remove', 'pre_sale'); $del_count++; } } /* 如果删除了预售活动,清除缓存 */ if ($del_count > 0) { clear_cache_files(); } $links[] = array('text' => $_LANG['back_list'], 'href' => 'pre_sale.php?act=list'); sys_msg(sprintf($_LANG['batch_drop_success'], $del_count), 0, $links); } else { $links[] = array('text' => $_LANG['back_list'], 'href' => 'pre_sale.php?act=list'); sys_msg($_LANG['no_select_pre_sale'], 0, $links); } }
function action_my_comment_send() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; include_once ROOT_PATH . 'includes/lib_clips.php'; $user_info = $db->getRow("SELECT * FROM " . $ecs->table('users') . " WHERE user_id = '{$user_id}'"); $comment_type = 0; $id_value = $_POST['goods_id']; $email = $user_info['email']; $user_name = $user_info['user_name']; $user_id = $user_id; $content = $_POST['content']; $comment_rank = $_POST['comment_rank']; // 代码增加 $server = $_POST['server']; $send = $_POST['send']; $shipping = $_POST['shipping']; $o_id = $_REQUEST['o_id']; if (!$o_id) { $o_id = $_REQUEST['o1_id']; } // 代码增加 $add_time = gmtime(); $ip_address = real_ip(); $status = $_CFG['comment_check'] == 1 ? 0 : 1; $rec_id = $_POST['rec_id']; $hide_username = intval($_POST['hide_username']); $buy_time = $db->getOne("SELECT o.add_time FROM " . $ecs->table('order_info') . " AS o\r\n\t\t\t\t\t\t\t LEFT JOIN " . $ecs->table('order_goods') . " AS og ON o.order_id=og.order_id\r\n\t\t\t\t\t\t\t WHERE og.rec_id = '{$rec_id}'"); /* 自定义标签 */ $tags = $_POST['comment_tag'] ? explode(",", $_POST['comment_tag']) : array(); if (is_array($_POST['tags_zi'])) { foreach ($_POST["tags_zi"] as $tag) { $status = $_CFG['user_tag_check']; $db->query("INSERT INTO " . $ecs->table('goods_tag') . " (goods_id, tag_name, is_user, state) VALUES ('{$id_value}', '{$tag}', 1, '{$status}')"); $tags[] = $db->insert_id(); } } foreach ($tags as $tagid) { if ($tagid > 0) { $tagids[] = $tagid; } } $comment_tag = is_array($tagids) ? implode(",", $tagids) : ''; // 代码增加o_id $sql = "INSERT INTO " . $ecs->table('comment') . "(comment_type, id_value, email, user_name, content, comment_rank, add_time, ip_address, user_id, status, rec_id, comment_tag, buy_time, hide_username, order_id)" . "VALUES ('{$comment_type}', '{$id_value}', '{$email}', '{$user_name}', '{$content}', '{$comment_rank}', '{$add_time}', '{$ip_address}', '{$user_id}', '{$status}', '{$rec_id}', '{$comment_tag}', '{$buy_time}', '{$hide_username}', '{$o_id}')"; $db->query($sql); $db->query("UPDATE " . $ecs->table('order_goods') . " SET comment_state = 1 WHERE rec_id = '{$rec_id}'"); // 代码增加 if ($o_id) { $o_sn = $db->getOne("SELECT order_sn FROM " . $ecs->table('order_info') . " \t\t\t\t\r\n\t\t\t\t\t\t\t WHERE order_id = '{$o_id}'"); $sql = "INSERT INTO " . $ecs->table('shop_grade') . "(user_id, user_name, add_time, server, send, shipping, order_id, order_sn)" . "VALUES ('{$user_id}', '{$user_name}', '{$add_time}', '{$server}', '{$send}', '{$shipping}', '{$o_id}', '{$o_sn}')"; $db->query($sql); } // 代码增加 clear_cache_files(); if ($status == 0) { $msg = '您的信息提交成功,需要管理员审核后才能显示!'; } else { $msg = '您的信息提交成功!'; } echo "<script>alert('{$msg}');self.location='user.php?act=my_comment';</script>"; exit; }
/** * * * @access public * @param * * @return void */ function save_integrate_config($code, $cfg) { $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('touch_shop_config') . " WHERE code = 'integrate_code'"; if ($GLOBALS['db']->GetOne($sql) == 0) { $sql = "INSERT INTO " . $ecs->table('touch_shop_config') . " (code, value) " . "VALUES ('integrate_code', '{$code}')"; } else { $sql = "SELECT value FROM " . $GLOBALS['ecs']->table('touch_shop_config') . " WHERE code = 'integrate_code'"; if ($code != $GLOBALS['db']->getOne($sql)) { /* 有缺换整合插件,需要把积分设置也清除 */ $sql = "UPDATE " . $GLOBALS['ecs']->table('touch_shop_config') . " SET value = '' WHERE code = 'points_rule'"; $GLOBALS['db']->query($sql); } $sql = "UPDATE " . $GLOBALS['ecs']->table('touch_shop_config') . " SET value = '{$code}' WHERE code = 'integrate_code'"; } $GLOBALS['db']->query($sql); /* 当前的域名 */ if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { $cur_domain = $_SERVER['HTTP_X_FORWARDED_HOST']; } elseif (isset($_SERVER['HTTP_HOST'])) { $cur_domain = $_SERVER['HTTP_HOST']; } else { if (isset($_SERVER['SERVER_NAME'])) { $cur_domain = $_SERVER['SERVER_NAME']; } elseif (isset($_SERVER['SERVER_ADDR'])) { $cur_domain = $_SERVER['SERVER_ADDR']; } } /* 整合对象的域名 */ $int_domain = str_replace(array('http://', 'https://'), array('', ''), $cfg['integrate_url']); if (strrpos($int_domain, '/')) { $int_domain = substr($int_domain, 0, strrpos($int_domain, '/')); } if ($cur_domain != $int_domain) { $same_domain = true; $domain = ''; /* 域名不一样,检查是否在同一域下 */ $cur_domain_arr = explode(".", $cur_domain); $int_domain_arr = explode(".", $int_domain); if (count($cur_domain_arr) != count($int_domain_arr) || $cur_domain_arr[0] == '' || $int_domain_arr[0] == '') { /* 域名结构不相同 */ $same_domain = false; } else { /* 域名结构一致,检查除第一节以外的其他部分是否相同 */ $count = count($cur_domain_arr); for ($i = 1; $i < $count; $i++) { if ($cur_domain_arr[$i] != $int_domain_arr[$i]) { $domain = ''; $same_domain = false; break; } else { $domain .= ".{$cur_domain_arr[$i]}"; } } } if ($same_domain == false) { /* 不在同一域,设置提示信息 */ $cfg['cookie_domain'] = ''; $cfg['cookie_path'] = '/'; } else { $cfg['cookie_domain'] = $domain; $cfg['cookie_path'] = '/'; } } else { $cfg['cookie_domain'] = ''; $cfg['cookie_path'] = '/'; } $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('touch_shop_config') . " WHERE code = 'integrate_config'"; if ($GLOBALS['db']->GetOne($sql) == 0) { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('touch_shop_config') . " (code, value) " . "VALUES ('integrate_config', '" . serialize($cfg) . "')"; } else { $sql = "UPDATE " . $GLOBALS['ecs']->table('touch_shop_config') . " SET value='" . serialize($cfg) . "' " . "WHERE code='integrate_config'"; } $GLOBALS['db']->query($sql); clear_cache_files(); return true; }
if ($_REQUEST['act'] == 'remove') { check_authz_json('cat_manage'); /* 初始化分类ID并取得分类名称 */ $cat_id = intval($_GET['id']); $cat_name = $db->getOne('SELECT cat_name FROM ' . $ecs->table('category') . " WHERE cat_id='{$cat_id}'"); /* 当前分类下是否有子分类 */ $cat_count = $db->getOne('SELECT COUNT(*) FROM ' . $ecs->table('category') . " WHERE parent_id='{$cat_id}'"); /* 当前分类下是否存在商品 */ $goods_count = $db->getOne('SELECT COUNT(*) FROM ' . $ecs->table('goods') . " WHERE cat_id='{$cat_id}'"); /* 如果不存在下级子分类和商品,则删除之 */ if ($cat_count == 0 && $goods_count == 0) { /* 删除分类 */ $sql = 'DELETE FROM ' . $ecs->table('category') . " WHERE cat_id = '{$cat_id}'"; if ($db->query($sql)) { $db->query("DELETE FROM " . $ecs->table('nav') . "WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'"); clear_cache_files(); admin_log($cat_name, 'remove', 'category'); } } else { make_json_error($cat_name . ' ' . $_LANG['cat_isleaf']); } $url = 'category.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']); ecs_header("Location: {$url}\n"); exit; } /*------------------------------------------------------ */ //-- PRIVATE FUNCTIONS /*------------------------------------------------------ */ // ///** // * 检查分类是否已经存在
function gen_link($name, $db, $ecs) { /* 生成红包序列号 */ //$num = $db->getOne("SELECT MAX(bonus_sn) FROM ". $ecs->table('user_bonus')); $num = $num ? floor($num / 10000) : 100000; $type_id = $db->getOne("SELECT type_id FROM " . $ecs->table('bonus_type') . " WHERE type_name = '{$name}'"); $bonus_sn = $num . str_pad(mt_rand(0, 9999), 4, '0', STR_PAD_LEFT); $db->query("INSERT INTO " . $ecs->table('user_bonus') . " (bonus_type_id, bonus_sn) VALUES({$type_id}, '{$bonus_sn}')"); /* 记录管理员操作 */ admin_log($bonus_sn, 'add', 'userbonus'); /* 清除缓存 */ clear_cache_files(); }