2014-01-15 02:51:25 +00:00
< ? php
2018-09-11 07:51:35 -05:00
use LibreNMS\Authentication\LegacyAuth ;
2017-11-18 11:33:03 +01:00
2015-09-01 22:42:02 +01:00
session_start ();
2016-08-18 20:28:22 -05:00
if ( empty ( $_POST ) && ! empty ( $_SESSION ) && ! isset ( $_REQUEST [ 'stage' ])) {
2015-09-01 22:42:02 +01:00
$_POST = $_SESSION ;
2017-08-18 20:29:12 +00:00
} elseif ( ! file_exists ( " ../config.php " )) {
2017-10-18 13:19:16 +01:00
$allowed_vars = array ( 'stage' , 'build-ok' , 'dbhost' , 'dbuser' , 'dbpass' , 'dbname' , 'dbport' , 'dbsocket' , 'add_user' , 'add_pass' , 'add_email' );
foreach ( $allowed_vars as $allowed ) {
if ( isset ( $_POST [ $allowed ])) {
$_SESSION [ $allowed ] = $_POST [ $allowed ];
}
}
2015-09-01 22:42:02 +01:00
}
2014-01-15 02:51:25 +00:00
2017-10-28 11:48:28 +02:00
$stage = isset ( $_POST [ 'stage' ]) ? $_POST [ 'stage' ] : 0 ;
2014-01-15 02:51:25 +00:00
// Before we do anything, if we see config.php, redirect back to the homepage.
2017-10-28 11:48:28 +02:00
if ( file_exists ( '../config.php' ) && $stage != 6 ) {
unset ( $_SESSION [ 'stage' ]);
header ( " Location: / " );
exit ;
}
2014-01-15 02:51:25 +00:00
2016-11-21 14:12:59 -06:00
// do not use the DB in init, we'll bring it up ourselves
$init_modules = array ( 'web' , 'nodb' );
require realpath ( __DIR__ . '/..' ) . '/includes/init.php' ;
// List of php modules we expect to see
2019-03-14 13:10:45 -05:00
$modules = array ( 'gd' , 'mysqlnd' , 'pdo_mysql' );
2016-11-21 14:12:59 -06:00
2015-09-01 22:42:02 +01:00
$dbhost = @ $_POST [ 'dbhost' ] ? : 'localhost' ;
$dbuser = @ $_POST [ 'dbuser' ] ? : 'librenms' ;
$dbpass = @ $_POST [ 'dbpass' ] ? : '' ;
$dbname = @ $_POST [ 'dbname' ] ? : 'librenms' ;
2017-01-27 23:16:04 +00:00
$dbport = @ $_POST [ 'dbport' ] ? : 3306 ;
2018-04-11 10:15:13 -05:00
if ( empty ( $_POST [ 'dbsocket' ])) {
$dbsocket = null ;
2017-04-06 16:02:37 -05:00
} else {
2018-04-11 10:15:13 -05:00
$dbhost = 'localhost' ;
$dbsocket = $_POST [ 'dbsocket' ];
$dbport = null ;
2017-04-06 16:02:37 -05:00
}
2016-11-21 14:12:59 -06:00
2015-09-01 22:42:02 +01:00
$add_user = @ $_POST [ 'add_user' ] ? : '' ;
$add_pass = @ $_POST [ 'add_pass' ] ? : '' ;
$add_email = @ $_POST [ 'add_email' ] ? : '' ;
2014-01-15 02:51:25 +00:00
// Check we can connect to MySQL DB, if not, back to stage 1 :)
2016-11-21 14:12:59 -06:00
if ( $stage > 1 ) {
2017-04-06 16:02:37 -05:00
try {
2017-08-18 20:29:12 +00:00
if ( $stage != 6 ) {
2018-04-11 10:15:13 -05:00
dbConnect ( $dbhost , $dbuser , $dbpass , $dbname , $dbport , $dbsocket );
2018-09-01 16:54:25 +01:00
if ( dbIsConnected () === false ) {
$msg = " We could not connect to your database, please check the details and try again " ;
$stage = 1 ;
}
2017-08-18 20:29:12 +00:00
}
2017-04-06 16:02:37 -05:00
if ( $stage == 2 && $_SESSION [ 'build-ok' ] == true ) {
$stage = 3 ;
$msg = " It appears that the database is already setup so have moved onto stage $stage " ;
2015-07-13 20:10:26 +02:00
}
2017-04-06 16:02:37 -05:00
} catch ( \LibreNMS\Exceptions\DatabaseConnectException $e ) {
$stage = 1 ;
$msg = " Couldn't connect to the database, please check your details<br /> " . $e -> getMessage ();
2014-01-15 02:51:25 +00:00
}
2015-09-01 22:42:02 +01:00
$_SESSION [ 'stage' ] = $stage ;
2016-11-21 14:12:59 -06:00
}
2017-07-01 15:28:29 -05:00
session_write_close ();
2016-11-21 14:12:59 -06:00
if ( $stage == 4 ) {
2015-07-13 20:10:26 +02:00
// Now check we have a username, password and email before adding new user
2016-08-18 20:28:22 -05:00
if ( empty ( $add_user ) || empty ( $add_pass ) || empty ( $add_email )) {
2015-09-01 22:42:02 +01:00
$stage = 3 ;
2015-07-13 20:10:26 +02:00
$msg = " You haven't entered enough information to add the user account, please check below and re-try " ;
}
2016-11-21 14:12:59 -06:00
} elseif ( $stage == 6 ) {
2015-07-13 20:10:26 +02:00
// If we get here then let's do some final checks.
2016-08-18 20:28:22 -05:00
if ( ! file_exists ( " ../config.php " )) {
2015-07-13 20:10:26 +02:00
// config.php file doesn't exist. go back to that stage
$msg = " config.php still doesn't exist " ;
2016-11-21 14:12:59 -06:00
$stage = 5 ;
2017-08-26 13:35:13 -05:00
} else {
// all done, remove all traces of the install session
session_unset ();
session_destroy ();
setcookie ( session_name (), '' , 0 , '/' );
session_regenerate_id ( true );
2015-07-13 20:10:26 +02:00
}
2014-01-15 02:51:25 +00:00
}
2016-08-18 20:28:22 -05:00
if ( empty ( $stage )) {
2016-11-21 14:12:59 -06:00
$stage = 0 ;
2014-01-15 02:51:25 +00:00
}
$total_stages = 6 ;
$stage_perc = $stage / $total_stages * 100 ;
$complete = 1 ;
?>
<! DOCTYPE HTML >
2017-08-08 14:26:03 -05:00
< html lang = " en " >
2014-01-15 02:51:25 +00:00
< head >
< title >< ? php echo ( $config [ 'page_title_prefix' ]); ?> </title>
2017-08-08 14:26:03 -05:00
< meta charset = " utf-8 " >
< meta http - equiv = " X-UA-Compatible " content = " IE=edge " >
2014-01-15 02:51:25 +00:00
< meta name = " viewport " content = " width=device-width, initial-scale=1.0 " >
< link href = " css/bootstrap.min.css " rel = " stylesheet " type = " text/css " />
< link href = " <?php echo( $config['stylesheet'] ); ?> " rel = " stylesheet " type = " text/css " />
< script src = " js/jquery.min.js " ></ script >
< script src = " js/bootstrap.min.js " ></ script >
< script src = " js/bootstrap-hover-dropdown.min.js " ></ script >
< script src = " js/hogan-2.0.0.js " ></ script >
</ head >
< body >
< div class = " container " >
< div class = " row " >
2017-08-08 14:26:03 -05:00
< div class = " col-md-6 col-md-offset-3 " >
2014-01-15 02:51:25 +00:00
< h2 class = " text-center " > Welcome to the < ? php echo ( $config [ 'project_name' ]); ?> install</h2>
</ div >
</ div >
< div class = " row " >
2017-08-08 14:26:03 -05:00
< div class = " col-md-6 col-md-offset-3 " >
2016-08-03 10:06:33 -05:00
< h4 class = " text-center " > Stage < ? php echo $stage ; ?> of <?php echo $total_stages; ?> complete</h4>
2014-01-15 02:51:25 +00:00
</ div >
</ div >
< ? php
2015-07-13 20:10:26 +02:00
2016-08-18 20:28:22 -05:00
if ( ! empty ( $msg )) {
2014-01-15 02:51:25 +00:00
?>
< div class = " row " >
2017-08-08 14:26:03 -05:00
< div class = " col-md-6 col-md-offset-3 " >
2014-01-15 02:51:25 +00:00
< div class = " alert alert-danger " >< ? php echo $msg ; ?> </div>
</ div >
</ div >
< ? php
}
?>
< div class = " row " >
2017-08-08 14:26:03 -05:00
< div class = " col-md-6 col-md-offset-3 " >
2017-08-26 13:35:13 -05:00
< div id = " install-progress " class = " progress progress-striped " >
< div class = " progress-bar progress-bar-success " role = " progressbar " aria - valuenow = " <?php echo $stage_perc ; ?> "
aria - valuemin = " 0 " aria - valuemax = " 100 " style = " width: <?php echo $stage_perc ; ?>% " >
2014-01-15 02:51:25 +00:00
< span class = " sr-only " >< ? php echo $stage_perc ; ?> % Complete</span>
</ div >
</ div >
</ div >
</ div >
< ? php
2016-08-18 20:28:22 -05:00
if ( $stage == 0 ) {
2014-01-15 02:51:25 +00:00
?>
< div class = " row " >
2017-08-08 14:26:03 -05:00
< div class = " col-md-6 col-md-offset-3 " >
< h4 class = " text-center " > Pre - Install Checks </ h4 >
2014-01-15 02:51:25 +00:00
</ div >
</ div >
< div class = " row " >
2017-08-08 14:26:03 -05:00
< div class = " col-md-6 col-md-offset-3 " >
2014-01-15 02:51:25 +00:00
< table class = " table table-condensed table-bordered " >
< tr >
2017-08-08 14:26:03 -05:00
< th > Item </ th >
< th > Status </ th >
2014-01-15 02:51:25 +00:00
< th > Comments </ th >
</ tr >
< ? php
2017-08-08 14:26:03 -05:00
$complete = true ;
2016-08-18 20:28:22 -05:00
foreach ( $modules as $extension ) {
if ( extension_loaded ( " $extension " )) {
2017-08-08 14:26:03 -05:00
$status = 'installed' ;
2016-08-18 20:28:22 -05:00
$row_class = 'success' ;
} else {
2017-08-08 14:26:03 -05:00
$status = 'missing' ;
2016-08-18 20:28:22 -05:00
$row_class = 'danger' ;
2017-08-08 14:26:03 -05:00
$complete = false ;
2016-08-18 20:28:22 -05:00
}
2015-07-13 20:10:26 +02:00
2017-08-08 14:26:03 -05:00
echo " <tr class=' $row_class '><td>PHP module <strong> $extension </strong></td><td> $status </td><td></td></tr> " ;
2016-08-18 20:28:22 -05:00
}
2014-01-15 02:51:25 +00:00
2017-09-18 13:22:24 -05:00
if ( is_writable ( session_save_path () === '' ? '/tmp' : session_save_path ())) {
2017-08-08 14:26:03 -05:00
$status = 'yes' ;
2016-08-18 20:28:22 -05:00
$row_class = 'success' ;
} else {
2017-08-08 14:26:03 -05:00
$status = 'no' ;
2016-08-18 20:28:22 -05:00
$row_class = 'danger' ;
2017-08-08 14:26:03 -05:00
$complete = false ;
2016-08-18 20:28:22 -05:00
}
2015-07-13 20:10:26 +02:00
2017-08-08 14:26:03 -05:00
echo " <tr class=' $row_class '><td>Session directory writable</td><td> $status </td><td> " ;
if ( $status == 'no' ) {
echo session_save_path () . " is not writable " ;
2017-11-10 09:20:47 -06:00
if ( function_exists ( 'posix_getgrgid' )) {
$group_info = posix_getgrgid ( filegroup ( session_save_path ()));
if ( $group_info [ 'gid' ] !== 0 ) { // don't suggest adding users to the root group
$group = $group_info [ 'name' ];
$user = get_current_user ();
echo " , suggested fix <strong>usermod -a -G $group $user </strong> " ;
}
2017-08-08 14:26:03 -05:00
}
2016-08-18 20:28:22 -05:00
}
2017-08-08 14:26:03 -05:00
echo " </td></tr> " ;
2014-01-15 02:51:25 +00:00
?>
</ table >
</ div >
</ div >
< div class = " row " >
2017-08-08 14:26:03 -05:00
< div class = " col-md-6 col-md-offset-3 " >
2014-01-15 02:51:25 +00:00
< form class = " form-inline " role = " form " method = " post " >
< input type = " hidden " name = " stage " value = " 1 " >
2017-11-29 02:23:19 -06:00
< button type = " submit " class = " btn btn-success pull-right "
< ? php
if ( ! $complete ) {
2016-08-18 20:28:22 -05:00
echo " disabled='disabled' " ;
2017-11-29 02:23:19 -06:00
}
?> >Next Stage</button>
2014-01-15 02:51:25 +00:00
</ form >
</ div >
</ div >
< ? php
2016-08-18 20:28:22 -05:00
} elseif ( $stage == 1 ) {
2014-01-15 02:51:25 +00:00
?>
< div class = " row " >
< div class = " col-md-3 " >
</ div >
< div class = " col-md-6 " >
< form class = " form-horizontal " role = " form " method = " post " >
< input type = " hidden " name = " stage " value = " 2 " >
< div class = " form-group " >
< label for = " dbhost " class = " col-sm-4 " control - label " >DB Host: </label>
< div class = " col-sm-8 " >
2017-04-06 16:02:37 -05:00
< input type = " text " class = " form-control " name = " dbhost " id = " dbhost " value = " <?php echo $dbhost ; ?> " placeholder = " Leave empty if using Unix-Socket " >
2014-01-15 02:51:25 +00:00
</ div >
</ div >
2017-01-27 23:16:04 +00:00
< div class = " form-group " >
< label for = " dbport " class = " col-sm-4 " control - label " >DB Port: </label>
< div class = " col-sm-8 " >
2017-04-06 16:02:37 -05:00
< input type = " text " class = " form-control " name = " dbport " id = " dbport " value = " <?php echo $dbport ; ?> " placeholder = " Leave empty if using Unix-Socket " >
</ div >
</ div >
< div class = " form-group " >
< label for = " dbsocket " class = " col-sm-4 " control - label " >DB Unix-Socket: </label>
< div class = " col-sm-8 " >
< input type = " text " class = " form-control " name = " dbsocket " id = " dbsocket " value = " <?php echo $dbsocket ; ?> " placeholder = " Leave empty if using Host " >
2017-01-27 23:16:04 +00:00
</ div >
</ div >
2014-01-15 02:51:25 +00:00
< div class = " form-group " >
< label for = " dbuser " class = " col-sm-4 " control - label " >DB User: </label>
< div class = " col-sm-8 " >
< input type = " text " class = " form-control " name = " dbuser " id = " dbuser " value = " <?php echo $dbuser ; ?> " >
</ div >
</ div >
< div class = " form-group " >
< label for = " dbpass " class = " col-sm-4 " control - label " >DB Pass: </label>
< div class = " col-sm-8 " >
< input type = " password " class = " form-control " name = " dbpass " id = " dbpass " value = " <?php echo $dbpass ; ?> " >
</ div >
</ div >
< div class = " form-group " >
< label for = " dbname " class = " col-sm-4 " control - label " >DB Name: </label>
< div class = " col-sm-8 " >
< input type = " text " class = " form-control " name = " dbname " id = " dbname " value = " <?php echo $dbname ; ?> " >
</ div >
</ div >
2017-08-26 13:35:13 -05:00
< button type = " submit " class = " btn btn-success pull-right " > Next Stage </ button >
2014-01-15 02:51:25 +00:00
</ form >
</ div >
< div class = " col-md-3 " >
</ div >
</ div >
< ? php
2016-08-18 20:28:22 -05:00
} elseif ( $stage == " 2 " ) {
2014-01-15 02:51:25 +00:00
?>
< div class = " row " >
< div class = " col-md-3 " >
</ div >
< div class = " col-md-6 " >
2015-08-11 08:39:14 +10:00
< h5 class = " text-center " > Importing MySQL DB - Do not close this page or interrupt the import </ h5 >
2017-07-01 15:28:29 -05:00
< textarea readonly id = " db-update " class = " form-control " rows = " 20 " placeholder = " Please Wait... " style = " resize:vertical; " ></ textarea >
2014-01-15 02:51:25 +00:00
</ div >
< div class = " col-md-3 " >
</ div >
</ div >
< div class = " row " >
< div class = " col-md-3 " >
</ div >
< div class = " col-md-6 " >
If you don ' t see any errors or messages above then the database setup has been successful .< br />
< form class = " form-horizontal " role = " form " method = " post " >
< input type = " hidden " name = " stage " value = " 3 " >
< input type = " hidden " name = " dbhost " value = " <?php echo $dbhost ; ?> " >
< input type = " hidden " name = " dbuser " value = " <?php echo $dbuser ; ?> " >
< input type = " hidden " name = " dbpass " value = " <?php echo $dbpass ; ?> " >
< input type = " hidden " name = " dbname " value = " <?php echo $dbname ; ?> " >
2017-01-27 23:16:04 +00:00
< input type = " hidden " name = " dbport " value = " <?php echo $dbport ; ?> " >
2017-04-06 16:02:37 -05:00
< input type = " hidden " name = " dbsocket " value = " <?php echo $dbsocket ; ?> " >
2017-08-26 13:35:13 -05:00
< input type = " button " id = " retry-btn " value = " Retry " onClick = " window.location.reload() " style = " display: none; " class = " btn btn-success " >
< button type = " submit " id = " add-user-btn " class = " btn btn-success pull-right " disabled > Goto Add User </ button >
2015-05-10 16:40:38 +03:00
</ form >
2014-01-15 02:51:25 +00:00
</ div >
< div class = " col-md-3 " >
</ div >
</ div >
2017-07-01 15:28:29 -05:00
< script type = " text/javascript " >
2017-08-26 13:35:13 -05:00
var output = document . getElementById ( " db-update " );
2017-07-01 15:28:29 -05:00
xhr = new XMLHttpRequest ();
xhr . open ( " GET " , " ajax_output.php?id=db-update " , true );
xhr . onprogress = function ( e ) {
output . innerHTML = e . currentTarget . responseText ;
output . scrollTop = output . scrollHeight - output . clientHeight ; // scrolls the output area
2019-01-23 23:42:19 -06:00
if ( output . innerHTML . indexOf ( 'Error!' ) !== - 1 ) {
// if error word in output, show the retry button
$ ( " #retry-btn " ) . css ( " display " , " " );
}
2017-07-01 15:28:29 -05:00
};
2017-09-07 03:28:03 -05:00
xhr . timeout = 90000 ; // if no response for 90s, allow the user to retry
2017-08-26 13:35:13 -05:00
xhr . ontimeout = function ( e ) {
$ ( " #retry-btn " ) . css ( " display " , " " );
};
2017-07-01 15:28:29 -05:00
xhr . onreadystatechange = function () {
2017-08-26 13:35:13 -05:00
if ( xhr . readyState === XMLHttpRequest . DONE ) {
if ( xhr . status === 200 ) {
console . log ( " Complete " );
$ ( '#add-user-btn' ) . removeAttr ( 'disabled' );
}
$ ( '#install-progress' ) . removeClass ( 'active' )
2017-07-01 15:28:29 -05:00
}
};
xhr . send ();
2017-08-26 13:35:13 -05:00
$ ( '#install-progress' ) . addClass ( 'active' )
2017-07-01 15:28:29 -05:00
</ script >
2014-01-15 02:51:25 +00:00
< ? php
2016-08-18 20:28:22 -05:00
} elseif ( $stage == " 5 " ) {
2014-01-15 02:51:25 +00:00
?>
< div class = " row " >
< div class = " col-md-3 " >
</ div >
< div class = " col-md-6 " >
< ? php
// Create the config file we will write or display
$config_file = <<< " EOD "
## Have a look in defaults.inc.php for examples of settings you can set here. DO NOT EDIT defaults.inc.php!
### Database config
2015-09-21 13:23:09 +00:00
\ $config\ [ 'db_host' \ ] = '$dbhost' ;
2017-01-27 23:16:04 +00:00
\ $config\ [ 'db_port' \ ] = '$dbport' ;
2015-09-21 13:23:09 +00:00
\ $config\ [ 'db_user' \ ] = '$dbuser' ;
\ $config\ [ 'db_pass' \ ] = '$dbpass' ;
\ $config\ [ 'db_name' \ ] = '$dbname' ;
2017-04-06 16:02:37 -05:00
\ $config\ [ 'db_socket' \ ] = '$dbsocket' ;
2014-01-15 02:51:25 +00:00
2015-09-21 21:06:57 +00:00
// This is the user LibreNMS will run as
//Please ensure this user is created and has the correct permissions to your install
\ $config [ 'user' ] = 'librenms' ;
2014-01-15 02:51:25 +00:00
### Locations - it is recommended to keep the default
2017-06-29 01:09:22 -05:00
#\$config\['install_dir'\] = "$install_dir";
2014-01-15 02:51:25 +00:00
### This should *only* be set if you want to *force* a particular hostname/port
### It will prevent the web interface being usable form any other hostname
#\$config\['base_url'\] = "http://librenms.company.com";
### Enable this to use rrdcached. Be sure rrd_dir is within the rrdcached dir
### and that your web server has permission to talk to rrdcached.
#\$config\['rrdcached'\] = "unix:/var/run/rrdcached.sock";
### Default community
\ $config\ [ 'snmp' \ ] \ [ 'community' \ ] = array ( " public " );
### Authentication Model
\ $config\ [ 'auth_mechanism' \ ] = " mysql " ; # default, other options: ldap, http-auth
#\$config\['http_auth_guest'\] = "guest"; # remember to configure this user if you use http-auth
### List of RFC1918 networks to allow scanning-based discovery
#\$config\['nets'\]\[\] = "10.0.0.0/8";
#\$config\['nets'\]\[\] = "172.16.0.0/12";
#\$config\['nets'\]\[\] = "192.168.0.0/16";
2018-02-08 15:46:55 -06:00
# Update configuration
#\$config\['update_channel'\] = 'release'; # uncomment to follow the monthly release channel
#\$config\['update'\] = 0; # uncomment to completely disable updates
2014-01-15 02:51:25 +00:00
EOD ;
2016-08-18 20:28:22 -05:00
if ( ! file_exists ( " ../config.php " )) {
2014-01-15 02:51:25 +00:00
$conf = fopen ( " ../config.php " , 'w' );
2015-07-13 20:10:26 +02:00
if ( $conf != false ) {
2016-08-18 20:28:22 -05:00
if ( fwrite ( $conf , " <?php \n " ) === false ) {
2015-07-13 20:10:26 +02:00
echo ( " <div class='alert alert-danger'>We couldn't create the config.php file, please create this manually before continuing by copying the below into a config.php in the root directory of your install (typically /opt/librenms/)</div> " );
echo ( " <pre><?php \n " . stripslashes ( $config_file ) . " </pre> " );
2016-08-18 20:28:22 -05:00
} else {
2015-07-13 20:10:26 +02:00
$config_file = stripslashes ( $config_file );
2016-08-18 20:28:22 -05:00
fwrite ( $conf , $config_file );
2015-07-13 20:10:26 +02:00
echo ( " <div class='alert alert-success'>The config file has been created</div> " );
}
2016-08-18 20:28:22 -05:00
} else {
2015-05-11 00:48:38 +03:00
echo ( " <div class='alert alert-danger'>We couldn't create the config.php file, please create this manually before continuing by copying the below into a config.php in the root directory of your install (typically /opt/librenms/)</div> " );
echo ( " <pre><?php \n " . stripslashes ( $config_file ) . " </pre> " );
2014-01-15 02:51:25 +00:00
}
2015-07-13 20:10:26 +02:00
}
2014-01-15 02:51:25 +00:00
?>
< form class = " form-horizontal " role = " form " method = " post " >
< input type = " hidden " name = " stage " value = " 6 " >
< input type = " hidden " name = " dbhost " value = " <?php echo $dbhost ; ?> " >
< input type = " hidden " name = " dbuser " value = " <?php echo $dbuser ; ?> " >
< input type = " hidden " name = " dbpass " value = " <?php echo $dbpass ; ?> " >
< input type = " hidden " name = " dbname " value = " <?php echo $dbname ; ?> " >
2017-04-06 16:02:37 -05:00
< input type = " hidden " name = " dbsocket " value = " <?php echo $dbsocket ; ?> " >
2017-08-26 13:35:13 -05:00
< button type = " submit " class = " btn btn-success pull-right " > Finish install </ button >
2014-01-15 02:51:25 +00:00
</ form >
< ? php
?>
</ div >
< div class = " col-md-3 " >
</ div >
</ div >
< ? php
2016-08-18 20:28:22 -05:00
} elseif ( $stage == " 3 " ) {
2014-01-15 02:51:25 +00:00
?>
< div class = " row " >
< div class = " col-md-3 " >
</ div >
< div class = " col-md-6 " >
< form class = " form-horizontal " role = " form " method = " post " >
< input type = " hidden " name = " stage " value = " 4 " >
< input type = " hidden " name = " dbhost " value = " <?php echo $dbhost ; ?> " >
< input type = " hidden " name = " dbuser " value = " <?php echo $dbuser ; ?> " >
< input type = " hidden " name = " dbpass " value = " <?php echo $dbpass ; ?> " >
< input type = " hidden " name = " dbname " value = " <?php echo $dbname ; ?> " >
2017-04-06 16:02:37 -05:00
< input type = " hidden " name = " dbsocket " value = " <?php echo $dbsocket ; ?> " >
2014-01-15 02:51:25 +00:00
< div class = " form-group " >
< label for = " add_user " class = " col-sm-4 control-label " > Username </ label >
< div class = " col-sm-8 " >
< input type = " text " class = " form-control " name = " add_user " id = " add_user " value = " <?php echo $add_user ; ?> " >
</ div >
</ div >
< div class = " form-group " >
< label for = " add_pass " class = " col-sm-4 control-label " > Password </ label >
< div class = " col-sm-8 " >
< input type = " password " class = " form-control " name = " add_pass " id = " add_pass " value = " <?php echo $add_pass ; ?> " >
</ div >
</ div >
< div class = " form-group " >
< label for = " add_email " class = " col-sm-4 control-label " > Email </ label >
< div class = " col-sm-8 " >
< input type = " email " class = " form-control " name = " add_email " id = " add_email " value = " <?php echo $add_email ; ?> " >
</ div >
</ div >
2017-08-26 13:35:13 -05:00
< button type = " submit " class = " btn btn-success pull-right " > Add User </ button >
2014-01-15 02:51:25 +00:00
</ form >
</ div >
< div class = " col-md-3 " >
</ div >
</ div >
< ? php
2016-08-18 20:28:22 -05:00
} elseif ( $stage == " 4 " ) {
2015-07-13 20:10:26 +02:00
$proceed = 1 ;
2014-01-15 02:51:25 +00:00
?>
< div class = " row " >
< div class = " col-md-3 " >
</ div >
< div class = " col-md-6 " >
< ? php
2018-09-11 07:51:35 -05:00
if ( LegacyAuth :: get () -> canManageUsers ()) {
if ( ! LegacyAuth :: get () -> userExists ( $add_user )) {
if ( LegacyAuth :: get () -> addUser ( $add_user , $add_pass , '10' , $add_email )) {
2016-08-18 20:28:22 -05:00
echo ( " <div class='alert alert-success'>User has been added successfully</div> " );
$proceed = 0 ;
} else {
echo ( " <div class='alert alert-danger'>User hasn't been added, please try again</div> " );
2015-07-13 20:10:26 +02:00
}
2016-08-18 20:28:22 -05:00
} else {
echo ( " <div class='alert alert-danger'>User $add_user already exists!</div> " );
2014-01-15 02:51:25 +00:00
}
2016-08-18 20:28:22 -05:00
} else {
echo ( " <div class='alert alert-danger'>Auth module isn't loaded</div> " );
}
2014-01-15 02:51:25 +00:00
?>
< form class = " form-horizontal " role = " form " method = " post " >
< input type = " hidden " name = " stage " value = " 5 " >
< input type = " hidden " name = " dbhost " value = " <?php echo $dbhost ; ?> " >
< input type = " hidden " name = " dbuser " value = " <?php echo $dbuser ; ?> " >
< input type = " hidden " name = " dbpass " value = " <?php echo $dbpass ; ?> " >
< input type = " hidden " name = " dbname " value = " <?php echo $dbname ; ?> " >
2017-04-06 16:02:37 -05:00
< input type = " hidden " name = " dbsocket " value = " <?php echo $dbsocket ; ?> " >
2017-11-29 02:23:19 -06:00
< button type = " submit " class = " btn btn-success pull-right "
< ? php
if ( $proceed == " 1 " ) {
2016-08-18 20:28:22 -05:00
echo " disabled='disabled' " ;
2017-11-29 02:23:19 -06:00
}
?> >Generate Config</button>
2014-01-15 02:51:25 +00:00
</ form >
</ div >
< div class = " col-md-3 " >
</ div >
</ div >
< ? php
2016-08-18 20:28:22 -05:00
} elseif ( $stage == " 6 " ) {
2014-01-15 02:51:25 +00:00
?>
2016-08-05 19:52:22 +01:00
< div class = " row " >
< div class = " col-md-offset-3 col-md-6 " >
2017-10-26 01:56:09 -05:00
< div class = " alert alert-danger " >
< p > You haven ' t quite finished yet !</ p >
< p > First , you need to < a href = " validate/ " > validate your install and fix any issues .</ a ></ p >
</ div >
2016-08-05 19:52:22 +01:00
</ div >
</ div >
2014-01-15 02:51:25 +00:00
< div class = " row " >
< div class = " col-md-3 " >
</ div >
< div class = " col-md-6 " >
2017-10-26 01:56:09 -05:00
< div class = " alert alert-success " >
< p > Thank you for setting up LibreNMS .</ p >
< p > It would be great if you would consider contributing to our statistics , you can do this on the < a href = " about/ " > About LibreNMS Page </ a > and check the box under Statistics .</ p >
2014-01-15 02:51:25 +00:00
</ div >
< div class = " col-md-3 " >
</ div >
< ? php
}
?>
</ div >
</ body >
</ html >