-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
29 lines (25 loc) · 868 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
//----------------------------------------------------------------------------
// ● Pick Random Image From Local Directory
//----------------------------------------------------------------------------
// Get All Images in Directory
$dir_path = "./images/";
$images_paths = glob(
$dir_path . "/*.{jpg,jpeg,jpe,jfif,png,gif,bmp,dib,tif,tiff}", GLOB_BRACE
);
if (empty($images_paths)) exit;
// Get Random Image from Images in Directory
$image_path = $images_paths[array_rand($images_paths)];
// Send Image JSON Data to Browser
if (isset($_GET["json"])) {
header("Content-Type: application/json; charset=utf-8");
include "./json.php";
echo image_json($image_path);
exit;
}
// Send Image Directly to Browser
header("Content-Type: " . mime_content_type($image_path));
header("Content-Length: " . filesize($image_path));
readfile($image_path);
exit;
?>