cf api有問題仍可操作,只是會提示要手動去cf修改

This commit is contained in:
Wayne 2024-03-13 09:11:48 +08:00
parent 6bcf2bf94f
commit c0eb4586ef

View File

@ -10,9 +10,9 @@ $exc = new exchange($ecs->table('hs_web'), $db, 'id', 'name');
if ($_REQUEST['act'] == 'edit') if ($_REQUEST['act'] == 'edit')
{ {
include_once(ROOT_PATH . 'includes/fckeditor/fckeditor.php'); // 包含 html editor 文件 include_once(ROOT_PATH . 'includes/fckeditor/fckeditor.php'); // 包含 html editor 文件
// admin_priv('goods_manage'); // 检查权 // admin_priv('goods_manage'); // 檢查權
if (ini_get('safe_mode') == 1 && (!file_exists('../' . IMAGE_DIR . '/'.date('Ym')) || !is_dir('../' . IMAGE_DIR . '/'.date('Ym')))) if (ini_get('safe_mode') == 1 && (!file_exists('../' . IMAGE_DIR . '/'.date('Ym')) || !is_dir('../' . IMAGE_DIR . '/'.date('Ym'))))
{ {
@ -23,7 +23,7 @@ if ($_REQUEST['act'] == 'edit')
} }
} }
/* 如果目录存在但不可写,提示用户 */ /* 如果目錄存在但不可寫,提示用戶 */
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')); $warning = sprintf($_LANG['not_writable_warning'], '../' . IMAGE_DIR . '/'.date('Ym'));
@ -37,7 +37,7 @@ if ($_REQUEST['act'] == 'edit')
if (empty($hs) === true) if (empty($hs) === true)
{ {
/* 默值 */ /* 默值 */
$hs = array( $hs = array(
'domain' => '', 'domain' => '',
'cname' => '' 'cname' => ''
@ -45,11 +45,11 @@ if ($_REQUEST['act'] == 'edit')
} }
/* 片列表 */ /* 片列表 */
$sql = "SELECT * FROM " . $ecs->table('hs_gallery') . " WHERE hs_id = '$_SESSION[user_id]'"; $sql = "SELECT * FROM " . $ecs->table('hs_gallery') . " WHERE hs_id = '$_SESSION[user_id]'";
$img_list = $db->getAll($sql); $img_list = $db->getAll($sql);
/* 格式化相册图片路径 */ /* 格式化相冊圖片路徑 */
if (isset($GLOBALS['shop_id']) && ($GLOBALS['shop_id'] > 0)) if (isset($GLOBALS['shop_id']) && ($GLOBALS['shop_id'] > 0))
{ {
foreach ($img_list as $key => $gallery_img) foreach ($img_list as $key => $gallery_img)
@ -66,7 +66,7 @@ if ($_REQUEST['act'] == 'edit')
} }
} }
/* 模板值 */ /* 模板值 */
$smarty->assign('ur_here', '編輯內容'); $smarty->assign('ur_here', '編輯內容');
$smarty->assign('action_link', ''); $smarty->assign('action_link', '');
$smarty->assign('hs', $hs); $smarty->assign('hs', $hs);
@ -78,7 +78,7 @@ if ($_REQUEST['act'] == 'edit')
$smarty->assign('thumb_width', 200); $smarty->assign('thumb_width', 200);
$smarty->assign('thumb_height', 0); $smarty->assign('thumb_height', 0);
/* 显示商品信息页面 */ /* 顯示商品信息頁面 */
assign_menu_info(); assign_menu_info();
assign_query_info(); assign_query_info();
$smarty->display('hs_info.htm'); $smarty->display('hs_info.htm');
@ -86,8 +86,8 @@ if ($_REQUEST['act'] == 'edit')
elseif ($_REQUEST['act'] == 'update') elseif ($_REQUEST['act'] == 'update')
{ {
// admin_priv('goods_manage'); // 检查权 // admin_priv('goods_manage'); // 檢查權
/* 检查domain是否重复 */ /* 檢查domain是否重複 */
if ($_POST['domain']) if ($_POST['domain'])
{ {
$sql = "SELECT COUNT(*) FROM " . $ecs->table('hs_web') . $sql = "SELECT COUNT(*) FROM " . $ecs->table('hs_web') .
@ -99,14 +99,14 @@ elseif ($_REQUEST['act'] == 'update')
} }
} }
/* 检查图片:如果有错误,检查尺寸是否超过最大值;否则,检查文件类型 */ /* 檢查圖片:如果有錯誤,檢查尺寸是否超過最大值;否則,檢查文件類型 */
if (isset($_FILES['index_banner']['error'])) // php 4.2 版本才支持 error if (isset($_FILES['index_banner']['error'])) // php 4.2 版本才支持 error
{ {
// 最大上文件大小 // 最大上文件大小
$php_maxsize = ini_get('upload_max_filesize'); $php_maxsize = ini_get('upload_max_filesize');
$htm_maxsize = '20M'; $htm_maxsize = '20M';
// 商品 // 商品
if ($_FILES['index_banner']['error'] == 0) if ($_FILES['index_banner']['error'] == 0)
{ {
if (!$image->check_img_type($_FILES['index_banner']['type'])) if (!$image->check_img_type($_FILES['index_banner']['type']))
@ -146,7 +146,7 @@ elseif ($_REQUEST['act'] == 'update')
/* 4.1版本 */ /* 4.1版本 */
else else
{ {
// 商品 // 商品
if ($_FILES['index_banner']['tmp_name'] != 'none') if ($_FILES['index_banner']['tmp_name'] != 'none')
{ {
if (!$image->check_img_type($_FILES['index_banner']['type'])) if (!$image->check_img_type($_FILES['index_banner']['type']))
@ -156,7 +156,7 @@ elseif ($_REQUEST['act'] == 'update')
} }
} }
// 相册图 // 相冊圖
foreach ($_FILES['img_url']['tmp_name'] AS $key => $value) foreach ($_FILES['img_url']['tmp_name'] AS $key => $value)
{ {
if ($value != 'none') if ($value != 'none')
@ -169,17 +169,17 @@ elseif ($_REQUEST['act'] == 'update')
} }
} }
/* 处理商品图片 */ /* 處理商品圖片 */
$index_banner = ''; // 初始化商品 $index_banner = ''; // 初始化商品
$old_index_banner = ''; // 初始化原始图片旧图 $old_index_banner = ''; // 初始化原始圖片舊圖
// 如果上传了商品图片,相应处 // 如果上傳了商品圖片,相應處
if (($_FILES['index_banner']['tmp_name'] != '' && $_FILES['index_banner']['tmp_name'] != 'none')) if (($_FILES['index_banner']['tmp_name'] != '' && $_FILES['index_banner']['tmp_name'] != 'none'))
{ {
if ($_REQUEST['id'] > 0) if ($_REQUEST['id'] > 0)
{ {
/* 删除原来的图片文件 */ /* 刪除原來的圖片文件 */
$sql = "SELECT index_banner " . $sql = "SELECT index_banner " .
" FROM " . $ecs->table('hs_web') . " FROM " . $ecs->table('hs_web') .
" WHERE id = '$_REQUEST[id]'"; " WHERE id = '$_REQUEST[id]'";
@ -190,22 +190,22 @@ elseif ($_REQUEST['act'] == 'update')
} }
if ($row['original_img'] != '' && is_file('../' . $row['original_img'])) if ($row['original_img'] != '' && is_file('../' . $row['original_img']))
{ {
/* 先不处理,以防止程序中途出错停止 */ /* 先不處理,以防止程序中途出錯停止 */
//$old_original_img = $row['original_img']; //记录旧图路径 //$old_original_img = $row['original_img']; //記錄舊圖路徑
} }
/* 清除原来商品图片 */ /* 清除原來商品圖片 */
if ($proc_thumb === false) if ($proc_thumb === false)
{ {
// get_image_path($_REQUEST[goods_id], $row['goods_img'], false, 'goods', true); // get_image_path($_REQUEST[goods_id], $row['goods_img'], false, 'goods', true);
// get_image_path($_REQUEST[goods_id], $row['goods_thumb'], true, 'goods', true); // get_image_path($_REQUEST[goods_id], $row['goods_thumb'], true, 'goods', true);
} }
$original_img = $image->upload_image($_FILES['index_banner']); // 原始 $original_img = $image->upload_image($_FILES['index_banner']); // 原始
if ($original_img === false) if ($original_img === false)
{ {
sys_msg($image->error_msg(), 1, array(), false); sys_msg($image->error_msg(), 1, array(), false);
} }
$index_banner = $original_img; // 商品 $index_banner = $original_img; // 商品
} }
} }
@ -289,7 +289,7 @@ elseif ($_REQUEST['act'] == 'update')
exit; exit;
} }
} }
/* 入 */ /* 入 */
if ($is_insert) if ($is_insert)
{ {
$sql = "INSERT INTO " . $ecs->table('hs_web') . " (domain, cname, ename, " . $sql = "INSERT INTO " . $ecs->table('hs_web') . " (domain, cname, ename, " .
@ -303,7 +303,7 @@ elseif ($_REQUEST['act'] == 'update')
} }
else else
{ {
/* 如果有上传图片,删除原来的商品图 */ /* 如果有上傳圖片,刪除原來的商品圖 */
// $sql = "SELECT index_banner " . // $sql = "SELECT index_banner " .
// " FROM " . $ecs->table('hs_web') . // " FROM " . $ecs->table('hs_web') .
// " WHERE id = '$_REQUEST[id]'"; // " WHERE id = '$_REQUEST[id]'";
@ -333,7 +333,7 @@ elseif ($_REQUEST['act'] == 'update')
"location_desc = '$_POST[location_desc]', " . "location_desc = '$_POST[location_desc]', " .
"location_map = '$_POST[location_map]', "; "location_map = '$_POST[location_map]', ";
/* 如果有上传图片,需要更新数据库 */ /* 如果有上傳圖片,需要更新數據庫 */
if ($index_banner) if ($index_banner)
{ {
$sql .= "index_banner = '$index_banner', "; $sql .= "index_banner = '$index_banner', ";
@ -365,10 +365,10 @@ elseif ($_REQUEST['act'] == 'update')
} }
$db->query($sql); $db->query($sql);
/* 商品编号 */ /* 商品編號 */
$id = $is_insert ? $db->insert_id() : $_REQUEST['id']; $id = $is_insert ? $db->insert_id() : $_REQUEST['id'];
/* 记录日志 */ /* 記錄日誌 */
if ($is_insert) if ($is_insert)
{ {
//admin_log($_POST['goods_name'], 'add', 'goods'); //admin_log($_POST['goods_name'], 'add', 'goods');
@ -389,7 +389,7 @@ elseif ($_REQUEST['act'] == 'update')
} }
} }
/* 不保留商品原图的时候删除原图 */ /* 不保留商品原圖的時候刪除原圖 */
// if ($proc_thumb && !$_CFG['retain_original_img'] && !empty($original_img)) // if ($proc_thumb && !$_CFG['retain_original_img'] && !empty($original_img))
// { // {
// $db->query("UPDATE " . $ecs->table('goods') . " SET original_img='' WHERE `goods_id`='{$goods_id}'"); // $db->query("UPDATE " . $ecs->table('goods') . " SET original_img='' WHERE `goods_id`='{$goods_id}'");
@ -398,7 +398,7 @@ elseif ($_REQUEST['act'] == 'update')
// @unlink('../' . $img); // @unlink('../' . $img);
// } // }
/* 清空存 */ /* 清空存 */
clear_cache_files(); clear_cache_files();
if ($is_insert) if ($is_insert)
@ -417,7 +417,11 @@ elseif ($_REQUEST['act'] == 'update')
$link = array_combine($key_array, $link); $link = array_combine($key_array, $link);
sys_msg('更新成功', 0, $link); if($cf_iden>0){
sys_msg('更新成功', 0, $link);
}else{
sys_msg('更新成功,但網域自動修改失敗,請手動至CF操作',1, array(), false);
}
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
@ -428,7 +432,7 @@ elseif ($_REQUEST['act'] == 'batch')
{ {
$code = empty($_REQUEST['extension_code'])? '' : trim($_REQUEST['extension_code']); $code = empty($_REQUEST['extension_code'])? '' : trim($_REQUEST['extension_code']);
/* 取得要操作的商品编号 */ /* 取得要操作的商品編號 */
$goods_id = !empty($_POST['checkboxes']) ? join(',', $_POST['checkboxes']) : 0; $goods_id = !empty($_POST['checkboxes']) ? join(',', $_POST['checkboxes']) : 0;
if (isset($_POST['type'])) if (isset($_POST['type']))
@ -436,18 +440,18 @@ elseif ($_REQUEST['act'] == 'batch')
/* 放入回收站 */ /* 放入回收站 */
if ($_POST['type'] == 'trash') if ($_POST['type'] == 'trash')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('remove_back'); admin_priv('remove_back');
update_goods($goods_id, 'is_delete', '1'); update_goods($goods_id, 'is_delete', '1');
/* 记录日志 */ /* 記錄日誌 */
admin_log('', 'batch_trash', 'goods'); admin_log('', 'batch_trash', 'goods');
} }
/* 上架 */ /* 上架 */
elseif ($_POST['type'] == 'on_sale') elseif ($_POST['type'] == 'on_sale')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'is_on_sale', '1'); update_goods($goods_id, 'is_on_sale', '1');
} }
@ -455,15 +459,15 @@ elseif ($_REQUEST['act'] == 'batch')
/* 下架 */ /* 下架 */
elseif ($_POST['type'] == 'not_on_sale') elseif ($_POST['type'] == 'not_on_sale')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'is_on_sale', '0'); update_goods($goods_id, 'is_on_sale', '0');
} }
/* 设为精品 */ /* 設為精品 */
elseif ($_POST['type'] == 'best') elseif ($_POST['type'] == 'best')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'is_best', '1'); update_goods($goods_id, 'is_best', '1');
} }
@ -471,15 +475,15 @@ elseif ($_REQUEST['act'] == 'batch')
/* 取消精品 */ /* 取消精品 */
elseif ($_POST['type'] == 'not_best') elseif ($_POST['type'] == 'not_best')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'is_best', '0'); update_goods($goods_id, 'is_best', '0');
} }
/* 设为新品 */ /* 設為新品 */
elseif ($_POST['type'] == 'new') elseif ($_POST['type'] == 'new')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'is_new', '1'); update_goods($goods_id, 'is_new', '1');
} }
@ -487,68 +491,68 @@ elseif ($_REQUEST['act'] == 'batch')
/* 取消新品 */ /* 取消新品 */
elseif ($_POST['type'] == 'not_new') elseif ($_POST['type'] == 'not_new')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'is_new', '0'); update_goods($goods_id, 'is_new', '0');
} }
/* 设为热销 */ /* 設為熱銷 */
elseif ($_POST['type'] == 'hot') elseif ($_POST['type'] == 'hot')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'is_hot', '1'); update_goods($goods_id, 'is_hot', '1');
} }
/* 取消热销 */ /* 取消熱銷 */
elseif ($_POST['type'] == 'not_hot') elseif ($_POST['type'] == 'not_hot')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'is_hot', '0'); update_goods($goods_id, 'is_hot', '0');
} }
/* 转移到分类 */ /* 轉移到分類 */
elseif ($_POST['type'] == 'move_to') elseif ($_POST['type'] == 'move_to')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'cat_id', $_POST['target_cat']); update_goods($goods_id, 'cat_id', $_POST['target_cat']);
} }
/* 转移到供货商 */ /* 轉移到供貨商 */
elseif ($_POST['type'] == 'suppliers_move_to') elseif ($_POST['type'] == 'suppliers_move_to')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('goods_manage'); admin_priv('goods_manage');
update_goods($goods_id, 'suppliers_id', $_POST['suppliers_id']); update_goods($goods_id, 'suppliers_id', $_POST['suppliers_id']);
} }
/* 原 */ /* 原 */
elseif ($_POST['type'] == 'restore') elseif ($_POST['type'] == 'restore')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('remove_back'); admin_priv('remove_back');
update_goods($goods_id, 'is_delete', '0'); update_goods($goods_id, 'is_delete', '0');
/* 记录日志 */ /* 記錄日誌 */
admin_log('', 'batch_restore', 'goods'); admin_log('', 'batch_restore', 'goods');
} }
/* 除 */ /* 除 */
elseif ($_POST['type'] == 'drop') elseif ($_POST['type'] == 'drop')
{ {
/* 检查权限 */ /* 檢查權限 */
admin_priv('remove_back'); admin_priv('remove_back');
delete_goods($goods_id); delete_goods($goods_id);
/* 记录日志 */ /* 記錄日誌 */
admin_log('', 'batch_remove', 'goods'); admin_log('', 'batch_remove', 'goods');
} }
} }
/* 清除存 */ /* 清除存 */
clear_cache_files(); clear_cache_files();
if ($_POST['type'] == 'drop' || $_POST['type'] == 'restore') if ($_POST['type'] == 'drop' || $_POST['type'] == 'restore')
@ -563,7 +567,7 @@ elseif ($_REQUEST['act'] == 'batch')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 显示图 //-- 顯示圖
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'show_image') elseif ($_REQUEST['act'] == 'show_image')
@ -576,7 +580,7 @@ elseif ($_REQUEST['act'] == 'show_image')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改商品名 //-- 修改商品名
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_goods_name') elseif ($_REQUEST['act'] == 'edit_goods_name')
{ {
@ -593,7 +597,7 @@ elseif ($_REQUEST['act'] == 'edit_goods_name')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改商品货号 //-- 修改商品貨號
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_goods_sn') elseif ($_REQUEST['act'] == 'edit_goods_sn')
{ {
@ -602,7 +606,7 @@ elseif ($_REQUEST['act'] == 'edit_goods_sn')
$goods_id = intval($_POST['id']); $goods_id = intval($_POST['id']);
$goods_sn = json_str_iconv(trim($_POST['val'])); $goods_sn = json_str_iconv(trim($_POST['val']));
/* 检查是否重复 */ /* 檢查是否重複 */
if (!$exc->is_only('goods_sn', $goods_sn, $goods_id)) if (!$exc->is_only('goods_sn', $goods_sn, $goods_id))
{ {
make_json_error($_LANG['goods_sn_exists']); make_json_error($_LANG['goods_sn_exists']);
@ -621,7 +625,7 @@ elseif ($_REQUEST['act'] == 'check_goods_sn')
$goods_id = intval($_REQUEST['goods_id']); $goods_id = intval($_REQUEST['goods_id']);
$goods_sn = htmlspecialchars(json_str_iconv(trim($_REQUEST['goods_sn']))); $goods_sn = htmlspecialchars(json_str_iconv(trim($_REQUEST['goods_sn'])));
/* 检查是否重复 */ /* 檢查是否重複 */
if (!$exc->is_only('goods_sn', $goods_sn, $goods_id)) if (!$exc->is_only('goods_sn', $goods_sn, $goods_id))
{ {
make_json_error($_LANG['goods_sn_exists']); make_json_error($_LANG['goods_sn_exists']);
@ -661,12 +665,12 @@ elseif ($_REQUEST['act'] == 'check_products_goods_sn')
} }
} }
} }
/* 检查是否重复 */ /* 檢查是否重複 */
make_json_result(''); make_json_result('');
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改商品 //-- 修改商品
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_goods_price') elseif ($_REQUEST['act'] == 'edit_goods_price')
{ {
@ -690,7 +694,7 @@ elseif ($_REQUEST['act'] == 'edit_goods_price')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改商品库存数 //-- 修改商品庫存數
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_goods_number') elseif ($_REQUEST['act'] == 'edit_goods_number')
{ {
@ -717,7 +721,7 @@ elseif ($_REQUEST['act'] == 'edit_goods_number')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改上架状态 //-- 修改上架狀態
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'toggle_on_sale') elseif ($_REQUEST['act'] == 'toggle_on_sale')
{ {
@ -734,7 +738,7 @@ elseif ($_REQUEST['act'] == 'toggle_on_sale')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改精品推荐状态 //-- 修改精品推薦狀態
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'toggle_best') elseif ($_REQUEST['act'] == 'toggle_best')
{ {
@ -751,7 +755,7 @@ elseif ($_REQUEST['act'] == 'toggle_best')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改新品推荐状态 //-- 修改新品推薦狀態
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'toggle_new') elseif ($_REQUEST['act'] == 'toggle_new')
{ {
@ -768,7 +772,7 @@ elseif ($_REQUEST['act'] == 'toggle_new')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改热销推荐状态 //-- 修改熱銷推薦狀態
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'toggle_hot') elseif ($_REQUEST['act'] == 'toggle_hot')
{ {
@ -802,7 +806,7 @@ elseif ($_REQUEST['act'] == 'edit_sort_order')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 排序、分页、查询 //-- 排序、分頁、查詢
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'query') elseif ($_REQUEST['act'] == 'query')
{ {
@ -819,11 +823,11 @@ elseif ($_REQUEST['act'] == 'query')
$smarty->assign('list_type', $is_delete ? 'trash' : 'goods'); $smarty->assign('list_type', $is_delete ? 'trash' : 'goods');
$smarty->assign('use_storage', empty($_CFG['use_storage']) ? 0 : 1); $smarty->assign('use_storage', empty($_CFG['use_storage']) ? 0 : 1);
/* 排序标记 */ /* 排序標記 */
$sort_flag = sort_flag($goods_list['filter']); $sort_flag = sort_flag($goods_list['filter']);
$smarty->assign($sort_flag['tag'], $sort_flag['img']); $smarty->assign($sort_flag['tag'], $sort_flag['img']);
/* 获取商品类型存在规格的类型 */ /* 獲取商品類型存在規格的類型 */
$tpl = $is_delete ? 'goods_trash.htm' : 'goods_list.htm'; $tpl = $is_delete ? 'goods_trash.htm' : 'goods_list.htm';
@ -838,7 +842,7 @@ elseif ($_REQUEST['act'] == 'remove')
{ {
$goods_id = intval($_REQUEST['id']); $goods_id = intval($_REQUEST['id']);
/* 检查权限 */ /* 檢查權限 */
check_authz_json('remove_back'); check_authz_json('remove_back');
if ($exc->edit("is_delete = 1", $goods_id)) if ($exc->edit("is_delete = 1", $goods_id))
@ -846,7 +850,7 @@ elseif ($_REQUEST['act'] == 'remove')
clear_cache_files(); clear_cache_files();
$goods_name = $exc->get_name($goods_id); $goods_name = $exc->get_name($goods_id);
admin_log(addslashes($goods_name), 'trash', 'goods'); // 记录日志 admin_log(addslashes($goods_name), 'trash', 'goods'); // 記錄日誌
$url = 'goods.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']); $url = 'goods.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']);
@ -856,21 +860,21 @@ elseif ($_REQUEST['act'] == 'remove')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 原回收站中的商品 //-- 原回收站中的商品
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'restore_goods') elseif ($_REQUEST['act'] == 'restore_goods')
{ {
$goods_id = intval($_REQUEST['id']); $goods_id = intval($_REQUEST['id']);
check_authz_json('remove_back'); // 检查权 check_authz_json('remove_back'); // 檢查權
$exc->edit("is_delete = 0, add_time = '" . gmtime() . "'", $goods_id); $exc->edit("is_delete = 0, add_time = '" . gmtime() . "'", $goods_id);
clear_cache_files(); clear_cache_files();
$goods_name = $exc->get_name($goods_id); $goods_name = $exc->get_name($goods_id);
admin_log(addslashes($goods_name), 'restore', 'goods'); // 记录日志 admin_log(addslashes($goods_name), 'restore', 'goods'); // 記錄日誌
$url = 'goods.php?act=query&' . str_replace('act=restore_goods', '', $_SERVER['QUERY_STRING']); $url = 'goods.php?act=query&' . str_replace('act=restore_goods', '', $_SERVER['QUERY_STRING']);
@ -879,14 +883,14 @@ elseif ($_REQUEST['act'] == 'restore_goods')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 彻底删除商品 //-- 徹底刪除商品
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'drop_goods') elseif ($_REQUEST['act'] == 'drop_goods')
{ {
// 检查权 // 檢查權
check_authz_json('remove_back'); check_authz_json('remove_back');
// 取得参数 // 取得參數
$goods_id = intval($_REQUEST['id']); $goods_id = intval($_REQUEST['id']);
if ($goods_id <= 0) if ($goods_id <= 0)
{ {
@ -909,7 +913,7 @@ elseif ($_REQUEST['act'] == 'drop_goods')
make_json_error($_LANG['goods_not_in_recycle_bin']); make_json_error($_LANG['goods_not_in_recycle_bin']);
} }
/* 删除商品图片和轮播图片 */ /* 刪除商品圖片和輪播圖片 */
if (!empty($goods['goods_thumb'])) if (!empty($goods['goods_thumb']))
{ {
@unlink('../' . $goods['goods_thumb']); @unlink('../' . $goods['goods_thumb']);
@ -922,14 +926,14 @@ elseif ($_REQUEST['act'] == 'drop_goods')
{ {
@unlink('../' . $goods['original_img']); @unlink('../' . $goods['original_img']);
} }
/* 除商品 */ /* 除商品 */
$exc->drop($goods_id); $exc->drop($goods_id);
/* 记录日志 */ /* 記錄日誌 */
admin_log(addslashes($goods['goods_name']), 'remove', 'goods'); admin_log(addslashes($goods['goods_name']), 'remove', 'goods');
/* 删除商品相册 */ /* 刪除商品相冊 */
$sql = "SELECT img_url, thumb_url, img_original " . $sql = "SELECT img_url, thumb_url, img_original " .
"FROM " . $ecs->table('goods_gallery') . "FROM " . $ecs->table('goods_gallery') .
" WHERE goods_id = '$goods_id'"; " WHERE goods_id = '$goods_id'";
@ -953,7 +957,7 @@ elseif ($_REQUEST['act'] == 'drop_goods')
$sql = "DELETE FROM " . $ecs->table('goods_gallery') . " WHERE goods_id = '$goods_id'"; $sql = "DELETE FROM " . $ecs->table('goods_gallery') . " WHERE goods_id = '$goods_id'";
$db->query($sql); $db->query($sql);
/* 删除相关表记录 */ /* 刪除相關表記錄 */
$sql = "DELETE FROM " . $ecs->table('collect_goods') . " WHERE goods_id = '$goods_id'"; $sql = "DELETE FROM " . $ecs->table('collect_goods') . " WHERE goods_id = '$goods_id'";
$db->query($sql); $db->query($sql);
$sql = "DELETE FROM " . $ecs->table('goods_article') . " WHERE goods_id = '$goods_id'"; $sql = "DELETE FROM " . $ecs->table('goods_article') . " WHERE goods_id = '$goods_id'";
@ -983,7 +987,7 @@ elseif ($_REQUEST['act'] == 'drop_goods')
$sql = "DELETE FROM " . $ecs->table('goods_activity') . " WHERE goods_id = '$goods_id'"; $sql = "DELETE FROM " . $ecs->table('goods_activity') . " WHERE goods_id = '$goods_id'";
$db->query($sql); $db->query($sql);
/* 如果不是实体商品,删除相应虚拟商品记录 */ /* 如果不是實體商品,刪除相應虛擬商品記錄 */
if ($goods['is_real'] != 1) if ($goods['is_real'] != 1)
{ {
$sql = "DELETE FROM " . $ecs->table('virtual_card') . " WHERE goods_id = '$goods_id'"; $sql = "DELETE FROM " . $ecs->table('virtual_card') . " WHERE goods_id = '$goods_id'";
@ -1002,7 +1006,7 @@ elseif ($_REQUEST['act'] == 'drop_goods')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 切换商品类 //-- 切換商品類
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'get_attr') elseif ($_REQUEST['act'] == 'get_attr')
{ {
@ -1017,7 +1021,7 @@ elseif ($_REQUEST['act'] == 'get_attr')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 删除图 //-- 刪除圖
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'drop_image') elseif ($_REQUEST['act'] == 'drop_image')
{ {
@ -1025,7 +1029,7 @@ elseif ($_REQUEST['act'] == 'drop_image')
$img_id = empty($_REQUEST['img_id']) ? 0 : intval($_REQUEST['img_id']); $img_id = empty($_REQUEST['img_id']) ? 0 : intval($_REQUEST['img_id']);
/* 删除图片文件 */ /* 刪除圖片文件 */
$sql = "SELECT img_url, thumb_url, img_original " . $sql = "SELECT img_url, thumb_url, img_original " .
" FROM " . $GLOBALS['ecs']->table('hs_gallery') . " FROM " . $GLOBALS['ecs']->table('hs_gallery') .
" WHERE img_id = '$img_id'"; " WHERE img_id = '$img_id'";
@ -1044,7 +1048,7 @@ elseif ($_REQUEST['act'] == 'drop_image')
@unlink('../' . $row['img_original']); @unlink('../' . $row['img_original']);
} }
/* 删除数据 */ /* 刪除數據 */
$sql = "DELETE FROM " . $GLOBALS['ecs']->table('hs_gallery') . " WHERE img_id = '$img_id' LIMIT 1"; $sql = "DELETE FROM " . $GLOBALS['ecs']->table('hs_gallery') . " WHERE img_id = '$img_id' LIMIT 1";
$GLOBALS['db']->query($sql); $GLOBALS['db']->query($sql);
@ -1053,7 +1057,7 @@ elseif ($_REQUEST['act'] == 'drop_image')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 搜索商品,仅返回名称及ID //-- 搜索商品,僅返回名稱及ID
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'get_goods_list') elseif ($_REQUEST['act'] == 'get_goods_list')
{ {
@ -1076,7 +1080,7 @@ elseif ($_REQUEST['act'] == 'get_goods_list')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 把商品加入关联 //-- 把商品加入關聯
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'add_link_goods') elseif ($_REQUEST['act'] == 'add_link_goods')
{ {
@ -1094,7 +1098,7 @@ elseif ($_REQUEST['act'] == 'add_link_goods')
{ {
if ($is_double) if ($is_double)
{ {
/* 双向关联 */ /* 雙向關聯 */
$sql = "INSERT INTO " . $ecs->table('link_goods') . " (goods_id, link_goods_id, is_double, admin_id) " . $sql = "INSERT INTO " . $ecs->table('link_goods') . " (goods_id, link_goods_id, is_double, admin_id) " .
"VALUES ('$val', '$goods_id', '$is_double', '$_SESSION[admin_id]')"; "VALUES ('$val', '$goods_id', '$is_double', '$_SESSION[admin_id]')";
$db->query($sql, 'SILENT'); $db->query($sql, 'SILENT');
@ -1120,7 +1124,7 @@ elseif ($_REQUEST['act'] == 'add_link_goods')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 删除关联商品 //-- 刪除關聯商品
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'drop_link_goods') elseif ($_REQUEST['act'] == 'drop_link_goods')
{ {
@ -1175,7 +1179,7 @@ elseif ($_REQUEST['act'] == 'drop_link_goods')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 增加一配件 //-- 增加一配件
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'add_group_goods') elseif ($_REQUEST['act'] == 'add_group_goods')
@ -1212,7 +1216,7 @@ elseif ($_REQUEST['act'] == 'add_group_goods')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 删除一个配件 //-- 刪除一個配件
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'drop_group_goods') elseif ($_REQUEST['act'] == 'drop_group_goods')
@ -1282,11 +1286,11 @@ elseif ($_REQUEST['act'] == 'get_article_list')
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 货品删 //-- 貨品刪
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'product_remove') elseif ($_REQUEST['act'] == 'product_remove')
{ {
/* 检查权限 */ /* 檢查權限 */
check_authz_json('remove_back'); check_authz_json('remove_back');
/* 是否存在商品id */ /* 是否存在商品id */
@ -1299,22 +1303,22 @@ elseif ($_REQUEST['act'] == 'product_remove')
$product_id = intval($_REQUEST['id']); $product_id = intval($_REQUEST['id']);
} }
/* 货品库存 */ /* 貨品庫存 */
$product = get_product_info($product_id, 'product_number, goods_id'); $product = get_product_info($product_id, 'product_number, goods_id');
/* 删除货品 */ /* 刪除貨品 */
$sql = "DELETE FROM " . $ecs->table('products') . " WHERE product_id = '$product_id'"; $sql = "DELETE FROM " . $ecs->table('products') . " WHERE product_id = '$product_id'";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
/* 修改商品存 */ /* 修改商品存 */
if (update_goods_stock($product['goods_id'], $product_number - $product['product_number'])) if (update_goods_stock($product['goods_id'], $product_number - $product['product_number']))
{ {
//记录日志 //記錄日誌
admin_log('', 'update', 'goods'); admin_log('', 'update', 'goods');
} }
//记录日志 //記錄日誌
admin_log('', 'trash', 'products'); admin_log('', 'trash', 'products');
$url = 'goods.php?act=product_query&' . str_replace('act=product_remove', '', $_SERVER['QUERY_STRING']); $url = 'goods.php?act=product_query&' . str_replace('act=product_remove', '', $_SERVER['QUERY_STRING']);
@ -1325,7 +1329,7 @@ elseif ($_REQUEST['act'] == 'product_remove')
} }
/*------------------------------------------------------ */ /*------------------------------------------------------ */
//-- 修改货品价 //-- 修改貨品價
/*------------------------------------------------------ */ /*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_product_sn') elseif ($_REQUEST['act'] == 'edit_product_sn')
{ {
@ -1351,9 +1355,9 @@ elseif ($_REQUEST['act'] == 'edit_product_sn')
} }
/** /**
* 列表 * 列表
* @param bool $is_add 是否添加(插入) * @param bool $is_add 是否添加(插入)
* @param string $extension_code 虚拟商品扩展代码,实体商品为 * @param string $extension_code 虛擬商品擴展代碼,實體商品為
* @return array('href' => $href, 'text' => $text) * @return array('href' => $href, 'text' => $text)
*/ */
function list_link() function list_link()
@ -1365,8 +1369,8 @@ function list_link()
} }
/** /**
* 添加 * 添加
* @param string $extension_code 虚拟商品扩展代码,实体商品为 * @param string $extension_code 虛擬商品擴展代碼,實體商品為
* @return array('href' => $href, 'text' => $text) * @return array('href' => $href, 'text' => $text)
*/ */
function add_link() function add_link()
@ -1378,9 +1382,9 @@ function add_link()
} }
/** /**
* 检查图片网址是否合法 * 檢查圖片網址是否合法
* *
* @param string $url * @param string $url
* *
* @return boolean * @return boolean
*/ */