- add support for "BOINC teams" (to be explained later)

svn path=/trunk/boinc/; revision=13218
This commit is contained in:
David Anderson 2007-07-25 20:58:36 +00:00
parent 5b7095b97e
commit 3990e817e3
8 changed files with 289 additions and 34 deletions

View File

@ -7499,3 +7499,13 @@ David 25 July 2007
user/
create_account.php
create_account_action.php
David 25 July 2007
- add support for "BOINC teams" (to be explained later)
html/
inc/
team.inc
ops/
team_export.php
team_import.php

View File

@ -1,6 +1,13 @@
<?
$project_news = array(
array("July 25, 2007",
"BOINC finally has a new logo!
Many thanks Michal Krakowiak, the graphic designer who created it.
The logo (and icons based on it)
will soon appear on the BOINC client software
as well as the web site."
),
array("July 23, 2007",
"<a href=images/africa_workshop_7_07.jpg><img align=right src=images/workshop_200.jpg></a>
The Africa@home workshop on volunteer computing with BOINC,

View File

@ -51,7 +51,7 @@ function page_head($title) {
<table width='100%'>
<tr>
<td><center><h1>$title</h1></center>
<td align=right><a href=index.php><img src=logo/logo_small.png></a>
<td align=right><a href=index.php><img src=logo/www_logo.gif></a>
<br>
";
search_form();

View File

@ -179,7 +179,7 @@ echo "
<meta name=keywords content=\"distributed scientific computing supercomputing grid SETI@home public computing volunteer computing \">
</head>
<body bgcolor=#ffffff>
<img hspace=30 vspace=10 align=left src=logo/logo_small.png>
<img hspace=40 vspace=10 align=left src=logo/www_logo.gif>
<h1>
".tr(HOME_BOINC)."
</h1>

View File

@ -5,11 +5,18 @@ page_head("Logos and graphics");
echo "
<h2>The current BOINC logo and icons</h2>
<h2>The current logo</h2>
The current logo and associated icons was designed by Michal Krakowiak.
Its arms represent the convergence of separated things
(such as computers) into a unified whole.
The colors are based on U.C. Berkeley's blue-and-gold colors.
<h2>The old BOINC logo and icons</h2>
<ul>
<li>
The logo in its native form as <a href=logo/logo.doc>a Word document</a>.
The BOINC logo uses the Planet Benson font from
The old logo in its native form as <a href=logo/logo.doc>a Word document</a>.
The logo uses the Planet Benson font from
<a href=http://www.larabiefonts.com>Larabie Fonts</a>.
<li>
Hi-res versions of the logo:
@ -23,32 +30,7 @@ The 'B in a circle' icon
<img src=logo/setup.PNG>was designed by Tim Lan.
The Mac variant was contributed by Juho Viitasalo.
<h2>New BOINC logo?</h2>
<p>
We are looking for a new graphical identity for BOINC.
Our criteria:
<ul>
<li> It should work on light-colored backgrounds
(both the web) and also on black (for the screensaver).
<li> It should include graphics of various sizes,
including icons (16x16 up to 128x128),
a web-site logo (roughly 200x100),
and an installer splash screen (roughly 400x300).
These should all be recognizable and visually consistent.
<li>
It should appeal to people of all interests and demographics.
In particular, it should NOT have a futuristic,
high-tech, aggressive, or sci-fi look.
<li>
It would be good (though not vital) for the logo
to suggest global distributed computing,
or scientific research, or both.
</ul>
Here are some candidates.
If you have an opinion, or think you can do better,
please <a href=contact.php>contact us</a>.
<p>
<h2>Logo proposals</h2>
<table cellpadding=8 border=1>
<tr><th>Artist</th><th>Images (click for hi-res version)</th></tr>
";

View File

@ -319,9 +319,7 @@ function transfer_ok($team, $now) {
function make_team(
$userid, $name, $url, $type, $name_html, $description, $country
) {
echo $name;
$name = boinc_htmlentities(process_user_text(strip_tags($name)));
echo $name;
if (strlen($name) == 0) return null;
$name_lc = strtolower($name);
$url = process_user_text(strip_tags($url));
@ -349,7 +347,6 @@ function make_team(
$country,
0
);
echo $query;
$result = mysql_query($query);
if ($result) {
$teamid = mysql_insert_id();

56
html/ops/team_export.php Normal file
View File

@ -0,0 +1,56 @@
<?php
// This script is intended to be used ONLY by the BOINC-teams project.
// It generates an XML file with team and user info
require_once("../inc/db.inc");
require_once("../inc/util.inc");
db_init();
function handle_team($team, $f) {
$user = lookup_user_id($team->userid);
if (!$user) {
echo "no user for team $team->id\n";
exit(1);
}
if (!$user->email_validated) {
echo "the founder of $team->name, $user->email_addr, is not validated\n";
return;
}
$user_email_munged = str_rot13($user->email_addr);
fwrite($f,
"<team>
<name>$team->name</name>
<url>$team->url</url>
<type>$team->type</type>
<name_html>$team->name_html</name_html>
<description>
$team->description
</description>
<country>$team->country</country>
<id>$team->id</id>
<user_email_munged>$user_email_munged</user_email_munged>
<user_name>$user->name</user_name>
<user_country>$user->country</user_country>
<user_postal_code>$user->postal_code</user_postal_code>
<user_url>$user->url</user_url>
</team>
"
);
}
function main() {
$f = fopen("temp.xml", "w");
$result = mysql_query("select * from team");
fwrite($f, "<teams>\n");
while ($team=mysql_fetch_object($result)) {
handle_team($team, $f);
}
fwrite($f, "</teams>\n");
fclose($f);
rename("temp.xml", "boinc_teams.xml");
}
main();
?>

203
html/ops/team_import.php Normal file
View File

@ -0,0 +1,203 @@
<?php
// fetch a list of "BOINC-wide teams" and create/update them
// Note: these are identified by the seti_id field,
// allowing you to change the names
require_once("../inc/util.inc");
require_once("../inc/user.inc");
require_once("../inc/team.inc");
function lookup_team_seti_id($id) {
$result = mysql_query("select * from team where seti_id=$id");
if ($result) {
$team = mysql_fetch_object($result);
mysql_free_result($result);
return $team;
}
return null;
}
function parse_team($f) {
while ($s = fgets($f)) {
if (strstr($s, '</team>')) {
return $t;
}
else if (strstr($s, '<name>')) $t->name = parse_element($s, '<name>');
else if (strstr($s, '<url>')) $t->url = parse_element($s, '<url>');
else if (strstr($s, '<name_html>')) $t->name_html = parse_element($s, '<name_html>');
else if (strstr($s, '<description>')) {
while ($s = fgets($f)) {
if (strstr($s, '</description>')) break;
$t->description .= $s;
}
}
else if (strstr($s, '<country>')) $t->country = parse_element($s, '<country>');
else if (strstr($s, '<id>')) $t->id = parse_element($s, '<id>');
else if (strstr($s, '<user_email_munged>')) {
$user_email_munged = parse_element($s, '<user_email_munged>');
$t->user_email = str_rot13($user_email_munged);
}
else if (strstr($s, '<user_name>')) $t->user_name = parse_element($s, '<user_name>');
else if (strstr($s, '<user_country>')) $t->user_country = parse_element($s, '<user_country>');
else if (strstr($s, '<user_postal_code>')) $t->user_postal_code = parse_element($s, '<user_postal_code>');
else if (strstr($s, '<user_url>')) $t->user_url = parse_element($s, '<user_url>');
}
return null;
}
function valid_team($t) {
if (!$t->id) return false;
if (!$t->name) return false;
if (!$t->user_email) return false;
if (!$t->user_name) return false;
return true;
}
// if team belongs to given user, update it
//
function update_team($t, $team, $user) {
if (!$user) {
echo " No user\n";
return;
}
if ($user.id != $team.id) {
echo " owned by a different user\n";
return;
}
if (
$t->url == $team->url
&& $t->type == $team->type
&& $t->name_html == $team->name_html
&& $t->description == $team->description
&& $t->country == $team->country
&& $t->id == $team->seti_id
) {
echo " no changes\n";
return;
}
echo " updating\n";
$query = "update team set url='$t->url', type=$t->type, name_html='$t->name_html', description='$t->description', country='$t->country', seti_id=$t->id";
$retval = mysql_query($query);
if (!$retval) {
echo " update failed: $query\n";
exit;
}
}
function insert_case($t, $user) {
if (!$user) {
echo " making user\n";
$user = make_user($t->user_email, $t->user_name, random_string());
if (!$user) {
echo " Can't make user $t->user_email\n";
echo mysql_error();
exit;
}
}
echo " making team\n";
$team = make_team(
$user->id, $t->name, $t->url, $t->type, $t->name_html,
$t->description, $t->country
);
if (!$team) {
echo " Can't make team $t->id\n";
echo mysql_error();
exit;
}
}
// There are several cases for a given record:
// (note: "ID" means the ID coming from BOINC, stored locally in seti_id)
// insert case:
// There's no team with given name; create one,
// and create the user if needed
// update1 case:
// There's a team with the given name and the given ID
// and its founder has the right email address.
// Update its parameters if any are different.
// update2 case:
// There's a team with the given name and seti_id=0,
// and its founder has the right email address.
// Update its parameters if any are different,
// and set its seti_id.
// This handles the case where the team founder created the team
// before this new system was run.
// conflict case:
// There's a team with the given name,
// and either it has the wrong ID
// or its founder has a different email address.
// Don't change anything.
// These semantics mean that:
// - A BOINC team can't change its name via this mechanism.
// This avoids pathological cases, e.g. if two teams swapped names,
// the updates would always fail.
// If a BOINC team wants to change its name,
// it must do it manually everywhere.
// - If a BOINC team changes its founder (or the founder changes email)
// they'll have to make this change manually on all projects.
// (this is better than a security vulnerability)
// - This mechanism can't be used to update the founder's
// account parameters on all projects
function handle_team($f) {
$t = parse_team($f);
if (!$t) {
echo "Failed to parse team\n";
return;
}
//print_r($t);
//return;
if (!valid_team($t)) {
echo "Invalid team\n";
return;
}
$user = lookup_user_email_addr($t->user_email);
echo "Processing $t->name\n";
$team = lookup_team_name($t->name);
if ($team) {
if ($team->seti_id) {
if ($team->seti_id == $t->id) {
update_team($t, $team, $user); // update1 case
}
} else {
$team2 = lookup_team_seti_id($t->id);
if ($team2) {
// update1 case
update_team($t, $team2, $user);
} else {
// update2 case
update_team($t, $team, $user);
}
}
} else {
$team = lookup_team_seti_id($t->id);
if ($team) {
echo " A team with same ID but different name exists;\n";
echo " Please report this to $t->user_email;\n";
} else {
echo " Inserting team\n";
insert_case($t, $user);
}
}
}
function main() {
$f = fopen("http://boinc.berkeley.edu/boinc_teams.xml", "r");
if (!$f) {
echo "Can't get times file\n";
exit;
}
while ($s = fgets($f)) {
if (strstr($s, '<team>')) {
handle_team($f);
}
}
}
db_init();
main();
?>