#!/usr/bin/env php
.
// This script for use ONLY by the BOINC-teams project.
// It generates an XML file with team and user info
$cli_only = true;
require_once("../inc/util_ops.inc");
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);
}
function handle_team($team, $f) {
$user = BoincUser::lookup_id($team->userid);
if (!$user) {
echo "no user for team $team->id\n";
return;
}
if ($user->teamid != $team->id) {
echo "Founder is not member of $team->name\n";
return;
}
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,
"
".escape($team->name)."
".escape($team->url)."
$team->type
".escape($team->name_html)."
".escape($team->description)."
$team->country
$team->id
$user_email_munged
".escape($user->name)."
".escape($user->country)."
".escape($user->postal_code)."
".escape($user->url)."
"
);
}
function main() {
echo "------------ Starting at ".time_str(time())."-------\n";
$f = fopen("temp.xml", "w");
$teams = BoincTeam::enum(null);
fwrite($f, "\n");
foreach($teams as $team) {
handle_team($team, $f);
}
fwrite($f, "\n");
fclose($f);
if (!rename("temp.xml", "/home/boincadm/boinc/doc/boinc_teams.xml")) {
echo "Rename failed\n";
}
}
main();
?>