fetch1("select spid,spname,varname,sptype,maxnum,groupid,userclass,username from {$dbtbpre}enewssp where spid='$spid'");
if(!$spr['spid'])
{
printerror('ErrorUrl','');
}
//验证操作权限
CheckDoLevel($lur,$spr[groupid],$spr[userclass],$spr[username]);
return $spr;
}
//增加碎片信息
function AddSpInfo($add,$userid,$username){
global $empire,$dbtbpre;
$spid=(int)$add[spid];
if(!$spid)
{
printerror('ErrorUrl','');
}
//验证
$spr=CheckSpInfoLevel($spid);
if($spr[sptype]==1)//静态碎片
{
$log=AddSpInfo1($spid,$spr,$add);
}
elseif($spr[sptype]==2)//动态碎片
{
$log=AddSpInfo2($spid,$spr,$add);
}
else
{
printerror('ErrorUrl','');
}
//删除多余碎片信息
DelMoreSpInfo($spid,$spr);
//更新附件
UpdateTheFileEditOther(7,$spid,'other');
//操作日志
insert_dolog($log);
printerror("AddSpInfoSuccess","AddSpInfo.php?enews=AddSpInfo&spid=$spid".hReturnEcmsHashStrHref2(0));
}
//导入碎片信息
function LoadInSpInfo($add,$userid,$username){
global $empire,$dbtbpre,$class_r,$emod_r,$etable_r;
$spid=(int)$add[spid];
if(!$spid)
{
printerror('ErrorUrl','');
}
//验证
$spr=CheckSpInfoLevel($spid);
$tbname=RepPostVar($add['tbname']);
$infoids=$add['infoids'];
if(!$tbname||!$infoids)
{
printerror('ErrorUrl','');
}
$tbr=$empire->fetch1("select tbname from {$dbtbpre}enewstable where tbname='$tbname' limit 1");
if(!$tbr['tbname'])
{
printerror('ErrorUrl','');
}
//简介字段
$mid=$etable_r[$tbname]['mid'];
$smalltextf=$emod_r[$mid]['smalltextf'];
$sf='';
if($smalltextf&&$smalltextf<>',')
{
$smr=explode(',',$smalltextf);
$sf=$smr[1];
}
$addf='';
if($sf&&!strstr($emod_r[$mid]['tbdataf'],','.$sf.','))
{
$addf=','.$sf;
}
//导入
$infor=explode(',',$infoids);
$count=count($infor);
for($i=0;$i<$count;$i++)
{
$infoid=(int)$infor[$i];
if(!$infoid)
{
continue;
}
$r=$empire->fetch1("select id,classid,isurl,titleurl,newstime,titlepic,title,stb".$addf." from {$dbtbpre}ecms_".$tbname." where id='$infoid' limit 1");
if(!$r['id'])
{
continue;
}
if($sf&&!$addf)
{
$finfor=$empire->fetch1("select ".$sf." from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='$infoid' limit 1");
$r['smalltext']=$finfor[$sf];
}
else
{
$r['smalltext']=$r[$sf];
}
$r['newstime']=date("Y-m-d H:i:s",$r['newstime']);
if($spr[sptype]==1)//静态碎片
{
$log=AddSpInfo1($spid,$spr,$r);
}
elseif($spr[sptype]==2)//动态碎片
{
$log=AddSpInfo2($spid,$spr,$r,1);
}
else
{
printerror('ErrorUrl','');
}
}
//删除多余碎片信息
DelMoreSpInfo($spid,$spr);
//操作日志
insert_dolog("tbname=$tbname
id=$infoids");
printerror("LoadInSpInfoSuccess","ListSpInfo.php?spid=$spid".hReturnEcmsHashStrHref2(0));
}
//增加静态碎片信息
function AddSpInfo1($spid,$spr,$add){
global $empire,$dbtbpre;
$add['title']=eDoRepPostComStr($add['title'],1);
$add['titlepic']=eDoRepPostComStr($add['titlepic'],1);
$add['titleurl']=eDoRepPostComStr($add['titleurl'],1);
$titlefont=TitleFont($add[titlefont],$add[titlecolor]);
$newstime=$add[newstime]?to_time($add[newstime]):time();
$sql=$empire->query("insert into {$dbtbpre}enewssp_1(spid,title,titlepic,bigpic,titleurl,smalltext,titlefont,newstime,titlepre,titlenext) values('$spid','".eaddslashes2($add[title])."','".eaddslashes2($add[titlepic])."','".eaddslashes2($add[bigpic])."','".eaddslashes2($add[titleurl])."','".eaddslashes2($add[smalltext])."','".eaddslashes2($titlefont)."','$newstime','".eaddslashes2($add[titlepre])."','".eaddslashes2($add[titlenext])."');");
$sid=$empire->lastid();
$log="spid=$spid&sid=$sid&title=$add[title]";
return $log;
}
//增加动态碎片信息
function AddSpInfo2($spid,$spr,$add,$ecms=0){
global $empire,$dbtbpre,$class_r;
$add[classid]=(int)$add[classid];
$add[id]=(int)$add[id];
if(empty($class_r[$add[classid]][tbname]))
{
if($ecms==1)
{
return '';
}
else
{
printerror('HaveNotInfo','');
}
}
$infor=$empire->fetch1("select id,classid,newstime from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]."_index where id='$add[id]'");
if(!$infor[id]||$infor[classid]!=$add[classid])
{
if($ecms==1)
{
return '';
}
else
{
printerror('HaveNotInfo','');
}
}
$newstime=$add[newstime]?to_time($add[newstime]):$infor[newstime];
//是否重复
$rer=$empire->fetch1("select sid from {$dbtbpre}enewssp_2 where spid='$spid' and id='$add[id]' and classid='$add[classid]' limit 1");
if($rer['sid'])
{
if($ecms==1)
{
return '';
}
else
{
printerror('HaveSpInfo','');
}
}
$sql=$empire->query("insert into {$dbtbpre}enewssp_2(spid,classid,id,newstime) values('$spid','$add[classid]','$add[id]','$newstime');");
$sid=$empire->lastid();
$log="spid=$spid&sid=$sid&classid=$add[classid]&id=$add[id]";
return $log;
}
//删除多余碎片信息
function DelMoreSpInfo($spid,$spr){
global $empire,$dbtbpre;
if(!$spr[maxnum]||$spr[sptype]==3)
{
return '';
}
if($spr[sptype]==1)
{
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewssp_1 where spid='$spid'");
if($num>$spr[maxnum])
{
$limitnum=$num-$spr[maxnum];
$ids='';
$dh='';
$sql=$empire->query("select sid from {$dbtbpre}enewssp_1 where spid='$spid' order by sid limit ".$limitnum);
while($r=$empire->fetch($sql))
{
$ids.=$dh.$r['sid'];
$dh=',';
}
$empire->query("delete from {$dbtbpre}enewssp_1 where sid in ($ids)");
}
}
elseif($spr[sptype]==2)
{
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewssp_2 where spid='$spid'");
if($num>$spr[maxnum])
{
$limitnum=$num-$spr[maxnum];
$ids='';
$dh='';
$sql=$empire->query("select sid from {$dbtbpre}enewssp_2 where spid='$spid' order by sid limit ".$limitnum);
while($r=$empire->fetch($sql))
{
$ids.=$dh.$r['sid'];
$dh=',';
}
$empire->query("delete from {$dbtbpre}enewssp_2 where sid in ($ids)");
}
}
}
//修改碎片信息
function EditSpInfo($add,$userid,$username){
global $empire,$dbtbpre;
$spid=(int)$add[spid];
$sid=(int)$add['sid'];
if(!$spid)
{
printerror('ErrorUrl','');
}
//验证
$spr=CheckSpInfoLevel($spid);
if($spr[sptype]==1)//静态碎片
{
$log=EditSpInfo1($spid,$spr,$sid,$add);
}
elseif($spr[sptype]==2)//动态碎片
{
$log=EditSpInfo2($spid,$spr,$sid,$add);
}
elseif($spr[sptype]==3)//代码碎片
{
$log=EditSpInfo3($spid,$spr,$sid,$add);
}
else
{
printerror('ErrorUrl','');
}
//删除多余碎片信息
DelMoreSpInfo($spid,$spr);
//更新附件
UpdateTheFileEditOther(7,$spid,'other');
//操作日志
insert_dolog($log);
printerror("EditSpInfoSuccess","ListSpInfo.php?spid=$spid".hReturnEcmsHashStrHref2(0));
}
//修改静态碎片信息
function EditSpInfo1($spid,$spr,$sid,$add){
global $empire,$dbtbpre;
if(!$sid)
{
printerror('ErrorUrl','');
}
$checknum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewssp_1 where sid='$sid' and spid='$spid'");
if(!$checknum)
{
printerror('ErrorUrl','');
}
$add['title']=eDoRepPostComStr($add['title'],1);
$add['titlepic']=eDoRepPostComStr($add['titlepic'],1);
$add['titleurl']=eDoRepPostComStr($add['titleurl'],1);
$titlefont=TitleFont($add[titlefont],$add[titlecolor]);
$newstime=$add[newstime]?to_time($add[newstime]):time();
$empire->query("update {$dbtbpre}enewssp_1 set title='".eaddslashes2($add[title])."',titlepic='".eaddslashes2($add[titlepic])."',bigpic='".eaddslashes2($add[bigpic])."',titleurl='".eaddslashes2($add[titleurl])."',smalltext='".eaddslashes2($add[smalltext])."',titlefont='".eaddslashes2($titlefont)."',newstime='$newstime',titlepre='".eaddslashes2($add[titlepre])."',titlenext='".eaddslashes2($add[titlenext])."' where sid='$sid' and spid='$spid'");
$log="spid=$spid&sid=$sid&title=$add[title]";
return $log;
}
//修改动态碎片信息
function EditSpInfo2($spid,$spr,$sid,$add){
global $empire,$dbtbpre,$class_r;
if(!$sid)
{
printerror('ErrorUrl','');
}
$checknum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewssp_2 where sid='$sid' and spid='$spid'");
if(!$checknum)
{
printerror('ErrorUrl','');
}
$add[classid]=(int)$add[classid];
$add[id]=(int)$add[id];
if(empty($class_r[$add[classid]][tbname]))
{
printerror('HaveNotInfo','');
}
$infor=$empire->fetch1("select id,classid,newstime from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]."_index where id='$add[id]'");
if(!$infor[id]||$infor[classid]!=$add[classid])
{
printerror('HaveNotInfo','');
}
$newstime=$add[newstime]?to_time($add[newstime]):$infor[newstime];
//是否重复
$rer=$empire->fetch1("select sid from {$dbtbpre}enewssp_2 where spid='$spid' and id='$add[id]' and classid='$add[classid]' and sid<>$sid limit 1");
if($rer['sid'])
{
printerror('HaveSpInfo','');
}
$empire->query("update {$dbtbpre}enewssp_2 set classid='$add[classid]',id='$add[id]',newstime='$newstime' where sid='$sid' and spid='$spid'");
$log="spid=$spid&sid=$sid&classid=$add[classid]&id=$add[id]";
return $log;
}
//修改代码碎片信息
function EditSpInfo3($spid,$spr,$sid,$add){
global $empire,$dbtbpre;
$r=$empire->fetch1("select sid from {$dbtbpre}enewssp_3 where spid='$spid'");
if($r['sid'])
{
$empire->query("update {$dbtbpre}enewssp_3 set sptext='".eaddslashes2($add[sptext])."' where spid='$spid'");
$sid=$r['sid'];
}
else
{
$empire->query("insert into {$dbtbpre}enewssp_3(spid,sptext) values('$spid','".eaddslashes2($add[sptext])."');");
$sid=$empire->lastid();
}
//备份
EditSpInfo3_bak($spid,$sid,$add[sptext]);
$log="spid=$spid&sid=$sid&sptype=3";
return $log;
}
//备份代码碎片信息
function EditSpInfo3_bak($spid,$sid,$sptext){
global $empire,$dbtbpre,$lur;
$baknum=10; //备份最大数量
$username=$lur[username];
$time=time();
$empire->query("insert into {$dbtbpre}enewssp_3_bak(sid,spid,sptext,lastuser,lasttime) values('$sid','$spid','".eaddslashes2($sptext)."','$username','$time');");
//删除多余备份
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewssp_3_bak where sid='$sid'");
if($num>$baknum)
{
$limitnum=$num-$baknum;
$ids='';
$dh='';
$sql=$empire->query("select bid from {$dbtbpre}enewssp_3_bak where sid='$sid' order by bid limit ".$limitnum);
while($r=$empire->fetch($sql))
{
$ids.=$dh.$r[bid];
$dh=',';
}
$empire->query("delete from {$dbtbpre}enewssp_3_bak where bid in ($ids)");
}
}
//还原碎片信息记录
function SpInfoReBak($add,$userid,$username){
global $empire,$dbtbpre;
$spid=(int)$add[spid];
$sid=(int)$add['sid'];
$bid=(int)$add[bid];
if(!$spid||!$sid||!$bid)
{
printerror('ErrorUrl','');
}
//验证
$spr=CheckSpInfoLevel($spid);
if($spr['sptype']!=3)
{
printerror('ErrorUrl','');
}
$br=$empire->fetch1("select bid,sptext from {$dbtbpre}enewssp_3_bak where bid='$bid' and sid='$sid' and spid='$spid'");
if(!$br['bid'])
{
printerror('ErrorUrl','');
}
$sql=$empire->query("update {$dbtbpre}enewssp_3 set sptext='".StripAddsData($br[sptext])."' where sid='$sid'");
if($sql)
{
//操作日志
insert_dolog("spid=".$spid."&spname=".$spr[spname]."
sid=$sid&bid=$bid");
echo"";
exit();
}
else
{printerror("DbError","history.go(-1)");}
}
//删除碎片信息
function DelSpInfo($add,$userid,$username){
global $empire,$dbtbpre;
$spid=(int)$add[spid];
$sid=(int)$add['sid'];
if(!$spid||!$sid)
{
printerror('ErrorUrl','');
}
//验证
$spr=CheckSpInfoLevel($spid);
if($spr[sptype]==1)//静态碎片
{
$r=$empire->fetch1("select sid,title from {$dbtbpre}enewssp_1 where sid='$sid' and spid='$spid'");
if(!$r['sid'])
{
printerror('ErrorUrl','');
}
$empire->query("delete from {$dbtbpre}enewssp_1 where sid='$sid' and spid='$spid'");
$log="spid=$spid&sid=$sid&title=$r[title]";
}
elseif($spr[sptype]==2)//动态碎片
{
$r=$empire->fetch1("select sid,classid,id from {$dbtbpre}enewssp_2 where sid='$sid' and spid='$spid'");
if(!$r['sid'])
{
printerror('ErrorUrl','');
}
$empire->query("delete from {$dbtbpre}enewssp_2 where sid='$sid' and spid='$spid'");
$log="spid=$spid&sid=$sid&classid=$r[classid]&id=$r[id]";
}
else
{
printerror('ErrorUrl','');
}
//操作日志
insert_dolog($log);
printerror("DelSpInfoSuccess","ListSpInfo.php?spid=$spid".hReturnEcmsHashStrHref2(0));
}
//批量修改碎片发布时间
function EditSpInfoTime($add,$userid,$username){
global $empire,$dbtbpre;
$spid=(int)$add[spid];
$sid=$add['sid'];
$newstime=$add[newstime];
if(!$spid)
{
printerror('ErrorUrl','');
}
$count=count($sid);
if(!$count)
{
printerror('EmptySpInfoTime','');
}
//验证
$spr=CheckSpInfoLevel($spid);
if($spr[sptype]==1)//静态碎片
{
for($i=0;$i<$count;$i++)
{
$dosid=(int)$sid[$i];
$donewstime=$newstime[$i]?to_time($newstime[$i]):time();
$empire->query("update {$dbtbpre}enewssp_1 set newstime='$donewstime' where sid='$dosid' and spid='$spid'");
}
}
elseif($spr[sptype]==2)//动态碎片
{
for($i=0;$i<$count;$i++)
{
$dosid=(int)$sid[$i];
$donewstime=$newstime[$i]?to_time($newstime[$i]):time();
$empire->query("update {$dbtbpre}enewssp_2 set newstime='$donewstime' where sid='$dosid' and spid='$spid'");
}
}
else
{
printerror('ErrorUrl','');
}
//操作日志
insert_dolog("spid=$spid");
printerror("EditSpInfoTimeSuccess","ListSpInfo.php?spid=$spid".hReturnEcmsHashStrHref2(0));
}
$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
hCheckEcmsRHash();
}
if($enews=="AddSpInfo")//增加碎片信息
{
AddSpInfo($_POST,$logininid,$loginin);
}
elseif($enews=="EditSpInfo")//修改碎片信息
{
EditSpInfo($_POST,$logininid,$loginin);
}
elseif($enews=="DelSpInfo")//删除碎片信息
{
DelSpInfo($_GET,$logininid,$loginin);
}
elseif($enews=="SpInfoReBak")//还原碎片信息记录
{
SpInfoReBak($_GET,$logininid,$loginin);
}
elseif($enews=="EditSpInfoTime")//批量修改碎片信息时间
{
EditSpInfoTime($_POST,$logininid,$loginin);
}
elseif($enews=="LoadInSpInfo")//批量导入碎片信息
{
LoadInSpInfo($_GET,$logininid,$loginin);
}
$spid=(int)$_GET['spid'];
//碎片
$spr=CheckSpInfoLevel($spid);
//代码碎片
if($spr[sptype]==3)
{
Header("Location:AddSpInfo.php?enews=EditSpInfo&spid=$spid".$ecms_hashur['ehref']);
exit();
}
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$line=50;//每页显示条数
$page_line=12;//每页显示链接数
$offset=$page*$line;//总偏移量
$search="&spid=$spid".$ecms_hashur['ehref'];
$url="更新碎片 > ".$spr[spname]." > 管理碎片信息";
?>
碎片
gettotal($totalquery);//取得总条数
$query=$query." order by newstime desc limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page2($num,$line,$page_line,$start,$page,$search);
?>
说明:信息是按发布时间排序,如果要改顺序可以修改发布时间,发布时间设置空则改为当前时间。 |
gettotal($totalquery);//取得总条数
$query=$query." order by newstime desc limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page2($num,$line,$page_line,$start,$page,$search);
?>
说明:信息是按发布时间排序,如果要改顺序可以修改发布时间,发布时间设置空则改为当前时间。 |
db_close();
$empire=null;
?>