forked from tikiorg/tiki
/
tiki-check.php
2119 lines (2004 loc) · 93.4 KB
/
tiki-check.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
/*
About the design:
tiki-check.php is designed to run in 2 modes
1) Regular mode. From inside Tiki, in Admin | General
2) Stand-alone mode. Used to check a server pre-Tiki installation, by copying (only) tiki-check.php onto the server and pointing your browser to it.
tiki-check.php should not crash but rather avoid running tests which lead to tiki-check crashes.
*/
// TODO : Create sane 3rd mode for Monitoring Software like Nagios, Icinga, Shinken
// * needs authentication, if not standalone
isset($_REQUEST['nagios']) ? $nagios = true : $nagios = false;
file_exists('tiki-check.php.lock') ? $locked = true : $locked = false;
$font = 'lib/captcha/DejaVuSansMono.ttf';
if (file_exists('./db/local.php') && file_exists('./templates/tiki-check.tpl')) {
$standalone = false;
require_once ('tiki-setup.php');
// TODO : Proper authentication
if (!$nagios) {
$access->check_permission('tiki_p_admin');
}
} else {
$standalone = true;
$render = "";
/**
* @param $string
* @return mixed
*/
function tra($string)
{
return $string;
}
/**
* @param $var
*/
function renderTable($var)
{
global $render;
if (is_array($var)) {
$render .= '<table style="border:2px solid grey;">';
foreach ($var as $key => $value) {
$render .= '<tr style="border:1px solid">';
$render .= '<td style="border:1px black;padding:5px;white-space:nowrap;">';
$render .= $key;
$render .= "</td>";
$iNbCol=0;
foreach ($var[$key] as $key2 => $value2) {
$render .= '<td style="border:1px solid;';
if ($iNbCol != count(array_keys($var[$key]))-1) {
$render .= 'text-align: center;white-space:nowrap;';
}
$render .= '"><span class="';
switch($value2) {
case 'good':
case 'safe':
case 'ugly':
case 'bad':
case 'risky':
case 'info':
$render .= "button $value2";
break;
}
$render .= '">'.$value2.'</span></td>';
$iNbCol++;
}
$render .= '</tr>';
}
$render .= '</table>';
} else {
$render .= 'Nothing to display.';
}
}
}
// Get PHP properties and check them
$php_properties = false;
// Check error reporting level
$e = error_reporting();
$d = ini_get('display_errors');
if ( $e == 0 ) {
if ($d != 1) {
$php_properties['Error reporting'] = array(
'fitness' => tra('info'),
'setting' => 'Disabled',
'message' => tra('You will get no errors reported, because error_reporting and display_errors are both turned off. This might be the right thing for a production site, but in case of problems enable these in php.ini to get more information.')
);
} else {
$php_properties['Error reporting'] = array(
'fitness' => tra('info'),
'setting' => 'Disabled',
'message' => tra('You will get no errors reported although display_errors is On, because the error_reporting level is set to 0. This might be the right thing for a production site, but in case of problems raise the value in php.ini to get more information.')
);
}
} elseif ( $e > 0 && $e < 32767) {
if ($d != 1) {
$php_properties['Error reporting'] = array(
'fitness' => tra('info'),
'setting' => 'Disabled',
'message' => tra('You will get no errors reported, because display_errors is turned off. This might be the right thing for a production site, but in case of problems enable it in php.ini to get more information. Your error_reporting level is decent at '.$e.'.')
);
} else {
$php_properties['Error reporting'] = array(
'fitness' => tra('info'),
'setting' => 'Partly',
'message' => tra('You will not get all errors reported as your error_reporting level is at '.$e.'. '.'This is not necessarily a bad thing (and it might be just right for production sites) as you will still get critical errors reported, but sometimes it can be handy to get more information. Check your error_reporting level in php.ini in case of having issues.')
);
}
} else {
if ( $d != 1 ) {
$php_properties['Error reporting'] = array(
'fitness' => tra('info'),
'setting' => 'Disabled',
'message' => tra('You will get no errors reported although your error_reporting level is all the way up at '.$e.', but display_errors is off. This might be the right thing for a production site, but in case of problems enable it in php.ini to get more information.')
);
} else {
$php_properties['Error reporting'] = array(
'fitness' => tra('info'),
'setting' => 'Full',
'message' => tra('You will get all errors reported as your error_reporting level is all the way up at '.$e.' and display_errors is on. Way to go in case of problems as the error reports usually contain some valuable hints!')
);
}
}
// Now we can raise our error_reporting to make sure we get all errors
// This is especially important as we can't use proper exception handling with PDO as we need to be PHP 4 compatible
error_reporting(-1);
// Check if ini_set works
if (function_exists('ini_set')) {
$php_properties['ini_set'] = array(
'fitness' => tra('good'),
'setting' => 'Enabled',
'message' => tra('ini_set is used in some places to accomodate for special needs of some Tiki features.')
);
// As ini_set is available, use it for PDO error reporting
ini_set('display_errors', '1');
} else {
$php_properties['ini_set'] = array(
'fitness' => tra('ugly'),
'setting' => 'Disabled',
'message' => tra('ini_set is used in some places to accomodate for special needs of some Tiki features. Check disable_functions in your php.ini.')
);
}
// First things first
// If we don't have a DB-connection, some tests don't run
$s = extension_loaded('pdo_mysql');
if ($s) {
$php_properties['DB Driver'] = array(
'fitness' => tra('good'),
'setting' => 'PDO',
'message' => tra('The PDO extension is the suggested database driver/abstraction layer.')
);
} elseif ( $s = extension_loaded('mysqli') ) {
$php_properties['DB Driver'] = array(
'fitness' => tra('ugly'),
'setting' => 'MySQLi',
'message' => tra('You do not have the recommended PDO database driver/abstraction layer. You do have the MySQLi driver though, so we will to fall back to the AdoDB abstraction layer that is bundled with Tiki.')
);
} elseif ( extension_loaded('mysql') ) {
$php_properties['DB Driver'] = array(
'fitness' => tra('ugly'),
'setting' => 'MySQL',
'message' => tra('You do not have the recommended PDO database driver/abstraction layer. You do have the MySQL driver though, so we will to fall back to the AdoDB abstraction layer that is bundled with Tiki.')
);
} else {
$php_properties['DB Driver'] = array(
'fitness' => tra('bad'),
'setting' => 'Not available',
'message' => tra('You do not have any of the supported database drivers (PDO/mysqli/mysql) loaded. Tiki will not work.')
);
}
// Now connect to the DB and make all our connectivity methods work the same
$connection = false;
if ( $standalone && !$locked ) {
if ( empty($_POST['dbhost']) && !($php_properties['DB Driver']['setting'] == 'Not available') ) {
$render .= <<<DBC
<h2>Database credentials</h2>
Couldn't connect to database, please provide valid credentials.
<form method="post" action="{$_SERVER['REQUEST_URI']}">
<p><label for="dbhost">Database host</label>: <input type="text" id="dbhost" name="dbhost" value="localhost" /></p>
<p><label for="dbuser">Database username</label>: <input type="text" id="dbuser" name="dbuser" /></p>
<p><label for="dbpass">Database password</label>: <input type="password" id="dbpass" name="dbpass" /></p>
<p><input type="submit" class="btn btn-default btn-sm" value=" Connect " /></p>
</form>
DBC;
} else {
try {
switch ($php_properties['DB Driver']['setting']) {
case 'PDO':
// We don't do exception handling here to be PHP 4 compatible
$connection = new PDO('mysql:host='.$_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']);
/**
* @param $query
* @param $connection
* @return mixed
*/
function query($query, $connection)
{
$result = $connection->query($query);
$return = $result->fetchAll();
return($return);
}
break;
case 'MySQLi':
$error = false;
$connection = new mysqli($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']);
$error = mysqli_connect_error();
if ( !empty($error) ) {
$connection = false;
$render .= 'Couldn\'t connect to database: '.$error;
}
/**
* @param $query
* @param $connection
* @return array
*/
function query($query, $connection)
{
$result = $connection->query($query);
$return = array();
while ( $row = $result->fetch_assoc() ) {
$return[] = $row;
}
return($return);
}
break;
case 'MySQL':
$connection = mysql_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']);
if ( $connection === false ) {
$render .= 'Cannot connect to MySQL. Wrong credentials?';
}
/**
* @param $query
* @param string $connection
* @return array
*/
function query($query, $connection = '')
{
$result = mysql_query($query);
$return = array();
while ( $row = mysql_fetch_array($result) ) {
$return[] = $row;
}
return($return);
}
break;
}
} catch(Exception $e) {
$render .= 'Cannot connect to MySQL. Error: '.$e->getMessage();
}
}
} else {
/**
* @param $query
* @return array
*/
function query($query)
{
global $tikilib;
$result = $tikilib->query($query);
$return = array();
while ( $row = $result->fetchRow() ) {
$return[] = $row;
}
return($return);
}
}
// Basic Server environment
$server_information['Operating System'] = array(
'value' => PHP_OS,
);
if ( PHP_OS == 'Linux' && function_exists('exec') ) {
exec('lsb_release -d', $output, $retval);
if ( $retval == 0 ) {
$server_information['Release'] = array(
'value' => str_replace('Description:', '', $output[0])
);
# Check for FreeType fails without a font, i.e. standalone mode
# Using a URL as font source doesn't work on all PHP installs
# So let's try to gracefully fall back to some locally installed font at least on Linux
if (!file_exists($font)) {
$font = exec('find /usr/share/fonts/ -type f -name "*.ttf" | head -n 1', $output);
}
} else {
$server_information['Release'] = array(
'value' => tra('N/A')
);
}
}
$server_information['Web Server'] = array(
'value' => $_SERVER['SERVER_SOFTWARE']
);
$server_information['Server Signature']['value'] = !empty($_SERVER['SERVER_SIGNATURE']) ? $_SERVER['SERVER_SIGNATURE'] : 'off';
// Free disk space
if (function_exists('disk_free_space')) {
$bytes = @disk_free_space('.'); // this can fail on 32 bit systems with lots of disc space so suppress the possible warning
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
$class = min((int) log($bytes, $base), count($si_prefix) - 1);
$free_space = sprintf('%1.2f', $bytes / pow($base, $class)) . ' ' . $si_prefix[$class];
if ( $bytes === false ) {
$server_properties['Disk Space'] = array(
'fitness' => 'ugly',
'setting' => tra('Unable to detect'),
'message' => tra('Cannot determine the size of this disk drive.')
);
} else if ( $bytes < 200 * 1024 * 1024 ) {
$server_properties['Disk Space'] = array(
'fitness' => 'bad',
'setting' => $free_space,
'message' => tra('You have less than 200 megs of free disk space. Tiki will not fit on this disk drive.')
);
} elseif ( $bytes < 250 * 1024 * 1024 ) {
$server_properties['Disk Space'] = array(
'fitness' => 'ugly',
'setting' => $free_space,
'message' => tra('You have less than 250 megs of free disk space. This is quite tight. Tiki needs disk space for compiling templates and for uploading files.').' '.tra('When the disk runs full you will not be able to log into your Tiki any more.').' '.tra('We can not reliably check for quotas, so be warned that if your server makes use of them you might have less disk space available.')
);
} else {
$server_properties['Disk Space'] = array(
'fitness' => 'good',
'setting' => $free_space,
'message' => tra('You have more than 251 megs of free disk space. Tiki will run nicely, but you may run into issues when your site grows (e.g. file uploads)').' '.tra('When the disk runs full you will not be able to log into your Tiki any more.').' '.tra('We can not reliably check for quotas, so be warned that if your server makes use of them you might have less disk space available.')
);
}
} else {
$server_properties['Disk Space'] = array(
'fitness' => 'N/A',
'setting' => 'N/A',
'message' => tra('The PHP function disk_free_space is not available on your server, so we can\'t check for this.')
);
}
// PHP Version
if (version_compare(PHP_VERSION, '5.1.0', '<')) {
$php_properties['PHP version'] = array(
'fitness' => 'bad',
'setting' => phpversion(),
'message' => 'You can not run any supported versions of Tiki with this very old version of PHP. Please see http://doc.tiki.org/Requirements for details.'
);
} elseif (version_compare(PHP_VERSION, '5.2.0', '<')) {
$php_properties['PHP version'] = array(
'fitness' => tra('bad'),
'setting' => phpversion(),
'message' => 'You have a quite old version of PHP. You can run Tiki 6.x LTS but not later versions.'
);
} elseif (version_compare(PHP_VERSION, '5.3.0', '<')) {
$php_properties['PHP version'] = array(
'fitness' => tra('ugly'),
'setting' => phpversion(),
'message' => 'You have an old version of PHP. You can run Tiki 6.x LTS or 9.x LTS but not later versions.'
);
} elseif (version_compare(PHP_VERSION, '5.5.0', '<')) {
$php_properties['PHP version'] = array(
'fitness' => tra('ugly'),
'setting' => phpversion(),
'message' => 'You have a somewhat old version of PHP. You can run Tiki 6.x LTS, 9.x LTS or 12.x LTS but not later versions.'
);
} else {
$php_properties['PHP version'] = array(
'fitness' => tra('good'),
'setting' => phpversion(),
'message' => 'You have a recent version of PHP and you can run any supported versions of Tiki.'
);
}
// PHP Server API (SAPI)
$s = php_sapi_name();
if (substr($s, 0, 3) == 'cgi') {
$php_properties['PHP Server API'] = array(
'fitness' => tra('info'),
'setting' => $s,
'message' => tra('You are running PHP as CGI. Feel free to use a threaded Apache MPM to increase performance.')
);
} elseif (substr($s, 0, 3) == 'fpm') {
$php_properties['PHP Server API'] = array(
'fitness' => tra('info'),
'setting' => $s,
'message' => tra('You are running PHP using FPM (Fastcgi Process Manager). Feel free to use a threaded Apache MPM to increase performance.')
);
} else {
$php_properties['PHP Server API'] = array(
'fitness' => tra('info'),
'setting' => $s,
'message' => tra('You are not running PHP as CGI. Be aware that PHP is not thread-safe and you should not use a threaded Apache MPM (like worker).')
);
}
// ByteCode Cache
if ( function_exists('apc_sma_info') && ini_get('apc.enabled') ) {
$php_properties['ByteCode Cache'] = array(
'fitness' => tra('good'),
'setting' => 'APC',
'message' => tra('You are using APC as your ByteCode Cache which increases performance, if correctly configured. See Admin->Performance in your Tiki for more details.')
);
} elseif ( function_exists('xcache_info') && ( ini_get('xcache.cacher') == '1' || ini_get('xcache.cacher') == 'On' ) ) {
$php_properties['ByteCode Cache'] = array(
'fitness' => tra('good'),
'setting' => 'xCache',
'message' => tra('You are using xCache as your ByteCode Cache which increases performance, if correctly configured. See Admin->Performance in your Tiki for more details.')
);
} elseif ( function_exists('opcache_get_configuration') && ( ini_get('opcache.enable') == 1 || ini_get('opcache.enable') == '1') ) {
$php_properties['ByteCode Cache'] = array(
'fitness' => tra('good'),
'setting' => 'OPcache',
'message' => tra('You are using OPcache as your ByteCode Cache which increases performance, if correctly configured. See Admin->Performance in your Tiki for more details.')
);
} elseif ( function_exists('wincache_ocache_fileinfo') && ( ini_get('wincache.ocenabled') == '1') ) {
$sapi_type = php_sapi_name();
if ($sapi_type == 'cgi-fcgi') {
$php_properties['ByteCode Cache'] = array(
'fitness' => tra('good'),
'setting' => 'WinCache',
'message' => tra('You are using WinCache as your ByteCode Cache which increases performance, if correctly configured. See Admin->Performance in your Tiki for more details.')
);
} else {
$php_properties['ByteCode Cache'] = array(
'fitness' => tra('ugly'),
'setting' => 'WinCache',
'message' => tra('You are using WinCache as your ByteCode Cache, but you do not seem to use the required CGI/FastCGI server API.')
);
}
} else {
if (check_isIIS()) {
$php_properties['ByteCode Cache'] = array(
'fitness' => tra('info'),
'setting' => 'N/A',
'message' => tra('You are using neither APC, WinCache nor xCache as your ByteCode Cache which would increase performance, if correctly configured. See Admin->Performance in your Tiki for more details.')
);
} else {
$php_properties['ByteCode Cache'] = array(
'fitness' => tra('info'),
'setting' => 'N/A',
'message' => tra('You are using neither APC, nor xCache, nor OPcache as your ByteCode Cache which would increase performance, if correctly configured. See Admin->Performance in your Tiki for more details.')
);
}
}
// memory_limit
$memory_limit = ini_get('memory_limit');
$s = trim($memory_limit);
$last = strtolower($s{strlen($s)-1});
switch ( $last ) {
case 'g': $s *= 1024;
case 'm': $s *= 1024;
case 'k': $s *= 1024;
}
if ($s >= 160 * 1024 * 1024) {
$php_properties['memory_limit'] = array(
'fitness' => tra('good'),
'setting' => $memory_limit,
'message' => tra('Your memory_limit is at').' '.$memory_limit.'. '.tra('This is known to behave well even for bigger sites.')
);
} elseif ( $s < 160 * 1024 * 1024 && $s > 127 * 1024 * 1024 ) {
$php_properties['memory_limit'] = array(
'fitness' => tra('ugly') ,
'setting' => $memory_limit,
'message' => tra('Your memory_limit is at').' '.$memory_limit.'. '.tra('This will normally work, but you might run into problems when your site grows.')
);
} elseif ( $s == -1 ) {
$php_properties['memory_limit'] = array(
'fitness' => tra('ugly') ,
'setting' => $memory_limit,
'message' => tra("Your memory_limit is unlimited. This is not necessarily bad, but it's a good idea to limit this on productions servers in order to eliminate unexpectedly greedy scripts.")
);
} else {
$php_properties['memory_limit'] = array(
'fitness' => tra('bad'),
'setting' => $memory_limit,
'message' => tra('Your memory_limit is at').' '.$memory_limit.'. '.tra('This is known to cause issues! You should raise your memory_limit to at least 128M, which is the default of PHP.')
);
}
// session.save_handler
$s = ini_get('session.save_handler');
if ($s != 'files') {
$php_properties['session.save_handler'] = array(
'fitness' => tra('bad'),
'setting' => $s,
'message' => tra('Your session.save_handler must be set to \'files\'.')
);
} else {
$php_properties['session.save_handler'] = array(
'fitness' => tra('good'),
'setting' => $s,
'message' => tra('Well set! the default setting of \'files\' is needed for Tiki.')
);
}
// session.save_handler
$s = ini_get('session.save_path');
if (empty($s) || ! is_writable($s)) {
$php_properties['session.save_path'] = array(
'fitness' => tra('bad'),
'setting' => $s,
'message' => tra('Your session.save_path must writable.')
);
} else {
$php_properties['session.save_path'] = array(
'fitness' => tra('good'),
'setting' => $s,
'message' => tra('Your session.save_path is writable.')
);
}
// test session work
session_start();
if (empty($_SESSION['tiki-check'])) {
$php_properties['session'] = array(
'fitness' => tra('ugly'),
'setting' => tra('empty'),
'message' => tra('Your session is empty, try reloading the page and if you see this message again you may have a problem with your server setup.')
);
$_SESSION['tiki-check'] = 1;
} else {
$php_properties['session'] = array(
'fitness' => tra('good'),
'setting' => 'ok',
'message' => tra('Your appears to work.')
);
}
// zlib.output_compression
$s = ini_get('zlib.output_compression');
if ($s) {
$php_properties['zlib.output_compression'] = array(
'fitness' => tra('info'),
'setting' => 'On',
'message' => tra('You have zlib output compression turned on. This saves bandwidth. Turning it off would in turn reduce CPU usage. Choose your poison.')
);
} else {
$php_properties['zlib.output_compression'] = array(
'fitness' => tra('info'),
'setting' => 'Off',
'message' => tra('You have zlib output compression turned off. This reduces CPU usage. Turning it on would in turn save bandwidth. Choose your poison.')
);
}
// register globals
$s = ini_get('register_globals');
if ($s) {
$php_properties['register_globals'] = array(
'fitness' => tra('bad'),
'setting' => 'On',
'message' => tra('register_globals should be off by default. See the PHP manual for details.')
);
} else {
$php_properties['register_globals'] = array(
'fitness' => tra('good'),
'setting' => 'Off',
'message' => tra('Well set! And you are future proof also as register_globals is deprecated.')
);
}
// safe mode
$s = ini_get('safe_mode');
if ($s) {
$php_properties['safe_mode'] = array(
'fitness' => tra('bad'),
'setting' => 'On',
'message' => tra('safe_mode is deprecated and should be off by default. See the <a href="http://www.php.net/manual/de/features.safe-mode.php">PHP manual</a> for details.')
);
} else {
$php_properties['safe_mode'] = array(
'fitness' => tra('good'),
'setting' => 'Off',
'message' => tra('Well set! And you are future proof also as safe_mode is deprecated.')
);
}
// magic_quotes_gpc
$s = ini_get('magic_quotes_gpc');
if ($s) {
$php_properties['magic_quotes_gpc'] = array(
'fitness' => tra('bad'),
'setting' => 'On',
'message' => tra('Some features like assigning perms to a group with a name containing a quote will not work with this being on. magic_quotes_gpc is also deprecated and should be off by default. See the PHP manual for details. You may experience weird behaviour of your Tiki.')
);
} else {
$php_properties['magic_quotes_gpc'] = array(
'fitness' => tra('good'),
'setting' => 'Off',
'message' => tra('Well set! Some features like assigning perms to a group with a name containing a quote will not work with this being on. And you are future proof also as magic_quotes_gpc is deprecated.')
);
}
// default_charset
$s = ini_get('default_charset');
if ( strtolower($s) == 'utf-8' ) {
$php_properties['default_charset'] = array(
'fitness' => tra('good'),
'setting' => $s,
'message' => tra('Well set! Tiki is fully UTF-8 and so should your installation be.')
);
} else {
$php_properties['default_charset'] = array(
'fitness' => tra('ugly'),
'setting' => $s,
'message' => tra('default_charset should be UTF-8 as Tiki is fully UTF-8. Please check your php.ini.')
);
}
// date.timezone
$s = ini_get('date.timezone');
if ( empty($s) ) {
$php_properties['date.timezone'] = array(
'fitness' => tra('ugly'),
'setting' => $s,
'message' => tra('You have no time zone set! While there are a lot of fallbacks in PHP to determine the time zone, the only reliable solution is to set it explicitly in php.ini! Please check the value of date.timezone in php.ini.')
);
} else {
$php_properties['date.timezone'] = array(
'fitness' => tra('good'),
'setting' => $s,
'message' => tra('Well done! Having a time zone set protects you from many weird errors.')
);
}
// file_uploads
$s = ini_get('file_uploads');
if ($s) {
$php_properties['file_uploads'] = array(
'fitness' => tra('good'),
'setting' => 'On',
'message' => tra('You can upload files to your Tiki.')
);
} else {
$php_properties['file_uploads'] = array(
'fitness' => tra('bad'),
'setting' => 'Off',
'message' => tra('You will not be able to upload any files to your Tiki.')
);
}
// max_execution_time
$s = ini_get('max_execution_time');
if ( $s >= 30 && $s <= 90 ) {
$php_properties['max_execution_time'] = array(
'fitness' => tra('good'),
'setting' => $s.'s',
'message' => tra('Your max_execution_time is at').' '.$s.'. '.tra('This is a good value for production sites. If you experience timeouts (such as when performing admin functions) you may need to increase this nevertheless.')
);
} elseif ( $s == -1 || $s == 0 ) {
$php_properties['max_execution_time'] = array(
'fitness' => tra('ugly'),
'setting' => $s.'s',
'message' => tra('Your max_execution_time is unlimited.').' '.tra('This is not necessarily bad, but it\'s a good idea to limit this time on productions servers in order to eliminate unexpectedly long running scripts.')
);
} elseif ( $s > 90 ) {
$php_properties['max_execution_time'] = array(
'fitness' => tra('ugly'),
'setting' => $s.'s',
'message' => tra('Your max_execution_time is at').' '.$s.'. '.tra('This is not necessarily bad, but it\'s a good idea to limit this time on productions servers in order to eliminate unexpectedly long running scripts.')
);
} else {
$php_properties['max_execution_time'] = array(
'fitness' => tra('bad'),
'setting' => $s.'s',
'message' => tra('Your max_execution_time is at').' '.$s.'. '.tra('It is likely that some scripts, e.g. admin functions will not finish in this time! You should raise your max_execution_time to at least 30s.')
);
}
// max_input_time
$s = ini_get('max_input_time');
if ( $s >= 30 && $s <= 90 ) {
$php_properties['max_input_time'] = array(
'fitness' => tra('good'),
'setting' => $s.'s',
'message' => tra('Your max_input_time is at').' '.$s.'. '.tra('This is a good value for production sites. If you experience timeouts (such as when performing admin functions) you may need to increase this nevertheless.')
);
} elseif ( $s == -1 || $s == 0 ) {
$php_properties['max_input_time'] = array(
'fitness' => tra('ugly'),
'setting' => $s.'s',
'message' => tra('Your max_input_time is unlimited.').' '.tra('This is not necessarily bad, but it\'s a good idea to limit this time on productions servers in order to eliminate unexpectedly long running scripts.')
);
} elseif ( $s > 90 ) {
$php_properties['max_input_time'] = array(
'fitness' => tra('ugly'),
'setting' => $s.'s',
'message' => tra('Your max_input_time is at').' '.$s.'. '.tra('This is not necessarily bad, but it\'s a good idea to limit this time on productions servers in order to eliminate unexpectedly long running scripts.')
);
} else {
$php_properties['max_input_time'] = array(
'fitness' => tra('bad'),
'setting' => $s.'s',
'message' => tra('Your max_input_time is at').' '.$s.'. '.tra('It is likely that some scripts, e.g. admin functions will not finish in this time! You should raise your max_input_time to at least 30 seconds.')
);
}
// upload_max_filesize
$upload_max_filesize = ini_get('upload_max_filesize');
$s = trim($upload_max_filesize);
$last = strtolower($s{strlen($s)-1});
switch ( $last ) {
case 'g': $s *= 1024;
case 'm': $s *= 1024;
case 'k': $s *= 1024;
}
if ($s >= 8 * 1024 * 1024) {
$php_properties['upload_max_filesize'] = array(
'fitness' => tra('good'),
'setting' => $upload_max_filesize,
'message' => tra('Your upload_max_filesize is at').' '.$upload_max_filesize.'. '.tra('You can upload quite big files, but keep in mind to set your script timeouts accordingly.')
);
} else if ($s == 0) {
$php_properties['upload_max_filesize'] = array(
'fitness' => tra('ugly'),
'setting' => $upload_max_filesize,
'message' => tra('Your upload_max_filesize is at').' '.$upload_max_filesize.'. '.tra('Upload size is unlimited and this not a wise setting. A user could mistakenly upload a gigantic file which could fill up your disk. You should set this value to your realistic needs.')
);
} else {
$php_properties['upload_max_filesize'] = array(
'fitness' => tra('ugly'),
'setting' => $upload_max_filesize,
'message' => tra('Your upload_max_filesize is at').' '.$upload_max_filesize.'. '.tra('Nothing wrong with that, but some users might want to upload something bigger.')
);
}
// post_max_size
$post_max_size = ini_get('post_max_size');
$s = trim($post_max_size);
$last = strtolower($s{strlen($s)-1});
switch ( $last ) {
case 'g': $s *= 1024;
case 'm': $s *= 1024;
case 'k': $s *= 1024;
}
if ($s >= 8 * 1024 * 1024) {
$php_properties['post_max_size'] = array(
'fitness' => tra('good'),
'setting' => $post_max_size,
'message' => tra('Your post_max_size is at').' '.$post_max_size.'. '.tra('You can upload quite big files, but keep in mind to set your script timeouts accordingly.')
);
} else {
$php_properties['post_max_size'] = array(
'fitness' => tra('ugly'),
'setting' => $post_max_size,
'message' => tra('Your post_max_size is at').' '.$post_max_size.'. '.tra('Nothing wrong with that, but some users might want to upload something bigger.')
);
}
// PHP Extensions
// fileinfo
$s = extension_loaded('fileinfo');
if ($s) {
$php_properties['fileinfo'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra("The fileinfo extension is needed for the 'Validate uploaded file content' preference.")
);
} else {
$php_properties['fileinfo'] = array(
'fitness' => tra('ugly'),
'setting' => 'Not available',
'message' => tra("The fileinfo extension is needed for the 'Validate uploaded file content' preference.")
);
}
// intl
$s = extension_loaded('intl');
if ($s) {
$php_properties['intl'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra("intl extension is required for Tiki 15 onwards.")
);
} else {
$php_properties['intl'] = array(
'fitness' => tra('bad'),
'setting' => 'Not available',
'message' => tra("intl extension is required for Tiki 15 onwards.")
);
}
// GD
$s = extension_loaded('gd');
if ( $s && function_exists('gd_info') ) {
$gd_info = gd_info();
$im = $ft = null;
if (function_exists('imagecreate')) {
$im = @imagecreate(110, 20);
}
if (function_exists('imageftbbox')) {
$ft = @imageftbbox(12, 0, $font, 'test');
}
if ($im && $ft) {
$php_properties['gd'] = array(
'fitness' => tra('good'),
'setting' => $gd_info['GD Version'],
'message' => tra('The GD extension is needed for manipulation of images, e.g. also for CAPTCHAs.')
);
imagedestroy($im);
} else if ($im) {
$php_properties['gd'] = array(
'fitness' => tra('ugly'),
'setting' => $gd_info['GD Version'],
'message' => tra('The GD extension is loaded, and Tiki can create images, but the FreeType extension is needed for CAPTCHA text generation.')
);
imagedestroy($im);
} else {
$php_properties['gd'] = array(
'fitness' => tra('ugly'),
'setting' => 'Dysfunctional',
'message' => tra('The GD extension is loaded, but Tiki is unable to create images. Please check your GD library configuration.')
);
}
} else {
$php_properties['gd'] = array(
'fitness' => tra('bad'),
'setting' => 'Not available',
'message' => tra('The GD extension is needed for manipulation of images, e.g. also for CAPTCHAs.')
);
}
// Image Magick
$s = class_exists('Imagick');
if ( $s ) {
$image = new Imagick();
$image->newImage(100, 100, new ImagickPixel('red'));
if ( $image ) {
$php_properties['Image Magick'] = array(
'fitness' => tra('good'),
'setting' => 'Available',
'message' => tra('ImageMagick is used as a fallback in case that GD is not available.')
);
$image->destroy();
} else {
$php_properties['Image Magick'] = array(
'fitness' => tra('ugly'),
'setting' => 'Dysfunctional',
'message' => tra('ImageMagick is used as a fallback in case that GD is not available.').tra('ImageMagick is available, but unable to create images. Please check your ImageMagick configuration.')
);
}
} else {
$php_properties['Image Magick'] = array(
'fitness' => tra('info'),
'setting' => 'Not Available',
'message' => tra('ImageMagick is used as a fallback in case that GD is not available.')
);
}
// mbstring
$s = extension_loaded('mbstring');
if ($s) {
$func_overload = ini_get('mbstring.func_overload');
if ($func_overload == 0 && function_exists('mb_split')) {
$php_properties['mbstring'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra('The mbstring extension is needed for an UTF-8 compatible lower case filter in the admin search for example.')
);
} elseif ($func_overload != 0) {
$php_properties['mbstring'] = array(
'fitness' => tra('ugly'),
'setting' => 'Badly configured',
'message' => tra('The mbstring extension is loaded, but mbstring.func_overload = '.' '.$func_overload.'.'.' '.'Tiki only works with mbsring.func_overload = 0. Please check your php.ini.')
);
} else {
$php_properties['mbstring'] = array(
'fitness' => tra('bad'),
'setting' => 'Badly installed',
'message' => tra('The mbstring extension is loaded, but missing important functions as for example mb_split(). You need to reinstall it with --enable-mbregex or ask your hoster do do it.')
);
}
} else {
$php_properties['mbstring'] = array(
'fitness' => tra('bad'),
'setting' => 'Not available',
'message' => tra('The mbstring extension is needed for an UTF-8 compatible lower case filter.')
);
}
// calendar
$s = extension_loaded('calendar');
if ($s) {
$php_properties['calendar'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra('calendar extension is needed by Tiki.')
);
} else {
$php_properties['calendar'] = array(
'fitness' => tra('bad'),
'setting' => 'Not available',
'message' => tra('calendar extension is needed by Tiki.').' '.tra('You will not be able to use the calendar feature of Tiki.')
);
}
// ctype
$s = extension_loaded('ctype');
if ($s) {
$php_properties['ctype'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra('ctype extension is needed by Tiki.')
);
} else {
$php_properties['ctype'] = array(
'fitness' => tra('bad'),
'setting' => 'Not available',
'message' => tra('ctype extension is needed by Tiki.')
);
}
// libxml
$s = extension_loaded('libxml');
if ($s) {
$php_properties['libxml'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra('This extension is needed for WebDAV and the dom extension (see below).')
);
} else {
$php_properties['libxml'] = array(
'fitness' => tra('bad'),
'setting' => 'Not available',
'message' => tra('This extension is needed for WebDAV and the dom extension (see below).')
);
}
// dom (depends on libxml)
$s = extension_loaded('dom');
if ($s) {
$php_properties['dom'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra('This extension is needed for many features such as:') . '<br>' .
tra('bigbluebutton, machine translation, SCORM & meta-data in file galleries, wiki importers, custom search, Kaltura and others.')
);
} else {
$php_properties['dom'] = array(
'fitness' => tra('bad'),
'setting' => 'Not available',
'message' => tra('This extension is needed for many features such as:') . '<br>' .
tra('bigbluebutton, machine translation, SCORM & meta-data in file galleries, wiki importers, custom search, Kaltura and others.')
);
}
$s = extension_loaded('ldap');
if ($s) {
$php_properties['LDAP'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra('This extension is needed to connect your Tiki to an LDAP server. More info at: http://doc.tiki.org/LDAP ')
);
} else {
$php_properties['LDAP'] = array(
'fitness' => tra('info'),
'setting' => 'Not available',
'message' => tra('You will not be able to connect your Tiki to an LDAP server as the needed PHP extension is missing. More info at: http://doc.tiki.org/LDAP')
);
}
$s = extension_loaded('memcache');
if ($s) {
$php_properties['memcache'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra('This extension can be used to speed up your Tiki by saving sessions as well as wiki and forum data on a memcached server.')
);
} else {
$php_properties['memcache'] = array(
'fitness' => tra('info'),
'setting' => 'Not available',
'message' => tra('This extension can be used to speed up your Tiki by saving sessions as well as wiki and forum data on a memcached server.')
);
}
$s = extension_loaded('ssh2');
if ($s) {
$php_properties['SSH2'] = array(
'fitness' => tra('good'),
'setting' => 'Loaded',
'message' => tra('This extension is needed for the show.tiki.org tracker field type.')
);
} else {
$php_properties['SSH2'] = array(
'fitness' => tra('info'),