*** empty log message ***

svn path=/trunk/boinc/; revision=4177
This commit is contained in:
David Anderson 2004-09-10 00:14:37 +00:00
parent 424c45c6e5
commit 9bc5a5d426
5 changed files with 173 additions and 0 deletions

View File

@ -17223,3 +17223,16 @@ David 9 Sept 2004
lib/
util.C,h
David 9 Sept 2004
- Added support for stats access via WAP (for cell phones)
(from Carl Christensen)
html/
inc/
userw.inc
wap.inc
user/
opsw.php
userw.php

61
html/inc/userw.inc Normal file
View File

@ -0,0 +1,61 @@
<?php
function show_credit($user) {
$retstr = "<br/>User TotCred: " . format_credit($user->total_credit) . "<br/>";
$retstr .= "User AvgCred: " . format_credit($user->expavg_credit) . "<br/>";
/*
if ($user->seti_nresults) {
row2("SETI@home classic workunits", number_format($user->seti_nresults));
}
if ($user->seti_total_cpu) {
$x = number_format($user->seti_total_cpu/3600)." hours";
row2("SETI@home classic CPU time", $x);
}
*/
return $retstr;
}
function show_user_wap($user)
{
wap_begin();
if (!$user) {
echo "<br/>User not found!<br/>";
wap_end();
return;
}
// keep a 'running tab' in wapstr in case exceeds 1K WAP limit
$wapstr = PROJECT . "<br/>Account Data<br/>for $user->name<br/>Time: " . wap_timestamp();
$wapstr .= show_credit($user);
if ($user->teamid) {
$result = mysql_query("select name, total_credit, expavg_credit from team where id = $user->teamid");
$team = mysql_fetch_object($result);
$wapstr .= "<br/>Team: $team->name<br/>";
$wapstr .= "Team TotCred: " . format_credit($team->total_credit) . "<br/>";
$wapstr .= "Team AvgCred: " . format_credit($team->expavg_credit) . "<br/>";
mysql_free_result($result);
} else {
$wapstr .= "<br/>Team: None<br/>";
}
// finally get last 5 trickles for user
//$wapstr .= show_trickles("u", $user->id, 5, 1);
// don't want to send more than 1KB probably?
if (strlen($wapstr)>1024)
echo substr($wapstr,0,1024);
else
echo $wapstr;
wap_end();
}
?>

25
html/inc/wap.inc Normal file
View File

@ -0,0 +1,25 @@
<?PHP
// BOINC WAP functions
function wap_begin()
{
header("Content-type: text/vnd.wap.wml");
header("Expires: Thu, 01 Jan 1970 00:00:00 GMT");
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
. "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" "
. "\"http://www.wapforum.org/DTD/wml_1.2.xml\">"
. "<wml><card id=\"cd1\"><p>";
}
function wap_end()
{
echo "</p></card></wml>";
}
function wap_timestamp()
{
return strftime("%d %b %Y %H:%M:%S UTC", mktime());
}
?>

53
html/user/opsw.php Normal file
View File

@ -0,0 +1,53 @@
<?php
function getSingleQuery($query)
{
$result = mysql_query($query);
if (!$result) return;
$cnt = mysql_fetch_row($result);
if (!$cnt) return;
mysql_free_result($result);
return $cnt[0];
}
require_once("../inc/util.inc");
require_once("../inc/db.inc");
//require_once("../inc/trickle.inc");
require_once("../inc/wap.inc");
// show the home page of app user from envvar
$valid = $_GET['id'];
if (!$valid || $valid!="whatever-validation-key-you-want") {
echo "User id (t.php?id=###) missing!";
exit(); // can't do much without a userid!
}
db_init();
wap_begin();
// keep a 'running tab' in wapstr in case exceeds 1K WAP limit
$wapstr = PROJECT . "<br/>Status Info on<br/>" . wap_timestamp() . "<br/><br/>";
$wapstr .= "#Users: " . getSingleQuery("select count(*) from user") . "<br/>";
$wapstr .= "#Hosts: " . getSingleQuery("select count(*) from host") . "<br/>";
$wapstr .= "#ModYr: " . sprintf("%ld", getSingleQuery("select sum(total_credit)/(.007*17280.0) from host")) . "<br/>";
$wapstr .= "#Cobbl: " . sprintf("%ld", getSingleQuery("select sum(total_credit) from host")) . "<br/>";
// I consider a host active if it's trickled in the last week
//$wapstr .= "#Activ: " . getSingleQuery("select count(distinct hostid) from cpdnexpt.trickle "
// . "where trickledate>=" . sprintf("%d", mktime() - (3600*24*7))) . "<br/>";
// finally get last 5 trickles for everyone
//$wapstr .= show_trickles("a", 0, 5, 1);
// limit wap output to 1KB
if (strlen($wapstr)>1024)
echo substr($wapstr,0,1024);
else
echo $wapstr;
wap_end();
?>

21
html/user/userw.php Normal file
View File

@ -0,0 +1,21 @@
<?php
require_once("../inc/util.inc");
require_once("../inc/userw.inc");
require_once("../inc/db.inc");
// require_once("../inc/trickle.inc");
require_once("../inc/wap.inc");
// show the home page of app user from envvar
$userid = $_GET['id'];
if (!$userid) {
echo "User id (userw.php?id=###) missing!";
exit(); // can't do much without a userid!
}
db_init();
$res = mysql_query("select * from user where id = $userid") or die("error in query");
$user = mysql_fetch_object($res) or die("error in fetch_object");
show_user_wap($user);
mysql_free_result($res);
?>