Ejemplo n.º 1
0
/* $Id: person.php 368 2010-04-25 22:50:17Z izzy $ */
if (isset($_GET["mid"])) {
    $pid = $_GET["mid"];
    switch ($_GET["engine"]) {
        case "pilot":
            require "pilot_person.class.php";
            $person = new pilot_person($_GET["mid"]);
            $charset = "utf8";
            $source = "<A HREF='?engine=imdb&mid={$pid}'>IMDB</A> | <B CLASS='active'>MoviePilot</B>";
            if ($person->get_pilot_imdbfill()) {
                $source .= '<SUP>+i</SUP>';
            }
            break;
        default:
            require "imdb_person.class.php";
            $person = new imdb_person($_GET["mid"]);
            $charset = "iso-8859-1";
            $source = "<B CLASS='active'>IMDB</B> | <A HREF='?engine=pilot&mid={$pid}'>MoviePilot</A>";
            break;
    }
    $person->setid($pid);
    echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n";
    echo "<HTML><HEAD>\n";
    echo " <TITLE>" . $person->name() . " [IMDBPHP2 v" . $person->version . " Demo]</TITLE>\n";
    echo " <STYLE TYPE='text/css'>body,td,th { font-size:12px; font-family:sans-serif; }</STYLE>\n";
    echo "</HEAD>\n<BODY>\n<TABLE BORDER='1' ALIGN='center' STYLE='border-collapse:collapse'>";
    # Name
    echo '<TR><TH COLSPAN="3" STYLE="background-color:#ffb000">';
    echo "[IMDBPHP2 v" . $person->version . " Demo] Details for " . $person->name();
    echo "<SPAN STYLE='float:right;text-align:right;display:inline !important;font-size:75%;'>Source: [{$source}]</SPAN>";
    echo "</TH></tr>\n";
 /** Setup search results
  * @method results
  * @param optional string URL Replace search URL by your own
  * @return array results array of objects (instances of the imdb_person class)
  */
 public function results($url = "")
 {
     if ($this->page == "") {
         if (empty($url)) {
             $url = $this->mkurl();
         }
         $be = new MDB_Request($url);
         $be->sendrequest();
         $fp = $be->getResponseBody();
         if (!$fp) {
             if ($header = $be->getResponseHeader("Location")) {
                 if (strpos($header, $this->imdbsite . "/find?")) {
                     return $this->results($header);
                     break 4;
                 }
                 $url = explode("/", $header);
                 $id = substr($url[count($url) - 2], 2);
                 $this->resu[0] = new imdb_person($id);
                 return $this->resu;
             } else {
                 return NULL;
             }
         }
         $this->page = $fp;
     }
     // end (page="")
     if ($this->maxresults > 0) {
         $maxresults = $this->maxresults;
     } else {
         $maxresults = 999999;
     }
     // make sure to catch col #3, not #1 (pic only)
     preg_match_all('|<tr>\\s*<td.*>.*</td>\\s*<td.*>.*</td>\\s*<td.*<a href="/name/nm(\\d{7})[^>]*>([^<]+)</a>(.*)</td>|Uims', $this->page, $matches);
     $mc = count($matches[0]);
     $mids_checked = array();
     for ($i = 0; $i < $mc; ++$i) {
         if ($i == $maxresults) {
             break;
         }
         // limit result count
         $pid = $matches[1][$i];
         if (in_array($pid, $mids_checked)) {
             continue;
         }
         $mids_checked[] = $pid;
         $name = $matches[2][$i];
         $info = $matches[3][$i];
         $tmpres = new imdb_person($pid);
         $tmpres->fullname = $name;
         if (!empty($info)) {
             if (preg_match('|<small>\\((.*),\\s*<a href="/title/tt(\\d{7})/">(.*)</a>\\s*\\((\\d{4})\\)\\)|Ui', $info, $match)) {
                 $role = $match[1];
                 $mid = $match[2];
                 $movie = $match[3];
                 $year = $match[4];
                 $tmpres->setSearchDetails($role, $mid, $movie, $year);
             }
         }
         $this->resu[$i] = $tmpres;
         unset($tmpres);
     }
     return $this->resu;
 }
Ejemplo n.º 3
0
<?php

#############################################################################
# IMDBPHP                              (c) Giorgos Giagas & Itzchak Rehberg #
# written by Giorgos Giagas                                                 #
# extended & maintained by Itzchak Rehberg <izzysoft AT qumran DOT org>     #
# http://www.izzysoft.de/                                                   #
# ------------------------------------------------------------------------- #
# This program is free software; you can redistribute and/or modify it      #
# under the terms of the GNU General Public License (see doc/LICENSE)       #
#############################################################################
/* $Id: imdb_person.php 127 2008-05-15 11:10:23Z izzy $ */
require "imdb_person.class.php";
$person = new imdb_person($_GET["mid"]);
if (isset($_GET["mid"])) {
    $pid = $_GET["mid"];
    $person->setid($pid);
    echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n";
    echo "<HTML><HEAD>\n <TITLE>" . $person->name() . "</TITLE>\n";
    echo " <STYLE TYPE='text/css'>body,td,th { font-size:12px; font-family:sans-serif; }</STYLE>\n";
    echo "</HEAD>\n<BODY>\n<TABLE BORDER='1' ALIGN='center' STYLE='border-collapse:collapse'>";
    # Name
    echo '<TR><TH COLSPAN="3" STYLE="background-color:#ffb000">';
    echo $person->name() . "</TH></tr>\n";
    flush();
    # Photo
    echo '<TR><TD rowspan="28" valign="top">';
    if (($photo_url = $person->photo_localurl()) != FALSE) {
        echo '<div align="center"><img src="' . $photo_url . '" alt="Cover"></div>';
    } else {
        echo "No photo available";
 /**
  * Setup search results
  * @method results
  * @param optional string URL Replace search URL by your own
  * @return array results array of objects (instances of the imdb_person class)
  */
 public function results($url = "")
 {
     if (empty($url)) {
         $url = $this->mkurl();
     }
     $pageRequest = new imdb_page($url, $this, $this->cache, $this->logger);
     $page = $pageRequest->get();
     if ($this->maxresults > 0) {
         $maxresults = $this->maxresults;
     } else {
         $maxresults = 999999;
     }
     // make sure to catch col #3, not #1 (pic only)
     //                        photo           name                   1=id        2=name        3=details
     preg_match_all('|<tr.*>\\s*<td.*>.*</td>\\s*<td.*<a href="/name/nm(\\d{7})[^>]*>([^<]+)</a>\\s*(.*)</td>|Uims', $page, $matches);
     $mc = count($matches[0]);
     $this->logger->debug("[Person Search] {$mc} matches");
     $mids_checked = array();
     for ($i = 0; $i < $mc; ++$i) {
         if ($i == $maxresults) {
             break;
         }
         // limit result count
         $pid = $matches[1][$i];
         if (in_array($pid, $mids_checked)) {
             continue;
         }
         $mids_checked[] = $pid;
         $name = $matches[2][$i];
         $info = $matches[3][$i];
         $resultPerson = imdb_person::fromSearchResults($pid, $name, $this);
         if (!empty($info)) {
             if (preg_match('|<small>\\((.*),\\s*<a href="/title/tt(\\d{7}).*"\\s*>(.*)</a>\\s*\\((\\d{4})\\)\\)|Ui', $info, $match)) {
                 $role = $match[1];
                 $mid = $match[2];
                 $movie = $match[3];
                 $year = $match[4];
                 $resultPerson->setSearchDetails($role, $mid, $movie, $year);
             }
         }
         $this->resu[$i] = $resultPerson;
         unset($resultPerson);
     }
     return $this->resu;
 }
     }
 }
 foreach ($_POST as $key => $value) {
     if (strpos($key, $prefijo_nominacion_actor) === 0) {
         //Empieza por el prefijo de nominación de actores, es un actor nominado
         if ($value > 0) {
             //echo "<b>Actor:</b> ";
             //Si es positivo, el actor si está nominado, el valor es la categoría
             //y la parte final de la clave, el id del actor/actriz
             $id_actor = substr($key, strlen($prefijo_nominacion_actor));
             $sql = "INSERT INTO nominations(year,category_id,picture_id,nominee_id) VALUES(" . $year . "," . $value . ",'" . $id_imdb . "','" . $id_actor . "')";
             //echo $sql."<br>";
             $sqls[] = $sql;
             //Si el actor/actriz no existe, hay que crearlo
             if (!exists_person($bd, $id_actor)) {
                 $person = new imdb_person($id_actor);
                 $person->setid($id_actor);
                 $nuevo_profesional_nombre = $person->name();
                 $sqls[] = "INSERT INTO people(id,name) VALUES('" . $id_actor . "','" . $nuevo_profesional_nombre . "')";
             }
             $id_rol = get_role($bd, $value);
             if ($id_rol > 0) {
                 //La categoria tiene rol, hay que insertarlo
                 $sqls[] = "INSERT INTO person_picture(person_id,picture_id,role_id) VALUES(" . $id_actor . ",'" . $id_imdb . "'," . $id_rol . ")";
             }
         }
     }
 }
 foreach ($sqls as $i => $valor) {
     //echo $i.": ".$valor."<br>";
     $bd->exec($valor);
Ejemplo n.º 6
0
 /**
  * Setup search results
  * @method results
  * @param optional string URL Replace search URL by your own
  * @return array results array of objects (instances of the imdb_person class)
  */
 public function results($url = "")
 {
     if ($this->page == "") {
         if ($this->usecache && empty($url)) {
             // Try to read from cache
             $this->cache_read(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
         // end cache read
         if (empty($url)) {
             $url = $this->mkurl();
         }
         $be = new MDB_Request($url, $this);
         $be->sendrequest();
         $fp = $be->getResponseBody();
         if (!$fp) {
             if ($header = $be->getResponseHeader("Location")) {
                 mdb_base::debug_scalar("No immediate response body - we are redirected.<br>New URL: {$header}");
                 if (strpos($header, $this->imdbsite . "/find?")) {
                     return $this->results($header);
                     break 4;
                 }
                 $url = explode("/", $header);
                 $id = substr($url[count($url) - 2], 2);
                 $this->resu[0] = new imdb_person($id, $this);
                 return $this->resu;
             } else {
                 mdb_base::debug_scalar("No result, no redirection -- something's wrong here...");
                 return NULL;
             }
         }
         $this->page = $fp;
         if ($this->storecache && $this->page != "cannot open page" && $this->page != "") {
             //store cache
             $this->cache_write(urlencode(strtolower($this->name)) . '.search', $this->page);
         }
     }
     // end (page="")
     if ($this->maxresults > 0) {
         $maxresults = $this->maxresults;
     } else {
         $maxresults = 999999;
     }
     // make sure to catch col #3, not #1 (pic only)
     //                        photo           name                   1=id        2=name        3=details
     preg_match_all('|<tr.*>\\s*<td.*>.*</td>\\s*<td.*<a href="/name/nm(\\d{7})[^>]*>([^<]+)</a>\\s*(.*)</td>|Uims', $this->page, $matches);
     $mc = count($matches[0]);
     mdb_base::debug_scalar("{$mc} matches");
     $mids_checked = array();
     for ($i = 0; $i < $mc; ++$i) {
         if ($i == $maxresults) {
             break;
         }
         // limit result count
         $pid = $matches[1][$i];
         if (in_array($pid, $mids_checked)) {
             continue;
         }
         $mids_checked[] = $pid;
         $name = $matches[2][$i];
         $info = $matches[3][$i];
         $tmpres = new imdb_person($pid);
         $tmpres->fullname = $name;
         if (!empty($info)) {
             if (preg_match('|<small>\\((.*),\\s*<a href="/title/tt(\\d{7}).*"\\s*>(.*)</a>\\s*\\((\\d{4})\\)\\)|Ui', $info, $match)) {
                 $role = $match[1];
                 $mid = $match[2];
                 $movie = $match[3];
                 $year = $match[4];
                 $tmpres->setSearchDetails($role, $mid, $movie, $year);
             }
         }
         $this->resu[$i] = $tmpres;
         unset($tmpres);
     }
     return $this->resu;
 }
function show_imdb_awards($bd, $id)
{
    global $base_imdb;
    require_once "./" . $base_imdb . "/imdb_person.class.php";
    $person = new imdb_person($id);
    $person->setid($id);
    $aw = $person->awards();
    $aw_count = count($aw['Academy_Awards_USA']['entries']);
    //$aw_count=count($aw['Irish_Film_and_Television_Awards']['entries']);
    if ($aw_count > 0) {
        echo "<table><tr><th>Año</th><th>Resultado</th><th>Categoría</th><th>Película</th></tr>";
    }
    foreach ($aw['Academy_Awards_USA']['entries'] as $fila) {
        $won = $fila['won'] == 1 ? "Ganador" : "Nominado";
        $category = $fila['category'];
        if (!is_synonym($bd, $category, 1) && $fila['award'] == 'Oscar') {
            //Película, la ignoramos, nos interesan las categorías personales
            //Premios honoríficos también los ignoramos, nos interesan los competitivos
            echo "<tr><td>" . $fila['year'] . "</td><td>" . $won . "</td><td>" . get_category_synonym($bd, $category) . "</td><td>";
            foreach ($fila['pictures'] as $film_id => $film_title) {
                echo "<a href='movie.php?mid=" . $film_id . "&engine=imdb'>" . $film_title . "</a>";
            }
            echo "</td></tr>";
        }
    }
    if ($aw_count > 0) {
        echo "</table>";
    }
    echo "</td></tr>";
}