query("insert into {$dbtbpre}enewsuserjs(jsname,jssql,jstempid,jsfilename,classid) values('$add[jsname]','".addslashes($add[jssql])."',$jstempid,'$add[jsfilename]','$add[classid]');");
$jsid=$empire->lastid();
//刷新js
$add['jsid']=$jsid;
ReUserjs($add,"../");
if($sql)
{
//操作日志
insert_dolog("jsid=$jsid&jsname=$add[jsname]");
printerror("AddUserjsSuccess","AddUserjs.php?enews=AddUserjs&classid=$cid".hReturnEcmsHashStrHref2(0));
}
else
{
printerror("DbError","history.go(-1)");
}
}
//修改用户自定义js
function EditUserjs($add,$userid,$username){
global $empire,$dbtbpre;
$cid=(int)$add['cid'];
$jsid=(int)$add['jsid'];
$jstempid=(int)$add['jstempid'];
if(!$jsid||!$add[jsname]||!$jstempid||!$add[jssql]||!$add[jsfilename])
{
printerror("EmptyUserJsname","history.go(-1)");
}
$query_first=substr($add['jssql'],0,7);
if(!($query_first=="select "||$query_first=="SELECT "))
{
printerror("JsSqlError","history.go(-1)");
}
//验证权限
CheckLevel($userid,$username,$classid,"userjs");
//删除旧js文件
if($add['oldjsfilename']<>$add['jsfilename'])
{
DelFiletext($add['oldjsfilename']);
}
$add[jssql]=ClearAddsData($add[jssql]);
$add[jsname]=hRepPostStr($add[jsname],1);
$add['classid']=(int)$add['classid'];
$add['jsfilename']=hRepPostStr($add['jsfilename'],1);
$sql=$empire->query("update {$dbtbpre}enewsuserjs set jsname='$add[jsname]',jssql='".addslashes($add[jssql])."',jstempid=$jstempid,jsfilename='$add[jsfilename]',classid='$add[classid]' where jsid='$jsid'");
//刷新js
$add['jsid']=$jsid;
ReUserjs($add,"../");
if($sql)
{
//操作日志
insert_dolog("jsid=$jsid&jsname=$add[jsname]");
printerror("EditUserjsSuccess","ListUserjs.php?classid=$cid".hReturnEcmsHashStrHref2(0));
}
else
{
printerror("DbError","history.go(-1)");
}
}
//删除用户自定义js
function DelUserjs($jsid,$userid,$username){
global $empire,$dbtbpre;
$cid=(int)$add['cid'];
$jsid=(int)$jsid;
if(!$jsid)
{
printerror("NotChangeUserjsid","history.go(-1)");
}
//验证权限
CheckLevel($userid,$username,$classid,"userjs");
$r=$empire->fetch1("select jsname,jsfilename from {$dbtbpre}enewsuserjs where jsid=$jsid");
$sql=$empire->query("delete from {$dbtbpre}enewsuserjs where jsid=$jsid");
//删除文件
DelFiletext("../".$r['jsfilename']);
//moreportdo
$eautodofile=str_replace('../../','',$r['jsfilename']);
if($eautodofile)
{
$eautodofname='delfile|'.$eautodofile.'||';
eAutodo_AddDo('eDelFileUserjs',0,0,0,0,0,$eautodofname);
}
if($sql)
{
//操作日志
insert_dolog("jsid=$jsid&jsname=$r[jsname]");
printerror("DelUserjsSuccess","ListUserjs.php?classid=$cid".hReturnEcmsHashStrHref2(0));
}
else
{
printerror("DbError","history.go(-1)");
}
}
//刷新自定义JS
function DoReUserjs($add,$userid,$username){
global $empire,$dbtbpre;
//操作权限
CheckLevel($userid,$username,$classid,"userjs");
$jsid=$add['jsid'];
$count=count($jsid);
if(!$count)
{
printerror("EmptyReUserjsid","history.go(-1)");
}
for($i=0;$i<$count;$i++)
{
$jsid[$i]=(int)$jsid[$i];
if(empty($jsid[$i]))
{
continue;
}
$ur=$empire->fetch1("select jsid,jsname,jssql,jstempid,jsfilename from {$dbtbpre}enewsuserjs where jsid='".$jsid[$i]."'");
ReUserjs($ur,'../');
}
//操作日志
insert_dolog("");
printerror("DoReUserjsSuccess",EcmsGetReturnUrl());
}
$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
hCheckEcmsRHash();
require("../../data/dbcache/class.php");
}
if($enews=="AddUserjs")
{
AddUserjs($_POST,$logininid,$loginin);
}
elseif($enews=="EditUserjs")
{
EditUserjs($_POST,$logininid,$loginin);
}
elseif($enews=="DelUserjs")
{
$jsid=$_GET['jsid'];
DelUserjs($jsid,$logininid,$loginin);
}
elseif($enews=="DoReUserjs")
{
DoReUserjs($_POST,$logininid,$loginin);
}
else
{}
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$line=20;//每页显示条数
$page_line=20;//每页显示链接数
$offset=$page*$line;//总偏移量
$search='';
$search.=$ecms_hashur['ehref'];
$query="select jsid,jsname,jsfilename from {$dbtbpre}enewsuserjs";
$totalquery="select count(*) as total from {$dbtbpre}enewsuserjs";
//类别
$add="";
$classid=(int)$_GET['classid'];
if($classid)
{
$add=" where classid=$classid";
$search.="&classid=$classid";
}
$query.=$add;
$totalquery.=$add;
$num=$empire->gettotal($totalquery);//取得总条数
$query=$query." order by jsid desc limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page2($num,$line,$page_line,$start,$page,$search);
//分类
$cstr="";
$csql=$empire->query("select classid,classname from {$dbtbpre}enewsuserjsclass order by classid");
while($cr=$empire->fetch($csql))
{
$select="";
if($cr[classid]==$classid)
{
$select=" selected";
}
$cstr.="";
}
?>
管理用户自定义JS
选择类别:
|
db_close();
$empire=null;
?>