Code: Selecteer alles
<?php
//Made by Derk Vedelaar
//Version 1.5
$config['GebruikersID']='2'; //The user id of the user which will post the news.
$config['IP_adres']='127.0.0.1'; //the ip address of the user whick will post the news (choose anything you like)
$config['ForumID']='15'; //the id of the forum the news will be posted in
$config['IcoonID']='0'; //The id of the icon in front of the topics of the news
$config['Enable_BB']='1'; //check the checkbox 'ebable bb code' in every post? (if you change this the bot won't work correct anymore)
$config['Enable_smileys']='1'; //check the checkbox "enable smileys" in ervery post?
$config['Enable_magicurl']='1'; //Same as above but for magic url
$config['Enable_onderschrift']='1'; //same as above but for signature
$config['RSS_feed']='http://feeds.feedburner.com/tweakers/mixed'; //url to the rss feed of your choice
$config['Start_bericht']='0'; //Where does the bot need to start posting? (0 is standard, choose 1 or 2 if the feed has spam on top of it)
$config['Eind bericht']='39'; //where does the bot need to stop posting from the feed? (9 is standard, choose a lower one if here aren't 10 news items in the feed)
$config['Titel_begin']='0'; //Choose the character where the topic title needs to begin with (0 is standard, choose a higher one if there is spam at the beginning of a topic title)
$config['Onderwerp_grootte']='100'; //Don't change, if you change, the bot won't work correctly anymore (this is the size of the subject field in the database)
$config['HTML_toestaan']='1'; //The html codes which are accepted in the forum and which you accept in the news items
$config['maak_utf8']=0; //make it 1 if you have problems with óöòê or some of this characters. Don't make it 1 if you don't need to.
$config['maak_ISO-8859-1']=1; //make it 1 if you have problems with óöòê or some of this characters. Don't make it 1 if you don't need to.
$config['Charset']='ISO-8859-1'; //The character set of the feed. ISO-8859-1 is standard.
$config['Title_nopost']=array('ADV'); //An array with topic titles (or first characters only) which won't be posted (in case the feed has spam on random locations)
$config['Charset_fix']=0; //Fixes some problems with '". Don't make it 1 if you don't need to.
$config['Beschrijving']='description'; //How is the description field called in the feed?
$config['Titel']='title'; //How is the title field called in the feed?
$config['Link']='link'; //how is the link field called in the feed?
error_reporting(0);
if(!require_once('config.php'))
{
exit('Kon config bestand niet laden.');
}
if(!mysql_connect($dbhost,$dbuser,$dbpasswd))
{
exit('Kon geen connectie maken met de database server.');
}
if(!mysql_select_db($dbname ))
{
exit('Kon de database niet vinden.');
}
$gebruikersqry = mysql_query('SELECT user_colour, username FROM '.$table_prefix.'users WHERE user_id=\''.$config['GebruikersID'].'\'') or die(mysql_error());
list($Gebruikerskleur,$Gebruikersnaam) = mysql_fetch_row($gebruikersqry);
$tijd=time();
$bbcodeuid='Derk'.rand(0,9);
$posts=0;
$xml_feed = file_get_contents($config['RSS_feed']);
if ($config['maak_ISO-8859-1'])
{
$xml_feed=utf8_decode($xml_feed);
}
if ($config['maak_utf8'])
{
$xml_feed=utf8_encode($xml_feed);
}
$xml_praser = xml_parser_create($config['Charset']);
xml_parser_set_option($xml_praser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($xml_praser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($xml_praser,$xml_feed,$xml_inh,$xml_tags);
xml_parser_free($xml_praser);
for ($i=0; $i < count($xml_tags['item']); $i+=2)
{
$eerste = $xml_tags['item'][$i] + 1;
$tweede = $xml_tags['item'][$i + 1] - $eerste;
$item=array_slice($xml_inh,$eerste,$tweede);
for ($j=0; $j < count($item); $j++)
{
if (!isset($arr[$i/2][$item[$j]['tag']]))
{
$teller[$item[$j]['tag']]=1;
if ($config['Charset_fix']==1)
{
$item[$j]['value']=html_entity_decode($item[$j]['value'],ENT_NOQUOTES);
}
$arr[$i/2][$item[$j]['tag']]=$item[$j]['value'];
}
else
{
$teller[$item[$j]['tag']]++;
if ($config['Charset_fix']==1)
{
$item[$j]['value']=html_entity_decode($item[$j]['value'],ENT_NOQUOTES);
}
$arr[$i/2][$item[$j]['tag'].$teller[$item[$j]['tag']]]=$item[$j]['value'];
}
}
}
for ($i = $config['Start_bericht']; $i <= $config['Eind bericht']; $i++)
{
foreach($config['Title_nopost'] as $val)
{
if ($val==substr($arr[$i][$config['Titel']],0,strlen($val)))
{
unset($arr[$i]);
break;
}
}
}
for ($i = $config['Start_bericht']; $i <= $config['Eind bericht']; $i++)
{
$titel = substr($arr[$i][$config['Titel']], $config['Titel_begin'], $config['Onderwerp_grootte']);
if ($titel!='')
{
$titel=mysql_real_escape_string(strip_tags($titel,$config['HTML_toestaan']));
$postsqry = mysql_query('SELECT topic_title FROM '.$table_prefix.'topics WHERE topic_title=\''.$titel.'\' AND forum_id=\''.$config['ForumID'].'\'') or die(mysql_error());
if (mysql_num_rows($postsqry) == 0)
{
$bericht=mysql_real_escape_string(strip_tags($arr[$i][$config['Beschrijving']],$config['HTML_toestaan']));
$link=mysql_real_escape_string(strip_tags($arr[$i][$config['Link']],$config['HTML_toestaan']));
$bericht=$bericht.'<br /><br />[url='.$link.':'.$bbcodeuid.']Lees meer[/url:'.$bbcodeuid.']';
mysql_query('INSERT INTO '.$table_prefix.'topics (forum_id, icon_id, topic_title, topic_poster, topic_time, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time,topic_replies,topic_replies_real)VALUES("'.$config['ForumID'].'", "'.$config['IcoonID'].'", "'.$titel.'", "'.$config['GebruikersID'].'", "'.$tijd.'", "'.$config['GebruikersID'].'", "'.$Gebruikersnaam.'", "'.$Gebruikerskleur.'", "'.$config['GebruikersID'].'", "'.$Gebruikersnaam.'", "'.$Gebruikerskleur.'", "'.$titel.'", "'.$tijd.'", "'.$tijd.'", "0", "0")') or die(mysql_error());
$topic_id=mysql_insert_id();
mysql_query('INSERT INTO '.$table_prefix.'posts (topic_id, forum_id, poster_id, icon_id, poster_ip, post_time, enable_bbcode, enable_smilies, enable_magic_url, enable_sig, post_username, post_subject, post_text, post_checksum, bbcode_uid, bbcode_bitfield)VALUES("'.$topic_id.'", "'.$config['ForumID'].'", "'.$config['GebruikersID'].'", "'.$config['IcoonID'].'", "'.$config['IP_adres'].'", "'.$tijd.'", "'.$config['Enable_BB'].'", "'.$config['Enable_smileys'].'", "'.$config['Enable_magicurl'].'", "'.$config['Enable_onderschrift'].'", "'.$Gebruikersnaam.'", "'.$titel.'", "'.$bericht.'", "'.md5($bericht).'", "'.$bbcodeuid.'", "EA==")') or die(mysql_error());
$post_id=mysql_insert_id();
mysql_query('UPDATE '.$table_prefix.'topics SET topic_first_post_id="'.$post_id.'", topic_last_post_id="'.$post_id.'" WHERE topic_id="'.$post_id.'"') or die(mysql_error());
mysql_query('INSERT INTO '.$table_prefix.'topics_posted (user_id, topic_id, topic_posted)VALUES(\''.$config['GebruikersID'].'\', \''.$topic_id.'\', \'1\')') or die(mysql_error());
$posts=$posts+1;
}
}
}
if ($posts!=0)
{
mysql_query('UPDATE '.$table_prefix.'users SET user_posts=user_posts+'.$posts.', user_lastpost_time="'.$tijd.'", user_lastvisit="'.$tijd.'" WHERE user_id="'.$config['GebruikersID'].'"') or die(mysql_error());
mysql_query('UPDATE '.$table_prefix.'forums SET forum_posts=forum_posts+'.$posts.', forum_topics_real=forum_topics_real+'.$posts.', forum_topics=forum_topics+'.$posts.', forum_last_post_id="'.$post_id.'", forum_last_poster_id="'.$config['GebruikersID'].'", forum_last_post_subject="'.$titel.'", forum_last_post_time="'.$tijd.'", forum_last_poster_name="'.$Gebruikersnaam.'", forum_last_poster_colour="'.$Gebruikerskleur.'" WHERE forum_id="'.$config['ForumID'].'"') or die(mysql_error());
mysql_query('UPDATE '.$table_prefix.'config SET config_value=config_value+'.$posts.' WHERE config_name="num_posts"') or die(mysql_error());
mysql_query('UPDATE '.$table_prefix.'config SET config_value=config_value+'.$posts.' WHERE config_name="num_topics"') or die(mysql_error());
}
?>