www.webdeveloper.com
Results 1 to 9 of 9

Thread: Encoded/Encrypted Image Names Suggestions Help!!

  1. #1
    Join Date
    Jan 2013
    Posts
    11

    Question Encoded/Encrypted Image Names Suggestions Help!!

    Hello,
    So I'm trying to make it so the client doesn't see
    HTML Code:
    <div class="image" style="background-image: url(images/210.jpg)">
    But instead sees something like:
    HTML Code:
    <div class="image" style="background-image: url(images/r2re6er24y.jpg)">
    Just a random string of characters, it's to stop the user looking ahead for image 211.jpg or 320.jpg etc.

    currently the jpg number is called by
    PHP Code:
    $iddate date('z')+1
    If anyone has any ideas on how to do this it would be appreciated.
    I was thinking something with temporary images but I don't know how or if that would work?

    Many Thanks

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    Sounds to me like you need to have the actual images renamed to a seemingly random sequence, a database that has the original name / number and what it is renamed to so you are able to know via a script what to serve up.

    I really don't see why you would need to "Protect" these images, 99% of web users wouldn't have the technical knowledge on how to look ahead or couldn't care less about trying.

    Also, if somone wants it, they would only need to take a screen shot of it!
    Last edited by \\.\; 07-29-2013 at 04:59 PM.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Jan 2013
    Posts
    11
    The images are in numerical order (badly explained sorry) so they could easy all be seen.
    I'm not worried about people downloading them, and i agree most users wouldn't know how to but I'm trying to stop users who do how to use google chromes inspector from seeing the future images, as the images change daily.
    Maybe I'm being a bit paranoid but I just think it's a good thing to do.

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    How many images are we talking about?
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,326
    If it's truly important for users to not be able to guess related image names, you could make use of PHP sessions along with an image server script.

    Main script:
    PHP Code:
    <?php
    session_start
    ();
    $_SESSION['images'] = array(
      
    'img1' => array(
        
    'id' => uniqid('IMG'true),
        
    'path' => $_SERVER['DOCUMENT_ROOT'].'/images/img_1.jpg'
      
    ),
      
    'img2' => array(
        
    'id' => uniqid('IMG'true),
        
    'path' => $_SERVER['DOCUMENT_ROOT'].'/images/img_2.jpg'
      
    )
    );
    ?>
    <img src='show_image.php?img=<?php echo $_SESSION['images']['img1']['id']; ?>' alt='' />
    <img src='show_image.php?img=<?php echo $_SESSION['images']['img2']['id']; ?>' alt='' />
    show_image.php:
    PHP Code:
    <?php
    session_start
    ();
    if(!empty(
    $_SESSION['images'])) {
      foreach(
    $_SESSION['images'] as $key => $data) {
        if(
    $data['id'] == $_GET['img']) {
          
    header('Content-Type: image/jpeg');
          
    readfile($data['path']);
          exit;
        }
      }
    }
    header("HTTP/1.0 404 Not Found");
    This is just a rough cut at it: sure it could be cleaned up a bit.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #6
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    Is it important that the images are sequential or would a random image picked be ok?
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  7. #7
    Join Date
    Jan 2013
    Posts
    11
    365 images, and they have to be in order

  8. #8
    Join Date
    Jan 2013
    Posts
    11
    Great thanks i'll give this a go

  9. #9
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    An alternative way of securing the images would be to have a folder outside of the main folder, something that can't be predicted. Using a shell script that calls a PHP script to then move the next image in to the folder for display making it impossible to obtain a future image.

    I used this principle for a picture of the day script that needed two things, change over at 9pm and to be non-predictable before or after display.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles