1 | <?php |
||
2 | // This file is part of BOINC. |
||
3 | // http://boinc.berkeley.edu |
||
4 | // Copyright (C) 2008 University of California |
||
5 | // |
||
6 | // BOINC is free software; you can redistribute it and/or modify it |
||
7 | // under the terms of the GNU Lesser General Public License |
||
8 | // as published by the Free Software Foundation, |
||
9 | // either version 3 of the License, or (at your option) any later version. |
||
10 | // |
||
11 | // BOINC is distributed in the hope that it will be useful, |
||
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
14 | // See the GNU Lesser General Public License for more details. |
||
15 | // |
||
16 | // You should have received a copy of the GNU Lesser General Public License |
||
17 | // along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
||
18 | |||
19 | require_once("../inc/util_ops.inc"); |
||
20 | |||
21 | function getSingleQuery($query) { |
||
22 | $result = _mysql_query($query); |
||
23 | if (!$result) return; |
||
24 | $cnt = _mysql_fetch_row($result); |
||
25 | if (!$cnt) return; |
||
0 ignored issues
–
show
|
|||
26 | _mysql_free_result($result); |
||
27 | return $cnt[0]; |
||
28 | } |
||
29 | |||
30 | require_once("../inc/util.inc"); |
||
31 | require_once("../inc/db.inc"); |
||
32 | //require_once("../inc/trickle.inc"); |
||
33 | require_once("../inc/wap.inc"); |
||
34 | |||
35 | // show the home page of app user from envvar |
||
36 | |||
37 | $valid = $_GET['id']; |
||
38 | if (!$valid || $valid!="whatever-validation-key-you-want") { |
||
39 | echo "User id (t.php?id=###) missing!"; |
||
40 | exit(); // can't do much without a userid! |
||
41 | } |
||
42 | |||
43 | db_init(); |
||
44 | |||
45 | wap_begin(); |
||
46 | |||
47 | // keep a 'running tab' in wapstr in case exceeds 1K WAP limit |
||
48 | |||
49 | $wapstr = PROJECT . "<br/>Status Info on<br/>" . wap_timestamp() . "<br/><br/>"; |
||
50 | |||
51 | $wapstr .= "#Users: " . getSingleQuery("select count(*) from user") . "<br/>"; |
||
52 | $wapstr .= "#Hosts: " . getSingleQuery("select count(*) from host") . "<br/>"; |
||
53 | $wapstr .= "#ModYr: " . sprintf("%ld", getSingleQuery("select sum(total_credit)/(.007*17280.0) from host")) . "<br/>"; |
||
54 | $wapstr .= "#Cobbl: " . sprintf("%ld", getSingleQuery("select sum(total_credit) from host")) . "<br/>"; |
||
55 | // I consider a host active if it's trickled in the last week |
||
56 | //$wapstr .= "#Activ: " . getSingleQuery("select count(distinct hostid) from cpdnexpt.trickle " |
||
57 | // . "where trickledate>=" . sprintf("%d", mktime() - (3600*24*7))) . "<br/>"; |
||
58 | |||
59 | // finally get last 5 trickles for everyone |
||
60 | //$wapstr .= show_trickles("a", 0, 5, 1); |
||
61 | |||
62 | // limit wap output to 1KB |
||
63 | if (strlen($wapstr)>1024) |
||
64 | echo substr($wapstr,0,1024); |
||
65 | else |
||
66 | echo $wapstr; |
||
67 | |||
68 | wap_end(); |
||
69 | |||
70 | ?> |
||
71 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.