[英]How to hide images from unregistered users
I made a website to share pictures like films but i have problems with privacy. 我创建了一个网站来共享电影等图片,但隐私方面存在问题。 When u create a photo film u can share its url with people but people who are not logged in my website they still can watch my film http://thephotofilm.com/films/1002947 当您创建摄影胶片时,您可以与其他人共享其网址,但未登录我的网站的人仍然可以观看我的影片http://thephotofilm.com/films/1002947
SELECT path FROM images WHERE img_id=(id)
if($type=="ole")
$type=1;
else
$type=1;
if(!is_numeric($imageIndex) || $imageIndex<0)
invalidImage();
If user is not logged in display a blank picture 如果用户未登录,则显示空白图片
Thanks in advace! 感谢您的放心!
you do it with $_session['username']
. 您可以使用$_session['username']
。
if(isset($_session['username'])){ //change this session to your session name.
echo 'show image here';
}
else{
echo 'tell him wtf are you doing here';
}
I would use a session variable to check against. 我将使用会话变量进行检查。 If the user has a valid session, show the image. 如果用户具有有效的会话,请显示图像。 If not, do not show the image. 如果不是,则不显示图像。
Something like this: 像这样:
if ($_SESSION['my-session-var']
{
echo '<img src="my-image.jpg" />';
}
else
{
echo '<p>You gotta log in first, ya \'doofis!</p>';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.