Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[采集] 杂器Discuz7.0采集器(SS采集数据导入dz论坛办法)

[复制链接]
wo1234 发表于 2009-2-13 13:04:57 | 显示全部楼层
装过的人请立即更改数据库密码!
回复

使用道具 举报

 楼主| findallove 发表于 2009-2-13 16:51:16 | 显示全部楼层
采集数据是ss来采集的,我这里这个程序只是吧ss采集的数据导入到论坛而已
回复

使用道具 举报

 楼主| findallove 发表于 2009-2-13 16:53:06 | 显示全部楼层
我今天用了一天了,基本错误都解决了,感觉很爽啊
回复

使用道具 举报

 楼主| findallove 发表于 2009-2-13 16:57:38 | 显示全部楼层
<?php

/*
        [Zaqi!] (C)2009-2010 zaqi.net
        从supsite采集机器人导入数据
        QQ:findallove@qq.com
        tel:13430875919
*/

if(!defined('IN_DISCUZ')) {
        exit('Access Denied');
}
//supsites数据库连接设置
$dbhost1 = 'localhost';                        // 数据库服务器
$dbuser1 = 'root';                        // 数据库用户名
$dbpw1 = xxx;                                // 数据库密码
$dbname1 = xxx;                        // 数据库名
$pconnect1 = 0;                                // 数据库持久连接 0=关闭, 1=打开
$tablepre1 = 'supe_';
$first=1;
$db1 = new dbstuff;
$db1->connect($dbhost1, $dbuser1, $dbpw1, $dbname1, $pconnect1);
$dbuser1 = $dbpw1 = $dbname1 = $pconnect1 = NULL;
//运行机器人
/*
$sql="select robotid from {$tablepre1}robots";
$query = $db1->query($sql);
$url="http://www.168mobi.com/blog/admincp.php?action=robots&op=robot&clearcache=1&robotid=";
echo "<script language=javascript>";
while($rs= $db1->fetch_array($query)) {
$url1=$url.$rs['robotid'];
echo "open(\"$url1\");";
}
echo "</script>";
$db1->free_result($query);
*/
//设置发帖人
$author="findallove";
$authorid="1";
//$d1=round(time()/(3600*24))*3600*24;
//$sql="update {$tablepre}posts set message=replace(replace(message,'&lt;','<'),'&gt;','>') where dateline>$d1";
//$query = $db->query($sql);
//$db->query($sql);

if(!empty($_POST["author"])){
$author=$_POST["author"];
$sql="select uid from {$tablepre}members where username='$author'";
$rs=$db->getin($sql);
$authorid=$rs['uid'];
unset($rs);
}else{
echo "设置发帖人";
cjupdateforum();
//echo strftime("%Y-%m-%d",strtotime("1 day"))."<br>";
//echo microtime(strftime("%Y-%m-%d",strtotime("1 day")))."<br>";
//echo time()."<br>";
echo "<form method=post>";
echo "<input type=\"text\" name=\"author\">&nbsp;";
echo "<input type=\"submit\" value=\"开始采集\"></form><br>";
echo "技术支持:<a href=http://www.zaqi.net target=_blank>杂器网</a>";
echo "<a href=\"http://wpa.qq.com/msgrd?V=1&amp;Uin=64816414&amp;Site=杂器网&amp;Menu=yes\" target=\"_blank\">&nbsp;<img src=http://wpa.qq.com/pa?p=1:46133092:4 height=\"16\" border=\"0\" alt=\"QQ\" > 64816414</a><br><br>";
die("如果为空,则不会进行数据采集");
}
//读取机器人数据
$sql="select a.username,a.uid,a.subject,a.robotid,a.robottime,b.message,c.name from {$tablepre1}robotitems a left join {$tablepre1}robotmessages b on a.itemid=b.itemid left join {$tablepre1}robots c on c.robotid=b.robotid";
$query1 = $db1->query($sql);
while($rs1= $db1->fetch_array($query1)) {
//获取论坛分类
$sql="select fid from {$tablepre}forums where name='".$rs1['name']."'";
$rs=$db->getin($sql);
$fid=$rs['fid'];
if($fid!=''){
$subject=$rs1['subject'];
$dateline=$rs1['robottime'];
$views=rand(50,200);
//$subject=str_replace("\'","\"",$subject);
$subject=dhtml($subject);
//监测是否重复
$sql="select tid from {$tablepre}threads where subject like '$subject'";
unset($rs);
$rs=$db->getin($sql);
$sb=$rs['tid'];
if($sb==''){
//1.添加主题
$sql="insert into {$tablepre}threads(fid,subject,author,authorid,dateline,lastpost,lastposter,supe_pushstatus,views)values($fid,'$subject','$author',$authorid,'$dateline','$dateline','$author',1,$views)";
$db->query($sql);
$tid =$db->insert_id();
$db->free_result($query);
//2.添加内容
if($tid!=''){
echo $tid."subject<br>";
$message=$rs1['message'];
//$message=str_replace("\'","\"",$message);
$message=dhtml($message);
$sql="insert into {$tablepre}posts(tid,first,message,fid,subject,author,authorid,usesig,htmlon,bbcodeoff,smileyoff,parseurloff,dateline)values($tid,$first,'$message',$fid,'$subject','$author',$authorid,'0','1','0','-1','0',$dateline)";
$db->query($sql);
}
$db->free_result($query);
$lastpost = addslashes("$tid\t$subject\t$dateline\t$author");
mysql_query("UPDATE {$tablepre}forums SET lastpost='$lastpost', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'");
}
}
}
$db1->free_result($query1);
cjupdateforum();
//删除机器人采集的数据
$sql="DELETE FROM {$tablepre1}robotitems";
$db1->query($sql);
$db1->free_result($query);

$sql="DELETE FROM {$tablepre1}robotmessages";
$db1->query($sql);
$db1->free_result($query);

function cjupdateforum()
{
        global $tablepre,$db;
        $queryf = $db->query("SELECT fid FROM {$tablepre}forums WHERE type<>'group'");
        while($forum=$db->fetch_array($queryf)) {
               
                $rs = $db->getin("SELECT tid, subject, lastpost, lastposter FROM {$tablepre}threads WHERE fid='$forum[fid]' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
                $lastpost = addslashes("$rs[tid]\t$rs[subject]\t$rs[lastpost]\t$rs[lastposter]");
               
                $sql="SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM {$tablepre}threads WHERE fid='$forum[fid]' AND displayorder>='0'";
    $rs=$db->getin($sql);
    $threads=$rs['threads'];
    $posts=$rs['posts'];
    $d1=round(time()/(3600*24))*3600*24;
                $sql="SELECT COUNT(*) AS todayposts FROM {$tablepre}threads WHERE fid='$forum[fid]' AND displayorder>='0' and dateline>$d1";
    $rs=$db->getin($sql);
    $todayposts=$rs['todayposts'];
      
                $query=$db->query("UPDATE {$tablepre}forums SET threads='$threads', posts='$posts', lastpost='$lastpost',todayposts='$todayposts' WHERE fid='$forum[fid]'");
          $db->free_result($query);
        }
$db->free_result($queryf);
}
function dhtml($s){
        if($s!='') {
          $s=str_replace("'","&#39;",$s);
          $s=str_replace(",","&#44;",$s);
          $s=str_replace("\"","&#34;",$s);
          $s=str_replace("|","&#73;",$s);
    $s=str_replace("\t","",$s);
//    $s=str_replace("<","&lt;",$s);
//    $s=str_replace(">","&gt;",$s);
    $s=str_replace(" ","&nbsp;",$s);
        }
        return $s;
}
?>
这是最终版代码
回复

使用道具 举报

 楼主| findallove 发表于 2009-3-3 09:28:03 | 显示全部楼层
是ss采集,然后导入dz
回复

使用道具 举报

www.52cake.cn 发表于 2009-3-3 21:28:25 | 显示全部楼层
留记号;
回复

使用道具 举报

haihaigo 发表于 2009-6-9 04:06:49 | 显示全部楼层
总出现下面的错误:请楼主解答下,谢谢
Discuz! info: MySQL Query Error

User: haibbsmanerger
Time: 2009-6-9 4:12am
Script: /bbs/admincp.php

SQL: select a.itemid,a.username,a.uid,a.subject,a.robotid,a.robottime,c.name from blog_robotitems a left join blog_robots c on c.robotid=a.robotid
Error: Table 'a0126230705.blog_robotitems' doesn't exist
数据表缺失,请恢复备份数据详细解决方案请点击这里
回复

使用道具 举报

hssxysw 发表于 2009-6-9 10:07:43 | 显示全部楼层
SQL: select a.itemid,a.username,a.uid,a.subject,a.robotid,a.robottime,c.name from blog_robotitems a left join blog_robots c on c.robotid=a.robotid
Error: Table 'flbbs.blog_robotitems' doesn't exist
数据表缺失,请恢复备份数据详细解决方案请点击这里
回复

使用道具 举报

hssxysw 发表于 2009-6-9 10:13:16 | 显示全部楼层
被忽悠了~~~~~~~
回复

使用道具 举报

 楼主| findallove 发表于 2009-6-10 08:37:48 | 显示全部楼层
'flbbs.blog_robotitems' doesn't exist
表前缀不对,所以找不到表了,呵呵呵
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-16 03:18 , Processed in 0.036719 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表