.
require_once("../inc/boinc_db.inc");
require_once("../inc/util.inc");
require_once("../inc/common_defs.inc");
require_once("../project/project.inc");
function db_init_xml() {
if (web_stopped()) {
return ERR_PROJECT_DOWN;
}
$db = BoincDb::get();
if (!$db) return ERR_DB_CANT_CONNECT;
return 0;
}
// write PHP warnings as XML, so that the reply can be parsed by client
//
function error_handler($errno, $errstr, $errfile, $errline) {
if ($errno == E_WARNING) $errno = "Warning";
if ($errno == E_NOTICE) $errno = "Notice";
echo "
$errno
$errfile
$errline
";
}
function xml_header() {
global $generating_xml;
if (defined("RPC_DEBUG") && RPC_DEBUG) {
set_error_handler('error_handler', E_WARNING|E_NOTICE);
}
header('Content-type: text/xml');
echo "\n";
$generating_xml = true;
}
$xml_outer_tag = "";
function xml_start_tag($tag) {
global $xml_outer_tag;
echo "<$tag>\n";
$xml_outer_tag = $tag;
}
// used only if host owner is the requesting user
//
function show_host_xml($host) {
echo "
$host->id
$host->create_time
$host->rpc_seqno
$host->rpc_time
$host->host_cpid
$host->total_credit
$host->expavg_credit
$host->expavg_time
$host->domain_name
$host->p_ncpus
$host->p_vendor
$host->p_model
$host->p_fpops
$host->p_iops
$host->os_name
$host->os_version
$host->m_nbytes
$host->d_free
$host->d_total
$host->venue
";
}
// $show_hosts is true only if $user is the logged-in user
//
function show_user_xml($user, $show_hosts) {
$cpid = md5($user->cross_project_id.$user->email_addr);
echo "
$user->id
$cpid
$user->create_time
".htmlspecialchars($user->name)."
$user->total_credit
$user->expavg_credit
$user->expavg_time
$user->teamid
$user->has_profile
";
if ($show_hosts) {
$hosts = BoincHost::enum("userid=$user->id");
echo " $user->venue\n";
foreach ($hosts as $host) {
show_host_xml($host);
}
}
if (USER_COUNTRY) {
echo " $user->country\n";
}
if (USER_URL) {
$url = normalize_user_url($user->url);
echo " ".htmlspecialchars($url)."\n";
}
echo "\n";
}
function show_team_member($user, $creditonly = false) {
if ($creditonly && !$user->total_credit) { return; }
$cpid = md5($user->cross_project_id.$user->email_addr);
$url = normalize_user_url($user->url);
echo "
$user->id
$cpid
$user->total_credit";
if (!$creditonly) {
echo " $user->create_time
".htmlspecialchars($user->name)."
$user->expavg_credit
$user->expavg_time
$user->has_profile
";
if (USER_COUNTRY) {
echo " $user->country\n";
}
if (USER_URL) {
$url = normalize_user_url($user->url);
echo " ".htmlspecialchars($url)."\n";
}
}
echo "
";
}
function show_team_xml($team) {
echo "
$team->id
$team->create_time
$team->userid
".htmlspecialchars($team->name)."
".htmlspecialchars($team->url)."
$team->type
$team->country
$team->total_credit
$team->expavg_credit
$team->expavg_time
";
}
?>