Issues (1964)

html/ops/hrclass_summary.php (63 issues)

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
// Show how many unsent results are committed to each HR class
20
21
// TODO: convert to use new DB interface
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
22
// TODO: document in the wiki
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
23
24
include_once( "../inc/db.inc" );
25
include_once( "../inc/util.inc" );
26
include_once( "../inc/db_ops.inc" );
27
include_once( "../inc/util_ops.inc" );
28
include_once( "../inc/prefs.inc" );
29
30
$system_string[ 128 ] = "No OS";
0 ignored issues
show
Space found after square bracket; expected "[128" but found "[ 128"
Loading history...
Space found before square bracket; expected "128]" but found "128 ]"
Loading history...
31
$system_string[ 256 ] = "Linux";
0 ignored issues
show
Space found after square bracket; expected "[256" but found "[ 256"
Loading history...
Space found before square bracket; expected "256]" but found "256 ]"
Loading history...
32
$system_string[ 384 ] = "Windows";
0 ignored issues
show
Space found after square bracket; expected "[384" but found "[ 384"
Loading history...
Space found before square bracket; expected "384]" but found "384 ]"
Loading history...
33
$system_string[ 512 ] = "Darwin";
0 ignored issues
show
Space found after square bracket; expected "[512" but found "[ 512"
Loading history...
Space found before square bracket; expected "512]" but found "512 ]"
Loading history...
34
$system_string[ 640 ] = "FreeBSD";
0 ignored issues
show
Space found after square bracket; expected "[640" but found "[ 640"
Loading history...
Space found before square bracket; expected "640]" but found "640 ]"
Loading history...
35
36
$cpu_string[ 0 ]  = "Unspecified";
0 ignored issues
show
Space found after square bracket; expected "[0" but found "[ 0"
Loading history...
Space found before square bracket; expected "0]" but found "0 ]"
Loading history...
37
$cpu_string[ 1 ]  = "No cpu";
0 ignored issues
show
Space found after square bracket; expected "[1" but found "[ 1"
Loading history...
Space found before square bracket; expected "1]" but found "1 ]"
Loading history...
38
$cpu_string[ 2 ]  = "Intel";
0 ignored issues
show
Space found after square bracket; expected "[2" but found "[ 2"
Loading history...
Space found before square bracket; expected "2]" but found "2 ]"
Loading history...
39
$cpu_string[ 3 ]  = "AMD";
0 ignored issues
show
Space found after square bracket; expected "[3" but found "[ 3"
Loading history...
Space found before square bracket; expected "3]" but found "3 ]"
Loading history...
40
$cpu_string[ 4 ]  = "Macintosh";
0 ignored issues
show
Space found after square bracket; expected "[4" but found "[ 4"
Loading history...
Space found before square bracket; expected "4]" but found "4 ]"
Loading history...
41
$cpu_string[ 5 ]  = "AMD Athlon";
0 ignored issues
show
Space found after square bracket; expected "[5" but found "[ 5"
Loading history...
Space found before square bracket; expected "5]" but found "5 ]"
Loading history...
42
$cpu_string[ 6 ]  = "AMD Duron";
0 ignored issues
show
Space found after square bracket; expected "[6" but found "[ 6"
Loading history...
Space found before square bracket; expected "6]" but found "6 ]"
Loading history...
43
$cpu_string[ 7 ]  = "AMD Sempron";
0 ignored issues
show
Space found after square bracket; expected "[7" but found "[ 7"
Loading history...
Space found before square bracket; expected "7]" but found "7 ]"
Loading history...
44
$cpu_string[ 8 ]  = "AMD Opteron";
0 ignored issues
show
Space found after square bracket; expected "[8" but found "[ 8"
Loading history...
Space found before square bracket; expected "8]" but found "8 ]"
Loading history...
45
$cpu_string[ 9 ]  = "AMD Athlon 64";
0 ignored issues
show
Space found after square bracket; expected "[9" but found "[ 9"
Loading history...
Space found before square bracket; expected "9]" but found "9 ]"
Loading history...
46
$cpu_string[ 10 ] = "AMD Athlon XP";
0 ignored issues
show
Space found after square bracket; expected "[10" but found "[ 10"
Loading history...
Space found before square bracket; expected "10]" but found "10 ]"
Loading history...
47
$cpu_string[ 11 ] = "Intel Xeon";
0 ignored issues
show
Space found after square bracket; expected "[11" but found "[ 11"
Loading history...
Space found before square bracket; expected "11]" but found "11 ]"
Loading history...
48
$cpu_string[ 12 ] = "Intel Celeron";
0 ignored issues
show
Space found after square bracket; expected "[12" but found "[ 12"
Loading history...
Space found before square bracket; expected "12]" but found "12 ]"
Loading history...
49
$cpu_string[ 13 ] = "Intel Pentium";
0 ignored issues
show
Space found after square bracket; expected "[13" but found "[ 13"
Loading history...
Space found before square bracket; expected "13]" but found "13 ]"
Loading history...
50
$cpu_string[ 14 ] = "Intel Pentium II";
0 ignored issues
show
Space found after square bracket; expected "[14" but found "[ 14"
Loading history...
Space found before square bracket; expected "14]" but found "14 ]"
Loading history...
51
$cpu_string[ 15 ] = "Intel Pentium III";
0 ignored issues
show
Space found after square bracket; expected "[15" but found "[ 15"
Loading history...
Space found before square bracket; expected "15]" but found "15 ]"
Loading history...
52
$cpu_string[ 16 ] = "Intel Pentium 4";
0 ignored issues
show
Space found after square bracket; expected "[16" but found "[ 16"
Loading history...
Space found before square bracket; expected "16]" but found "16 ]"
Loading history...
53
$cpu_string[ 17 ] = "Intel Pentium D";
0 ignored issues
show
Space found after square bracket; expected "[17" but found "[ 17"
Loading history...
Space found before square bracket; expected "17]" but found "17 ]"
Loading history...
54
$cpu_string[ 18 ] = "Intel Pentium M";
0 ignored issues
show
Space found after square bracket; expected "[18" but found "[ 18"
Loading history...
Space found before square bracket; expected "18]" but found "18 ]"
Loading history...
55
$cpu_string[ 19 ] = "AMD Athlon MP";
0 ignored issues
show
Space found after square bracket; expected "[19" but found "[ 19"
Loading history...
Space found before square bracket; expected "19]" but found "19 ]"
Loading history...
56
$cpu_string[ 20 ] = "AMD Turion";
0 ignored issues
show
Space found after square bracket; expected "[20" but found "[ 20"
Loading history...
Space found before square bracket; expected "20]" but found "20 ]"
Loading history...
57
$cpu_string[ 21 ] = "Intel Core2";
0 ignored issues
show
Space found after square bracket; expected "[21" but found "[ 21"
Loading history...
Space found before square bracket; expected "21]" but found "21 ]"
Loading history...
58
59
$query = "SELECT COUNT(workunit.id) AS count FROM workunit LEFT JOIN result ON workunit.id=result.workunitid WHERE result.server_state=2 AND workunit.hr_class=";
60
61
function get_mysql_count($hr_class) {
62
    $result = _mysql_query("select count(id) as count from workunit where hr_class=" . $hr_class);
63
    $count = _mysql_fetch_object($result);
64
    _mysql_free_result($result);
65
    return $count->count;
66
}
67
68
function make_reset_url($hr_class) {
69
    return ("<a href=ops_reset_hrclass.php?hr_class=".$hr_class.">".$hr_class."</a>");
70
}
71
72
db_init();
73
74
$timestr = time_str(time(0));
0 ignored issues
show
The call to time() has too many arguments starting with 0. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

74
$timestr = time_str(/** @scrutinizer ignore-call */ time(0));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
75
$title = "hr_class summary list at ".$timestr;
76
77
admin_page_head($title);
78
79
start_table();
80
81
table_header(
82
    "hr_class", "System", "CPU", "# unsent results"
83
);
84
85
$unsentresults = get_mysql_count( 0 );
86
table_row(
87
    make_reset_url(0), $system_string[ 128 ], $cpu_string[ 0 ], $unsentresults  );
0 ignored issues
show
Space found after square bracket; expected "[128" but found "[ 128"
Loading history...
Space found before square bracket; expected "128]" but found "128 ]"
Loading history...
Space found after square bracket; expected "[0" but found "[ 0"
Loading history...
Space found before square bracket; expected "0]" but found "0 ]"
Loading history...
88
89
for ($system = 2; $system < 6; ++$system ) {
0 ignored issues
show
Space found before closing bracket of FOR loop
Loading history...
90
    for ($cpu = 1; $cpu < 22; ++$cpu ) {
0 ignored issues
show
Space found before closing bracket of FOR loop
Loading history...
91
        $hr_class=128*$system+$cpu;
92
93
        $unsentresults = get_mysql_count( $hr_class );
94
95
        table_row(
96
            make_reset_url($hr_class),
97
            $system_string[$system * 128],
98
            $cpu_string[$cpu],
99
            $unsentresults
100
        );
101
    }
102
}
103
104
end_table();
105
106
admin_page_tail();
107
108
?>
109