%PDF- %PDF-
Direktori : /mnt/tieto-nb/Documents/ |
Current File : //mnt/tieto-nb/Documents/index.php |
<?php function getmicrotime() { list($usec,$sec)=explode(" ",microtime()); return ((float)$usec+(float)$sec); } function makethumb($name) { $max = 300; $widthn = $max; $heightn = $max; //header('Content-type: image/jpeg'); list($width, $height) = getimagesize("./img/$name"); $ratio_orig = $width/$height; if (1 > $ratio_orig) { $widthn = $max*$ratio_orig; } else { $heightn = $max/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($widthn, $heightn); $image = imagecreatefromjpeg("./img/$name"); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $widthn, $heightn, $width, $height); imagejpeg($image_p, "./thumbs/$name", 75); } $cols = 3; ob_start(); $tzac=getmicrotime(); function fsize($size) { $jedn = array("bytes", "Kbytes", "Mbytes", "Gbytes", "Tbytes", "Pbytes"); //$size = filesize($name); $i = 0; while($size > 1023) { $size /= 1024; $i++; } return sprintf("%0.2f %s", $size, $jedn[$i]); } $sub = str_replace("\\'", "'", ($_GET['dir'])); if(strstr($sub, 'Pustina_1916_Rad')) { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Pustina-PA_Rad_matky_Elly"'); header('HTTP/1.0 401 Unauthorized'); echo 'UNAUTHORIZED!!!'; exit; } else { if($_SERVER['PHP_AUTH_USER'] != "ella" && $_SERVER['PHP_AUTH_PW'] != "veverka5VLahvi") { header('WWW-Authenticate: Basic realm="Pustina-PA_Rad_matky_Elly"'); header('HTTP/1.0 401 Unauthorized'); echo 'UNAUTHORIZED!!!'; exit; } } } $path = './img/'; //$path = "/www/varak.net"; $path = $path . "$sub"; $dh = opendir($path); $i=1; while ($dh && ($file = readdir($dh)) !== false) { if($file != "." && $file != ".." && $file != "Thumbs.db") { if (substr($file, -4, -3) =="."){ //echo "$i. <a href=\"http://music.varak.net/$sub/$file\">$file</a> ($size) <br />"; //echo "<tr><td>$i</td><td><a href=\"$sub/$file\">$file</a><!-- INODE: ".$stat['ino']." --></td><td>$size</td><td>$date</td></tr>\n"; $files[] = $file; }else{ //echo "$i. <a href='?dir=$sub/$file'>$file</a><br />"; $dirs[] = $file; } //$i++; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Album </title> </head> <body> <?php if($dirs) { echo "<h3>Podalba</h3>\n<ul>\n"; sort($dirs); foreach($dirs as $dir) { if(!file_exists("./thumbs/$sub/$dir/")) { mkdir("./thumbs/$sub/$dir/", 0777); } $dp = str_replace("'", "%27", urlencode($sub."/".$dir)); echo "<li><a href='?dir=$dp'>$dir</a></li>\n"; $i++; } } ?> </ul> <table width="960" align="center" border="0"> <?php if($files) { sort($files); $cc = 0; foreach($files as $file) { if($file == "index.php") continue; if(strtoupper(substr($file, -3)) != "JPG") continue; //echo "$i. <a href=\"http://music.varak.net/$sub/$file\">$file</a> ($size) <br />"; if($_GET['dir']) { $file = $_GET['dir']."/".$file; } if($cc == 0) { echo "<tr>\n"; } echo "\t<td><a href=\"./img/$file\" style=\"border : 0;\"><img src=\"./thumbs/$file\" style=\"border : 0;\" /></a></td>\n"; $cc++; if($cc == $cols) { $cc = 0; echo "</tr>\n"; } $i++; // Nyni je treba vyresit vytvoreni thumbnailu :D if(!file_exists("./thumbs/$file")) { makethumb("$file"); } } } closedir($dh); ?> </table> </body> </html> <?php $mem = sprintf("%01.2f", memory_get_peak_usage(true)/(1024*2024)); $tkon=getmicrotime(); $time=$tkon-$tzac; $time = sprintf("%01.4f", $time); header("X-Time-Used: $time"); header("X-Memory-Used: $mem MBytes"); echo ob_get_clean(); ?>