USE AT OWN RISK
Generated: Tue Jul 31 15:22:13 2007 from phpinc10.php 2005/12/10 18.9 KB bytes.
<?php // phpinc10.php ... function, variable, include file, for img?????.php series // set the TABLE items ... global $m_row_wrap; global $m_case; if (($m_row_wrap == 3) || ($m_row_wrap == 5)) { $m_td_wid = ' <td width="160">'; $m_img_wid = ' width="160" height="120"'; $m_table = '<table border="2" cellpadding="2" cellspacing="2" width="480">'; } else { $m_td_wid = ' <td width="120">'; $m_img_wid = ' width="120" height="90"'; $m_table = '<table border="2" cellpadding="2" cellspacing="2" width="720">'; } if ($m_case == 'family') { // warning: if other than some reasonable STANDARD size is uploaded to 'page??' // then the resultant table can be strange ... $m_img_wid = ' height="120"'; // let the actual images, size the table } // 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 == '*') || ( $cls == '?' )) { // return all 'temp?????.jpg', or 'temp*' files return 1; } elseif( $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 isMyDSC ( $file ) { $ln = strlen($file); if($ln >= (3+4+1+3)) { $pos = strrpos($file,"."); $exten = substr($file,($pos+1)); if( ( strtolower(substr($file,-4,4)) == '.jpg' ) && ( strtolower(substr($file,0,3)) == 'dsc' ) ) { // got our TYPE return 1; } // got 'DSC' and '.JPG' parts } // get length return 0; } function get_alt_msg10 ( $idx ) { global $m_mostarr; $msg = ''; $imx = count( $m_mostarr ); // get COUNT of FOUND ITEMS - full list of arrays if (( $imx > 0 ) && ($idx >= 0) && ( $idx < $imx )) { $arr = $m_mostarr[$idx]; // extract array $date = date("F d Y H:i A", $arr[1]); $msg .= $arr[0] . ' '; $msg .= $date . ' '; //$msg .= " $arr[2]"; //$msg .= " $arr[3]"; } return $msg; } // end - function get_alt_msg10 ( $idx ) { function outOrderList10 () { global $m_mostarr, $m_page; global $m_row_wrap, $m_max_out; global $m_td_wid, $m_img_wid, $m_table; // like = ' width="160" height="120"'; global $m_first_out, $m_last_out; $imx = count( $m_mostarr ); // get COUNT of FOUND ITEMS - full list of arrays $imx2 = $imx; // copy count $td_wid = $m_td_wid; // ' <td width="160">'; $img_wid = $m_img_wid; // ' width="160" height="120"', or 'nothing'; $row_wrap = $m_row_wrap; $max_out = $m_max_out; if ( $imx > 0 ) { $mx_ord = $max_out; if( $mx_ord == -1 ) { $mx_ord = $imx; } $out_cnt = 0; // start the OUT COUNTER print "<div align=\"center\">\r\n"; print "<center>\r\n"; // print "<table border=\"2\" cellpadding=\"2\" cellspacing=\"2\" width=\"480\">\r\n"; print "$m_table\r\n"; print "<font size=\"-2\">\r\n"; $pgs = $m_page; if($m_page > 0) { $pgs--; } // reduce to zero start page if ($pgs > 0) { // bump to the first seek 'order' value while($pgs--) { if ($imx2 > $mx_ord) { $imx2 -= $mx_ord; } } } while($imx2) { for($i = 0; $i < $imx; $i++) { $arr = $m_mostarr[$i]; // extract array if( $arr[3] == $imx2 ) { // found current order $m_last_out = $i; // KEEP index of LAST OUT if( $out_cnt == 0 ) { $m_first_out = $i; // and KEEP index of FIRST OUT } $a_msg = get_alt_msg10($i); // get an ALT tag message // start message output $m_msg = ''; if(($out_cnt % $row_wrap) == 0) { $m_msg .= " <tr>"; } $m_msg .= $td_wid; $m_msg .= '<center>'; $m_msg .= "<a href=\"$arr[4]\" target=_blank>"; $m_msg .= "<img src=\"$arr[4]\" alt=\"$a_msg\""; $m_msg .= $img_wid; // like = " width=\"160\" height=\"120\"" $m_msg .= '>'; $m_msg .= '</a>'; $m_msg .= "<br>\r\n"; $m_msg .= add_font_2( date("F d Y", $arr[1]) ); $m_msg .= '</center>'; $m_msg .= "</td>"; $out_cnt++; if(($out_cnt % $row_wrap) == 0) { $m_msg .= " </tr>"; } print "$m_msg\r\n"; break; } } $imx2--; if($out_cnt >= $mx_ord) { break; } } // fill in any missing, of the current ROW only ... while( $out_cnt % $row_wrap ) { $m_msg = $td_wid; // = say ' <td width="160">'; $m_msg .= ' no image'; $m_msg .= ' </td>'; $out_cnt++; if(($out_cnt % $row_wrap) == 0) { $m_msg .= " </tr>"; } print "$m_msg\r\n"; } print "</font>\r\n"; print "</table>\r\n"; print "</center>\r\n"; print "</div>\r\n"; } } // end function outOrderList10 () function getDirList10 ($dirName, $typ ) { global $m_mostrec, $m_mostnam, $m_mostcnt, $m_mostarr; if (! is_dir($dirName) ) { return; } $d = dir($dirName); // note, with '/.' added // build up a LIST of directories, and files, in this folder while($entry = $d->read()) { //$locpath = $dirName."/".$entry; $locpath = substr($dirName,0,(strlen($dirName)-1)).$entry; if ($entry != "." && $entry != "..") { if (is_dir($locpath)) { $dirlist[] = $entry; } else { $fillist[] = $entry; } } } $d->close(); 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); $filtm = filemtime($locpath); if( isMyFile( $fil, $typ ) ) { $arr = array(); $arr[] = $fil; // 'temp' + class + number[1-9999] + '.jpg' $arr[] = $filtm; // keep the file time $arr[] = $size; // keep file size $arr[] = 0; // sort order ... done later ... on $filtm value $arr[] = $locpath; // keep WHOLE (relative) name // ================================================== $m_mostarr[] = $arr; // keep the files that MATCH class $m_mostcnt++; // bump COUNT === $m_mostcnt, param passed by REF ... if( $filtm > $m_mostrec ) { $m_mostrec = $filtm; $m_mostnam = $fil; } } } } } // end func getDirList2 ($dir, $rec, $nam, ($cnt == &$m_mostcnt), $arr, $typ ) function getDirListDSC10 ($dirName, $typ ) { global $m_mostrec, $m_mostnam, $m_mostcnt, $m_mostarr; if (! is_dir($dirName) ) { return; } $path = substr($dirName,0,(strlen($dirName)-1)); $d = dir($dirName); // note, with '/.' added // build up a LIST of directories, in this folder ... while($entry = $d->read()) { //$locpath = $dirName."/".$entry; $locpath = $path.$entry; if ($entry != "." && $entry != "..") { if (is_dir($locpath)) { $ln = strlen( $entry ); if ($ln > 4 ) { if ( strtolower(substr($entry,0,4)) == 'page' ) { $dirlist[] = $entry; } } //else { // $fillist[] = $entry; //} } } } $d->close(); if (isset($dirlist)) { asort($dirlist); // we have some 'page'???? directories, folders foreach ($dirlist as $dir) { $locpath = $path . $dir . '/.'; $d = dir($locpath); while ($entry = $d->read()) { if ($entry != "." && $entry != "..") { $locpath = $path . $dir . '/' . $entry; if (is_file ($locpath)) { if (isMyDSC( $entry )) { $fillist[] = $entry; $size = filesize($locpath); $filtm = filemtime($locpath); $arr = array(); $arr[] = $entry; // 'DSC' + number[1-99999] + '.JPG' $arr[] = $filtm; // keep the file time $arr[] = $size; // keep file size $arr[] = 0; // sort order ... done later ... on $filtm value $arr[] = $locpath; // keep WHOLE (relative) name // ================================================== $m_mostarr[] = $arr; // keep the files that MATCH class $m_mostcnt++; // bump COUNT === $m_mostcnt, param passed by REF ... if( $filtm > $m_mostrec ) { $m_mostrec = $filtm; $m_mostnam = $entry; } } } } } $d->close(); // close this sub-directory } // end for each 'page' folder } // got some 'page'???? folders } // end func getDirListDSC ($dir, $typ ) function ordFileList_by_date10 () { global $m_mostarr, $m_case; // this is the LIST of found files do display $imx = count( $m_mostarr ); // get COUNT of FOUND ITEMS - full list of arrays $imx2 = $imx; // copy count $got_ord = 1; // SORT the array of files, per their FILETIME // iterate, finding the most recent, non-ordered, each time while($imx2) { // set order to N, N-1, N-2, ..., 1 ... note 1 is last $ft = 0; // start with zero time $idx = $imx; for($i = 0; $i < $imx; $i++) { $arr = $m_mostarr[$i]; // extract array if( $arr[3] == 0 ) { if( $arr[1] > $ft ) { // if later $ft = $arr[1]; // get it, $idx = $i; // keeping the index to it } else { if ($m_case == 'flowers') { // if the DEFAULT display if( $arr[1] == $ft ) { // if equal, go to next $idx = $i; // keeping the index to it } } } // check each FILETIME ... } } if( $idx < $imx ) { // found highest, latest, NOT previously ORDERED ... (nnn ... 1) $arr = $m_mostarr[$idx]; // extract array, of file things $arr[3] = $imx2; // set ORDER $m_mostarr[$idx] = $arr; // replace array, with value update // print "<p>Set order $arr[3]!</p>\r\n"; } else { print "<p>No order! Internal error, or filetime is ZERO!</p>\r\n"; $got_ord = 0; } $imx2--; } return $got_ord; // 1 = success - should NEVER be zero } function get_Latest_txt10 () { global $m_mostrec, $m_mostarr, $m_mostcnt, $m_folder, $m_mostnam, $m_max_out, $m_type; global $m_first_out, $m_last_out; global $m_case; $imx = count( $m_mostarr ); // get COUNT of FOUND ITEMS - full list of arrays if ($imx > 0) { $msg = "<p>Information only: Found $imx ($m_mostcnt) files, $m_case series "; $msg .= ($m_type == '?') ? 'ALL' : $m_type; $msg .= " jpg in $m_folder ...<br>\r\n"; $msg .= "Most recent: $m_mostnam "; $msg .= date("F d Y H:i:s.", $m_mostrec); $msg .= " max_out="; $msg .= ($m_max_out == -1) ? 'ALL' : $m_max_out; $msg .= " ...<br>\r\n"; $msg .= 'First = '.get_alt_msg10($m_first_out); $msg .= ' Last = '.get_alt_msg10($m_last_out); $msg .= '</p>'."\r\n"; } else { $msg = "<p>No most recent found using $m_folder, type = $m_type ...</p>"; } return $msg; } // ***************************************************************************************** function ordDirList10 () { global $m_mostrec, $m_mostarr, $m_mostcnt, $m_folder, $m_mostnam, $m_max_out, $m_type; // did we collect the files we need ... if( $m_mostrec > 0 ) { $imx = count( $m_mostarr ); // get COUNT of FOUND ITEMS - full list of arrays $got_ord = ordFileList_by_date10 (); outOrderList10 (); } else { // UGH! we have NO image files MATCHING our criteria ... simple FAILED message ... $msg = "<p>No most recent found using $m_folder, type = $m_type ...</p>"; } // print "$msg\r\n"; // return $msg; return get_latest_txt10(); // should get more than the 'latest', but latest is good } // end ordDirList2() function add_g_span ( $msg ) { return '<span style="background-color: #0066cc;"><font style="color:#ffffff; font-size:small;">'.$msg.'</font></span>'; } function add_r_span ( $msg ) { return '<span style="background-color: #0066cc;"><font style="color:#ffffff; font-size:small;">R'.$msg.'</font></span>'; } function add_b_span10 ( $msg ) { return '<span style="background-color: #0066cc;"><font style="color:#ffffff; font-size:small;">'. $msg.'</font></span>'; } function add_b_span2 ( $msg ) { return '<span style="background-color: #eeeeff;"><font style="color: black;">'. $msg . '</font></span>'; } function get_c ( $m ) { return "case=$m"; } function get_case () { global $m_case; return get_c ($m_case); } function get_t ( $m ) { return "type=$m"; } function get_type () { global $m_type; return get_t($m_type); } function get_w ( $m ) { return "wrap=$m"; } function get_wrap () { global $m_row_wrap; return get_w($m_row_wrap); } function get_m ( $m ) { return "max=$m"; } function get_max () { global $m_max_out; return get_m($m_max_out); } function get_p ( $m ) { return "page=$m"; } function get_page () { global $m_page; return get_p( $m_page ); } function get_self () { global $m_package; // if 'server' not available if ( isset($_SERVER['PHP_SELF']) ) { return $_SERVER['PHP_SELF']; } return $m_package; } function add_bold ( $msg ) { return '<b>'.$msg.'</b>'; } function add_p_center ( $msg ) { return '<p align="center">'.$msg.'</p>'; } function add_font_2 ( $msg ) { return '<font size="-2">'.$msg.'</font>'; } function add_href_case ( $msg ) { global $m_n_case; $m = '<a href="'; $m .= get_self(); // = test7.php?'; $m .= '?case='.$m_n_case; $m .= '">'; return $m.$msg.'</a>'; } function add_bounds ( $m ) { return '| '.$m; } function add_href_page ( $msg ) { $m = '<font style="color:#ffffff; font-size:xx-small; text-decoration: none; font-stretch: narrower ">'; $m .= '<a href="'.get_self(); $m .= '?'.get_case(); $m .= '&'.get_type(); $m .= '&'.get_wrap(); $m .= '&'.get_max(); $m .= '&page='.$msg; $m .= '">'; $m .= add_bounds( $msg + 1); $m .= '</font></a>'; return $m; } function get_case_txt () { global $m_n_case; $m = 'Switch to '. $m_n_case; return $m; } function is_curr_arr ( $w, $m ) { global $m_row_wrap, $m_max_out; if ($m_row_wrap == $w) { if ( ($m_max_out == $m) || ($m_max_out == -1) ) { return 1; } } return 0; } function add_arr_page ( $msg, $w, $m ) { if ( is_curr_arr ( $w, $m ) ) { $ms = add_r_span( add_bounds( add_bold($msg)) ); } else { $ms = '<a href="'.get_self(); $ms .= '?'.get_case(); $ms .= '&'.get_type(); $ms .= '&'.get_w($w); $ms .= '&'.get_m($m); //$ms .= '&'.get_page(); $ms .= '&'.get_p(0); $ms .= '">'; $ms .= add_bounds($msg); $ms .= '</a>'; } return $ms; } function is_curr_day ( $t ) { global $m_type; if ($m_type == $t) { return 1; } return 0; } function add_day_page ( $msg, $t ) { if ( is_curr_day ( $t ) ) { $ms = add_r_span( add_bounds( add_bold($msg)) ); } else { $ms = '<a href="'.get_self(); $ms .= '?'.get_case(); $ms .= '&'.get_t($t); $ms .= '&'.get_wrap(); $ms .= '&'.get_max(); //$ms .= '&'.get_page(); $ms .= '&'.get_p(0); $ms .= '">'; $ms .= add_bounds($msg); $ms .= '</a>'; } return $ms; } function get_curr_link ( $msg ) { $ms = '<a href="'.get_self(); $ms .= '?'.get_case(); $ms .= '&'.get_type(); $ms .= '&'.get_wrap(); $ms .= '&'.get_max(); $ms .= '&'.get_page(); $ms .= '">'; $ms .= $msg; $ms .= '</a>'; return add_bounds($ms); } function get_all_link ( $msg ) { $ms = '<a href="'.get_self(); $ms .= '?'.get_case(); $ms .= '&'.get_type(); $ms .= '&'.get_wrap(); $ms .= '&'.get_m(-1); $ms .= '&'.get_p(0); $ms .= '">'; $ms .= add_bounds($msg); $ms .= '</a>'; return $ms; } function get_page_link ( $msg ) { global $m_case; $m = '<a href="'.get_self(); $m .= '?'.get_case(); $m .= '&'.get_type(); //$m .= '&'.get_wrap(); if ($m_case == 'family') { $m .= '&'.get_w(5); $m .= '&'.get_m(10); } else { $m .= '&'.get_w(3); $m .= '&'.get_m(9); } $m .= '&'.get_p(0); $m .= '">'; $m .= add_bounds( $msg ); $m .= '</a>'; return $m; } function get_def_max () { global $m_case; // 'flowers' (default) or 'family' global $m_max_dflo; // = 9; // default max out for FLOWERS global $m_max_dfam; // = 10; // default max out for FAMILY $max = $m_max_dflo; if ( $m_case == 'family' ) { $max = $m_max_dfam; } return $max; } function getPageMenu10 () { global $m_mostarr, $m_max_out, $m_page; global $m_pg_max; // say = 10; // establish MAXIMUM pages to show in menu line //global $m_package; // target href file global $m_type; // *=all, a,b,c,d ... $meol = "\r\n"; $me = get_self(); $msg = ''; $msg .= $meol . '<center><table width="90%" border="0">'.$meol; $imx = count ( $m_mostarr ); if ($imx > 0) { // we have FOUND an image count ... of this or that 'case' ... calculate PAGES available ... // establish PAGE menu ******************************************************************** $msg .= '<font size="-2">' . $meol; $msg .= "<tr>$meol"; $msg .= '<td width="60%" align="left">' . $meol; // lefthand column $pmsg = 'Select Page: '; $dmax = get_def_max(); // get default max images per page $rmi = $imx % $dmax; // get remainder $cnt = ($imx - $rmi) / $dmax; // get PAGE count if($rmi) $cnt++; // bump one more page // echo "Got $imx files rmi=$rmi pages=$cnt tot=" . ($cnt * $m_max_out) . " ap=$m_page<br>$meol"; $max = $m_pg_max; // normal MAXIMUM page display if($cnt < $max) $max = $cnt; if($m_page > $cnt) $m_page = $cnt; $pg = 0; $sp = 0; $rm = $m_page % $m_pg_max; // get remainder $sp = ($m_page - $rm) / $m_pg_max; // get start page // echo "Got $cnt pages max=$max rm=$rm sp=$sp... ap=$m_page<br>$meol"; $i = 0; $pg = 1 + ($sp * $m_pg_max); $mp = $pg + $m_pg_max - 1; if($mp > $cnt) $mp = $cnt; $rng = "(Range: $pg-$mp of $cnt)"; if($pg > $m_pg_max) { // is there a PREVIOUS $pg--; $pmsg .= $meol . "<a href=\"$me?page=" . $pg . '">Previous</a> '; } for( $i = 0; $i < $max; $i++ ) { $pg = $i + 1 + ($sp * $m_pg_max); if($pg > $cnt) break; //if( $m_type == '*' ) { if(( $pg == $m_page ) && ($m_max_out != -1) ) { // && ($got_one_file == 0)) { $pmsg .= "$pg "; } else { $pmsg .= $meol . "<a href=\"$me?page=" . $pg . '">' . $pg . '</a> '; } } if($pg < $cnt) { // is there a NEXT $pg++; $pmsg .= $meol . "<a href=\"$me?page=" . $pg . '">More</a> '; } //if ( $m_type == '*' ) { // && ($got_one_file == 0) ) { if ( $m_max_out == -1 ) { // we are showing them ALL $pmsg .= 'All '; // so no link on All } else { $pmsg .= $meol . "<a href=\"$me?page=" . $m_page . '&type=*&max=-1">All</a> '; } $msg .= add_font_2($pmsg); $msg .= '</td>'.$meol; $msg .= '<td width="20%" align="center">'.$meol; $msg .= add_font_2('Click on Image to Enlarge') . $meol; $msg .= '</td>'.$meol; $msg .= '<td width="20%" align="right">' . add_font_2($rng) . $meol; $msg .= "</td>$meol"; $msg .= "</tr>$meol"; $msg .= "</font>$meol"; } else { // out a FAILED message $msg .= "<tr>$meol"; $msg .= '<td width="100%" align="center">' . $meol; $msg = 'No pages available ... NO IMAGES FOUND!'; $msg .= '</td>' . $meol; $msg .= "</tr>$meol"; } $msg .= '</table></center>' . $meol; return $msg; } ?>