Skip to content
WJunction - Webmaster Forum

PHP Help Please

Status
Not open for further replies.
i have wrote a little php code to output the name of movies with the following method:

first off in my config.php i have:

PHP:
<?php require("imdb.php") ?>
what this grabs is:

PHP:
<?php
$q=$_GET['name'];
$url="http://www.imdbapi.org?q=".$q."&type=xml&plot=full";
$xml= simplexml_load_file($url);
$blocks = $xml->xpath('//item'); //gets all <block/> tags
$b=$blocks[0];
?>

this is my main way of getting information from imdb.

now on my movies page i have this:

PHP:
<?php echo $b->poster ?>
which obviously echos the poster of imdb, now how can i make this download to my server into an image folder then output it back.

i then want a way of grabbing screenshots from iptorrents but not knowing how to grab screenshots to a folder then output them is a bit of a nightmare.

currently, to grab data from ipt i use:

PHP:
if($type=="movies"){
                        $matches = array();
                        preg_match("/(.*?)(dvdrip|xvid| cd[0-9]|dvdscr|brrip|divx|[\{\(\[]?[0-9]{4}).*/", $block->title, $matches);
                        $name=str_replace("(REQ)","", $matches[1]);
                        $name=str_replace("[REQ]","", $matches[1]);
                        $name=str_replace(" 3D","", $matches[1]);
                        $name=str_replace("CAM","", $matches[1]);
                        $name=str_replace("[Director's Cut]","", $matches[1]);
                        //echo "<font color=blue>".$name."</font>";
                        
                        if(trim($name)=="")
                            $name=$block->title;
                        
                        
                        $name1=str_replace(" ","%20", $matches[1]);
                    }
                    else
                    {
                        $name=$block->title;
                        $name1=urlencode($name); 
                    }
 

1 comment

now how can i make this download to my server into an image folder then output it back.
You can use any of these methods: Copy, file_put_contents or curl

Assuming $b->poster is the absolute url of imdb poster:

PHP:
$imglink = $b->poster; // http://ia.media-imdb.com/images/M/MV5BMTU1MTAwMjk1NF5BMl5BanBnXkFtZTcwMDI5NDc4Ng@@._V1._SY317_.jpg
$name = basename($imglink); // http://php.net/manual/en/function.basename.php

if (copy($imglink, "somefolder/$name"))
{
   echo 'Saved';
}
 
Last edited:
Status
Not open for further replies.

About the author

B
Senior Member · Joined
1,286
Messages
211
Reactions
63
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom