vBulletin 2.0 HACK----首页的新闻报道HACK++




原因:vBulletin 2.0还是没有自带,而这个功能在1.1.x下使用有不少的拥趸,所以就升级到2.0来。
优点:管理员、版主均可通过控制面板管理新闻;管理员可以在控制面板选择哪个版主有权发表新闻(很智能化),而且可以编辑或删除版主所发表的新闻;而版主则只能处理自己发表的新闻,而无权管理管理员或其他版主的;仍旧支持IE、NN两个最主流浏览器,幻影式变换;仍旧不需要修改原数据库结构,也不增加数据表。
缺点:仍旧占了首页的显示地方。
自评:上一个版本只能由管理员控制,现在因为2.0增加了版主控制面板,于是也给予版主这个权力。第一个"+"是表示升级到2.0后能由版主发表新闻,第二个"+"是表示管理员可以决定哪个版主有这样的权力。不要以为我不用动脑袋,事实上这个版本比起以前虽然在用户看来没有任何分别,但在管理方面却方便了很很的多。
注意:即使您曾经用过1.1.x的HACK,也应该看清楚下面的代码,除了JS文件外,都有很大的改动。
范例:http://gogosoft.oso.com.cn/ (其实用户看上去和旧版本一样)

步骤:
[用户显示部分]
⒈打开 index.php ,在适当位置,例如第6行的“
$permissions=getpermissions();
if (!$permissions['canview']) {
    show_nopermission();
}
”后面加入“
  // Hack newsfade
  $newsfadebits = "";
  if ($newsfades=$DB_site->query("SELECT title,pagetext FROM announcement WHERE enddate>=$datenow AND forumid=0 ORDER BY startdate DESC")) {
    while ($newsfade=$DB_site->fetch_array($newsfades)) {
      $newsfadebits.="\"".addslashes($newsfade[pagetext])."\",\"$newsfade[title]\",\n";
    }
  }
  if ($newsfadebits=="") {
    $newsfadebits = "\"今天无新闻\",\"\",\n";
  }
  $newsfadebits = substr($newsfadebits,0,-2);
  // End Hack newsfade
”,保存退出。

⒉将以下内容粘贴为新文件 fade.js :“
   FDRboxWid = 600;
   FDRboxHgt = 30;
   FDRborWid = 0;
   FDRborCol = "#070707";
   FDRborSty = "solid";
   FDRbackCol = "#f7f7f7";
   FDRboxPad = 4;

   FDRtxtAln = "center";
   FDRlinHgt = "25pt";
   FDRfntFam = "Verdana,Arial,Helvetica,sans-serif,宋体";
   FDRfntCol = "#000080";
   FDRfntSiz = "20pt";
   FDRfntWgh = "";
   FDRfntSty = "normal";
   FDRlnkCol = "#000080";
   FDRlnkDec = "underline";
   FDRhovCol = "#2f2f4f";

   FDRgifSrc = "images/fade.gif";
   FDRgifInt = 60;

   FDRblendInt = 6;
   FDRblendDur = 1;
   FDRmaxLoops = 100;

   FDRendWithFirst = true;
   FDRreplayOnClick = true;
   
   FDRjustFlip = false;
   FDRhdlineCount = 0;

NS4 = (document.layers);
IE4 = (document.all);

appVer = navigator.appVersion;
IEmac = (IE4 && appVer.indexOf("Mac") != -1);
IE4mac = (IEmac && appVer.indexOf("MSIE 4") != -1);
IE40mac = (IE4mac && appVer.indexOf("4.0;") != -1);
IE45mac = (IE4mac && appVer.indexOf("4.5;") != -1);
NSpre401 = (NS4 && (parseFloat(appVer) <= 4.01));
NSpre403 = (NS4 && (parseFloat(appVer) <= 4.03));

FDRjustFlip = (window.FDRjustFlip) ? FDRjustFlip : false;
FDRhdlineCount = (window.FDRhdlineCount) ? FDRhdlineCount : 1;

FDRfinite = (FDRmaxLoops > 0);
FDRisOver = false;
FDRloadCount = 0;

blendTimer = null;

if (!window.prefix) prefix = "";
window.onload = FDRcountLoads;

if (NS4) {
    if(FDRjustFlip || NSpre403) {
        totalLoads = 1;
        FDRfadeImg = new Object();
        FDRfadeImg.width = FDRboxWid - (FDRborWid*2);;
    }
    else {
        totalLoads = 2;
        FDRfadeImg = new Image();
        FDRfadeImg.onload = FDRcountLoads;
        FDRfadeImg.onerror = FDRcountLoads;
        FDRfadeImg.src = FDRgifSrc;
    }
}

function FDRcountLoads(e) {
    if (IE4) {
        setTimeout("FDRinit()",1);
    }
    else {
        if(e.type == "error") FDRjustFlip = true; 
        FDRloadCount++;
        if (FDRloadCount==totalLoads) {
            origWidth = innerWidth;
            origHeight = innerHeight;
            window.onresize = function(){
                if (innerWidth==origWidth && innerHeight==origHeight) return;
                location.reload();
            }
            FDRinit();
        }
    }
}

function FDRinit(){
    if(!window.arNews) {
        if(!window.arTXT || !window.arURL) return;
        if(arTXT.length != arURL.length) return;
        arNews = [];
        for (i=0;i<arTXT.length;i++){
            arNews[arNews.length] = arTXT[i];
            arNews[arNews.length] = arURL[i];
        }
    }

    if (NS4) {
        if (!document.elFader) return;
        with(document.classes.newslink.A) {
            textDecoration = FDRlnkDec;
            color = FDRlnkCol;
            fontWeight = FDRfntWgh;
            fontSize = FDRfntSiz;
            fontStyle = FDRfntSty;
            fontFamily = FDRfntFam;
            lineHeight = FDRlinHgt;
            textAlign = FDRtxtAln;
        }
        with(document.classes.nolink.P) {
            color = FDRfntCol;
            fontWeight = FDRfntWgh;
            fontSize = FDRfntSiz;
            fontStyle = FDRfntSty;
            fontFamily = FDRfntFam;
            lineHeight = FDRlinHgt;
            textAlign = FDRtxtAln;
        }
        elFader = document.elFader;
        with (elFader) {
            document.write(" ");
            document.close();
            bgColor = FDRborCol;
            clip.width = FDRboxWid;
            clip.height = FDRboxHgt;
        }

        contWidth = FDRboxWid - (FDRborWid*2);
        contHeight = FDRboxHgt - (FDRborWid*2);
        elCont = new Layer(contWidth,elFader);
        with (elCont) {
            top = FDRborWid;
            left = FDRborWid;
            clip.width = contWidth;
            clip.height = contHeight;
            bgColor = FDRbackCol;
            visibility = "inherit";
        }

        newsWidth = contWidth - (FDRboxPad*2);
        newsHeight = contHeight - (FDRboxPad*2);
        elNews = new Layer(newsWidth,elCont);
        with (elNews) {
            top = FDRboxPad;
            left = FDRboxPad;
            clip.width = newsWidth ;
            clip.height = newsHeight;
        }

        if (!FDRjustFlip) {
            elGif = new Layer(contWidth,elCont); 
            imStr = "<IMG SRC='" + FDRgifSrc +"' WIDTH="+ Math.max(FDRfadeImg.width,(FDRboxWid - (FDRborWid*2)));
            imStr += (NSpre403) ? " onError='window.FDRjustFlip = true'>" : ">";
            with (elGif) {
                document.write(imStr);
                document.close();
                moveAbove(elNews);
            }
    
            imgHeight = elGif.document.height;
            slideInc = (imgHeight/(FDRblendDur*1000/FDRgifInt));
            startTop = -(imgHeight - FDRboxHgt);
        }

        elFader.visibility =  "show";
    }
    else {
        if (!window.elFader) return;
        elFader.innerHTML ="";
        if(IE4mac) {
            document.body.insertAdjacentHTML("BeforeBegin","<STYLE></STYLE>");
        }
        else {
            if (!document.styleSheets.length) document.createStyleSheet();
        }
        with (document.styleSheets(document.styleSheets.length-1)) {
            addRule("A.newslink","text-decoration:"+FDRlnkDec+";color:"+ FDRlnkCol);
            addRule("A.newslink:hover","color:"+ FDRhovCol);
        }

        with (elFader.style) {
            errorOffset = (IE4mac) ? (FDRboxPad + FDRborWid) : 0;
            width = FDRboxWid - (errorOffset * 2);
            height = FDRboxHgt - (errorOffset * 2);
            if(IE4mac && !IE45mac){
                pixelLeft = elFader.offsetLeft + errorOffset;
                pixelTop = elFader.offsetTop + errorOffset;
            }

            backgroundColor = FDRbackCol;
            overflow = "hidden";
            color = FDRfntCol;
            fontWeight = FDRfntWgh;
            fontSize = FDRfntSiz;
            fontStyle = FDRfntSty;
            fontFamily = FDRfntFam;
            lineHeight = FDRlinHgt;
            textAlign = FDRtxtAln;
            cursor = "default";
            visibility = "visible";
            borderWidth = FDRborWid;
            borderStyle = FDRborSty;
            borderColor = FDRborCol;
            padding  = FDRboxPad;

            if(!FDRjustFlip) filter = "blendTrans(duration=" + FDRblendDur + ")";
        }
        elFader.onselectstart = function(){return false};

        IEhasFilters = (elFader.filters.blendTrans) ? true : false;

    }

    if (!NSpre401) {
        elFader.onmouseover = function (){
            FDRisOver = true;
        }
        elFader.onmouseout = function(){
            FDRisOver = false;
            status = "";
        }
    }
    
    FDRstart(0);
}

function FDRstart(ind){
    newsCount = ind;
    if (FDRfinite) loopCount = 0;
    FDRdo();
    blendTimer = setInterval("FDRdo()",FDRblendInt*1000)
}

function FDRdo() {
    if(!blendTimer && loopCount>0) return;

    if (FDRfinite && loopCount==FDRmaxLoops) {
        FDRend();
        return;
    }
    FDRfade();

    if (newsCount == arNews.length) {
        newsCount = 0;
        if (FDRfinite) loopCount++;
    }
}

function FDRmakeStr(){
    tempStr = "";
    for (i=0;i<FDRhdlineCount;i++){
        if(newsCount>=arNews.length)break;
        dispStr = arNews[newsCount];
        linkStr = arNews[newsCount+1];
        isLink = linkStr.length;
        if (isLink) {
            tempStr += "<P><A CLASS=newslink "
                    + "HREF='" + prefix + linkStr + "'>"
                    + dispStr + "</A></P>"
        }
        else {
            tempStr += ((NS4) ? "<P CLASS=nolink>" : "<P>") +dispStr+"</P>";

        }
        if(IE40mac) tempStr +="<BR>";
        newsCount += 2;
    }
    return tempStr;
}

function FDRfade(){
    newsStr = FDRmakeStr();

    if (NS4) {
        if (!FDRjustFlip) {
            elGif.top = startTop;
            elGif.visibility = "inherit";
        }

        elNews.visibility = "hide";
        with (elNews.document) {
            write(newsStr);
            close();
        }
        elNews.visibility = "inherit";
    }
    else {
        if(IEhasFilters)elFader.filters.blendTrans.Apply();
        elFader.innerHTML = newsStr;
        if(IEhasFilters)elFader.filters.blendTrans.Play();
    }

    if(FDRhdlineCount==1) window.status = (FDRisOver && isLink) ? (prefix + linkStr) : "";

    if (NS4 && !FDRjustFlip) FDRslide();
}

function FDRslide(){
    elGif.top += slideInc;
    if (elGif.top >= 0) {elGif.visibility = "hide";return}
    setTimeout("FDRslide()",FDRgifInt);
}

function FDRdblClickNS(){
    elFader.releaseEvents(Event.DBLCLICK);
    FDRstart(startIndex);
    return false;
}

function FDRend(){
    clearInterval(blendTimer);

    blendTimer = null;

    if (FDRendWithFirst) {
        newsCount = 0;
        FDRfade();
    }
    if (FDRreplayOnClick) {

        startIndex = FDRendWithFirst ? (FDRhdlineCount * 2) : 0;
        if (IE4) {
            elFader.title = "Double click to replay";
            elFader.ondblclick = function(){
                this.ondblclick = null;
                this.title = "";
                FDRstart(startIndex);
            }
        }
        else {
            elFader.captureEvents(Event.DBLCLICK);

            elFader.ondblclick = FDRdblClickNS;

        }
    }
}
”,并且建立一半透明GIF文件 fade.gif(例如 http://gogosoft.oso.com.cn/forum/images/fade.gif),上载到 images 目录下,以用于NN模仿淡出淡入的效果。

⒊在《控制面板》编辑模板 forumhome ,查找“
$headinclude
”,在后面加入“
<SCRIPT LANGUAGE='JavaScript1.2' TYPE='text/javascript'>
prefix="";
arNews = [
$newsfadebits
]
</SCRIPT>
<SCRIPT LANGUAGE='JavaScript1.2' SRC='fader.js' TYPE='text/javascript'></script>
”,查找“
<tr bgcolor="{tableheadbgcolor}">
<TD>&nbsp;</TD>
<td valign=bottom>
<smallfont COLOR="{tableheadtextcolor}"><B>论坛</B></smallfont>
</td>
<td NOWRAP valign=bottom align=center>
<b><smallfont COLOR="{tableheadtextcolor}">贴数</smallfont></B>
</td>
<td NOWRAP valign=bottom align=center>
<b><smallfont COLOR="{tableheadtextcolor}">话题</smallfont></B>
</td>
<td NOWRAP valign=bottom align=center>
<smallfont COLOR="{tableheadtextcolor}"><B>最新发表</B></smallfont>
</td>
<td valign=bottom>
<smallfont COLOR="{tableheadtextcolor}"><B>版主</B></smallfont>
</td></tr>
”,在前面加入“
<TR bgcolor="{categorybackcolor}" id=cat><TD colspan=6>
<normalfont color="{categoryfontcolor}"><B>论坛新闻</B></normalfont></td>
</tr>
<tr><td colspan=6 bgcolor="#f7f7f7" height=30 valign="top" align="center">
<div id="elFader" style="position:relative;visibility:hidden;width:500"><div align="center">论坛新闻</div></div>
</td></tr>
”,保存。


[管理员部分]
⒈打开 admin/index.php ,查找“
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#3F3849"><td><font color="#BCB6CD">
<b>公告</b>
</font></td></tr></table>
<a href="announcement.php?s=<?php echo $session[sessionhash]; ?>&action=add"> 增加 </a> |
<a href="announcement.php?s=<?php echo $session[sessionhash]; ?>&action=modify"> 修改 </a>
</td></tr>
”,在后面加入“
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#3F3849"><td><font color="#BCB6CD">
<b>新闻</b>
</font></td></tr></table>
<a href="newsfade.php?s=<?php echo $session[sessionhash]; ?>&action=add"> 增加 </a> |
<a href="newsfade.php?s=<?php echo $session[sessionhash]; ?>&action=modify"> 修改 </a>
</td></tr>
”,保存退出。


⒉将以下内容粘贴为新文件 admin/newsfade.php (与上一版本有不少区别,请留意):“
<?php

require("./global.php");

adminlog(iif($announcementid!=0,"announcement id = $announcementid",""));

cpheader();

if (isset(
$action)==0) {
  
$action="modify";
}

// ###################### Start add #######################
if ($action=="add") {

  
doformheader("newsfade","insert");

  
makeinputcode("连接 URL","title","http://");
  
makeinputcode("开始日期(格式: yyyy-mm-dd)","startdate",date("Y-m-d",time()));
  
makeinputcode("结束日期(格式: yyyy-mm-dd)","enddate",date("Y-m-d",time()+24*60*60*31));

  
makeinputcode("新闻内容(您可以使用HTML)","pagetext");

  
doformfooter();
}

// ###################### Start insert #######################
if ($action=="insert") {

  
$DB_site->query("INSERT INTO announcement(announcementid,title,userid,startdate,enddate,pagetext,forumid) VALUES (NULL,'".addslashes($title)."','$bbuserinfo[userid]',UNIX_TIMESTAMP('".addslashes($startdate)."'),UNIX_TIMESTAMP('".addslashes($enddate)."'),'".addslashes($pagetext)."',0)");

  
$action="modify";

  echo 
"<p>记录已经增加</p>";

}

// ###################### Start edit #######################
if ($action=="edit") {

  
$newsfade=$DB_site->query_first("SELECT title,userid,FROM_UNIXTIME(startdate) AS startdate,FROM_UNIXTIME(enddate) AS enddate,pagetext,forumid FROM announcement WHERE announcementid=$newsfadeid");

  
doformheader("newsfade","doupdate");
  
makehiddencode("newsfadeid","$newsfadeid");

  
makeinputcode("连接 URL","title",$newsfade[title]);

  
makeinputcode("开始日期(格式: yyyy-mm-dd)","startdate",$newsfade[startdate]);
  
makeinputcode("结束日期(格式: yyyy-mm-dd)","enddate",$newsfade[enddate]);

  
maketextareacode("新闻内容(您可以使用HTML)","pagetext",$newsfade[pagetext]);

  
doformfooter();

}

// ###################### Start do update #######################
if ($action=="doupdate") {

  
$DB_site->query("UPDATE announcement SET title='".addslashes($title)."',userid='$bbuserinfo[userid]',startdate=UNIX_TIMESTAMP('".addslashes($startdate)."'),enddate=UNIX_TIMESTAMP('".addslashes($enddate)."'),pagetext='".addslashes($pagetext)."',forumid=0 WHERE announcementid=$newsfadeid");

  echo 
"<p>记录已经更新!</p>";

  
$action="modify";

}
// ###################### Start Remove #######################

if ($action=="remove") {

  echo 
"<p>您确认要删除选择的记录吗?</p>\n";
  echo 
"<p><a href='newsfade.php?newsfadeid=$newsfadeid&action=kill'>是</a></p>";

}

// ###################### Start Kill #######################

if ($action=="kill") {

  
$DB_site->query("DELETE FROM announcement WHERE announcementid=$newsfadeid");

  
$action="modify";
}

// ###################### Start modify #######################
if ($action=="modify") {


  
$newsfades=$DB_site->query("SELECT announcementid AS newsfadeid,pagetext,FROM_UNIXTIME(startdate) AS startdate,FROM_UNIXTIME(enddate) AS enddate FROM announcement WHERE forumid=0 ORDER BY startdate");

    if (
$DB_site->num_rows($newsfades)) {
        echo 
"<table width=\"100%\" bgcolor=\"black\" border=0 cellpadding=0 cellspacing=0><tr><td>";
        echo 
"<table border=0 width=\"100%\" cellspacing=1 cellpadding=4><tr bgcolor=\"#3F3849\"><td align=\"center\" colspan=4><FONT color=\"#BCB6CD\"><b>新闻</b></FONT></td></tr>\n";
        echo 
"<tr bgcolor=\"#51485F\"><td nowrap align=\"center\" width=\"100%\"><FONT color=\"#BCB6CD\">内容</font></td><td align=\"center\" nowrap><FONT color=\"#BCB6CD\">开始日期</font></td><td align=\"center\" nowrap><FONT color=\"#BCB6CD\">结束日期</font></td><td nowrap align=\"center\"><FONT color=\"#BCB6CD\">修改</font></td></tr>\n";
        while (
$newsfade=$DB_site->fetch_array($newsfades)) {
            echo 
"<tr bgcolor=\"#CCCCCC\"><td width=\"100%\">$newsfade[pagetext]</td><td nowrap>$newsfade[startdate]</td><td nowrap>$newsfade[enddate]</td><td nowrap>".
                
makelinkcode("编辑","newsfade.php?s=$session[sessionhash]&action=edit&newsfadeid=$newsfade[newsfadeid]]").
                
makelinkcode("删除","newsfade.php?s=$session[sessionhash]&action=remove&newsfadeid=$newsfade[newsfadeid]").
                
"</td></tr>\n";
        }
        echo 
"</table></td></tr></table>\n";
    } else {
      echo 
"无新闻";
    }

}

cpfooter();

?>
”。

⒊打开 admin/forum.php ,查找“
  makeyesnocode("可以大量删减话题","canmassprune",0);
”,在后面加入“
  makeyesnocode("可以发表新闻","canpostnews",1);
”,查找“
  makeyesnocode("可以大量删减话题","canmassprune",$moderator[canmassprune]);
”,在后面加入“
  makeyesnocode("可以发表新闻","canpostnews",$moderator[canpostnews]);
”,查找(在前面)“
    $DB_site->query("INSERT INTO moderator (moderatorid,forumid,userid,newpostemail,newthreademail,caneditposts,candeleteposts,canviewips,canmanagethreads,canopenclose,caneditthreads,caneditstyles,canbanusers,canviewprofile,canannounce,canmassmove,canmassprune,canmoderateposts,canmoderateattachments) VALUES (NULL,'$parentid','$userid','$newpostemail','$newthreademail','$caneditposts','$candeleteposts','$canviewips','$canmanagethreads','$canopenclose','$caneditthreads','$caneditstyles','$canbanusers','$canviewprofile','$canannounce','$canmassmove','$canmassprune','$canmoderateposts','$canmoderateattachments')");
”,替换为“
    $DB_site->query("INSERT INTO moderator (moderatorid,forumid,userid,newpostemail,newthreademail,caneditposts,candeleteposts,canviewips,canmanagethreads,canopenclose,caneditthreads,caneditstyles,canbanusers,canviewprofile,canannounce,canmassmove,canmassprune,canmoderateposts,canmoderateattachments,canpostnews) VALUES (NULL,'$parentid','$userid','$newpostemail','$newthreademail','$caneditposts','$candeleteposts','$canviewips','$canmanagethreads','$canopenclose','$caneditthreads','$caneditstyles','$canbanusers','$canviewprofile','$canannounce','$canmassmove','$canmassprune','$canmoderateposts','$canmoderateattachments','$canpostnews')");
”,查找“
  $moderator=$DB_site->query_first("SELECT forumid,userid,newpostemail,newthreademail,caneditposts,candeleteposts,canviewips,canmanagethreads,canopenclose,caneditthreads,caneditstyles,canbanusers,canviewprofile,canannounce,canmassmove,canmassprune,canmoderateposts,canmoderateattachments FROM moderator WHERE moderatorid=$moderatorid");
”,替换为“
  $moderator=$DB_site->query_first("SELECT forumid,userid,newpostemail,newthreademail,caneditposts,candeleteposts,canviewips,canmanagethreads,canopenclose,caneditthreads,caneditstyles,canbanusers,canviewprofile,canannounce,canmassmove,canmassprune,canmoderateposts,canmoderateattachments,canpostnews FROM moderator WHERE moderatorid=$moderatorid");
”,查找“
    $DB_site->query("UPDATE moderator SET forumid='$parentid',userid='$userid',newpostemail='$newpostemail',newthreademail='$newthreademail',caneditposts='$caneditposts',candeleteposts='$candeleteposts',canviewips='$canviewips',canmanagethreads='$canmanagethreads',canopenclose='$canopenclose',caneditthreads='$caneditthreads',caneditstyles='$caneditstyles',canbanusers='$canbanusers',canviewprofile='$canviewprofile',canannounce='$canannounce',canmassmove='$canmassmove',canmassprune='$canmassprune',canmoderateposts='$canmoderateposts',canmoderateattachments='$canmoderateattachments' WHERE moderatorid='$moderatorid'");
”,替换为“
    $DB_site->query("UPDATE moderator SET forumid='$parentid',userid='$userid',newpostemail='$newpostemail',newthreademail='$newthreademail',caneditposts='$caneditposts',candeleteposts='$candeleteposts',canviewips='$canviewips',canmanagethreads='$canmanagethreads',canopenclose='$canopenclose',caneditthreads='$caneditthreads',caneditstyles='$caneditstyles',canbanusers='$canbanusers',canviewprofile='$canviewprofile',canannounce='$canannounce',canmassmove='$canmassmove',canmassprune='$canmassprune',canmoderateposts='$canmoderateposts',canmoderateattachments='$canmoderateattachments',canpostnews='$canpostnews' WHERE moderatorid='$moderatorid'");
”,保存。


[版主部分]
⒈使用phpMyAdmin或其他工具打开论坛数据库,执行“
ALTER TABLE moderator ADD canpostnews SMALLINT (6) not null
”。

⒉像上面炮制 admin/index.php 那样对付 mod/index.php 。

⒊将以下内容粘贴为新文件 mod/newsfade.php (与上面有不少区别,请留意):“
<?php

require("./global.php");

cpheader();

$perms=getpermissions();
if (!
$perms[ismoderator] and !$ismod=$DB_site->query_first("SELECT * FROM moderator WHERE userid=$bbuserinfo[userid] AND (canpostnews=1)")) {
  echo 
"<p>基于安全理由,您没有权限处理新闻!</p>";
  exit;
}

if (isset(
$action)==0) {
  
$action="modify";
}

// ###################### Start add #######################
if ($action=="add") {

  
doformheader("newsfade","insert");

  
makeinputcode("连接 URL","title","http://");
  
makeinputcode("开始日期(格式: yyyy-mm-dd)","startdate",date("Y-m-d",time()));
  
makeinputcode("结束日期(格式: yyyy-mm-dd)","enddate",date("Y-m-d",time()+24*60*60*31));

  
makeinputcode("新闻内容(您可以使用HTML)","pagetext");

  
doformfooter();
}

// ###################### Start insert #######################
if ($action=="insert") {

  
$DB_site->query("INSERT INTO announcement(announcementid,title,userid,startdate,enddate,pagetext,forumid) VALUES (NULL,'".addslashes($title)."','$bbuserinfo[userid]',UNIX_TIMESTAMP('".addslashes($startdate)."'),UNIX_TIMESTAMP('".addslashes($enddate)."'),'".addslashes($pagetext)."',0)");

  
$action="modify";

  echo 
"<p>记录已经增加</p>";

}

// ###################### Start edit #######################
if ($action=="edit") {

  
$newsfade=$DB_site->query_first("SELECT title,userid,FROM_UNIXTIME(startdate) AS startdate,FROM_UNIXTIME(enddate) AS enddate,pagetext,forumid FROM announcement WHERE announcementid=$newsfadeid");

  if (
$newsfade[userid]!=$bbuserinfo[userid]) {
    echo 
"<p>您不能编辑或删除管理员或其他版主所发布的新闻!</p>";
    exit;
  }

  
doformheader("newsfade","doupdate");
  
makehiddencode("newsfadeid","$newsfadeid");

  
makeinputcode("连接 URL","title",$newsfade[title]);

  
makeinputcode("开始日期(格式: yyyy-mm-dd)","startdate",$newsfade[startdate]);
  
makeinputcode("结束日期(格式: yyyy-mm-dd)","enddate",$newsfade[enddate]);

  
maketextareacode("新闻内容(您可以使用HTML)","pagetext",$newsfade[pagetext]);

  
doformfooter();

}

// ###################### Start do update #######################
if ($action=="doupdate") {

  
$newsfade=$DB_site->query_first("SELECT userid FROM announcement WHERE announcementid=$newsfadeid");

  if (
$newsfade[userid]!=$bbuserinfo[userid]) {
    echo 
"<p>您不能编辑或删除管理员或其他版主所发布的新闻!</p>";
    exit;
  }

  
$DB_site->query("UPDATE announcement SET title='".addslashes($title)."',userid='$bbuserinfo[userid]',startdate=UNIX_TIMESTAMP('".addslashes($startdate)."'),enddate=UNIX_TIMESTAMP('".addslashes($enddate)."'),pagetext='".addslashes($pagetext)."',forumid=0 WHERE announcementid=$newsfadeid");

  echo 
"<p>记录已经更新!</p>";

  
$action="modify";

}
// ###################### Start Remove #######################

if ($action=="remove") {

  
$newsfade=$DB_site->query_first("SELECT userid FROM announcement WHERE announcementid=$newsfadeid");

  if (
$newsfade[userid]!=$bbuserinfo[userid]) {
    echo 
"<p>您不能编辑或删除管理员或其他版主所发布的新闻!</p>";
    exit;
  }

  echo 
"<p>您确认要删除选择的记录吗?</p>\n";
  echo 
"<p><a href='newsfade.php?newsfadeid=$newsfadeid&action=kill'>是</a></p>";

}

// ###################### Start Kill #######################

if ($action=="kill") {

  
$newsfade=$DB_site->query_first("SELECT userid FROM announcement WHERE announcementid=$newsfadeid");

  if (
$newsfade[userid]==1) {
    echo 
"<p>您不能编辑/删除管理员所发布的新闻!</p>";
    exit;
  }

  
$DB_site->query("DELETE FROM announcement WHERE announcementid=$newsfadeid");

  
$action="modify";
}

// ###################### Start modify #######################
if ($action=="modify") {


  
$newsfades=$DB_site->query("SELECT announcementid AS newsfadeid,pagetext,FROM_UNIXTIME(startdate) AS startdate,FROM_UNIXTIME(enddate) AS enddate FROM announcement WHERE forumid=0 ORDER BY startdate");

    if (
$DB_site->num_rows($newsfades)) {
        echo 
"<table width=\"100%\" bgcolor=\"black\" border=0 cellpadding=0 cellspacing=0><tr><td>";
        echo 
"<table border=0 width=\"100%\" cellspacing=1 cellpadding=4><tr bgcolor=\"#3F3849\"><td align=\"center\" colspan=4><FONT color=\"#BCB6CD\"><b>新闻</b></FONT></td></tr>\n";
        echo 
"<tr bgcolor=\"#51485F\"><td nowrap align=\"center\" width=\"100%\"><FONT color=\"#BCB6CD\">内容</font></td><td align=\"center\" nowrap><FONT color=\"#BCB6CD\">开始日期</font></td><td align=\"center\" nowrap><FONT color=\"#BCB6CD\">结束日期</font></td><td nowrap align=\"center\"><FONT color=\"#BCB6CD\">修改</font></td></tr>\n";
        while (
$newsfade=$DB_site->fetch_array($newsfades)) {
            echo 
"<tr bgcolor=\"#CCCCCC\"><td width=\"100%\">$newsfade[pagetext]</td><td nowrap>$newsfade[startdate]</td><td nowrap>$newsfade[enddate]</td><td nowrap>".
                
makelinkcode("编辑","newsfade.php?s=$session[sessionhash]&action=edit&newsfadeid=$newsfade[newsfadeid]").
                
makelinkcode("删除","newsfade.php?s=$session[sessionhash]&action=remove&newsfadeid=$newsfade[newsfadeid]").
                
"</td></tr>\n";
        }
        echo 
"</table></td></tr></table>\n";
        echo 
"<p>你只能编辑或删除自己发布的新闻!</p>";
    } else {
      echo 
"无新闻";
    }

}

cpfooter();

?>
”。

大功告成!我的立场是给予版主最充分的权力,所以上面的HACK缺省地是给予版主新闻管理权的。