dedecms调用访客最近浏览的文章

1、添加数据表,运行:

CREATE TABLE `数据库`.`dede_zj` (
  `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `mid` INTEGER UNSIGNED NOT NULL,
  `ip` VARCHAR(45) NOT NULL,
  `aid` INTEGER UNSIGNED NOT NULL,
  `logintime` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`id`)
)

2、在puls下新建文件count_zj.php,代码如下:

<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(dirname(__FILE__)."/../member/config.php");
global $cfg_ml;
 
$mid=$cfg_ml->M_ID;
$joinip = GetIP();
//当前时间戳
$nowTime = time();
 
if($mid)
{
$row = $dsql->GetOne(" Select * From `dede_zj`  where aid='$aid' and mid='$mid'");
if(!$row){
$dsql->ExecuteNoneQuery("INSERT INTO dede_zj( `id`, `mid`, `ip`,`aid` ,`logintime`)
VALUES (  '',$mid, '$joinip',$aid,$nowTime) ");
}
$db->SetQuery(" Select title,dede_archives.id From dede_archives  join dede_zj on dede_archives.id=dede_zj.aid where dede_zj.mid='$mid' order by logintime desc limit 1,5");   
$db->Execute();   
while($row = $db->GetArray())   
{ 
echo "document.write(\"<a href='view.php?aid=".$row['id']."'>\");"; 
echo "document.write('".$row['title']."');"; 
echo "document.write(\"</a>\");\r\n";  
} 
 
}
if(!$mid){
$m = $dsql->GetOne(" Select * From `dede_zjw`  where aid='$aid' and ip='$joinip'");
if(!$m){
$dsql->ExecuteNoneQuery("INSERT INTO dede_zjw( `id`, `mid`, `ip`,`aid` ,`logintime`)
VALUES (  '',$mid, '$joinip',$aid,$nowTime) ");
}
$db->SetQuery(" Select title,dede_archives.id From dede_archives  join dede_zj on dede_archives.id=dede_zj.aid where dede_zjw.ip='$joinip' order by logintime desc limit 1,5");   
$db->Execute();   
while($row = $db->GetArray())   
{ 
echo "document.write(\"<a href='https://www.360muye.cn/view.php?aid=".$row['id']."'>\");"; 
echo "document.write('".$row['title']."');"; 
echo "document.write(\"</a>\");\r\n"; 
} 
}
exit();
?>

3、在模板处用以下代码调用:

<SPAN id="span_zj"> 
<script src="{dede:field name='phpurl'/}/count_zj.php?view=yes&aid={dede:field name='id'/}&mid={dede:field name='mid'/}" type='text/javascript' language="javascript"></script>
<script type="text/javascript">  
document.getElementById("zj").innerHTML = document.getElementById("span_zj").innerHTML; 
document.getElementById("span_zj").innerHTML = ""; 
</script>
</SPAN> 

到此即可完成dedecms访客调用最近浏览文章。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值