If the email doesn't arrive in a few minutes, your ISP may be blocking it as spam. In this case please contact your ISP and ask them to not block email from $email_from. "; } // Initializes the session and returns the authenticator // for the session (if any) // function init_session() { $url = parse_url(MASTER_URL); $path = $url['path']; if (strlen($path)) { session_set_cookie_params(0, $path); } session_start(); // NOTE: in PHP 4.1+, s/key_exists/array_key_exists/ if (array_key_exists('authenticator', $_SESSION)) { return $_SESSION["authenticator"]; } else { return NULL; } } // if not logged in, put up login form and exit // function require_login($user) { if (!$user) { print_login_form(); exit(); } } function get_user_from_auth($auth) { if ($auth) return lookup_user_auth($auth); return NULL; } function get_user_from_id($id) { if ($id) return lookup_user_id($id); return NULL; } function get_logged_in_user($must_be_logged_in=true) { $authenticator = init_session(); if (!$authenticator) { $authenticator = $_COOKIE['auth']; } $user = get_user_from_auth($authenticator); if ($must_be_logged_in) { require_login($user); } return $user; } function show_login($user) { if ($user) { echo "Logged in as %s.\n", $user->name; echo "
Log in as someone else.\n"; } else { echo "Not logged in"; } } // output a select form item with the given name, // from a list of newline-delineated items from the text file. // If $selection is provided, and if it matches one of the entries in the file, // it will be selected by default. // function show_combo_box($name, $filename, $selection=null) { if (!file_exists($filename)) { echo "ERROR: $filename does not exist! Cannot create combo box.
"; exit(); } echo "\n"; fclose($file); } function page_head($title) { $styleSheet = URL_BASE . STYLESHEET; echo "".strip_tags($title)." "; project_banner($title); } function page_tail($is_main=false) { echo "

"; if (!$is_main) { echo "Return to ".PROJECT." main page
\n"; } // put your copyright notice etc. here echo "

Copyright © 2004 ".COPYRIGHT_HOLDER."
\n\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 date_str($x) { if ($x == 0) return "---"; // return date("g:i A, l M j", $when); return strftime("%Y-%m-%d", $x); } function time_str($x) { if ($x == 0) return "---"; //return strftime("%j %m-%d %H:%M:%S", $x)"; 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) { 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 rowify($string) { echo "$string"; } 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 ID:
If you don't know your account ID, click here. ", "" ); row2("Remember account ID 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); } // 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 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; } // 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 not containing _. // When an email address hasn't been validated yet, it's munged. // (Used during account creation and email address changes) 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, $auth, &$email) { if (substr($addr, 0, 1) != "@") return false; $x = strrchr($addr, "_"); if (!$x) return false; $y = substr($x, 1); if ($auth && $y != $auth) return false; $email = substr($addr, 1, strlen($addr)-strlen($x)-1); return true; } // Generates a standard set of links between associated multi-page documents. // All linked files must be of the form "$filename_.html". function write_page_links($filename, $currPageNum, $numPages) { echo "

Page $currPageNum of $numPages

"; $nextPageNum = $currPageNum + 1; $prevPageNum = $currPageNum - 1; // Make the 'previous' and 'next' page links as appropriate. if ($currPageNum > 1) { echo "Previous Page"; if ($currPageNum != $numPages) { echo " | "; } } if ($currPageNum != $numPages) { //fwrite($descriptor, "Next Page"); echo "Next Page"; } //fwrite($descriptor, "

Jump to Page:\n"); echo "

Jump to Page:\n"; // Make the individual page links (or a bold non-link for the current page). // for ($i = 1; $i <= $numPages; $i++) { if ($i != $currPageNum) { //fwrite($descriptor, "$i\n"); echo "$i\n"; } else { //fwrite($descriptor, "$i\n"); echo "$i\n"; } } } // 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($cobblestones) { return sprintf("%.2f", $cobblestones); } 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 intelligently_scale_image($sourcefile, $fw, $fh) { //In order to use the default built-in GD library all imageCreateTrueColor //has been commented out. //If you whish to enable the advanced GD features (resamples copy for instance) //simply switch back to the commented functions. list($ow, $oh, $from_type) = getimagesize($sourcefile); switch($from_type) { case 1: // GIF $srcImage = imageCreateFromGif($sourcefile); break; case 2: // JPG $srcImage = imageCreateFromJpeg($sourcefile); break; case 3: // PNG $srcImage = imageCreateFromPng($sourcefile); break; } $tempw = $fw; $temph = number_format((($oh*$fw)/$ow), 0); if($temph < $fh) { $tempw = number_format((($ow*$fh)/$oh), 0); $temph = $fh; } // $tempImage = imageCreateTrueColor($tempw, $temph); // imageAntiAlias($tempImage, true); $tempImage = imageCreate($tempw, $temph); // imagecopyresampled($tempImage, $srcImage, 0, 0, 0, 0, $tempw, $temph, $ow, $oh); imagecopyresized($tempImage, $srcImage, 0, 0, 0, 0, $tempw, $temph, $ow, $oh); // Calculate offsets if($temph < $fh) { $offsety = number_format(($temph/2)-($fh/2), 0); $offsetx = 0; } else { $offsety = 0; $offsetx = number_format(($tempw/2)-($fw/2), 0); } // $destImage = imageCreateTrueColor($fw, $fh); // imagecopyresampled($destImage, $tempImage, 0, 0, $offsetx, $offsety, $fw, $fh, $fw, $fh); $destImage = imageCreate($fw, $fh); imagecopyresized($destImage, $tempImage, 0, 0, $offsetx, $offsety, $fw, $fh, $fw, $fh); return $destImage; //imageJpeg($destImage, $destfile, $jpegquality); } ?>