I need to display pictures with ads around them (showpic.php)

Discussion in 'PHP' started by smi, Mar 5, 2007.

  1. #1
    I want to store all images in a folder and when I want to display them I just link to: showpic.php?img=image001.jpg

    In the showpic.php file I can have phpads or other ad solutions in order to display ads to everyone who view the images.

    I have seen such a solution on various celebrity blogs and other sites. Is there any script or code available? I have googled extensively but only succeeded in finding plenty of "randomizers."
     
    smi, Mar 5, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Create the showpic.php page, and somewhere there put:

    
    
    <?php
    
    $path = './images/'; // Path to images
    
    $image = htmlentities(basename(rawurldecode($_GET['img'])));
    
    if (!file_exists($path . $image))
    {
         $image = 'error.jpg';
    }
    
    ?>
    <img src="images/<?php echo $path . $image; ?>" border="0" />
    
    PHP:
    Now place your ads around there, wherever you need them, and you're basically done. The image source will be what is given in the URL.
     
    nico_swd, Mar 5, 2007 IP
  3. smi

    smi Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you very much for your help.
     
    smi, Mar 6, 2007 IP
  4. donthate

    donthate Banned

    Messages:
    922
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Or use this, would work fine.

    <?
    $img = $HTTP_GET_VARS['img'];
    echo "ads above image<br>";
    echo "<img src='http://www.yoursite.com/images/$img'></img><br>";
    echo "ads below image<br>";
    ?>


    then link to ( saying above file is showpic.php ) -

    http://www.yoursite.com/showpic.php?img=mycoolpic.jpg

    its EXACTLY what you need, just change yoursite to your domain/url in the script.

    enjoy
     
    donthate, Mar 6, 2007 IP