Issues (1963)

html/user/show_coproc.php (2 issues)

1
<?php
2
// This file is part of BOINC.
3
// http://boinc.berkeley.edu
4
// Copyright (C) 2011 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
// show the results of ops/analyze_coproc_log.php
20
21
// DEPRECATED
22
23
require_once("../inc/util.inc");
24
require_once("../inc/boinc_db.inc");
25
26
check_get_args(array("mode"));
27
28
function filename($mode) {
29
    switch ($mode) {
30
    case 'host': return "cuda_hosts.dat";
31
    case 'user': return "cuda_users.dat";
32
    case 'team': return "cuda_teams.dat";
33
    case 'model': return "cuda_models.dat";
34
    case 'day': return "cuda_days.dat";
35
    }
36
}
37
38
function title($mode) {
39
    switch ($mode) {
40
    case 'host': return "Top CUDA hosts";
41
    case 'user': return "Top CUDA users";
42
    case 'team': return "Top CUDA teams";
43
    case 'model': return "Top CUDA models";
44
    case 'day': return "Daily CUDA credit";
45
    }
46
}
47
48
function header_row($mode) {
49
    echo "<tr><th>";
50
    switch ($mode) {
51
    case 'host':
52
        echo "Computer ID<br><p class=\"text-muted\">click for details</p>";
53
        break;
54
    case 'user':
55
        echo "User";
56
        break;
57
    case 'team':
58
        echo "Team";
59
        break;
60
    case 'model':
61
        echo "Model";
62
        break;
63
    case 'day':
64
        echo "Date";
65
        break;
66
    }
67
    echo "</th><th>CUDA Credit</th><th>Number of CUDA jobs</th></tr>\n";
68
}
69
70
function show_row($x, $y, $mode) {
71
    echo "<tr><td>";
72
    switch ($mode) {
73
    case 'host':
74
        echo "<a href=show_host_detail.php?hostid=$x>$x</a>";
75
        break;
76
    case 'user':
77
        $user = BoincUser::lookup_id($x);
78
        echo sprintf(
79
            '<a href=%s?userid=%d>%s</a>',
80
            SHOW_USER_PAGE, $x, $user->name
81
        );
82
        break;
83
    case 'team':
84
        $team = BoincTeam::lookup_id($x);
85
        if ($team) {
86
            echo "<a href=team_display.php?teamid=$x>$team->name</a>";
87
        } else {
88
            echo "(no team)";
89
        }
90
        break;
91
    case 'model':
92
        echo $x;
93
        break;
94
    case 'day':
95
        echo $x;
96
        break;
97
    }
98
    echo "</td><td align=right>".format_credit_large($y->credit),"</td><td align=right>$y->nresults</td></tr>\n";
99
}
100
101
$mode = get_str('mode', true);
102
if (!$mode) {
103
    page_head("Show GPU info");
104
    echo "
105
        <ul>
106
        <li> <a href=show_coproc.php?mode=host>Hosts</a>
107
        <li> <a href=show_coproc.php?mode=user>Users</a>
108
        <li> <a href=show_coproc.php?mode=team>Teams</a>
109
        <li> <a href=show_coproc.php?mode=model>GPU models</a>
110
        <li> <a href=show_coproc.php?mode=day>Day</a>
111
        </ul>
112
    ";
113
    page_tail();
114
    exit;
115
}
116
117
$fname = "../ops/".filename($mode);
118
$data = file_get_contents($fname);
119
$array = unserialize($data);
120
121
page_head(title($mode));
122
123
start_table('table-striped');
124
header_row($mode);
125
foreach ($array as $x=>$y) {
0 ignored issues
show
Expected 1 space before "=>"; 0 found
Loading history...
Expected 1 space after "=>"; 0 found
Loading history...
126
    show_row($x, $y, $mode);
127
}
128
end_table();
129
130
page_tail();
131
132
?>
133