WinFuture-Forum.de: Rss Feed --> Wbb [an Die Php Guru's] - WinFuture-Forum.de

Zum Inhalt wechseln

Nachrichten zum Thema: Entwicklung
Seite 1 von 1

Rss Feed --> Wbb [an Die Php Guru's]


#1 Mitglied ist offline   kai_fischer 

geschrieben 04. September 2006 - 21:15

Hi,

ich habe folgendes Script:

<?PHP

//include
require("global.php");

//configuration

//boardid of the board in which we want to post our RSSImport
$boardid = 1;			 

//userid of the poster (0 eq GUEST)
$uid = 1;					  

//if $uid != 0 then the nick of the user with $uid else any nick.
$uname = "user";		 

//add your rssurls here - just 2 examples:
$sites[] = "http://www.url.de/rss.xml";

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] .= "[b][i]Dieser Beitrag wurde automatisch erstellt![/i][/b]";
}
for($i = 0;$i < count($newstext);$i++){
	$db->query("INSERT INTO bb".$n."_threads (boardid,topic,iconid,starttime,starterid,start
er,lastposttime,lastposterid,lastposter,closed,att
achments,pollid,important,visible) VALUES ('".$boardid."','".addslashes($newstopic[$i])."','3','".$time."','".$uid."','".addslashes($uname)."','".$time."','".$uid."','".addslashes($uname)."','0','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,p
osttopic,posttime,message,attachments,allowsmilies
,allowhtml,allowbbcode,allowimages,showsignature,i
paddress,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";
}		
?>


Script beschreibung:

Wenn man das Script aufruft, wird in dem oben angegebenem Forum ein Thread mit den Rss Feed News erstellt.


Mein Problem:

Alle Rss feed news werden in einen Thread geposted, ich hätte jedoch pro news einen extra thread.



Warum brauche ich Hilfe?

Weil ich in PHP noch nicht groß durchblicke und bisher noch nicht die zeit gefunden habe bei video2brain weiter als php schleifen zu kommen


Währe nett wenn mir jemand helfen könnte!
0

Anzeige



Thema verteilen:


Seite 1 von 1

1 Besucher lesen dieses Thema
Mitglieder: 0, Gäste: 1, unsichtbare Mitglieder: 0