0

Hello, i am trying to create a php script that offers the following functions...

wardrobe.php?friend=FRIENDNAME
wardrobe.php?hash=HASHTAG

but i dont want you to be able to use both at the same time, please could you help improve my code to become more stable, add error checking and also offer this feature mentioned above, thanks

<?

header("Content-Type: image/png");

$friend = strtolower($_GET['friend']);
$hash = strtolower($_GET['hash']);

if (empty($hash) {

$filepath = "wardrobe/md5($friend)";
$errorpath = "wardrobe/cb5e100e5a9a3e7f6d1fd97512215282";

if (is_readable($filepath)) {
	readfile($filepath);
} else {
	readfile($errorpath);
}	

} elseif (empty($friend) {

$filepath = "wardrobe/$hash";
$errorpath = "wardrobe/cb5e100e5a9a3e7f6d1fd97512215282";

if (is_readable($filepath)) {
	readfile($filepath);
} else {
	readfile($errorpath);
}	

}

?>

Kind Regards,
Nathaniel Blackburn

Edited by shadowscape: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by shadowscape
0

you may try

wardrobe.php?key=hash&value=HASHTAG
or
wardrobe.php?key=friend&value=FRIENDNAME

your code file may look like

<?

header("Content-Type: image/png");

$value = strtolower($_GET['value']);

if( strtolower($_GET['value'])=='hash')
   $filepath = "wardrobe/$value";

else if( strtolower($_GET['value'])=='friend')
   $filepath = "wardrobe/md5($value)";
else
   exit;

$errorpath = "wardrobe/cb5e100e5a9a3e7f6d1fd97512215282";

if (is_readable($filepath)) {
	readfile($filepath);
} else {
	readfile($errorpath);
}	




?>

Edited by urtrivedi: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.