query("insert into {$dbtbpre}enewspic(title,pic_url,url,pic_width,pic_height,open_pic,border,pictext,classid) values('$title','$pic_url','$url','$pic_width','$pic_height','$open_pic',$border,'$pictext',$add[classid]);");
//生成js
$picid=$empire->lastid();
GetPicJs($picid);
if($sql)
{
//操作日志
insert_dolog("picid=".$picid."
title=".$title);
printerror("AddPicNewsSuccess","AddPicNews.php?enews=AddPicNews".hReturnEcmsHashStrHref2(0));
}
else
{printerror("DbError","history.go(-1)");}
}
//生成图片信息js
function GetPicJs($picid){
global $empire,$dbtbpre;
$r=$empire->fetch1("select * from {$dbtbpre}enewspic where picid='$picid'");
$string="
".$r[title]."";
$string="document.write(\"".addslashes($string)."\");";
$filename="../../../d/js/pic/pic_".$picid.".js";
WriteFiletext_n($filename,$string);
}
//删除图片信息js
function DelPicJs($picid){
$filename="../../../d/js/pic/pic_".$picid.".js";
DelFiletext($filename);
}
//修改图片信息
function EditPicNews($add,$picid,$title,$pic_url,$url,$pic_width,$pic_height,$open_pic,$border,$pictext,$userid,$username){
global $empire,$dbtbpre;
$picid=(int)$picid;
if(!$picid||!$title||!$pic_url||!$url||!$add[classid])
{printerror("MustEnter","history.go(-1)");}
//操作权限
CheckLevel($userid,$username,$classid,"picnews");
$add[classid]=(int)$add[classid];
$border=(int)$border;
$title=hRepPostStr($title,1);
$pic_url=hRepPostStr2($pic_url);
$url=hRepPostStr2($url);
$pic_width=hRepPostStr($pic_width,1);
$pic_height=hRepPostStr($pic_height,1);
$open_pic=hRepPostStr($open_pic,1);
$pictext=hRepPostStr2($pictext);
$sql=$empire->query("update {$dbtbpre}enewspic set title='$title',pic_url='$pic_url',url='$url',pic_width='$pic_width',pic_height='$pic_height',open_pic='$open_pic',border=$border,pictext='$pictext',classid=$add[classid] where picid='$picid'");
//生成js
GetPicJs($picid);
if($sql)
{
//操作日志
insert_dolog("picid=".$picid."
title=".$title);
printerror("EditPicNewsSuccess","ListPicNews.php".hReturnEcmsHashStrHref2(1));
}
else
{printerror("DbError","history.go(-1)");}
}
//删除图片信息
function DelPicNews($picid,$userid,$username){
global $empire,$dbtbpre;
$picid=(int)$picid;
if(!$picid)
{printerror("NotDelPicnewsid","history.go(-1)");}
//操作权限
CheckLevel($userid,$username,$classid,"picnews");
$r=$empire->fetch1("select title from {$dbtbpre}enewspic where picid='$picid'");
$sql=$empire->query("delete from {$dbtbpre}enewspic where picid='$picid'");
//删除图片js
DelPicJs($picid);
if($sql)
{
//操作日志
insert_dolog("picid=".$picid."
title=".$r[title]);
printerror("DelPicNewsSuccess","ListPicNews.php".hReturnEcmsHashStrHref2(1));
}
else
{printerror("DbError","history.go(-1)");}
}
//批量删除图片信息
function DelPicNews_all($picid,$userid,$username){
global $empire,$dbtbpre;
//操作权限
CheckLevel($userid,$username,$classid,"picnews");
$count=count($picid);
if(!$count)
{printerror("NotDelPicnewsid","history.go(-1)");}
for($i=0;$i<$count;$i++)
{
$picid[$i]=(int)$picid[$i];
$add.="picid='$picid[$i]' or ";
//删除图片js
DelPicJs($picid[$i]);
}
$add=substr($add,0,strlen($add)-4);
$sql=$empire->query("delete from {$dbtbpre}enewspic where ".$add);
if($sql)
{
//操作日志
insert_dolog("");
printerror("DelPicNewsSuccess","ListPicNews.php".hReturnEcmsHashStrHref2(1));
}
else
{
printerror("DbError","history.go(-1)");
}
}
$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
hCheckEcmsRHash();
}
//增加图片新闻
if($enews=="AddPicNews")
{
$add=$_POST['add'];
$title=$_POST['title'];
$pic_url=$_POST['pic_url'];
$url=$_POST['url'];
$pic_width=$_POST['pic_width'];
$pic_height=$_POST['pic_height'];
$open_pic=$_POST['open_pic'];
$border=$_POST['border'];
$pictext=$_POST['pictext'];
AddPicNews($add,$title,$pic_url,$url,$pic_width,$pic_height,$open_pic,$border,$pictext,$logininid,$loginin);
}
//修改图片新闻
elseif($enews=="EditPicNews")
{
$add=$_POST['add'];
$picid=$_POST['picid'];
$title=$_POST['title'];
$pic_url=$_POST['pic_url'];
$url=$_POST['url'];
$pic_width=$_POST['pic_width'];
$pic_height=$_POST['pic_height'];
$open_pic=$_POST['open_pic'];
$border=$_POST['border'];
$pictext=$_POST['pictext'];
EditPicNews($add,$picid,$title,$pic_url,$url,$pic_width,$pic_height,$open_pic,$border,$pictext,$logininid,$loginin);
}
//删除图片新闻
elseif($enews=="DelPicNews")
{
$picid=$_GET['picid'];
DelPicNews($picid,$logininid,$loginin);
}
//批量删除图片新闻
elseif($enews=="DelPicNews_all")
{
$picid=$_POST['picid'];
DelPicNews_all($picid,$logininid,$loginin);
}
$start=0;
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$add="";
$search="";
$search.=$ecms_hashur['ehref'];
$classid=(int)$_GET['classid'];
if($classid)
{
$add=" where classid='$classid'";
$search.="&classid=$classid";
}
$line=10;//每行显示
$page_line=15;
$offset=$page*$line;
$totalquery="select count(*) as total from {$dbtbpre}enewspic".$add;
$num=$empire->gettotal($totalquery);//取得总条数
$query="select picid,title,pic_url,url,pic_width,pic_height,open_pic,border,pictext from {$dbtbpre}enewspic".$add;
$query.=" order by picid desc limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page2($num,$line,$page_line,$start,$page,$search);
//图片类别
$csql=$empire->query("select classid,classname from {$dbtbpre}enewspicclass order by classid");
while($cr=$empire->fetch($csql))
{
if($classid==$cr[classid])
{$select=" selected";}
else
{$select="";}
$class.="";
}
?>
管理图片信息
分类:
|
db_close();
$empire=null;
?>