Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_GET['user']) || $_GET['user'] == '' || !file_exists($_GET['user'] . ".txt"))
- echo "User not found!: " . $_GET['user'];
- $filePaths = explode("\n", file_get_contents($_GET['user'] . ".txt"));
- $imageFile = trim($filePaths[rand(0, count($filePaths) -1)]);
- $imginfo_array = getimagesize($imageFile);
- if ($imginfo_array !== false) {
- $mime_type = $imginfo_array['mime'];
- switch($mime_type) {
- case "image/jpeg":
- $im = imagecreatefromjpeg($imageFile);
- header('Content-Type: image/jpeg');
- imagejpeg($im);
- break;
- case "image/png":
- $im = imagecreatefrompng($imageFile);
- header('Content-Type: image/png');
- imagealphablending($im, true); // setting alpha blending on
- imagesavealpha($im, true); // save alphablending setting (important)
- imagepng($im);
- break;
- case "image/gif":
- /*$im = imagecreatefromgif($imageFile);
- header('Content-Type: image/gif');
- imagealphablending($im, true); // setting alpha blending on
- imagesavealpha($im, true); // save alphablending setting (important)
- imagegif($im);*/
- header('Location: ' . $imageFile);
- break;
- }
- @imagedestroy($im);
- }
- else {
- echo "This is not a valid image file";
- }
- ?>
Add Comment
Please, Sign In to add comment