forked from sauruscms/Saurus-CMS-Community-Edition
/
install.php
1430 lines (1196 loc) · 38 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
/**
* This source file is is part of Saurus CMS content management software.
* It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php).
* Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/).
* Redistribution of this file must retain the above copyright notice.
*
* Please note that the original authors never thought this would turn out
* such a great piece of software when the work started using Perl in year 2000.
* Due to organic growth, you may find parts of the software being
* a bit (well maybe more than a bit) old fashioned and here's where you can help.
* Good luck and keep your open source minds open!
*
* @package SaurusCMS
* @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/)
* @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php)
*
*/
/**
* Saurus CMS installation and version upgrade script.
* Independent script, not for including, new Site is generated.
*
* Process includes 6 steps:
* 1. display intro +
* + [INSTALL: check config file chmod + EULA agreement]
* + system requirements
* + backwards compability check, warnings
*
* 2. database settings input form
*
* 3. display database settings
* + [INSTALL: write config.php + create Database and user]
* + [UPGRADE: check db user permissions]
* + ask for db dump file
*
* 4. run SQL file(s)
* + [UPGRADE: import language files]
*
* 5. [INSTALL: CMS admin account form]
* + [UPGRADE: run php update-scripts]
* + show configuration table
*
* 6. [INSTALL: save cms admin account]
* + save configuration table data
* + display site links
*
*/
############# GLOBAL
$FDAT = (sizeof($_POST) > 0 ? $_POST : $_GET);
$op = $FDAT["op"];
$install = $FDAT["install"];
# if install.php should show any HTML output or not
$skip_html = false; # default value: false
############# ERRORS - display all errors during installation (none during version upgrade)
if($install || isset($_GET["error_reporting"])) { $display_errors = 0; } ## turn off until Step3 causes db errors
else { $display_errors = 0;}
ini_set('display_errors', $display_errors); // hide or display all errors from screen
# set script execution time to 10 min only if general value is smaller
if ( intval(ini_get('max_execution_time')) < 600 ) {
set_time_limit ( 600 ) ;
}
# memory limit = 24,
if ( intval(ini_get('memory_limit')) < 24 ) {
ini_set ( "memory_limit", "24M" );
}
/***********************************/
/* INCLUDED FILES */
/***********************************/
$class_path = "./classes/";
$is_installation_script = true; # needed for error display handling in core
include_once($class_path."port.inc.php");
include_once($class_path."nodebug.inc.php");
include_once($class_path."install.inc.php"); # all installation related functions
# set error display second time - to override settings in port.inc.php
ini_set('display_errors', $display_errors); // hide or display all errors from screen
############# CONF
$CONF = ReadConf(); # db connect data from config.php
############# VERSION CHECK
$current_ver = current_version(); # try to connect database and find which version is installed returns 0, if no database found
############# VERSION NUMBERS
# version numbers // the CE version can only be update'd from a 4.6.6 version
$versions = array();
array_push($versions, '4.6.6');
array_push($versions, '4.7.0');
##############################
# get the new version number
$new_ver = end($versions);
# kui esileht ja current versiooni ei leitud, siis järelikult install
if (!$current_ver && !$install) {
$install = 1;
}
$step_count = 6;
$error_file = "install_errors.txt";
$url = site_url();
##########################
# default_data_files
$default_data_files = array();
if ($install) { # install
array_push($default_data_files, "install/default_db.sql");
}
else { # update
// scrub EE licensing and commercial modules (not used on CE)
$default_data_files[] = 'admin/updates/updateEEtoCE.sql';
$i = 1;
foreach ($versions as $version_array_index => $tmpver)
{
$next = $versions[$version_array_index + 1];
# if not current version yet, go to next ver
# jooksev ver <= installitav ver
if (strnatcmp($current_ver, $tmpver) <= 0) {
# if overinstalling same ver, then go back in versions
# jooksev ver = installitav ver
if (strnatcmp($current_ver,$new_ver)==0) {
array_push($default_data_files, "admin/updates/update".$versions[$i-2]."to".$tmpver.".sql");
}
# usual case
else {
array_push($default_data_files, "admin/updates/update".$tmpver."to".$next.".sql");
}
}
$i++;
} # foreach
# remove last element if not repairing/overinstalling same version
if (strnatcmp($current_ver,$new_ver) != 0) {
array_pop($default_data_files);
}
}
############# leia saidi default keele encoding ja kasuta seda siin lehel (Bug #1854)
if(!$install){
# otsida välja default keel:
$sqlK = "SELECT encoding FROM keel WHERE on_default = '1'";
$sthK = new SQL($sqlK);
$encoding = $sthK->fetchsingle();
}
## new install: default encoding is UTF-8 (Bug #2225)
$encoding = $encoding ? $encoding : 'UTF-8';
/***********************************/
/* HTML START */
/***********************************/
if( ! $skip_html) { # display HTML output
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Saurus CMS CE <?=($install?"Installation":"Update")." ".$new_ver?></title>
<meta name="author" content="Saurus - www.saurus.info">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=<?=$encoding?>">
<link rel="stylesheet" href="styles/default/scms_general.css">
<link rel="stylesheet" href="styles/default/scms_install.css">
</head>
<body>
<center>
<?
######################
# header tabel, logo
$step_nr = substr(strtolower($op?$op:"step1"),-1);
?>
<div id="installheader">
<table width="750">
<tr>
<td valign="bottom"><h1>Saurus CMS CE <?=$new_ver." ".($install?"Installation":"Update")?>: Step <?=$step_nr?> of 6</h1></td>
<td align="right"><img class="logo" src="styles/default/gfx/install/logo.gif" height="20" width="101" alt="Saurus" /></td>
</tr>
</table>
</div>
<?
######################
# wizard
?>
<!-- Scrollable area -->
<div id="listing" class="scms_scroll_div">
<?
} # if display HTML output
/***********************************/
/* STEPS START */
/***********************************/
//$op = 'Step5';
switch(@$op) {
case "Step2":
/**************************
STEP 2
INSTALL:
- ask db connect info
UPDATE:
- ask db user info with all privileges
***************************/
?>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font class="txt">
<?
#########################
# if INSTALL step2
if ($install) {
?>
<?
######################
# sisutabel
?>
<h2>Database</h2>
<form action="install.php" method="POST" name="form" style="margin-top: 25px;">
<p>
<input type="radio" name="mysql_root" id="mysql_root0" value="0" checked onclick="document.getElementById('dbRootAccess').style.display='none';">
<label for="mysql_root0"><strong>Use existing database</strong>. I have user account with nescessary permissions to connect and create tables.</label>
</p>
<p>
<input type="radio" name="mysql_root" id="mysql_root1" value="1" onclick="form.create_user.checked=true; document.getElementById('dbRootAccess').style.display='block';">
<label for="mysql_root1"><strong>Create new database</strong>. I have root access to the database server.</label>
<table id="dbRootAccess" style="display: none; margin: 5px 0 5px 30px;" border="0" width="300">
<tr>
<td></td>
<td align="left">Database root username</td>
<td><input type="text" NAME="dbrootname" maxlength=80 value="root"></td>
</tr>
<tr>
<td></td>
<td align="left">Database root password</td>
<td><input type="password" NAME="dbrootpass" maxlength=80 value=""></td>
</tr>
<tr>
<td></td>
<td colspan=2 align="left"><input type="checkbox" name="create_user" id="create_user" value="1" checked><label for="create_user">Create a new database user for database connection</label>
</table>
</p>
<?php print_dbdata_editabletext() ?>
<p>Next step will write database connection parameters into the file "config.php". Please check that you have entered valid information before continuing.</p>
<center>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='';document.form.submit();" class="redbutton">
<INPUT type="submit" value="Next" class="redbutton">
<INPUT type="hidden" name="op" id="op" value="Step3">
<INPUT type="hidden" name="install" value="1">
</center>
</form>
<?
}
# / if INSTALL step2
#########################
#########################
# if UPDATE step2
else {
?>
<h2>Database</h2>
<form action="install.php" method="post" name="form">
Full access to database "<?=$CONF["db"]?>" is needed to update table structures. Click Next if user "<?=$CONF["db"]?>" has appropriate privileges or specify another account.
<br /><br />
<table border="0" width="750">
<tr>
<td align="left">Database host</td>
<td align="left"><?=$CONF[dbhost];?></td>
</tr>
<tr>
<td align="left">Database port</td>
<td align="left"><?=$CONF[dbport];?></td>
</tr>
<tr>
<td align="left">Database name</td>
<td align="left"><?=$CONF[db];?></td>
</tr>
<tr>
<td align="left">Database user name</td>
<td><input type="text" NAME="update_user" SIZE=30 maxlength=80 value="<?=$CONF[user];?>"></td>
</tr>
<tr>
<td align="left">Database user password</td>
<td><input type="password" NAME="update_passwd" SIZE=30 maxlength=80 value="<?=$CONF[passwd];?>"></td>
</tr>
<tr>
<td align="left">Database type</td>
<td align="left"><?=$CONF[dbtype];?></td>
</tr>
</table>
<br />
<center>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='';document.form.submit();" class="redbutton">
<INPUT type="submit" value="Next" class="redbutton">
<INPUT type="hidden" name="op" id="op" value="Step3">
</center>
</form>
<br />
<?
}
# / if UPDATE step2
#########################
?>
</font>
</td>
</tr>
</table>
<? break;
case "Step3":
/**************************
STEP 3
INSTALL:
- write db connect data into config file
- show db connect data
- if root: create db and user
- if no root: check if db exists
- ask db dump file
UPDATE:
- show db connect data
- check user privileges CREATE, DROP, ALTER, INDEX
- if not OK, show error
- if OK, ask for db dump file
***************************/
?>
<table width="750" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font class="txt">
<?
#########################
# if INSTALL step3
if ($install) {
?>
<h2>Database info confirmation</h2>
<form action="install.php" method="post" name="form" enctype="multipart/form-data">
<?/*** write db connect data into config file ***/?>
Database connection parameters were saved into file:
<?
$conf_update_result = update_config_php($FDAT["dbhost"], $FDAT["dbport"], $FDAT["db"], $FDAT["dbtype"], $FDAT["user"], $FDAT["passwd"]);
if (preg_match("/Error/", $conf_update_result)) {
echo '<font color="red">';
echo($conf_update_result);
echo '</font>';
?>
<br /><br />
<INPUT type="button" value="Back" onclick="javascript:document.getElementById('op').value='Step2';document.form.submit();" class="redbutton">
<?
}
else {
echo($conf_update_result);
# read CONF again because file was modified
$CONF = ReadConf();
/*** end: write db connect data into config file ***/
?>
<br />
<br />
<?/*** show db connect data ***/?>
<? print_dbdata_text() ?>
<br />
<?
/*** end: show db connect data ***/
######################
# connect to database
if ($FDAT["mysql_root"] == 1) {
// connect to database as root
$conn = 0;
dbconnect(1, $FDAT["dbrootname"], $FDAT["dbrootpass"], '');
}
else {
// search for database
$db_found = check_db();
}
######################
# if connect error
if ($conn->error) {
?>
<font color=red>Error: <?=$conn->error?></font>
<INPUT type="button" value="Back" onclick="javascript:document.getElementById('op').value='Step2';document.form.submit();" class="redbutton">
<INPUT type="hidden" name="mysql_root" value="<?=$FDAT["mysql_root"] ?>">
<br />
<?
}
######################
# go on
else {
######################
# if root access to database
if ($FDAT["mysql_root"] ) {
##################
# create database
$db_created = make_db();
if ($db_created) { ?>
Database "<?=$CONF["db"] ?>" is created.
<? } else { ?>
Database "<?=$CONF["db"] ?>" already exists. Database has not been created.
<? }
##################
# if create user
if ($FDAT["create_user"]) {
$user_created = make_user();
if ($user_created) { ?>
<br />
User "<?=$CONF["user"] ?>" for database "<?=$CONF["db"] ?>" is created.
<? } else { ?>
<br />
User "<?=$CONF["user"] ?>" already exists. User has not been created. Be sure that this user has access to database "<?=$CONF["db"] ?>"!
<? } ?>
<? }
######################
# if no root access to database
} else {
# 1. db found, but user access error
if ($conn->error) {
?>
<font color=red>Error: <?=$conn->error?></font>
<INPUT type="button" value="Back" onclick="javascript:document.getElementById('op').value='Step2';document.form.submit();" class="redbutton">
<INPUT type="hidden" name="mysql_root" value="<?=$FDAT["mysql_root"] ?>">
<br />
<?
}
# 2. db found, all OK
else if ($db_found) {
?>
Database "<?=$CONF["db"] ?>" found.
<?
# 3. db not found, error, diplay back button
} else {
?>
Database "<?=$CONF["db"] ?>" not found. Please create a new database before continuing.
<br />
<INPUT type="button" value="Back" onclick="javascript:document.getElementById('op').value='Step2';document.form.submit();" class="redbutton">
<INPUT type="hidden" name="mysql_root" value="<?=$FDAT["mysql_root"] ?>">
<br />
<?
} # conn
}
/*** end: if root access to database ***/
## OK message
if ($FDAT["mysql_root"] || $db_found) {
?>
<p>In next step, the database will be updated using default SQL definitions at <br>
<?=join(", ",$default_data_files)?></p>
<p>Advanced users may select a custom SQL file:<br>
<input type="file" NAME="data_file"></p>
<center>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='Step2';document.form.submit();" class="redbutton">
<INPUT type="submit" value="Next" class="redbutton">
</center>
<?
} # OK message
}
# if not db connect error
######################
} # config.php udpate OK
?>
<INPUT type="hidden" name="update_user" value="<?=$CONF["user"] ?>">
<INPUT type="hidden" name="update_passwd" value="<?=$CONF["passwd"] ?>">
<INPUT type="hidden" name="op" id="op" value="Step4">
<INPUT type="hidden" name="install" value="1">
</form>
<br />
<?
}
# / if INSTALL step3
#########################
#########################
# if UPDATE step3
/*
UPDATE:
- show db connect data
- check user privileges CREATE, DROP, ALTER, INDEX
- if not OK, show error
- if OK, ask for db dump file
*/
else {
?>
<h2>Database info confirmation</h2>
<table border="0" width="400">
<tr>
<td align="left">Database host</td>
<td align="left"><?=$CONF[dbhost];?></td>
</tr>
<tr>
<td align="left">Database port</td>
<td align="left"><?=$CONF[dbport];?></td>
</tr>
<tr>
<td align="left">Database name</td>
<td align="left"><?=$CONF[db];?></td>
</tr>
<tr>
<td align="left">Database user name</td>
<td><?=$FDAT["update_user"];?></td>
</tr>
<tr>
<td align="left">Database user password</td>
<td><?=$FDAT["update_passwd"];?></td>
</tr>
<tr>
<td align="left">Database type</td>
<td align="left"><?=$CONF[dbtype];?></td>
</tr>
</table>
<?
# check if user has all privileges
# $error = check_allpriv($FDAT["update_user"],$FDAT["update_passwd"]);
$error = 0;
if ($error) {
?>
<br /><br /><font color=red><?=$error?></font>
<br />
<form action="install.php" method="post" name="form">
<center>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='Step2';document.form.submit();" class="redbutton">
</center>
<INPUT type="hidden" name="op" id="op" value="Step4">
</form>
<? } else { ?>
<form action="install.php" method="post" name="form" enctype="multipart/form-data">
<br />
<br />
The database will be updated using default SQL file (<?=join(", ",$default_data_files)?>).<br />If you have a custom SQL file, select it here:<br />
<input type="file" NAME="data_file">
<INPUT type="hidden" name="op" id="op" value="Step4">
<INPUT type="hidden" name="update_user" value="<?=$FDAT["update_user"]?>">
<INPUT type="hidden" name="update_passwd" value="<?=$FDAT["update_passwd"]?>">
<br />
<br />
<center>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='Step2';document.form.submit();" class="redbutton">
<INPUT type="submit" value="Next" class="redbutton">
</center>
</form>
<?
}
}
# / if UPDATE step3
#########################
?>
</font>
</td>
</tr>
</table>
<?
break;
case "Step4":
/**************************
STEP 4
INSTALL:
- create tables
UPDATE:
- run sql files
- import language files
***************************/
#########################
# if INSTALL step4
if ($install) {
?>
<h2>Updating Database</h2>
<form action="install.php" method="post" name="form">
<?
if (!$FDAT["dont_make_db"]) {
$tbl_error = run_dumpfile();
}
?>
<?
if ($tbl_error != '') {
?>
<font color="red">
<?=$tbl_error?>
<br />Error, tables have not been created.</font>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='Step3';document.form.submit();" class="redbutton">
<?
print_dbdata_hidden();
} else if ($FDAT["dont_make_db"]) {
?>
<font color="red">
<br />Tables have not been created.</font>
<?
} else {
?>
<p>Tables for database "<?=$CONF["db"] ?>" have been created.</p>
<?
} # tbl error
?>
<center>
<p><input type="submit" value="Next" class="redbutton"></p>
</center>
<input type="hidden" name="op" id="op" value="Step5">
<input type="hidden" name="install" value="1">
</form>
<?
}
# / if INSTALL step4
#########################
#########################
# if UPDATE step4
else {
?>
<h2>Updating Database</h2>
<font class="txt">
<form action="install.php" method="post" name="form">
<?
###############
# run sql
$upd_error = run_dumpfile();
?>
<table width="580" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font class="txt">
<?
if ($upd_error != '') { ?>
<font color="red">
<br />Fatal error occured during updating database "<?=$CONF["db"] ?>"!</font>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='Step3';document.form.submit();" class="redbutton">
<? } else {
?>
Database "<?=$CONF["db"] ?>" update finished.<br>
<?
flush();usleep(500000);
?>
</font>
</td>
</tr>
</table>
<br />
<font class="txt">
<?
###############
# lang file import: importida ainult need keeled, mis saidis aktiivsed
# 0 - Estonian, 1 - English
$default_languages = array('0','1');
# get languages in use
$sqlK = "select distinct b.glossary_id as keel_id, b.encoding as encoding from keel as a left join keel as b on a.keel_id = b.glossary_id where b.on_kasutusel = '1'";
$sthK = new SQL($sqlK);
###############
# loop over active languages
while ($keel = $sthK->fetch()) {
# check if it is default language?
if(!in_array($keel['keel_id'], $default_languages)) {
continue;
}
# get site encoding, default is UTF-8 if not set
$lang_encoding = $keel['encoding'] ? strtoupper($keel['encoding']) : "UTF-8";
# file = admin/updates/language0.csv
$file = "admin/updates/".$lang_encoding."/language".$keel['keel_id'].".csv";
# kui leidub selle keele keelefail
if(file_exists($file)) {
echo "Importing file '".$file."'...";
echo "<script>document.getElementById('listing').scrollTop = document.getElementById('listing').scrollHeight - 500;</script>";
flush();usleep(500000);
$one_lang_error = import_langfile($file,$keel);
if(!$one_lang_error) { # import OK
$lang_error .= $one_lang_error;
echo " Done.<br>";
}
echo "<script>document.getElementById('listing').scrollTop = document.getElementById('listing').scrollHeight - 500;</script>";
flush();usleep(500000);
}
}
# / loop over active languages
###############
?>
<br />
<table width=600 border=0 cellspacing=0 cellpadding=0><tr><td><font class=txt>
<?###### language result #######?>
<? if ($lang_error != '') { ?>
<font color="red">
<?=$lang_error?>
<br />Fatal error occured during importing language files into database "<?=$CONF["db"] ?>"!</font>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='Step3';document.form.submit();" class="redbutton">
<? } else {
echo "Glossary import finished.";
} # if import language files ok
?>
</font></td></tr></table>
<?
##################
# next nupp
?>
<br /><br />
<center>
<INPUT type="submit" value="Next" class="redbutton">
</center>
<INPUT type="hidden" name="op" id="op" value="Step5">
</form>
<script>document.getElementById('listing').scrollTop = document.getElementById('listing').scrollHeight - 500;</script>
<?
} # if run sql ok
}
# / if UPDATE step4
#########################
break;
case "Step5":
/**************************
STEP 5
INSTALL
- CMS admin account form
- show configuration table
- poll free
UPDATE
- run php update-scripts
- save new templates info into db
- show configuration table
***************************/
?>
<table width="580" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font class="txt">
<?
#########################
# if INSTALL step5
if ($install) {
?>
<h2>Site Settings</h2>
<form action="install.php" method="post" name="form">
<?
// connect to database
if (!$conn) { dbconnect(0, '', '', ''); }
?>
<p>Please create user account for logging in to Saurus CMS. You can not use "saurus" for password.</p>
<?
// read the other config data from config table
$CONFDB = ReadConfDB();
###################
# if table config doesn't exist at all
if (!$CONFDB) {
?>
Table "config" not found!
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='Step4';document.form.submit();" class="redbutton">
<? }
###################
# go on
else {
#####################
# ask admin login access
?>
<table border="0">
<tr>
<td align="left">Username</td>
<td><input type="text" NAME="admin" SIZE=30 maxlength=80 value="admin"></td>
<td></td>
</tr>
<tr><td align="left">Name</td>
<td><input type="text" NAME="adminname" SIZE=30 maxlength=80 value="Default "></td>
<td></td>
</tr>
<tr><td align="left">Password</td>
<td><input type="password" NAME="adminpasswd" SIZE=30 maxlength=80 value=""></td>
<td></td>
</tr>
<tr><td align="left">Password confirmation</td>
<td><input type="password" NAME="adminpasswd_check" SIZE=30 maxlength=80 value=""></td>
<td></td>
</tr>
</table>
<br />
<?
#####################
# print config rows
?>
<table width="580" border=0>
<?
# create new site for config script
include_once($class_path.'port.inc.php');
$site = new Site(array(
'on_debug' => ($_COOKIE['debug'] ? 1:0),
'on_admin_keel' => 1
));
include_once("admin/change_config.php");
print_config_table();
$site->site_polling(2); // poll Saurus for site stats
?>
</table>
<br />
<br />
<center>
<INPUT type="button" value="Previous" onclick="javascript:document.getElementById('op').value='Step4';document.form.submit();" class="redbutton">
<INPUT type="submit" value="Next" class="redbutton">
<?
} # if config tabelit pole olemas
?>
<INPUT type="hidden" name="op" id="op" value="Step6">
<INPUT type="hidden" name="install" value="1">
<INPUT type="hidden" name="dont_make_db" value="1">
</form>
</center>
<?
}
# / if INSTALL step5
#########################
#########################
# if UPDATE step5
else {
?>
<h2>Site Settings</h2>
<br />
<form action="install.php" method="post" name="form">
<table border="0" cellspacing="0" cellpadding="3" width="580">
<?
#####################
# connect to database
if (!$conn) { dbconnect(0, '', '', ''); }
#####################
# print config rows
include_once("admin/change_config.php");
print_config_table();
?>
</table>
<br />
<center>
<INPUT type="submit" value="Next" class="redbutton">
<INPUT type="hidden" name="op" id="op" value="Step6">
</form>
</center>
<?
}
# / if UPDATE step5
#########################
?>
</font>
</td>
</tr>
</table>
<?
break;
/**************************
STEP 6
INSTALL
- save cms admin account
- save configuration table data
UPGRADE
- save configuration table data
***************************/
case "Step6":
?>
<table width="580" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font class="txt">
<form action="install.php" method="post" name="form">
<?
#########################
# if INSTALL step6
if ($install) {
set_hostname_wwwroot($_SERVER['HTTP_HOST'].str_replace('install.php', '', $_SERVER['REQUEST_URI']));