mark103 Posted December 22, 2011 Share Posted December 22, 2011 Hi guys, I need your help with my php script. On my script, I'm currently working with image where I can hot-link them from another website while it is on protected. when you click right-mouse button on firefox, you could see something like "view page source" which is disabled. when you click on "save page as", you can save the image as "image.php". when you open them, you would not be able to read due to the image but you can find the real image link in image.php where i want to protect them. here's the currently code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydbname'); $id = (int)$_GET['id']; $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var) { return mysql_real_escape_string(strip_tags($var)); } $qrytable1="SELECT images FROM image_list WHERE id=$id"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { $image = $row['images']; $details = getimagesize($image); header ('Content-Type: ' . image_type_to_mime_type($details[2])); echo readfile($image), "<p id='images'>", $row['images'] . "</p>"; } ?> I guess that there must be a way to protected the url in the php script where i can hide them. It should be easy to modify but I am not sure what line I need to adjust to make it protected. Can you please help me in what line I need to modify in order to protected the hot-linking in my php? Quote Link to comment Share on other sites More sharing options...
AGuyWithAthing Posted December 22, 2011 Share Posted December 22, 2011 I'm not entirely sure what you are trying to achieve but it sounds like you are trying to hide the fact your images are coming from a php script? If so you could use mod_rewrite to act as a alias to the file e.g. image012.jpg being an alias for myimage.php RewriteEngine on RewriteRule ^([A-Za-z0-9]+)\.jpg$ myimage.php?image=$1 If that's what you meant? If it was about stopping people altogether getting an image from you website then it is impossible as if you serve an image then you have made it publicly accessible. You can do certain things like protecting how people access the image such as with keys or host dependencies. Quote Link to comment Share on other sites More sharing options...
ocpaul20 Posted December 26, 2011 Share Posted December 26, 2011 you can also place a watermark on your image like property agents sometimes do. You can check the referer string or store a SESSION variable in your own website programs that you can check in the php program that generates/shows the image. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.