<?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_img = cinput($_POST['lm_img']);
$lm_tags = cinput($_POST['lm_tags']);
$lm_keywords = cinput($_POST['lm_keywords']);
$lm_type = cinput($_POST['lm_type']);
$lm_des = cinput($_POST['lm_des']);
$lm_body = cinput($_POST['lm_body']);
$lm_date = cinput($_POST['lm_date']);
$lm_action = cinput($_POST['lm_action']);
$lm_istj = cinput($_POST['lm_istj']);
$lm_isindex = cinput($_POST['lm_isindex']);
$atype = $_POST['atype'];
if(!is_numeric($lm_type)){
	viewmsg('栏目选择错误！','add_article.php');
	}

switch($atype){
  case "add":
  if($lm_type=="0"){
	 echo "<script>alert('顶级栏目不允许发布信息');history.go(-1);</script>";
	 break;  
	}else{
    $sqlstr="insert into limao_article(lm_title,lm_source,lm_writer,lm_img,lm_tags,lm_keywords,lm_type,lm_des,lm_body,lm_date,lm_action,lm_istj,lm_isindex) value
('".mysql_real_escape_string($lm_title)."','".mysql_real_escape_string($lm_source)."','".mysql_real_escape_string($lm_writer)."','".mysql_real_escape_string($lm_img)."',
'".mysql_real_escape_string($lm_tags)."','".mysql_real_escape_string($lm_keywords)."','".mysql_real_escape_string($lm_type)."','".mysql_real_escape_string($lm_des)."',
'".mysql_real_escape_string($lm_body)."','".mysql_real_escape_string($lm_date)."','".mysql_real_escape_string($lm_action)."','".mysql_real_escape_string($lm_istj)."','".mysql_real_escape_string($lm_isindex)."')";
    limaors($sqlstr);
    viewmsg('成功发布一条信息！','list_article.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_article 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_img='".mysql_real_escape_string($lm_img)."',
lm_tags='".mysql_real_escape_string($lm_tags)."',lm_keywords='".mysql_real_escape_string($lm_keywords)."',lm_type='".mysql_real_escape_string($lm_type)."',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_action='".mysql_real_escape_string($lm_action)."',lm_istj='".mysql_real_escape_string($lm_istj)."',lm_isindex='".mysql_real_escape_string($lm_isindex)."' where lm_id='".mysql_real_escape_string($lm_id)."'";
    limaors($sqlstr);
    viewmsg('信息修改成功！','list_article.php');
    break;
  }
  
  
  default:
   
   
}


?>