Initial commit
This commit is contained in:
60
index.php
Normal file
60
index.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
// Indicate the location of your images
|
||||
$root = '';
|
||||
// use if specifying path from root
|
||||
//$root = $_SERVER['DOCUMENT_ROOT'];
|
||||
|
||||
$path = 'images/';
|
||||
|
||||
function getImagesFromDir($path) {
|
||||
$images = array();
|
||||
if ( $img_dir = @opendir($path) ) {
|
||||
while ( false !== ($img_file = readdir($img_dir)) ) {
|
||||
// checks for gif, jpg, png and jpeg
|
||||
if ( preg_match("/(\.gif|\.jpg|\.png\.jpeg)$/", $img_file) ) {
|
||||
$images[] = $img_file;
|
||||
}
|
||||
}
|
||||
closedir($img_dir);
|
||||
}
|
||||
return $images;
|
||||
}
|
||||
|
||||
function getRandomFromArray($ar) {
|
||||
mt_srand( (double)microtime() * 1000000 ); // php 4.2+ not needed
|
||||
$num = array_rand($ar);
|
||||
return $ar[$num];
|
||||
}
|
||||
|
||||
|
||||
// Obtain list of images from directory
|
||||
$imgList = getImagesFromDir($root . $path);
|
||||
|
||||
$img = getRandomFromArray($imgList);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Yagyuu</title>
|
||||
<style type="text/css">
|
||||
body { font: 14px/1.3 verdana, arial, helvetica, sans-serif; }
|
||||
h1 { font-size:1.3em; }
|
||||
h2 { font-size:1.2em; }
|
||||
a:link { color:#33c; }
|
||||
a:visited { color:#339; }
|
||||
p { max-width: 60em; }
|
||||
|
||||
/* so linked image won't have border */
|
||||
a img { border:none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<center>
|
||||
<!-- image displays here -->
|
||||
<div><img src="<?php echo $path . $img ?>" alt="" /></div>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user