您现在的位置是:首页 > 教程 > dedecms教程dedecms教程

dedecms如何调用出访客最近浏览过的文章

涵菡2024-08-16 21:16:32dedecms教程已有人查阅

导读以下是本人针对上面问题的一个拙劣的笨方法:不对的地方请高手赐教后台出执行如下语句新建php文件count_zj.php 存放到puls目录下内容如下

以下是本人针对上面问题的一个拙劣的笨方法:不对的地方请高手赐教
后台出执行如下语句
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`)
)
新建php文件count_zj.php 存放到puls目录下内容如下
<?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='view.php?aid=".$row['id']."'>\");";
echo "document.write('".$row['title']."');";
echo "document.write(\"</a>\");\r\n";
}
}
exit();
?>
在文章模板处添加如下语句
<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>
在引用处直接添加<span id="span_zj"></span>

本文标签:

很赞哦! ()

留言与评论 (共有 条评论)
验证码:

本栏推荐

相关标签