Passed
Pull Request — master (#5954)
by
unknown
10:07
created

display_cvs_versions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
// This file is part of BOINC.
3
// http://boinc.berkeley.edu
4
// Copyright (C) 2021 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
// Utility functions for BOINC web pages
20
// Stuff that's not web-specific (e.g. that's used in non-web scripts)
21
// should go in util_basic.inc
22
23
require_once("../inc/util_basic.inc");
24
require_once("../project/project.inc");
25
require_once("../inc/countries.inc");
26
require_once("../inc/db.inc");
27
require_once("../inc/boinc_db.inc");
28
require_once("../inc/translation.inc");
29
require_once("../inc/profile.inc");
30
require_once("../inc/bootstrap.inc");
31
32
// parse config.xml (do it here for efficiency)
33
//
34
$config = get_config();
35
global $master_url;
36
$master_url = parse_config($config , "<master_url>");
37
$recaptcha_public_key = parse_config($config, "<recaptcha_public_key>");
38
$recaptcha_private_key = parse_config($config, "<recaptcha_private_key>");
39
40
// Set parameters to defaults if not defined in config.xml
41
42
$x = parse_config($config, "<user_country>");
43
define('USER_COUNTRY', ($x===null)?1:(int)$x);
44
45
$x = parse_config($config, "<user_url>");
46
define('USER_URL', ($x===null)?1:(int)$x);
47
48
// Set parameters to defaults if not defined in project.inc
49
50
if (defined('TIMEZONE')) {
51
    date_default_timezone_set(TIMEZONE);
52
} else {
53
    date_default_timezone_set('UTC');
54
}
55
if (!defined('DISABLE_PROFILES')) {
56
    define('DISABLE_PROFILES', false);
57
}
58
if (!defined('DISABLE_FORUMS')) {
59
    define('DISABLE_FORUMS', false);
60
}
61
if (!defined('DISABLE_TEAMS')) {
62
    define('DISABLE_TEAMS', false);
63
}
64
if (!defined('DISABLE_BADGES')) {
65
    define('DISABLE_BADGES', false);
66
}
67
if (!defined('BADGE_HEIGHT_SMALL')) {
68
    define('BADGE_HEIGHT_SMALL', 20);
69
}
70
if (!defined('BADGE_HEIGHT_MEDIUM')) {
71
    define('BADGE_HEIGHT_MEDIUM', 24);
72
}
73
if (!defined('BADGE_HEIGHT_LARGE')) {
74
    define('BADGE_HEIGHT_LARGE', 56);
75
}
76
if (!defined('LDAP_HOST')) {
77
    define('LDAP_HOST', null);
78
}
79
if (!defined('POSTAL_CODE')) {
80
    define('POSTAL_CODE', false);
81
}
82
if (!defined('NO_COMPUTING')) {
83
    define('NO_COMPUTING', false);
84
}
85
if (!defined('NO_HOSTS')) {
86
    define('NO_HOSTS', false);
87
}
88
if (!defined('NO_STATS')) {
89
    define('NO_STATS', false);
90
}
91
if (!defined('NO_GLOBAL_PREFS')) {
92
    define('NO_GLOBAL_PREFS', false);
93
}
94
95
// the 'home page' of the logged-in user.
96
// go here after login, account creation, team operations, etc.
97
//
98
if (!defined('HOME_PAGE')) {
99
    define('HOME_PAGE', 'home.php');
100
}
101
102
// the page showing another user ('userid' arg).
103
// Link to here wherever we show a user name.
104
//
105
if (!defined('SHOW_USER_PAGE')) {
106
    define('SHOW_USER_PAGE', 'show_user.php');
107
}
108
109
if (!defined('POST_MAX_LINKS')) {
110
    define('POST_MAX_LINKS', 0);
111
}
112
if (!defined('DARK_MODE')) {
113
    define('DARK_MODE', false);
114
}
115
if (!defined('VALIDATE_EMAIL_TO_POST')) {
116
    define('VALIDATE_EMAIL_TO_POST', false);
117
}
118
if (!defined('UNIQUE_USER_NAME')) {
119
    define('UNIQUE_USER_NAME', false);
120
}
121
122
// don't allow anything between .php and ? in URL
123
//
124
if (array_key_exists("PATH_INFO", $_SERVER)) {
125
    die("bad URL");
126
}
127
128
// sleep this long on any login failure
129
// (slow the rate of hacker attacks)
130
//
131
define('LOGIN_FAIL_SLEEP_SEC', 5);
132
133
$caching = false;
134
    // if set, we're writing to a file rather than to client
135
$did_page_head = false;
136
137
define('KILO', 1024);
138
define('MEGA', 1024*KILO);
139
define('GIGA', 1024*MEGA);
140
define('TERA', 1024*GIGA);
141
142
// return true if this page is HTTPS
143
//
144
function is_https() {
145
    return isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'];
146
}
147
148
function secure_url_base() {
149
    if (defined('SECURE_URL_BASE')) return SECURE_URL_BASE;
150
    return URL_BASE;
151
}
152
153
function url_base() {
154
    return is_https()?secure_url_base():URL_BASE;
155
}
156
157
function send_cookie($name, $value, $permanent, $ops=false) {
158
    global $master_url;
159
160
    // the following allows independent login for projects on the same server
161
    //
162
    $url = parse_url($master_url);
163
    $path = $url['path'];
164
    if ($ops) {
165
        $path = substr($path, 0, -1);
166
        $path .= "_ops/";
167
    }
168
    $expire = $permanent?time()+3600*24*365:0;
169
    setcookie($name, $value, $expire, $path);
170
}
171
172
function clear_cookie($name, $ops=false) {
173
    global $master_url;
174
    $url = parse_url($master_url);
175
    $path = $url['path'];
176
    if ($ops) {
177
        $path = substr($path, 0, -1);
178
        $path .= "_ops/";
179
    }
180
    setcookie($name, '', time()-3600, $path);
181
}
182
183
$g_logged_in_user = null;
184
$got_logged_in_user = false;
185
186
function get_logged_in_user($must_be_logged_in=true) {
187
    global $g_logged_in_user, $got_logged_in_user;
188
    if ($got_logged_in_user) {
189
        // this could have been called earlier with $must_be_logged_in false
190
        if ($must_be_logged_in) {
191
            if ($g_logged_in_user) return $g_logged_in_user;
192
        } else {
193
            return $g_logged_in_user;
194
        }
195
    }
196
197
    if (web_stopped()) return null;
198
199
    $authenticator = null;
200
    if (isset($_COOKIE['auth'])) $authenticator = $_COOKIE['auth'];
201
202
    if ($authenticator) {
203
        $authenticator = BoincDb::escape_string($authenticator);
204
        $g_logged_in_user = BoincUser::lookup("authenticator='$authenticator'");
205
    }
206
    if ($must_be_logged_in && !$g_logged_in_user) {
207
        $next_url = '';
208
        if (array_key_exists('REQUEST_URI', $_SERVER)) {
209
            $next_url = $_SERVER['REQUEST_URI'];
210
            $n = strrpos($next_url, "/");
211
            if ($n) {
212
                $next_url = substr($next_url, $n+1);
213
            }
214
        }
215
        $next_url = urlencode($next_url);
216
        Header("Location: ".url_base()."login_form.php?next_url=$next_url");
0 ignored issues
show
Coding Style introduced by
Calls to inbuilt PHP functions must be lowercase; expected "header" but found "Header"
Loading history...
217
        exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
218
    }
219
    $got_logged_in_user = true;
220
    return $g_logged_in_user;
221
}
222
223
function show_login_info($prefix="") {
224
    $user = get_logged_in_user(false);
0 ignored issues
show
Bug introduced by
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...
225
    if ($user) {
226
        $url_tokens = url_tokens($user->authenticator);
227
        echo "<nobr>$user->name &middot; <a href=".$prefix."logout.php?$url_tokens>".tra("log out")."</a></nobr>";
228
    } else {
229
        echo "<a href=".$prefix."login_form.php>".tra("log in")."</a>";
230
    }
231
}
232
233
$cache_control_extra="";
234
$is_login_page = false;
235
236
// Call this to start pages.
237
// Outputs some HTML boilerplate,
238
// then calls project_banner() (in html/project/project.inc)
239
// to output whatever you want at the top of your web pages.
240
//
241
// Page_head() is overridable so that projects that want to integrate BOINC
242
// with an existing web framework can more easily do so.
243
// To do so, define page_head() in the project include file.
244
//
245
if (!function_exists("page_head")){
246
function page_head(
247
    $title,
248
        // page title. Put in <title>, used as title for browser tab.
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
249
    $body_attrs=null,
250
        // <body XXXX>
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
251
        // e.g. Javascript to put focus in an input field
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
252
        // (onload="document.form.foo.focus()")
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
253
        // or to jump to a particular post (onload="jumpToUnread();")
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
254
    $is_main = false,
255
        // if set, include schedulers.txt.
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
256
        // also pass to project_banner() in case you want a different
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
257
        // header for your main page.
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
258
    $url_prefix="",
259
        // prepend this to links.
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
260
        // Use for web pages not in the top directory
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
261
    $head_extra=null
262
        // extra stuff to put in <head>. E.g.:
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
263
        // reCAPTCHA code (create_profile.php)
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
264
        // bbcode javascript (forums)
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
265
) {
266
    global $caching, $cache_control_extra, $did_page_head;
267
    global $is_login_page, $fixed_navbar;
268
269
    if ($did_page_head) {
270
        return;
271
    }
272
273
    $did_page_head = true;
274
    $url_base = url_base();
275
276
    $rssname = "RSS 2.0";
277
    $rsslink = $url_base."rss_main.php";
278
279
    if (!$caching) {
280
        header("Content-type: text/html; charset=utf-8");
281
        header("Expires: Mon, 26 Jul 1997 05:00:00 UTC");
282
            // Date in the past
283
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC");
284
            // always modified
285
        header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0");
286
            // for HTTP/1.1
287
        header("Pragma: no-cache");
288
            // for HTTP/1.0
289
    }
290
291
    echo '<!DOCTYPE html>
292
        <html lang="en">
293
        <head>
294
    ';
295
    if (defined('GLOBAL_HEAD_EXTRA')) {
296
        echo GLOBAL_HEAD_EXTRA;
297
    }
298
    echo '
299
        <meta name="viewport" content="width=device-width, initial-scale=1">
300
    ';
301
    if ($head_extra) {
302
        echo "\n$head_extra\n";
303
    }
304
    if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space before logical operator; 0 found
Loading history...
Coding Style introduced by
Expected 1 space after logical operator; 0 found
Loading history...
305
        readfile("schedulers.txt");
306
    }
307
308
    $t = $title?$title:PROJECT;
309
    echo "<title>$t</title>\n";
310
    echo '
311
        <meta charset="utf-8">
312
    ';
313
    if (DARK_MODE) {
314
        echo <<<EOT
0 ignored issues
show
Coding Style introduced by
Use of heredoc and nowdoc syntax ("<<<") is not allowed; use standard strings or inline HTML instead
Loading history...
315
<script>
316
  if (window.matchMedia('(prefers-color-scheme: dark)').media === 'not all') {
317
      console.log("foobar");
318
    document.documentElement.style.display = 'none';
319
    document.head.insertAdjacentHTML(
320
        'beforeend',
321
        '<link rel="stylesheet" href="sample_bootstrap.min.css" onload="document.documentElement.style.display = \'\'"><link rel="stylesheet" href="custom.css">'
322
    );
323
  }
324
</script>
325
<link rel="stylesheet" href="bootstrap_darkly.min.css" media="(prefers-color-scheme: dark)">
326
<link rel="stylesheet" href="custom_dark.css" media="(prefers-color-scheme: dark)">
327
<link rel="stylesheet" href="sample_bootstrap.min.css" media="(prefers-color-scheme: no-preference), (prefers-color-scheme: light)">
328
<link rel="stylesheet" href="custom.css" media="(prefers-color-scheme: no-preference), (prefers-color-scheme: light)">
329
EOT;
330
    } else {
331
        echo '
332
            <link type="text/css" rel="stylesheet" href="'.secure_url_base().'/bootstrap.min.css" media="all">
333
        ';
334
    }
335
    if (defined('STYLESHEET')) {
336
        $stylesheet = $url_base.STYLESHEET;
337
        echo "
338
            <link rel=stylesheet type=\"text/css\" href=\"$stylesheet\">
339
        ";
340
    }
341
    if (defined('STYLESHEET2')) {
342
        $stylesheet2 = $url_base.STYLESHEET2;
343
        echo "
344
            <link rel=stylesheet type=\"text/css\" href=\"$stylesheet2\">
345
        ";
346
    }
347
348
    if (defined("SHORTCUT_ICON")) {
349
        echo '<link rel="icon" type="image/x-icon" href="'.SHORTCUT_ICON.'"/>
350
';
351
    }
352
353
    echo "
354
        <link rel=alternate type=\"application/rss+xml\" title=\"$rssname\" href=\"$rsslink\">
355
        </head>
356
    ";
357
    if ($fixed_navbar) {
358
        $body_attrs .= ' style="padding-top:70px"';
359
    }
360
    echo "<body $body_attrs>";
361
    echo '<div class="container-fluid">
362
    ';
363
364
    switch($title) {    //kludge
365
    case tra("Log in"):
366
    case tra("Create an account"):
367
    case tra("Server status page"):
368
        $is_login_page = true;
369
        break;
370
    default:
0 ignored issues
show
Coding Style introduced by
DEFAULT keyword must be indented 4 spaces from SWITCH keyword
Loading history...
Coding Style introduced by
Comment required for empty DEFAULT case
Loading history...
371
        break;
372
    }
373
    project_banner($title, $url_prefix, $is_main);
374
}
375
}
376
377
// See the comments for page_head()
378
//
379
if (!function_exists("page_tail")){
380
function page_tail(
381
    $show_date=false,
382
        // true for pages that are generated periodically rather than on the fly
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
383
    $url_prefix="",
384
        // use for pages not at top level
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
385
    $is_main=false
386
        // passed to project_footer;
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 4 spaces but found 8
Loading history...
387
) {
388
    echo "<br>\n";
389
    project_footer($is_main, $show_date, $url_prefix);
390
    echo '
391
        <script src="'.secure_url_base().'/jquery.min.js"></script>
392
        <script src="'.secure_url_base().'/bootstrap.min.js"></script>
393
        </div>
394
        </body>
395
        </html>
396
    ';
397
}
398
}
399
400
function db_error_page() {
401
    page_head("Database error");
402
    echo tra("A database error occurred while handling your request; please try again later.");
403
    page_tail();
404
}
405
406
function error_page($msg) {
407
    global $generating_xml;
408
    if ($generating_xml) {
409
        xml_error(-1, $msg);
410
    }
411
    page_head(tra("Unable to handle request"));
412
    echo $msg;
413
    page_tail();
414
    exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
415
}
416
417
// convert time interval in seconds to a string of the form
418
// 'D days h hours m min s sec'.
419
420
function time_diff($x, $res=3) {
421
    $x = (int)$x;
422
    $days    = (int)($x/86400);
423
    $hours   = (int)(($x-$days*86400)/3600);
424
    $minutes = (int)(($x-$days*86400-$hours*3600)/60);
425
    $seconds = $x % 60;
426
427
    $s = "";
428
    if ($days) {
429
        $s .= "$days ".tra("days")." ";
430
    }
431
    if ($res>0 && ($hours || strlen($s))) {
432
        $s .= "$hours ".tra("hours")." ";
433
    }
434
    if ($res>1 && ($minutes || strlen($s))) {
435
        $s .= "$minutes ".tra("min")." ";
436
    }
437
    if ($res>2) {
438
        $s .= "$seconds ".tra("sec")." ";
439
    }
440
    return $s;
441
}
442
443
444
function date_str($x) {
445
    if ($x == 0) return "---";
446
    return gmdate('j M Y', (int)$x);
447
}
448
449
function time_str($x) {
450
    if ($x == 0) return "---";
451
    return gmdate('j M Y, G:i:s', (int)$x) . " UTC";
452
}
453
454
function local_time_str($x) {
455
    if ($x == 0) return "---";
456
    return date('j M Y, H:i T', (int)$x);
457
}
458
459
function pretty_time_str($x) {
460
    return time_str($x);
461
}
462
463
function start_table_str($class="", $style="") {
464
    $s = $style?'style="'.$style.'"':'';
465
    return '<div class="table">
466
      <table '.$s.' width="100%" class="table table-condensed '.$class.'" >
467
    ';
468
}
469
470
function start_table($class="", $style="") {
471
    echo start_table_str($class, $style);
472
}
473
474
function end_table_str() {
475
    return '</table>
476
        </div>
477
    ';
478
}
479
480
function end_table() {
481
    echo end_table_str();
482
}
483
484
// Table header row with unlimited number of columns
485
486
function table_header() {
487
    echo "<tr>\n";
488
    $c = 'class="bg-primary"';
489
    for ($i = 0; $i < func_num_args(); $i++) {
490
        if (is_array(func_get_arg($i))) {
491
            $col = func_get_arg($i);
492
            echo "<th $c ".$col[1].">".$col[0]."</th>\n";
493
        } else {
494
            echo "<th $c>".func_get_arg($i)."</th>\n";
495
        }
496
    }
497
    echo "</tr>\n";
498
}
499
500
// Table row with unlimited number of columns
501
502
function table_row() {
503
    echo "<tr>\n";
504
    for ($i = 0; $i < func_num_args(); $i++) {
505
        if (is_array(func_get_arg($i))) {
506
            $col = func_get_arg($i);
507
            echo "<td ".$col[1].">".$col[0]."</td>\n";
508
        } else {
509
            echo "<td>".func_get_arg($i)."</td>\n";
510
        }
511
    }
512
    echo "</tr>\n";
513
}
514
515
function row1($x, $ncols=2, $class="heading") {
516
    if ($class == "heading") {
517
        echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n";
518
    } else {
519
        echo "<tr><td class=\"$class\" colspan=\"$ncols\">$x</td></tr>\n";
520
    }
521
}
522
523
define('NAME_ATTRS', 'class="text-right " style="padding-right:12px"');
524
define('VALUE_ATTRS', 'style="padding-left:12px"');
525
define('VALUE_ATTRS_ERR', 'class="danger" style="padding-left:12px"');
526
527
// a table row with 2 columns, with the left on right-aligned
528
529
function row2($x, $y, $show_error=false, $lwidth='40%') {
530
    if ($x==="") $x="<br>";
531
    if ($y==="") $y="<br>";
532
    $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS;
533
    echo "<tr>
534
        <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td>
535
        <td $attrs >$y</td>
536
        </tr>
537
    ";
538
}
539
540
// output the first part of row2();
541
// then write the content, followed by </td></tr>
542
543
function row2_init($x, $lwidth='40%') {
544
    echo sprintf('<tr>
545
        <td width="%s" %s>%s</td>
546
        <td %s>',
547
        $lwidth, NAME_ATTRS, $x, VALUE_ATTRS
548
    );
549
}
550
551
function row2_plain($x, $y) {
552
    echo "<tr><td>$x</td><td>$y</td></tr>\n";
553
}
554
555
function rowify($string) {
556
    echo "<tr><td>$string</td></tr>";
557
}
558
559
function row_array($x, $attrs=null) {
560
    echo "<tr>\n";
561
    $i = 0;
562
    foreach ($x as $h) {
563
        $a = $attrs?$attrs[$i]:"";
564
        echo "<td $a>$h</td>\n";
565
        $i++;
566
    }
567
    echo "</tr>\n";
568
}
569
570
define ('ALIGN_RIGHT', 'style="text-align:right;"');
571
572
function row_heading_array($x, $attrs=null, $class='bg-primary') {
573
    echo "<tr>";
574
    $i = 0;
575
    foreach ($x as $h) {
576
        $a = $attrs?$attrs[$i]:"";
577
        echo "<th $a class=\"$class\">$h</th>";
578
        $i++;
579
    }
580
    echo "</tr>\n";
581
}
582
583
function row_heading($x, $class='bg-primary') {
584
    echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr>
585
        ', $class, $x
586
    );
587
}
588
589
function url_tokens($auth) {
590
    $now = time();
591
    $ttok = md5((string)$now.$auth);
592
    return "&amp;tnow=$now&amp;ttok=$ttok";
593
}
594
595
function form_tokens($auth) {
596
    $now = time();
597
    $ttok = md5((string)$now.$auth);
598
    return "<input type=\"hidden\" name=\"tnow\" value=\"$now\">
599
        <input type=\"hidden\" name=\"ttok\" value=\"$ttok\">
600
    ";
601
}
602
603
function valid_tokens($auth) {
604
    $tnow = get_str('tnow', true);
605
    $ttok = get_str('ttok', true);
606
    if (!$tnow) {
607
      if (isset($_POST['tnow'])) {
608
          $tnow = $_POST['tnow'];
609
      }
610
    }
611
    if (!$ttok) {
612
      if (isset($_POST['ttok'])) {
613
          $ttok = $_POST['ttok'];
614
      }
615
    }
616
    if (!$tnow) return false;
617
    if (!$ttok) return false;
618
    $t = md5((string)$tnow.$auth);
619
    if ($t != $ttok) return false;
620
    if (time() > $tnow + 86400) return false;
621
    return true;
622
}
623
624
function check_tokens($auth) {
625
    if (valid_tokens($auth)) return;
626
    error_page(
627
        tra("Link has timed out. Please click Back, refresh the page, and try again.")
628
    );
629
}
630
631
// Generates a legal filename from a parameter string.
632
633
function get_legal_filename($name) {
634
    return strtr($name, array(','=>'', ' '=>'_'));
635
}
636
637
// Returns a string containing as many words
638
// (being collections of characters separated by the character $delimiter)
639
// as possible such that the total string length is <= $chars characters long.
640
// If $ellipsis is true, then an ellipsis is added to any sentence which
641
// is cut short.
642
643
function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) {
644
    $words = explode($delimiter, $sentence);
645
    $total_chars = 0;
646
    $trunc = false;
647
    $result = "";
648
649
    foreach ($words as $word) {
650
        if (strlen($result) + strlen($word) > $max_chars) {
651
            $trunc = true;
652
            break;
653
        }
654
        if ($result) {
655
            $result .= " $word";
656
        } else {
657
            $result = $word;
658
        }
659
    }
660
661
    if ($ellipsis && $trunc) {
662
        $result .= "...";
663
    }
664
665
    return $result;
666
}
667
668
// use this for user RAC and result credit
669
//
670
function format_credit($x) {
671
    return number_format($x, 2);
672
}
673
674
// use this when credit is likely to be large, e.g. team RAC
675
//
676
function format_credit_large($x) {
677
    return number_format($x, 0);
678
}
679
680
function host_link($hostid) {
681
    if ($hostid) {
682
        return "<a href=\"show_host_detail.php?hostid=$hostid\">$hostid</a>";
683
    } else {
684
        return "---";
685
    }
686
}
687
688
function open_output_buffer() {
689
    ob_start();
690
    ob_implicit_flush(0);
691
}
692
693
function close_output_buffer($filename) {
694
    $fh = fopen($filename, "w");
695
    $page = ob_get_contents();
696
    ob_end_clean();
697
    fwrite($fh, $page);
698
    fclose($fh);
699
}
700
701
function bbcode_info() {
702
    return "<br><a href=bbcode.php target=new><small>".tra("Use BBCode tags to format your text")."</small></a>\n";
703
}
704
705
// strip slashes if magic quotes in effect
706
function undo_magic_quotes($x) {
707
    if (version_compare(PHP_VERSION, '5.4.0') < 0 && get_magic_quotes_gpc()) {
708
        return stripslashes($x);
709
    }
710
    return $x;
711
}
712
713
// check for bogus GET args
714
//
715
function check_get_args($args) {
716
    foreach ($_GET as $key => $val) {
717
        if (!in_array($key, $args)) {
718
            Header("Location: extra_arg_$key.html");
0 ignored issues
show
Coding Style introduced by
Calls to inbuilt PHP functions must be lowercase; expected "header" but found "Header"
Loading history...
719
            die;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
720
        }
721
    }
722
}
723
724
// returns null if the arg is optional and missing
725
//
726
function get_int($name, $optional=false) {
727
    $x=null;
728
    if (isset($_GET[$name])) $x = $_GET[$name];
729
    if (!is_numeric($x)) {
730
        if ($optional) {
731
            if ($x) {
732
                Header("Location: non_num_arg.html");
0 ignored issues
show
Coding Style introduced by
Calls to inbuilt PHP functions must be lowercase; expected "header" but found "Header"
Loading history...
733
                die;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
734
            }
735
            return null;
736
        } else {
737
            Header("Location: missing_arg_$name.html");
0 ignored issues
show
Coding Style introduced by
Calls to inbuilt PHP functions must be lowercase; expected "header" but found "Header"
Loading history...
738
            die;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
739
        }
740
    }
741
    return (int)$x;
742
}
743
744
// returns null if the arg is optional and missing
745
//
746
function post_num($name, $optional=false) {
747
    $x = null;
748
    if (isset($_POST[$name])) $x = $_POST[$name];
749
    if (!is_numeric($x)) {
750
        if ($optional) {
751
            return null;
752
        } else {
753
            error_page("missing or bad parameter: $name; supplied: ".htmlspecialchars($x));
754
        }
755
    }
756
    return (double)$x;
757
}
758
759
// returns null if the arg is optional and missing
760
//
761
function post_int($name, $optional=false) {
762
    $x = post_num($name, $optional);
763
    if (is_null($x)) return null;
764
    $y = (int)$x;
765
    if ($x != $y) {
766
        error_page("param $name must be an integer");
767
    }
768
    return $y;
769
}
770
771
function get_array($name) {
772
    if (isset($_GET[$name])) {
773
        return $_GET[$name];
774
    } else {
775
        return array();
776
    }
777
}
778
779
function get_str($name, $optional=false) {
780
    if (isset($_GET[$name])) {
781
        $x = $_GET[$name];
782
    } else {
783
        if (!$optional) {
784
            error_page("missing or bad parameter: $name");
785
        }
786
        $x = null;
787
    }
788
    return undo_magic_quotes($x);
789
}
790
791
function post_str($name, $optional=false) {
792
    if (isset($_POST[$name])) {
793
        $x = $_POST[$name];
794
    } else {
795
        if (!$optional) {
796
            error_page("missing or bad parameter: $name");
797
        }
798
        $x = null;
799
    }
800
    return undo_magic_quotes($x);
801
}
802
803
function post_arr($name, $optional=false) {
804
    if (isset($_POST[$name]) && is_array($_POST[$name])) {
805
        $x = $_POST[$name];
806
    } else {
807
        if (!$optional) {
808
            error_page("missing or bad parameter: $name");
809
        }
810
        $x = null;
811
    }
812
    return $x;
813
}
814
815
function is_ascii($str) {
816
    // the mb_* functions are not included by default
817
    // return (mb_detect_encoding($passwd) -= 'ASCII');
818
819
    for ($i=0; $i<strlen($str); $i++) {
0 ignored issues
show
Coding Style Performance introduced by
The use of strlen() inside a loop condition is not allowed; assign the return value to a variable and use the variable in the loop condition instead
Loading history...
820
        $c = ord(substr($str, $i));
821
        if ($c < 32 || $c > 127) return false;
822
    }
823
    return true;
824
}
825
826
// This function replaces some often made mistakes while entering numbers
827
// and gives back an error if there are false characters
828
// It will also be checked if the value is within certain borders
829
// @param string &$value reference to the value that should be verified
830
// @param double $low the lowest number of value if verified
831
// @param double $high the highest number of value if verified
832
// @return bool true if $value is numeric and within the defined borders,
833
//   false if $value is not numeric, no changes were made in this case
834
//
835
function verify_numeric(&$value, $low, $high = false) {
836
    $number = trim($value);
837
    $number = str_replace('o', '0', $number);
838
    $number = str_replace('O', '0', $number);
839
    $number = str_replace('x', '', $number); //if someone enters '0x100'
840
    $number = str_replace(',', '.', $number); // replace the german decimal separator
841
    // if no value was entered and this is ok
842
    //
843
    if ($number=='' && !$low) return true;
844
845
    // the supplied value contains alphabetic characters
846
    //
847
    if (!is_numeric($number)) return false;
848
849
    if ($number < $low) return false;
850
851
    if ($high) {
852
        if ($number > $high) return false;
853
    }
854
    $value = (double)$number;
855
    return true;
856
}
857
858
// Generate a "select" element from an array of values
859
//
860
function select_from_array($name, $array, $selection=null, $width=240) {
861
    $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"';
862
863
    foreach ($array as $key => $value) {
864
        if ($value) {
865
            $out .= "<option ";
866
            if ($key == $selection) {
867
                $out .= "selected ";
868
            }
869
            $out .= "value=\"".$key."\">".$value."</option>\n";
870
        }
871
    }
872
    $out .= "</select>\n";
873
    return $out;
874
}
875
876
// Convert to entities, while preserving already-encoded entities.
877
// Do NOT use if $str contains valid HTML tags.
878
//
879
function boinc_htmlentities($str) {
880
    $str = html_entity_decode($str, ENT_COMPAT, "UTF-8");
881
    $str = htmlentities($str, ENT_COMPAT, "UTF-8");
882
    return $str;
883
}
884
885
function strip_bbcode($string){
886
    return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string);
887
}
888
889
function current_url() {
890
    $url = "http";
891
    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
892
        $url .= "s";
893
    }
894
    $url .= "://";
895
    $url .= $_SERVER['SERVER_NAME'];
896
    $url .= ":".$_SERVER['SERVER_PORT'];
897
    if (isset($_SERVER['REQUEST_URI'])) {
898
        $url .= $_SERVER['REQUEST_URI'];
899
    } else {
900
        if ($_SERVER['QUERY_STRING']) {
901
            $url .= "?".$_SERVER['QUERY_STRING'];
902
        }
903
    }
904
    return $url;
905
}
906
907
// return style for a button
908
// the colors for bootstrap's btn-success are almost illegible;
909
// the green is too light.  Use a darker green.
910
//
911
function button_style($color='green', $font_size=null) {
912
    $fs = '';
913
    if ($font_size) {
914
        $fs = sprintf('; font-size:%dpx', $font_size);
915
    }
916
    $c = 'seagreen';
917
    if ($color == 'blue') $c = 'steelblue';
918
    return sprintf(
919
        'style="background-color:%s; color:white; text-decoration:none%s"',
920
        $c, $fs
921
    );
922
}
923
// Show a link formatted to look like a button.
924
// url: the destination of the lin
925
// text: The text to display on the button
926
// desc: tooltip text (show on hover)
927
// class: class of the button, e.g. btn
928
// extra: Additional text in href tag
929
//
930
function button_text($url, $text, $desc=null, $class=null, $extra='') {
931
    if (!$desc) {
932
        $desc = $text;
933
    }
934
    if (!$extra && !$class) {
935
        $extra = button_style();
936
    }
937
    if (!$class) {
938
        $class = "btn btn-sm";
939
    }
940
    return sprintf(' <a href="%s" title="%s" class="btn %s" %s>%s</a>',
941
        $url, $desc, $class, $extra, $text
942
    );
943
}
944
945
function button_text_small($url, $text, $desc=null) {
946
    return button_text($url, $text, $desc, "btn btn-xs", button_style());
947
}
948
949
function show_button($url, $text, $desc=null, $class=null, $extra=null) {
950
    echo button_text($url, $text, $desc, $class, $extra);
951
}
952
953
// for places with a bunch of buttons, like forum posts
954
//
955
function show_button_small($url, $text, $desc=null) {
956
    echo button_text_small($url, $text, $desc);
957
}
958
959
// used for showing icons
960
//
961
function show_image($src, $title, $alt, $height=null) {
962
    $h = "";
963
    if ($height) {
964
        $h = "height=\"$height\"";
965
    }
966
    echo "<img class=\"icon\" border=\"0\" title=\"$title\" alt=\"$alt\" src=\"$src\" $h>";
967
}
968
969
function show_project_down() {
970
    global $did_page_head;
971
    if (!$did_page_head) {
972
        page_head(tra("Project down for maintenance"));
973
    }
974
    echo tra(
975
        "%1 is temporarily shut down for maintenance.  Please try again later.",
976
        PROJECT
977
    );
978
    page_tail();
979
    exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
980
}
981
982
function check_web_stopped() {
983
    global $generating_xml;
984
    if (web_stopped()) {
985
        if ($generating_xml) {
986
            xml_error(-183);
987
        } else {
988
            show_project_down();
989
        }
990
    }
991
}
992
993
// Connects to database server and selects database as noted in config.xml
994
// If only read-only access is necessary,
995
// tries instead to connect to <replica_db_host> if tag exists.
996
// DEPRECATED - use boinc_db.inc
997
//
998
function db_init($try_replica=false) {
999
    check_web_stopped();
1000
    $retval = db_init_aux($try_replica);
1001
    if ($retval == 1) {
1002
        echo tra("Unable to connect to database - please try again later");
1003
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1004
    }
1005
    if ($retval == 2) {
1006
        echo tra("Unable to select database - please try again later");
1007
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1008
    }
1009
    return 0;
1010
}
1011
1012
// return a structure indicating whether project has non-deprecated
1013
// apps versions for various resource types,
1014
// and with a count of app versions
1015
//
1016
function get_app_types() {
1017
    $t = new StdClass;
1018
    $t->cpu = false;
1019
    $t->cuda = false;
1020
    $t->ati = false;
1021
    $t->intel_gpu = false;
1022
    $t->apple_gpu = false;
1023
    $t->count = 0;
1024
    $avs = BoincAppVersion::enum("deprecated=0");
1025
    foreach ($avs as $av) {
1026
        if (strstr($av->plan_class, "ati")) {
1027
            $t->ati = true;
1028
            $t->count++;
1029
        } else if (strstr($av->plan_class, "amd")) {
1030
            $t->ati = true;
1031
            $t->count++;
1032
        } else if (strstr($av->plan_class, "cuda")) {
1033
            $t->cuda = true;
1034
            $t->count++;
1035
        } else if (strstr($av->plan_class, "nvidia")) {
1036
            $t->cuda = true;
1037
            $t->count++;
1038
        } else if (strstr($av->plan_class, "intel_gpu")) {
1039
            $t->intel_gpu = true;
1040
            $t->count++;
1041
        } else if (strstr($av->plan_class, "apple_gpu")) {
1042
            $t->apple_gpu = true;
1043
            $t->count++;
1044
        } else {
1045
            $t->cpu = true;
1046
            $t->count++;
1047
        }
1048
    }
1049
    return $t;
1050
}
1051
1052
// Functions to sanitize GET and POST args
1053
1054
// "next_url" arguments (must be local, not full URLs)
1055
//
1056
function sanitize_local_url($x) {
1057
    if (!$x) return $x;
1058
    $x = trim($x, "/");
1059
    if (strstr($x, "/")) return "";
1060
    if (strstr($x, "<")) return "";
1061
    if (strstr($x, "\"")) return "";
1062
    return $x;
1063
}
1064
1065
function sanitize_user_url($x) {
1066
    // if protocol is given, must be http: or https:
1067
    $y = explode('//', $x);
1068
    switch (count($y)) {
1069
    case 1:
1070
        $z = $x;
1071
        break;
1072
    case 2:
1073
        $z = $y[1];
1074
        if (strtolower($y[0]) == 'http:') break;
1075
        if (strtolower($y[0]) == 'https:') break;
1076
        return '';
1077
    default: return '';
0 ignored issues
show
Coding Style introduced by
DEFAULT keyword must be indented 4 spaces from SWITCH keyword
Loading history...
Coding Style introduced by
Blank lines are not allowed after DEFAULT statements
Loading history...
1078
    }
1079
    // everything else must be alphanumeric, or -_/.#?&=
1080
    if (preg_match('/^[-_.\/#?&=a-zA-Z0-9]*$/', $z)) {
1081
        return $x;
1082
    }
1083
    return '';
1084
}
1085
1086
// strip HTML tags
1087
//
1088
function sanitize_tags($x) {
1089
    if (!$x) return $x;
1090
    return strip_tags($x);
1091
}
1092
1093
function sanitize_numeric($x) {
1094
    if (!$x || !is_numeric($x)) {
1095
        return '';
1096
    }
1097
    return $x;
1098
}
1099
1100
function sanitize_email($x) {
1101
    if (!$x) return $x;
1102
    if (function_exists('filter_var')) {
1103
        return filter_var($x, FILTER_SANITIZE_EMAIL);
1104
    } else {
1105
        return strip_tags($x);
1106
    }
1107
}
1108
1109
// pages like top_hosts.php, team_members.php etc. have a textual
1110
// "sort_by" argument.
1111
// Check this to avoid XSS vulnerability
1112
//
1113
function sanitize_sort_by($x) {
1114
    switch($x) {
1115
    case 'expavg_credit':
1116
    case 'total_credit':
1117
        return;
1118
    default:
0 ignored issues
show
Coding Style introduced by
DEFAULT keyword must be indented 4 spaces from SWITCH keyword
Loading history...
Coding Style introduced by
DEFAULT case must have a breaking statement
Loading history...
1119
        error_page('bad sort_by');
1120
    }
1121
}
1122
1123
function flops_to_credit($f) {
1124
    return $f*(200/86400e9);
1125
}
1126
1127
function credit_to_gflop_hours($c) {
1128
    return $c/(200/24);
1129
}
1130
1131
function do_download($path) {
1132
    $name=basename($path);
1133
    header('Content-Description: File Transfer');
1134
    header('Content-Type: application/octet-stream');
1135
    header('Content-Disposition: attachment; filename='.$name);
1136
    header('Content-Transfer-Encoding: binary');
1137
    header('Expires: 0');
1138
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1139
    header('Pragma: public');
1140
    header('Content-Length: ' . filesize($path));
1141
    flush();
1142
    readfile($path);
1143
}
1144
1145
// if have SSL but not using it, redirect
1146
//
1147
function redirect_to_secure_url() {
1148
    if (defined('SECURE_URL_BASE')
1149
        && strstr(SECURE_URL_BASE, "https://")
1150
        && empty($_SERVER['HTTPS'])
1151
    ) {
1152
        Header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
0 ignored issues
show
Coding Style introduced by
Calls to inbuilt PHP functions must be lowercase; expected "header" but found "Header"
Loading history...
1153
        exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1154
    }
1155
}
1156
1157
if (php_sapi_name() != "cli") {
1158
    redirect_to_secure_url();
1159
}
1160
1161
function badges_string($is_user, $item, $height) {
1162
    if (DISABLE_BADGES) return null;
1163
    if ($is_user) {
1164
        $bus = BoincBadgeUser::enum("user_id=$item->id");
1165
    } else {
1166
        $bus = BoincBadgeTeam::enum("team_id=$item->id");
1167
    }
1168
    if (!$bus) return null;
1169
    $x = "";
1170
    foreach ($bus as $bu) {
1171
        $badge = BoincBadge::lookup_id($bu->badge_id);
1172
        $x .= "<img title=\"$badge->title\" valign=top height=$height src=$badge->image_url> ";
1173
    }
1174
    return $x;
1175
}
1176
1177
function show_badges_row($is_user, $item) {
1178
    if (BADGE_HEIGHT_LARGE == 0) return;
0 ignored issues
show
introduced by
The condition BADGE_HEIGHT_LARGE == 0 is always false.
Loading history...
1179
    $x = badges_string($is_user, $item, BADGE_HEIGHT_LARGE);
1180
    if ($x) {
1181
        row2("Badges", $x);
1182
    }
1183
}
1184
1185
// If this request is from a BOINC client, return its version as MMmmRR.
1186
// Otherwise return 0.
1187
// Format of user agent string is "BOINC client (windows_x86_64 7.3.17)"
1188
//
1189
function boinc_client_version(){
1190
    if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0;
1191
    $x = $_SERVER['HTTP_USER_AGENT'];
1192
    $e =  "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/";
0 ignored issues
show
Coding Style introduced by
Expected 1 space after "="; 2 found
Loading history...
1193
    if (preg_match($e, $x, $matches)) {
1194
        return $matches[1]*10000 + $matches[2]*100 + $matches[3];
1195
    }
1196
    return 0;
1197
}
1198
1199
// output a script for counting chars left in text field
1200
//
1201
function text_counter_script() {
1202
    echo "<script type=\"text/javascript\">
1203
        function text_counter(field, countfield, maxlimit) {
1204
            if (field.value.length > maxlimit) {
1205
                field.value =field.value.substring(0, maxlimit);
1206
            } else {
1207
                countfield.value = maxlimit - field.value.length
1208
            }
1209
        }
1210
        </script>
1211
    ";
1212
}
1213
1214
// return HTML for a textarea with chars-remaining counter.
1215
// Call text_counter_script() before using this.
1216
//
1217
function textarea_with_counter($name, $maxlen, $text) {
1218
    $rem_name = $name."_remaining";
1219
    return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\"
1220
        onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea>
1221
        <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining")
1222
    ;
0 ignored issues
show
Coding Style introduced by
Space found before semicolon; expected ");" but found ")
;"
Loading history...
1223
}
1224
1225
// convert number MMmmrr to string MM.mm.rr
1226
//
1227
function version_string_maj_min_rel($v) {
1228
    $maj = (int)($v/10000);
1229
    $v -= $maj*10000;
1230
    $min = (int)($v/100);
1231
    $v -= $min*100;
1232
    return sprintf("%d.%d.%d", $maj, $min, $v);
1233
}
1234
1235
function google_search_form($url) {
1236
    echo "
1237
        <nobr>
1238
        <form method=get action=\"https://google.com/search\">
1239
        <input type=hidden name=domains value=\"$url\">
1240
        <input type=hidden name=sitesearch value=\"$url\">
1241
        <input name=q size=20>
1242
        <input type=submit value=".tra("Search").">
1243
        </form>
1244
        </nobr>
1245
    ";
1246
}
1247
1248
// use the following around text with long lines,
1249
// to limit the width and make it more readable.
1250
//
1251
function text_start($width=640) {
1252
    echo sprintf("<div style=\"max-width: %dpx;\">\n", $width);
1253
}
1254
function text_end() {
1255
    echo "</div>\n";
1256
}
1257
1258
// express a size in terms of TB, GB etc.
1259
//
1260
function size_string($x) {
1261
    if ($x > TERA) {
1262
        return number_format($x/TERA, 2)." TB";
1263
    }
1264
    if ($x > GIGA) {
1265
        return number_format($x/GIGA, 2)." GB";
1266
    }
1267
    if ($x > MEGA) {
1268
        return number_format($x/MEGA, 2)." MB";
1269
    }
1270
    if ($x > KILO) {
1271
        return number_format($x/KILO, 2)." KB";
1272
    }
1273
    return "$x bytes";
1274
}
1275
1276
function cert_filename() {
1277
    return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php";
1278
}
1279
1280
// if user hasn't validated their email addr, tell them to
1281
//
1282
function check_validated_email($user) {
1283
    if (!$user->email_validated) {
1284
        page_head("Please validate your email address");
1285
        echo "
1286
            To post here, please
1287
            <a href=validate_email_addr.php>validate your email address<a>.
1288
        ";
1289
        page_tail();
1290
        exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
1291
    }
1292
}
1293
1294
1295
?>
1296