ecshop代码要求21页.docx
- 文档编号:25283426
- 上传时间:2023-06-07
- 格式:DOCX
- 页数:16
- 大小:19.48KB
ecshop代码要求21页.docx
《ecshop代码要求21页.docx》由会员分享,可在线阅读,更多相关《ecshop代码要求21页.docx(16页珍藏版)》请在冰豆网上搜索。
ecshop代码要求21页
1.数据库连接关键代码
/*初始化数据库类*/
require(ROOT_PATH.'includes/cls_mysql.php');
$db=newcls_mysql($db_host,$db_user,$db_pass,$db_name);
$db_host=$db_user=$db_pass=$db_name=NULL;
2.查看用户关键代码部分
//--用户帐号列表
if($_REQUEST['act']=='list')
/*检查权限*/
admin_priv('users_manage');
$sql="SELECTrank_id,rank_name,min_pointsFROM".$ecs->table('user_rank')."ORDERBYmin_pointsASC";
$rs=$db->query($sql);
$ranks=array();
while($row=$db->FetchRow($rs))
$ranks[$row['rank_id']]=$row['rank_name'];
$smarty->assign('user_ranks',$ranks);
$smarty->assign('ur_here',$_LANG['03_users_list']);
$smarty->assign('action_link',array('text'=>$_LANG['04_users_add'],'href'=>'users.php?
act=add'));
$user_list=user_list();
$smarty->assign('user_list',$user_list['user_list']);
$smarty->assign('filter',$user_list['filter']);
$smarty->assign('record_count',$user_list['record_count']);
$smarty->assign('page_count',$user_list['page_count']);
$smarty->assign('full_page',1);
$smarty->assign('sort_user_id','
assign_query_info();
$smarty->display('users_list.htm');
3.修改用户关键代码部分
//--更新用户帐号
elseif($_REQUEST['act']=='update')
/*检查权限*/
admin_priv('users_manage');
$username=empty($_POST['username'])?
'':
trim($_POST['username']);
$password=empty($_POST['password'])?
'':
trim($_POST['password']);
$email=empty($_POST['email'])?
'':
trim($_POST['email']);
$sex=empty($_POST['sex'])?
0:
intval($_POST['sex']);
$sex=in_array($sex,array(0,1,2))?
$sex:
0;
$birthday=$_POST['birthdayYear'].'-'.$_POST['birthdayMonth'].'-'.$_POST['birthdayDay'];
$rank=empty($_POST['user_rank'])?
0:
intval($_POST['user_rank']);
$credit_line=empty($_POST['credit_line'])?
0:
floatval($_POST['credit_line']);
$users=&init_users();
if(!
$users->edit_user(array('username'=>$username,'password'=>$password,'email'=>$email,'gender'=>$sex,'bday'=>$birthday),1))
if($users->error==ERR_EMAIL_EXISTS)
$msg=$_LANG['email_exists'];
else
$msg=$_LANG['edit_user_failed'];
sys_msg($msg,1);
/*更新用户扩展字段的数据*/
$sql='SELECTidFROM'.$ecs->table('reg_fields').'WHEREtype=0ANDdisplay=1ORDERBYdis_order,id';//读出所有扩展字段的id
$fields_arr=$db->getAll($sql);
$user_id_arr=$users->get_profile_by_name($username);
$user_id=$user_id_arr['user_id'];
foreach($fields_arrAS$val)//循环更新扩展用户信息
$extend_field_index='extend_field'.$val['id'];
if(isset($_POST[$extend_field_index]))
$temp_field_content=strlen($_POST[$extend_field_index])>100?
mb_substr($_POST[$extend_field_index],0,99):
$_POST[$extend_field_index];
$sql='SELECT*FROM'.$ecs->table('reg_extend_info')."WHEREreg_field_id='$val[id]'ANDuser_id='$user_id'";
if($db->getOne($sql))//如果之前没有记录,则插入
$sql='UPDATE'.$ecs->table('reg_extend_info')."SETcontent='$temp_field_content'WHEREreg_field_id='$val[id]'ANDuser_id='$user_id'";
else
$sql='INSERTINTO'.$ecs->table('reg_extend_info')."(`user_id`,`reg_field_id`,`content`)VALUES('$user_id','$val[id]','$temp_field_content')";
$db->query($sql);
/*更新会员的其它信息*/
$other=array();
$other['credit_line']=$credit_line;
$other['user_rank']=$rank;
$other['msn']=isset($_POST['extend_field1'])?
htmlspecialchars(trim($_POST['extend_field1'])):
'';
$other['qq']=isset($_POST['extend_field2'])?
htmlspecialchars(trim($_POST['extend_field2'])):
'';
$other['office_phone']=isset($_POST['extend_field3'])?
htmlspecialchars(trim($_POST['extend_field3'])):
'';
$other['home_phone']=isset($_POST['extend_field4'])?
htmlspecialchars(trim($_POST['extend_field4'])):
'';
$other['mobile_phone']=isset($_POST['extend_field5'])?
htmlspecialchars(trim($_POST['extend_field5'])):
'';
$db->autoExecute($ecs->table('users'),$other,'UPDATE',"user_name='$username'");
4.删除用户代码部分
//--删除会员帐号
elseif($_REQUEST['act']=='remove')
/*检查权限*/
admin_priv('users_drop');
$sql="SELECTuser_nameFROM".$ecs->table('users')."WHEREuser_id='".$_GET['id']."'";
$username=$db->getOne($sql);
/*通过插件来删除用户*/
$users=&init_users();
$users->remove_user($username);//已经删除用户所有数据
/*记录管理员操作*/
admin_log(addslashes($username),'remove','users');
/*提示信息*/
$link[]=array('text'=>$_LANG['go_back'],'href'=>'users.php?
act=list');
sys_msg(sprintf($_LANG['remove_success'],$username),0,$link);
5.查看商品关键代码部分
admin_priv('goods_manage');
$cat_id=empty($_REQUEST['cat_id'])?
0:
intval($_REQUEST['cat_id']);
$code=empty($_REQUEST['extension_code'])?
'':
trim($_REQUEST['extension_code']);
$suppliers_id=isset($_REQUEST['suppliers_id'])?
(empty($_REQUEST['suppliers_id'])?
'':
trim($_REQUEST['suppliers_id'])):
'';
$is_on_sale=isset($_REQUEST['is_on_sale'])?
((empty($_REQUEST['is_on_sale'])&&$_REQUEST['is_on_sale']===0)?
'':
trim($_REQUEST['is_on_sale'])):
'';
$handler_list=array();
$handler_list['virtual_card'][]=array('url'=>'virtual_card.php?
act=card','title'=>$_LANG['card'],'img'=>'icon_send_bonus.gif');
$handler_list['virtual_card'][]=array('url'=>'virtual_card.php?
act=replenish','title'=>$_LANG['replenish'],'img'=>'icon_add.gif');
$handler_list['virtual_card'][]=array('url'=>'virtual_card.php?
act=batch_card_add','title'=>$_LANG['batch_card_add'],'img'=>'icon_output.gif');
if($_REQUEST['act']=='list'&&isset($handler_list[$code]))
$smarty->assign('add_handler',$handler_list[$code]);
6.添加商品关键代码部分
include_once(ROOT_PATH.'includes/fckeditor/fckeditor.php');//包含htmleditor类文件
$is_add=$_REQUEST['act']=='add';//添加还是编辑的标识
$is_copy=$_REQUEST['act']=='copy';//是否复制
$code=empty($_REQUEST['extension_code'])?
'':
trim($_REQUEST['extension_code']);
if($code=='virual_card')
admin_priv('virualcard');//检查权限
else
admin_priv('goods_manage');//检查权限
/*供货商名*/
$suppliers_list_name=suppliers_list_name();
$suppliers_exists=1;
if(empty($suppliers_list_name))
$suppliers_exists=0;
$smarty->assign('suppliers_exists',$suppliers_exists);
$smarty->assign('suppliers_list_name',$suppliers_list_name);
unset($suppliers_list_name,$suppliers_exists);
/*如果是安全模式,检查目录是否存在*/
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'));
$smarty->assign('warning',$warning);
/*如果目录存在但不可写,提示用户*/
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);
7.修改商品关键代码
$code=empty($_REQUEST['extension_code'])?
'':
trim($_REQUEST['extension_code']);
/*是否处理缩略图*/
$proc_thumb=(isset($GLOBALS['shop_id'])&&$GLOBALS['shop_id']>0)?
false:
true;
if($code=='virtual_card')
admin_priv('virualcard');//检查权限
else
admin_priv('goods_manage');//检查权限
/*检查货号是否重复*/
if($_POST['goods_sn'])
$sql="SELECTCOUNT(*)FROM".$ecs->table('goods').
"WHEREgoods_sn='$_POST[goods_sn]'ANDis_delete=0ANDgoods_id<>'$_POST[goods_id]'";
if($db->getOne($sql)>0)
sys_msg($_LANG['goods_sn_exists'],1,array(),false);
/*检查图片:
如果有错误,检查尺寸是否超过最大值;否则,检查文件类型*/
if(isset($_FILES['goods_img']['error']))//php4.2版本才支持error
//最大上传文件大小
$php_maxsize=ini_get('upload_max_filesize');
$htm_maxsize='2M';
//商品图片
if($_FILES['goods_img']['error']==0)
if(!
$image->check_img_type($_FILES['goods_img']['type']))
sys_msg($_LANG['invalid_goods_img'],1,array(),false);
elseif($_FILES['goods_img']['error']==1)
sys_msg(sprintf($_LANG['goods_img_too_big'],$php_maxsize),1,array(),false);
elseif($_FILES['goods_img']['error']==2)
sys_msg(sprintf($_LANG['goods_img_too_big'],$htm_maxsize),1,array(),false);
//商品缩略图
if(isset($_FILES['goods_thumb']))
if($_FILES['goods_thumb']['error']==0)
if(!
$image->check_img_type($_FILES['goods_thumb']['type']))
sys_msg($_LANG['invalid_goods_thumb'],1,array(),false);
elseif($_FILES['goods_thumb']['error']==1)
sys_msg(sprintf($_LANG['goods_thumb_too_big'],$php_maxsize),1,array(),false);
elseif($_FILES['goods_thumb']['error']==2)
sys_msg(sprintf($_LANG['goods_thumb_too_big'],$htm_maxsize),1,array(),false);
//相册图片
foreach($_FILES['img_url']['error']AS$key=>$value)
if($value==0)
if(!
$image->check_img_type($_FILES['img_url']['type'][$key]))
sys_msg(sprintf($_LANG['invalid_img_url'],$key+1),1,array(),false);
elseif($value==1)
sys_msg(sprintf($_LANG['img_url_too_big'],$key+1,$php_maxsize),1,array(),false);
elseif($_FILES['img_url']['error']==2)
sys_msg(sprintf($_LANG['img_url_too_big'],$key+1,$htm_maxsize),1,array(),false);
8.删除商品关键代码
//--彻底删除商品
elseif($_REQUEST['act']=='drop_goods')
//检查权限
check_authz_json('remove_back');
//取得参数
$goods_id=intval($_REQUEST['id']);
if($goods_id<=0)
make_'invalidparams');
/*取得商品信息*/
$sql="SELECTgoods_id,goods_name,is_delete,is_real,goods_thumb,".
"goods_img,original_img".
"FROM".$ecs->table('goods').
"WHEREgoods_id='$goods_id'";
$goods=$db->getRow($sql);
if(empty($goods))
make_$_LANG['goods_not_exist']);
if($goods['is_delete']!
=1)
make_$_LANG['goods_not_in_recycle_bin']);
/*删除商品图片和轮播图片*/
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']);
/*删除商品*/
$exc->drop($goods_id);
/*删除商品的货品记录*/
$sql="DELETEFROM".$ecs
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ecshop 代码 要求 21
![提示](https://static.bdocx.com/images/bang_tan.gif)