2007-07-26 21:50:45 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
|
2007-07-25 20:58:36 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-07-25 20:58:36 +00:00
|
|
|
|
2007-07-26 21:50:45 +00:00
|
|
|
// This script for use ONLY by the BOINC-teams project.
|
2007-07-25 20:58:36 +00:00
|
|
|
// It generates an XML file with team and user info
|
|
|
|
|
2009-10-02 18:32:40 +00:00
|
|
|
$cli_only = true;
|
2009-09-15 18:14:37 +00:00
|
|
|
require_once("../inc/util_ops.inc");
|
2007-07-25 20:58:36 +00:00
|
|
|
|
2011-10-03 03:29:58 +00:00
|
|
|
function escape2($strin) {
|
|
|
|
$strout = null;
|
|
|
|
|
|
|
|
for ($i = 0; $i < strlen($strin); $i++) {
|
|
|
|
$ord = ord($strin[$i]);
|
|
|
|
|
|
|
|
if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
|
|
|
|
$strout .= "&#{$ord};";
|
|
|
|
} else {
|
|
|
|
switch ($strin[$i]) {
|
|
|
|
case '<': $strout .= '<'; break;
|
|
|
|
case '>': $strout .= '>'; break;
|
|
|
|
case '&': $strout .= '&'; break;
|
|
|
|
case '"': $strout .= '"'; break;
|
|
|
|
default: $strout .= $strin[$i]; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $strout;
|
|
|
|
}
|
|
|
|
|
|
|
|
function escape($strin) {
|
|
|
|
return htmlspecialchars($strin);
|
|
|
|
}
|
|
|
|
|
2007-07-25 20:58:36 +00:00
|
|
|
function handle_team($team, $f) {
|
2007-12-24 17:32:54 +00:00
|
|
|
$user = BoincUser::lookup_id($team->userid);
|
2007-07-25 20:58:36 +00:00
|
|
|
if (!$user) {
|
|
|
|
echo "no user for team $team->id\n";
|
2010-03-29 22:28:20 +00:00
|
|
|
return;
|
2007-07-25 20:58:36 +00:00
|
|
|
}
|
2007-12-24 17:32:54 +00:00
|
|
|
if ($user->teamid != $team->id) {
|
2007-12-07 23:23:25 +00:00
|
|
|
echo "Founder is not member of $team->name\n";
|
|
|
|
return;
|
|
|
|
}
|
2007-07-25 20:58:36 +00:00
|
|
|
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>
|
2011-10-03 03:29:58 +00:00
|
|
|
<name>".escape($team->name)."</name>
|
|
|
|
<url>".escape($team->url)."</url>
|
2007-07-25 20:58:36 +00:00
|
|
|
<type>$team->type</type>
|
2011-10-03 03:29:58 +00:00
|
|
|
<name_html>".escape($team->name_html)."</name_html>
|
2007-07-25 20:58:36 +00:00
|
|
|
<description>
|
2011-10-03 03:29:58 +00:00
|
|
|
".escape($team->description)."
|
2007-07-25 20:58:36 +00:00
|
|
|
</description>
|
|
|
|
<country>$team->country</country>
|
|
|
|
<id>$team->id</id>
|
|
|
|
<user_email_munged>$user_email_munged</user_email_munged>
|
2011-10-03 03:29:58 +00:00
|
|
|
<user_name>".escape($user->name)."</user_name>
|
|
|
|
<user_country>".escape($user->country)."</user_country>
|
|
|
|
<user_postal_code>".escape($user->postal_code)."</user_postal_code>
|
|
|
|
<user_url>".escape($user->url)."</user_url>
|
2007-07-25 20:58:36 +00:00
|
|
|
</team>
|
|
|
|
"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
2010-11-17 20:04:58 +00:00
|
|
|
echo "------------ Starting at ".time_str(time())."-------\n";
|
2007-07-25 20:58:36 +00:00
|
|
|
$f = fopen("temp.xml", "w");
|
2010-11-17 20:04:58 +00:00
|
|
|
$teams = BoincTeam::enum(null);
|
2007-07-25 20:58:36 +00:00
|
|
|
fwrite($f, "<teams>\n");
|
2007-12-24 17:32:54 +00:00
|
|
|
foreach($teams as $team) {
|
2007-07-25 20:58:36 +00:00
|
|
|
handle_team($team, $f);
|
|
|
|
}
|
|
|
|
fwrite($f, "</teams>\n");
|
|
|
|
fclose($f);
|
2010-03-29 22:28:20 +00:00
|
|
|
if (!rename("temp.xml", "/home/boincadm/boinc/doc/boinc_teams.xml")) {
|
|
|
|
echo "Rename failed\n";
|
|
|
|
}
|
2007-07-25 20:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main();
|
|
|
|
|
|
|
|
?>
|