1 ) { // If we got optional args, then assign them $home = $args[1]; } else { // default $home = "/home/www.whoopis.com/html/howtos"; } // Grab the mod date of the file, then make it a unix timestamp // (= total seconds since the epoch) so that we can do date // arithmetic easily. $moddate = date("F d Y H:i:s", filemtime("$home/$filename")); $moddatestamp = strtotime($moddate); // 7 days times 60 seconds times 60 minutes times 24 hours = a week, // in seconds $weekduration = 7*(60*60*24); // Without a second param, date() returns the date/time right now $rightnow = date("F d Y H:i:s"); // Everything in seconds $weekago = strtotime($rightnow) - $weekduration; if ( $moddatestamp >= $weekago ) { // counter-intuitive; bigger timestamps are more recent echo " Last modified: $moddate"; } else { echo " Last modified: $moddate "; } } ////////////////////////////////////////////////////////////////////////////////////////////// function searchmod() { // Display search block and lastmod time // Takes $bgcolor, $path, and $pagename as arguments. // $path and $pagename are optional, defaults will be used // if this function is called without them. They are only // needed if the calling page is not under webroot (e.g. ~/public_html dirs) $args = func_get_args(); $bgcolor = $args[0]; if ( $bgcolor === "white" ) { // we have a white background $logocolor = "white"; $bgcolorvalue = "#ffffff"; $fontcolor = "#000000"; } else { // we have a black background $logocolor = "black"; $bgcolorvalue = "#000000"; $fontcolor = "#ffffff"; } // Start output, sub in variables where they matter echo '
| ';
// end of search part
if ( func_num_args() > 1 ) { // If we got optional args, then assign them
$path = $args[1];
$home = $path . "/";
$pagename = $args[2];
$self = $pagename;
}
else { // default
$home = "/home/www.whoopis.com/html";
$self = $_SERVER['PHP_SELF']; // name of the page calling this
}
// No slash here, _SERVER[PHP_SELF] comes with a slash already,
// and we do the same in the other case to match
$filename = "$home$self";
if ( file_exists($filename) ) {
// outputs e.g. somefile.txt was last modified: December 29 2002 22:16:23.
echo 'This page was last modified on ' . date ("F d Y H:i:s.", filemtime($filename)) . ''; } // finish table echo ' |
';
}
//////////////////////////////////////////////////////////////////////////////////
function printLink2man($theQuery) {
echo '
See the Unix man pages for '.$theQuery.' here.';
}
//////////////////////////////////////////////////////////////////////////////////
function printEurogeek() {
$imageDir = "eurogeek_imgs";
//////
$baseurl = "http://www.whoopis.com/$imageDir";
$imagePath = "/home/www.whoopis.com/html/$imageDir";
$handle = opendir($imagePath);
while ( false !== ($imageName = readdir($handle)) ) {
if ($imageName[0] != ".") {
$imgs[] .= $imageName;
}
}
closedir($handle);
// Shuffle the array
shuffle($imgs);
// NOTE: More efficient would be to just grab two random indices
// from the array BUT they could be identical. This guarantees
// that the two images will always be different. Plus it's what
// I thought of first, and it worked. ;)
if (func_num_args() > 0) { // if we got an arg, we need to format differently for the man page thing.
echo 'Get Euro-style oval stickers for Geeks!
';
}
else {
echo '
(scroll down to find the color one, or just click here to jump right to it.)
'; // links in black $googleAdBlack = '
'; // black background, white links $googleAdDark = '
'; ?>