". $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('/(.*?)<\/a>(.*?)<\/td>/i', $block, $imdbMovies); foreach($imdbMovies[1] as $key => $value){ $SearchData[] = array("id" => $value, "name" => $imdbMovies[2][$key], "help" => str_replace(" aka","
    ",strip_tags($imdbMovies[3][$key])), "cat" => '- ' . $categoryBlocks[1][$currentBlock]); } $currentBlock++; } } else { $out .= $GLOBALS['strErrNothingFoundEnterNewString']; return(PML_FETCH_SEARCHDONE); } $out .= $GLOBALS['strFoundMore']; //print out all the movies found: $out .= ""; $Page = basename(__FILE__); $Page = substr($Page, 6); $Page = substr($Page, 0, -4); $LastCat = ""; foreach($SearchData as $Dat) { if($Dat['cat']!=$LastCat) { $out .= "\n"; $j=1; } $LastCat = $Dat['cat']; $out .= "\n"; } $out .= "
$Dat[cat]
 "; $out .= "$Dat[name]"; $out .= " - [$GLOBALS[strInfo]]\n"; if(strlen($Dat['help'])>2) $out .= "". $Dat['help'] .""; $out .= "
"; return(PML_FETCH_SEARCHDONE); } /** * GetCachedPage * * downloaded a given url with a given referrer, uses caching from fetch-class * * @param string the url to fetch * @param string the Referrer (default-value is set here) **/ function GetCachedPage($Url, $Referer="http://akas.imdb.com/") { return($this->fetchCachedUrl($Url, "akas.imdb.com", $Referer)); } /** * DoFetch - perform the search on the page to fetch from * * IMPORTANT if you want to add some feilds: * if you add new fields, add them to var $FieldNames on top of this file * * @param string the fetched value (return-string) * @param string the FieldName * @access public * @return const PML_FETCH_ERROR, PML_FETCH_OK or PML_FETCH_ITEMNOTFOUND **/ function DoFetch(&$ret, $FieldName) { global $CFG; switch($FieldName) { case "Title": //fetch Title //get this url, cached if allready used: $site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find"); //regular-expresstion to filter out the field //if(!preg_match('/
#msi', $site, $gen)) { return(PML_FETCH_ERROR); } $gen = $gen[1]; $ret = array(); while(eregi("([a-zA-Z\\-]*)", $gen, $x)) { $gen = substr($gen,strpos($gen,$x[0])+strlen($x[0])); $ret[] = addslashes($x[1]); } if(sizeof($ret)==0) { return(PML_FETCH_ERROR); } break; case "Rating": $site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find"); #if(!eregi('([0-9]).([0-9])/10.*\([0-9,]+ votes\)', $site, $x)) { if(!eregi('([0-9]).([0-9])/10', $site, $x)) { return(PML_FETCH_ERROR); } $ret = $x[1].$x[2]; $ret = $ret/10; break; case "Starring": $site = $this->GetCachedPage("/title/tt$this->FetchID/", "http://akas.imdb.com/Find"); $ret = array(); $i=0; //Modified July 4 2009 by Marco Nierlich to be in line with IMDB changes #while(eregi('([^<]*)', $site, $x)) { while(eregi('/castlist\/([^<]*)\/*\';">([^<]*)<\/a><\/td> ... <\/td>', $site, $x)) { $i++; if($i>$this->actorLimit) break; $site = substr($site,strpos($site,$x[0])+strlen($x[0])); $ret[] = addslashes($x[2]); } if(sizeof($ret)==0) { return(PML_FETCH_ERROR); } break; case "Plot": $site = $this->GetCachedPage("/title/tt$this->FetchID/plotsummary", "http://akas.imdb.com/title/tt$this->FetchID/"); if(eregi('

([^<]*)', $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; } } } ?>