phpinc2.php to HTML

index

USE AT OWN RISK

Generated: Tue Jul 31 15:22:13 2007 from phpinc2.php 2005/08/14 17.8 KB bytes.

<?php

// phpinc2.php ... function, variable, include file, for img?????.php series
// created: 10 August, 2005 - grm - see ealier version phpinc.pp ...
// updated: 14 August, 2005 - grm - macpcfirstaid.com ...
// set the TABLE items ...
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 = ''; // 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 outOrderList ( $imx, $got_ord, $m_mostarr, $row_wrap, $max_out ) {
// function outOrderList ( $imx, $got_ord, $m_mostarr ) {
function outOrderList () {
   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"';
   $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";
   if ($m_page > 0) { // bump to the first seek 'order' value
   $pgs = $m_page; // get the required PAGE
   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
   $date = date("F d Y H:i:s.", $arr[1]);
   $a_msg = '';
   $a_msg .= $arr[0] . ' ';
   $a_msg .= $date . ' '; // = date("F d Y H:i:s.", $arr[1]) . ' ';
   $a_msg .= " $arr[2]";
   $a_msg .= " $arr[3]";

   $m_msg = '';
   if(($out_cnt % $row_wrap) == 0) {
   $m_msg .= " <tr>";
   }
   $m_msg .= $td_wid;
   // $m_msg .= "<font size=\"-2\">";
   $m_msg .= '<center>';
   $m_msg .= "<a href=\"$arr[4]\">";
   $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 .= "<font size=\"-2\">";
   $m_msg .= "<br>";
   // $m_msg .= "<font size=\"-2\">";
   $m_msg .= $arr[0]; // like, temp?nnnn.jpg
   $m_msg .= ' ' . date("H:i:s", $arr[1]);
   //$m_msg .= " $date";
   //$m_msg .= $a_msg;
   $m_msg .= "</font>";
   $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>";
   print "</table>\n";
   print "</center>\r\n";
   print "</div>\r\n";
   }
} // end function outOrderList ()


function getDirList2 ($dirName, $mostrec, $mostnam, $mostcnt, $mostarr, $typ ) { 
 $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
   // ==================================================
   $mostarr[] = $arr; // keep the files that MATCH class
   $mostcnt++; // bump COUNT === $m_mostcnt, param passed by REF ...
   if( $filtm > $mostrec ) {
   $mostrec = $filtm;
   $mostnam = $fil;
   }
   }
 }

 }
} // end func getDirList2 ($dir, $rec, $nam, ($cnt == &$m_mostcnt), $arr, $typ )

function getDirListDSC ($dirName, $mostrec, $mostnam, $mostcnt, $mostarr, $typ ) { 
   $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
   // ==================================================
   $mostarr[] = $arr; // keep the files that MATCH class
   $mostcnt++; // bump COUNT === $m_mostcnt, param passed by REF ...
   if( $filtm > $mostrec ) {
   $mostrec = $filtm;
   $mostnam = $entry;
   }
   }
   }
   }
   }
   $d->close(); // close this sub-directory
   } // end for each 'page' folder
   } // got some 'page'???? folders
} // end func getDirListDSC ($dir, $rec, $nam, ($cnt == &$m_mostcnt), $arr, $typ )

function ordFileList_by_date () {
   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_txt () {
   global $m_mostrec, $m_mostarr, $m_mostcnt, $m_folder, $m_mostnam, $m_max_out, $m_type;
   $imx = count( $m_mostarr ); // get COUNT of FOUND ITEMS - full list of arrays
   if ($imx > 0) {
   $msg = "<p>Found $imx ($m_mostcnt) files, temp series ";
   $msg .= ($m_type == '?') ? 'ALL' : $m_type;
   $msg .= " jpg in $m_folder ... ";
   $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 .= "...</p>";
   } else {
   $msg = "<p>No most recent found using $m_folder, type = $m_type ...</p>";
   }
   return $msg;
}


// *****************************************************************************************
function ordDirList2 () {
   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_date ();
   //outOrderList ( $imx, $got_ord, $m_mostarr );
   outOrderList ();
   } 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_txt(); // should get more than the 'latest', but latest is good
} // end ordDirList2()

function get_index_link () {
   return '<a href="index.html">index</a>';
}

function out_the_menu2 () {
   $eol = "\r\n"; 
   print '<p align="center">'.$eol;
   print '<span style="background-color: #FFFFFF">'.$eol;
   print '|* ';
   print get_index_link(); // <a href="index.html">index</a>
   print ' *|';
   print '* <a href="imagea9.php">'.$eol;
   print 'Friday(a)</a> *|* <a href="imageb9.php">'.$eol;
   print 'Saturday(b)</a> *|* <a href="imagec9.php">'.$eol;
   print 'Sunday(c)</a> *|* <a href="imaged9.php">'.$eol;
   print 'Other(d)</a> *|* <a href="images9.php">'.$eol;
   print 'Special(s)</a> *|* <a href="imgall.php">'.$eol;
   print 'All</a> *|* <a href="imgall9.php">'.$eol;
   print 'All-9</a> *|* <a href="imgall15.php">'.$eol;
   print 'All-15</a> *|* <a href="imgall21.php">'.$eol;
   print 'All-21</a> *|* <a href="imgall28.php">'.$eol;
   print 'All-28</a> *|* <a href="famall.php">'.$eol;
   print 'Family</a> *|'.$eol;
   print '</span>'.$eol;
   print '</p>'.$eol;
} // end out_menu()

function add_g_span ( $msg ) {
   return '<span style="background-color: #88ff88">'.$msg.'</span>';
}
function add_r_span ( $msg ) {
   return '<span style="background-color: #ff8888">'.$msg.'</span>';
}
function add_b_span ( $msg ) {
   return '<span style="background-color: #8888ff">'.$msg.'</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 () {
   //return 'test7.php';
   return $_SERVER['PHP_SELF'];
}

function add_bold ( $msg ) {
   return '<b>'.$msg.'</b>';
}

function add_p_center ( $msg ) {
   return '<p align="center">'.$msg.'</p>';
}

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 = '<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 .= '</a>';
   return $m;
}


function get_case_txt () {
   global $m_n_case;
   $m = 'Switch to ';
   $m .= add_bold( $m_n_case );
   return $m;
}

function is_curr_arr ( $w, $m ) {
   global $m_row_wrap, $m_max_out;
   if ( ($m_row_wrap == $w) &&
   ($m_max_out == $m) ) {
   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 get_array_menu () {
   global $m_case;
   $m = add_bounds('Switch Array ');
   if ( $m_case == 'family' ) {
   $m .= add_arr_page ( '5x2=10', 5, 10 );
   } else {
   $m .= add_arr_page ( '3x3= 9', 3, 9 );
   }
   $m .= add_arr_page ( '5x3=15', 5, 15 );
   $m .= add_arr_page ( '7x3=21', 7, 21 );
   $m .= add_arr_page ( '7x4=28', 7, 28 );
   return $m;
}


function get_case_menu () {
   return add_bounds(add_href_case(get_case_txt()));
}

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_day_menu () {
   global $m_case, $m_type;
   $m = add_bounds('Switch Day ');
   if ( $m_case == 'flowers' ) {
   $m .= add_day_page ( 'All', '*' );
   $m .= add_day_page ( 'Fri', 'a' );
   $m .= add_day_page ( 'Sat', 'b' );
   $m .= add_day_page ( 'Sun', 'c' );
   $m .= add_day_page ( 'Oth', 'd' );
   $m .= add_day_page ( 'Spe', 's' );
   }
   return $m;
}

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;
}

// note: this imx count should/must equal $m_mostcnt, but NOT USED information
function getPageMenu () {
   global $m_mostarr, $m_max_out, $m_page;
   $msg = '';
   $imx = count ( $m_mostarr );
   if ($imx > 0) {
   // we have FOUND an image count ... of this or that 'case' ... calculate PAGES available ...
   // establish PAGE menu ********************************************************************
   $mx_ot = $m_max_out;
   if ($mx_ot == -1) {
   $mx_ot = $imx;
   }
   $pgs = $imx / $mx_ot;
   settype($pgs, "int"); // reduce it to an integer 
   if ($imx % $mx_ot) { $pgs++; } // bump for any 'remainder' ...
   if ($pgs == 0) { $pgs++; } // make sure, at least ONE page ...
   if ($m_page > 0) { // ok, we WANT to display, GREATER than the LATEST page - rows x cols = max
   if ($m_max_out == -1) {
   // this is ALL ... overrides a PAGE display
   $m_page = 0; // set ZERO PAGE
   } elseif ($m_max_out > 0) {
   if ($m_page > $pgs ) { // can NOT have this
   $m_page = $pgs; // set the LAST PAGE DISPLAY
   }
   }
   }
   // build PAGE menu ...
   $msg .= add_bounds('Select Page ');
   for ($i = 0; $i < $pgs; $i++) {
   if ( $m_page == $i ) {
   $msg .= add_r_span( add_bounds( add_bold(($i + 1) )) );
   } else {
   $msg .= add_href_page ( $i );
   }
   $msg .= " \r\n";
   }
   $msg .= add_b_span(get_all_link('All'));
   $msg .= " ($pgs $m_max_out $imx)";
   //return (add_g_span(add_p_center($msg))."\r\n"); // output the PAGES available ...
   // print (add_g_span(add_p_center($msg))."\r\n"); // output the PAGES available ...
   // $msg = ( add_g_span(add_p_center($msg))."\r\n" ); // output the PAGES available ...
   } else {
   $msg = 'No pages available ...';
   }
//   print (add_g_span(add_p_center($msg))."\r\n"); // output the PAGES available ...
   return $msg;
}

?>

index

Valid HTML 4.01 Transitional