Completed
Push — rework ( 810325...63821e )
by Markus
02:43
created

selftest.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<!DOCTYPE html>
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 77 and the first side effect is on line 1.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
<html>
3
<head>
4
    <title>SSPkS Selftest</title>
5
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
    <link rel="stylesheet" href="data/css/style.css" type="text/css" />
7
    <link rel="stylesheet" href="data/css/style_mobile.css" type="text/css" media="handheld"/>
8
    <!-- Colours from: https://www.materialui.co/colors -->
9
    <style type="text/css">
10
        .check {
11
            width: 80%;
12
            background-color: #cfd8dc;
13
            vertical-align: middle;
14
        }
15
16
        .check .checkline {
17
            height: 3em;
18
            position: relative;
19
        }
20
21
        .check .description {
22
            height: 3em;
23
            line-height: 3em;
24
            margin-left: 2em;
25
        }
26
27
        .check .description span {
28
            display: inline-block;
29
            line-height: 1em;
30
            vertical-align: middle;
31
            font-weight: bold;
32
        }
33
34
        .checkline .result {
35
            position: absolute;
36
            right: 0px;
37
            bottom: 0px;
38
            height: 3em;
39
            line-height: 3em;
40
            width: 3em;
41
            text-align: center;
42
        }
43
44
        .checkline .result span {
45
            display: inline-block;
46
            line-height: 1em;
47
            vertical-align: middle;
48
            font-size: 2.5em;
49
        }
50
51
        .ok {
52
            background-color: #4caf50;
53
            color: white;
54
        }
55
56
        .error {
57
            background-color: #d50000;
58
            color: white;
59
        }
60
61
        .errortext {
62
            margin-left: 1em;
63
            padding-left: 1em;
64
            margin-right: 4em;
65
            margin-top: 0.3em;
66
            padding-top: 0.3em;
67
            padding-bottom: 0.3em;
68
            background-color: #ffcdd2;
69
        }
70
    </style>
71
</head>
72
<body>
73
<h1>SSPkS Selftest</h1>
74
<p>
75
<?php
76
77
function assertTrue($assertion, $description, $error_text)
78
{
79
    echo('<div class="check">');
80
    echo('<div class="checkline">');
81
    echo('<div class="description"><span>' . $description . '</span></div>');
82
    if ($assertion === true) {
83
        // All OK
84
        echo('<div class="result ok"><span>✔</span></div>');
85
        echo('</div>');  // close checkline
86
    } else {
87
        // Not OK
88
        echo('<div class="result error"><span>✖</span></div>');
89
        echo('</div>');  // close checkline
90
        echo('<div class="errortext">' . $error_text . '</div>');
91
    }
92
    echo('</div>');
93
    echo('<br/>');
94
}
95
96
97
assertTrue(
98
    version_compare(phpversion(), '5.6', '>='),
99
    'PHP Version (' . phpversion() . ')',
100
    'Please use a more recent PHP version for optimal performance. PHP 7 preferred.'
101
);
102
103
assertTrue(
104
    extension_loaded('phar'),
105
    'Phar extension installed',
106
    'Please install/enable the <tt>php-phar</tt> extension.'
107
);
108
109
assertTrue(
110
    is_dir(dirname(__FILE__) . '/vendor'),
111
    'Composer <tt>vendor</tt> directory exists',
112
    'Please download and run Composer according to the <tt>INSTALL.md</tt>.'
113
);
114
115
assertTrue(
116
    file_exists(dirname(__FILE__) . '/vendor/autoload.php'),
117
    'Composer <tt>vendor/autoload.php</tt> was generated',
118
    'Please download and run Composer according to the <tt>INSTALL.md</tt>.'
119
);
120
121
assertTrue(
122
    is_dir(sys_get_temp_dir()),
123
    'System temporary directory (' . sys_get_temp_dir() . ') exists.',
124
    'Make sure your temporary directory exists and is writeable and your environment variables (<tt>TMP</tt>, <tt>TEMP</tt>) are set or set <tt>sys_temp_dir</tt> in your <tt>php.ini</tt>.'
125
);
126
127
assertTrue(
128
    is_writeable(sys_get_temp_dir()),
129
    'System temporary directory (' . sys_get_temp_dir() . ') is writeable.',
130
    'Make sure your temporary directory is writeable for the web server process.'
131
);
132
133
assertTrue(
134
    (ini_get('allow_url_fopen') == true),
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing ini_get('allow_url_fopen') of type string to the boolean true. If you are specifically checking for a non-empty string, consider using the more explicit !== '' instead.
Loading history...
135
    'Using URLs in <tt>fopen()</tt> is allowed',
136
    'Please set <tt>allow_url_fopen</tt> to <tt>true</tt> in your <tt>php.ini</tt>.'
137
);
138
139
assertTrue(
140
    is_writable(dirname(__FILE__) . '/packages/'),
141
    'Directory <tt>packages/</tt> writeable',
142
    'Please make the <tt>packages/</tt> directory writeable for the web server process.'
143
);
144
145
$test_file = dirname(__FILE__) . '/packages/testfile.$$$';
146
147
assertTrue(
148
    (file_put_contents($test_file, 'TestData12345678') === 16),
149
    'Can write testfile to <tt>packages/</tt> directory',
150
    'Please make the <tt>packages/</tt> directory writeable for the web server process.'
151
);
152
153
assertTrue(
154
    unlink($test_file),
155
    'Can remove testfile from <tt>packages/</tt> directory',
156
    'Please make the <tt>packages/</tt> directory writeable for the web server process (also allow deletions).'
157
);
158
159
/*
160
assertTrue(
161
    false,
162
    'This is to see how a failed test looks like.',
163
    'Don\'t panic. This is only here during development.'
164
);
165
*/
166
167
?>
168
</body>
169
</html>
170