Menu

[r22485]: / branches / groupoffice-6.1 / www / install / gotest.php  Maximize  Restore  History

Download this file

966 lines (761 with data), 28.8 kB

  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
<?php
/**
* Copyright Intermesh
*
* This file is part of Group-Office. You should have received a copy of the
* Group-Office license along with Group-Office. See the file /LICENSE.TXT
*
* If you have questions write an e-mail to info@intermesh.nl
*
* @copyright Copyright Intermesh
* @version $Id$
* @author Merijn Schering <mschering@intermesh.nl>
*/
$product_name = class_exists('GO') ? \GO::config()->product_name : 'Group-Office';
/**
* Format a size to a human readable format.
*
* @param int $size The size in bytes
* @param int $decimals Number of decimals to display
* @access public
* @return string
*/
if(!function_exists('format_size'))
{
function format_size($size, $decimals = 1) {
switch ($size) {
case ($size > 1073741824) :
$size = number_format($size / 1073741824, $decimals, '.', ' ');
$size .= " GB";
break;
case ($size > 1048576) :
$size = number_format($size / 1048576, $decimals, '.', ' ');
$size .= " MB";
break;
case ($size > 1024) :
$size = number_format($size / 1024, $decimals, '.', ' ');
$size .= " KB";
break;
default :
number_format($size, $decimals, '.', ' ');
$size .= " bytes";
break;
}
return $size;
}
}
function ini_is_enabled($name){
$v = ini_get($name);
return $v==1 || strtolower($v)=='on';
}
function ini_return_bytes($val) {
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
switch($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024*1024*1024;
case 'm':
$val *= 1024*1024;
case 'k':
$val *= 1024;
}
return $val;
}
function test_system(){
global $product_name;
$tests=array();
$test['name']='Operating System';
$test['showSuccessFeedback'] = false;
$test['pass']=strtolower(PHP_OS) === 'linux';
$test['feedback']='Warning Your OS is "'.PHP_OS.'" The recommended OS is Linux. Other systems may work but are not officially supported';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Web server';
$test['showSuccessFeedback'] = false;
$test['pass']=stripos($_SERVER["SERVER_SOFTWARE"], 'apache') !== false;
$test['feedback']="Warning, your web server ".$_SERVER["SERVER_SOFTWARE"]." is not officially supported";
$test['fatal']=false;
$tests[]=$test;
$test['name']='PHP SAPI mode';
$test['showSuccessFeedback'] = false;
$test['pass']=php_sapi_name() != 'apache';
$test['feedback']="Warning: PHP running in '".php_sapi_name()."' mode. This works fine but you need some additional rewrite rules for setting up activesync and CalDAV. See https://www.group-office.com/wiki/Z-push_2";
$test['fatal']=false;
$tests[]=$test;
$test['name']='Expose PHP';
$test['showSuccessFeedback'] = false;
$test['pass']=!ini_is_enabled('expose_php');
$test['feedback']='Warning. You should set expose php to off to prevent version information to be public';
$test['fatal']=false;
$tests[]=$test;
$test['name']='PHP version';
$test['showSuccessFeedback'] = false;
$test['pass']=function_exists('version_compare') && version_compare( phpversion(), "5.3", ">=");
$test['feedback']='Fatal error: Your PHP version is too old to run '.$product_name.'. PHP 5.3 or higher is required';
$test['fatal']=true;
// $tests[]=$test;
// $test['name']='Session Cookies';
// $test['pass']=ini_get('session.cookie_httponly')!=1;
// $test['feedback']='Warning: session.cookie_httponly is set to 1. We recommend setting it to 0 because this can give problems with file uploads.';
// $test['fatal']=false;
$tests[]=$test;
$test['name']='Output buffering';
$test['showSuccessFeedback'] = false;
$test['pass']=!ini_is_enabled('output_buffering');
$test['feedback']='Warning: output_buffering is enabled. This will increase memory usage might cause memory errors';
$test['fatal']=false;
$tests[]=$test;
//echo ini_get('mbstring.func_overload');
$test['name']='mbstring function overloading';
$test['showSuccessFeedback'] = false;
$test['pass']=ini_get('mbstring.func_overload')<1;
$test['feedback']='Warning: mbstring.func_overload is enabled in php.ini. Encrypting e-mail passwords will be disabled with this feature enabled. Disabling this feature is recommended';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Magic quotes setting';
$test['showSuccessFeedback'] = false;
$test['pass']=!get_magic_quotes_gpc();
$test['feedback']='Warning: magic_quotes_gpc is enabled. You will get better performance if you disable this setting.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='MySQL support';
$test['showSuccessFeedback'] = false;
$test['pass']=function_exists('mysqli_connect');
$test['feedback']='Fatal error: The improved MySQL (MySQLi) extension is required. So is the MySQL server.';
$test['fatal']=true;
$tests[]=$test;
$test['name']='PDO support';
$test['showSuccessFeedback'] = false;
$test['pass']= class_exists('PDO') && extension_loaded('pdo_mysql');
$test['feedback']='Fatal error: The PHP PDO extension with MySQL support is required.';
$test['fatal']=true;
$tests[]=$test;
$test['name']='Mcrypt support';
$test['showSuccessFeedback'] = false;
$test['pass']=extension_loaded('mcrypt');
$test['feedback']='Warning: No Mcrypt extension for PHP found. Without mcrypt Group-Office has to save e-mail passwords in plain text.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='GD support';
$test['showSuccessFeedback'] = false;
$test['pass']=function_exists('getimagesize');
$test['feedback']='Warning: No GD extension for PHP found. Without GD Group-Office can\'t create thumbnails.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='pspell support';
$test['showSuccessFeedback'] = false;
$test['pass']=function_exists('pspell_new');
$test['feedback']='Warning: No pspell extension for PHP found. The spellchecker in the e-mail composer won\'t work.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='File upload support';
$test['showSuccessFeedback'] = false;
$test['pass']=ini_is_enabled('file_uploads');
$test['feedback']='Warning: File uploads are disabled. Please set file_uploads=On in php.ini.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='File upload size';
$test['showSuccessFeedback'] = false;
$test['pass']= ini_return_bytes(ini_get('upload_max_filesize')) >= 20 * 1024 * 1024;
$test['feedback']='Warning: The upload_max_filesize php.ini value is lower than 20MB ('.ini_get('upload_max_filesize').'). We recommend to settings this to at least 20MB';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Safe mode';
$test['showSuccessFeedback'] = false;
$test['pass']=!ini_is_enabled('safe_mode');
$test['feedback']='Warning: safe_mode is enabled in php.ini. This may cause trouble with the filesystem module and Synchronization. If you can please set safe_mode=Off in php.ini';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Open base_dir';
$test['showSuccessFeedback'] = false;
$test['pass']=ini_get('open_basedir')=='';
$test['feedback']='Warning: open_basedir is enabled. This may cause trouble with the filesystem module and Synchronization.';
$test['fatal']=false;
$tests[]=$test;
// $test['name']='URL fopen';
// $test['pass']=ini_is_enabled('allow_url_fopen');
// $test['feedback']='Warning: allow_url_fopen is disabled in php.ini. RSS feeds on the start page will not work.';
// $test['fatal']=false;
// $tests[]=$test;
$test['name']='Register globals';
$test['showSuccessFeedback'] = false;
$test['pass']=!ini_is_enabled('register_globals');
$test['feedback']='Warning: register_globals is enabled in php.ini. This causes a problem in the spell checker and probably in some other parts. It\'s recommended to disable this.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='zlib compression';
$test['showSuccessFeedback'] = false;
$test['pass']=extension_loaded('zlib');
$test['feedback']='Warning: No zlib output compression support. You can increase the initial load time by installing this php extension.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Calendar functions';
$test['showSuccessFeedback'] = false;
$test['pass']=function_exists('easter_date');
$test['feedback']='Warning: Calendar functions not available. The '.$product_name.' calendar won\'t be able to generate all holidays for you. Please compile PHP with --enable-calendar.';
$test['fatal']=false;
$memory_limit = return_bytes(ini_get('memory_limit'));
$tests[]=$test;
$test['name']='Memory limit';
$test['showSuccessFeedback'] = false;
// $test['pass']=$memory_limit>=64*1024*1024;
$test['pass']=($memory_limit<=0 || $memory_limit>=64*1024*1024);
$test['feedback']='Warning: Your memory limit setting ('.format_size($memory_limit).') is less than 64MB. It\'s recommended to allow at least 64 MB.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Error logging';
$test['showSuccessFeedback'] = false;
$test['pass']=ini_is_enabled('log_errors');
$test['feedback']='Warning: PHP error logging is disabled in php.ini. It\'s recommended that this feature is enabled in a production environment.';
$test['fatal']=false;
/*$tests[]=$test;
$test['name']='Error display';
$test['pass']=ini_get('display_errors')!='1';
$test['feedback']='Warning: PHP error display is enabled in php.ini. It\'s recommended that this feature is disabled because it can cause unnessecary interface crashes.';
$test['fatal']=false;*/
$tests[]=$test;
$test['name']='libwbxml';
$test['showSuccessFeedback'] = false;
if(class_exists('GO'))
{
$wbxml2xml = whereis('wbxml2xml') ? whereis('wbxml2xml') : \GO::config()->cmd_wbxml2xml;
$xml2wbxml = whereis('xml2wbxml') ? whereis('xml2wbxml') : \GO::config()->cmd_xml2wbxml;
}else
{
$wbxml2xml = whereis('wbxml2xml') ? whereis('wbxml2xml') : '/usr/bin/wbxml2xml';
$xml2wbxml = whereis('xml2wbxml') ? whereis('xml2wbxml') : '/usr/bin/xml2wbxml';
}
$test['pass']=@is_executable($wbxml2xml) && @is_executable($xml2wbxml);
$test['feedback']='Warning: libwbxml2 is not installed. SyncML sync will not work!';
$test['fatal']=false;
$tests[]=$test;
$test['name']='DOM functions';
$test['showSuccessFeedback'] = false;
$test['pass']=class_exists('DOMDocument', false);
$test['feedback']='Warning: DOM functions are not installed. Synchronization with SyncML will not work. Install php-xml';
$test['fatal']=false;
$tests[]=$test;
$test['name']='MultiByte string functions';
$test['pass']=function_exists('mb_detect_encoding');
$test['feedback']='Warning: php-mbstring is not installed. Problems with non-ascii characters in e-mails and filenames might occur.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='TAR Compression';
$test['showSuccessFeedback'] = false;
if(class_exists('GO'))
{
$tar = whereis('tar') ? whereis('tar') : \GO::config()->cmd_tar;
}else
{
$tar = whereis('tar') ? whereis('tar') : '/bin/tar';
}
$test['pass']=@is_executable($tar);
$test['feedback']='Warning: tar is not installed or not executable.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='ZIP Compression';
$test['showSuccessFeedback'] = false;
if(class_exists('GO'))
{
$zip = whereis('zip') ? whereis('zip') : \GO::config()->cmd_zip;
}else
{
$zip = whereis('zip') ? whereis('zip') : '/usr/bin/zip';
}
$test['pass']=@is_executable($zip);
$test['feedback']='Warning: zip is not installed or not executable. Unpacking zip archives and using document templates for Microsoft Word and Open-Office.org won\'t be possible.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='TNEF';
$test['showSuccessFeedback'] = false;
if(class_exists('GO'))
{
$tnef = whereis('tnef') ? whereis('tnef') : \GO::config()->cmd_tnef;
}else
{
$tnef = whereis('tnef') ? whereis('tnef') : '/usr/bin/tnef';
}
$test['pass']=@is_executable($tnef);
$test['feedback']='Warning: tnef is not installed or not executable. you can\'t view winmail.dat attachments in the email module.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Ioncube enabled';
$test['pass']=$ioncubeWorks = ioncube_tester();
$test['feedback']='Warning: Ioncube is not installed. The professional modules will not be enabled.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Ioncube version check';
$testResultArray = ioncube_version_tester();
$test['showSuccessFeedback'] = true;
$test['pass']= ($testResultArray['status'] == 'OK') ? true : false;
$test['feedback']= $testResultArray['problem'].(!empty($testResultArray['problem']) ? ' - ' : '').$testResultArray['solution'];
$test['fatal']=false;
$tests[]=$test;
$test['name']='JSON functions';
$test['showSuccessFeedback'] = false;
$test['pass']=function_exists('json_encode');
$test['feedback']='Fatal error: json_encode and json_decode functions are not available. Try apt-get install php5-json on Debian or Ubuntu.';
$test['fatal']=true;
$tests[]=$test;
$ze1compat=ini_get('zend.ze1_compatibility_mode');
$test['name']='zend.ze1_compatibility_mode';
$test['showSuccessFeedback'] = false;
$test['pass']=empty($ze1compat);
$test['feedback']='Fatal error: zend.ze1_compatibility_mode is enabled. '.$product_name.' can\'t run with this setting enabled';
$test['fatal']=true;
$tests[]=$test;
$url = "http".(!empty($_SERVER['HTTPS'])?"s":"")."://".$_SERVER['HTTP_HOST'];
$headers = @get_headers($url.'/caldav');
$test['name']='CalDAV alias';
$test['showSuccessFeedback'] = false;
$test['pass']=$headers && (strpos($headers[0], '401')!==false || strpos($headers[0], '200')!==false);
$test['feedback']="Note: The alias /caldav was not detected. Please create: Alias /caldav /groupoffice/modules/caldav/calendar.php.";
$test['fatal']=false;
$tests[]=$test;
$headers = @get_headers($url.'/.well-known/caldav');
$test['name']='CalDAV autodiscovery';
$test['showSuccessFeedback'] = false;
$test['pass']=$headers && (strpos($headers[0], '301')!==false|| strpos($headers[0], '200')!==false);
$test['feedback']="Note: The redirect /.well-known/caldav was not detected. Please create a redirect: Redirect 301 /.well-known/caldav /caldav";
$test['fatal']=false;
$tests[]=$test;
$headers = @get_headers($url.'/carddav');
$test['name']='CardDAV alias';
$test['showSuccessFeedback'] = false;
$test['pass']=$headers && (strpos($headers[0], '401')!==false || strpos($headers[0], '200')!==false);;
$test['feedback']="Note: The alias /carddav was not detected. Please create: Alias /carddav /groupoffice/modules/carddav/addressbook.php.";
$test['fatal']=false;
$tests[]=$test;
$headers = @get_headers($url.'/.well-known/carddav');
$test['name']='CardDAV autodiscovery';
$test['showSuccessFeedback'] = false;
$test['pass']=$headers && (strpos($headers[0], '301')!==false || strpos($headers[0], '200')!==false);
$test['feedback']="Note: The redirect /.well-known/carddav was not detected. Please create a redirect: Redirect 301 /.well-known/carddav /carddav";
$test['fatal']=false;
$tests[]=$test;
$headers = @get_headers($url.'/Microsoft-Server-ActiveSync');
// var_dump($headers);
$test['name']='Microsoft-Server-ActiveSync alias';
$test['showSuccessFeedback'] = false;
$test['pass']=$headers && (strpos($headers[0], '401')!==false || strpos($headers[0], '200')!==false);
$test['feedback']="Note: The alias /Microsoft-Server-ActiveSync was not detected. Please create: Alias /Microsoft-Server-ActiveSync /groupoffice/modules/z-push/index.php.";
$test['fatal']=false;
$tests[]=$test;
$test['name']='Shared Memory Functions';
$test['showSuccessFeedback'] = false;
$test['pass']= function_exists('sem_get') && function_exists('shm_attach') && function_exists('sem_acquire') && function_exists('shm_get_var');
$test['feedback']= "InterProcessData::InitSharedMem(): PHP libraries for the use shared memory are not available. Z-push will work unreliably!";
$test['fatal']=false;
$tests[]=$test;
$test['name']='Process Control Extensions';
$test['showSuccessFeedback'] = false;
$test['pass']= function_exists('posix_getuid');
$test['feedback']= "Process Control Extensions PHP library not avaialble. Z-push will work unreliably!";
$test['fatal']=false;
$tests[]=$test;
if(class_exists('GO')){
// $test['name']='Writable license file';
// $test['pass']=GO::getLicenseFile()->exists() && GO::getLicenseFile()->isWritable();
// $test['feedback']="Fatal: the license file ".GO::getLicenseFile()->path()." is not writable. Please make it writable for the webserver.";
// $test['fatal']=true;
//
// $tests[]=$test;
$root = dirname(dirname(__FILE__));
if($ioncubeWorks && is_dir($root.'/modules/professional'))
{
$test['name']='Professional license';
$test['showSuccessFeedback'] = false;
// if(!file_exists(GO::config()->root_path.'groupoffice-pro-'.\GO::config()->getMajorVersion().'-license.txt')){
// $test['feedback']='Warning: There\'s no license file "groupoffice-pro-'.\GO::config()->getMajorVersion().'-license.txt" in the root of Group-Office. The professional modules will not be enabled.';
// $test['fatal']=false;
// $test['pass']=false;
// }else
if(!\GO::scriptCanBeDecoded('Professional'))
{
$test['feedback']='Warning: Your professional license is invalid. The professional modules will not be enabled. Please contact Intermesh about this problem and supply the output of this page.';
$test['fatal']=false;
$test['pass']=false;
}else
{
$test['feedback']='';
$test['fatal']=false;
$test['pass']=true;
}
$tests[]=$test;
}
if(\GO::isInstalled())
{
$test['name']='Protected files path';
$test['showSuccessFeedback'] = false;
$test['pass']=is_writable(\GO::config()->file_storage_path);
$test['feedback']='Fatal error: the file_storage_path setting in config.php is not writable. You must correct this or '.$product_name.' will not run.';
$test['fatal']=false;
$tests[]=$test;
$test['name']='Cronjob';
$test['showSuccessFeedback'] = false;
$test['pass']=GO::cronIsRunning();
$test['feedback']="Warning: The main cron job doesn't appear to be running. Please add a cron job: \n\n* * * * * www-data php ".\GO::config()->root_path."groupofficecli.php -c=".\GO::config()->get_config_file()." -r=core/cron/run -q > /dev/null";
$test['fatal']=false;
$tests[]=$test;
}
}
return $tests;
}
function output_system_test(){
global $product_name;
$tests = test_system();
$fatal = false;
foreach($tests as $test)
{
echo '<p>'.$test['name'].': ';
if(!$test['pass'])
{
echo '<span style="color:red">'.$test['feedback'].'</span>';
if($test['fatal'])
$fatal=true;
}else
{
echo '<span style="color:green">OK</span>';
if(!empty($test['showSuccessFeedback'])){
echo ' <span style="color:green"><small>( '.$test['feedback'].' )</small></span>';
}
}
echo '</p>';
}
if($fatal)
{
echo '<p style="color:red">Fatal errors occured. '.$product_name.' will not run properly with current system setup!</p>';
}else
{
echo '<p><b>Passed!</b> '.$product_name.' should run on this machine</p>';
}
echo '<table style="font:12px Arial"><tr>
<td colspan="2">
<br />
<b>Use this information for your '.$product_name.' Professional license:</b>
</td>
</tr>
<tr>
<td valign="top">Server name:</td>
<td>'.$_SERVER['SERVER_NAME'].'</td>
</tr>
<tr>
<td valign="top">Server IP:</td>
<td>'.gethostbyname($_SERVER['SERVER_NAME']).'</td>
</tr></table>';
return !$fatal;
}
//
// Detect some system parameters
//
function ic_system_info()
{
$thread_safe = false;
$debug_build = false;
$cgi_cli = false;
$php_ini_path = '';
ob_start();
phpinfo(INFO_GENERAL);
$php_info = ob_get_contents();
ob_end_clean();
foreach (explode("\n",$php_info) as $line) {
if (stripos($line, 'command')!==false) {
continue;
}
if (preg_match('/thread safety.*(enabled|yes)/Ui',$line)) {
$thread_safe = true;
}
if (preg_match('/debug.*(enabled|yes)/Ui',$line)) {
$debug_build = true;
}
if (preg_match("/configuration file.*(<\/B><\/td><TD ALIGN=\"left\">| => |v\">)([^ <]*)(.*<\/td.*)?/",$line,$match)) {
$php_ini_path = $match[2];
//
// If we can't access the php.ini file then we probably lost on the match
//
if (!@file_exists($php_ini_path)) {
$php_ini_path = '';
}
}
$cgi_cli = ((strpos(php_sapi_name(),'cgi') !== false) ||
(strpos(php_sapi_name(),'cli') !== false));
}
return array('THREAD_SAFE' => $thread_safe,
'DEBUG_BUILD' => $debug_build,
'PHP_INI' => $php_ini_path,
'CGI_CLI' => $cgi_cli);
}
/**
* Get the ioncube version data
*
* @return array
*/
function ioncube_loader_version_array () {
if ( function_exists('ioncube_loader_iversion') ) {
// Mmmrr
$ioncube_loader_iversion = ioncube_loader_iversion();
$ioncube_loader_version_major = (int)substr($ioncube_loader_iversion,0,1);
$ioncube_loader_version_minor = (int)substr($ioncube_loader_iversion,1,2);
$ioncube_loader_version_revision = (int)substr($ioncube_loader_iversion,3,2);
$ioncube_loader_version = "$ioncube_loader_version_major.$ioncube_loader_version_minor.$ioncube_loader_version_revision";
} else {
$ioncube_loader_version = ioncube_loader_version();
$ioncube_loader_version_major = (int)substr($ioncube_loader_version,0,1);
$ioncube_loader_version_minor = (int)substr($ioncube_loader_version,2,1);
}
return array('version'=>$ioncube_loader_version, 'major'=>$ioncube_loader_version_major, 'minor'=>$ioncube_loader_version_minor);
}
/**
* Test Ioncube version
*
* @return array
*/
function ioncube_version_tester(){
$test = array(
'status' =>'OK',
'problem' =>'',
'solution'=>'No additional configuration required.'
);
if(!ioncube_tester()){
$test = array(
'status' =>'ERROR',
'problem' =>'',
'solution'=>'Warning: Ioncube is not installed. The professional modules will not be enabled.'
);
return $test;
}
if(extension_loaded('ionCube Loader')){
$ioncube_loader_version = ioncube_loader_version_array();
if ($ioncube_loader_version['major'] < 5 ) {// || ($ioncube_loader_version['major'] == 4 && $ioncube_loader_version['minor'] < 6) ) {
$test = array(
'status' =>'ERROR',
'problem' =>'Installed: version '. $ioncube_loader_version['version'],
'solution'=>'Ioncube loader is installed but needs to be updated. Group-Office will only work reliably with ioncube loader version 5.0 or later. The most recent version of the loader can be found <a href="http://www.ioncube.com/loaders.php" target="_blank">here</a>.'
);
} else {
$test = array(
'status' =>'OK',
'problem' =>'Installed: version '. $ioncube_loader_version['version'],
'solution'=>'No additional configuration required.'
);
}
} else {
$sys_info = ic_system_info();
if ($sys_info['THREAD_SAFE'] && !$sys_info['CGI_CLI']) {
$test = array(
'status' =>'ERROR',
'problem' =>'Your PHP install appears to have threading support and run-time loading is only possible on threaded web servers if using the CGI, FastCGI or CLI interface.',
'solution'=>'To run encoded files please install the Loader in the php.ini file.'
);
return $test;
}
if ($sys_info['DEBUG_BUILD']) {
$test = array(
'status' =>'ERROR',
'problem' =>'Your PHP installation appears to be built with debugging support enabled and this is incompatible with ionCube Loaders. Debugging support in PHP produces slower execution, is not recommended for production builds and was probably a mistake.',
'solution'=>'You should rebuild PHP without the --enable-debug option.'
);
return $test;
}
if ( ini_get('safe_mode') ) {
$test = array(
'status' =>'ERROR',
'problem' =>'PHP safe mode is enabled and run time loading will not be possible.',
'solution'=>'To run encoded files please install the Loader in the php.ini file. Instructions can be found <a href="http://www.ioncube.com/loader_installation.php" target="_blank">here</a>. Alternatively contact your hosting provider or system administrator and ask them to enable safe mode for your account.'
);
return $test;
}
$test = array(
'status' =>'ERROR',
'problem' =>'',
'solution'=>'Warning: Ioncube is not installed. The professional modules will not be enabled.'
);
}
return $test;
}
function ioncube_tester()
{
if(extension_loaded('ionCube Loader'))
{
return true;
}
//
// Test some system info
//
$sys_info = ic_system_info();
if ($sys_info['THREAD_SAFE'] && !$sys_info['CGI_CLI']) {
return false;
}
if ($sys_info['DEBUG_BUILD']) {
return false;
}
//
// Check safe mode and for a valid extensions directory
//
if (ini_get('safe_mode') == '1') {
return false;
}
// Old style naming should be long gone now
$test_old_name = false;
$_u = php_uname();
$_os = substr($_u,0,strpos($_u,' '));
$_os_key = strtolower(substr($_u,0,3));
$_php_version = phpversion();
$_php_family = substr($_php_version,0,3);
$_loader_sfix = (($_os_key == 'win') ? '.dll' : '.so');
$_ln_old="ioncube_loader.$_loader_sfix";
$_ln_old_loc="/ioncube/$_ln_old";
$_ln_new="ioncube_loader_${_os_key}_${_php_family}${_loader_sfix}";
$_ln_new_loc="/ioncube/$_ln_new";
$_extdir = ini_get('extension_dir');
if ($_extdir == './') {
$_extdir = '.';
}
$_oid = $_id = realpath($_extdir);
$_here = dirname(__FILE__);
if ((@$_id[1]) == ':') {
$_id = str_replace('\\','/',substr($_id,2));
$_here = str_replace('\\','/',substr($_here,2));
}
$_rd=str_repeat('/..',substr_count($_id,'/')).$_here.'/';
if ($_oid === false) {
return false;
}
$_ln = '';
$_i=strlen($_rd);
while($_i--) {
if($_rd[$_i]=='/') {
if ($test_old_name) {
// Try the old style Loader name
$_lp=substr($_rd,0,$_i).$_ln_old_loc;
$_fqlp=$_oid.$_lp;
if(@file_exists($_fqlp)) {
$_ln=$_lp;
break;
}
}
// Try the new style Loader name
$_lp=substr($_rd,0,$_i).$_ln_new_loc;
$_fqlp=$_oid.$_lp;
if(@file_exists($_fqlp)) {
$_ln=$_lp;
break;
}
}
}
//
// If Loader not found, try the fallback of in the extensions directory
//
if (!$_ln) {
if ($test_old_name) {
if (@file_exists($_id.$_ln_old_loc)) {
$_ln = $_ln_old_loc;
}
}
if (@file_exists($_id.$_ln_new_loc)) {
$_ln = $_ln_new_loc;
}
}
if ($_ln) {
if(function_exists('dl')){
@dl($_ln);
}
if(extension_loaded('ionCube Loader')) {
return true;
} else {
return false;
}
}
return false;
}
function is__writable($path) {
//will work in despite of Windows ACLs bug
//NOTE: use a trailing slash for folders!!!
//see http://bugs.php.net/bug.php?id=27609
//see http://bugs.php.net/bug.php?id=30931
if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
return is__writable($path.uniqid(mt_rand()).'.tmp');
else if (is_dir($path))
return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
// check tmp file for read/write capabilities
$rm = file_exists($path);
$f = @fopen($path, 'a');
if ($f===false)
return false;
fclose($f);
if (!$rm)
unlink($path);
return true;
}
function escape_config_value($value)
{
return str_replace('\\"', '"', addslashes($value));
}
function save_config($config_obj)
{
global $CONFIG_FILE;
require($CONFIG_FILE);
$values = get_object_vars($config_obj);
foreach($values as $key=>$value)
{
if($key == 'version')
break;
if(!is_object($value))
{
$config[$key]=$value;
}
}
$config_data = "<?php\n";
foreach($config as $key=>$value)
{
if($value===true)
{
$config_data .= '$config[\''.$key.'\']=true;'."\n";
}elseif($value===false)
{
$config_data .= '$config[\''.$key.'\']=false;'."\n";
}else
{
$config_data .= '$config[\''.$key.'\']="'.$value.'";'."\n";
}
}
return file_put_contents($CONFIG_FILE, $config_data);
}
function whereis($cmd)
{
if(strtoupper(substr(PHP_OS, 0, 3)) != 'WIN' && @is_executable('whereis'))
{
exec('whereis '.$cmd, $return);
if(isset($return[0]))
{
$locations = explode(' ', $return[0]);
if(isset($locations[1]))
{
return $locations[1];
}
}
}
return false;
}
function return_bytes($val) {
$val = trim($val);
$last = strtolower($val{strlen($val)-1});
switch($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
}
//check if we are included
if(!class_exists('GO'))
{
echo '<h1 style="font-family: Arial, Helvetica;font-size: 18px;">'.$product_name.' test script</h1><div style="font-family: Arial, Helvetica;font-size: 12px;"> ';
output_system_test();
echo "</div>";
}