please help me with this little problem

Discussion in 'Programming' started by nevret2, May 29, 2009.

  1. #1
    hello,

    at my website http://trailergalaxy.net

    i use a little imdb info grabber script


    http://trailergalaxy.net/movie.php?mid=IDIMDBHERE


    example: http://www.imdb.com/title/tt1307989/

    fi you put that id number after http://trailergalaxy.net/movie.php?mid= you get the info

    so = http://trailergalaxy.net/movie.php?mid=1307989


    http://trailergalaxy.net/movie.php?mid=1307989 works great but when i put http://trailergalaxy.net/movie.php?mid=1307989/ it doesnt works

    can someone please help me with this

    most of my urls are like http://trailergalaxy.net/movie.php?mid=1307989/ but then it doesnt works





    i want my urls like http://trailergalaxy.net/movie.php?mid=1307989/ and not http://trailergalaxy.net/movie.php?mid=1307989


    how can i make this working


    this is the code of movie.php=

    <?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.php 159 2008-06-26 16:00:03Z izzy $ */
    
    require ("imdb.class.php");
    
    $movie = new imdb ($_GET["mid"]);
    
    if (isset ($_GET["mid"])) {
      $movieid = $_GET["mid"];
      $movie->setid ($movieid);
      $rows = 2; // count for the rowspan; init with photo + year
    
      echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n";
      echo "<HTML><HEAD>\n <TITLE>".$movie->title().' ('.$movie->year().")</TITLE>\n";
      echo " <STYLE TYPE='text/css'>body,td,th { font-size:12px; font-family:sans-serif; }</STYLE>\n";
      echo "</HEAD>\n<BODY ONLOAD='fix_colspan()'>\n<TABLE BORDER='1' ALIGN='center' STYLE='border-collapse:collapse'>";
    
      # Title & year
      echo '<TR><TH COLSPAN="3" STYLE="background-color:#ffb000">';
      echo $movie->title().' ('.$movie->year().")</TH></tr>\n";
      flush();
    
      # Year & runtime
      echo '<TR><TD><B>Year:</B></TD><TD>'.$movie->year().'</TD></TR>';
      $runtime = $movie->runtime();
      if (!empty($runtime)) {
        ++$rows;
        echo "<TR><TD valign=top><B>Runtime:</b></TD><TD>$runtime minutes</TD></TR>\n";
      }
      flush();
      
        # Plot outline & plot
      $plotoutline = $movie->plotoutline();
      if (!empty($plotoutline)) {
        ++$rows;
        echo "<tr><td valign='top'><b>Plot Outline:</b></td><td>$plotoutline</td></tr>\n";
      }
    
      $plot = $movie->plot();
      if (!empty($plot)) {
        ++$rows;
        echo '<tr><td valign=top><b>Plot:</b></td><td><ul>';
        for ($i = 0; $i < count($plot); $i++) {
          echo "<li>".$plot[$i]."</li>\n";
        }
        echo "</ul></td></tr>\n";
      }
      flush();
    
         # Title & year
      echo '<TR><TH COLSPAN="3" STYLE="background-color:#ffb000">';
      echo require ("ads.php");  require ("ads.php");  require ("ads.php"); 
      flush();
     
    
      # Languages
      $languages = $movie->languages();
      if (!empty($languages)) {
        ++$rows;
        echo '<TR><TD><B>Languages:</B></TD><TD>';
        for ($i = 0; $i + 1 < count($languages); $i++) {
          echo $languages[$i].', ';
        }
        echo $languages[$i]."</TD></TR>\n";
      }
      flush();
    
      # Country
      $country = $movie->country();
      if (!empty($country)) {
        ++$rows;
        echo '<TR><TD><B>Country:</B></TD><TD>';
        for ($i = 0; $i + 1 < count($country); $i++) {
          echo $country[$i].', ';
        }
        echo $country[$i]."</TD></TR>\n";
      }
    
      # Genres
      $genre = $movie->genre();
      if (!empty($genre)) { echo "<TR><TD><B>Genre:</B></TD><TD>$genre</TD></TR>\n"; ++$rows; }
    
      $gen = $movie->genres();
      if (!empty($gen)) {
        ++$rows;
        echo '<TR><TD><B>All Genres:</B></TD><TD>';
        for ($i = 0; $i + 1 < count($gen); $i++) {
          echo $gen[$i].', ';
        }
        echo $gen[$i]."</TD></TR>\n";
      }
    
      # Colors
      $col = $movie->colors();
      if (!empty($col)) {
        ++$rows;
        echo '<TR><TD><B>Colors:</B></TD><TD>';
        for ($i = 0; $i + 1 < count($col); $i++) {
          echo $col[$i].', ';
        }
        echo $col[$i]."</TD></TR>\n";
      }
      flush();
    
      # Sound
      $sound = $movie->sound ();
      if (!empty($sound)) {
        ++$rows;
        echo '<TR><TD><B>Sound:</B></TD><TD>';
        for ($i = 0; $i + 1 < count($sound); $i++) {
          echo $sound[$i].', ';
        }
        echo $sound[$i]."</TD></TR>\n";
      }
    
      $tagline = $movie->tagline();
      if (!empty($tagline)) {
        ++$rows;
        echo "<TR><TD valign='top'><B>Tagline:</B></TD><TD>$tagline</TD></TR>\n";
      }
    
      #==[ Staff ]==
      # director(s)
      $director = $movie->director();
      if (!empty($director)) {
        ++$rows;
        echo '<TR><TD valign=top><B>Director:</B></TD><TD>';
        echo "<table align='left' border='1' style='border-collapse:collapse;background-color:#ddd;'><tr><th style='background-color:#07f;'>Actor</th><th style='background-color:#07f;'>Role</th></tr>";
        for ($i = 0; $i < count($director); $i++) {
          echo '<tr><td width=200>';
          echo '<a href="imdb_person.php?mid='.$director[$i]["imdb"].'">';
          echo $director[$i]["name"].'</a></td><td>';
          echo $director[$i]["role"]."</td></tr>";
        }
        echo "</table></td></tr>\n";
      }
    
      # Story
      $write = $movie->writing();
      if (!empty($write)) {
        ++$rows;
        echo '<TR><TD valign=top><B>Writing By:</B></TD><TD>';
        echo "<table align='left' border='1' style='border-collapse:collapse;background-color:#ddd;'><tr><th style='background-color:#07f;'>Actor</th><th style='background-color:#07f;'>Role</th></tr>";
        for ($i = 0; $i < count($write); $i++) {
          echo '<tr><td width=200>';
          echo '<a href="imdb_person.php?mid='.$write[$i]["imdb"].'/">';
          echo $write[$i]["name"].'</a></td><td>';
          echo $write[$i]["role"]."</td></tr>";
        }
        echo "</table></td></tr>\n";
      }
      flush();
    
      # Producer
      $produce = $movie->producer();
      if (!empty($produce)) {
        ++$rows;
        echo '<TR><TD valign=top><B>Produced By:</B></TD><TD>';
        echo "<table align='left' border='1' style='border-collapse:collapse;background-color:#ddd;'><tr><th style='background-color:#07f;'>Actor</th><th style='background-color:#07f;'>Role</th></tr>";
        for ($i = 0; $i < count($produce); $i++) {
          echo '<tr><td width=200>';
          echo '<a href="imdb_person.php?mid='.$produce[$i]["imdb"].'/">';
          echo $produce[$i]["name"].'</a></td><td>';
          echo $produce[$i]["role"]."</td></tr>";
        }
        echo "</table></td></tr>\n";
      }
    
      # Music
      $compose = $movie->composer();
      if (!empty($compose)) {
        ++$rows;
        echo '<TR><TD valign=top><B>Music:</B></TD><TD>';
        echo "<table align='left' border='1' style='border-collapse:collapse;background-color:#ddd;'><tr><th style='background-color:#07f;'>Actor</th><th style='background-color:#07f;'>Role</th></tr>";
        for ($i = 0; $i < count($compose); $i++) {
          echo '<tr><td width=200>';
          echo '<a href="imdb_person.php?mid='.$compose[$i]["imdb"].'">';
          echo $compose[$i]["name"]."</a></td></tr>";
        }
        echo "</table></td></tr>\n";
      }
      flush();
    
      # Cast
      $cast = $movie->cast();
      if (!empty($cast)) {
        ++$rows;
        echo '<TR><TD valign=top><B>Cast:</B></TD><TD>';
        echo "<table align='left' border='1' style='border-collapse:collapse;background-color:#ddd;'><tr><th style='background-color:#07f;'>Actor</th><th style='background-color:#07f;'>Role</th></tr>";
        for ($i = 0; $i < count($cast); $i++) {
          echo '<tr><td width=200>';
          echo '<a href="imdb_person.php?mid='.$cast[$i]["imdb"].'">';
          echo $cast[$i]["name"].'</a></td><td>';
          echo $cast[$i]["role"]."</td></tr>";
        }
        echo "</table></td></tr>\n";
      }
      flush();
    
    
      # Taglines
      $taglines = $movie->taglines();
      if (!empty($taglines)) {
        ++$rows;
        echo '<tr><td valign=top><b>Taglines:</b></td><td><ul>';
        for ($i = 0; $i < count($taglines); $i++) {
          echo "<li>".$taglines[$i]."</li>\n";
        }
        echo "</ul></td></tr>\n";
      }
    
      $seasons = $movie->seasons();
      if ( $seasons != 0 ) {
        ++$rows;
        $episodes = $movie->episodes();
        echo '<tr><td valign=top><b>Episodes:</b></td><td>';
        for ( $season = 1; $season <= $seasons; ++$season ) {
          $eps = @count($episodes[$season]);
          for ( $episode = 1; $episode <= $eps; ++$episode ) {
            $episodedata = &$episodes[$season][$episode];
            echo '<b>Season '.$season.', Episode '.$episode.': <a href="'.$_SERVER["PHP_SELF"].'?mid='.$episodedata['imdbid'].'">'.$episodedata['title'].'</a></b> (<b>Original Air Date: '.$episodedata['airdate'].'</b>)<br>'.$episodedata['plot'].'<br/><br/>';
          }
        }
        echo "</td></tr>\n";
      }
    
      # Selected User Comment
      $comment = $movie->comment();
      if (!empty($comment)) {
        ++$rows;
        echo "<tr><td valign='top'><b>User Comments:</b></td><td>$comment</td></tr>\n";
      }
    
      # Quotes
      $quotes = $movie->quotes();
      if (!empty($quotes)) {
        ++$rows;
        echo '<tr><td valign=top><b>Movie Quotes:</b></td><td>';
        echo preg_replace("/http\:\/\/".str_replace(".","\.",$movie->imdbsite)."\/name\/nm(\d{7})\//","imdb_person.php?mid=\\1",$quotes[0])."</td></tr>\n";
      }
    
      # Trailer
      $trailers = $movie->trailers();
      if (!empty($trailers)) {
        ++$rows;
        echo '<tr><td valign=top><b>Trailers:</b></td><td>';
        for ($i=0;$i<count($trailers);++$i) {
          echo "<a href='".$trailers[$i]."'>".$trailers[$i]."</a><br>\n";
        }
        echo "</td></tr>\n";
      }
    
      # Crazy Credits
      $crazy = $movie->crazy_credits();
      $cc    = count($crazy);
      if ($cc) {
        ++$rows;
        echo '<tr><td valign=top><b>Crazy Credits:</b></td><td>';
        echo "We know about $cc <i>Crazy Credits</i>. One of them reads:<br>$crazy[0]</td></tr>\n";
      }
    
      # Goofs
      $goofs = $movie->goofs();
      $gc    = count($goofs);
      if ($gc > 0) {
        ++$rows;
        echo '<tr><td valign=top><b>Goofs:</b></td><td>';
        echo "We know about $gc goofs. Here comes one of them:<br>";
        echo "<b>".$goofs[0]["type"]."</b> ".$goofs[0]["content"]."</td></tr>\n";
      }
    
      # Trivia
      $trivia = $movie->trivia();
      $gc     = count($trivia);
      if ($gc > 0) {
        ++$rows;
        echo '<tr><td valign=top><b>Trivia:</b></td><td>';
        echo "There are $gc entries in the trivia list - like these:<br><ul>";
        for ($i=0;$i<5;++$i) {
          if (empty($trivia[$i])) break;
          echo "<li>".preg_replace("/http\:\/\/".str_replace(".","\.",$movie->imdbsite)."\/name\/nm(\d{7})\//","imdb_person.php?mid=\\1",$trivia[$i])."</li>";
        }
        echo "</ul></td></tr>\n";
      }
    
      # Soundtracks
      $soundtracks = $movie->soundtrack();
      $gc = count($soundtracks);
      if ($gc > 0) {
        ++$rows;
        echo '<tr><td valign=top><b>Soundtracks:</b></td><td>';
        echo "There are $gc soundtracks listed - like these:<br>";
        echo "<table align='center' border='1' style='border-collapse:collapse;background-color:#ddd;'><tr><th style='background-color:#07f;'>Soundtrack</th><th style='background-color:#07f;'>Credit 1</th><th style='background-color:#07f;'>Credit 2</th></tr>";
        for ($i=0;$i<5;++$i) {
          if (empty($soundtracks[$i])) break;
          $credit1 = preg_replace("/http\:\/\/".str_replace(".","\.",$movie->imdbsite)."\/name\/nm(\d{7})\//","imdb_person.php?mid=\\1",$soundtracks[$i]["credits"][0]);
          $credit2 = preg_replace("/http\:\/\/".str_replace(".","\.",$movie->imdbsite)."\/name\/nm(\d{7})\//","imdb_person.php?mid=\\1",$soundtracks[$i]["credits"][1]);
          echo "<tr><td>".$soundtracks[$i]["soundtrack"]."</td><td>$credit1</td><td>$credit2</td></tr>";
        }
        echo "</table></td></tr>\n";
      }
    
      echo "</TABLE><BR>\n";
      echo "<SCRIPT TYPE='text/javascript'>// <!--\n";
      echo "  function fix_colspan() {\n";
      echo "    document.getElementById('photocol').rowspan = '$rows';\n";
      echo "  }\n//-->\n</SCRIPT>\n";
      echo "</BODY></HTML>";
    }
    ?>
    
    PHP:
     
    nevret2, May 29, 2009 IP
  2. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #2
    Use URL-rewriting to alter the URL pattern (preferred method) or alter the script. For example, you can use regular expressions to clean the input (i.e. strip the "/" and other non-numeric characters).
     
    Social.Network, May 29, 2009 IP
  3. nevret2

    nevret2 Peon

    Messages:
    518
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    how can i do this please help me with a solution
     
    nevret2, May 31, 2009 IP