Issues (1964)

html/user/sample_index.php (2 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
// This is a template for your web site's front page.
20
// You are encouraged to customize this file,
21
// and to create a graphical identity for your web site.
22
// by customizing the header/footer functions in html/project/project.inc
23
// and picking a Bootstrap theme
24
//
25
// If you add text, put it in tra() to make it translatable.
26
27
require_once("../inc/db.inc");
28
require_once("../inc/util.inc");
29
require_once("../inc/news.inc");
30
require_once("../inc/cache.inc");
31
require_once("../inc/uotd.inc");
32
require_once("../inc/sanitize_html.inc");
33
require_once("../inc/text_transform.inc");
34
require_once("../project/project.inc");
35
require_once("../inc/bootstrap.inc");
36
37
$config = get_config();
38
$no_web_account_creation = parse_bool($config, "no_web_account_creation");
39
$project_id = parse_config($config, "<project_id>");
40
41
$stopped = web_stopped();
42
$user = get_logged_in_user(false);
0 ignored issues
show
Are you sure the assignment to $user is correct as get_logged_in_user(false) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
43
44
// The panel at the top of the page
45
//
46
function panel_contents() {
47
}
48
49
function top() {
50
    global $stopped, $user;
51
    if ($stopped) {
52
        echo '
53
            <p class="lead text-center">'
54
            .tra("%1 is temporarily shut down for maintenance.", PROJECT)
55
            .'</p>
56
        ';
57
    }
58
    //panel(null, 'panel_contents');
59
}
60
61
function left(){
62
    global $user, $no_web_account_creation, $project_id;
63
    panel(
64
        $user?tra("Welcome, %1", $user->name):tra("What is %1?", PROJECT),
65
        function() use($user) {
0 ignored issues
show
Expected 1 space after USE keyword; found 0
Loading history...
66
            global $no_web_account_creation, $project_id;
67
            if ($user) {
68
                $dt = time() - $user->create_time;
69
                if ($dt < 86400) {
70
                    echo tra("Thanks for joining %1", PROJECT);
71
                } else if ($user->total_credit == 0) {
72
                    echo tra("Your computer hasn't completed any tasks yet.  If you need help, %1go here%2.",
73
                            "<a href=https://boinc.berkeley.edu/help.php>",
74
                            "</a>"
75
                    );
76
                } else {
77
                    $x = format_credit($user->expavg_credit);
78
                    echo tra("You've contributed about %1 credits per day to %2 recently.", $x, PROJECT);
79
                    if ($user->expavg_credit > 1) {
80
                        echo " ";
81
                        echo tra("Thanks!");
82
                    } else {
83
                        echo "<p><p>";
84
                        echo tra("Please make sure BOINC is installed and enabled on your computer.");
85
                    }
86
                }
87
                echo "<p><p>";
88
                echo sprintf('<center>%s</center>',
89
                    button_text('home.php',
90
                        tra('Continue to your home page'),
91
                        '',
92
                        '',
93
                        button_style('green', 16)
94
                    )
95
                );
96
                echo "<p><p>";
97
                echo sprintf('%s
98
                    <ul>
99
                    <li> %s
100
                    <li> %s
101
                    <li> %s
102
                    ',
103
                    tra("Want to help more?"),
104
                    tra("If BOINC is not installed on this computer, %1download it%2.",
105
                        "<a href=download_software.php>", "</a>"
106
                    ),
107
                    tra("Install BOINC on your other computers, tablets, and phones."),
108
                    tra("Tell your friends about BOINC, and show them how to join %1.", PROJECT)
109
                );
110
                if (function_exists('project_help_more')) {
111
                    project_help_more();
112
                }
113
                echo "</ul>\n";
114
            } else {
115
                echo "<p>";
116
                $pd = "../project/project_description.php";
117
                if (file_exists($pd)) {
118
                    include($pd);
119
                } else {
120
                    echo "No project description yet. Create a file html/project/project_description.php
121
                        that prints a short description of your project.
122
                    ";
123
                }
124
                echo "</p>\n";
125
                if (NO_COMPUTING) {
126
                    if (!$no_web_account_creation) {
127
                        echo "
128
                            <a href=\"create_account_form.php\">Create an account</a>
129
                        ";
130
                    }
131
                } else {
132
                    // use auto-attach if possible
133
                    //
134
                    if (!$no_web_account_creation) {
135
                        echo '<center><a href="signup.php" class="btn btn-success"><font size=+2>'.tra('Join %1', PROJECT).'</font></a></center>';
136
                    }
137
                    echo "<p><p>".tra("Already joined? %1Log in%2.",
138
                        "<a href=login_form.php>", "</a>"
139
                    );
140
                }
141
            }
142
        }
143
    );
144
    global $stopped;
145
    if (!$stopped) {
146
        $profile = get_current_uotd();
147
        if ($profile) {
148
            panel(tra('User of the Day'),
149
                function() use ($profile) {
150
                    show_uotd($profile);
151
                }
152
            );
153
        }
154
    }
155
}
156
157
function right() {
158
    panel(tra('News'),
159
        function() {
160
            include("motd.php");
161
            if (!web_stopped()) {
162
                show_news(0, 5);
163
            }
164
        }
165
    );
166
}
167
168
page_head(null, null, true);
169
170
grid('top', 'left', 'right');
171
172
page_tail(false, "", true);
173
174
?>
175