帝国CMS二次开发会员空间增加最近访客
2020-04-10 站长 站长日志
帝国CMS会员空间是没有访客记录功能的,所以我们需要二次开发一个,方法不是非常复杂,步骤代码会全部列出,大致效果是这样的。
1、首先我们去后台新建一个会员字段,用来储存访客记录。字段名
zuijin
字段标识
最近访客
字段类型
字符型0-255字节(VARCHAR) 255
输入表单替换html代码
<
input
name
=
"zuijin"
type
=
"text"
id
=
"zuijin"
value
=
"<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($addr[zuijin]))?>" size="">
2、然后修改会员空间的header.temp.php模板,增加访问空间页面就写入访客记录代码//增加会员访问记录
if
(
$getuserid
&&
$getuserid
<>
$userid
){
$r
=
$empire
->fetch1(
"select zuijin from {$dbtbpre}enewsmemberadd where userid='$userid' limit 1"
);
if
(
empty
(
$r
[
'zuijin'
])){
$empire
->query(
"update {$dbtbpre}enewsmemberadd set zuijin='$getuserid::::::' where userid='$userid'"
);
}
else
{
$zuijin
=
explode
(
"::::::"
,
$r
[
'zuijin'
]);
if
(in_array(
$getuserid
,
$zuijin
))
{
$newzuijin
=
$getuserid
.
"::::::"
.
str_replace
(
$getuserid
.
"::::::"
,
""
,
$r
[
'zuijin'
]);
$empire
->query(
"update {$dbtbpre}enewsmemberadd set zuijin='$newzuijin' where userid='$userid'"
);
}
else
{
$empire
->query(
"update {$dbtbpre}enewsmemberadd set zuijin='$getuserid::::::$r[zuijin]' where userid='$userid'"
);
}
}
}
当用户访问就写入字段zuijin记录下来。数据库大致格式为:ID::::::
3、最后就是在需要的地方调用访问记录就可以了<?php
$jl
=
$empire
->fetch1(
"select zuijin from {$dbtbpre}enewsmemberadd where userid='$userid' limit 1"
);
$jluserid
=
explode
(
"::::::"
,
$jl
[
'zuijin'
]);
$i
=0;
$jlnum
=
count
(
$jluserid
)-1;
if
(
$jlnum
>=8){
$jlnum
=8;
}
elseif
(
$jlnum
==
'0'
)
{
echo
'<div class="nogz">暂时还没有访客记录</div>'
;
}
while
(
$i
<
$jlnum
)
{
$jluser
=
$empire
->fetch1(
"select * from {$dbtbpre}enewsmemberadd where userid='$jluserid[$i]' limit 1"
);
$jluserxx
=
$empire
->fetch1(
"select * from {$dbtbpre}enewsmember where userid='$jluserid[$i]' limit 1"
);
$jluserpic
=
$jluser
[
'userpic'
]?
$jluser
[
'userpic'
]:
$public_r
[newsurl].
'e/data/images/nouserpic.gif'
;
?>
<li><a href=
"/e/space/?userid=<?=$jluserid[$i]?>"
><img src=
"<?=$jluserpic?>"
/><span><?=
$jluserxx
[username]?></span></a></li>
<?
$i
++;
}
?>
首先循环查询出zuijin字段的内容,然后分隔出来,最后再循环调用对应的ID会员内容,完工了。