-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.php
1272 lines (1217 loc) · 45.7 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
/**
* Lilac Installer Script
*/
require_once('includes/init.inc.php');
if(isset($_POST['reg'])) {
// We are registering!
$curl = curl_init('http://register.eyesofnetwork.com/');
$request = array();
$request['organizationName'] = $_POST['organizationName'];
$request['organizationCountry'] = $_POST['organizationCountry'];
$request['organizationSize'] = $_POST['organizationSize'];
$request['lilacUse'] = $_POST['lilacUse'];
$request['lilacVersion'] = $_POST['lilacVersion'];
$request['interestedEmail'] = $_POST['interestedEmail'];
$request['interestedInServices'] = $_POST['interestedInServices'];
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, array('request' => json_encode($request)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$response = json_decode($response, true);
print json_encode(true);
die();
}
// Check to see if we're being called from CLI mode, to check if we can run PHP scripts via cli
if(isset($argv) && sizeof($argv) > 0) {
// We need to make sure we can do the things we need in CLI mode.
$results = array();
$results['mysql'] = extension_loaded("pdo_mysql");
$results['json'] = function_exists("json_encode");
$results['simplexml'] = function_exists("simplexml_load_file");
$results['pcntl'] = function_exists("pcntl_fork");
// memory limit check
$memoryLimit = ini_get("memory_limit");
// Default to true
$results['memorylimit'] = true;
// It's in bytes, unless it's using some shorthand.
if(preg_match("/^(\d+)([a-zA-Z])$/", $memoryLimit, $matches)) {
// Using shorthand, convert to bytes
if($matches[2] == 'm' || $matches[2] == 'M') {
// Megabytes
$memorySize = (1048576 * $matches[1]);
}
else if($matches[2] == 'K' || $matches[2] == 'k') {
$memorySize = (1024 * $matches[1]);
}
else if($matches[2] == 'g' || $matches[2] == 'G') {
$memorySize = (1073741824 * $matches[1]);
}
else {
// Unknown shorthand
$results['memorylimit'] = false;
}
}
else if($memoryLimit != "-1") {
$memorySize = $memoryLimit;
}
if($memoryLimit != "-1" && $memorySize < 67108864) {
// Memory set is less than 64megs. This probably won't do.
$results['memorylimit'] = false;
}
$results['memorysize'] = $memoryLimit;
if(function_exists("json_encode")) {
print(json_encode($results));
}
else {
print("fail");
}
die();
}
if(!isset($_POST['stage'])) {
$stage = "1";
}
else {
$stage = $_POST['stage'];
}
if($stage == 2) {
$error = false;
if(!isset($_POST['mysqlRootUsername'])) {
$mysqlRootUsername = 'root';
$mysqlRootPassword = '';
$mysqlHostname = 'localhost';
$mysqlUsername = '';
$mysqlPassword = '';
$mysqlDatabase = 'lilac';
$mysqlPopulate = true;
$mysqlCreateUserDatabase = false;
}
else {
$mysqlRootUsername = trim($_POST['mysqlRootUsername']);
$mysqlRootPassword = trim($_POST['mysqlRootPassword']);
$mysqlHostname = trim($_POST['mysqlHostname']);
$mysqlUsername = trim($_POST['mysqlUsername']);
$mysqlPassword = trim($_POST['mysqlPassword']);
$mysqlDatabase = trim($_POST['mysqlDatabase']);
$mysqlPopulate = trim($_POST['mysqlPopulate']);
if(isset($_POST['mysqlCreateUserDatabase'])) {
$mysqlCreateUserDatabase = true;
}
else {
$mysqlCreateUserDatabase = false;
}
// Check for required parameters
if($mysqlCreateUserDatabase) {
if(empty($mysqlRootUsername)) {
$error = "MySQL Administrator username cannot be blank if you want to create user and database.";
}
}
if(!$error) {
if(empty($mysqlHostname)) {
$error = "MySQL Hostname cannot be blank.";
}
else if(empty($mysqlUsername)) {
$error = "MySQL Username cannot be blank.";
}
else if(empty($mysqlDatabase)) {
$error = "MySQL Database cannot be blank.";
}
}
if(!$error) {
// Okay, breathe, we're going to do the grunt of the work now.
// Check to see if we need to create the user and database
if($mysqlCreateUserDatabase) {
// Attempt to connect as admin
$dbConn = @mysqli_connect($mysqlHostname, $mysqlRootUsername, $mysqlRootPassword);
if(!$dbConn) {
$error = "Failed to connect to MySQL server with Administrator login.";
}
else {
if(!mysqli_select_db("mysql", $dbConn)) {
$error = "Failed creating user and database. Check your Admin credentials. Error was: <em>" . mysqli_error($dbConn) . "</em>";
}
else {
// Create database
if(!mysqli_query("create database " . $mysqlDatabase, $dbConn)) {
$error = "Failed to create database. Error was: <em>" . mysqli_error($dbConn) . "</em>";
}
else {
// Okay, db is selected, let's grant privileges.
//
// NOTE TO SELF. TICKET #10
//
// k
if(in_array(strtolower($mysqlHostname), array('127.0.0.1', 'localhost'))) {
// Assign rights to localhost
if(!mysqli_query("grant all privileges on " . $mysqlDatabase . ".* to '" . $mysqlUsername . "'@localhost identified by '" . $mysqlPassword . "'")) {
$error = "Failed to create user. Error was: <em>" . mysqli_error($dbConn) . "</em>";
}
}
else {
// Assign rights via our hostname
if(!mysqli_query("grant all privileges on " . $mysqlDatabase . ".* to '" . $mysqlUsername . "'@'" . $_SERVER['SERVER_NAME'] . "' identified by '" . $mysqlPassword . "'")) {
$error = "Failed to create user. Error was: <em>" . mysqli_error($dbConn) . "</em>";
}
}
mysqli_query("flush privileges");
}
}
}
}
if(!$error && $mysqlPopulate) {
// Okay, we need to populate the database. Attempt to connect as our user.
$dbConn = @mysqli_connect($mysqlHostname, $mysqlUsername, $mysqlPassword);
if(!$dbConn) {
$error = "Failed to connect to MySQL server with " . $mysqlUsername . " user.";
}
else {
// Select db.
if(!mysqli_select_db($mysqlDatabase, $dbConn)) {
$error = "Failed to use " . $mysqlDatabase . " database. Check your User credentials. Error was: <em>" . mysqli_error($dbConn) . "</em>";
}
else {
// Load the data
exec("mysql -h " . $mysqlHostname . " -u " . $mysqlUsername . " -p" . $mysqlPassword . " " . $mysqlDatabase . " < " . dirname(__FILE__) . "/sqldata/schema.sql", $output, $retVal);
if($retVal != 0) {
$error = "Failed to import database schema. Make sure the mysql binary is in the search path for the web user.";
}
else {
// Import labels
exec("mysql -h " . $mysqlHostname . " -u " . $mysqlUsername . " -p" . $mysqlPassword . " " . $mysqlDatabase . " < " . dirname(__FILE__) . "/sqldata/lilac-nagios-en-label.sql", $output, $retVal);
if($retVal != 0) {
$error = "Failed to import Nagios labels. Error was: <br />" . str_replace("\n", "<br />", $output[count($output)]);
}
else {
// Import Seed
exec("mysql -h " . $mysqlHostname . " -u " . $mysqlUsername . " -p" . $mysqlPassword . " " . $mysqlDatabase . " < " . dirname(__FILE__) . "/sqldata/seed.sql", $output, $retVal);
if($retVal != 0) {
$error = "Failed to import seed data. Error was: <br />" . str_replace("\n", "<br />", $output[count($output)]);
}
}
}
}
}
}
// Create PDO connection to perform upgrades
try {
$dbConn = new PDO("mysql:host=" . $mysqlHostname . ";dbname=" . $mysqlDatabase, $mysqlUsername, $mysqlPassword);
} catch(PDOException $e) {
$error = "Failed to connect to MySQL server with " . $mysqlUsername . " user:" . $e->getMessage();
}
if(!$error) {
if(!perform_upgrade($dbConn)) {
$error = true;
}
}
if(!$error) {
// Okay, write to the configuration file!
$conf = file_get_contents(dirname(__FILE__) . "/includes/lilac-conf.php.dist");
$conf = str_replace("%%DSN%%", "mysql:host=" . $mysqlHostname . ";dbname=" . $mysqlDatabase, $conf);
$conf = str_replace("%%USERNAME%%",$mysqlUsername, $conf);
$conf = str_replace("%%PASSWORD%%",$mysqlPassword, $conf);
$conf = str_replace("%%DATABASE%%",$mysqlDatabase, $conf);
// We have the new conf
$ret = file_put_contents(dirname(__FILE__) . "/includes/lilac-conf.php", $conf);
if($ret == false) {
$error = "Failed to write to includes/lilac-conf.php. Check that the web user can write to the includes directory and try again.";
}
$success = "Completed Database Setup.";
}
}
}
}
if(file_exists(dirname(__FILE__) . "/NOTICE")) {
// Notice exists, we should display it here.
$noticeContents = file_get_contents(dirname(__FILE__) . "/NOTICE");
$warning = $noticeContents;
}
print_header("Installer");
if($stage == 1) {
$fatalErrors = false;
// Dependency checking
print_window_header("Dependency Checks");
?>
<div class="notice">
<strong>Note:</strong> Lilac supports Nagios 3.x only. It is possible to import Nagios 2.x configuration files, but Lilac will only export to Nagios 3.x.
</div>
<div class="checks">
<?php
if(false === ($fp = @fopen(dirname(__FILE__) . "/includes/lilac-conf.php", "w+"))) {
$fail = true;
}
else {
$fail = false;
}
if($fp)
fclose($fp);
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
Configuration File Writable
</div>
<?php
if($fail) {
?>
<div class="error">
The Lilac installer requires that it write to the configuration file at <em><?php echo dirname(__FILE__) . "/includes/lilac-conf.php";?></em>. It is
recommended that you change the permissions of the includes directory so the web user can write to it.</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// PHP VERSION CHECK
if(version_compare(PHP_VERSION, '5.2.0', '<') || !class_exists("DateTime")) {
$fail = true;
}
else {
$fail = false;
}
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP Version 5.2 or Better
</div>
<?php
if($fail) {
?>
<div class="error">
PHP Version 5.2 or greater is required for Lilac. Download the latest at <a href="http://www.php.net">The PHP Group's Website</a> or
check with your operating system distribution. (Version 5.2 also provides the class DateTime, which is also required).
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
$fail = addslashes($fail);
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
Magic Quotes GPC Set to Disabled
</div>
<?php
if($fail) {
?>
<div class="error">
Magic Quotes GPC is set to enabled in your PHP configuration. Lilac will not work with Magic Quotes GPC set to enabled. Please disable it in your PHP configuration. Refer to <a href="http://www.php.net/manual/en/security.magicquotes.disabling.php">Disabling Magic Quotes</a> for more information.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// Pear Library Installed Check
$fail = @include_once('PEAR.php');
if($fail === false) {
$fail = true;
}
else {
$fail = false;
}
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP Pear Library Installed
</div>
<?php
if($fail) {
?>
<div class="error">
PHP's PEAR library must be loaded. Please refer to <a href="http://pear.php.net">PHP's PEAR Homepage</a> for more information.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// PDO MYSQL Extension Installed Check
$fail = !extension_loaded("pdo_mysql");
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP PDO MySQL Extension Loaded
</div>
<?php
if($fail) {
?>
<div class="error">
PHP's PDO MySQL extension must be loaded. This is not the same as the MySQLi extension. Please refer to <a href="http://us3.php.net/manual/en/ref.pdo.html">PHP's PDO documentation</a> for more information.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// MySQL Executable Located
exec("which mysql", $output, $retVal);
if($retVal != 0) {
$fail = true;
}
else {
$fail = false;
}
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
MySQL Client Executable
</div>
<?php
if($fail) {
?>
<div class="notice">
The Lilac installer needs the MySQL client binary to be installed and executable by the webserver if you need to populate the Lilac database. Install the MySQL command line utility.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// Nmap Executable Located
exec("which nmap", $output, $retVal);
if($retVal != 0) {
$fail = true;
}
else {
$fail = false;
}
?>
<div class="<?php if($fail) echo "warning"; else echo "success";?>">
NMAP Executable
</div>
<?php
if($fail) {
?>
<div class="notice">
Not a fatal error, Lilac needs the NMAP binary to be installed and executable by the webserver to perform auto-discovery tasks. Install the NMAP command line utility. If you are not going to perform auto-discovery tasks, you can ignore this and continue. If you choose to do auto-discovery tasks in the future, you must have NMAP installed.
</div>
<?php
}
?>
<?php
// Curl extension
$fail = !function_exists("curl_init");
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP Curl Support
</div>
<?php
if($fail) {
?>
<div class="error">
PHP's Curl support is not available. Curl is required for for Lilac to call internal webservices.. For more information, refer to <a href="http://www.php.net/manual/en/curl.setup.php">PHP'S Curl Extension setup guide</a> for more information on how to install it.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// SimpleXML extension
$fail = !function_exists("simplexml_load_file");
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP SimpleXML Support
</div>
<?php
if($fail) {
?>
<div class="error">
PHP's SimpleXML support is not available. SimpleXML is required for parsing XML documents and is used by Lilac's Autodiscovery system. For more information, refer to <a href="http://www.php.net/manual/en/simplexml.setup.php">PHP'S SimpleXML Extension setup guide</a> for more information on how to install it.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// PHP POSIX Functions Installed Check
$fail = !function_exists("posix_getpid");
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP POSIX Support
</div>
<?php
if($fail) {
?>
<div class="error">
PHP's POSIX support is not available. POSIX support is required for the importer/exporter/autodiscovery to function. For instructions, refer to <a href="http://us3.php.net/manual/en/posix.setup.php">PHP's POSIX Extension setup guide</a> for more information on how to install it.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// PHP JSON Functions Installed Check
$fail = !function_exists("json_encode");
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP JSON Support
</div>
<?php
if($fail) {
?>
<div class="error">
PHP's JSON support is not available. JSON support is automatically provided in PHP 5.2.0. For previous versions of PHP, refer to <a href="http://us3.php.net/manual/en/json.setup.php">PHP's JSON Extension setup guide</a> for more information on how to install it.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// Able to call PHP via command line
$cliOutput = array();
$retVal = '';
$result = exec("php " . dirname(__FILE__) . "/install.php", $cliOutput, $retVal);
$fail = $retVal != 0;
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP Command Line Interface (CLI) Available
</div>
<?php
if($fail) {
?>
<div class="error">
Lilac must be able to run command line PHP script to import and export configurations. Please make sure PHP's command line interface
is installed and the PHP binary is in the search path for the web user. Refer to <a href="http://www.php.net">The PHP Group's Homepage</a> for more information.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<div class="checks">
<?php
// CLI JSON Support
$clisupport = @json_decode($cliOutput[0], true);
if($clisupport === false) {
$fail = true;
}
else {
$fail = false;
}
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
CLI JSON Support
</div>
<?php
if($fail) {
?>
<div class="error">
JSON Support must be provided to PHP's command line interface. This is automatically provided in PHP 5.2.0 and above. For previous versions of PHP, refer to <a href="http://us3.php.net/manual/en/json.setup.php">PHP's JSON Extension setup guide</a> for more information on how to install it.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// Memory Limit Check
$fail = !$clisupport['memorylimit'];
?>
<div class="<?php if($fail) echo "warning"; else echo "success";?>">
PHP Memory Limit For Scripts: <?php echo $clisupport['memorysize']; ?>
</div>
<?php
if($fail) {
?>
<div>
Not Really an Errror, but a note, PHP's Memory Limit for the command line scripts must be set to either -1 (Unlimited) or to a reasonable amount according to the size of your configuration. Suggested amount is 64M. Refer to <a href="http://www.php.net/manual/en/ini.core.php#ini.memory-limit">php.ini directives</a> for more information on how to change this value.
</div>
<?php
}
?>
<?php
// CLI PCNTL Support
$fail = !$clisupport['pcntl'];
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
CLI Process Control Support
</div>
<?php
if($fail) {
?>
<div class="error">
PHP must have Process control compiled in in order to properly import/export and auto-discover. For more information on how to install process control for PHP, refer to <a href="http://www.php.net/manual/en/pcntl.setup.php">PHP's PCNTL Installation documentation</a>.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// CLI MySQL Support
$fail = !$clisupport['mysql'];
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
CLI PDO MySQL Support
</div>
<?php
if($fail) {
?>
<div class="error">
MySQL Support must be provided to PHP's command line interface. This is not the same as the MySQLi extension. Please refer to <a href="http://us3.php.net/manual/en/ref.pdo.html">PHP's PDO documentation</a> for more information.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
<?php
// SimpleXML extension
$fail = !function_exists("simplexml_load_file");
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
PHP SimpleXML Support
</div>
<?php
if($fail) {
?>
<div class="error">
PHP's SimpleXML support is not available for PHP's command line interface. SimpleXML is required for parsing XML documents and is used by Lilac's Autodiscovery system. For more information, refer to <a href="http://www.php.net/manual/en/simplexml.setup.php">PHP'S SimpleXML Extension setup guide</a> for more information on how to install it.
</div>
<?php
}
if($fail) $fatalErrors = true;
?>
</div>
</div>
<?php
if($fatalErrors) {
?>
<div class="error">
You must resolve the issues above before continuing the installation. <a href="install.php">Refresh The Page</a> to perform the checks again.
</div>
<?php
}
else {
?>
<form action="install.php" method="post">
<input type="hidden" name="stage" value="2" />
<input class="submit" type="submit" value="Continue To Database Configuration..." />
</form>
<?php
}
print_window_footer();
?>
<?php
}
else if($stage == 2 && empty($success)) {
print_window_header("MySQL Database Setup");
?>
<script type="text/javascript">
$(document).ready(function() {
<?php
if($mysqlCreateUserDatabase) {
?>
$("#createdb").attr("checked", true);
$("#mysqladminform").css("display", "block");
<?php
}
else {
?>
$("#createdb").attr("checked", false);
<?php
}
?>
// do stuff when DOM is ready
$("#createdb").click(function(){
if(this.checked) {
$("#mysqladminform").show('fast');
}
else {
$("#mysqladminform").hide('fast');
}
});
});
</script>
Lilac needs credentials to connect to your MySQL server. The user should have all privileges on the Lilac database (except for grant). If
you do not know how to create a MySQL user and database, you can provide your MySQL root credentials to create the user and database.
<form action="install.php" method="post">
<input type="hidden" name="stage" value="2" />
<p>
<input type="checkbox" name="mysqlCreateUserDatabase" id="createdb"><label for="createdb">Create Database And User For Me</label>
</p>
<fieldset id="mysqladminform" style="display: none;">
<legend>MySQL Administrator Credentials</legend>
<p>
<label for="mysqlRootUsername">Admin Username:</label> <input type="text" id="mysqlRootUsername" name="mysqlRootUsername" value="<?php echo $mysqlRootUsername;?>" />
</p>
<p>
<label for="mysqlRootPassword">Admin Password:</label> <input type="password" id="mysqlRootPassword" name="mysqlRootPassword" value="<?php echo $mysqlRootPassword;?>" />
</p>
</fieldset>
<fieldset id="mysqlform">
<legend>MySQL Connection Information</legend>
<p>
<label for="mysqlHostname">Host: </label><input type="text" id="mysqlHostname" name="mysqlHostname" value="<?php echo$mysqlHostname;?>" />
</p>
<p>
<label for="mysqlUsername">Username: </label><input type="text" id="mysqlUsername" name="mysqlUsername" value="<?php echo $mysqlUsername;?>" />
</p>
<p>
<label for="mysqlPassword">Password: </label><input type="password" id="mysqlPassword" name="mysqlPassword" value="<?php echo $mysqlPassword;?>" />
</p>
<p>
<label for="mysqlDatabase">Database: </label><input type="text" id="mysqlDatabase" name="mysqlDatabase" value="<?php echo $mysqlDatabase;?>" />
</p>
</fieldset>
<p>
<input type="checkbox" <?php if($mysqlPopulate) echo "checked=\"checked\"" ;?> name="mysqlPopulate" id="populatedb"><label for="populatedb">Populate Database With Sample Data (Uncheck if you want to keep existing data or upgrading) <strong>Warning:</strong> This will remove any existing data! You should back-up any existing data.</label>
</p>
<input class="submit" type="submit" value="Continue" />
<?php
print_window_footer();
}
else if($stage == 2 && $success) {
// OMGZ!
print_window_header("Installation Complete");
?>
Congratulations!
<p>
Your lilac installation is now complete. You should remove the <em>install.php</em> script as it is no longer needed. You can also remove the write privileges to the <em>includes</em> directory.
</p>
<fieldset class="regform" id="regform">
<legend>Want to help us improve Lilac?</legend>
<p>
We're very interested in knowing who is using Lilac and how they're using the tool. Fill out the completely optional form below to help us improve Lilac's future releases. Or you can choose to <a href="index.php">Launch Lilac Now</a>.
</p>
<p>
<label for="organizationName">Organization's Name: </label><input type="text" id="organizationName" name="organizationName" />
</p>
<p>
<label for="organizationCountry">Country Your Organization Is In: </label><select name="organizationCountry" id="organizationCountry" style="width:150px;">
<option value="United States" selected="selected">United States</option>
<option value="Canada">Canada</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="Ireland" >Ireland</option>
<option value="Australia" >Australia</option>
<option value="New Zealand" >New Zealand</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antarctica">Antarctica</option>
<option value="Antigua and Barbuda">Antigua and Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Bouvet Island">Bouvet Island</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
<option value="Brunei Darussalam">Brunei Darussalam</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Congo, The Democratic Republic of The">Congo, The Democratic Republic of The</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote D'ivoire">Cote D'ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Territories">French Southern Territories</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guinea-bissau">Guinea-bissau</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Heard Island and Mcdonald Islands">Heard Island and Mcdonald Islands</option>
<option value="Holy See (Vatican City State)">Holy See (Vatican City State)</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran, Islamic Republic of">Iran, Islamic Republic of</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea, Democratic People's Republic of">Korea, Democratic People's Republic of</option>
<option value="Korea, Republic of">Korea, Republic of</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macao">Macao</option>
<option value="Macedonia, The Former Yugoslav Republic of">Macedonia, The Former Yugoslav Republic of</option>
<option value="Madagascar">Madagascar</option>
<option value="Malawi">Malawi</option>
<option value="Malaysia">Malaysia</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
<option value="Moldova, Republic of">Moldova, Republic of</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Namibia">Namibia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherlands">Netherlands</option>
<option value="Netherlands Antilles">Netherlands Antilles</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Northern Mariana Islands">Northern Mariana Islands</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau">Palau</option>
<option value="Palestinian Territory, Occupied">Palestinian Territory, Occupied</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Philippines">Philippines</option>
<option value="Pitcairn">Pitcairn</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russian Federation">Russian Federation</option>
<option value="Rwanda">Rwanda</option>
<option value="Saint Helena">Saint Helena</option>
<option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
<option value="Saint Lucia">Saint Lucia</option>
<option value="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option>
<option value="Saint Vincent and The Grenadines">Saint Vincent and The Grenadines</option>
<option value="Samoa">Samoa</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome and Principe">Sao Tome and Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Serbia and Montenegro">Serbia and Montenegro</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="South Georgia and The South Sandwich Islands">South Georgia and The South Sandwich Islands</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Svalbard and Jan Mayen">Svalbard and Jan Mayen</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syrian Arab Republic">Syrian Arab Republic</option>
<option value="Taiwan, Province of China">Taiwan, Province of China</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania, United Republic of">Tanzania, United Republic of</option>
<option value="Thailand">Thailand</option>
<option value="Timor-leste">Timor-leste</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad and Tobago">Trinidad and Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Emirates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States">United States</option>
<option value="United States Minor Outlying Islands">United States Minor Outlying Islands</option>
<option value="Uruguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Venezuela">Venezuela</option>
<option value="Viet Nam">Viet Nam</option>
<option value="Virgin Islands, British">Virgin Islands, British</option>
<option value="Virgin Islands, U.S.">Virgin Islands, U.S.</option>
<option value="Wallis and Futuna">Wallis and Futuna</option>
<option value="Western Sahara">Western Sahara</option>
<option value="Yemen">Yemen</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>
<p>
<label for="organizationSize">Organization's Size: </label><select id="organizationSize" name="organizationSize">
<option value="1-10">1 - 10 People</option>
<option value="11-50">11 - 50 People</option>
<option value="51 - 200">51 - 200 People</option>
<option value="More than 200">More than 200 People</option>
</select> </p>
<p>
<label for="lilacUse">How are you using this install of Lilac?</label>
<select id="lilacUse" name="lilacUse">
<option value="New Lilac User, also new to Nagios">New Lilac User, also new to Nagios</option>
<option value="New Lilac User, existing nagios user">New Lilac User, existing Nagios user</option>
<option value="Existing User">Existing Lilac User</option>
</select>
</p>
<p>
<label for="interestedInServices">Are You Interested In Commercial Support/Services For Lilac And Nagios, Or Open Source Monitoring In General?</label>
<select id="interestedInServices" name="interestedInServices">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
</p>
<br style="clear: both;">
<p id="interestedField" style="display: none;">
<label for="interestedEmail">Provide Your E-Mail and a Lilac Networks Representative Will Get You More Information</label>
<input type="text" id="interestedEmail" maxlength="255" />
</p>
<br style="clear: both;">
<p>
<input type="hidden" id="lilacVersion" value="<?php echo LILAC_VERSION;?>" />
<input class="btn btn-primary" type="submit" value="Submit Information" id="submitReg" />
</p>
</fieldset>
<p>
<a href="index.php">Launch Lilac Now</a>
</p>
<script type="text/javascript">
$(function() {
$("#interestedInServices").attr("value", "No");
$("#interestedInServices").change(function(event) {
if($(this).attr("value") == "Yes") {
$("#interestedField").show("fast");
}
else {
$("#interestedField").hide("fast");
}
});
$("#submitReg").click(function(event) {
event.preventDefault();
var request = {};
request.organizationName = $("#organizationName").attr("value");
request.organizationCountry = $("#organizationCountry").attr("value");
request.organizationSize = $("#organizationSize").attr("value");
request.lilacUse = $("#lilacUse").attr("value");