首先打开/admin/tpl/side.htm,选择一个分类,增加一个菜单,比方说我在聚合设置里面增加了一个站内统计的菜单:
<!--{if $menus[8]}-->
<div class="block style1" id="menus_8">
<h2>聚合设置</h2>
<ul class="folder">
<!--{if $menus[8][zntj]}--><li$menuactive[zntj]><a href="{CPURL}?action=zntj">站内统计</a></li><!--{/if}-->
<!--{if $menus[8][bbs]}--><li$menuactive[bbs]><a href="{CPURL}?action=bbs">论坛设置</a></li><!--{/if}-->
<!--{if $menus[8][bbsforums]}--><li$menuactive[bbsforums]><a href="{CPURL}?action=bbsforums">版块聚合</a></li><!--{/if}-->
<!--{if $menus[8][threads]}--><li$menuactive[threads]><a href="{CPURL}?action=threads">帖子批量聚合</a></li><!--{/if}-->
<!--{if $menus[8][uchome]}--><li$menuactive[uchome]><a href="{CPURL}?action=uchome">UCHome设置</a></li><!--{/if}-->
</ul>
</div>
<!--{/if}-->
这里说明下:
$menus[8][zntj]},这里的zntj就是我给的后台权限的标志,等下配置权限表的时候再说。
href="{CPURL}?action=zntj",这里的zntj是操作标志,会与admin文件夹下的文件对应。
接着,打开admincp.php,修改允许的方法(113-122行)
对应刚才side.php的修改,在相应的行里添加方法。比如我就在聚合设置所属的行(122)里面添加:
array('bbs', 'bbsforums', 'threads', 'uchome','zntj')
你可以通过查看该行允许的方法来确定自己要在哪行添加,这行里一定会包含该类其他的方法。
然后该配置权限了。
打开/admin/tpl/usergroups.htm,找到刚才添加菜单的那个分类,添加
<tr>
<th>统计数据查询</th>
<td>
<input type="radio" name="set[managezntj]" value="1"{$thevalue['managezntj'][1]}> 可管理
<input type="radio" name="set[managezntj]" value="0"{$thevalue['managezntj'][0]}> 禁止
</td>
</tr>
说明一下,managezntj=manage+zntj,即manage+操作代码。
接着打开数据库,找到表supe_usergroups,添加一个项managezntj,类型tinyint,长度1,默认值0。
好了,接着就可以进后台在权限配置界面进行权限配置了。
最后是功能实现了。在admin文件夹下面创建文件admin_zntj.php,下面是基础代码,想要什么功能自己修改:
<?php
if(!defined('IN_SUPESITE_ADMINCP')) {
exit('Access Denied');
}
//权限
if(!checkperm('managezntj')) {
showmessage('no_authority_management_operation');
}
$_GET['error'] = trim($_GET['error']);
$formurl = CPURL.'?action=zntj';
//栏目
if ($_GET['tjflg'] == 'c' || $_GET['tjflg'] == ''){
$findtime="< 24*60*60";
$getcc = 0;
$getcc = strtotime($_POST['dateline']);
$getdd = $getcc+24*60*60;
if ($_POST['classchange']=='最近一天') $findtime="< 24*60*60";
if ($_POST['classchange']=='最近一周') $findtime="< 24*60*60*7";
if ($_POST['classchange']=='最近一月') $findtime="< 24*60*60*30";
if ($_POST['classchange']=='最近三月') $findtime="< 24*60*60*90";
if ($_POST['classchange']=='最近一年') $findtime="< 24*60*60*365";
if ($_POST['classchange']=='指定时间查看') $findtime="!=0 and supe_spaceitems.dateline < ".$getdd." and supe_spaceitems.dateline > ".$getcc;
$classtop = array();
$query = $_SGLOBAL['db']->query("SELECT count(supe_spaceitems.itemid) AS ccnum, sum(supe_spaceitems.viewnum) AS vvnum, supe_categories.catid, supe_categories.upid, supe_categories.name, supe_categories.subcatid FROM supe_categories ,supe_spaceitems WHERE supe_categories.catid = supe_spaceitems.catid and UNIX_TIMESTAMP( NOW( ) ) - supe_spaceitems.dateline ".$findtime." GROUP BY supe_categories.catid order by ccnum desc");
while ($pageorder = $_SGLOBAL['db']->fetch_array($query)) {
$classtop[] = $pageorder;
}
include template('admin/tpl/zntj.htm', 1);
}
//文章
if ($_GET['tjflg'] == 'v'){
$findtime="< 24*60*60";
$getcc = 0;
$getcc = strtotime($_POST['dateline']);
$getdd = $getcc+24*60*60;
if ($_POST['classchange']=='最近一天') $findtime="< 24*60*60";
if ($_POST['classchange']=='最近一周') $findtime="< 24*60*60*7";
if ($_POST['classchange']=='最近一月') $findtime="< 24*60*60*30";
if ($_POST['classchange']=='最近三月') $findtime="< 24*60*60*90";
if ($_POST['classchange']=='最近一年') $findtime="< 24*60*60*365";
if ($_POST['classchange']=='指定时间查看') $findtime="!=0 and supe_spaceitems.dateline < ".$getdd." and supe_spaceitems.dateline > ".$getcc;
$classtop = array();
$query = $_SGLOBAL['db']->query("SELECT itemid,catid,uid,username,subject,dateline,lastpost,viewnum FROM supe_spaceitems WHERE UNIX_TIMESTAMP( NOW( ) ) - supe_spaceitems.dateline ".$findtime." order by viewnum desc limit 0,50");
while ($pageorder = $_SGLOBAL['db']->fetch_array($query)) {
$classtop[] = $pageorder;
}
include template('admin/tpl/zntj.htm', 1);
}
//用户
if ($_GET['tjflg'] == 'u'){
$findtime="< 24*60*60";
$getcc = 0;
$getcc = strtotime($_POST['dateline']);
$getdd = $getcc+24*60*60;
if ($_POST['classchange']=='最近一天') $findtime="< 24*60*60";
if ($_POST['classchange']=='最近一周') $findtime="< 24*60*60*7";
if ($_POST['classchange']=='最近一月') $findtime="< 24*60*60*30";
if ($_POST['classchange']=='最近三月') $findtime="< 24*60*60*90";
if ($_POST['classchange']=='最近一年') $findtime="< 24*60*60*365";
if ($_POST['classchange']=='指定时间查看') $findtime="!=0 and supe_members.dateline < ".$getdd." and supe_members.dateline > ".$getcc;
$classtop = array();
$query = $_SGLOBAL['db']->query("SELECT username,dateline,lastlogin,ip FROM supe_members WHERE UNIX_TIMESTAMP( NOW( ) ) - supe_members.dateline ".$findtime." order by lastlogin desc limit 0,100");
while ($pageorder = $_SGLOBAL['db']->fetch_array($query)) {
$classtop[] = $pageorder;
}
include template('admin/tpl/zntj.htm', 1);
}
?>
在admin/tpl下面创建文件zntj.htm,下面是基础代码,想要什么功能自己修改:
<table summary="" id="pagehead" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td><h1>$alang[map_setting_info]</h1></td>
<td class="actions">
<table cellspacing="0" cellpadding="0" border="0" align="right" summary="">
<tbody><tr>
<td<!--{if $_GET['tjflg'] == 'c' || $_GET['tjflg'] == '' }--> class="active"<!--{/if}-->><a href="$cpurl?action=tongjishuju&tjflg=c">$alang[tj_category]</a></td>
<td<!--{if $_GET['tjflg'] == 'v' }--> class="active"<!--{/if}-->><a href="$cpurl?action=tongjishuju&tjflg=v">$alang['tj_view']</a></td>
<td<!--{if $_GET['tjflg'] == 'u' }--> class="active"<!--{/if}-->><a href="$cpurl?action=tongjishuju&tjflg=u">$alang[tj_user]</a></td>
</tr>
</tbody></table>
</td>
</tr>
</table>
<!---栏目--->
<!--{if $_GET['tjflg'] == 'c' || $_GET['tjflg'] == '' }-->
<div class="colorarea01">
<table cellspacing="2" cellpadding="2" class="helptable"><tr><td><ul>
<li>栏目统计说明:</li>
<li>指定日期查看可以查看从该时间开始二十四小时内的栏目文章发布情况。</li>
<li>浏览量是该栏目内所有该时段发布的所有文章的总点击数,不是该段时间内的文章点击数。</li>
</ul></td></tr></table>
</div>
<a name="base"></a>
<div class="colorarea02">
<form method="post" name="mapclasschange" id="mapclasschange" action="$formurl" enctype="multipart/form-data">
<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
<h2>栏目统计数据</h2>
<div class="buttons">
<input type="submit" name="classchange" value="最近一天" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一周" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一月" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近三月" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一年" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="指定时间查看" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<INPUT id="dateline" readOnly name="dateline" value="#date('Y-m-d H:i',time())#" /><IMG οnclick="getDatePicker('dateline', event, 21)" src="http://www.cnchu.com/admin/images/time.gif" />
</div>
<table cellspacing="0" cellpadding="0" width="100%" class="maintable">
<tr><th style="width:30px;text-align:center;">排名</th><th width="30%">栏目名称</th><th width="30%">更新数量</th><th style="width:30%;text-align:center;">浏览量</th></tr>
<!--{eval $top=0}-->
<!--{eval $allcc=0}-->
<!--{eval $allvv=0}-->
<!--{loop $classtop $value}-->
<tr>
<!--{eval $top=$top+1}-->
<!--{eval $allcc=$allcc+$value[ccnum]}-->
<!--{eval $allvv=$allvv+$value[vvnum]}-->
<td style="width:30px;text-align:center;">$top</td>
<td>$value[name]</td>
<td>$value[ccnum]</td>
<td>$value[vvnum]</td>
</tr>
<!--{/loop}-->
<tr>
<td style="width:30px;text-align:center;"></td>
<td>总计:</td>
<td>$allcc</td>
<td>$allvv</td>
</tr>
</table>
</form>
</div>
<!--{/if}-->
<!---文章--->
<!--{if $_GET['tjflg'] == 'v' }-->
<div class="colorarea01">
<table cellspacing="2" cellpadding="2" class="helptable"><tr><td><ul>
<li>文章统计说明:</li>
<li>指定日期查看可以查看从该时间开始二十四小时内的文章浏览情况。</li>
<li>最多显示浏览量前五十的文章。</li>
</ul></td></tr></table>
</div>
<a name="base"></a>
<div class="colorarea02">
<form method="post" name="mapclasschange" id="mapclasschange" action="$formurl&action=tongjishuju&tjflg=v" enctype="multipart/form-data">
<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
<h2>栏目统计数据</h2>
<div class="buttons">
<input type="submit" name="classchange" value="最近一天" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一周" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一月" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近三月" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一年" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="指定时间查看" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<INPUT id="dateline" readOnly name="dateline" value="#date('Y-m-d H:i',time())#" /><IMG οnclick="getDatePicker('dateline', event, 21)" src="http://www.cnchu.com/admin/images/time.gif" />
</div>
<table cellspacing="0" cellpadding="0" width="100%" class="maintable">
<tr><th style="width:30px;text-align:center;">排名</th><th width="30%">文章名称</th><th width="30%">浏览数量</th><th style="width:30%;text-align:center;">发布人</th></tr>
<!--{eval $top=0}-->
<!--{eval $allcc=0}-->
<!--{loop $classtop $value}-->
<tr>
<!--{eval $top=$top+1}-->
<!--{eval $allcc=$allcc+$value[viewnum]}-->
<td style="width:30px;text-align:center;">$top</td>
<td>$value[subject]</td>
<td>$value[viewnum]</td>
<td>$value[username]</td>
</tr>
<!--{/loop}-->
<tr>
<td style="width:30px;text-align:center;"></td>
<td>总计:</td>
<td>$allcc</td>
<td></td>
</tr>
</table>
</form>
</div>
<!--{/if}-->
<!---用户--->
<!--{if $_GET['tjflg'] == 'u' }-->
<div class="colorarea01">
<table cellspacing="2" cellpadding="2" class="helptable"><tr><td><ul>
<li>用户统计说明:</li>
<li>该功能显示指定日期内的用户注册情况。</li>
<li>最多按登录时间排序显示前一百个用户的信息。</li>
</ul></td></tr></table>
</div>
<a name="base"></a>
<div class="colorarea02">
<form method="post" name="mapclasschange" id="mapclasschange" action="$formurl&action=tongjishuju&tjflg=u" enctype="multipart/form-data">
<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
<h2>用户统计数据</h2>
<div class="buttons">
<input type="submit" name="classchange" value="最近一天" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一周" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一月" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近三月" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="最近一年" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<input type="submit" name="classchange" value="指定时间查看" class="submit" style="margin-left: 5px; margin-right: 5xp;">
<INPUT id="dateline" readOnly name="dateline" value="#date('Y-m-d H:i',time())#" /><IMG οnclick="getDatePicker('dateline', event, 21)" src="http://www.cnchu.com/admin/images/time.gif" />
</div>
<table cellspacing="0" cellpadding="0" width="100%" class="maintable">
<tr><th style="width:30px;text-align:center;">排名</th><th width="20%">用户名</th><th width="20%">注册时间</th><th style="width:20%;text-align:center;">最后登录时间</th><th style="width:20%;text-align:center;">最后登录IP</th></tr>
<!--{eval $top=0}-->
<!--{loop $classtop $value}-->
<tr>
<!--{eval $top=$top+1}-->
<td style="width:30px;text-align:center;">$top</td>
<td>$value[username]</td>
<td>#date('Y-m-d H:i',$value[dateline])#</td>
<td>#date('Y-m-d H:i',$value[lastlogin])#</td>
<td>$value[ip]</td>
</tr>
<!--{/loop}-->
</table>
</form>
</div>
<!--{/if}-->
到此全部结束,谢谢收看。