This repository has been archived on 2025-04-04. You can view files and clone it, but cannot push or open issues or pull requests.
2013-05-22 23:27:23 +02:00

23 lines
658 B
PHP

<?php
class picfolder {
public static function get($path, $id){
if(!is_dir($path)){
throw new ERROR("Picfolder -> invalid folder");}
$filelist = array();
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
while($it->valid()) {
if (!$it->isDot()) {
$filelist[] = $it->key();}
$it->next();
}
//random
if($id == -1 || $id < 0 || $id >= count($filelist)){
$id = rand(0, count($filelist)-1);}
\SYSTEM\HEADER::PNG();
return file_get_contents($filelist[$id]);
}
}