name; echo "
Log in as someone else.\n"; } else { echo "Not logged in"; } } function page_head($title, $java_onload="") { $styleSheet = URL_BASE . STYLESHEET; $rssname = PROJECT . " RSS 2.0"; $rsslink = URL_BASE . "rss_main.php"; if (defined("CHARSET")) { header("Content-type: text/html; charset=".tr(CHARSET)); } echo "".strip_tags($title)." "; if ($java_onload!=""){echo ""; } else { echo "";} display_cvs_versions(); project_banner($title); } function page_tail_aux($show_return, $show_date) { project_footer($show_return, $show_date); echo "\n"; } function page_tail_main($show_date=false) { page_tail_aux(false, $show_date); } function page_tail($show_date=false) { page_tail_aux(true, $show_date); } function display_cvs_versions(){ global $cvs_version_tracker; echo "\n\n"; for ($i=0;$i\n"; } } function db_error_page() { page_head("Database error"); echo "A database error occurred while handling your request.
Please try again later.
If the error persists, please submit a problem report. "; page_tail(); } function profile_error_page($str) { page_head("Profile error"); echo "$str
\n"; echo "

Click your browser's Back button to try again.\n

\n"; page_tail(); } function error_page($msg) { page_head("Unable to handle request"); echo $msg; page_tail(); exit(); } // takes argument in second and returns a human formatted time string // in the form D days + h Hours + m Min + s sec. function time_diff($x) { $days = (int)($x/86400); $hours = (int)(($x-$days*86400)/3600); $minutes = (int)(($x-$days*86400-$hours*3600)/60); $seconds = (int)($x % 60); $datestring = ""; if ($days) $datestring .= "$days days "; if ($hours || strlen($datestring)) $datestring .= "$hours hours "; if ($min || strlen($datestring)) $datestring .= "$minutes min "; if ($seconds) $datestring .= "$seconds sec"; return $datestring; } function date_str($x) { if ($x == 0) return "---"; return gmdate('j M Y', $x); } function time_str($x) { if ($x == 0) return "---"; return gmdate('j M Y G:i:s', $x) . " UTC"; } function pretty_time_str($x) { return time_str($x); } function start_table($extra="width=100%") { echo ""; } function start_table_noborder($width="100%") { echo "
"; } function end_table() { echo "
\n"; } function row1($x, $ncols=2, $class="heading") { 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 row4($xx, $xy, $yx, $yy) { echo "$xx$xy" . "$yx$yy "; } function rowify($string) { echo "$string"; } function row_array($x) { echo ""; foreach ($x as $h) { echo "$h"; } echo "\n"; } function row_heading_array($x) { echo ""; foreach ($x as $h) { echo "$h"; } echo "\n"; } function random_string() { return md5(uniqid(rand(), true)); } 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("Remember account key on this computer", "" ); row2("", "" ); if ($user) { row1("Log out"); row2("You are logged in as $user->name", "Log out" ); } end_table(); echo " "; } function print_login_form() { page_head("Please log in"); echo " 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; } if (!function_exists("file_get_contents")) { function file_get_contents($path) { $x = ""; $f = fopen($path, "r"); if ($f) { while (!feof($f)) $x .= fread($f, 4096); fclose($f); } return $x; } } $g_config = null; function get_config() { global $g_config; if ($g_config == null) { $g_config = file_get_contents("../../config.xml"); } return $g_config; } // look for a particular element in the ../../config.xml file // function parse_config($config, $tag) { $element = parse_element($config, $tag); return trim($element); } // return true if XML contains either or 1 // function parse_bool($xml, $tag) { $x = "<$tag/>"; if (strstr($xml, $x)) return true; $x = "<$tag>"; $y = (int)parse_element($xml, $x); if ($y != 0) return true; return false; } // 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 } // Generates a legal filename from a parameter string. function get_legal_filename($name) { $name = ereg_replace(',', '', $name); return ereg_replace(' ', '_', $name); } // Returns a string containing as many words // (being collections of characters separated by the character $delimiter) // as possible such that the total string length is <= $chars characters long. // If $ellipsis is true, then an ellipsis is added to any sentence which // is cut short. function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { $words = explode($delimiter, $sentence); $total_chars = 0; $count = 0; $result = ''; do { if ($count > 0) { $result = $result . ' ' . $words[$count]; } else { $result = $result . $words[$count]; } $total_chars += strlen($words[$count]) + 1; $count++; } while ($count < count($words) && ($total_chars + strlen($words[$count])) <= $max_chars); if ($ellipsis && ($count < count($words))) { $result = $result . '...'; } return $result; } function format_credit($x) { return number_format($x, 2); } function project_is_stopped() { if (file_exists("../../stop_web")) return true; return false; } function user_links($user) { $x = "id>$user->name"; if ($user->has_profile) { $x .= " id>"; } return $x; } function host_link($hostid) { if ($hostid) { return "$hostid"; } else { return "---"; } } function open_output_buffer() { ob_start(); ob_implicit_flush(0); } function close_output_buffer($filename) { $fh = fopen($filename, "w"); $page = ob_get_contents(); ob_end_clean(); fwrite($fh, $page); fclose($fh); } function html_info() { return "
You may use HTML tags\n"; } function get_int($name, $optional=false) { $x = $_GET[$name]; if (!is_numeric($x)) { if ($optional) { return null; } else { error_page("missing or bad parameter: $name $x"); } } return (int)$x; } function post_int($name, $optional=false) { $x = $_POST[$name]; if (!is_numeric($x)) { if ($optional) { return null; } else { error_page("missing or bad parameter: $name $x"); } } return (int)$x; } function get_str($name, $optional=false) { $x = $_GET[$name]; if (!$x && !optional) { error_page("missing or bad parameter: $name"); } return $x; } function get_venue($name) { $x = $_GET[$name]; if ($x == "") return $x; if ($x == "home") return $x; if ($x == "work") return $x; if ($x == "school") return $x; error_page("no such venue: $x"); } function post_str($name, $optional=false) { $x = $_POST[$name]; if (!$x && !optional) { error_page("missing or bad parameter: $name"); } return $x; } ?>