ציטוט:
נכתב במקור על ידי ZeroDay
כמו שאמרתי אתה יכול לעשות עם HTACCESS שזה יראה כמו תיקיה ותיצור קובץ בPHP שיהיה בתוכו תנאי שאם הוא יהיה לו גישה התמונה תופיע
|
תראה, ניסו לעזור לי איכשהו..
זה מה ששמתי בhtacces:
PHP קוד:
RewriteEngine On
RewriteRule ^images/(.+)/(.+) getfile.php?user=$1&file=$2
וזה הקובץ getfile.php:
PHP קוד:
<?php
// Validate request
if( !isset($_GET['user'], $_GET['file']) ) die('404 File Not Found');
// Check whether the username is profer
if( !preg_match("#[a-z0-9]#i", $_GET['user'])) die("Invalid user name");
if( strpos($_GET['file'], '..')) die("That can not be the filename");
// Create file path
$filename = './images/'.$_GET['user'].'/'.$_GET['file'];
// Validate file existance
if (!is_file($filename)) die('404 File Not Found');
// Checking authorization
if( "user_authorized" )
{
// Check file's type
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $filename);
finfo_close($finfo);
// Send file to the user
header("Content-Type: ".$mime);
readfile($filename);
}
else
{
die("Please authorize");
}
?>
אני נכנס לכאן:
http://www.eample.com/images/dor/pic.png
ואכן רואה את התמונה..אבל איפה בקובץ php אני יכול להכניס בדיקה מתאימה?
בקיצור, אני לא רואה שקורה משהו..מה אני לא עושה בסדר?
זה פשוט מתסכל..
אין פיתרון אחר מלבד htacces?
גם לא מצאתי מקום שמלמד על זה בצורה מקיפה..בעברית בכלל אין.
שלא תבינו לא נכון, אני מאוד מאוד מאוד מעריך ומודה לכם, אני פשוט מתוסכל.
תודה.