<?php
include("loginkey.php");//引入权限检测文件
include("include/config.php");//引入公共变量文件
include("include/common.php");//引入公共函数文件
$lm_title = cinput($_POST['lm_title']);
$lm_source = cinput($_POST['lm_source']);
$lm_writer = cinput($_POST['lm_writer']);
$lm_type = cinput($_POST['lm_type']);
$lm_img = cinput($_POST['lm_img']);
$lm_imgw = cinput($_POST['lm_imgw']);
$lm_imgh = cinput($_POST['lm_imgh']);
$lm_keywords = cinput($_POST['lm_keywords']);
$lm_des = cinput($_POST['lm_des']);
$lm_body = cinput($_POST['lm_body']);
$lm_date = cinput($_POST['lm_date']);
$lm_buyurl = cinput($_POST['lm_buyurl']);
$lm_dw = cinput($_POST['lm_dw']);
$lm_dj = cinput($_POST['lm_dj']);
$lm_numeric = cinput($_POST['lm_numeric']);
$lm_alt = cinput($_POST['lm_alt']);
$atype = $_POST['atype'];
if(!is_numeric($lm_type)){
	 echo "<script>alert('栏目参数传入错误');history.go(-1);</script>";
	}
if(!is_numeric($lm_imgw)){
	 echo "<script>alert('图片宽度参数传入错误');history.go(-1);</script>";
	}
if(!is_numeric($lm_imgh)){
	 echo "<script>alert('图片高度参数传入错误');history.go(-1);</script>";
	}
	if(!is_numeric($lm_dj)){
	 echo "<script>alert('单价参数传入错误');history.go(-1);</script>";
	}
	if(!is_numeric($lm_numeric)){
	 echo "<script>alert('可售数量参数传入错误');history.go(-1);</script>";
	}
switch($atype){
  case "add":
  if($lm_type=="0"){
	 echo "<script>alert('顶级栏目不允许发布信息');history.go(-1);</script>";
	 break;  
	}else{
    $sqlstr="insert into limao_shop(lm_title,lm_source,lm_writer,lm_type,lm_img,lm_imgw,lm_imgh,lm_keywords,lm_des,lm_body,lm_date,lm_buyurl,lm_dw,lm_dj,lm_numeric,lm_alt) value
('".mysql_real_escape_string($lm_title)."','".mysql_real_escape_string($lm_source)."','".mysql_real_escape_string($lm_writer)."',
'".mysql_real_escape_string($lm_type)."','".mysql_real_escape_string($lm_img)."','".mysql_real_escape_string($lm_imgw)."','".mysql_real_escape_string($lm_imgh)."',
'".mysql_real_escape_string($lm_keywords)."','".mysql_real_escape_string($lm_des)."','".mysql_real_escape_string($lm_body)."',
'".mysql_real_escape_string($lm_date)."','".mysql_real_escape_string($lm_buyurl)."','".mysql_real_escape_string($lm_dw)."',
'".mysql_real_escape_string($lm_dj)."','".mysql_real_escape_string($lm_numeric)."','".mysql_real_escape_string($lm_alt)."')";
    limaors($sqlstr);
    viewmsg('商品信息发布成功！','shop_list.php');
    break;
  }
  case "edit":
  $lm_id = intval($_POST['lm_id']);
  if(!is_numeric($lm_id)){
	echo "<script>alert('传入的参数错误');history.go(-1);</script>";
　break;
	}
   if($lm_type=="0"){
	 echo "<script>alert('不能选择顶级栏目');history.go(-1);</script>";
	 break;  
	}else{
 
   $sqlstr="update limao_shop set lm_title='".mysql_real_escape_string($lm_title)."',lm_source='".mysql_real_escape_string($lm_source)."',lm_writer='".mysql_real_escape_string($lm_writer)."',
lm_type='".mysql_real_escape_string($lm_type)."',lm_img='".mysql_real_escape_string($lm_img)."',lm_imgw='".mysql_real_escape_string($lm_imgw)."',lm_imgh='".mysql_real_escape_string($lm_imgh)."',
lm_keywords='".mysql_real_escape_string($lm_keywords)."',lm_des='".mysql_real_escape_string($lm_des)."',lm_body='".mysql_real_escape_string($lm_body)."',
lm_date='".mysql_real_escape_string($lm_date)."',lm_buyurl='".mysql_real_escape_string($lm_buyurl)."',lm_dw='".mysql_real_escape_string($lm_dw)."',
lm_dj='".mysql_real_escape_string($lm_dj)."',lm_numeric='".mysql_real_escape_string($lm_numeric)."',lm_alt='".mysql_real_escape_string($lm_alt)."' where lm_id='".mysql_real_escape_string($lm_id)."'";
    limaors($sqlstr);
    viewmsg('商品信息修改成功！','shop_list.php');
 
    break;
  }
  
  
  default:
   
   
}


?>