<?php
error_reporting(false);
set_time_limit(0);
if (!defined('BB_ROOT')) die(basename(__FILE__));
require(INC_DIR .'bbcode.php');
require(INC_DIR .'functions_post.php');
for($i=0; $i < 1; $i++)
{
$content = file_get_contents('http://www.3dnews.ru/news');
$content = html_entity_decode($content);
preg_match_all('#<a name=".*?"></a><a class="entry-header" href="/(.*?)"><h1>(.*?)</h1></a>#', $content, $content);
for($c=0; $c < count($content[1]); $c++)
{
$subject = addslashes($content[2][$c]);
if(DB()->fetch_row("SELECT topic_id FROM ". BB_TOPICS ." WHERE topic_title = '$subject'")){}
else
{
$contents = file_get_contents('http://www.3dnews.ru/'.$content[1][$c]);
preg_match_all('#<div class="entry-body _ga1_on_" itemprop="articleBody">([\s\S]*?)<ul class="related">#', $contents, $source, PREG_SET_ORDER);
$message = $source[0][1];
if($message)
{
$message = preg_replace('#<p><strong>Материалы по теме:</strong></p>#', '', $message);
$message = preg_replace("/<img src=\"(.*?)\" .*?>/", build_image('$1'), $message);
$message = preg_replace('/<a href=\"(.*?)\" style="font-size: 10pt;>(.*?)<\/a>/', "[url=\\1]\\2[/url]", $message);
$message = preg_replace('/<iframe frameborder="0" height="396" src=\"(.*?)\" width="720" allowfullscreen=""><\/iframe>/', "$1", $message);
$message = str_replace('<b>', '[b]', $message);
$message = str_replace('</b>', '[/b]', $message);
$message = str_replace('<s>', '[s]', $message);
$message = str_replace('</s>', '[/s]', $message);
$message = str_replace('<u>', '[u]', $message);
$message = str_replace('</u>', '[/u]', $message);
$message = str_replace('<i>', '[i]', $message);
$message = str_replace('<i>', '[/i]', $message);
$message = str_replace('<br>', '[br]', $message);
$message = str_replace('<p>', '', $message);
$message = str_replace('</p>', '', $message);
$message = str_replace('amp;', '', $message);
$message = preg_replace('#<marker >.*?</marker>#', '', $message);
$message = preg_replace('#<noindex>.*?</noindex>#', '', $message);
$message = '[size=14]'. $message .'[/size]';
if($message = addslashes(strip_tags($message)))
{
submit_topic($subject, $message, 4);
}
}
else
{
}
unset($message);
}
}
}
for($a=0; $a < 1; $a++)
{
$content = file_get_contents('http://www.3dnews.ru/software-news');
$content = html_entity_decode($content);
preg_match_all('#<a name=".*?"></a><a class="entry-header" href="/(.*?)"><h1>(.*?)</h1></a>#', $content, $content);
for($b=0; $b < count($content[1]); $b++)
{
$subject = addslashes($content[2][$b]);
if(DB()->fetch_row("SELECT topic_id FROM ". BB_TOPICS ." WHERE topic_title = '$subject'")){}
else
{
$contents = file_get_contents('http://www.3dnews.ru/'.$content[1][$b]);
preg_match_all('#<div class="entry-body _ga1_on_" itemprop="articleBody">([\s\S]*?)<ul class="related">#', $contents, $sources, PREG_SET_ORDER);
$message = @$sources[0][1];
if($message)
{
$message = preg_replace('#<p><strong>Материалы по теме:</strong></p>#', '', $message);
$message = preg_replace("/<img src=\"(.*?)\" .*?>/", build_image('$1'), $message);
$message = preg_replace('/<a href="([\s\S]*?)" style="font-size: 10pt;>(.*?)<\/a>/', "[url=\\1]\\2[/url]", $message);
$message = preg_replace('/<iframe frameborder="0" height="396" src=\"(.*?)\" width="720" allowfullscreen=""><\/iframe>/', "$1", $message);
$message = str_replace('#<marker>#', '', $message);
$message = str_replace('#</marker>#', '', $message);
$message = str_replace('<b>', '[b]', $message);
$message = str_replace('</b>', '[/b]', $message);
$message = str_replace('<s>', '[s]', $message);
$message = str_replace('</s>', '[/s]', $message);
$message = str_replace('<u>', '[u]', $message);
$message = str_replace('</u>', '[/u]', $message);
$message = str_replace('<i>', '[i]', $message);
$message = str_replace('<i>', '[/i]', $message);
$message = str_replace('<br>', '[br]', $message);
$message = str_replace('<p>', '', $message);
$message = str_replace('</p>', '', $message);
$message = str_replace('amp;', '', $message);
$message = preg_replace('#<noindex>.*?</noindex>#', '', $message);
$message = '[size=14]'. $message .'[/size]';
if($message = addslashes(strip_tags($message)))
{
submit_topic($subject, $message, 4);
}
}
else
{
}
unset($message);
}
}
}
function build_image($url)
{
$url = trim($url);
$url = str_replace(' ','%20', $url);
return "[align=center][img]".$url."[/img][/align]";
}
function submit_topic($subject, $message, $forum_id)
{
global $bb_cfg, $userdata, $datastore;
$user_ip = USER_IP;
$user_id = -746;
$time = TIMENOW+1;
$t_data = DB()->fetch_row("SELECT f.* FROM ". BB_FORUMS ." f WHERE f.forum_id = $forum_id");
DB()->query("INSERT INTO ". BB_TOPICS ." (topic_title, topic_poster, topic_time, forum_id, topic_last_post_time) VALUES ('$subject', '$user_id', '$time', '$forum_id', '$time')");
$topic_id = DB()->sql_nextid();
DB()->query("INSERT INTO ". BB_POSTS ." (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ($topic_id, $forum_id, '$user_id', '$time', '$user_ip')");
$post_id = DB()->sql_nextid();
DB()->query("UPDATE ". BB_TOPICS ." SET topic_first_post_id = $post_id, topic_last_post_id = $post_id WHERE topic_id = $topic_id");
$message = prepare_message($message, 1, 1);
DB()->query("INSERT INTO ". BB_POSTS_TEXT ." (post_id, post_text) VALUES ($post_id, '$message')");
DB()->query("UPDATE ". BB_FORUMS ." SET forum_posts = forum_posts + 1, forum_last_post_id = $post_id, forum_topics = forum_topics + 1 WHERE forum_id = $forum_id");
add_search_words($post_id, stripslashes($message), stripslashes($subject));
update_post_stats('newtopic', $t_data, $forum_id, $topic_id, $post_id, $user_id);
update_post_html(array(
'post_id' => $post_id,
'post_text' => $message,
));
}