1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
|
<?PHP
/*
* (C) 2005 CoderCrew
* http://www.CoderCrew.org
* info@CoderCrew.org
*/
//include
require("global.php");
//configuration
//boardid of the board in which we want to post our RSSImport
$boardid = 58;
//userid of the poster (0 eq GUEST)
$uid = 3;
//if $uid != 0 then the nick of the user with $uid else any nick.
$uname = "Peter";
//add your rssurls here - just 2 examples:
$sites[] = "rss url!";
print '*** ['.date("d.m.Y H:i").'] Starting script...';
print "\n";
print '*** ['.date("d.m.Y H:i").'] UID->'.$uid.'';
print "\n";
print '*** ['.date("d.m.Y H:i").'] UNAME->'.$uname.'';
print "\n";
print '*** ['.date("d.m.Y H:i").'] BOARDID->'.$boardid.'';
print "\n";
print '*** ['.date("d.m.Y H:i").'] SITESCONT->'.count(sites).'';
print "\n";
$time = time();
for($s = 0;$s < count($sites); $s++){
preg_match("/^((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si",$sites[$s],$input[1]);
$urlsplit = split("/",$input[1][3]);
print '*** ['.date("d.m.Y H:i").'] sites['.$s.'] = '.$urlsplit[0].'';
print "\n";
$content = implode("",file($sites[$s]));
preg_match_all("/\<item\>(.*?)\<\/item\>/si", $content, $results);
for($i = 0;$i < count($results[1]);$i++) {
preg_match("/\<link\>(.*?)\<\/link\>/si", $results[1][$i], $link);
preg_match("/\<title\>(.*?)\<\/title\>/si", $results[1][$i], $title);
preg_match("/\<description\>(.*?)\<\/description\>/si", $results[1][$i], $desc);
preg_match("/\<pubDate\>(.*?)\<\/pubDate\>/si", $results[1][$i], $date);
$link = $link[1];
$title = $title[1];
$desc = $desc[1];
$date = $date[1];
$check = $db->query("SELECT id,title FROM bb".$n."_rss WHERE title = '".addslashes($title)."'");
if($db->num_rows($check) == 0){
$db->query("INSERT INTO `bb".$n."_rss` ( `id` , `from` , `title` , `link` , `description` ) VALUES ('', '".$s."', '".addslashes($title)."', '".addslashes($link)."', '".addslashes($desc)."')");
if(!empty($date)) $news[$s][$i]['date'] = substr($date,0,strlen($date)-6);
$news[$s][$i]['link'] = $link;
$news[$s][$i]['title'] = $title;
$news[$s][$i]['desc'] = $desc;
if(!$news[$s]['name']) $news[$s]['name'] = $urlsplit[0];
print '*** ['.date("d.m.Y H:i").'] DB->INERSRT('.$title.')';
print "\n";
} else {
print '*** ['.date("d.m.Y H:i").'] DB->EXISTS('.$title.')';
print "\n";
}
}
}
for($i = 0;$i < count($news);$i++){
$newstopic[$i] = "".$news[$i]['name']." - News [".date("d.m.Y H:i")."]";
for($a = 0;$a < count($news[$i]);$a++){
if(!empty($news[$i][$a]['date'])) $newstext[$i] .= "[i][".$news[$i][$a]['date']."][/i] [b]» [URL=".$news[$i][$a]['link']."]".$news[$i][$a]['title']."[/URL][/b]\n";
else if(!empty($news[$i][$a]['title'])) $newstext[$i] .= "[b]» [URL=".$news[$i][$a]['link']."]".$news[$i][$a]['title']."[/URL][/b]\n";
if(!empty($news[$i][$a]['desc'])) $newstext[$i] .= "[i]".$news[$i][$a]['desc']."[/i]\n\n";
}
$newstext[$i] .= "\n[i]Quelle: [URL=http://".$news[$i]['name']."]".$news[$i]['name']."[/URL][/i]\n\n";
$newstext[$i] .= "[m]Dieser Beitrag wurde automatisch erstellt.[/m]";
}
for($i = 0;$i < count($newstext);$i++){
$db->query("INSERT INTO bb".$n."_threads (boardid,topic,iconid,starttime,starterid,starter,lastposttime,lastposterid,lastposter,closed,attachments,pollid,important,visible) VALUES ('".$boardid."','".addslashes($newstopic[$i])."','3','".$time."','".$uid."','".addslashes($uname)."','".$time."','".$uid."','".addslashes($uname)."','1','0','0','0','1')");
$threadid = $db->insert_id();
print '*** ['.date("d.m.Y H:i").'] DB->CREATE_THRED('.$threadid.'->'.$newstopic[$i].')';
print "\n";
$db->unbuffered_query("UPDATE bb".$n."_stats SET threadcount=threadcount+1", 1);
print '*** ['.date("d.m.Y H:i").'] DB->UPDATE_GLOBAL_THREADCOUNT';
print "\n";
$db->query("INSERT INTO bb".$n."_posts (parentpostid,threadid,userid,username,iconid,posttopic,posttime,message,attachments,allowsmilies,allowhtml,allowbbcode,allowimages,showsignature,ipaddress,visible) VALUES "."('0','".$threadid."','".$uid."','".addslashes($uname)."','3','".addslashes($newstopic[$i])."','".$time."','".addslashes($newstext[$i])."','0','0','0','1','0','0','127.0.0.1','1')");
$postid = $db->insert_id();
print '*** ['.date("d.m.Y H:i").'] DB->CREATE_POST('.$threadid.'->'.$postid.')';
print "\n";
$db->unbuffered_query("UPDATE bb".$n."_stats SET postcount=postcount+1", 1);
print '*** ['.date("d.m.Y H:i").'] DB->UPDATE_GLOBAL_POSTCOUNT';
print "\n";
$db->unbuffered_query("UPDATE bb".$n."_boards SET threadcount=threadcount+1, postcount=postcount+1, lastthreadid='".$threadid."', lastposttime='".$time."', lastposterid='".$uid."', lastposter='".addslashes($uname)."' WHERE boardid IN (".$boardid.")", 1);
print '*** ['.date("d.m.Y H:i").'] DB->UPDATE_BOARD('.$boardid.')';
print "\n";
}
?>
|