on viewtopic.php
find
Code: Select all
<?php
Code: Select all
function get_parse($text) {
$text = preg_replace("/<!-- m --><a class=\"postlink\" href=\"http:\/\/www\.imdb\.com\/title\/[a-zA-Z0-9]*\/\">/",
"", $text);
$text = preg_replace("/<\/a><!-- m -->/", "", $text);
$imdb_regex = "/http:\/\/www\.imdb\.com\/title\/[a-zA-Z0-9]+\//";
preg_match($imdb_regex, $text, $matches);
for ($i = 0; isset($matches[$i]); $i++){
$url = $matches[$i];
}
//get the page content
$imdb_content = get_data($url);
//parse for product name
$name = get_match('/<title>(.*)<\/title>/isU', $imdb_content);
$director = strip_tags(get_match('/<h5[^>]*>Director:<\/h5>(.*)<\/div>/isU', $imdb_content));
$plot = get_match('/<h5[^>]*>Plot:<\/h5>(.*)<\/div>/isU', $imdb_content);
$release_date = get_match('/<h5[^>]*>Release Date:<\/h5>(.*)<\/div>/isU', $imdb_content);
$mpaa = get_match('/<a href="\/mpaa">MPAA<\/a>:<\/h5>(.*)<\/div>/isU', $imdb_content);
$run_time = get_match('/Runtime:<\/h5>(.*)<\/div>/isU', $imdb_content);
$image_link = get_match("#<link rel=\"image_src\" href=\"(.*)\">#Ui", $imdb_content);
//build content
$content .= "<div style='display:block;background-color:#FFF;border:1px solid black;padding:5px;'>";
$content .= "<table><tr><td align=\"center\">" . $name . "<br>";
$content .= "<img src=" . $image_link . "></img></td>";
$content .= "<td>" . $director . "<br>";
$content .= substr($plot, 0, strpos($plot, '<a')) . "</div><br>";
$content .= substr($release_date, 0, strpos($release_date, '<a')) . "</div><br>";
$content .= $mpaa . "<br>";
$content .= $run_time . "</div><br>";
$content .= $url . "<br></td></tr></table></div>";
return preg_replace("/http:\/\/www\.imdb\.com\/title\/[a-zA-Z0-9]+\//", $content, $text,1);
}
//gets the match content
function get_match($regex, $content) {
preg_match($regex, $content, $matches);
return $matches[1];
}
//gets the data from a URL
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
find
Code: Select all
'MESSAGE' => $message,
Code: Select all
'MESSAGE' => get_parse($message),
and their is one imdb per post, it can be on code or just as text.