". $SearchString . " ... "; //$Name = rawurlencode($SearchString); //$Name = str_replace("%20", "+", $SearchString); $extra = " xx"; $SearchString = $SearchString.$extra; echo $SearchString; //Modified July 5th 2007 to comply with imdb url changes $data = "GET /find?s=all&q=". rawurlencode($SearchString) .";tt=on;mx=20 HTTP/1.0\r\n"; $data .= "Accept: text/html, image/png, image/x-xbitmap, image/gif, image/jpeg, */*\r\n"; $data .= "Referer: http://akas.imdb.com/Find\r\n"; $data .= "Content-type: application/x-www-form-urlencoded\r\n"; $data .= "Accept-Encoding: *;q=0\r\n"; $data .= "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)\r\n"; $data .= "Host: akas.imdb.com\r\n"; $data .= "Connection: Keep-Alive\r\n"; $data .= "Cache-Control: no-cache\r\n"; $data .= "\r\n"; $site = $this->FetchPage($data, "akas.imdb.com:80"); $sections = preg_split("/Names \(Exact Matches\)/i", $site); // $sections[0]: part with movie matches // [1]: part with actor matches $site = $sections[0]; //when you use the search-form on imdb.com and you search for a title that was exactly found //imdb uses a 302-found-page to redirect to the Title-page of this movie. //if this happens, we can use this imdb-id too if(strstr($site, "HTTP/1.0 302") || strstr($site, "HTTP/1.1 302")) { //exact match? $out .= $GLOBALS['strExactMatch']; ereg('\/title\/tt([0-9]+)\/', $site, $x); $this->FetchID = $x[1]; //save the id in $FetchID return(PML_FETCH_EXACTMATCH); //return to editentry that it can fetch now the data - search is allready done } //Modified July 5th 2007 to comply with imdb format changes $tlBlocks = preg_match_all('/(P?o?p?u?l?a?r? ?Titles.*?<\/b>).*?<\/p>/msi', $site, $categoryBlocks); if ($tlBlocks > 0) { //$categoryBlocks contain movies from "Popular Titles" and/or "Exact Matches" and/or "Partial Matches" $currentBlock = 0; $SearchData = array(); // remove text "Titles" and () from the category-names $categoryBlocks[1] = preg_replace('/(Titles \()|\)|;/i','',$categoryBlocks[1]); //Modified July 5th 2007 to comply with imdb format changes foreach($categoryBlocks[0] as $block){ preg_match_all('/
$Dat[cat] | |
"; $out .= "$Dat[name]"; $out .= " - [$GLOBALS[strInfo]]\n"; if(strlen($Dat['help'])>2) $out .= "". $Dat['help'] .""; $out .= " |
([^<]*)', $site, $x)) {
//plot exists:
$ret = addslashes($x[1]);
break;
}
//plot doesn't exist, use plot-outline from title-page:
$site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find");
if (preg_match("#Plot Outline:
([^<]*)#", $site, $x)) {
$ret = addslashes($x[1]);
break;
}
//plot doesn't exist, use plot-summary from title-page:
if (preg_match("#Plot Summary:
([^<]*)#", $site, $x)) {
$ret = addslashes($x[1]);
break;
}
// if there's no plot outline fetch tagline.
if(!preg_match("#Tagline:
([^<]*)#", $site, $x)) {
$ret = addslashes($x[1]);
break;
}
//error, no plot found
return(PML_FETCH_ERROR);
case "Release":
// Marco Nierlich: 15.02.2010 changes....
//$site = $this->GetCachedPage("/title/tt$this->FetchID/releaseinfo", "http://akas.imdb.com/title/tt$this->FetchID/");
$site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find");
$convert["January"]="01";
$convert["February"]="02";
$convert["March"]="03";
$convert["April"]="04";
$convert["May"]="05";
$convert["June"]="06";
$convert["July"]="07";
$convert["August"]="08";
$convert["September"]="09";
$convert["October"]="10";
$convert["November"]="11";
$convert["December"]="12";
// change of imdb date string
//if(!eregi(']*>([^<]*)", $site, $year)) {
// return(PML_FETCH_ERROR);
//}
//$ret = $year[1] . "-" . $convert[$date[2]] . "-" . $date[1];
// if(!eregi('Release Date:
[^>]*>([0-9]+) ([A-Za-z]+) ([0-9]+)', $site, $date)) {
if(!eregi('Release Date:
[^%]*([0-9]+) ([A-Za-z]+) ([0-9]{4})', $site, $date)) {
return(PML_FETCH_ERROR);
}
$ret = $date[3] . "-" . $convert[$date[2]] . "-" . $date[1];
break;
case "imdbid":
$ret = $this->FetchID;
break;
case "Runtime":
$site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find");
if(!preg_match('#Runtime:
\n([0-9]+) min#i', $site,$x)) {
return(PML_FETCH_ERROR);
}
$ret = $x[1];
$ret = addslashes($ret);
break;
case "MPAA":
$site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find");
if(!preg_match('#MPAA:
Rated ([^ ]+) for (.+).
#i', $site,$x)) {
return(PML_FETCH_ERROR);
}
$ret = $x[1];
$ret = addslashes($ret);
break;
case "Akas":
$site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find");
$ret = array();
if(eregi('Also Known As
(.*)MPAA:
',$site, $y)) {
$site = $y[0];
while(eregi(']*)>([^<]*)', $site, $x)) {
if(eregi($this->akaCountry, $x[2]))
$ret[] = addslashes(str_replace(" ", " ", $x[2]));
$site = substr($site,strpos($site,$x[0])+strlen($x[0]));
}
}
if(sizeof($ret)==0) {
return(PML_FETCH_ERROR);
}
break;
case "Country":
$site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find");
$ret = array();
while(eregi(' Actors to fetch\n";
return($out);
case "Akas":
if($set=="") $set="USA";
$out = " Aka(s) to fetch\n";
return($out);
}
}
/**
* saveSettings
*
* processes the $_GET-stuff and validates it and then moves it into
* one string that will be saved in the database (only one field is
* avaliable for saving the data!
*
* @access public
* @param string the field
* @return string the string that will be saved in the db
**/
function saveSettings($field) {
switch($field) {
case "Starring":
return($_POST['set'.$field]);
case "Akas":
return($_POST['set'.$field]);
default:
return("");
}
}
/**
* setSetting
*
* will be called from editentry.php bevore calling DoFetch
* (only if $set is not empty)
* There shoud the setting be processed and saved into some
* class-vars...
*
* @access public
* @param string
* @param string the field
**/
function setSettings($field, $set) {
switch($field) {
case "Starring":
if($set=="" || $set==0) $set="3";
$this->actorLimit = $set;
break;
case "Akas":
if($set=="") $set="USA";
$this->akaCountry = $set;
break;
}
}
}
?>