-
Notifications
You must be signed in to change notification settings - Fork 16
/
install.php
2712 lines (2417 loc) · 104 KB
/
install.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 /*
ocPortal
Copyright (c) ocProducts, 2004-2012
See text/EN/licence.txt for full licencing information.
*/
/**
* @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
* @copyright ocProducts Ltd
* @package installer
*/
if (!function_exists('preg_match')) exit('The PHP preg extension required for PHP 4.1, or the PHP preg support may not be disabled for PHP 4.2+');
$functions=array('fopen');
foreach ($functions as $function)
{
if (preg_match('#[^,\s]'.$function.'[$,\s]#',@ini_get('disable_functions'))!=0) exit('The '.$function.' function appears to have been manually disabled in your PHP installation. This is a basic and necessary function, required for ocPortal.');
}
if ((!array_key_exists('type',$_GET)) && (file_exists('install_locked')))
{
exit('Installer is locked for security reasons (delete the \'install_locked\' file to return to the installer)');
}
global $IN_MINIKERNEL_VERSION;
$IN_MINIKERNEL_VERSION=1;
// FIX PATH
global $FILE_BASE,$RELATIVE_PATH;
$FILE_BASE=(strpos(__FILE__,'./')===false)?__FILE__:realpath(__FILE__);
$FILE_BASE=str_replace('\\\\','\\',$FILE_BASE);
if (substr($FILE_BASE,-4)=='.php')
{
$a=strrpos($FILE_BASE,'/');
if ($a===false) $a=0;
$b=strrpos($FILE_BASE,'\\');
if ($b===false) $b=0;
$FILE_BASE=substr($FILE_BASE,0,($a>$b)?$a:$b);
}
$RELATIVE_PATH='';
@chdir($FILE_BASE);
error_reporting(E_ALL & ~(defined('E_DEPRECATED')?E_DEPRECATED:0));
if (!defined('FILE_TEXT')) define('FILE_TEXT',false);
if (!defined('FILE_BINARY')) define('FILE_BINARY',false);
@ini_set('display_errors','1');
@ini_set('assert.active','0');
@ini_set('opcache.revalidate_freq', '1'); // Bitnami WAMP puts it to 60 by default, breaking reading of _config.php
global $MOBILE;
$MOBILE=0;
global $DEFAULT_FORUM;
$DEFAULT_FORUM='ocf';
global $REQUIRED_BEFORE;
$REQUIRED_BEFORE=array();
global $SITE_INFO;
$SITE_INFO=array();
global $CACHE_DB;
$CACHE_DB=array();
global $CURRENT_SHARE_USER;
$CURRENT_SHARE_USER=NULL;
$GLOBALS['DEBUG_MODE']=false;
$GLOBALS['SEMI_DEBUG_MODE']=true;
@ob_end_clean();
if ((strpos(PHP_VERSION,'hiphop')!==false) || (array_key_exists('ZERO_HOME',$_ENV)) || (function_exists('quercus_version')) || (defined('PHALANGER')) || (defined('ROADSEND_PHPC')))
define('HIPHOP_PHP','1');
if (!array_key_exists('type',$_GET))
{
if (count($_GET)==0)
header('Content-type: text/html');
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.chr(10);
if (count($_GET)==0) // Special code to skip checks if need-be. The XHTML here is invalid but unfortunately it does need to be.
{
echo '<script type="text/javascript">// <![CDATA[
window.setTimeout(function() { if (!document.getElementsByTagName("div")[0]) window.location+="?skip_disk_checks=1"; }, 30000);
window.setInterval(function() { if ((!document.getElementsByTagName("div")[0]) && (document.body) && (document.body.innerHTML) && (document.body.innerHTML.indexOf("Maximum execution time")!=-1)) window.location+="?skip_disk_checks=1"; }, 500);
//]]></script>';
}
}
$shl=@ini_get('suhosin.memory_limit');
if (($shl===false) || ($shl=='') || ($shl=='0'))
{
@ini_set('memory_limit','-1');
} else
{
if (is_numeric($shl)) $shl.='M'; // Units are in MB for this, while PHP's memory limit setting has it in bytes
@ini_set('memory_limit',$shl);
}
// Tunnel into some ocPortal code we can use
require_code('critical_errors');
require_code('permissions');
require_code('minikernel');
require_code('inst_special');
require_code('forum_stub');
require_code('support');
require_code('temporal');
$GLOBALS['MEM_CACHE']=NULL;
require_code('files');
require_code('lang');
require_code('tempcode');
require_code('templates');
require_code('version');
require_code('urls');
if ((!array_key_exists('step',$_GET)) || (intval($_GET['step'])!=5))
{
require_code('zones');
require_code('comcode');
require_code('themes');
}
global $CACHE_TEMPLATES;
if (is_writable(get_file_base().'/themes/default/templates_cached/'.user_lang())) $CACHE_TEMPLATES=true;
// Set up some globals
global $LANG,$VERSION,$CHMOD_ARRAY,$USER_LANG_CACHED;
$LANG=fallback_lang();
if (array_key_exists('default_lang',$_GET)) $LANG=$_GET['default_lang'];
if (array_key_exists('default_lang',$_POST)) $LANG=$_POST['default_lang'];
$USER_LANG_CACHED=$LANG;
// Languages we can use
require_lang('global');
require_lang('critical_error');
require_lang('installer');
require_lang('version');
// If we are referencing this file in order to extract dependant url's from a pack
handle_self_referencing_embedment();
// Requirements check
$phpv=phpversion();
if (substr($phpv,0,2)=='3.') exit(do_lang('PHP_OLD'));
if (substr($phpv,0,3)=='4.0') exit(do_lang('PHP_OLD'));
if (ini_get('file_uploads')=='0') exit(do_lang('NO_UPLOAD'));
// Set up some globals
$minor=ocp_version_minor();
$VERSION=strval(ocp_version());
if ($minor!='') $VERSION.=(is_numeric($minor[0])?'.':'-').$minor;
$CHMOD_ARRAY=get_chmod_array();
$password_prompt=new ocp_tempcode();
if (!array_key_exists('step',$_GET))
{
$_GET['step']='1';
}
if (intval($_GET['step'])==1) // Language
{
$content=step_1();
}
if (intval($_GET['step'])==2) // Licence
{
$content=step_2();
}
if (intval($_GET['step'])==3) // Welcome
{
$content=step_3();
}
if (intval($_GET['step'])==4) // Define settings
{
$content=step_4();
$forum_type=get_param('forum_type','');
if ($forum_type=='none') $username='admin';
/*if (!is_null($username))
$password_prompt_2=do_lang_tempcode('CONFIRM_ADMIN_PASSWORD_2',escape_html($username));
else */$password_prompt_2=new ocp_tempcode();
$password_prompt=do_lang_tempcode('CONFIRM_ADMIN_PASSWORD',$password_prompt_2);
}
if (intval($_GET['step'])==5)
{
$content=step_5();
}
if (intval($_GET['step'])==6)
{
$content=step_6();
}
if (intval($_GET['step'])==7)
{
$content=step_7();
}
if (intval($_GET['step'])==8)
{
$content=step_8();
}
if (intval($_GET['step'])==9)
{
$content=step_9();
}
if (intval($_GET['step'])==10)
{
$content=step_10();
}
$css_url='install.php?type=css';
$css_url_2='install.php?type=css_2';
$logo_url='install.php?type=logo';
if (is_null($DEFAULT_FORUM)) $DEFAULT_FORUM='ocf'; // Shouldn't happen, but who knows
require_code('tempcode_compiler');
$css_nocache=_do_template('default','/css/','no_cache','no_cache','EN','.css');
$out_final=do_template('INSTALLER_WRAP',array('_GUID'=>'29aa056c05fa360b72dbb01c46608c4b','CSS_NOCACHE'=>$css_nocache,'DEFAULT_FORUM'=>$DEFAULT_FORUM,'PASSWORD_PROMPT'=>$password_prompt,'CSS_URL'=>$css_url,'CSS_URL_2'=>$css_url_2,'LOGO_URL'=>$logo_url,'STEP'=>integer_format(intval($_GET['step'])),'CONTENT'=>$content,'VERSION'=>$VERSION));
unset($css_nocache);
unset($content);
$out_final->evaluate_echo();
global $MYFILE;
if (@is_resource($MYFILE))
{
if ((intval($_GET['step'])==10) && (!is_suexec_like()))
{
$conn=false;
$domain=trim(post_param('ftp_domain'));
$port=21;
if (strpos($domain,':')!==false)
{
list($domain,$_port)=explode(':',$domain,2);
$port=intval($_port);
}
if (function_exists('ftp_ssl_connect')) $conn=@ftp_ssl_connect($domain,$port);
$ssl=($conn!==false);
$username=trim(post_param('ftp_username'));
$password=trim(post_param('ftp_password'));
if (($ssl) && (!@ftp_login($conn,$username,$password)))
{
$conn=false;
$ssl=false;
}
if ($conn===false) $conn=ftp_connect($domain,$port);
if (!$ssl) ftp_login($conn,$username,$password);
$ftp_folder=trim(post_param('ftp_folder'));
if (substr($ftp_folder,-1)!='/') $ftp_folder.='/';
ftp_chdir($conn,$ftp_folder);
if (file_exists('ocp_inst_tmp'))
{
$tmp=fopen(get_file_base().'/ocp_inst_tmp/tmp','wb');
fwrite($tmp,'');
fclose($tmp);
ftp_put($conn,'install_locked',get_file_base().'/ocp_inst_tmp/tmp',FTP_BINARY);
ftp_put($conn,'install_ok',get_file_base().'/ocp_inst_tmp/tmp',FTP_BINARY);
@unlink(get_file_base().'/ocp_inst_tmp/tmp'); // Might not be able to unlink on a Windows server, if has permission to create but not delete
@unlink(get_file_base().'/ocp_inst_tmp');
@ftp_rmdir($conn,'ocp_inst_tmp');
if (function_exists('ftp_close'))
{
ftp_close($conn);
}
}
}
}
// ========================================
// Installation steps
// ========================================
/**
* First installation step.
*
* @return tempcode Progress report / UI
*/
function step_1()
{
$warnings=new ocp_tempcode();
global $MYFILE;
if (!@is_resource($MYFILE)) // Do an integrity check - missing corrupt files
{
if ((array_key_exists('skip_disk_checks',$_GET)) || (file_exists(get_file_base().'/.git')))
{
if (!file_exists(get_file_base().'/.git'))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('INSTALL_SLOW_SERVER'))));
} else
{
$files=@unserialize(file_get_contents(get_file_base().'/data/files.dat',FILE_TEXT));
if (($files!==false) && (!file_exists(get_file_base().'/.svn')))
{
$missing=array();
$corrupt=array();
foreach ($files as $file=>$file_info)
{
if ($file=='data_custom/errorlog.php') continue;
if ($file=='ocp_sitemap.xml') continue;
if ($file=='data_custom/spelling/output.log') continue;
if ($file=='info.php') continue;
if ($file=='themes/map.ini') continue;
if ($file=='sources/version.php') continue;
if ($file=='data_custom/functions.dat') continue;
if (strpos($file,'/pagepics/')!==false) continue;
if ($file=='data/files.dat') continue;
if ($file=='data/files_previous.dat') continue;
if ($file=='data/modules/admin_stats/IP_Country.txt') continue;
if ($file=='data/areaedit/plugins/SpellChecker/aspell/bin/aspell-15.dll') continue;
if ($file=='data/areaedit/plugins/SpellChecker/aspell/bin/en-only.rws') continue;
if (substr($file,-4)=='.ttf') continue;
$contents=@file_get_contents(get_file_base().'/'.$file,FILE_BINARY);
if (!file_exists(get_file_base().'/'.$file))
{
$missing[]=$file;
}
elseif (($contents!==false) && (sprintf('%u',crc32(preg_replace('#[\r\n\t ]#','',$contents)))!=$file_info[0]))
{
$corrupt[]=$file;
}
}
if (count($missing)>4)
{
$warnings->attach(do_template('INSTALLER_WARNING_LONG',array('_GUID'=>'515c2f26a5415224f3c09b2429a78a5f','FILES'=>$missing,'MESSAGE'=>do_lang_tempcode('_MISSING_INSTALLATION_FILE',integer_format(count($missing))))));
} else
{
foreach ($missing as $file)
{
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('MISSING_INSTALLATION_FILE',escape_html($file)))));
}
}
if (count($corrupt)>4)
{
$warnings->attach(do_template('INSTALLER_WARNING_LONG',array('_GUID'=>'f8958458d76bd4f6d146d3fe59132a02','FILES'=>$corrupt,'MESSAGE'=>do_lang_tempcode('_CORRUPT_INSTALLATION_FILE',integer_format(count($corrupt))))));
} else
{
foreach ($corrupt as $file)
{
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('CORRUPT_INSTALLATION_FILE',escape_html($file)))));
}
}
}
}
}
$test=ini_get('mbstring.func_overload');
if (($test!==false) && ($test!=='') && ($test!=='0'))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('WARNING_MBSTRING_FUNC_OVERLOAD'))));
if (php_function_allowed('disk_free_space'))
{
$disk_space=@disk_free_space(get_file_base());
if ((is_integer($disk_space)) && ($disk_space<25*1024*1024))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('WARNING_DISK_SPACE'))));
}
if ((!function_exists('zip_open')) && (!@file_exists('/usr/bin/unzip')))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('NO_ZIP_ON_SERVER'))));
if (!function_exists('imagecreatefromstring'))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('NO_GD_ON_SERVER'))));
if (!function_exists('xml_parser_create'))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('NO_XML_ON_SERVER'))));
if ((function_exists('memory_get_usage')) && (@ini_get('memory_limit')!='') && (@ini_get('memory_limit')!='-1') && (@ini_get('memory_limit')!='0') && (intval(trim(str_replace('M','',@ini_get('memory_limit'))))<16))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('LOW_MEMORY_LIMIT'))));
if ((is_numeric(@ini_get('max_execution_time'))) && (intval(@ini_get('max_execution_time'))>0) && (intval(@ini_get('max_execution_time'))<10) && (str_replace(array('on','true','yes'),array('1','1','1'),strtolower(ini_get('safe_mode')))=='1'))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('WARNING_MAX_EXECUTION_TIME'))));
if ((is_numeric(@ini_get('max_input_time'))) && (intval(@ini_get('max_input_time'))>0) && (intval(@ini_get('max_input_time'))<60) && (str_replace(array('on','true','yes'),array('1','1','1'),strtolower(ini_get('safe_mode')))=='1'))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('WARNING_MAX_INPUT_TIME'))));
$needed_functions=<<<END
abs addslashes array_count_values array_diff array_flip array_key_exists array_keys
array_intersect array_merge array_pop array_push array_reverse array_search array_shift
array_slice array_splice array_unique array_values arsort asort base64_decode base64_encode
call_user_func ceil chdir checkdate chmod chr chunk_split class_exists clearstatcache closedir
constant copy cos count crypt current date dechex decoct define defined dirname
deg2rad error_reporting eval exit explode fclose feof fgets file file_exists
file_get_contents filectime filegroup filemtime fileowner fileperms filesize floatval floor
get_defined_vars get_declared_classes get_defined_functions fopen fread fseek ftell
function_exists fwrite gd_info get_class get_html_translation_table get_magic_quotes_gpc getcwd
getdate getenv gmdate gzclose gzopen gzwrite header headers_sent hexdec highlight_string
htmlentities imagealphablending imagecolorallocate imagecolortransparent imagecopy
imagecopyresampled imagecopyresized imagecreate imagecreatefromstring imagecreatefrompng
imagecreatefromjpeg imagecreatetruecolor imagecolorat imagecolorsforindex
imagedestroy imagefill imagefontheight imagefontwidth imagejpeg imagepng imagesavealpha
imagesetpixel imagestring imagesx imagesy imagestringup imagettfbbox imagettftext imagetypes
imagearc imagefilledarc imagecopymergegray imageline imageellipse imagefilledellipse
imagechar imagefilledpolygon imagepolygon imagefilledrectangle imagerectangle imagefilltoborder
imagegammacorrect imageinterlace imageloadfont imagepalettecopy imagesetbrush
imagesetstyle imagesetthickness imagesettile imagetruecolortopalette
imagecharup imagecolorclosest imagecolorclosestalpha imagecolorclosesthwb
imagecolordeallocate imagecolorexact imagecolorexactalpha imagecolorresolve
imagecolorresolvealpha imagecolorset imagecolorstotal imagecopymerge
implode in_array include include_once ini_get ini_set intval is_a is_array is_bool is_dir is_file is_float
is_integer is_null is_numeric is_object is_readable is_resource is_string is_uploaded_file is_writable
isset krsort ksort localeconv ltrim mail max md5 method_exists microtime min
mkdir mktime move_uploaded_file mt_getrandmax mt_rand mt_srand number_format ob_end_clean
ob_end_flush ob_get_contents ob_start octdec opendir ord pack parse_url pathinfo phpversion
preg_match preg_grep preg_match_all
preg_replace preg_replace_callback preg_split print_r putenv rawurldecode
rawurlencode readdir realpath register_shutdown_function rename require require_once reset rmdir
round rsort rtrim serialize set_error_handler set_magic_quotes_runtime
setcookie setlocale sha1 sin sort sprintf srand str_pad str_repeat str_replace
strcmp strftime strip_tags stripslashes strlen strpos strrpos strstr strtok strtolower
strtotime strtoupper strtr strval substr substr_count tempnam time trim trigger_error
uasort ucfirst ucwords uksort uniqid unlink unserialize unset urldecode urlencode usort
utf8_decode utf8_encode wordwrap xml_error_string xml_get_current_byte_index xml_get_current_line_number
xml_get_error_code xml_parse xml_parser_create_ns xml_parser_free xml_parser_set_option
xml_set_character_data_handler xml_set_element_handler xml_set_end_namespace_decl_handler xml_set_object
xml_set_start_namespace_decl_handler xmlrpc_encode_request acos array_rand array_unshift asin assert
assert_options atan base_convert basename bin2hex bindec call_user_func_array
connection_aborted connection_status crc32 decbin each empty fflush fileatime flock flush
get_current_user gethostbyaddr getrandmax gmmktime gmstrftime ip2long
levenshtein log log10 long2ip md5_file money_format pow preg_quote prev rad2deg
range readfile shuffle similar_text sqrt strcasecmp strcoll strcspn stristr strnatcasecmp
strnatcmp strncasecmp strncmp strrchr strrev strspn substr_replace tan unpack version_compare
gettype zend_version zend_logo_guid xml_get_current_column_number xml_parser_create
xml_parser_get_option xml_parse_into_struct xml_set_default_handler xml_set_external_entity_ref_handler
xml_set_notation_decl_handler xml_set_processing_instruction_handler xml_set_unparsed_entity_decl_handler
var_dump vprintf vsprintf touch tanh sinh sleep soundex sscanf stripcslashes
readgzfile restore_error_handler rewind rewinddir quoted_printable_decode
quotemeta exp ezmlm_hash lcg_value localtime addcslashes
array_filter array_map array_merge_recursive array_multisort array_pad array_reduce array_walk
atan2 fgetc fgetcsv fgetss filetype fscanf fstat ftp_cdup ftp_fget ftp_get ftp_pasv
ftp_pwd ftp_rawlist ftp_systype ftruncate func_get_arg func_get_args func_num_args
parse_ini_file parse_str is_executable
is_scalar is_subclass_of metaphone natcasesort natsort nl2br ob_get_length ob_gzhandler
ob_iconv_handler ob_implicit_flush php_sapi_name
printf convert_cyr_string cosh count_chars
disk_total_space gethostbynamel getimagesize getlastmod getmypid getmyuid
gettimeofday get_cfg_var get_magic_quotes_runtime get_meta_tags get_parent_class
get_included_files get_resource_type gzcompress gzdeflate gzencode gzfile gzinflate
gzuncompress hypot ignore_user_abort
gzclose gzopen gzwrite ftp_chdir ftp_close ftp_connect ftp_delete ftp_fput
ftp_login ftp_mkdir ftp_nlist ftp_put ftp_rename ftp_rmdir ftp_site ftp_size
END;
foreach (preg_split('#\s+#',$needed_functions) as $function)
{
if (trim($function)=='') continue;
if (@preg_match('#(\s|,|^)'.str_replace('#','\#',preg_quote($function)).'(\s|$|,)#',strtolower(@ini_get('disable_functions').','.ini_get('suhosin.executor.func.blacklist').','.ini_get('suhosin.executor.include.blacklist').','.ini_get('suhosin.executor.eval.blacklist')))!=0)
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('DISABLED_FUNCTION',escape_html($function)))));
}
/*client check is wrong if (function_exists('mysqli_get_client_version'))
{
$x=float_to_raw_string(floatval(mysqli_get_client_version())/10000.0);
if (version_compare($x,'4.1.0','<'))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('MYSQL_TOO_OLD'))));
}
elseif (function_exists('mysql_get_client_version'))
{
if (version_compare(mysql_get_client_version(),'4.1.0','<'))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('MYSQL_TOO_OLD'))));
}*/
global $FILE_ARRAY;
if (!@is_array($FILE_ARRAY)) // Talk about manual permission setting a bit
{
if ((function_exists('posix_getuid')) && (strpos(@ini_get('disable_functions'),'posix_getuid')===false) && (!isset($_SERVER['HTTP_X_MOSSO_DT'])) && (@posix_getuid()==@fileowner(get_file_base().'/install.php'))) // NB: Could also be that files are owned by 'apache'/'nobody'. In these cases the users have consciously done something special and know what they're doing (they have open_basedir at least hopefully!) so we'll still consider this 'suexec'. It's too much an obscure situation.
$warnings->attach(do_template('INSTALLER_NOTICE',array('MESSAGE'=>do_lang_tempcode('SUEXEC_SERVER'))));
elseif (is_writable_wrap(get_file_base().'/install.php'))
$warnings->attach(do_template('INSTALLER_NOTICE',array('MESSAGE'=>do_lang_tempcode('RECURSIVE_SERVER'))));
}
if ((file_exists(get_file_base().'/info.php')) && (!is_writable_wrap(get_file_base().'/info.php')) && (!function_exists('posix_getuid')) && ((strpos(PHP_OS,'WIN')!==false)))
$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('TROUBLESOME_WINDOWS_SERVER'))));
// Some sanity checks
if (!@is_array($FILE_ARRAY)) // Secondary to the file-by-file check. Aims to give more specific information
{
if ((file_exists(get_file_base().'/themes/default/templates/ANCHOR.tpl')) && (!file_exists(get_file_base().'/themes/default/templates/COMCODE_REAL_TABLE_CELL.tpl')))
warn_exit(do_lang_tempcode('CORRUPT_FILES_CROP'));
if ((!file_exists(get_file_base().'/themes/default/templates/ANCHOR.tpl')) && (file_exists(get_file_base().'/themes/default/templates/anchor.tpl')))
warn_exit(do_lang_tempcode('CORRUPT_FILES_LOWERCASE'));
/* if (!file_exists(get_file_base().'/themes/default/templates/ADDITIONAL.tpl')) Redundant now
warn_exit(do_lang_tempcode('MISSING_FILES'));*/
}
if (file_exists('lang_custom/langs.ini'))
$lookup=better_parse_ini_file(get_custom_file_base().'/lang_custom/langs.ini');
else
$lookup=better_parse_ini_file(get_file_base().'/lang/langs.ini');
$lang_count=array();
$langs1=get_dir_contents('lang');
foreach (array_keys($langs1) as $lang)
{
if (array_key_exists($lang,$lookup))
{
if (!array_key_exists($lang,$lang_count)) $lang_count[$lang]=0;
$files=get_dir_contents('lang/'.$lang);
foreach (array_keys($files) as $file)
if (substr($file,-4)=='.ini')
$lang_count[$lang]+=count(better_parse_ini_file(get_file_base().'/lang/'.$lang.'/'.$file));
}
}
$langs2=get_dir_contents('lang_custom');
foreach (array_keys($langs2) as $lang)
{
if (array_key_exists($lang,$lookup))
{
if (!array_key_exists($lang,$lang_count)) $lang_count[$lang]=0;
$files=get_dir_contents('lang_custom/'.$lang);
foreach (array_keys($files) as $file)
if (substr($file,-4)=='.ini')
$lang_count[$lang]+=count(better_parse_ini_file(get_custom_file_base().'/lang_custom/'.$lang.'/'.$file));
}
}
$langs=array_merge($langs1,$langs2);
ksort($langs);
unset($langs['EN']);
$langs=array_merge(array('EN'=>'lang'),$langs);
$tlanguages=new ocp_tempcode();
foreach (array_keys($langs) as $lang)
{
if (array_key_exists($lang,$lookup))
{
$stub=($lang=='EN')?'':(' (unofficial, '.strval(intval(round(100.0*$lang_count[$lang]/$lang_count['EN']))).'% changed)');
$entry=do_template('FORM_SCREEN_INPUT_LIST_ENTRY',array('SELECTED'=>$lang==user_lang(),'DISABLED'=>false,'NAME'=>$lang,'CLASS'=>'','TEXT'=>$lookup[$lang].$stub));
$tlanguages->attach($entry);
}
}
$hidden=build_keep_post_fields();
$max=strval(get_param_integer('max',1000));
$hidden->attach(form_input_hidden('max',$max));
return do_template('INSTALLER_STEP_1',array('_GUID'=>'83f0ca881b9f63ab9378264c6ff507a3','WARNINGS'=>$warnings,'HIDDEN'=>$hidden,'LANGUAGES'=>$tlanguages));
}
/**
* Second installation step.
*
* @return tempcode Progress report / UI
*/
function step_2()
{
if (!array_key_exists('default_lang',$_POST)) $_POST['default_lang']='EN';
global $FILE_ARRAY;
if (@is_array($FILE_ARRAY))
{
$licence=file_array_get('text/'.filter_naughty($_POST['default_lang']).'/licence.txt');
if (is_null($licence)) $licence=file_array_get('text/EN/licence.txt');
}
else
{
$licence=@file_get_contents(get_file_base().'/text/'.filter_naughty($_POST['default_lang']).'/licence.txt',FILE_TEXT);
if ($licence=='') $licence=file_get_contents(get_file_base().'/text/EN/licence.txt',FILE_TEXT);
}
$hidden=build_keep_post_fields();
return do_template('INSTALLER_STEP_2',array('_GUID'=>'b08b0268784c9a0f44863ae3aece6789','HIDDEN'=>$hidden,'LICENCE'=>$licence));
}
/**
* Third installation step.
*
* @return tempcode Progress report / UI
*/
function step_3()
{
if (count($_POST)==0) exit(do_lang('INST_POST_ERROR'));
global $LANG;
// Call home, if they asked to
$advertise_on=array_key_exists('advertise_on',$_POST)?intval($_POST['advertise_on']):0;
$email=$_POST['email'];
if ($email==do_lang('EMAIL_ADDRESS')) $email='';
if (($email!='') || ($advertise_on==1))
{
$call='/join_hook.php?url='.urlencode('http://'.ocp_srv('HTTP_HOST').ocp_srv('REQUEST_URI')).'&email='.urlencode($email).'&interest_level='.$_POST['interest_level'].'&advertise_on='.strval($advertise_on).'&lang='.$LANG;
$errno=0;
$errstr='';
$mysock=@fsockopen('ocportal.com',80,$errno,$errstr,6.0);
if ($mysock!==false)
{
$out="GET ".$call." HTTP/1.1\r\n";
$out.="Host: ocportal.com\r\n";
$out.="Connection: Close\r\n\r\n";
@fwrite($mysock,$out);
@fclose($mysock);
}
}
// Forum chooser
$forums=get_dir_contents('sources/forum',true);
unset($forums['none']);
ksort($forums);
$forums=array_merge(array('none'=>1),$forums);
$forum_info=better_parse_ini_file(get_file_base().'/sources/forum/forums.ini');
$tforums=new ocp_tempcode();
$classes=array();
foreach (array_keys($forums) as $forum)
{
$class=array_key_exists($forum.'_class',$forum_info)?$forum_info[$forum.'_class']:'general';
$classes[$class][]=$forum;
}
global $DEFAULT_FORUM;
if ((file_exists(get_file_base().'/info.php')) && (filesize(get_file_base().'/info.php')!=0))
{
require_once(get_file_base().'/info.php');
global $SITE_INFO;
if (array_key_exists('forum_type',$SITE_INFO)) $DEFAULT_FORUM=$SITE_INFO['forum_type'];
}
$default_version=new ocp_tempcode();
/*foreach ($classes as $class=>$forums)
{
foreach ($forums as $forum)
{
if (strpos(get_file_base(),'/'.$forum.'/')!==false) $DEFAULT_FORUM=$forum;
}
}*/
$simple_forums=new ocp_tempcode(); // For is JS is off, this is a simple flat list of all versions (rather than a two level list - with first level being $tforums and the second level being filtered using CSS 'display' from $versions)
foreach ($classes as $class=>$forums)
{
if (trim($class)=='') continue;
$mapped_name=do_lang('FORUM_CLASS_'.$class,NULL,NULL,NULL,NULL,false);
if (is_null($mapped_name)) $mapped_name=ucwords($class);
$versions=new ocp_tempcode();
$first=true;
$forums=array_reverse($forums);
$rec=in_array($DEFAULT_FORUM,$forums);
foreach ($forums as $forum)
{
if ($class=='general')
{
$version=$forum;
} else
{
$version=array_key_exists($forum.'_version',$forum_info)?do_lang('VERSION_NUM',$forum_info[$forum.'_version']):do_lang('NA');
}
$extra2='';//(($first && !$rec) || $rec)?'checked="checked"':'';
$versions->attach(do_template('INSTALLER_FORUM_CHOICE_VERSION',array('_GUID'=>'159a5a7cd1397620ef34e98c3b06cd7f','IS_DEFAULT'=>($DEFAULT_FORUM==$forum) || ($first && !$rec),'CLASS'=>$class,'NAME'=>$forum,'VERSION'=>$version,'EXTRA'=>$extra2)));
$first=false;
$simple_forums->attach(do_template('INSTALLER_FORUM_CHOICE_VERSION',array('_GUID'=>'c4c0e7accab56ae45e8e1a4ff777c42b','IS_DEFAULT'=>($DEFAULT_FORUM==$forum) || ($first && !$rec),'CLASS'=>$class,'NAME'=>$forum,'VERSION'=>$mapped_name.' '.$version,'EXTRA'=>'')));
}
if ($rec) $default_version=$versions;
$extra=($rec)?'checked="checked"':'';
$tforums->attach(do_template('INSTALLER_FORUM_CHOICE',array('_GUID'=>'a5460829e86c9da3637f8e566cfca63c','CLASS'=>$class,'REC'=>$rec,'TEXT'=>$mapped_name,'VERSIONS'=>$versions,'EXTRA'=>$extra)));
}
// Database chooser
$databases=array_merge(get_dir_contents('sources/database',true),get_dir_contents('sources_custom/database',true));
ksort($databases);
$database_names=better_parse_ini_file(get_file_base().'/sources/database/database.ini');
$tdatabase=new ocp_tempcode();
foreach (array_keys($databases) as $database)
{
if ((count($databases)==1) && ($database=='xml')) continue; // If they only have experimental XML option, they'll choose it - we don't want that - we want them to get the error
if (($database=='mysqli') && (!function_exists('mysqli_connect'))) continue;
if (($database=='mysql_dbx') && (!function_exists('dbx_connect'))) continue;
if (($database=='mysql') && (!function_exists('mysql_connect'))) continue;
if (($database=='access') && (!function_exists('odbc_connect'))) continue;
if (($database=='ibm') && (!function_exists('odbc_connect'))) continue;
if (($database=='oracle') && (!function_exists('ocilogon'))) continue;
if (($database=='postgresql') && (!function_exists('pg_connect'))) continue;
if (($database=='sqlite') && (!function_exists('sqlite_popen'))) continue;
if (($database=='sqlserver') && (!function_exists('mssql_connect')) && (!function_exists('sqlsrv_connect'))) continue;
if (array_key_exists($database,$database_names)) $mapped_name=$database_names[$database]; else $mapped_name=$database;
$tdatabase->attach(do_template('FORM_SCREEN_INPUT_LIST_ENTRY',array('SELECTED'=>$database=='mysql','DISABLED'=>false,'NAME'=>$database,'CLASS'=>'','TEXT'=>$mapped_name)));
}
if ($tdatabase->is_empty()) warn_exit(do_lang_tempcode('NO_PHP_DB'));
$js=do_template('JAVASCRIPT');
$js->attach(chr(10));
$js->attach(do_template('JAVASCRIPT_AJAX'));
$hidden=build_keep_post_fields();
return do_template('INSTALLER_STEP_3',array('_GUID'=>'af52ecea73e9a8e2a92c12adbabbf4ab','JS'=>$js,'HIDDEN'=>$hidden,'SIMPLE_FORUMS'=>$simple_forums,'FORUM_PATH_DEFAULT'=>get_file_base().DIRECTORY_SEPARATOR.'forums','FORUMS'=>$tforums,'DATABASES'=>$tdatabase,'VERSION'=>$default_version));
}
/**
* Fourth installation step.
*
* @return tempcode Progress report / UI
*/
function step_4()
{
global $LANG;
if (count($_POST)==0) exit(do_lang('INST_POST_ERROR'));
require_code('database/'.post_param('db_type'));
$GLOBALS['DB_STATIC_OBJECT']=object_factory('Database_Static_'.post_param('db_type'));
$domain=ocp_srv('HTTP_HOST');
if (substr($domain,0,4)=='www.') $domain=substr($domain,4);
$colon_pos=strpos($domain,':');
if ($colon_pos!==false) $domain=substr($domain,0,$colon_pos);
$pos=strpos(ocp_srv('PHP_SELF'),'install.php');
if ($pos===false) $pos=strlen(ocp_srv('PHP_SELF')); else $pos--;
$port=ocp_srv('SERVER_PORT');
if (($port=='') || ($port=='80') || ($port=='443')) $port=''; else $port=':'.$port;
$base_url=post_param('base_url','http://'.$domain.$port.substr(ocp_srv('PHP_SELF'),0,$pos));
if (substr($base_url,-1)=='/') $base_url=substr($base_url,0,strlen($base_url)-1);
// Our forum is
$forum_type=post_param('forum_type');
require_code('forum/'.$forum_type);
$GLOBALS['FORUM_DRIVER']=object_factory('forum_driver_'.filter_naughty_harsh($forum_type));
$GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED=array();
// Try and grab ourselves forum details
global $INFO;
$INFO['sql_database']='';
$INFO['sql_user']='';
$INFO['sql_pass']='';
$board_path=post_param('board_path');
find_forum_path($board_path);
if ((!array_key_exists('board_url',$INFO)) || (!(strlen($INFO['board_url'])>0)))
{
$file_base=get_file_base();
for ($i=0;$i<strlen($board_path);$i++)
{
if ($i>=strlen($file_base)) break;
if ($board_path[$i]!=$file_base[$i]) break;
}
$append=str_replace('\\','/',substr($board_path,$i));
$INFO['board_url']=(strlen($append)<15)?(substr($base_url,0,strlen($base_url)-($i-strlen($board_path))).((((strlen($append)>0) && ($append[0]=='/')))?'':'/').$append):($base_url.'/forums');
}
if (!array_key_exists('cookie_member_id',$INFO)) $INFO['cookie_member_id']='ocp_member_id';
if (!array_key_exists('cookie_member_hash',$INFO)) $INFO['cookie_member_hash']='ocp_member_hash';
$cookie_domain='';//(($domain=='localhost') || (strpos($domain,'.')===false))?'':('.'.$domain);
$cookie_path='/';
$cookie_days='120';
$use_persistent=false;
require_code('version');
$table_prefix=($domain=='test.ocportal.com')?($forum_type.'_ocp_'):('ocp_');
if (strpos(strtoupper(PHP_OS),'WIN')!==false)
{
$db_site_host='127.0.0.1';
} else
{
$db_site_host='localhost';
}
$db_site_user=$INFO['sql_user'];
$db_site_password=$INFO['sql_pass'];
$db_site=$INFO['sql_database'];
$db_forums_host=$db_site_host;
$db_forums_user=$db_site_user;
$db_forums_password=$db_site_password;
$db_forums=$db_site;
$board_prefix=$INFO['board_url'];
$member_cookie=$INFO['cookie_member_id'];
$pass_cookie=$INFO['cookie_member_hash'];
if ((function_exists('posix_getpwuid')) && (strpos(@ini_get('disable_functions'),'posix_getpwuid')===false))
{
$u_info=posix_getpwuid(fileowner(get_file_base().'/install.php'));
if ($u_info!==false) $ftp_username=$u_info['name']; else $ftp_username='';
} else $ftp_username='';
if (is_null($ftp_username)) $ftp_username='';
$dr=array_key_exists('DOCUMENT_ROOT',$_SERVER)?$_SERVER['DOCUMENT_ROOT']:(array_key_exists('DOCUMENT_ROOT',$_ENV)?$_ENV['DOCUMENT_ROOT']:'');
if (strpos($dr,'/')!==false) $dr_parts=explode('/',$dr); else $dr_parts=explode('\\',$dr);
$webdir_stub=$dr_parts[count($dr_parts)-1];
// If we have a host where the FTP is two+ levels down (often when we have one FTP covering multiple virtual hosts), then this "last component" rule would be insufficient; do a search through for critical strings to try and make a better guess
$special_root_dirs=array('public_html','www','webroot','httpdocs','wwwroot');
$webdir_stub=$dr_parts[count($dr_parts)-1];
foreach ($dr_parts as $i=>$part)
{
if (in_array($part,$special_root_dirs))
{
$webdir_stub=implode('/',array_slice($dr_parts,$i));
}
}
$ftp_folder='/'.$webdir_stub.substr(ocp_srv('PHP_SELF'),0,$pos);
$ftp_domain=$domain;
$specifics=$GLOBALS['FORUM_DRIVER']->install_specifics();
// Now we've gone through all the work of detecting it, lets grab from info.php to see what we had last time we installed
global $SITE_INFO;
if ((file_exists(get_file_base().'/info.php')) && (filesize(get_file_base().'/info.php')!=0))
{
require_once(get_file_base().'/info.php');
if ($INFO['sql_database']!='')
{
if ((!array_key_exists('forum_type',$SITE_INFO)) || ($SITE_INFO['forum_type']!=$forum_type)) // Don't want to throw detected versions of these away
{
unset($SITE_INFO['user_cookie']);
unset($SITE_INFO['pass_cookie']);
}
foreach ($specifics as $specific)
{
if (array_key_exists($specific['name'],$SITE_INFO)) unset($SITE_INFO[$specific['name']]);
}
unset($SITE_INFO['db_forums_host']);
unset($SITE_INFO['db_forums_user']);
unset($SITE_INFO['db_forums_password']);
unset($SITE_INFO['db_forums']);
unset($SITE_INFO['db_site_host']);
unset($SITE_INFO['db_site_user']);
unset($SITE_INFO['db_site_password']);
unset($SITE_INFO['db_site']);
}
unset($SITE_INFO['base_url']);
}
$sections=new ocp_tempcode();
// Is this autoinstaller?
global $FILE_ARRAY;
if ((@is_array($FILE_ARRAY)) && (!is_suexec_like()))
{
$title=protect_from_escaping(escape_html('FTP'));
$text=do_lang_tempcode('AUTO_INSTALL');
$hidden=new ocp_tempcode();
$options=new ocp_tempcode();
$options->attach(make_option(do_lang_tempcode('FTP_DOMAIN'),new ocp_tempcode(),'ftp_domain',post_param('ftp_domain',$ftp_domain),false,true));
$options->attach(make_option(do_lang_tempcode('FTP_USERNAME'),new ocp_tempcode(),'ftp_username',post_param('ftp_username',$ftp_username),false,true));
$options->attach(make_option(do_lang_tempcode('FTP_PASSWORD'),new ocp_tempcode(),'ftp_password',post_param('ftp_password',''),true));
$options->attach(make_option(do_lang_tempcode('FTP_DIRECTORY'),do_lang_tempcode('FTP_FOLDER'),'ftp_folder',post_param('ftp_folder',$ftp_folder)));
$options->attach(make_option(do_lang_tempcode('FTP_FILES_PER_GO'),do_lang_tempcode('DESCRIPTION_FTP_FILES_PER_GO'),'max',post_param('max','1000')));
$sections->attach(do_template('INSTALLER_STEP_4_SECTION',array('_GUID'=>'50fcb00f4d1da1813e94d86529ea0862','HIDDEN'=>$hidden,'TITLE'=>$title,'TEXT'=>$text,'OPTIONS'=>$options)));
}
$title=do_lang_tempcode('GENERAL_SETTINGS');
$text=new ocp_tempcode();
$options=new ocp_tempcode();
$hidden=new ocp_tempcode();
$options->attach(make_option(do_lang_tempcode('DOMAIN'),example('DOMAIN_EXAMPLE','DOMAIN_TEXT'),'domain',$domain,false,true));
$options->attach(make_option(do_lang_tempcode('BASE_URL'),example('BASE_URL_EXAMPLE','BASE_URL_TEXT'),'base_url',$base_url,false,true));
if (post_param('db_type')!='xml')
$options->attach(make_option(do_lang_tempcode('TABLE_PREFIX'),example('TABLE_PREFIX_EXAMPLE','TABLE_PREFIX_TEXT'),'table_prefix',$table_prefix));
else
$hidden->attach(form_input_hidden('table_prefix',$table_prefix));
$admin_password='';
$options->attach(make_option(do_lang_tempcode('MASTER_PASSWORD'),example('','CHOOSE_ADMIN_PASSWORD'),'admin_password',$admin_password,true));
$options->attach(make_tick(do_lang_tempcode('USE_PERSISTENT'),example('','USE_PERSISTENT_TEXT'),'use_persistent',$use_persistent?1:0));
// $options->attach(make_tick(do_lang_tempcode('MULTI_LANG'),example('','MULTI_LANG_TEXT'),'multi_lang',true));
require_lang('config');
$options->attach(make_tick(do_lang_tempcode('SEND_ERROR_EMAILS_OCPRODUCTS'),example('','CONFIG_OPTION_send_error_emails_ocproducts'),'allow_reports_default',1));
$sections->attach(do_template('INSTALLER_STEP_4_SECTION',array('_GUID'=>'f051465e86a7a53ec078e0d9de773993','HIDDEN'=>$hidden,'TITLE'=>$title,'TEXT'=>$text,'OPTIONS'=>$options)));
$hidden=new ocp_tempcode();
$forum_text=new ocp_tempcode();
if (($forum_type=='ocf') || ($forum_type=='none'))
{
$forum_title=do_lang_tempcode('FORUM_SETTINGS');
} else
{
$_forum_type=do_lang('FORUM_CLASS_'.preg_replace('#\d+$#','',$forum_type),NULL,NULL,NULL,NULL,false);
if (is_null($_forum_type)) $_forum_type=ucwords($forum_type);
$forum_title=do_lang_tempcode('_FORUM_SETTINGS',escape_html($_forum_type));
}
$forum_options=new ocp_tempcode();
$use_msn=post_param_integer('use_msn',0);
if ($use_msn==0) $use_msn=post_param_integer('use_multi_db',0);
$forum_type=post_param('forum_type');
if ($forum_type!='none')
{
if ($use_msn==1)
{
if ($forum_type!='ocf') $forum_text=do_lang_tempcode('AUTODETECT');
$forum_options->attach(make_option(do_lang_tempcode('DATABASE_NAME'),new ocp_tempcode(),'db_forums',$db_forums,false,true));
if (!$GLOBALS['DB_STATIC_OBJECT']->db_is_flat_file_simple())
{
$forum_options->attach(make_option(do_lang_tempcode('DATABASE_HOST'),example('','DATABASE_HOST_TEXT'),'db_forums_host',$db_forums_host,false,true));
$forum_options->attach(make_option(do_lang_tempcode('DATABASE_USERNAME'),new ocp_tempcode(),'db_forums_user',$db_forums_user,false,true));
$forum_options->attach(make_option(do_lang_tempcode('DATABASE_PASSWORD'),new ocp_tempcode(),'db_forums_password',$db_forums_password,true));
} else
{
$hidden->attach(form_input_hidden('db_forums_host','localhost'));
$hidden->attach(form_input_hidden('db_forums_user',''));
$hidden->attach(form_input_hidden('db_forums_password',''));
}
$hidden->attach(form_input_hidden('use_msn',strval($use_msn)));
}
if (($forum_type!='ocf') || ($use_msn==1))
$forum_options->attach(make_option(do_lang_tempcode('BASE_URL'),example('FORUM_BASE_URL_EXAMPLE','BASE_URL_TEXT_FORUM'),'board_prefix',$board_prefix,false,true));
}
foreach ($specifics as $specific)
{
if (($specific['name']=='clear_existing_forums_on_install') /*&& ($use_msn==0)*/)
{
$hidden->attach(form_input_hidden('clear_existing_forums_on_install','yes'));
}
elseif (($specific['name']=='ocf_table_prefix') && ($use_msn==0))
{
// Nothing
} else
{
$forum_options->attach(make_option(is_object($specific['title'])?$specific['title']:make_string_tempcode($specific['title']),is_object($specific['description'])?$specific['description']:make_string_tempcode($specific['description']),$specific['name'],array_key_exists($specific['name'],$SITE_INFO)?$SITE_INFO[$specific['name']]:$specific['default'],strpos($specific['name'],'password')!==false));
}
}
$text=($use_msn==1)?do_lang_tempcode(($forum_type=='ocf')?'DUPLICATE_OCF':'DUPLICATE'):new ocp_tempcode();
$options=make_option(do_lang_tempcode('DATABASE_NAME'),new ocp_tempcode(),'db_site',$db_site,false,true);
if (!$GLOBALS['DB_STATIC_OBJECT']->db_is_flat_file_simple())
{
$options->attach(make_option(do_lang_tempcode('DATABASE_HOST'),example('','DATABASE_HOST_TEXT'),'db_site_host',$db_site_host,false,true));
$options->attach(make_option(do_lang_tempcode('DATABASE_USERNAME'),new ocp_tempcode(),'db_site_user',$db_site_user,false,true));
$options->attach(make_option(do_lang_tempcode('DATABASE_PASSWORD'),new ocp_tempcode(),'db_site_password',$db_site_password,true));
} else
{
$hidden->attach(form_input_hidden('db_site_host','localhost'));
$hidden->attach(form_input_hidden('db_site_user',''));
$hidden->attach(form_input_hidden('db_site_password',''));
}
if (($use_msn==0) && ($forum_type!='ocf')) // Merge into one set of options
{
$forum_options->attach($options);
$sections->attach(do_template('INSTALLER_STEP_4_SECTION',array('HIDDEN'=>$hidden,'TITLE'=>$forum_title,'TEXT'=>$forum_text,'OPTIONS'=>$forum_options)));
} else
{
$title=do_lang_tempcode('OCPORTAL_SETTINGS');
if (!$forum_options->is_empty()) $sections->attach(do_template('INSTALLER_STEP_4_SECTION',array('_GUID'=>'232b69a995f384275c1cd9269a42c3b8','HIDDEN'=>'','TITLE'=>$forum_title,'TEXT'=>$forum_text,'OPTIONS'=>$forum_options)));
$sections->attach(do_template('INSTALLER_STEP_4_SECTION',array('_GUID'=>'15e0f275f78414b6c4fe7775a1cacb23','HIDDEN'=>$hidden,'TITLE'=>$title,'TEXT'=>$text,'OPTIONS'=>$options)));
}
$title=do_lang_tempcode('COOKIE_SETTINGS');
$text=new ocp_tempcode();
$options=new ocp_tempcode();
$hidden=new ocp_tempcode();
$options->attach(make_option(do_lang_tempcode('COOKIE'),example('COOKIE_EXAMPLE','COOKIE_TEXT'),'user_cookie',$member_cookie,false,true));
$options->attach(make_option(do_lang_tempcode('COOKIE_PASSWORD'),example('COOKIE_PASSWORD_EXAMPLE','COOKIE_PASSWORD_TEXT'),'pass_cookie',$pass_cookie,false,true));
$options->attach(make_option(do_lang_tempcode('COOKIE_DOMAIN'),example('COOKIE_DOMAIN_EXAMPLE','COOKIE_DOMAIN_TEXT'),'cookie_domain',$cookie_domain));
$options->attach(make_option(do_lang_tempcode('COOKIE_PATH'),example('COOKIE_PATH_EXAMPLE','COOKIE_PATH_TEXT'),'cookie_path',$cookie_path));
$options->attach(make_option(do_lang_tempcode('COOKIE_DAYS'),example('COOKIE_DAYS_EXAMPLE','COOKIE_DAYS_TEXT'),'cookie_days',$cookie_days,false,true));
$temp=do_template('INSTALLER_STEP_4_SECTION',array('_GUID'=>'3b9ea022164801f4b60780a4a966006f','HIDDEN'=>$hidden,'TITLE'=>$title,'TEXT'=>$text,'OPTIONS'=>$options));
$sections->attach(do_template('INSTALLER_STEP_4_SECTION_HIDE',array('_GUID'=>'42eb3d44bcf8ef99987b6daa9e6530aa','TITLE'=>$title,'CONTENT'=>$temp)));
$js=do_template('JAVASCRIPT');
$js->attach(chr(10));
$js->attach(do_template('JAVASCRIPT_AJAX'));
$message=paragraph(do_lang_tempcode('BASIC_CONFIG'));
if (($forum_type!='none') && ($forum_type!='ocf'))
$message->attach(paragraph(do_lang_tempcode('FORUM_DRIVER_NATIVE_LOGIN')));
return do_template('INSTALLER_STEP_4',array('_GUID'=>'73c3ac0a7108709b74b2e89cae30be12','JS'=>$js,'MESSAGE'=>$message,'LANG'=>$LANG,'DB_TYPE'=>post_param('db_type'),'FORUM_TYPE'=>$forum_type,'BOARD_PATH'=>$board_path,'SECTIONS'=>$sections,'MAX'=>strval(post_param_integer('max',1000))));
}
/**
* Fifth installation step.
*
* @return tempcode Progress report / UI
*/
function step_5()
{
if (count($_POST)==0) exit(do_lang('INST_POST_ERROR'));
if (isset($_POST['table_prefix']))
$_POST['table_prefix']=preg_replace('#[^\w]#','',$_POST['table_prefix']);
if (isset($_POST['ocf_table_prefix']))
$_POST['ocf_table_prefix']=preg_replace('#[^\w]#','',$_POST['ocf_table_prefix']);
if (function_exists('set_time_limit')) @set_time_limit(180);
$url='install.php?step=6';
$use_msn=post_param_integer('use_msn',0);
if ($use_msn==0) $use_msn=post_param_integer('use_multi_db',0);
if ($use_msn==0)
{
$_POST['db_forums']=$_POST['db_site'];
$_POST['db_forums_host']=$_POST['db_site_host'];
$_POST['db_forums_user']=$_POST['db_site_user'];
$_POST['db_forums_password']=$_POST['db_site_password'];
$_POST['ocf_table_prefix']=array_key_exists('table_prefix',$_POST)?$_POST['table_prefix']:'ocp_';
}
// Check cookie settings. IF THIS CODE IS CHANGED ALSO CHANGE COPY&PASTED CODE IN CONFIG_EDITOR.PHP
$cookie_path=post_param('cookie_path');
$cookie_domain=trim(post_param('cookie_domain'));
$base_url=post_param('base_url');
if (substr($base_url,-1)=='/') $base_url=substr($base_url,0,strlen($base_url)-1);
$url_parts=parse_url($base_url);
if (!array_key_exists('host',$url_parts)) $url_parts['host']='localhost';
if (!array_key_exists('path',$url_parts)) $url_parts['path']='';
if (substr($url_parts['path'],-1)!='/') $url_parts['path'].='/';
if (substr($cookie_path,-1)=='/') $cookie_path=substr($cookie_path,0,strlen($cookie_path)-1);
if (($cookie_path!='') && (substr($url_parts['path'],0,strlen($cookie_path)+1)!=$cookie_path.'/'))
{
warn_exit(do_lang_tempcode('COOKIE_PATH_MUST_MATCH',escape_html($url_parts['path'])));
}
if ($cookie_domain!='')
{
if (strpos($url_parts['host'],'.')===false)
{
warn_exit(do_lang_tempcode('COOKIE_DOMAIN_CANT_USE'));
}