1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| <?php
function filtre_html($s) {
$s = str_replace("\r\n","",$s);
$s = str_replace("\n","",$s);
$s = str_replace("</TR>","</TR>\n",$s);
$s = strip_tags($s);
$s = str_replace(" "," ",$s);
return($s);
}
function Recherche($Nom_Film)
{
$Url = "http://www.allocine.fr/recherche/?motcle=".$Nom_Film ;
$ch = curl_init($Url);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch);
curl_close($ch);
// On récupére la partie global des infos
$pos1 = strpos($html, "<h2 class=\"SpBlocTitle\" >Films <h4>");
$pos2 = strpos($html, "<h2 class=\"SpBlocTitle\" >Séries TV <h4>",$pos1);
$data_brut = substr($html,$pos1,$pos2-$pos1);
// On récupére la Ligne d'un Film
$pos_ligne_1 = strpos($data_brut, "<td valign=\"top\"><h4>");
$pos_ligne_2 = strpos($data_brut, "</a></h4>",$pos_ligne_1);
while ($pos_ligne_1 & $pos_ligne_2) {
// On extrait le Titre
$ligne=substr($data_brut,$pos_ligne_1,$pos_ligne_2-$pos_ligne_1);
$titre = trim(strip_tags($ligne));
if ($titre!='Plus...') {
// On extrait l'url
$pos_url_1 = strpos($ligne, "<a href=\"");
$pos_url_2 = strpos($ligne, "\" class=\"link1\">", $pos_url_1);
if ($pos_url_1 & $pos_url_2) {
$pos_url_1+=strlen('<a href="');
if ($ligne[$pos_url_1]=='/') $pos_url_1++;
$url = "http://www.allocine.fr/" . substr($ligne,$pos_url_1,$pos_url_2 - $pos_url_1);
// on affiche le titre et on pré-coche le premier bouton radio
// l'utilisateur pourra cliquer sur le titre et ouvrir une nouvelle
// fenêtre avec la fiche du film
$LigneFinal = " <a href=" .$url. "><b>". $titre . "</b></a> ";
}
}
echo str_pad(" ",300);
echo "\n";
ob_flush();
flush();
}
return $LigneFinal;
}
require_once "Donnees/Fonctions.php";
set_include_path(get_include_path() . ":/home/boby1500/www/PEAR");
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm('Inscription', 'post','','');
$form->addElement('header','Recherche','Recherche du Film...');
// Création des Champs...
$form->addElement('text', 'Nom_Film', 'Nom du Film : ');
$form->addElement('submit', 'Bt_Envoyer', 'S\'inscrire');
// Régle du formulaire...
$form->addRule('Nom_Film', 'Aucun Titre n\'a été tapé', 'required', '', 'client');
$form->applyFilter('Nom_Film','trim') ;
$form->applyFilter('Nom_Film','urlencode') ;
if ($form->validate())
{
$Nom_Film = $form->exportValue('Nom_Film');
echo "<b>Résultat pour : ".urldecode($Nom_Film)."</b><br>";
echo Recherche($Nom_Film);
}
else
{
$form->display();
}
?> |
Partager