• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[HELP - PHP] Grab image code

Joined
Dec 16, 2011
Messages
1,994
Reaction score
633
Hello there, I'm making a little script where it'll grab an image, IE:



Now, I started on a little script;
PHP:
<?php
$url = "http://website.com";$png = $_GET['png'];if(is_numeric($png)){?><img src=<?php echo $url, $png; ?>.gif'><?php  print("<br /><br /> Text will go under the image");}else{  print("The image you were looking for wasn't found!");}?>

Now, that's just a small base script I started, but I was wondering if someone could possibly make the script more clean, and/or help me with making it so people can't just right click on the image and open it in a new tab.
 
Experienced Elementalist
Joined
Dec 18, 2007
Messages
243
Reaction score
37
Is the script supposed to look for a image on the server it's hosted on or is it supposed to work global?

If it's for the local domain it's hosted on, I'd suggest you to just check if the file (image) exists.

PHP:
if(file_exists($image_path.$image_filename))
{
      // found the image, lets display it
      echo '<img src="my_url_or_the_direct_path/'  . $image_filename . '">';
}
else
{
     // the image does not exist
}
 
Skilled Illusionist
Joined
Jun 21, 2010
Messages
324
Reaction score
54
Can you even hide it? From my knowledge, you wouldn't be able to hide it without HTML not being able to parse it. Basically HTML needs it. If you echo a variable it is still read by HTML.

Are you sure this works?
 
Joined
May 23, 2008
Messages
1,071
Reaction score
574
Instead of using PHP, try using javascript to disable right click, using flash to hold the image (can't save an image if it's flash), and clearing the user's clipboard if the print screen button is pressed. Also make sure to require them to sign a legal document and fax it to you(because the government is in our emailz) before viewing images on your site.

Or you can watermark the image. And/or license it.

Or, you know, just don't worry about it.
 
Newbie Spellweaver
Joined
Aug 22, 2008
Messages
88
Reaction score
14
It's not that, I'm making a nifty PHP image hosting script, and I don't want un-registered users to just be able to copy and paste the image, you know.

 
Joined
Dec 16, 2011
Messages
1,994
Reaction score
633
So you want only registered users to be able to use your service?
That's not a smart idea.
No, I don't think you understand the concept of what I ment.

Un-registered user:
View images in a webpage where it'll receive the image and they'll be able to get the image in a txtbox after 5 seconds of waiting (advertisements, etc)

Registered users:
They'll get a direct link to there image with no advertisements.

This is to generate some sort of income in a smart manner.
 
Custom Title Activated
Loyal Member
Joined
May 23, 2011
Messages
1,607
Reaction score
589
No, I don't think you understand the concept of what I ment.

Un-registered user:
View images in a webpage where it'll receive the image and they'll be able to get the image in a txtbox after 5 seconds of waiting (advertisements, etc)

Registered users:
They'll get a direct link to there image with no advertisements.

This is to generate some sort of income in a smart manner.
I see.
You'd need to check for the user's session (if they're logged in) and then output content based on that.
PHP:
//some generic code
if($session)
{
//output specific stuff here
}
 
Back
Top