--- imdb.class.php 2007-12-26 00:18:48.000000000 +0100 +++ imdb/imdb.class.php 2007-12-26 00:30:10.000000000 +0100 @@ -92,6 +92,7 @@ $temp .= fread ($fp, 1024); $this->page[$wt] = $temp; } + fclose($fp); return; } } // end cache @@ -204,12 +205,9 @@ if ($this->page["Title"] == "") { $this->openpage ("Title"); } - $this->main_title = strstr ($this->page["Title"], ""); - $endpos = strpos ($this->main_title, ""); - $this->main_title = substr ($this->main_title, 7, $endpos - 7); - $year_s = strpos ($this->main_title, "(", 0); - $year_e = strpos ($this->main_title, ")", 0); - $this->main_title = substr ($this->main_title, 0, $year_s - 1); + $startpos = strpos($this->page["Title"], ""); + $endpos = strpos($this->page["Title"], ""); + $this->main_title = substr($this->page["Title"], $startpos + 7, $endpos - $startpos - 7); } return $this->main_title; } @@ -223,13 +221,12 @@ if ($this->page["Title"] == "") { $this->openpage ("Title"); } - $this->main_year = strstr ($this->page["Title"], ""); - $endpos = strpos ($this->main_title, ""); - $this->main_year = substr ($this->main_year, 7, $endpos - 7); - $year_s = strpos ($this->main_year, "(", 0); - $year_e = strpos ($this->main_year, ")", 0); - $this->main_year = substr ($this->main_year, $year_s + 1, $year_e - $year_s - 1); + $startpos = strpos($this->page["Title"], ""); + $endpos = strpos($this->page["Title"], ""); + $this->main_title = substr($this->page["Title"], $startpos + 7, $endpos - $startpos - 7); + preg_match_all("/([0-9]{4})/", $this->main_title, $year, PREG_SET_ORDER); } + $this->main_year = $year[0][sizeof($year[0])-1]; return $this->main_year; } @@ -803,6 +800,7 @@ } fputs ($fp2, $fp); + fclose($fp2); return TRUE; }