2002-04-30 22:22:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("db.inc");
|
|
|
|
|
2002-08-13 00:08:08 +00:00
|
|
|
define("EMAIL_EXISTS", -1);
|
|
|
|
define("EMAIL_UPDATED", 1);
|
|
|
|
define("EMAIL_FAIL", -2);
|
|
|
|
|
2002-08-12 22:16:34 +00:00
|
|
|
define("LG_FONT", "<font size=+1>");
|
|
|
|
define("SM_FONT", "<font size=-1>");
|
2002-08-13 00:08:08 +00:00
|
|
|
|
2002-09-27 06:12:50 +00:00
|
|
|
define("TD", "<td bgcolor=cccccc>");
|
|
|
|
define("TD2", "<td colspan=2 bgcolor=cccccc>");
|
|
|
|
define("TD3", "<td colspan=3 bgcolor=cccccc>");
|
2002-08-13 00:08:08 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
define("TABLE", "<table cellpadding=10 cellspacing=4 border=0 width=100%>");
|
2002-12-06 21:37:30 +00:00
|
|
|
define("VISTABLE", "<table cellpadding=2 cellspacing=0 border=1 width=100%>");
|
2002-08-12 22:16:34 +00:00
|
|
|
define("TABLE2", "<table width=580>");
|
2002-08-13 00:08:08 +00:00
|
|
|
|
2002-09-27 06:12:50 +00:00
|
|
|
define("BG_COLOR", " bgcolor=ffffff ");
|
2002-04-30 22:22:54 +00:00
|
|
|
define("TITLE_COLOR", " bgcolor=000000 ");
|
2002-08-05 23:20:57 +00:00
|
|
|
define("TITLE_FONT", " <font color=ffffff> ");
|
2002-04-30 22:22:54 +00:00
|
|
|
define("BODY_COLOR", " bgcolor=ffffff ");
|
2002-11-11 10:26:40 +00:00
|
|
|
define("PROJECT", "Astropulse");
|
2002-11-25 19:44:40 +00:00
|
|
|
define("MASTER_URL", "http://maggie.ssl.berkeley.edu/ap/");
|
2002-08-13 23:59:34 +00:00
|
|
|
|
2002-12-06 21:37:30 +00:00
|
|
|
// Sends the authenticator to the given email address
|
|
|
|
function send_auth_email($email_addr, $auth) {
|
|
|
|
mail($email_addr, "Account information for ".PROJECT,
|
|
|
|
"The URL for this project is \n\n".MASTER_URL."\n\nYour account key is \n\n$auth\n\nCopy this information into the BOINC client.");
|
|
|
|
}
|
|
|
|
|
2002-12-04 19:22:58 +00:00
|
|
|
// Initializes the session and returns the authenticator
|
|
|
|
// for the session (if any)
|
|
|
|
function init_session() {
|
|
|
|
session_start();
|
2002-12-11 23:09:22 +00:00
|
|
|
if (!isset($_SESSION["authenticator"])) {
|
2002-12-16 21:41:41 +00:00
|
|
|
$_SESSION["authenticator"] = $authenticator;
|
2002-12-04 19:22:58 +00:00
|
|
|
}
|
|
|
|
return $_SESSION["authenticator"];
|
|
|
|
}
|
|
|
|
|
2002-12-16 21:41:41 +00:00
|
|
|
// requires that the user be logged in
|
|
|
|
function require_login($user) {
|
|
|
|
if (!$user) {
|
|
|
|
print_login_form();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-04 19:22:58 +00:00
|
|
|
function get_user_from_auth($auth) {
|
|
|
|
if ($auth) return lookup_user_auth($auth);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
function get_user_from_cookie() {
|
|
|
|
$auth = "";
|
|
|
|
$c = getenv("HTTP_COOKIE");
|
|
|
|
$d = str_replace("; ", "&", $c);
|
|
|
|
parse_str($d);
|
|
|
|
if ($auth) return lookup_user_auth($auth);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_login($user) {
|
2002-08-07 18:56:55 +00:00
|
|
|
if ($user) {
|
2002-11-12 17:01:16 +00:00
|
|
|
echo "Logged in as %s.\n", $user->name;
|
|
|
|
echo "<br><a href=login.php>Log in as someone else.</a>\n";
|
2002-08-07 18:56:55 +00:00
|
|
|
} else {
|
2002-11-12 17:01:16 +00:00
|
|
|
echo "Not logged in";
|
2002-08-07 18:56:55 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function page_head($title) {
|
2002-11-08 17:21:45 +00:00
|
|
|
echo "<head><title>$title</title><body ".BG_COLOR.">\n";
|
|
|
|
|
|
|
|
// Put your project title and logo here
|
|
|
|
|
2002-11-11 10:26:40 +00:00
|
|
|
echo "<h2>".PROJECT."</h2><hr>\n";
|
2002-11-08 17:21:45 +00:00
|
|
|
echo "<h3>$title</h3>\n";
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-12-11 00:12:42 +00:00
|
|
|
function page_tail() {
|
2002-12-11 23:09:22 +00:00
|
|
|
|
2002-12-16 21:41:41 +00:00
|
|
|
echo "<br><br><a href=index.php>Return to main ".PROJECT." page</a><br>\n";
|
2002-11-25 22:14:05 +00:00
|
|
|
|
2002-11-08 17:21:45 +00:00
|
|
|
// put your copyright notice etc. here
|
|
|
|
|
2002-12-06 21:37:30 +00:00
|
|
|
echo "<hr>Copyright (c) 2002 Sample Project\n";
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
|
|
|
echo "<table width=600 border=2 cellpadding=4>";
|
|
|
|
}
|
|
|
|
|
|
|
|
function row($x, $y) {
|
|
|
|
echo "<tr><td width=30% valign=top align=right>$x</td><td>$y</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
2002-08-12 22:16:34 +00:00
|
|
|
function row2($x, $y) {
|
|
|
|
echo "<tr><td>$x</td><td>$y</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
2002-09-05 22:19:23 +00:00
|
|
|
function row2a($x, $y) {
|
|
|
|
echo "<tr><td>$x</td><td width=50%>$y</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
2002-08-12 22:16:34 +00:00
|
|
|
function row3($x, $y, $z) {
|
2002-08-12 23:31:43 +00:00
|
|
|
echo "<tr><td width=30% valign=top align=right>$x</td><td>$y</td><td>$z</td></tr>\n";
|
2002-08-12 22:16:34 +00:00
|
|
|
}
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
function random_string() {
|
|
|
|
return md5(uniqid(rand()));
|
|
|
|
}
|
|
|
|
|
|
|
|
function print_country_select() {
|
2002-11-09 20:26:50 +00:00
|
|
|
$x = posix_getcwd();
|
|
|
|
PassThru("$x/country_select");
|
|
|
|
}
|
|
|
|
|
2002-11-11 19:40:22 +00:00
|
|
|
function print_login_form() {
|
|
|
|
page_head("Please log in");
|
|
|
|
echo "This function requires that you be logged in.\n";
|
2002-11-26 00:39:58 +00:00
|
|
|
echo "Please <a href=login_form.php>log in</a>.\n<p>\n";
|
2002-11-11 19:40:22 +00:00
|
|
|
page_tail();
|
|
|
|
}
|
|
|
|
|
2002-11-09 20:26:50 +00:00
|
|
|
// look for an element in some XML text
|
|
|
|
//
|
|
|
|
function parse_element($xml, $tag) {
|
|
|
|
$element = null;
|
|
|
|
$x = strstr($xml, $tag);
|
|
|
|
if ($x) {
|
|
|
|
$y = substr($x, strlen($tag));
|
|
|
|
$n = strpos($y, "<");
|
|
|
|
if ($n) {
|
|
|
|
$element = substr($y, 0, $n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $element;
|
|
|
|
}
|
|
|
|
|
|
|
|
// look for a particular element in the config.xml file
|
|
|
|
//
|
|
|
|
function parse_config($tag) {
|
|
|
|
$element = null;
|
|
|
|
$fp = fopen("config.xml", "r");
|
|
|
|
while (1) {
|
|
|
|
$buf = fgets($fp, 1024);
|
|
|
|
if ($buf == null) break;
|
|
|
|
$element = parse_element($buf, $tag);
|
|
|
|
if ($element) break;
|
|
|
|
}
|
|
|
|
fclose($fp);
|
|
|
|
return $element;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-08-13 00:08:08 +00:00
|
|
|
?>
|