USE AT OWN RISK
Generated: Tue Jul 31 15:22:05 2007 from imagesa2.php 2005/08/04 10.2 KB bytes.
<html> <head> <meta http-equiv="Content-Language" content="en-au"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta http-equiv="refresh" content="90;url=images2.php"> <title>Image 160x120 Index 2</title> </head> <body background="images/lotus01.jpg"> <h1 align="center"><b>Image 160x120 Index 2</b></h1> <p align="center"><span style="background-color: #FFFFFF">|* <a href="index.html">index</a> *|</span></p> <?php // $m_folder = 'c:/HOMEPAGE/russ4/images/.'; $m_folder = 'images/.'; $m_mostcnt = 0; $m_mostnam = ' '; $m_mostarr = array(); $m_msg = ' '; $m_type = 'a'; // set the DAY, type of file to find, list ... function getBlkSz( $sz ) { $blk = 4096; $bcnt = $sz / $blk; settype($bcnt,"int"); if( $sz % $blk ) $bcnt++; if( $bcnt == 0 ) $bcnt++; // make zero a 1 return ($bcnt * $blk); } function getSizeStr( $insz ) { $sz = getBlkSz( $insz ); $ss = "$sz"; if($sz < 10) { $ss .= ' B'; } elseif($sz < 1024) { $ss .= ' B'; } elseif($sz < (1024*1024)) { $sk = ($sz / 1024) * 10; settype($sk,"int"); $sk = $sk / 10; $ss = "$sk"; $ss .= ' KB'; } elseif($sz < (1024*1024*1024)) { $sk = ($sz / (1024*1024)) * 10; settype($sk,"int"); $sk = $sk / 10; $ss = "$sk"; $ss .= ' MB'; } else { $sk = ($sz / (1024*1024*1024)) * 10; settype($sk,"int"); $sk = $sk / 10; $ss = "$sk"; $ss .= ' GB'; } return $ss; } function TranslatePerm( $in_Perms ) { $sP = ' '; if(($in_Perms & 0xC000) == 0xC000) // Socket $sP = 's'; elseif(($in_Perms & 0xA000) == 0xA000) // Symbolic Link $sP = 'l'; elseif(($in_Perms & 0x8000) == 0x8000) // Regular $sP = '−'; elseif(($in_Perms & 0x6000) == 0x6000) // Block special $sP = 'b'; elseif(($in_Perms & 0x4000) == 0x4000) // Directory $sP = 'd'; elseif(($in_Perms & 0x2000) == 0x2000) // Character special $sP = 'c'; elseif(($in_Perms & 0x1000) == 0x1000) // FIFO pipe $sP = 'p'; else // UNKNOWN $sP = 'u'; // owner $sP .= (($in_Perms & 0x0100) ? 'r' : '−') . (($in_Perms & 0x0080) ? 'w' : '−') . (($in_Perms & 0x0040) ? (($in_Perms & 0x0800) ? 's' : 'x' ) : (($in_Perms & 0x0800) ? 'S' : '−')); // group $sP .= (($in_Perms & 0x0020) ? 'r' : '−') . (($in_Perms & 0x0010) ? 'w' : '−') . (($in_Perms & 0x0008) ? (($in_Perms & 0x0400) ? 's' : 'x' ) : (($in_Perms & 0x0400) ? 'S' : '−')); // world $sP .= (($in_Perms & 0x0004) ? 'r' : '−') . (($in_Perms & 0x0002) ? 'w' : '−') . (($in_Perms & 0x0001) ? (($in_Perms & 0x0200) ? 't' : 'x' ) : (($in_Perms & 0x0200) ? 'T' : '−')); return $sP; } // $file = lstat("/bin/bash"); // echo TranslatePerm($file['mode']); // function isMyFile( $file, $cls ) // file name of form 'temp' + single-letter [a,b,c...] + number 0000 form + '.jpg' // ******************************************************************************* function isMyFile( $file, $cls ) { $ln = strlen($file); if($ln >= (4+1+4+1+3)) { $pos = strrpos($file,"."); $exten = substr($file,($pos+1)); if( ( substr($file,-4,4) == '.jpg' ) && ( substr($file,0,4) == 'temp' ) ) { if( $cls == substr($file,4,1) ) { // get 'a', 'b', 'c', ... , 's' (sunset 60) // got our TYPE return 1; } // got class, day, set } // got 'temp' part } // get length return 0; } function getDirList2 ($dirName, $dep, $mostrec, $mostnam, $mostcnt, $mostarr, $add_tab, $typ ) { $fdrgif = 'folder.gif'; $filgif = 'file.gif'; $d = dir($dirName); // note, with '/.' added while($entry = $d->read()) { //$locpath = $dirName."/".$entry; $locpath = substr($dirName,0,(strlen($dirName)-1)).$entry; if ($entry != "." && $entry != "..") { //$type = filetype($locpath); //$size = filesize($locpath); if (is_dir($locpath)) { //getDirList($locpath, ($dep + 1)); //echo "<img src=\"folder.gif\"> ".$entry." DIR $type <br>"; $dirlist[] = $entry; } else { //echo "<img src=\"file.gif\"> ".$entry." $size bytes $type<br>\n"; $fillist[] = $entry; } } } $d->close(); $totb = 0; if( $add_tab ) { echo "root=".getcwd()."/.<br>\n"; echo "<table width=\"90%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n"; echo "<tr><td>\n"; echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n"; echo "<tr bgcolor=\"#EFEFEF\"><td>img</td><td>name</td><td>size</td>"; echo "<td>date/time</td><td>permissions</td></tr>\n"; } if (isset($dirlist)) { asort($dirlist); foreach ($dirlist as $dir) { // $locpath = $dirName."/".$dir; $locpath = substr($dirName,0,(strlen($dirName)-1)).$dir; $stats = stat($locpath); $size = $stats['size']; // $totb += $size; $totb += getBlkSz($size); $filst = lstat($locpath); $perm = TranslatePerm($filst['mode']); if( $add_tab ) { echo "<tr><td><img src=\"" . $fdrgif; echo "\"></td><td>".$dir; echo "</td>"; echo "<td>$size</td>"; echo "<td><b>DIR</b></td>"; echo "<td>$perm</td>"; echo "</tr>\n"; } } } if (isset($fillist)) { asort($fillist); foreach ($fillist as $fil) { // $locpath = $dirName."/".$fil; // note: dir name ends with '/.', guaranteed!!! $locpath = substr($dirName,0,(strlen($dirName)-1)).$fil; $size = filesize($locpath); // $totb += $size; $totb += getBlkSz($size); $filtm = filemtime($locpath); // if( isMyFile( $fil, 's' ) ) { if( isMyFile( $fil, $typ ) ) { if( $filtm > $mostrec ) { $mostrec = $filtm; //$mostnam = $locpath; $mostnam = $fil; } $arr = array(); //$arr[] = $locpath; $arr[] = $fil; // 'temp' + class + number[1-9999] + '.jpg' $arr[] = $filtm; // keep the file time $arr[] = $size; // keep file size $arr[] = 0; // sort order $arr[] = $locpath; // keep WHOLE (relative) name $mostarr[] = $arr; // keep the files that MATCH class $mostcnt++; } $date = date ("F d Y H:i:s.", $filtm); // $date = date ("F d Y H:i:s.", filemtime($locpath)); $filst = lstat($locpath); $perm = TranslatePerm($filst['mode']); if( $add_tab ){ echo "<tr><td><img src=\"" . $filgif . "\"></td><td>".$fil."</td>\n"; echo "<td>$size (". getSizeStr($size) . ")</td>\n"; echo "<td>$date</td>\n"; echo "<td>$perm</td></tr>\n"; } } } if( $add_tab ) { // echo "<tr><td><b>Total ".$totb." bytes</b></td></tr>"; echo "<tr bgcolor=\"#EFEFEF\"><td>img</td>"; echo "<td><b>Total</b></td>"; echo "<td><b>".$totb." (". getSizeStr( $totb ) .")</b></td>"; echo "<td><b> - </b></td>"; echo "<td>perm</td>"; echo "</tr>\n"; echo "</table>\n"; echo "</td></tr>\n"; echo "</table>\n"; } } getDirList2 ($m_folder, 0, &$m_mostrec, &$m_mostnam, &$m_mostcnt, &$m_mostarr, 0, $m_type ); // did we collect the files ... if( $m_mostrec > 0 ) { $imx = count( $m_mostarr ); // get COUNT of FOUND ITEMS - full list of arrays $imx2 = $imx; // copy count $got_ord = 1; while($imx2) { $ft = 0; $idx = $imx; for($i = 0; $i < $imx; $i++) { $arr = $m_mostarr[$i]; // extract array if( $arr[3] == 0 ) { if( $arr[1] > $ft ) { $ft = $arr[1]; $idx = $i; } } } if( $idx < $imx ) { // found highest, latest $arr = $m_mostarr[$idx]; // extract array $arr[3] = $imx2; // set ORDER $m_mostarr[$idx] = $arr; // replace array // print "<p>Set order $arr[3]!</p>\r\n"; } else { print "<p>No order!</p>\r\n"; $got_ord = 0; } $imx2--; } if( $imx < 9 ) { // if a VERY SHORT list $m_msg = '<p>'; for($i = 0; $i < $imx; $i++) { $arr = $m_mostarr[$i]; // extract array $m_msg .= $arr[0] . ' '; $m_msg .= date("F d Y H:i:s.", $arr[1]) . ' '; $m_msg .= " $arr[2]"; $m_msg .= " $arr[3]"; $m_msg .= "<br>\r\n"; } $m_msg .= "</p>\r\n"; print "$m_msg\r\n"; } $imx2 = $imx; // copy count if( $got_ord ) { $mx_ord = 9; $got_ord = 0; print "<div align=\"center\">\r\n"; print "<center>\r\n"; print "<table border=\"2\" cellpadding=\"2\" cellspacing=\"2\" width=\"480\">\r\n"; while($imx2) { for($i = 0; $i < $imx; $i++) { $arr = $m_mostarr[$i]; // extract array if( $arr[3] == $imx2 ) { $m_msg = ''; if(($got_ord % 3) == 0) { $m_msg .= " <tr>"; } $m_msg .= ' <td width="160">'; $m_msg .= "<img src=\"$arr[4]\" alt=\""; $m_msg .= $arr[0] . ' '; $m_msg .= date("F d Y H:i:s.", $arr[1]) . ' '; $m_msg .= " $arr[2]"; $m_msg .= " $arr[3]"; $m_msg .= "\""; $m_msg .= " width=\"160\" height=\"120\""; $m_msg .= ">"; $m_msg .= " </td>"; $got_ord++; if(($got_ord % 3) == 0) { $m_msg .= " </tr>"; } print "$m_msg\r\n"; break; } } $imx2--; if($got_ord >= $mx_ord) { break; } } // fill in any missing SET-OF-THREE if( $got_ord % 3 ) { $m_msg = ' <td width="160">'; $m_msg .= 'no image'; $m_msg .= ' </td>'; $got_ord++; if(($got_ord % 3) == 0) { $m_msg .= " </tr>"; } print "$m_msg\r\n"; } print "</table>\n"; print "</center>\r\n"; print "</div>\r\n"; $m_msg = "<p>Most recent: $m_mostnam "; $m_msg .= date("F d Y H:i:s.", $m_mostrec); $m_msg .= " ($m_mostrec) of $m_mostcnt ($imx) ...</p>"; print "$m_msg\r\n"; } } else { $m_msg = "<p>No most recent ...</p>"; print "$m_msg\r\n"; } ?> <p align="center"><span style="background-color: #FFFFFF">|* <a href="index.html">index</a> *|</span></p> <p>EOP</p> </body> </html> <!-- 5 August 2005 - imagesa.php Version 0.0.1 - friendofflowers.com - grm -->