Log in

View Full Version : Grabbing info from a url...


wolfe
06-13-2007, 12:57 PM
is it possible to grab certain information from a url that is entered in a forum and insert the collected info into the database.

urgently needed.

also is it possible to upload files and when they are downloaded they can be compressed such as download as zip / rar ?

thx.

wolfe
06-15-2007, 08:58 AM
anyone able to help

heres the functions is it possilble for anyone to fix it to work.


function getIMDbInfo($title)
{
global $vbulletin;

$movie=searchIMDb($title);

$movie_title=$movie['aResult'][0][0];
$movie_id=$movie['aResult'][0][1];
$movie_year=$movie['aResult'][0][2];

if($movie['title_or_find']) {
$movie=$movie['aResult'];
$movieurl="http://www.imdb.com/title/".$movie_id."/";
}
else {
$movie=$movie['aResult'];
$movieurl="http://www.imdb.com/find?q=".urlencode($title)."/";
}

$content=file_get_contents($movieurl);
$poster_delim1="title=\"".twoDelimitersIMDb($content, "<title>", " (")."\" src=\"";

if(!$movie['title_or_find']) {
$movie_title=twoDelimitersIMDb($content, "<title>", " (");
$movie_id=preg_match("/title\/tt([0-9]*)\//", $content);
$movie_year=fulhackIMDb($content, "/Sections/Years/", "</a>");

//id
$pattern_id="/title\/tt([0-9]*)\/ratings/";
preg_match($pattern_id, $content, $movie_id);
$movie_id="tt".$movie_id[1];
}

//--plot----------------------------------------
$pattern_summary="/\<b class=\"ch\"\>Plot Summary\:/";
$pattern_outline="/\<b class=\"ch\"\>Plot Outline:/";


if(preg_match($pattern_summary, $content)||preg_match($pattern_outline, $content)) {
$pattern_plotsummary="/plotsummary\/title\/".$movie_id."\/plotsummary/";
$pattern_morelank="/plotsummary\"\>\(more\)\<\/a\>/";
if(preg_match($pattern_plotsummary, $content)) {
$content_plot=file_get_contents("http://www.imdb.com/title/".$movie_id."/plotsummary");
$plot=twoDelimitersIMDb($content_plot, "<p class=\"plotpar\">", "</p>");
}
else {
if(preg_match($pattern_outline, $content)) {
$plot=twoDelimitersIMDb($content, "Plot Outline:</b>", "<");
}
else if(preg_match($pattern_summary, $content)) {
$plot=twoDelimitersIMDb($content, "Plot Summary:</b>", "<");
}
}
}


//----------------------------------------------
$array=array(
"title" => $movie_title,
"id" => $movie_id,
"plot" => $plot,
);

return $array;
}



function searchIMDb($sTitle) {
$sPage = file_get_contents($sTitle);

$aResult = array();
if(preg_match("/IMDb Search/", $sPage)) {
preg_match_all("/<a href=\"\/title\/([^\/]*)\/([^>]*)>([^<]*)<\/a> \(([0-9]*)\)([^\<]*)/i", $sPage, $aMatches);
$nLen = count($aMatches[0]);

for($i = 0;$i < $nLen;$i++) {

$sType = trim($aMatches[5][$i]);

if($sType != "") {
continue;
}

$aResult[] = array($aMatches[3][$i], $aMatches[1][$i], $aMatches[4][$i]);
}

$id=$aResult[0][1];
$movieurl="http://www.imdb.com/title/".$id."/";
$result=array(
"aResult" => $aResult,
"title_or_find" => 1,
);
}

else {
$movieurl="http://www.imdb.com/find?q=".urlencode($sTitle)."/";
$result=array(
"aResult" => $aResult,
"title_or_find" => 0,
);
}

return $result;
}



function twoDelimitersIMDb($content, $delim1, $delim2) {
$len1=strlen($delim1);
if(strpos($content, $delim1)) {
$start=strpos($content, $delim1)+$len1;
$end=strpos(substr($content, $start), $delim2)+$start;
$length=$end-$start;
$content=substr($content, $start, $length);
}

if(!preg_match("/imdb\-online/", $content)) {
return $content;
}
}


function fulhackIMDb($content, $delim1, $delim2) {
$content=twoDelimitersIMDb($content, $delim1, $delim2);
$pos=strpos($content, ">")+1;

return substr($content, $pos);
}

$movieinfo=getIMDbInfo($_POST['imdburl']);
eval('print_output("' . fetch_template('TEST') . '");');
}