bug fixed
This commit is contained in:
parent
183e514a60
commit
893ece1936
309
admin/portal.php
309
admin/portal.php
@ -14,7 +14,7 @@ $image = new cls_image($_CFG['bgcolor']);
|
||||
if ($_REQUEST['act'] == 'list') {
|
||||
// admin_priv('games_view');
|
||||
|
||||
/* 模板赋值 */
|
||||
/* 模板賦值 */
|
||||
$ur_here = $_LANG['01_games_list'];
|
||||
$smarty->assign('ur_here', $ur_here);
|
||||
$action_link = array('href' => 'portal.php?act=add', 'text' => '加入入口');
|
||||
@ -27,17 +27,17 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('record_count', $portal_list['record_count']);
|
||||
$smarty->assign('page_count', $portal_list['page_count']);
|
||||
$smarty->assign('full_page', 1);
|
||||
/* 排序标记 */
|
||||
/* 排序標記 */
|
||||
$sort_flag = sort_flag($portal_list['filter']);
|
||||
$smarty->assign($sort_flag['tag'], $sort_flag['img']);
|
||||
|
||||
/* 显示商品列表页面 */
|
||||
/* 顯示商品列表頁面 */
|
||||
assign_query_info();
|
||||
$smarty->display('portal_list.htm');
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 排序、分页、查询
|
||||
//-- 排序、分頁、查詢
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'query') {
|
||||
$portal_list = portal_list();
|
||||
|
||||
@ -47,7 +47,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('page_count', $portal_list['page_count']);
|
||||
$smarty->assign('full_page', 0);
|
||||
|
||||
/* 排序标记 */
|
||||
/* 排序標記 */
|
||||
$sort_flag = sort_flag($portal_list['filter']);
|
||||
$smarty->assign($sort_flag['tag'], $sort_flag['img']);
|
||||
|
||||
@ -60,14 +60,14 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 添加新商品 编辑商品
|
||||
//-- 添加新商品 編輯商品
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'add' || $_REQUEST['act'] == 'edit') {
|
||||
include_once(ROOT_PATH . 'includes/fckeditor/fckeditor.php'); // 包含 html editor 类文件
|
||||
include_once(ROOT_PATH . 'includes/fckeditor/fckeditor.php'); // 包含 html editor 類文件
|
||||
|
||||
$is_add = $_REQUEST['act'] == 'add'; // 添加还是编辑的标识
|
||||
// admin_priv('games_manage'); // 检查权限
|
||||
$is_add = $_REQUEST['act'] == 'add'; // 添加還是編輯的標識
|
||||
// admin_priv('games_manage'); // 檢查權限
|
||||
|
||||
/* 如果是安全模式,检查目录是否存在 */
|
||||
/* 如果是安全模式,檢查目錄是否存在 */
|
||||
if (ini_get('safe_mode') == 1 && (!file_exists('../' . IMAGE_DIR . '/' . date('Ym')) || !is_dir('../' . IMAGE_DIR . '/' . date('Ym')))) {
|
||||
if (@!mkdir('../' . IMAGE_DIR . '/' . date('Ym'), 0777)) {
|
||||
$warning = sprintf($_LANG['safe_mode_warning'], '../' . IMAGE_DIR . '/' . date('Ym'));
|
||||
@ -75,14 +75,14 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
}
|
||||
|
||||
/* 如果目录存在但不可写,提示用户 */ elseif (file_exists('../' . IMAGE_DIR . '/' . date('Ym')) && file_mode_info('../' . IMAGE_DIR . '/' . date('Ym')) < 2) {
|
||||
/* 如果目錄存在但不可寫,提示用戶 */ elseif (file_exists('../' . IMAGE_DIR . '/' . date('Ym')) && file_mode_info('../' . IMAGE_DIR . '/' . date('Ym')) < 2) {
|
||||
$warning = sprintf($_LANG['not_writable_warning'], '../' . IMAGE_DIR . '/' . date('Ym'));
|
||||
$smarty->assign('warning', $warning);
|
||||
}
|
||||
|
||||
/* 取得商品信息 */
|
||||
if ($is_add) {
|
||||
/* 默认值 */
|
||||
/* 默認值 */
|
||||
$last_choose = array(0, 0);
|
||||
if (!empty($_COOKIE['ECSCP']['last_choose'])) {
|
||||
$last_choose = explode('|', $_COOKIE['ECSCP']['last_choose']);
|
||||
@ -96,7 +96,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
'mkeyword' => '',
|
||||
);
|
||||
|
||||
/* 图片列表 */
|
||||
/* 圖片列表 */
|
||||
$img_list = array();
|
||||
} else {
|
||||
/* 商品信息 */
|
||||
@ -104,7 +104,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$portal = $db->getRow($sql);
|
||||
|
||||
if (empty($portal) === true) {
|
||||
/* 默认值 */
|
||||
/* 默認值 */
|
||||
$portal = array(
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
@ -114,18 +114,18 @@ if ($_REQUEST['act'] == 'list') {
|
||||
'mkeyword' => '',
|
||||
);
|
||||
}
|
||||
/* 商品图片路径 */
|
||||
/* 商品圖片路徑 */
|
||||
if (isset($GLOBALS['shop_id']) && ($GLOBALS['shop_id'] > 10) && !empty($games['original_img'])) {
|
||||
$games['games_img'] = get_image_path($_REQUEST['games_id'], $games['games_img']);
|
||||
$games['games_thumb'] = get_image_path($_REQUEST['games_id'], $games['games_thumb'], true);
|
||||
}
|
||||
}
|
||||
|
||||
/* 创建 html editor */
|
||||
/* 創建 html editor */
|
||||
// create_html_editor('games_desc', $games['games_desc']);
|
||||
// create_html_editor('mobile_desc', $games['mobile_desc'],'FCKeditor2');
|
||||
|
||||
/* 模板赋值 */
|
||||
/* 模板賦值 */
|
||||
$smarty->assign('ur_here', $is_add ? (empty($code) ? '加入入口' : $_LANG['51_virtual_card_add']) : ($_REQUEST['act'] == 'edit' ? '編輯入口' : $_LANG['copy_games']));
|
||||
$smarty->assign('action_link', list_link($is_add));
|
||||
$smarty->assign('portal', $portal);
|
||||
@ -138,16 +138,17 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('gd', gd_version());
|
||||
$smarty->assign('thumb_width', $_CFG['thumb_width']);
|
||||
$smarty->assign('thumb_height', $_CFG['thumb_height']);
|
||||
/* 显示商品信息页面 */
|
||||
/* 顯示商品信息頁面 */
|
||||
assign_query_info();
|
||||
$smarty->display('portal_info.htm');
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 插入商品 更新商品
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'insert' || $_REQUEST['act'] == 'update') {
|
||||
/* 是否处理缩略图 */
|
||||
// admin_priv('games_manage'); // 检查权限
|
||||
/*------------------------------------------------------ */
|
||||
elseif ($_REQUEST['act'] == 'insert' || $_REQUEST['act'] == 'update') {
|
||||
/* 是否處理縮略圖 */
|
||||
// admin_priv('games_manage'); // 檢查權限
|
||||
//domain處理
|
||||
if ($_REQUEST['act'] == 'insert') {
|
||||
if (strlen($_REQUEST['domain'])) {
|
||||
@ -184,11 +185,11 @@ if ($_REQUEST['act'] == 'list') {
|
||||
|
||||
if (isset($_FILES['logo']['error'])) // php 4.2 版本才支持 error
|
||||
{
|
||||
// 最大上传文件大小
|
||||
// 最大上傳文件大小
|
||||
$php_maxsize = ini_get('upload_max_filesize');
|
||||
$htm_maxsize = '20M';
|
||||
|
||||
// 商品图片
|
||||
// 商品圖片
|
||||
if ($_FILES['logo']['error'] == 0) {
|
||||
if (!$image->check_img_type($_FILES['logo']['type'])) {
|
||||
sys_msg($_LANG['invalid_games_img'], 1, array(), false);
|
||||
@ -200,7 +201,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
}
|
||||
/* 4.1版本 */ else {
|
||||
// 商品图片
|
||||
// 商品圖片
|
||||
if ($_FILES['logo']['tmp_name'] != 'none') {
|
||||
if (!$image->check_img_type($_FILES['logo']['type'])) {
|
||||
|
||||
@ -211,11 +212,11 @@ if ($_REQUEST['act'] == 'list') {
|
||||
|
||||
if (isset($_FILES['slogo']['error'])) // php 4.2 版本才支持 error
|
||||
{
|
||||
// 最大上传文件大小
|
||||
// 最大上傳文件大小
|
||||
$php_maxsize = ini_get('upload_max_filesize');
|
||||
$htm_maxsize = '20M';
|
||||
|
||||
// 商品图片
|
||||
// 商品圖片
|
||||
if ($_FILES['slogo']['error'] == 0) {
|
||||
if (!$image->check_img_type($_FILES['slogo']['type'])) {
|
||||
sys_msg($_LANG['invalid_games_img'], 1, array(), false);
|
||||
@ -227,7 +228,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
}
|
||||
/* 4.1版本 */ else {
|
||||
// 商品图片
|
||||
// 商品圖片
|
||||
if ($_FILES['slogo']['tmp_name'] != 'none') {
|
||||
if (!$image->check_img_type($_FILES['slogo']['type'])) {
|
||||
|
||||
@ -236,19 +237,19 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
}
|
||||
|
||||
/* 插入还是更新的标识 */
|
||||
/* 插入還是更新的標識 */
|
||||
$is_insert = $_REQUEST['act'] == 'insert';
|
||||
|
||||
/* 处理商品图片 */
|
||||
$logo = ''; // 初始化商品图片
|
||||
$logo_thumb = ''; // 初始化商品缩略图
|
||||
$original_img = ''; // 初始化原始图片
|
||||
$old_original_img = ''; // 初始化原始图片旧图
|
||||
/* 處理商品圖片 */
|
||||
$logo = ''; // 初始化商品圖片
|
||||
$logo_thumb = ''; // 初始化商品縮略圖
|
||||
$original_img = ''; // 初始化原始圖片
|
||||
$old_original_img = ''; // 初始化原始圖片舊圖
|
||||
|
||||
// 如果上传了商品图片,相应处理
|
||||
// 如果上傳了商品圖片,相應處理
|
||||
if (($_FILES['logo']['tmp_name'] != '' && $_FILES['logo']['tmp_name'] != 'none')) {
|
||||
if ($_REQUEST['id'] > 0) {
|
||||
/* 删除原来的图片文件 */
|
||||
/* 刪除原來的圖片文件 */
|
||||
$sql = "SELECT logo " .
|
||||
" FROM " . $ecs->table('portal') .
|
||||
" WHERE id = '$_REQUEST[id]'";
|
||||
@ -256,26 +257,26 @@ if ($_REQUEST['act'] == 'list') {
|
||||
if ($row['logo'] != '' && is_file('../' . $row['logo'])) {
|
||||
@unlink('../' . $row['logo']);
|
||||
}
|
||||
/* 清除原来商品图片 */
|
||||
/* 清除原來商品圖片 */
|
||||
if ($proc_thumb === false) {
|
||||
get_image_path($_REQUEST[id], $row['logo'], false, 'portal', true);
|
||||
}
|
||||
}
|
||||
|
||||
$original_img = $image->upload_image($_FILES['logo']); // 原始图片
|
||||
$original_img = $image->upload_image($_FILES['logo']); // 原始圖片
|
||||
if ($original_img === false) {
|
||||
sys_msg($image->error_msg(), 1, array(), false);
|
||||
}
|
||||
$logo = $original_img; // 商品图片
|
||||
$logo = $original_img; // 商品圖片
|
||||
|
||||
|
||||
// 如果系统支持GD,缩放商品图片,且给商品图片和相册图片加水印
|
||||
// 如果系統支持GD,縮放商品圖片,且給商品圖片和相冊圖片加水印
|
||||
/* if ($proc_thumb && $image->gd_version() > 0 && $image->check_img_function($_FILES['games_img']['type']) || $is_url_games_img)
|
||||
{
|
||||
|
||||
if (empty($is_url_games_img))
|
||||
{
|
||||
// 如果设置大小不为0,缩放图片
|
||||
// 如果設置大小不為0,縮放圖片
|
||||
if ($_CFG['image_width'] != 0 || $_CFG['image_height'] != 0)
|
||||
{
|
||||
$games_img = $image->make_thumb('../'. $games_img , $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height']);
|
||||
@ -288,15 +289,15 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
*/
|
||||
}
|
||||
/* 处理商品图片 */
|
||||
$slogo = ''; // 初始化商品图片
|
||||
$slogo_thumb = ''; // 初始化商品缩略图
|
||||
$original_simg = ''; // 初始化原始图片
|
||||
$old_original_simg = ''; // 初始化原始图片旧图
|
||||
/* 處理商品圖片 */
|
||||
$slogo = ''; // 初始化商品圖片
|
||||
$slogo_thumb = ''; // 初始化商品縮略圖
|
||||
$original_simg = ''; // 初始化原始圖片
|
||||
$old_original_simg = ''; // 初始化原始圖片舊圖
|
||||
|
||||
if (($_FILES['slogo']['tmp_name'] != '' && $_FILES['slogo']['tmp_name'] != 'none')) {
|
||||
if ($_REQUEST['id'] > 0) {
|
||||
/* 删除原来的图片文件 */
|
||||
/* 刪除原來的圖片文件 */
|
||||
$sql = "SELECT slogo " .
|
||||
" FROM " . $ecs->table('portal') .
|
||||
" WHERE id = '$_REQUEST[id]'";
|
||||
@ -304,28 +305,28 @@ if ($_REQUEST['act'] == 'list') {
|
||||
if ($row['slogo'] != '' && is_file('../' . $row['slogo'])) {
|
||||
@unlink('../' . $row['slogo']);
|
||||
}
|
||||
/* 清除原来商品图片 */
|
||||
/* 清除原來商品圖片 */
|
||||
if ($proc_thumb === false) {
|
||||
get_image_path($_REQUEST[id], $row['slogo'], false, 'portal', true);
|
||||
}
|
||||
}
|
||||
|
||||
$original_simg = $image->upload_image($_FILES['slogo']); // 原始图片
|
||||
$original_simg = $image->upload_image($_FILES['slogo']); // 原始圖片
|
||||
if ($original_simg === false) {
|
||||
sys_msg($image->error_msg(), 1, array(), false);
|
||||
}
|
||||
$slogo = $original_simg; // 商品图片
|
||||
$slogo = $original_simg; // 商品圖片
|
||||
}
|
||||
|
||||
|
||||
/* 入库 */
|
||||
/* 入庫 */
|
||||
if ($is_insert) {
|
||||
$sql = "INSERT INTO " . $ecs->table('portal') . " (name, domain," .
|
||||
"mtitle,mdesc,mkeyword, logo,slogo,type,cf_iden)" .
|
||||
"VALUES ('$_POST[name]','$_POST[domain]', " .
|
||||
"'$_POST[mtitle]','$_POST[mdesc]','$_POST[mkeyword]','$logo','$slogo','$_POST[type]','$cf_iden')";
|
||||
} else {
|
||||
/* 如果有上传图片,删除原来的商品图 */
|
||||
/* 如果有上傳圖片,刪除原來的商品圖 */
|
||||
$sql = "SELECT * " .
|
||||
" FROM " . $ecs->table('portal') .
|
||||
" WHERE id = '$_REQUEST[id]'";
|
||||
@ -357,7 +358,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
"mtitle = '$_POST[mtitle]', " .
|
||||
"mdesc = '$_POST[mdesc]', ";
|
||||
|
||||
/* 如果有上传图片,需要更新数据库 */
|
||||
/* 如果有上傳圖片,需要更新數據庫 */
|
||||
if ($logo) {
|
||||
$sql .= "logo = '$logo', ";
|
||||
}
|
||||
@ -369,16 +370,16 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
$db->query($sql);
|
||||
|
||||
/* 商品编号 */
|
||||
/* 商品編號 */
|
||||
$id = $is_insert ? $db->insert_id() : $_REQUEST['id'];
|
||||
|
||||
/* 记录日志 */
|
||||
/* 記錄日誌 */
|
||||
if ($is_insert) {
|
||||
admin_log($_POST['name'], 'add', 'portal');
|
||||
} else {
|
||||
admin_log($_POST['name'], 'edit', 'portal');
|
||||
}
|
||||
/* 重新格式化图片名称 */
|
||||
/* 重新格式化圖片名稱 */
|
||||
// $logo = reformat_image_name('logo', $id, $logo, 'portal');
|
||||
|
||||
// if ($logo !== false)
|
||||
@ -386,7 +387,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
// $db->query("UPDATE " . $ecs->table('portal') . " SET logo = '$logo' WHERE id='$id'");
|
||||
// }
|
||||
|
||||
/* 不保留商品原图的时候删除原图 */
|
||||
/* 不保留商品原圖的時候刪除原圖 */
|
||||
// if ($proc_thumb && !$_CFG['retain_original_img'] && !empty($original_img))
|
||||
// {
|
||||
// $db->query("UPDATE " . $ecs->table('games') . " SET original_img='' WHERE `games_id`='{$games_id}'");
|
||||
@ -394,12 +395,12 @@ if ($_REQUEST['act'] == 'list') {
|
||||
// @unlink('../' . $img);
|
||||
// }
|
||||
|
||||
/* 记录上一次选择的分类和品牌 */
|
||||
/* 記錄上一次選擇的分類和品牌 */
|
||||
// setcookie('ECSCP[last_choose]', $catgory_id . '|' . $brand_id, gmtime() + 86400);
|
||||
/* 清空缓存 */
|
||||
/* 清空緩存 */
|
||||
clear_cache_files();
|
||||
|
||||
/* 提示页面 */
|
||||
/* 提示頁面 */
|
||||
$link = array();
|
||||
if ($is_insert) {
|
||||
$link[0] = add_link($code);
|
||||
@ -419,52 +420,53 @@ if ($_REQUEST['act'] == 'list') {
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 批量操作
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'batch') {
|
||||
/*------------------------------------------------------ */
|
||||
elseif ($_REQUEST['act'] == 'batch') {
|
||||
$code = '';
|
||||
|
||||
/* 取得要操作的商品编号 */
|
||||
/* 取得要操作的商品編號 */
|
||||
$games_id = !empty($_POST['checkboxes']) ? join(',', $_POST['checkboxes']) : 0;
|
||||
|
||||
if (isset($_POST['type'])) {
|
||||
/* 放入回收站 */
|
||||
if ($_POST['type'] == 'trash') {
|
||||
/* 检查权限 */
|
||||
/* 檢查權限 */
|
||||
admin_priv('remove_back');
|
||||
|
||||
update_games($games_id, 'is_delete', '1');
|
||||
|
||||
/* 记录日志 */
|
||||
/* 記錄日誌 */
|
||||
admin_log('', 'batch_trash', 'games');
|
||||
}
|
||||
/* 上架 */ elseif ($_POST['type'] == 'on_sale') {
|
||||
/* 检查权限 */
|
||||
/* 檢查權限 */
|
||||
admin_priv('games_manage');
|
||||
update_games($games_id, 'is_on_sale', '1');
|
||||
}
|
||||
|
||||
/* 下架 */ elseif ($_POST['type'] == 'not_on_sale') {
|
||||
/* 检查权限 */
|
||||
/* 檢查權限 */
|
||||
admin_priv('games_manage');
|
||||
update_games($games_id, 'is_on_sale', '0');
|
||||
}
|
||||
|
||||
/* 转移到分类 */ elseif ($_POST['type'] == 'move_to') {
|
||||
/* 检查权限 */
|
||||
/* 轉移到分類 */ elseif ($_POST['type'] == 'move_to') {
|
||||
/* 檢查權限 */
|
||||
admin_priv('games_manage');
|
||||
update_games($games_id, 'cat_id', $_POST['target_cat']);
|
||||
}
|
||||
/* 删除 */ elseif ($_POST['type'] == 'drop') {
|
||||
/* 检查权限 */
|
||||
/* 刪除 */ elseif ($_POST['type'] == 'drop') {
|
||||
/* 檢查權限 */
|
||||
admin_priv('remove_back');
|
||||
|
||||
delete_games($games_id);
|
||||
|
||||
/* 记录日志 */
|
||||
/* 記錄日誌 */
|
||||
admin_log('', 'batch_remove', 'games');
|
||||
}
|
||||
}
|
||||
|
||||
/* 清除缓存 */
|
||||
/* 清除緩存 */
|
||||
clear_cache_files();
|
||||
|
||||
if ($_POST['type'] == 'drop' || $_POST['type'] == 'restore') {
|
||||
@ -475,8 +477,9 @@ if ($_REQUEST['act'] == 'list') {
|
||||
sys_msg($_LANG['batch_handle_ok'], 0, $link);
|
||||
}
|
||||
/*------------------------------------------------------ */
|
||||
//-- 显示图片
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'show_image') {
|
||||
//-- 顯示圖片
|
||||
/*------------------------------------------------------ */
|
||||
elseif ($_REQUEST['act'] == 'show_image') {
|
||||
|
||||
// $img_url = $_GET['img_url'];
|
||||
$img_url = '../' . $_GET['img_url'];
|
||||
@ -500,7 +503,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 修改上架状态
|
||||
//-- 修改上架狀態
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'toggle_on_sale') {
|
||||
check_authz_json('games_manage');
|
||||
|
||||
@ -540,10 +543,10 @@ if ($_REQUEST['act'] == 'list') {
|
||||
make_json_result($sort_order);
|
||||
}
|
||||
} elseif ($_REQUEST['act'] == 'remove') {
|
||||
// 检查权限
|
||||
// 檢查權限
|
||||
// check_authz_json('remove_back');
|
||||
|
||||
// 取得参数
|
||||
// 取得參數
|
||||
$id = intval($_REQUEST['id']);
|
||||
if ($id <= 0) {
|
||||
make_json_error('invalid params');
|
||||
@ -564,7 +567,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
// make_json_error($_LANG['games_not_in_recycle_bin']);
|
||||
// }
|
||||
|
||||
/* 删除商品图片和轮播图片 */
|
||||
/* 刪除商品圖片和輪播圖片 */
|
||||
if (!empty($portal['logo'])) {
|
||||
@unlink('../' . $portal['logo']);
|
||||
}
|
||||
@ -573,7 +576,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
@unlink('../' . $portal['slogo']);
|
||||
}
|
||||
|
||||
/* 删除商品 */
|
||||
/* 刪除商品 */
|
||||
$exc->drop($id);
|
||||
/* 刪除domain */
|
||||
if (strlen($portal['domain'])) {
|
||||
@ -584,7 +587,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
}
|
||||
|
||||
/* 记录日志 */
|
||||
/* 記錄日誌 */
|
||||
admin_log(addslashes($protal['name']), 'remove', 'portal');
|
||||
|
||||
clear_cache_files();
|
||||
@ -596,7 +599,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 切换商品类型
|
||||
//-- 切換商品類型
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'get_attr') {
|
||||
check_authz_json('games_manage');
|
||||
|
||||
@ -609,13 +612,13 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 删除图片
|
||||
//-- 刪除圖片
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'drop_image') {
|
||||
check_authz_json('games_manage');
|
||||
|
||||
$img_id = empty($_REQUEST['img_id']) ? 0 : intval($_REQUEST['img_id']);
|
||||
|
||||
/* 删除图片文件 */
|
||||
/* 刪除圖片文件 */
|
||||
$sql = "SELECT img_url, thumb_url, img_original " .
|
||||
" FROM " . $GLOBALS['ecs']->table('games_gallery') .
|
||||
" WHERE img_id = '$img_id'";
|
||||
@ -631,7 +634,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
@unlink('../' . $row['img_original']);
|
||||
}
|
||||
|
||||
/* 删除数据 */
|
||||
/* 刪除數據 */
|
||||
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('games_gallery') . " WHERE img_id = '$img_id' LIMIT 1";
|
||||
$GLOBALS['db']->query($sql);
|
||||
|
||||
@ -640,7 +643,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 搜索商品,仅返回名称及ID
|
||||
//-- 搜索商品,僅返回名稱及ID
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'get_games_list') {
|
||||
include_once(ROOT_PATH . 'includes/cls_json.php');
|
||||
$json = new JSON;
|
||||
@ -662,7 +665,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 把商品加入关联
|
||||
//-- 把商品加入關聯
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'add_link_games') {
|
||||
include_once(ROOT_PATH . 'includes/cls_json.php');
|
||||
$json = new JSON;
|
||||
@ -676,7 +679,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
|
||||
foreach ($linked_array as $val) {
|
||||
if ($is_double) {
|
||||
/* 双向关联 */
|
||||
/* 雙向關聯 */
|
||||
$sql = "INSERT INTO " . $ecs->table('link_games') . " (games_id, link_games_id, is_double, admin_id) " .
|
||||
"VALUES ('$val', '$games_id', '$is_double', '$_SESSION[admin_id]')";
|
||||
$db->query($sql, 'SILENT');
|
||||
@ -703,7 +706,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 删除关联商品
|
||||
//-- 刪除關聯商品
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'drop_link_games') {
|
||||
include_once(ROOT_PATH . 'includes/cls_json.php');
|
||||
$json = new JSON;
|
||||
@ -751,7 +754,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 货品列表
|
||||
//-- 貨品列表
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'product_list') {
|
||||
admin_priv('games_manage');
|
||||
|
||||
@ -774,14 +777,14 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('games_name', sprintf($_LANG['products_title'], $games['games_name']));
|
||||
|
||||
|
||||
/* 获取商品规格列表 */
|
||||
/* 獲取商品規格列表 */
|
||||
$attribute = get_games_specifications_list($games_id);
|
||||
if (empty($attribute)) {
|
||||
$link[] = array('href' => 'games.php?act=edit&games_id=' . $games_id, 'text' => $_LANG['edit_games']);
|
||||
sys_msg($_LANG['not_exist_games_attr'], 1, $link);
|
||||
}
|
||||
foreach ($attribute as $attribute_value) {
|
||||
//转换成数组
|
||||
//轉換成數組
|
||||
$_attribute[$attribute_value['attr_id']]['attr_values'][] = $attribute_value['attr_value'];
|
||||
$_attribute[$attribute_value['attr_id']]['attr_id'] = $attribute_value['attr_id'];
|
||||
$_attribute[$attribute_value['attr_id']]['attr_name'] = $attribute_value['attr_name'];
|
||||
@ -794,7 +797,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('product_sn', $games['games_sn'] . '_');
|
||||
$smarty->assign('product_number', $_CFG['default_storage']);
|
||||
|
||||
/* 取商品的货品 */
|
||||
/* 取商品的貨品 */
|
||||
$product = product_list($games_id, '');
|
||||
|
||||
$smarty->assign('ur_here', $_LANG['18_product_list']);
|
||||
@ -806,14 +809,14 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('filter', $product['filter']);
|
||||
$smarty->assign('full_page', 1);
|
||||
|
||||
/* 显示商品列表页面 */
|
||||
/* 顯示商品列表頁面 */
|
||||
assign_query_info();
|
||||
|
||||
$smarty->display('product_info.htm');
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 货品排序、分页、查询
|
||||
//-- 貨品排序、分頁、查詢
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'product_query') {
|
||||
/* 是否存在商品id */
|
||||
if (empty($_REQUEST['games_id'])) {
|
||||
@ -834,13 +837,13 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('games_sn', sprintf($_LANG['products_title_2'], $games['games_sn']));
|
||||
|
||||
|
||||
/* 获取商品规格列表 */
|
||||
/* 獲取商品規格列表 */
|
||||
$attribute = get_games_specifications_list($games_id);
|
||||
if (empty($attribute)) {
|
||||
make_json_error($_LANG['sys']['wrong'] . $_LANG['cannot_found_games']);
|
||||
}
|
||||
foreach ($attribute as $attribute_value) {
|
||||
//转换成数组
|
||||
//轉換成數組
|
||||
$_attribute[$attribute_value['attr_id']]['attr_values'][] = $attribute_value['attr_value'];
|
||||
$_attribute[$attribute_value['attr_id']]['attr_id'] = $attribute_value['attr_id'];
|
||||
$_attribute[$attribute_value['attr_id']]['attr_name'] = $attribute_value['attr_name'];
|
||||
@ -853,7 +856,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('product_sn', $games['games_sn'] . '_');
|
||||
$smarty->assign('product_number', $_CFG['default_storage']);
|
||||
|
||||
/* 取商品的货品 */
|
||||
/* 取商品的貨品 */
|
||||
$product = product_list($games_id, '');
|
||||
|
||||
$smarty->assign('ur_here', $_LANG['18_product_list']);
|
||||
@ -863,7 +866,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$smarty->assign('games_id', $games_id);
|
||||
$smarty->assign('filter', $product['filter']);
|
||||
|
||||
/* 排序标记 */
|
||||
/* 排序標記 */
|
||||
$sort_flag = sort_flag($product['filter']);
|
||||
$smarty->assign($sort_flag['tag'], $sort_flag['img']);
|
||||
|
||||
@ -875,9 +878,9 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 货品删除
|
||||
//-- 貨品刪除
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'product_remove') {
|
||||
/* 检查权限 */
|
||||
/* 檢查權限 */
|
||||
check_authz_json('remove_back');
|
||||
|
||||
/* 是否存在商品id */
|
||||
@ -887,20 +890,20 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$product_id = intval($_REQUEST['id']);
|
||||
}
|
||||
|
||||
/* 货品库存 */
|
||||
/* 貨品庫存 */
|
||||
$product = get_product_info($product_id, 'product_number, games_id');
|
||||
|
||||
/* 删除货品 */
|
||||
/* 刪除貨品 */
|
||||
$sql = "DELETE FROM " . $ecs->table('products') . " WHERE product_id = '$product_id'";
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
/* 修改商品库存 */
|
||||
/* 修改商品庫存 */
|
||||
if (update_games_stock($product['games_id'], $product_number - $product['product_number'])) {
|
||||
//记录日志
|
||||
//記錄日誌
|
||||
admin_log('', 'update', 'games');
|
||||
}
|
||||
|
||||
//记录日志
|
||||
//記錄日誌
|
||||
admin_log('', 'trash', 'products');
|
||||
|
||||
$url = 'games.php?act=product_query&' . str_replace('act=product_remove', '', $_SERVER['QUERY_STRING']);
|
||||
@ -911,7 +914,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 修改货品价格
|
||||
//-- 修改貨品價格
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'edit_product_sn') {
|
||||
check_authz_json('games_manage');
|
||||
|
||||
@ -933,21 +936,21 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 修改货品库存
|
||||
//-- 修改貨品庫存
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'edit_product_number') {
|
||||
check_authz_json('games_manage');
|
||||
|
||||
$product_id = intval($_POST['id']);
|
||||
$product_number = intval($_POST['val']);
|
||||
|
||||
/* 货品库存 */
|
||||
/* 貨品庫存 */
|
||||
$product = get_product_info($product_id, 'product_number, games_id');
|
||||
|
||||
/* 修改货品库存 */
|
||||
/* 修改貨品庫存 */
|
||||
$sql = "UPDATE " . $ecs->table('products') . " SET product_number = '$product_number' WHERE product_id = '$product_id'";
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
/* 修改商品库存 */
|
||||
/* 修改商品庫存 */
|
||||
if (update_games_stock($product['games_id'], $product_number - $product['product_number'])) {
|
||||
clear_cache_files();
|
||||
make_json_result($product_number);
|
||||
@ -956,7 +959,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 货品添加 执行
|
||||
//-- 貨品添加 執行
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'product_add_execute') {
|
||||
admin_priv('games_manage');
|
||||
|
||||
@ -970,7 +973,7 @@ if ($_REQUEST['act'] == 'list') {
|
||||
sys_msg($_LANG['sys']['wrong'] . $_LANG['cannot_found_games'], 1, array(), false);
|
||||
}
|
||||
|
||||
/* 判断是否为初次添加 */
|
||||
/* 判斷是否為初次添加 */
|
||||
$insert = true;
|
||||
if (product_number_count($product['games_id']) > 0) {
|
||||
$insert = false;
|
||||
@ -985,34 +988,34 @@ if ($_REQUEST['act'] == 'list') {
|
||||
|
||||
/* */
|
||||
foreach ($product['product_sn'] as $key => $value) {
|
||||
//过滤
|
||||
$product['product_number'][$key] = empty($product['product_number'][$key]) ? (empty($_CFG['use_storage']) ? 0 : $_CFG['default_storage']) : trim($product['product_number'][$key]); //库存
|
||||
//過濾
|
||||
$product['product_number'][$key] = empty($product['product_number'][$key]) ? (empty($_CFG['use_storage']) ? 0 : $_CFG['default_storage']) : trim($product['product_number'][$key]); //庫存
|
||||
|
||||
//获取规格在商品属性表中的id
|
||||
//獲取規格在商品屬性表中的id
|
||||
foreach ($product['attr'] as $attr_key => $attr_value) {
|
||||
/* 检测:如果当前所添加的货品规格存在空值或0 */
|
||||
/* 檢測:如果當前所添加的貨品規格存在空值或0 */
|
||||
if (empty($attr_value[$key])) {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$is_spec_list[$attr_key] = 'true';
|
||||
|
||||
$value_price_list[$attr_key] = $attr_value[$key] . chr(9) . ''; //$key,当前
|
||||
$value_price_list[$attr_key] = $attr_value[$key] . chr(9) . ''; //$key,當前
|
||||
|
||||
$id_list[$attr_key] = $attr_key;
|
||||
}
|
||||
$games_attr_id = handle_games_attr($product['games_id'], $id_list, $is_spec_list, $value_price_list);
|
||||
|
||||
/* 是否为重复规格的货品 */
|
||||
/* 是否為重複規格的貨品 */
|
||||
$games_attr = sort_games_attr_id_array($games_attr_id);
|
||||
$games_attr = implode('|', $games_attr['sort']);
|
||||
if (check_games_attr_exist($games_attr, $product['games_id'])) {
|
||||
continue;
|
||||
//sys_msg($_LANG['sys']['wrong'] . $_LANG['exist_same_games_attr'], 1, array(), false);
|
||||
}
|
||||
//货品号不为空
|
||||
//貨品號不為空
|
||||
if (!empty($value)) {
|
||||
/* 检测:货品货号是否在商品表和货品表中重复 */
|
||||
/* 檢測:貨品貨號是否在商品表和貨品表中重複 */
|
||||
if (check_games_sn_exist($value)) {
|
||||
continue;
|
||||
//sys_msg($_LANG['sys']['wrong'] . $_LANG['exist_same_games_sn'], 1, array(), false);
|
||||
@ -1023,14 +1026,14 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
}
|
||||
|
||||
/* 插入货品表 */
|
||||
/* 插入貨品表 */
|
||||
$sql = "INSERT INTO " . $GLOBALS['ecs']->table('products') . " (games_id, games_attr, product_sn, product_number) VALUES ('" . $product['games_id'] . "', '$games_attr', '$value', '" . $product['product_number'][$key] . "')";
|
||||
if (!$GLOBALS['db']->query($sql)) {
|
||||
continue;
|
||||
//sys_msg($_LANG['sys']['wrong'] . $_LANG['cannot_add_products'], 1, array(), false);
|
||||
}
|
||||
|
||||
//货品号为空 自动补货品号
|
||||
//貨品號為空 自動補貨品號
|
||||
if (empty($value)) {
|
||||
$sql = "UPDATE " . $GLOBALS['ecs']->table('products') . "
|
||||
SET product_sn = '" . $games['games_sn'] . "g_p" . $GLOBALS['db']->insert_id() . "'
|
||||
@ -1038,10 +1041,10 @@ if ($_REQUEST['act'] == 'list') {
|
||||
$GLOBALS['db']->query($sql);
|
||||
}
|
||||
|
||||
/* 修改商品表库存 */
|
||||
/* 修改商品表庫存 */
|
||||
$product_count = product_number_count($product['games_id']);
|
||||
if (update_games($product['games_id'], 'games_number', $product_count)) {
|
||||
//记录日志
|
||||
//記錄日誌
|
||||
admin_log($product['games_id'], 'update', 'games');
|
||||
}
|
||||
}
|
||||
@ -1062,21 +1065,21 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------ */
|
||||
//-- 货品批量操作
|
||||
//-- 貨品批量操作
|
||||
/*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'batch_product') {
|
||||
/* 定义返回 */
|
||||
/* 定義返回 */
|
||||
$link[] = array('href' => 'games.php?act=product_list&games_id=' . $_POST['games_id'], 'text' => $_LANG['item_list']);
|
||||
|
||||
/* 批量操作 - 批量删除 */
|
||||
/* 批量操作 - 批量刪除 */
|
||||
if ($_POST['type'] == 'drop') {
|
||||
//检查权限
|
||||
//檢查權限
|
||||
admin_priv('remove_back');
|
||||
|
||||
//取得要操作的商品编号
|
||||
//取得要操作的商品編號
|
||||
$product_id = !empty($_POST['checkboxes']) ? join(',', $_POST['checkboxes']) : 0;
|
||||
$product_bound = db_create_in($product_id);
|
||||
|
||||
//取出货品库存总数
|
||||
//取出貨品庫存總數
|
||||
$sum = 0;
|
||||
$games_id = 0;
|
||||
$sql = "SELECT product_id, games_id, product_number FROM " . $GLOBALS['ecs']->table('products') . " WHERE product_id $product_bound";
|
||||
@ -1087,23 +1090,23 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
$games_id = $product_array[0]['games_id'];
|
||||
|
||||
/* 删除货品 */
|
||||
/* 刪除貨品 */
|
||||
$sql = "DELETE FROM " . $ecs->table('products') . " WHERE product_id $product_bound";
|
||||
if ($db->query($sql)) {
|
||||
//记录日志
|
||||
//記錄日誌
|
||||
admin_log('', 'delete', 'products');
|
||||
}
|
||||
|
||||
/* 修改商品库存 */
|
||||
/* 修改商品庫存 */
|
||||
if (update_games_stock($games_id, -$sum)) {
|
||||
//记录日志
|
||||
//記錄日誌
|
||||
admin_log('', 'update', 'games');
|
||||
}
|
||||
|
||||
/* 返回 */
|
||||
sys_msg($_LANG['product_batch_del_success'], 0, $link);
|
||||
} else {
|
||||
/* 错误 */
|
||||
/* 錯誤 */
|
||||
sys_msg($_LANG['cannot_found_products'], 1, $link);
|
||||
}
|
||||
}
|
||||
@ -1113,9 +1116,9 @@ if ($_REQUEST['act'] == 'list') {
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表链接
|
||||
* 列表鏈接
|
||||
* @param bool $is_add 是否添加(插入)
|
||||
* @param string $extension_code 虚拟商品扩展代码,实体商品为空
|
||||
* @param string $extension_code 虛擬商品擴展代碼,實體商品為空
|
||||
* @return array('href' => $href, 'text' => $text)
|
||||
*/
|
||||
function list_link($is_add = true)
|
||||
@ -1131,8 +1134,8 @@ function list_link($is_add = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加链接
|
||||
* @param string $extension_code 虚拟商品扩展代码,实体商品为空
|
||||
* 添加鏈接
|
||||
* @param string $extension_code 虛擬商品擴展代碼,實體商品為空
|
||||
* @return array('href' => $href, 'text' => $text)
|
||||
*/
|
||||
function add_link($extension_code = '')
|
||||
@ -1144,9 +1147,9 @@ function add_link($extension_code = '')
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查图片网址是否合法
|
||||
* 檢查圖片網址是否合法
|
||||
*
|
||||
* @param string $url 网址
|
||||
* @param string $url 網址
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@ -1157,10 +1160,10 @@ function games_parse_url($url)
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存某商品的优惠价格
|
||||
* @param int $games_id 商品编号
|
||||
* @param array $number_list 优惠数量列表
|
||||
* @param array $price_list 价格列表
|
||||
* 保存某商品的優惠價格
|
||||
* @param int $games_id 商品編號
|
||||
* @param array $number_list 優惠數量列表
|
||||
* @param array $price_list 價格列表
|
||||
* @return void
|
||||
*/
|
||||
function handle_volume_price($games_id, $number_list, $price_list)
|
||||
@ -1170,9 +1173,9 @@ function handle_volume_price($games_id, $number_list, $price_list)
|
||||
$GLOBALS['db']->query($sql);
|
||||
|
||||
|
||||
/* 循环处理每个优惠价格 */
|
||||
/* 循環處理每個優惠價格 */
|
||||
foreach ($price_list as $key => $price) {
|
||||
/* 价格对应的数量上下限 */
|
||||
/* 價格對應的數量上下限 */
|
||||
$volume_number = $number_list[$key];
|
||||
|
||||
if (!empty($price)) {
|
||||
@ -1185,8 +1188,8 @@ function handle_volume_price($games_id, $number_list, $price_list)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品库存
|
||||
* @param string $games_id 商品编号,可以为多个,用 ',' 隔开
|
||||
* 修改商品庫存
|
||||
* @param string $games_id 商品編號,可以為多個,用 ',' 隔開
|
||||
* @param string $value 字段值
|
||||
* @return bool
|
||||
*/
|
||||
@ -1200,7 +1203,7 @@ function update_games_stock($games_id, $value)
|
||||
WHERE games_id = '$games_id'";
|
||||
$result = $GLOBALS['db']->query($sql);
|
||||
|
||||
/* 清除缓存 */
|
||||
/* 清除緩存 */
|
||||
clear_cache_files();
|
||||
|
||||
return $result;
|
||||
@ -1220,16 +1223,16 @@ function portal_list()
|
||||
$filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'id' : trim($_REQUEST['sort_by']);
|
||||
$filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
|
||||
|
||||
/* 关键字 */
|
||||
/* 關鍵字 */
|
||||
if (!empty($filter['keyword'])) {
|
||||
// $where .= " AND (games_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%')";
|
||||
}
|
||||
|
||||
/* 记录总数 */
|
||||
/* 記錄總數 */
|
||||
$sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('portal') . " WHERE 1 $where";
|
||||
$filter['record_count'] = $GLOBALS['db']->getOne($sql);
|
||||
|
||||
/* 分页大小 */
|
||||
/* 分頁大小 */
|
||||
$filter = page_and_size($filter);
|
||||
|
||||
$sql = "SELECT * " .
|
||||
@ -1249,7 +1252,7 @@ function portal_list()
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化商品图片名称(按目录存储)
|
||||
* 格式化商品圖片名稱(按目錄存儲)
|
||||
*
|
||||
*/
|
||||
function reformat_image_name($type, $id, $source_img, $position = '')
|
||||
|
Loading…
Reference in New Issue
Block a user