150) { $width = 150; $height = round(($y/$x) * $width); $tmpimage = imagecreatetruecolor($width, $height); imagecopyresampled($tmpimage, $img, 0, 0, 0, 0, $width, $height, $x, $y); imagedestroy($img); $img = $tmpimage; } if ($type == 'jpg' || $type == 'jpeg') { header("Content-type: image/jpeg"); imagejpeg($img, '', 65); } elseif ($type == 'png') { header("Content-type: image/png"); imagetruecolortopalette($img, false, 128); imagepng($img); } elseif ($type == 'gif') { header("Content-type: image/png"); imagetruecolortopalette($img, false, 128); imagepng($img); } exit(); } /* Directory Listing Script - Version 2 ==================================== Script Author: Ash Young . www.evoluted.net Layout: Manny . www.tenka.co.uk REQUIREMENTS ============ This script requires PHP and GD2 if you wish to use the thumbnail functionality. INSTRUCTIONS ============ 1) Unzip all files 2) Edit this file, making sure everything is setup as required. 3) Upload to server 4) ?????? 5) Profit! CONFIGURATION ============= Edit the variables in this section to make the script work as you require. Start Directory - To list the files contained within the current directory enter '.', otherwise enter the path to the directory you wish to list. The path must be relative to the current directory. */ /* if(!preg_match("http\:\/\/(.*)\.home\.hefr\.ch\/(.*)/i",$_SERVER[SCRIPT_URI],$results)) { $startdir="/home/".$results[1]."/home_unix/public_html/".$results[2]; } else exit(0); */ $startdir="."; if(!preg_match("http\:\/\/(.*)\.home\.hefr\.ch(\/.+)\/.*/i",$_SERVER[SCRIPT_URI],$results)) { !preg_match("http\:\/\/(.*)\.home\.hefr\.ch\/i",$_SERVER[SCRIPT_URI],$results); $userdir=$results[1]; $apath="/"; } else { $userdir=$results[1]; $apath=$results[2]; } /* Show Thumbnails? - Set to true if you wish to use the scripts auto-thumbnail generation capabilities. This requires that GD2 is installed. */ $showthumbnails = true; /* Show Directories - Do you want to make subdirectories available? If not set this to false */ $showdirs = true; /* Force downloads - Do you want to force people to download the files rather than viewing them in their browser? */ $forcedownloads = false; /* Hide Files - If you wish to hide certain files or directories then enter their details here. The values entered are matched against the file/directory names. If any part of the name matches what is entered below then it is now shown. */ $hide = array( 'dlf', 'Thumbs' ); $showext = array( 'pdf', 'doc', 'xls', 'docx', 'xlsx', 'zip', 'jpg', 'jpeg', 'gif', 'txt', 'png', 'bmp', 'zip', 'rar', 'psd', 'eps', 'gz', 'tar', 'pps', 'ppt', 'pptx', 'vsd', 'epf', 'jar', 'htm', 'html', 'java', 'mov', 'flv', 'swf', 'mp4', 'avi', 'mpeg', 'class', 'md5', 'tgz', 'bz2', 'c', 'C', 'h', 'o', 'asm', 'odp', 'pem', 'pcap', 'cap', 'py', 'tbz2', 'code' ); /* Show index files - if an index file is found in a directory to you want to display that rather than the listing output from this script? */ $displayindex = false; /* Allow uploads? - If enabled users will be able to upload files to any viewable directory. You should really only enable this if the area this script is in is already password protected. */ $allowuploads = false; /* Overwrite files - If a user uploads a file with the same name as an existing file do you want the existing file to be overwritten? */ $overwrite = false; /* Index files - The follow array contains all the index files that will be used if $displayindex (above) is set to true. Feel free to add, delete or alter these */ $indexfiles = array ( 'index.html', 'index.htm', 'default.htm', 'default.html' ); /* File Icons - If you want to add your own special file icons use this section below. Each entry relates to the extension of the given file, in the form => . These files must be located within the dlf directory. */ $filetypes = array ( 'png' => 'jpg.gif', 'jpeg' => 'jpg.gif', 'bmp' => 'jpg.gif', 'jpg' => 'jpg.gif', 'gif' => 'gif.gif', 'zip' => 'archive.png', 'jar' => 'archive.png', 'rar' => 'archive.png', 'exe' => 'exe.gif', 'setup' => 'setup.gif', 'txt' => 'text.png', 'md5' => 'text.png', 'java' => 'text.png', 'class' => 'exe.gif', 'epf' => 'text.png', 'htm' => 'html.gif', 'html' => 'html.gif', 'fla' => 'fla.gif', 'swf' => 'swf.gif', 'xls' => 'xls.gif', 'doc' => 'doc.gif', 'xlsx' => 'xls.gif', 'docx' => 'doc.gif', 'sig' => 'sig.gif', 'fh10' => 'fh10.gif', 'pdf' => 'pdf.gif', 'psd' => 'psd.gif', 'rm' => 'real.gif', 'mpg' => 'video.gif', 'mov' => 'video.gif', 'flv' => 'video.gif', 'swf' => 'video.gif', 'mp4' => 'video.gif', 'avi' => 'video.gif', 'mpeg' => 'video.gif', 'mov' => 'video2.gif', 'avi' => 'video.gif', 'eps' => 'eps.gif', 'gz' => 'archive.png', 'tgz' => 'archive.png', 'asc' => 'sig.gif', 'pps' => 'pps.gif', 'vsd' => 'vsd.gif', ); /* That's it! You are now ready to upload this script to the server. Only edit what is below this line if you are sure that you know what you are doing! */ error_reporting(0); if(!function_exists('imagecreatetruecolor')) $showthumbnails = false; $leadon = $startdir; if($leadon=='.') $leadon = ''; if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/'; $startdir = $leadon; if($_GET['dir']) { //check this is okay. if(substr($_GET['dir'], -1, 1)!='/') { $_GET['dir'] = $_GET['dir'] . '/'; } $dirok = true; $dirnames = split('/', $_GET['dir']); for($di=0; $di",$url,$results[1],$results[2]); } # recherche dans le ldap si la partie "user" de l'url est un ancien login # si ce n'est pas un ancien login, ca peut etre un login existant. on recherche le full name de l'utilisateur $sr = ldap_search($link, "ou=courant,ou=People,o=hefr", "(cn=".$uname.")"); if( ($entry = ldap_first_entry($link, $sr))) { $fname = ldap_get_values($link, $entry, "fullName"); $fname = $fname[0]; } # deconexion du LDAP ldap_close($link); } # si on atteint ce point sans avoir un match dans les deux recherches precedentes, l'utilisateur n'existe pas et c'est une 404 pure souche, le errorstyle reste a 0 ?> Personal Homepages - HES-SO Fribourg