1、导入数据库:
CREATE TABLE `uchome_app_laba` (
`lid` mediumint(8) unsigned NOT NULL auto_increment,
`uid` mediumint(8) NOT NULL default '0',
`username` varchar(20) NOT NULL default '',
`dealy` tinyint(2) unsigned NOT NULL default '0',
`say` varchar(200) NOT NULL default '',
`act` varchar(10) NOT NULL default '',
`dateline` int(10) default '0',
PRIMARY KEY (`lid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf-8;
2、在common.php的最下边代码里添加:
//每页都有一个获取喇叭的函数
function get_laba(){
global $_SGLOBAL;
$cachefile = S_ROOT.'./data/cache_laba.txt';
if(!$_SGLOBAL['laba']){
if($_SGLOBAL['timestamp'] - @filemtime($cachefile)<60) {
$_SGLOBAL['laba'] = unserialize(sreadfile($cachefile));
}else{
$query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('app_laba').' ORDER BY dateline DESC LIMIT 10');
while($value = $_SGLOBAL['db']->fetch_array($query)){
$_SGLOBAL['laba'][] = $value;
}
swritefile($cachefile, serialize($_SGLOBAL['laba']));
}
}
foreach($_SGLOBAL['laba'] as $key=>$value){
realname_set($value['uid'], $value['username']);//实名
$_SGLOBAL['laba'][$key] = $value;
}
return $_SGLOBAL['laba'];
}
//随机颜色
function get_rndcolor(){
$str = "0123456789abcdef";
$color = '#';
for($i=1;$i<7;$i++){
$color .= $str{intval(rand(0, 15))};
}
return $color;
}
3、打开template/default/header.htm:
找到
<a href="do.php?ac=$_SCONFIG[login_action]">登录</a> |
<a href="do.php?ac=$_SCONFIG[register_action]">注册</a>
<!--{/if}-->
</div>
</div>
</div>
在下边添加:
<!--{if $isnovel||$do != 'index'}-->
<!--{eval get_laba();$i=0;}-->
<div style="position: relative;padding:5px 0;width:950px; margin:0 auto;">
<ul style="position:absolute;height:25px;line-height:25px;text-align:right;overflow:hidden;right:0;top:-19px;" id="top_scroll">
<!--{loop $_SGLOBAL['laba'] $value}-->
<!--{eval $say = addslashes(preg_replace('/\r|\n/is', '', shtmlspecialchars($value[say])));}-->
<li><a id="laba_user" style="color:#1782db" href="space.php?uid={$value[uid]}"></a>(<span id="laba_time" class="gray"><!--{date('Y-m-d H:i',$value[dateline],1)}--></span>)使用爪喇叭<span id="laba_act">{$value[act]}</span>:<span id="laba_content">$say</span> <img src="image/app/message.gif" />[<a href="laba.php">发布</a>]</li>
<!--{eval break;}-->
<!--{/loop}-->
</ul>
</div>
<script>
var labas = Array();
<!--{loop $_SGLOBAL['laba'] $value}-->
<!--{eval $say = addslashes(preg_replace('/\r|\n/is', '', shtmlspecialchars($value[say])));}-->
labas[{$i}]= ['{$value[uid]}','<!--{eval echo addslashes($value[username])}-->','<!--{date('Y-m-d H:i',$value[dateline],1)}-->','{$value[act]}','{$say}', '<!--{eval echo get_rndcolor();}-->','<!--{eval echo get_rndcolor();}-->',{$value[dealy]}];
<!--{eval $i++;}-->
<!--{/loop}-->
var topindex =0;
function topdealy(){
if(labas.length<topindex+1)topindex=0;
$('laba_user').innerHTML = labas[topindex][1];
$('laba_user').href = 'space.php?uid='+labas[topindex][0];
$('laba_time').innerHTML = labas[topindex][2];
$('laba_act').innerHTML = labas[topindex][3];
$('laba_content').innerHTML = labas[topindex][4];
$('laba_content').style.color = labas[topindex][5];
$('laba_act').style.color = labas[topindex][6];
setTimeout('topdealy()', labas[topindex][7]*1000);
topindex++;
}
topdealy();
</script>
<!--{/if}-->
把cleanlaba.php放到source/corn目录里,
去后台,添加一个任务,定期清除喇叭。
即可...
我喜欢在发布的时候把使用说明发出来... |