"; } else { echo ""; } echo "$title"; echo ""; /* Function to print number -- used by HowLong() */ function PrintNumber($var, $label) { if ($var > 0) { echo "$var $label "; } } /* Function to get timestamp of a remote file, used by HowLong() */ function fileStamp($domain, $file) { $file = "/" . $file; $fp = fsockopen ($domain, 80, $errno, $errstr, 30); $header = "HEAD $file HTTP/1.0\r\nHost: $domain\r\n\r\n"; if (!$fp){ echo "$errstr ($errno)"; return false; } fputs ($fp, $header); while (!feof($fp)) { $output .= fgets ($fp,128); } fclose ($fp); $begin = strpos($output, "Last-Modified: ") + 15; if($begin==15) //no last-modified (like yahoo.com) return false; $end = strpos($output, "\n", $begin); $time = substr($output, $begin, $end-$begin-1); return strtotime($time); } /* Function to format timestamp and such */ function HowLong($domain, $file) { // Gets the update times $imgCur = fileStamp($domain, $file); // Get the current time $now = date("U"); // Compare the two $diff = ($now - $imgCur); // Define some variables $year = 31536000; $week = 604800; $day = 86400; $hour = 3600; $minute = 60; // How many years? if ($diff >= $year) { $numYears = floor(($diff/$year)); } // Get difference modulo years before addressing weeks $diff %= $year; // ...and so on if ($diff >= $week) { $numWeeks = floor(($diff/$week)); } $diff %= $week; if ($diff >= $day) { $numDays = floor(($diff/$day)); } $diff %= $day; if ($diff >= $hour) { $numHours = floor(($diff/$hour)); } $diff %= $hour; if ($diff >= $minute) { $numMinutes = floor(($diff/$minute)); } $diff %= $minute; // Print the string PrintNumber($numYears, years); PrintNumber($numDays, days); PrintNumber($numHours, hours); PrintNumber($numMinutes, minutes); PrintNumber($diff, seconds); echo "ago"; } ?>
$title
"; if ($refresh) { echo "Page will automatically refresh every $refresh_rate seconds

"; } echo "
"; // create connection $conn = mysql_connect($hostname, $username, $password); if (!$conn) { die ("Couldn't connect to server : " . mysql_error()); } // select database $db = mysql_select_db($database, $conn); if (!$db) { die ("Couldn't select $database : " . mysql_error()); } /* If a cam is specified, feature it */ if ($cam != null) { // sql statement to pull values $sql = "SELECT cam_name, homepage, email, cam_url, id FROM cams WHERE id = '$cam'"; // execute SQL query and get result $sql_result = mysql_query($sql,$conn); if (!$sql_result) { die ("Couldn't execute query : " . mysql_error()); } // format results while ($row = mysql_fetch_array($sql_result)) { $name = $row["cam_name"]; $homepage = $row["homepage"]; $email = $row["email"]; $image = $row["cam_url"]; $id = $row["id"]; } // Seperate the domain from the filename, to pass to HowLong() $url_string = parse_url($image); $image_domain = $url_string[host]; $image_file = $url_string[path]; echo "

"; echo ""; echo ""; echo "
$name
"; if ($homepage != null) { echo "HOMEPAGE "; } if ( ($homepage != null)&&($email != null) ) { echo "~/~ "; } if ($email != null) { echo "EMAIL
"; } echo ""; echo "
Uploaded "; HowLong($image_domain, $image_file); echo "
"; echo "Click here to open popup
"; echo "

"; } /* Show the portal */ // sql statement $sql = "SELECT cam_name, cam_url, id FROM cams ORDER BY cam_name"; // execute query and get result $sql_result = mysql_query($sql, $conn); if (!$sql_result) { die ("Couldn't execute query : " . mysql_error()); } // Show the portal table echo ""; /* Format results */ // counter variable to keep track of rows $i = 1; // current date/time $date = date("U"); // Show each cam, and give it a colored border if it was recently updated while ($row = mysql_fetch_array($sql_result)) { $name = $row["cam_name"]; $image = $row["cam_url"]; $id = $row["id"]; // Seperate the domain from the filename $url_string = parse_url($image); $image_domain = $url_string[host]; $image_file = $url_string[path]; if ( ($name != null) && ($image != null) ) { $timestamp = fileStamp($image_domain, $image_file); if ( ($date - $timestamp) <= $recent) { echo ""; if ( ($i % $cols) == 0 ) { echo ""; } $i++; } } echo "
Cam portal
Add your cam!
"; } else { echo ""; } echo "
$name
"; ?>

FAP copyright 2004 by Erica Schechter