name; echo "
Log in as someone else.\n"; } else { echo "Not logged in"; } } function page_head($title, $user=null) { echo "$title\n"; project_banner($user); } function page_tail() { echo "

Return to ".PROJECT." main page
\n"; // put your copyright notice etc. here echo "

Copyright (c) 2003 ".PROJECT."
\n"; } function db_error_page() { page_head("Database error"); echo "

Database error

A database error occurred while handling your request.
Please try again later.
If the error persists, please submit a problem report. "; page_tail(); } function date_str($when) { return date("g:i A, l M j", $when); } function time_str($x) { if ($x == 0) return "---"; return strftime("%T %b %e, %Y", $x); } function start_table($width="") { echo ""; } function end_table() { echo "
\n"; } function row1($x, $ncols=2) { echo "$x\n"; } function row2($x, $y) { if ($x=="") $x="
"; if ($y=="") $y="
"; echo "$x$y\n"; } function row2_init($x, $y) { echo "$x$y\n"; } function row2_plain($x, $y) { echo "$x$y\n"; } function row3($x, $y, $z) { echo "$x$y$z\n"; } function random_string() { return md5(uniqid(rand())); } function print_country_select($country="None") { $x = posix_getcwd(); PassThru("$x/country_select '$country'"); } function print_login_form_aux($next_url, $user) { echo "
"; start_table(); row1("Log in"); row2("Your account key:
If you don't know your account key, click here. ", "" ); row2("", "" ); if ($user) { row1("Log out"); row2("You are logged in as $user->name", "Log out" ); } end_table(); } function print_login_form() { page_head("Please log in"); echo "

Please log in

This function requires that you log in. "; $next_url = $_SERVER[REQUEST_URI]; print_login_form_aux($next_url, null); page_tail(); } // Look for an element in a line of XML text // If it's a single-tag element, and it's present, just return the tag // function parse_element($xml, $tag) { $element = null; $x = strstr($xml, $tag); if ($x) { if (strstr($tag, "/>")) return $tag; $y = substr($x, strlen($tag)); $n = strpos($y, "<"); if ($n) { $element = substr($y, 0, $n); } } return $element; } // look for a particular element in the .htconfig.xml file // function parse_config($tag) { $element = null; $fp = fopen(".htconfig.xml", "r"); while (1) { $buf = fgets($fp, 1024); if ($buf == null) break; $element = parse_element($buf, $tag); if ($element) break; } fclose($fp); return $element; } // Call this if for dynamic pages // function no_cache() { header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 } // A few functions relating to email-address munging // A "munged" email address is of the form @X_Y, // where X is a valid email address and Y is a random string. // When an email address hasn't been validated yet, it's munged. // (Used during account creation and email address changes) // a valid email address is of the form A@B.C // where A, B, C are nonempty, // A and B don't contain @ or ., // and C doesn't contain @ // function is_valid_email_addr($addr) { $x = strstr($addr, "@"); if (!$x) return false; if (strlen($x) == strlen($addr)) return false; $x = substr($x, 1); if (strstr($x, "@")) return false; $y = strstr($x, "."); if (!$y) return false; if (strlen($y) == strlen($x)) return false; if (strlen($y) == 1) return false; return true; } function munge_email_addr($email, $string) { return "@".$email."_".$string; } // if email_addr is of the form @X_Y, split out the X and return true. // otherwise return false // function split_munged_email_addr($addr, $string, &$email) { if (substr($addr, 0, 1) != "@") return false; $x = strrchr($addr, "_"); if (!$x) return false; $y = substr($x, 1); if ($y != $string) return false; $email = substr($addr, 1, strlen($addr)-strlen($x)-1); return true; } ?>