-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathinstall.php
1287 lines (1179 loc) · 53.4 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
// Single Sign-On Server
// (C) 2017 CubicleSoft. All Rights Reserved.
if (file_exists("config.php")) exit();
require_once "support/debug.php";
require_once "support/str_basics.php";
require_once "support/page_basics.php";
require_once "support/sso_functions.php";
require_once "support/utf8.php";
require_once "support/smtp.php";
require_once "support/pop3.php";
require_once "support/random.php";
require_once "support/csdb/db.php";
SetDebugLevel();
Str::ProcessAllInput();
// Only allow secure database products to be used except on localhost by default.
// Can be overridden with an installation hook BUT please know exactly what you are doing before doing so.
$allowinsecuredatabases = ($_SERVER["REMOTE_ADDR"] == "127.0.0.1" || $_SERVER["REMOTE_ADDR"] == "::1");
// Allow developers to inject code here. For example, IP address restriction logic or a SSO bypass.
if (file_exists("install_hook.php")) require_once "install_hook.php";
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "checklist")
{
?>
<table align="center">
<tr class="head"><th>Test</th><th>Passed?</th></tr>
<tr class="row">
<td>PHP 5.6.x or later</td>
<td align="right">
<?php
if ((double)phpversion() < 5.6) echo "<span class=\"error\">No</span><br /><br />The server is running PHP " . phpversion() . ". The installation may succeed but the rest of the Single Sign-On Server will be broken. You will be unable to use this product. Running outdated versions of PHP poses a serious website security risk. Please contact your system administrator to upgrade your PHP installation.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row">
<td>Able to create files in ./</td>
<td align="right">
<?php
if (file_put_contents("test.dat", "a") === false) echo "<span class=\"error\">No</span><br /><br />chmod 777 on the directory may fix the problem.";
else if (!unlink("test.dat")) echo "<span class=\"error\">No</span><br /><br />Unable to delete test file. chmod 777 on the directory may fix the problem.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row altrow">
<td>Able to create directories in ./</td>
<td align="right">
<?php
if (!mkdir("test")) echo "<span class=\"error\">No</span><br /><br />chmod 777 on the directory may fix the problem.";
else if (!rmdir("test")) echo "<span class=\"error\">No</span><br /><br />Unable to delete test directory. chmod 777 on the parent directory may fix the problem.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row">
<td>No './index.html'</td>
<td align="right">
<?php
if (file_exists("index.html")) echo "<span class=\"error\">No</span><br /><br />Depending on server settings, 'index.html' may interfere with the proper operation of Single Sign-On Server.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row altrow">
<td>Endpoint './endpoint.php' exists</td>
<td align="right">
<?php
if (!file_exists("endpoint.php")) echo "<span class=\"error\">No</span><br /><br />'endpoint.php' does not exist on the server. Installation will fail.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row">
<td>Admin './admin.php' exists</td>
<td align="right">
<?php
if (!file_exists("admin.php")) echo "<span class=\"error\">No</span><br /><br />'admin.php' does not exist on the server. Installation will fail.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row">
<td>No './settings.php'</td>
<td align="right">
<?php
if (file_exists("settings.php")) echo "<span class=\"error\">No</span><br /><br />'settings.php' will be overwritten upon install.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row altrow">
<td>$_SERVER["REQUEST_URI"] supported</td>
<td align="right">
<?php
if (!isset($_SERVER["REQUEST_URI"])) echo "<span class=\"error\">No</span><br /><br />Server does not support this feature. The installation may fail and the site might not work.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row altrow">
<td>Installation over SSL</td>
<td align="right">
<?php
if (!BB_IsSSLRequest()) echo "<span class=\"error\">No</span><br /><br />While Single Sign-On Server will install and run without using HTTPS/SSL, think about the implications of network sniffing access tokens, who will have access to the system, and what they can do in the system. SSL certificates can be obtained for free. Proceed only if this major security risk is acceptable.";
else echo "<span class=\"success\">Yes</span>";
?>
</td>
</tr>
<tr class="row">
<td>Crypto-safe CSPRNG available</td>
<td align="right">
<?php
try
{
$rng = new CSPRNG(true);
echo "<span class=\"success\">Yes</span>";
}
catch (Exception $e)
{
echo "<span class=\"error\">No</span><br /><br />Installation will fail. Please ask your system administrator to install a supported PHP extension (e.g. OpenSSL, Mcrypt).";
}
?>
</td>
</tr>
<tr class="head">
<th>Supported PHP functions/classes</th>
<th> </th>
</tr>
<?php
$functions = array(
"fsockopen" => "Web/e-mail automation/validation functions",
"json_encode" => "JSON encoding support functions",
"openssl_open" => "OpenSSL extension support",
);
$x = 0;
foreach ($functions as $function => $info)
{
echo "<tr class=\"row" . ($x % 2 ? " altrow" : "") . "\"><td>" . htmlspecialchars($function) . "</td><td align=\"right\">" . (function_exists($function) ? "<span class=\"success\">Yes</span>" : "<span class=\"error\">No</span><br /><br />Single Sign-On Server will be unable to use " . $info . ". The installation might succeed but the product will not function at all or have terrible performance.") . "</td></tr>\n";
$x++;
}
$classes = array(
"PDO" => "PDO database class",
);
foreach ($classes as $class => $info)
{
echo "<tr class=\"row" . ($x % 2 ? " altrow" : "") . "\"><td>" . htmlspecialchars($class) . "</td><td align=\"right\">" . (class_exists($class) ? "<span class=\"success\">Yes</span>" : "<span class=\"error\">No</span><br /><br />Single Sign-On Server will be unable to use " . $info . ". The installation might succeed but the product will not function at all or have terrible performance.") . "</td></tr>\n";
$x++;
}
?>
</table>
<?php
}
else if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "dbtest")
{
$databases = SSO_GetSupportedDatabases();
$type = (string)$_REQUEST["type"];
if (!isset($databases[$type]))
{
echo "<span class=\"error\">Please select a database server.</span>";
exit();
}
if ($_REQUEST["dsn"] == "")
{
$rng = new CSPRNG(true);
$dsn = $databases[$type]["default_dsn"];
$dsn = str_replace("@RANDOM@", $rng->GenerateString(), $dsn);
$dsn = str_replace("@PATH@", str_replace("\\", "/", dirname(__FILE__)), $dsn);
$_REQUEST["dsn"] = $dsn;
}
require_once "support/csdb/db_" . $type . ".php";
$classname = "CSDB_" . $type;
try
{
$db = new $classname();
$db->SetDebug(true);
$db->Connect($type . ":" . $_REQUEST["dsn"], ($databases[$type]["login"] ? $_REQUEST["user"] : false), ($databases[$type]["login"] ? $_REQUEST["pass"] : false));
echo "<span class=\"success\">Successfully connected to the server.</span><br /><b>Running " . htmlspecialchars($db->GetDisplayName() . " " . $db->GetVersion()) . "</b>";
unset($db);
}
catch (Exception $e)
{
echo "<span class=\"error\">Database connection attempt failed.</span><br />" . htmlspecialchars($e->getMessage());
}
if ($databases[$type]["replication"] && $_REQUEST["master_dsn"] != "")
{
try
{
$db = new $classname();
$db->SetDebug(true);
$db->Connect($type . ":" . $_REQUEST["master_dsn"], ($databases[$type]["login"] ? $_REQUEST["master_user"] : false), ($databases[$type]["login"] ? $_REQUEST["master_pass"] : false));
echo "<span class=\"success\">Successfully connected to the replication master server.</span><br /><b>Running " . htmlspecialchars($db->GetDisplayName() . " " . $db->GetVersion()) . "</b>";
unset($db);
}
catch (Exception $e)
{
echo "<span class=\"error\">Replication master connection attempt failed.</span><br />" . htmlspecialchars($e->getMessage());
}
}
}
else if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "emailtest")
{
$smtpserver = explode(":", trim($_REQUEST["smtpserver"]));
if (count($smtpserver) == 2)
{
$smtpport = $smtpserver[1];
$smtpserver = $smtpserver[0];
}
else
{
$smtpserver = trim($_REQUEST["smtpserver"]);
$smtpport = 25;
}
$pop3server = explode(":", trim($_REQUEST["pop3server"]));
if (count($pop3server) == 2)
{
$pop3port = $pop3server[1];
$pop3server = $pop3server[0];
}
else
{
$pop3server = trim($_REQUEST["pop3server"]);
$pop3port = 110;
}
$message = <<<EOF
<html><body>Hello,<br>
<br>
This is the Single Sign-On (SSO) Server installer test e-mail.<br>
<br>
Thank you for using SSO Server.
</body></html>
EOF;
$headers = SMTP::GetUserAgent("Thunderbird");
$smtpsent = false;
if ($smtpserver != "" && $_REQUEST["from"] != "" && $_REQUEST["to"] != "")
{
$smtpoptions = array(
"headers" => $headers,
"textmessage" => strip_tags($message),
"htmlmessage" => $message,
"server" => $smtpserver,
"port" => $smtpport,
"secure" => ($smtpport == 465),
"username" => $_REQUEST["user"],
"password" => $_REQUEST["pass"]
);
$result = SMTP::SendEmail($_REQUEST["from"], $_REQUEST["to"], "[SSO Server] Installer Test Message", $smtpoptions);
if (!$result["success"])
{
echo "<span class=\"error\">Failed to connect to the SMTP server. " . htmlspecialchars($result["error"]) . (isset($result["info"]) ? " (" . htmlspecialchars($result["info"]) . ")" : "") . "</span><br />";
}
else
{
echo "<span class=\"success\">Successfully connected to the SMTP server and sent the test message.</span><br />";
$smtpsent = true;
}
}
else if ($smtpserver == "") echo "<span class=\"error\">SMTP: 'SMTP Server' field not filled in.</span><br />";
else if ($_REQUEST["from"] == "") echo "<span class=\"error\">SMTP: 'Default E-mail Address' field not filled in.</span><br />";
else if ($_REQUEST["to"] == "") echo "<span class=\"error\">SMTP: 'Send To' field not filled in.</span><br />";
$pop3valid = false;
if ($pop3server != "" && $_REQUEST["user"] != "" && $_REQUEST["pass"] != "")
{
$pop3options = array(
"server" => $pop3server,
"port" => $pop3port,
"secure" => ($pop3port == 995)
);
$temppop3 = new POP3;
$result = $temppop3->Connect($_REQUEST["user"], $_REQUEST["pass"], $pop3options);
if (!$result["success"])
{
echo "<span class=\"error\">Failed to connect to the POP3 server. " . htmlspecialchars($result["error"]) . (isset($result["info"]) ? " (" . htmlspecialchars($result["info"]) . ")" : "") . "</span><br />";
}
else
{
echo "<span class=\"success\">Successfully connected to the POP3 server.</span><br />";
$temppop3->Disconnect();
$pop3valid = true;
}
}
else if ($pop3server == "") echo "<span class=\"error\">POP3: 'POP3 Server' field not filled in.</span><br />";
else if ($_REQUEST["user"] == "") echo "<span class=\"error\">POP3: 'Username' field not filled in.</span><br />";
else if ($_REQUEST["pass"] == "") echo "<span class=\"error\">POP3: 'Password' field not filled in.</span><br />";
// Test SMTP again if POP3 succeeded.
if ($pop3valid && !$smtpsent)
{
if ($smtpserver != "" && $_REQUEST["from"] != "" && $_REQUEST["to"] != "")
{
$result = SMTP::SendEmail($_REQUEST["from"], $_REQUEST["to"], "[SSO Server] Installer Test Message", $smtpoptions);
if (!$result["success"])
{
echo "<span class=\"error\">Failed to connect to the SMTP server. " . htmlspecialchars($result["error"]) . (isset($result["info"]) ? " (" . htmlspecialchars($result["info"]) . ")" : "") . "</span><br />";
}
else
{
echo "<span class=\"success\">Successfully connected to the SMTP server.</span><br />";
$smtpsent = true;
}
}
}
}
else if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "install")
{
function InstallError($message)
{
echo "<span class=\"error\">" . $message . " Click 'Prev' below to go back and correct the problem.</span>";
echo "<script type=\"text/javascript\">InstallFailed();</script>";
exit();
}
function InstallWarning($message)
{
echo "<span class=\"warning\">" . $message . "</span><br />";
flush();
}
function InstallSuccess($message)
{
echo "<span class=\"success\">" . $message . "</span><br />";
flush();
}
// Set up page-level calculation variables.
define("SSO_ROOT_PATH", str_replace("\\", "/", dirname(__FILE__)));
$url = str_replace("\\", "/", dirname(BB_GetRequestURLBase()));
if (substr($url, -1) == "/") $url = substr($url, 0, -1);
define("SSO_ROOT_URL", $url);
$url = dirname(BB_GetFullRequestURLBase());
if (substr($url, -1) != "/") $url .= "/";
define("SSO_LOGIN_URL", $url);
define("SSO_SUPPORT_PATH", "support");
define("SSO_PROVIDER_PATH", "providers");
// Generate random seeds.
$rng = new CSPRNG(true);
$sso_rng = $rng;
for ($x = 0; $x < 14; $x++)
{
$seed = $rng->GenerateToken(128);
if ($seed === false) InstallError("Seed generation failed.");
define("SSO_BASE_RAND_SEED" . ($x ? $x + 1 : ""), $seed);
}
define("SSO_USE_LESS_SAFE_STORAGE", $_REQUEST["sso_use_less_safe_storage"] == "yes");
// Connect to the database server.
$databases = SSO_GetSupportedDatabases();
$dbtype = (string)$_REQUEST["db_select"];
if (!isset($databases[$dbtype])) InstallError("Please select a database server.");
if ($_REQUEST["db_dsn"] == "")
{
$dsn = $databases[$dbtype]["default_dsn"];
$dsn = str_replace("@RANDOM@", $rng->GenerateString(), $dsn);
$dsn = str_replace("@PATH@", str_replace("\\", "/", dirname(__FILE__)), $dsn);
$_REQUEST["db_dsn"] = $dsn;
}
require_once "support/csdb/db_" . $dbtype . ".php";
$dbclassname = "CSDB_" . $dbtype;
try
{
$db = new $dbclassname($dbtype . ":" . $_REQUEST["db_dsn"], ($databases[$dbtype]["login"] ? $_REQUEST["db_user"] : false), ($databases[$dbtype]["login"] ? $_REQUEST["db_pass"] : false));
if ($_REQUEST["db_master_dsn"] != "") $db->SetMaster($dbtype . ":" . $_REQUEST["db_master_dsn"], ($databases[$dbtype]["login"] ? $_REQUEST["db_master_user"] : false), ($databases[$dbtype]["login"] ? $_REQUEST["db_master_pass"] : false));
}
catch (Exception $e)
{
InstallError("Database connection failed. " . htmlspecialchars($e->getMessage()));
}
try
{
InstallSuccess("Successfully connected to the database server. Running " . htmlspecialchars($db->GetDisplayName() . " " . $db->GetVersion()));
}
catch (Exception $e)
{
InstallError("Database connection succeeded but unable to get server version. " . htmlspecialchars($e->getMessage()));
}
// Create/Use the SSO database.
try
{
$db->Query("USE", $_REQUEST["db_name"]);
}
catch (Exception $e)
{
try
{
$db->Query("CREATE DATABASE", array($_REQUEST["db_name"], "CHARACTER SET" => "utf8", "COLLATE" => "utf8_general_ci"));
$db->Query("USE", $_REQUEST["db_name"]);
}
catch (Exception $e)
{
InstallError("Unable to create/use database '" . htmlspecialchars($_REQUEST["db_name"]) . "'. " . htmlspecialchars($e->getMessage()));
}
}
InstallSuccess("Successfully created and selected database '" . htmlspecialchars($_REQUEST["db_name"]) . "'.");
// Create SSO database tables.
$dbprefix = $_REQUEST["db_sso_prefix"];
$sso_db_apikeys = $dbprefix . "apikeys";
$sso_db_fields = $dbprefix . "fields";
$sso_db_users = $dbprefix . "users";
$sso_db_user_tags = $dbprefix . "user_tags";
$sso_db_user_sessions = $dbprefix . "user_sessions";
$sso_db_temp_sessions = $dbprefix . "temp_sessions";
$sso_db_tags = $dbprefix . "tags";
$sso_db_ipcache = $dbprefix . "ipcache";
try
{
$apikeysfound = $db->TableExists($sso_db_apikeys);
$fieldsfound = $db->TableExists($sso_db_fields);
$usersfound = $db->TableExists($sso_db_users);
$usertagsfound = $db->TableExists($sso_db_user_tags);
$usersessionsfound = $db->TableExists($sso_db_user_sessions);
$tempsessionsfound = $db->TableExists($sso_db_temp_sessions);
$tagsfound = $db->TableExists($sso_db_tags);
$ipcachefound = $db->TableExists($sso_db_ipcache);
}
catch (Exception $e)
{
InstallError("Unable to determine the existence of a database table. " . htmlspecialchars($e->getMessage()));
}
if (!$apikeysfound)
{
try
{
$db->Query("CREATE TABLE", array($sso_db_apikeys, array(
"id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true, "PRIMARY KEY" => true, "AUTO INCREMENT" => true),
"user_id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true),
"namespace" => array("STRING", 1, 20, "NOT NULL" => true),
"apikey" => array("STRING", 1, 64, "NOT NULL" => true),
"created" => array("DATETIME", "NOT NULL" => true),
"info" => array("STRING", 3, "NOT NULL" => true),
),
array(
array("KEY", array("user_id"), "NAME" => $sso_db_apikeys . "_user_id"),
array("KEY", array("namespace"), "NAME" => $sso_db_apikeys . "_namespace"),
)));
}
catch (Exception $e)
{
InstallError("Unable to create the database table '" . htmlspecialchars($sso_db_apikeys) . "'. " . htmlspecialchars($e->getMessage()));
}
}
if (!$fieldsfound)
{
try
{
$db->Query("CREATE TABLE", array($sso_db_fields, array(
"id" => array("INTEGER", 4, "UNSIGNED" => true, "NOT NULL" => true, "PRIMARY KEY" => true, "AUTO INCREMENT" => true),
"field_name" => array("STRING", 1, 50, "NOT NULL" => true),
"field_desc" => array("STRING", 1, 255, "NOT NULL" => true),
"field_hash" => array("STRING", 1, 32, "NOT NULL" => true),
"encrypted" => array("INTEGER", 1, "NOT NULL" => true),
"enabled" => array("INTEGER", 1, "NOT NULL" => true),
"created" => array("DATETIME", "NOT NULL" => true),
),
array(
array("UNIQUE", array("field_name"), "NAME" => $sso_db_fields . "_field_name"),
)));
}
catch (Exception $e)
{
InstallError("Unable to create the database table '" . htmlspecialchars($sso_db_fields) . "'. " . htmlspecialchars($e->getMessage()));
}
}
if (!$usersfound)
{
try
{
$db->Query("CREATE TABLE", array($sso_db_users, array(
"id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true, "PRIMARY KEY" => true, "AUTO INCREMENT" => true),
"provider_name" => array("STRING", 1, 50, "NOT NULL" => true),
"provider_id" => array("STRING", 1, 255, "NOT NULL" => true),
"session_extra" => array("STRING", 1, 64, "NOT NULL" => true),
"version" => array("INTEGER", 4, "NOT NULL" => true),
"lastipaddr" => array("STRING", 1, 50, "NOT NULL" => true),
"lastactivated" => array("DATETIME", "NOT NULL" => true),
"info" => array("STRING", 3, "NOT NULL" => true),
"info2" => array("STRING", 3, "NOT NULL" => true),
),
array(
array("UNIQUE", array("provider_name", "provider_id"), "NAME" => $sso_db_users . "_provider"),
)));
}
catch (Exception $e)
{
InstallError("Unable to create the database table '" . htmlspecialchars($sso_db_users) . "'. " . htmlspecialchars($e->getMessage()));
}
}
if (!$usertagsfound)
{
try
{
$db->Query("CREATE TABLE", array($sso_db_user_tags, array(
"user_id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true),
"tag_id" => array("INTEGER", 4, "NOT NULL" => true),
"issuer_id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true),
"reason" => array("STRING", 1, 100, "NOT NULL" => true),
"created" => array("DATETIME", "NOT NULL" => true),
),
array(
array("PRIMARY", array("user_id", "tag_id"), "NAME" => $sso_db_user_tags . "_usertag"),
)));
}
catch (Exception $e)
{
InstallError("Unable to create the database table '" . htmlspecialchars($sso_db_user_tags) . "'. " . htmlspecialchars($e->getMessage()));
}
}
if (!$usersessionsfound)
{
try
{
$db->Query("CREATE TABLE", array($sso_db_user_sessions, array(
"id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true, "PRIMARY KEY" => true, "AUTO INCREMENT" => true),
"user_id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true),
"apikey_id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true),
"updated" => array("DATETIME", "NOT NULL" => true),
"created" => array("DATETIME", "NOT NULL" => true),
"session_id" => array("STRING", 1, 64, "NOT NULL" => true),
"info" => array("STRING", 3, "NOT NULL" => true),
),
array(
array("KEY", array("user_id", "updated"), "NAME" => $sso_db_user_sessions . "_user_id"),
array("KEY", array("apikey_id", "updated"), "NAME" => $sso_db_user_sessions . "_apikey_id"),
)));
}
catch (Exception $e)
{
InstallError("Unable to create the database table '" . htmlspecialchars($sso_db_user_sessions) . "'. " . htmlspecialchars($e->getMessage()));
}
}
if (!$tempsessionsfound)
{
try
{
$db->Query("CREATE TABLE", array($sso_db_temp_sessions, array(
"id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true, "PRIMARY KEY" => true, "AUTO INCREMENT" => true),
"apikey_id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true),
"updated" => array("DATETIME", "NOT NULL" => true),
"created" => array("DATETIME", "NOT NULL" => true),
"heartbeat" => array("INTEGER", 4, "UNSIGNED" => true, "NOT NULL" => true),
"session_id" => array("STRING", 1, 64, "NOT NULL" => true),
"ipaddr" => array("STRING", 1, 50, "NOT NULL" => true),
"info" => array("STRING", 3, "NOT NULL" => true),
"recoverinfo" => array("STRING", 3, "NOT NULL" => true),
),
array(
array("KEY", array("apikey_id", "updated"), "NAME" => $sso_db_temp_sessions . "_apikey_id"),
)));
}
catch (Exception $e)
{
InstallError("Unable to create the database table '" . htmlspecialchars($sso_db_temp_sessions) . "'. " . htmlspecialchars($e->getMessage()));
}
}
if (!$tagsfound)
{
try
{
$db->Query("CREATE TABLE", array($sso_db_tags, array(
"id" => array("INTEGER", 4, "UNSIGNED" => true, "NOT NULL" => true, "PRIMARY KEY" => true, "AUTO INCREMENT" => true),
"tag_name" => array("STRING", 1, 50, "NOT NULL" => true),
"tag_desc" => array("STRING", 1, 255, "NOT NULL" => true),
"enabled" => array("INTEGER", 1, "NOT NULL" => true),
"created" => array("DATETIME", "NOT NULL" => true),
),
array(
array("UNIQUE", array("tag_name"), "NAME" => $sso_db_tags . "_tag_name"),
)));
}
catch (Exception $e)
{
InstallError("Unable to create the database table '" . htmlspecialchars($sso_db_tags) . "'. " . htmlspecialchars($e->getMessage()));
}
try
{
$db->Query("INSERT", array($sso_db_tags, array(
"tag_name" => $_REQUEST["sso_site_admin"],
"tag_desc" => "",
"enabled" => 1,
"created" => CSDB::ConvertToDBTime(time()),
)));
}
catch (Exception $e)
{
InstallError("Unable to insert '" . htmlspecialchars($_REQUEST["sso_site_admin"]) . "' into database table '" . htmlspecialchars($sso_db_tags) . "'. " . htmlspecialchars($e->getMessage()));
}
try
{
$db->Query("INSERT", array($sso_db_tags, array(
"tag_name" => $_REQUEST["sso_admin"],
"tag_desc" => "",
"enabled" => 1,
"created" => CSDB::ConvertToDBTime(time()),
)));
}
catch (Exception $e)
{
InstallError("Unable to insert '" . htmlspecialchars($_REQUEST["sso_admin"]) . "' into database table '" . htmlspecialchars($sso_db_tags) . "'. " . htmlspecialchars($e->getMessage()));
}
try
{
$db->Query("INSERT", array($sso_db_tags, array(
"tag_name" => $_REQUEST["sso_locked"],
"tag_desc" => "",
"enabled" => 1,
"created" => CSDB::ConvertToDBTime(time()),
)));
}
catch (Exception $e)
{
InstallError("Unable to insert '" . htmlspecialchars($_REQUEST["sso_locked"]) . "' into database table '" . htmlspecialchars($sso_db_tags) . "'. " . htmlspecialchars($e->getMessage()));
}
}
if (!$ipcachefound)
{
try
{
$db->Query("CREATE TABLE", array($sso_db_ipcache, array(
"id" => array("INTEGER", 8, "UNSIGNED" => true, "NOT NULL" => true, "PRIMARY KEY" => true, "AUTO INCREMENT" => true),
"ipaddr" => array("STRING", 1, 50, "NOT NULL" => true),
"created" => array("DATETIME", "NOT NULL" => true),
"info" => array("STRING", 3, "NOT NULL" => true),
),
array(
array("UNIQUE", array("ipaddr"), "NAME" => $sso_db_ipcache . "_ipaddr"),
array("KEY", array("created"), "NAME" => $sso_db_ipcache . "_created"),
)));
}
catch (Exception $e)
{
InstallError("Unable to create the database table '" . htmlspecialchars($sso_db_ipcache) . "'. " . htmlspecialchars($e->getMessage()));
}
}
InstallSuccess("Successfully created database tables and data in '" . htmlspecialchars($_REQUEST["db_name"]) . "'.");
$sso_fields = array();
$sso_settings = array();
if (!SSO_SaveSettings()) InstallError("Unable to install the settings file.");
SSO_LoadSettings();
if (!SSO_SaveSettings()) InstallError("Unable to save the default settings file.");
InstallSuccess("Successfully set up the settings file.");
// Extract SMTP/POP3 settings.
$smtpserver = explode(":", trim($_REQUEST["smtp_server"]));
if (count($smtpserver) == 2)
{
$smtpport = $smtpserver[1];
$smtpserver = $smtpserver[0];
}
else
{
$smtpserver = trim($_REQUEST["smtp_server"]);
$smtpport = 25;
}
$pop3server = explode(":", trim($_REQUEST["pop3_server"]));
if (count($pop3server) == 2)
{
$pop3port = $pop3server[1];
$pop3server = $pop3server[0];
}
else
{
$pop3server = trim($_REQUEST["pop3_server"]);
$pop3port = 110;
}
// Optionally move critical files to final locations. Some security through obscurity here.
if ($_REQUEST["sso_endpoint_sto"] > 0)
{
$srcfile = SSO_ROOT_PATH . "/endpoint.php";
$endpointdir = "endpoint_" . $rng->GenerateString();
$destfile = SSO_ROOT_PATH . "/" . $endpointdir;
if (!@mkdir($destfile, 0755)) InstallError("Unable to create endpoint directory.");
$destfile .= "/endpoint.php";
if (!@rename($srcfile, $destfile)) InstallError("Unable to move 'endpoint.php' to endpoint directory.");
$url = dirname(BB_GetFullRequestURLBase());
if (substr($url, -1) != "/") $url .= "/";
$url .= $endpointdir . "/endpoint.php";
define("SSO_ENDPOINT_URL", $url);
InstallSuccess("Successfully created a randomly named directory and moved 'endpoint.php' into it.");
}
else
{
$url = dirname(BB_GetFullRequestURLBase());
if (substr($url, -1) != "/") $url .= "/";
$url .= "endpoint.php";
define("SSO_ENDPOINT_URL", $url);
}
if ($_REQUEST["sso_admin_sto"] > 0)
{
$srcfile = SSO_ROOT_PATH . "/admin.php";
$admindir = "admin_" . $rng->GenerateString();
$destfile = SSO_ROOT_PATH . "/" . $admindir;
if (!@mkdir($destfile, 0755)) InstallError("Unable to create endpoint directory.");
$destfile .= "/admin.php";
if (!@rename($srcfile, $destfile)) InstallError("Unable to move 'admin.php' to admin directory.");
$adminurl = dirname(BB_GetFullRequestURLBase());
if (substr($adminurl, -1) != "/") $adminurl .= "/";
$adminurl .= $admindir . "/admin.php";
InstallSuccess("Successfully created a randomly named directory and moved 'admin.php' into it.");
$adminhookfile = SSO_ROOT_PATH . "/" . $admindir . "/admin_hook.php";
}
else
{
$adminurl = dirname(BB_GetFullRequestURLBase());
if (substr($adminurl, -1) != "/") $adminurl .= "/";
$adminurl .= "admin.php";
$adminhookfile = SSO_ROOT_PATH . "/admin_hook.php";
}
// Create a basic admin hook file.
$data = "<" . "?php\n";
$data .= "\tif (!defined(\"SSO_FILE\")) exit();\n";
$data .= "\n";
$data .= "\tif (\$_SERVER[\"REMOTE_ADDR\"] !== \"" . $_SERVER["REMOTE_ADDR"] . "\") exit();\n";
$data .= "\n";
$data .= "\t\$bb_usertoken = \"" . substr($rng->GenerateToken(), 0, 32) . "\";\n";
$data .= "\t\$sso_site_admin = true;\n";
if (file_put_contents($adminhookfile, $data) === false) InstallError("Unable to create the admin hook file.");
InstallSuccess("Successfully created the admin hook file.");
// Set up the main configuration file.
$data = "<" . "?php\n";
$data .= "\tdefine(\"SSO_HTTP_SERVER\", \"\");\n";
$data .= "\tdefine(\"SSO_HTTPS_SERVER\", \"\");\n";
$data .= "\tdefine(\"SSO_USE_HTTPS\", " . var_export(BB_IsSSLRequest(), true) . ");\n";
$data .= "\tdefine(\"SSO_ROOT_PATH\", " . var_export(SSO_ROOT_PATH, true) . ");\n";
$data .= "\tdefine(\"SSO_ROOT_URL\", " . var_export(SSO_ROOT_URL, true) . ");\n";
$data .= "\tdefine(\"SSO_LOGIN_URL\", " . var_export(SSO_LOGIN_URL, true) . ");\n";
$data .= "\tdefine(\"SSO_ENDPOINT_URL\", " . var_export(SSO_ENDPOINT_URL, true) . ");\n";
$data .= "\tdefine(\"SSO_SUPPORT_PATH\", " . var_export(SSO_SUPPORT_PATH, true) . ");\n";
$data .= "\tdefine(\"SSO_PROVIDER_PATH\", " . var_export(SSO_PROVIDER_PATH, true) . ");\n";
$data .= "\tdefine(\"SSO_LANG_PATH\", \"lang\");\n";
$data .= "\tdefine(\"SSO_DEFAULT_LANG\", " . var_export($_REQUEST["sso_default_lang"], true) . ");\n";
$data .= "\tdefine(\"SSO_ADMIN_LANG\", " . var_export($_REQUEST["sso_admin_lang"], true) . ");\n";
$data .= "\tdefine(\"SSO_PROXY_X_FORWARDED_FOR\", " . var_export($_REQUEST["sso_proxy_x_forwarded_for"], true) . ");\n";
$data .= "\tdefine(\"SSO_PROXY_CLIENT_IP\", " . var_export($_REQUEST["sso_proxy_client_ip"], true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED\", " . var_export(SSO_BASE_RAND_SEED, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED2\", " . var_export(SSO_BASE_RAND_SEED2, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED3\", " . var_export(SSO_BASE_RAND_SEED3, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED4\", " . var_export(SSO_BASE_RAND_SEED4, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED5\", " . var_export(SSO_BASE_RAND_SEED5, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED6\", " . var_export(SSO_BASE_RAND_SEED6, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED7\", " . var_export(SSO_BASE_RAND_SEED7, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED8\", " . var_export(SSO_BASE_RAND_SEED8, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED9\", " . var_export(SSO_BASE_RAND_SEED9, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED10\", " . var_export(SSO_BASE_RAND_SEED10, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED11\", " . var_export(SSO_BASE_RAND_SEED11, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED12\", " . var_export(SSO_BASE_RAND_SEED12, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED13\", " . var_export(SSO_BASE_RAND_SEED13, true) . ");\n";
$data .= "\tdefine(\"SSO_BASE_RAND_SEED14\", " . var_export(SSO_BASE_RAND_SEED14, true) . ");\n";
$data .= "\tdefine(\"SSO_HEARTBEAT_LIMIT\", 30);\n";
$data .= "\tdefine(\"SSO_STO_ENDPOINT\", " . var_export($_REQUEST["sso_endpoint_sto"] > 0, true) . ");\n";
$data .= "\tdefine(\"SSO_STO_ADMIN\", " . var_export($_REQUEST["sso_admin_sto"] > 0, true) . ");\n";
$data .= "\tdefine(\"SSO_USING_CRON\", " . var_export($_REQUEST["sso_using_cron"] > 0, true) . ");\n";
$data .= "\tdefine(\"SSO_PRIMARY_CIPHER\", " . var_export($_REQUEST["sso_primary_cipher"], true) . ");\n";
$data .= "\tdefine(\"SSO_DUAL_ENCRYPT\", " . var_export($_REQUEST["sso_dual_encrypt"] > 0, true) . ");\n";
$data .= "\tdefine(\"SSO_USE_LESS_SAFE_STORAGE\", " . var_export($_REQUEST["sso_use_less_safe_storage"] == "yes", true) . ");\n";
$data .= "\n";
$data .= "\tdefine(\"SSO_DB_TYPE\", " . var_export($_REQUEST["db_select"], true) . ");\n";
$data .= "\tdefine(\"SSO_DB_DSN\", " . var_export($_REQUEST["db_dsn"], true) . ");\n";
$data .= "\tdefine(\"SSO_DB_USER\", " . var_export($_REQUEST["db_user"], true) . ");\n";
$data .= "\tdefine(\"SSO_DB_PASS\", " . var_export($_REQUEST["db_pass"], true) . ");\n";
$data .= "\tdefine(\"SSO_DB_MASTER_DSN\", " . var_export($_REQUEST["db_master_dsn"], true) . ");\n";
$data .= "\tdefine(\"SSO_DB_MASTER_USER\", " . var_export($_REQUEST["db_master_user"], true) . ");\n";
$data .= "\tdefine(\"SSO_DB_MASTER_PASS\", " . var_export($_REQUEST["db_master_pass"], true) . ");\n";
$data .= "\tdefine(\"SSO_DB_NAME\", " . var_export($_REQUEST["db_name"], true) . ");\n";
$data .= "\tdefine(\"SSO_DB_PREFIX\", " . var_export($dbprefix, true) . ");\n";
$data .= "\n";
$data .= "\tdefine(\"SSO_SMTP_SERVER\", " . var_export($smtpserver, true) . ");\n";
$data .= "\tdefine(\"SSO_SMTP_PORT\", " . var_export($smtpport, true) . ");\n";
$data .= "\tdefine(\"SSO_POP3_SERVER\", " . var_export($pop3server, true) . ");\n";
$data .= "\tdefine(\"SSO_POP3_PORT\", " . var_export($pop3port, true) . ");\n";
$data .= "\tdefine(\"SSO_SMTPPOP3_USER\", " . var_export($_REQUEST["smtppop3_user"], true) . ");\n";
$data .= "\tdefine(\"SSO_SMTPPOP3_PASS\", " . var_export($_REQUEST["smtppop3_pass"], true) . ");\n";
$data .= "\tdefine(\"SSO_SMTP_FROM\", " . var_export($_REQUEST["smtp_from"], true) . ");\n";
$data .= "\n";
$data .= "\tdefine(\"SSO_SITE_ADMIN_TAG\", " . var_export($_REQUEST["sso_site_admin"], true) . ");\n";
$data .= "\tdefine(\"SSO_ADMIN_TAG\", " . var_export($_REQUEST["sso_admin"], true) . ");\n";
$data .= "\tdefine(\"SSO_LOCKED_TAG\", " . var_export($_REQUEST["sso_locked"], true) . ");\n";
$data .= "?" . ">";
if (file_put_contents("config.php", $data) === false) InstallError("Unable to create the configuration file.");
if ($_REQUEST["sso_endpoint_sto"] > 0 && file_put_contents(SSO_ROOT_PATH . "/" . $endpointdir . "/config.php", $data) === false) InstallError("Unable to create the configuration file clone in the endpoint subdirectory.");
if ($_REQUEST["sso_admin_sto"] > 0 && file_put_contents(SSO_ROOT_PATH . "/" . $admindir . "/config.php", $data) === false) InstallError("Unable to create the configuration file clone in the admin subdirectory.");
InstallSuccess("Successfully created the configuration file.");
InstallSuccess("The installation completed successfully.");
?>
<br />
Next: <a href="<?php echo htmlspecialchars($adminurl); ?>">Start using Single-Sign On</a><br />
<?php
}
else
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Single Sign-On Server Installer</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="support/install.css" type="text/css" />
<script type="text/javascript" src="support/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
function Page(curr, next)
{
$('#page' + curr).hide();
$('#page' + next).fadeIn('normal');
return false;
}
</script>
</head>
<body>
<noscript><span class="error">Er... You need Javascript enabled to install Single Sign-On (SSO) Server.</span></noscript>
<form id="installform" method="post" enctype="multipart/form-data" action="install.php" accept-charset="utf-8">
<input type="hidden" name="action" value="install" />
<div id="main">
<div id="page1" class="box">
<h1>Single Sign-On Server Installer</h1>
<h3>Welcome to the Single Sign-On Server installer.</h3>
<div class="boxmain">
If you are looking to implement a centralized account management and login system for one or more domains,
bring disparate login systems together under a unified system, and easily manage all aspects of a user account,
then this is most likely what you are looking for:<br /><br />
<div class="indent">
A self-contained, centralized account management server that can sit on any domain with tools
to easily manage user fields and access permissions, with multiple signup and sign in options,
and easy-to-use client functions to sign in and extract information from the server in a
secure manner. Or more simply put: Do you need a login system that rocks?
</div>
<br />
If that sounds like you, Single Sign-On (SSO) is the answer. Just click "Next" below to get started.
</div>
<div class="boxbuttons">
<a href="#" onclick="return Page(1, 2);">Next »</a>
</div>
</div>
<div id="page2" class="box" style="display: none;">
<h1>Single Sign-On Server Requirements</h1>
<h3>The Single Sign-On Server system requirements.</h3>
<div class="boxmain">
In order to use Single Sign-On (SSO) Server, you will need to meet these logistical requirements:<br />
<ul>
<li>Someone who knows PHP (a PHP programmer)</li>
<li>Someone who knows design (a web designer)</li>
</ul>
You will also need to meet these technical requirements (most of these are auto-detected by this installation wizard):<br />
<ul>
<li><a href="http://www.php.net/" target="_blank">PHP 5.4.x or later</a> (preferably the latest)</li>
<li><a href="http://barebonescms.com/documentation/csdb/" target="_blank">A CSDB-compliant database</a></li>
</ul>
</div>
<div class="boxbuttons">
<a href="#" onclick="return Page(2, 1);">« Prev</a> | <a href="#" onclick="return Page(2, 3);">Next »</a>
</div>
</div>
<div id="page3" class="box" style="display: none;">
<h1>Single Sign-On Server Checklist</h1>
<h3>The Single Sign-On Server compatability checklist.</h3>
<div class="boxmain">
Before beginning the installation, you should check to make sure that the server meets or exceeds
the basic technical requirements. Below is the checklist for compatability with Single Sign-On (SSO) Server.<br /><br />
<div id="checklist"></div>
<br />
<script type="text/javascript">
function RefreshChecklist()
{
$('#checklist').load('install.php', { 'action' : 'checklist' });
return false;
}
RefreshChecklist();
</script>
<a href="#" onclick="return RefreshChecklist();">Refresh the checklist</a><br /><br />
NOTE: You are allowed to install Single Sign-On (SSO) Server even if you don't meet the requirements above. Just don't complain if your
installation or this installer does not work. Each web server is different - there is no way to satisfy all servers
without a ton of code. Besides, you may be able to get away with some missing things for some websites.
</div>
<div class="boxbuttons">
<a href="#" onclick="return Page(3, 2);">« Prev</a> | <a href="#" onclick="return Page(3, 4);">Next »</a>
</div>
</div>
<div id="page4" class="box" style="display: none;">
<h1>Database Setup</h1>
<h3>Set up database options.</h3>
<div class="boxmain">
Single Sign-On (SSO) Server requires a database.<br /><br />
<div class="formfields">
<div class="formitem">
<div class="formitemtitle">Database Server</div>
<select id="db_select" name="db_select">
<?php
$login = array();
$replication = array();
$databases = SSO_GetSupportedDatabases();
foreach ($databases as $database => $info)
{
if ($info["production"] || $allowinsecuredatabases)
{
require_once "support/csdb/db_" . $database . ".php";
try
{
$classname = "CSDB_" . $database;
$db = new $classname();
if ($db->IsAvailable() !== false)
{
echo "<option value=\"" . htmlspecialchars($database) . "\">" . htmlspecialchars($db->GetDisplayName()) . (!$info["production"] ? " [NOT for production use]" : "") . "</option>";
$login[$database] = $info["login"];
$replication[$database] = $info["replication"];
}
}
catch (Exception $e)
{
}
}
}
?>
</select>
<div class="formitemdesc">Select a database server. If the list is empty, please contact your hosting provider and ask them to enable a <a href="http://barebonescms.com/documentation/csdb/" target="_blank">supported PDO database driver</a>.</div>
</div>
<div class="db_selected" style="display: none;">
<div class="formitem">
<div class="formitemtitle">DSN Options</div>
<input class="text" id="db_dsn" type="text" name="db_dsn" value="" />
<div class="formitemdesc">The initial connection string to connect to the database server. Options are driver specific. Leave blank for the default. Usually takes the form of: host=ipaddr_or_hostname[;port=portnum] (e.g. host=127.0.0.1;port=3306)</div>
</div>
<div class="formitem db_login">
<div class="formitemtitle">Username</div>
<input class="text" id="db_user" type="text" name="db_user" />
<div class="formitemdesc">The username to use to log into the database server.</div>
</div>
<div class="formitem db_login">
<div class="formitemtitle">Password</div>
<input class="text" id="db_pass" type="password" name="db_pass" />
<div class="formitemdesc">The password to use to log into the database server.</div>
</div>
<div class="formitem">
<div class="formitemtitle">Database</div>