Created
August 3, 2015 08:09
-
-
Save sweenzor/551c25c8a8636e4e6c87 to your computer and use it in GitHub Desktop.
Walk directory and find md5 hashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function md5sum($filenm) | |
{ | |
$val = md5_file($filenm); | |
echo $filenm.":".$val."<br/>"."\n"; | |
} | |
//read folder | |
$folder=opendir("."); | |
while ($file = readdir($folder)){ | |
$names[]=$file; | |
} | |
closedir($folder); | |
array_walk($names, 'md5sum'); | |
?> | |
<?php | |
/* | |
function rnd($min, $max){//mt_rand wrapper, seeds automatically, once per page | |
global $rnd_seeded; | |
if ($rnd_seeded!=1){//seed if not seeded | |
$mtime=microtime(); | |
list($usec,$sec)=explode(" ",$mtime); | |
mt_srand($usec*$sec); | |
$rnd_seeded=1; | |
} | |
return mt_rand($min, $max); | |
} | |
$def_img_url="<DEFAULT-SIG-URL>"; | |
//default image to redirect to if no images exist in random dir | |
//read folder | |
$folder=opendir("."); | |
while ($file = readdir($folder)){ | |
$ext=strtolower(substr(trim($file),-4)); | |
if ($ext==".jpg"||$ext==".gif"||$ext==".jpeg"||$ext==".png")$imgs[]=$file; | |
} | |
closedir($folder); | |
if (is_array($imgs)){ | |
header ("location: ".$imgs[rnd(0, count($imgs)-1)]); | |
}else{ | |
header ("location: $def_img_url"); | |
} | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment