/*-------------------------------------------------------------------------*/ // regex_parse_imdb: cria a caixinha do imdb /*-------------------------------------------------------------------------*/ var $imdb_count = 0; function regex_parse_imdb($texto="") { global $imdb_count; // Change this to your like $imdb_toptext = 'IMDB'; // Title of the IMDB-Box $imdb_perpost = 1; // maximum number of imdb tags allowed per post // Stop editing here if ($texto == "") return; $imdb_count++; if ($imdb_count > $imdb_perpost) return; $idfilme = preg_replace('/[^0-9]/i',"\\1",$texto); if (strlen($idfilme) != 7) { $this->error = 'imdb_nao7'; return; } $imdb_style = $this->wrap_style('quote'); $imdb_url = "http://imdb.com/title/tt".$idfilme."/"; $imdb = @fopen($imdb_url, "r"); if ($imdb == FALSE) { $this->error = 'imdb_invalido'; return; } while (!feof($imdb)) $imdb_raw .= fgets($imdb, 4096); fclose($imdb); preg_match ( "'<h1><strong class=\"title\">(.*?)</strong></h1>'s" , $imdb_raw , $titulo ); $titulo = str_replace("\n"," ", trim(strip_tags($titulo[1]))); preg_match ( "'Genre:</b>\\n(.*?)(\(more\)|\\n)'" , $imdb_raw , $genero ); $genero = @strip_tags($genero[1]); preg_match ( "'Tagline:</b> (.*?)( <a href|\\n)'" , $imdb_raw , $slogan ); $slogan = @$slogan[1]; preg_match ( "'Plot (Outline|Summary):</b> (.*?)( <a href=|\\n)'" , $imdb_raw , $resumo ); $resumo = @$resumo[2]; preg_match ( "'Runtime:</b>\\n(.*?)\\n<br>'" , $imdb_raw , $duracao ); $duracao = @$duracao[1]; if (strlen($duracao) > 50) $duracao = substr($duracao,0,50)."..."; preg_match ( "'User Rating:(.*?)\\n\\n(.*?)\\n(.*?)\\n<b>(.*?)/10</b> \((.*?) votes\)\\n'" , $imdb_raw , $votacao ); $votos = @$votacao[5]; $votacao = @$votacao[4]; if ($votacao >= 0) $cor = 'red'; if ($votacao >= 4) $cor = '#C8C800'; if ($votacao >= 8) $cor = 'green'; $estrelas = 4 + $votacao * 9 + log10($votacao) ; $estrelas = '<span style="position:relative; font-size: 16px; background: url(\'style_images/1/imdb_rate_full.gif\')"><img width="'.($estrelas - 1).'" height="16" src="style_images/1/tp.gif"></span><span style="font-size: 16px; background: url(\'style_images/1/imdb_rate_none.gif\') right"><img width="'.(101 - $estrelas).'" height="16" src="style_images/1/tp.gif"></span>'; preg_match ( "'top 250: (.*?)</a>'" , $imdb_raw , $top ); $top = @strip_tags($top[0]); if (isset($top)) $top = '[URL=http://imdb.com/chart/top]'.$top.'[/URL]'; preg_match ( "'Awards:</b> \\n(.*?)\\n<a href's" , $imdb_raw , $premios ); $premios = @str_replace("\n"," ",$premios[1]); preg_match ( "'(Cast overview,|Complete credited cast|Credited cast)(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)'s" , $imdb_raw , $actores ); $actores = "[url=http://imdb.com".@$actores[3]."]".@$actores[4]."[/url], ". "[url=http://imdb.com".@$actores[6]."]".@$actores[7]."[/url], ". "[url=http://imdb.com".@$actores[9]."]".@$actores[10]."[/url], ". "[url=http://imdb.com".@$actores[12]."]".@$actores[13]."[/url], ". "[url=http://imdb.com".@$actores[15]."]".@$actores[16]."[/url]"; $imdb_final = "<table border='0'><tr><td style='font-size: 13px; line-height:125%;'>"; $imdb_final .= "[B][size=4]» [url=".$imdb_url."]".$titulo."[/url][/size][/B]<br><br>"; if ($genero <> "") $imdb_final .= "[B]Genre[/B]: $genero<br>"; if ($slogan <> "") $imdb_final .= "[B]Tagline[/B]: $slogan<br>"; if ($resumo <> "") $imdb_final .= "[B]Plot Outline[/B]: $resumo<br>"; if ($votos <> "") $imdb_final .= "[B]User Rating[/B]: [COLOR=$cor][B]".$votacao."[/B][/COLOR]/10 $estrelas ($votos votes) $top<br>"; if ($duracao <> "") $imdb_final .= "[B]Runtime[/B]: $duracao<br>"; if ($premios <> "") $imdb_final .= "[B]Awards[/B]: $premios<br>"; if ($actores <> "") $imdb_final .= "[B]Cast[/B] [SIZE=1][I](first 5)[/I][/SIZE]: $actores<br>"; $imdb_final .= "<br>[B]IMDB[/B]: [url]".$imdb_url."[/url]</span></td></tr></table>"; $imdb_topo = str_replace("<div class='quotetop'>QUOTE</div>","<div class='quotetop' style='padding:0px;'><div width=100% style='background: none no-repeat right top; margin:0;padding:4px;'>$imdb_toptext</div></div>", $imdb_style['START']); return "<!--ImdbBegin".$idfilme."-->".$imdb_topo.$imdb_final.$imdb_style['END']."<!--ImdbEnd".$idfilme."-->"; }