admin account creation

svn path=/trunk/boinc/; revision=2171
This commit is contained in:
David Anderson 2003-08-22 05:36:25 +00:00
parent 7de1f7ff54
commit 39bc2da38d
46 changed files with 123 additions and 112 deletions

View File

@ -5899,3 +5899,14 @@ Karl 2003/08/21
boinc_api.C
boinc_api.h
windows_opengl.C
David Aug 21 2003
- added administrative function for adding accounts
(even if account creation is disabled in config)
- html_ops can now refer to project-specific stuff (e.g. PROJECT)
- removed include of db.inc in html_user/util.inc.
This lets you use util.inc from html_ops
html_ops/
create_account_form.php (new)
create_acction_action.php (new)

View File

@ -0,0 +1,43 @@
<?
require_once("util_ops.inc");
require_once("../html_user/util.inc");
db_init();
$email_addr = $_GET["email_addr"];
// see if email address is taken
$query = "select * from user where email_addr='$email_addr'";
$result = mysql_query($query);
$user = mysql_fetch_object($result);
if ($user) {
echo "That email address ($email_addr) is taken";
exit();
}
$authenticator = random_string();
$munged_email_addr = munge_email_addr($email_addr, $authenticator);
$user_name = $_GET["user_name"];
$t = time();
$query = "insert into user (create_time, email_addr, name, authenticator) values ($t, '$munged_email_addr', '$user_name', '$authenticator')";
$result = mysql_query($query);
if (!$result) {
echo "couldn't create account:".mysql_error();
exit();
}
$url = URL_BASE."/account_created.php?email_addr=".urlencode($email_addr);
mail($email_addr, PROJECT. " account created",
"This email confirms the creation of your ".PROJECT." account.
".PROJECT." URL: ".MASTER_URL."
Your account key: $authenticator\n
Please save this email.
You will need your account key to log in to the ".PROJECT." web site.
To finish registration, go to
$url
"
);
?>

View File

@ -0,0 +1,18 @@
<?
// use this to create accounts while regular account creation is disabled
require_once("util_ops.inc");
echo "
<h2>Create ".PROJECT." account</h2>
<form action=create_account_action.php>
";
start_table();
row2("Name", "<input size=32 name=user_name>");
row2("Email address", "<input size=32 name=email_addr>");
row2("", "<input type=submit value=OK>");
echo "
</form>
";
?>

View File

@ -1,13 +1,14 @@
<?php
require_once("db_ops.inc");
require_once("util_ops.inc");
$cgi_url = parse_config("<cgi_url>");
$w = 7*86400;
echo "
<title>BOINC Project Management</title>
<h2>BOINC Project Management</h2>
<title>BOINC Project Management for ".PROJECT."</title>
<h2>BOINC Project Management for ".PROJECT."</h2>
<p>
Browse database:
<ul>
@ -38,6 +39,7 @@ echo "
<a href=$cgi_url/stripchart.cgi>Stripcharts</a> |
<a href=show_log.php>Show/Grep all logs</a> |
<a href=show_log.php?f=mysql*.log&l=-20>Tail MySQL logs</a>
<br><a href=create_account_form.php>Create account</a>
";
// TODO: Add functionality to list the number of recommends / rejects received

View File

@ -1,6 +1,8 @@
<?php
require_once("db_ops.inc");
require_once("../html_user/util.inc");
require_once("../html_user/project_specific/project.inc");
define("EMAIL_EXISTS", -1);
define("EMAIL_UPDATED", 1);
@ -20,58 +22,16 @@ define("TITLE_COLOR", " bgcolor=000000 ");
define("TITLE_FONT", " <font color=ffffff> ");
define("BODY_COLOR", " bgcolor=ffffff ");
define("NOLOGIN", "Not logged in. Click <a href=login.php>here</a> to login.\n");
define("BADPASS", "The password you entered is incorrect. Click the <b>Back</b> button on your browser to re-enter your password or try again later.");
define("DIFFPASS", "You've typed two different passwords. Click the <b>Back</b> button on your browser to edit your information, making sure you type the same password in both password fields.");
define("PROJECT", "Sample project");
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) {
if ($user) {
printf("Logged in as %s.\n", $user->name);
printf("<br><a href=login.php>Log in as someone else.</a>\n");
} else {
echo NOLOGIN;
}
}
function page_head($title) {
function admin_page_head($title) {
echo "<head><title>$title</title><body " . BODY_COLOR . ">\n";
echo TABLE . "<tr " . TITLE_COLOR . "><td>" . TITLE_FONT . "<font size=6><b><a href=index.php>".PROJECT.":</a> $title</b></font></td></tr></table>\n";
}
function page_tail() {
function admin_page_tail() {
echo "<hr><a href=index.php> Main admin page </a>\n";
}
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("%T %b %e, %Y", $x);
return strftime("%Y-%m-%d %H:%M:%S", $x);
}
function start_table() {
// echo "<table border=2 cellpadding=4 width=700>\n";
echo "<table border=2 cellpadding=4 width=100%>\n";
}
function end_table() {
echo "</table>\n";
}
function print_checkbox($text,$name,$checked) {
echo "<input type=checkbox name=$name"
. (strlen($checked) ? " checked" : "") . ">"
@ -95,58 +55,13 @@ function row($x, $y) {
echo "<tr>\n<td width=30% colspan=2 valign=top align=right>$x</td>\n<td colspan=2>$y</td>\n</tr>\n";
}
function row2($x, $y) {
echo "<tr><td align=right>$x</td><td>$y</td></tr>\n";
}
function c_row2($color, $x, $y) {
echo "<tr bgcolor=$color><td align=right>$x</td><td>$y</td></tr>\n";
}
function row3($x, $y, $z) {
echo "<tr><td width=30% valign=top align=right>$x</td><td>$y</td><td>$z</td></tr>\n";
}
function row4($xx, $xy, $yx, $yy) {
echo "<tr><td width=25% valign=top align=right>$xx</td><td width=25%>$xy</td>"
. "<td width=25% align=right>$yx</td><td width=%25>$yy</td></tr>\n";
}
function random_string() {
return md5(uniqid(rand()));
}
function print_country_select() {
PassThru("country_select");
}
// 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;
}
?>

View File

@ -1,4 +1,5 @@
<?php
require_once("db.inc");
require_once("util.inc");
db_init();

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
db_init();

View File

@ -1,5 +1,6 @@
<?php
include_once("db.inc");
include_once("util.inc");
function show_error($str) {

View File

@ -1,4 +1,5 @@
<?php
require_once('db.inc');
require_once('util.inc');
db_init();
page_head('New Account');

View File

@ -13,8 +13,8 @@ function db_init($pathMod='') {
}
$db_name = parse_config("<db_name>", $pathMod);
if(!mysql_select_db($db_name)) {
echo "Unable to select database - please try again later";
exit();
echo "Unable to select database - please try again later";
exit();
}
return 0;

View File

@ -1,8 +1,8 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("user.inc");
require_once("db.inc");
function send_verify_email($user, $email_addr, $key) {
mail(

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
db_init();

View File

@ -1,7 +1,7 @@
<?php
require_once("util.inc");
require_once("user.inc");
require_once("db.inc");
require_once("user.inc");
require_once("util.inc");
db_init();
$user = get_logged_in_user();

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
db_init();

View File

@ -1,4 +1,5 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("host.inc");

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("host.inc");

View File

@ -2,6 +2,7 @@
// show all the hosts for a user.
// if $userid is absent, show hosts of logged-in user
require_once("db.inc");
require_once("util.inc");
require_once("host.inc");

View File

@ -1,6 +1,6 @@
<?php
require_once("util.inc");
require_once("db.inc");
require_once("util.inc");
require_once("project_specific/project.inc");
init_session();

View File

@ -1,4 +1,5 @@
<?php
require_once('db.inc');
require_once('util.inc');
db_init();
page_head('Rules and Policies');

View File

@ -1,7 +1,7 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("user.inc");
require_once("db.inc");
init_session();
db_init();

View File

@ -1,4 +1,5 @@
<?php
require_once("db.inc");
require_once("util.inc");
$next_url = $_GET["next_url"];

View File

@ -1,7 +1,7 @@
<?php
require_once("util.inc");
require_once("db.inc");
require_once("util.inc");
db_init();

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
// TODO: Determine if we can always assume these will be the same number.

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("project_specific/project.inc");
require_once("profile.inc");

View File

@ -1,6 +1,7 @@
<?php
// show recent results for a host
require_once("db.inc");
require_once("util.inc");
require_once("result.inc");

View File

@ -1,6 +1,6 @@
<?php
require_once("util.inc");
require_once("db.inc");
require_once("util.inc");
require_once("user.inc");
require_once("host.inc");

View File

@ -1,7 +1,7 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("user.inc");
require_once("db.inc");
init_session();
db_init();

View File

@ -1,8 +1,8 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");
require_once("db.inc");
db_init();

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");

View File

@ -1,8 +1,8 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");
require_once("db.inc");
db_init();
$user = get_logged_in_user(false);

View File

@ -1,8 +1,8 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");
require_once("db.inc");
db_init();
$user = get_logged_in_user();

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");

View File

@ -1,8 +1,8 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");
require_once("db.inc");
db_init();

View File

@ -1,8 +1,8 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");
require_once("db.inc");
db_init();
$user = get_logged_in_user();

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");

View File

@ -1,8 +1,8 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");
require_once("db.inc");
db_init();
init_session();

View File

@ -1,7 +1,7 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");
require_once("db.inc");
db_init();
$user = get_logged_in_user();

View File

@ -1,5 +1,6 @@
<?php {
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");

View File

@ -1,8 +1,8 @@
<?php {
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");
require_once("db.inc");
db_init();
$user = get_logged_in_user();

View File

@ -1,5 +1,6 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("team.inc");

View File

@ -1,4 +1,5 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("host.inc");

View File

@ -1,4 +1,5 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("user.inc");
require_once("team.inc");

View File

@ -1,4 +1,5 @@
<?php
require_once("db.inc");
require_once("util.inc");
require_once("user.inc");

View File

@ -1,6 +1,6 @@
<?php
require_once("util.inc");
require_once("db.inc");
require_once("util.inc");
init_session();
db_init();

View File

@ -1,7 +1,6 @@
<?php
require_once("db.inc");
require_once("project_specific/project.inc");
require_once("project_specific/project.inc");
// Sends the authenticator to the given email address
//

View File

@ -1,6 +1,7 @@
<?php
// show summary of a workunit
require_once("db.inc");
require_once("util.inc");
require_once("result.inc");