<?php ## Config $imgDir = './img/'; $banDir = array ('.','..'); $goodExt = array ('png','jpg','jpeg','gif'); -- A venir ## End Config $img = ''; $case = ''; $handle = opendir($imgDir); while ($file = readdir($handle)) { $ext = array_pop(explode('.', $file)); if(!is_dir($file) && !in_array($file, $banDir) && in_array($ext, $goodExt)){ $path = $imgDir.$file; $name = strrev(substr(strrev($file), 4)); $img .= '$img_'.$name.' = <<< EOFILE'."<br />"; $img .= base64_encode(file_get_contents($path))."<br />"; $img .= 'EOFILE;'."<br />"; $case .= 'case \'img_'.$name.'\' :'."<br />"; $case .= 'header("Content-type: image/'.$ext.'");'."<br />"; $case .= 'echo base64_decode($img_'.$name.');'."<br />"; $case .= 'exit();'."<br />"; } } print $img; print "<br /><hr /><br />"; print $case; ?>
You need to create an account or log in to post comments to this site.