Revert "Fix coding style old files (part 2)"

This commit is contained in:
Daniel Preussker
2015-07-15 08:09:10 +00:00
parent 4ebabc634a
commit ba90b85f9f
731 changed files with 33750 additions and 37288 deletions
+167 -132
View File
@@ -3,9 +3,10 @@
$stage = $_POST['stage'];
// Before we do anything, if we see config.php, redirect back to the homepage.
if(file_exists('../config.php') && $stage != "6") {
header("Location: /");
exit;
if(file_exists('../config.php') && $stage != "6")
{
header("Location: /");
exit;
}
// List of php modules we expect to see
@@ -19,65 +20,76 @@ $add_user = $_POST['add_user'] ?: '';
$add_pass = $_POST['add_pass'] ?: '';
$add_email = $_POST['add_email'] ?: '';
if($stage == "4" || $stage == "3") {
// Ok now let's set the db connection up
$config['db_host']=$dbhost;
$config['db_user']=$dbuser;
$config['db_pass']=$dbpass;
$config['db_name']=$dbname;
if($stage == "4" || $stage == "3")
{
// Ok now let's set the db connection up
$config['db_host']=$dbhost;
$config['db_user']=$dbuser;
$config['db_pass']=$dbpass;
$config['db_name']=$dbname;
}
require '../includes/defaults.inc.php';
include("../includes/defaults.inc.php");
// Work out the install directory
$cur_dir = explode('/',$_SERVER['DOCUMENT_ROOT']);
$check = end($cur_dir);
if( empty($check) ) {
$install_dir = array_pop($cur_dir);
$install_dir = array_pop($cur_dir);
}
unset($check);
$install_dir = array_pop($cur_dir);
$install_dir = implode('/',$cur_dir);
$config['install_dir'] = $install_dir;
$config['log_dir'] = $install_dir.'/logs';
if($_POST['stage'] == "3" || $_POST['stage'] == "4") {
require_once '../includes/definitions.inc.php';
if($_POST['stage'] == "3" || $_POST['stage'] == "4")
{
include_once("../includes/definitions.inc.php");
}
require '../includes/functions.php';
require 'includes/functions.inc.php';
include("../includes/functions.php");
include("includes/functions.inc.php");
// Check we can connect to MySQL DB, if not, back to stage 1 :)
if($stage == 2) {
$test_db = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
if(mysqli_connect_error()) {
$stage = 1;
$msg = "Couldn't connect to the database, please check your details<br /> " . mysqli_connect_error();
}
else {
$sql = "SELECT * FROM users LIMIT 1";
if(mysqli_query($test_db,$sql)) {
$stage = 3;
$msg = "It appears that the database is already setup so have moved onto stage $stage";
}
if($stage == 2)
{
$test_db = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
if(mysqli_connect_error())
{
$stage = 1;
$msg = "Couldn't connect to the database, please check your details<br /> " . mysqli_connect_error();
}
else
{
$sql = "SELECT * FROM users LIMIT 1";
if(mysqli_query($test_db,$sql))
{
$stage = 3;
$msg = "It appears that the database is already setup so have moved onto stage $stage";
}
}
}
elseif($stage == "4") {
// Now check we have a username, password and email before adding new user
if(empty($add_user) || empty($add_pass) || empty($add_email)) {
$stage = 4;
$msg = "You haven't entered enough information to add the user account, please check below and re-try";
}
elseif($stage == "4")
{
// Now check we have a username, password and email before adding new user
if(empty($add_user) || empty($add_pass) || empty($add_email))
{
$stage = 4;
$msg = "You haven't entered enough information to add the user account, please check below and re-try";
}
}
elseif($stage == "6") {
// If we get here then let's do some final checks.
if(!file_exists("../config.php")) {
// config.php file doesn't exist. go back to that stage
$msg = "config.php still doesn't exist";
$stage = "5";
}
elseif($stage == "6")
{
// If we get here then let's do some final checks.
if(!file_exists("../config.php"))
{
// config.php file doesn't exist. go back to that stage
$msg = "config.php still doesn't exist";
$stage = "5";
}
}
if(empty($stage)) {
$stage = '0';
if(empty($stage))
{
$stage = '0';
}
$total_stages = 6;
@@ -126,8 +138,8 @@ $complete = 1;
</div>
</div>
<?php
if(!empty($msg)) {
if(!empty($msg))
{
?>
<div class="row">
@@ -160,7 +172,8 @@ if(!empty($msg)) {
<?php
if($stage == 0) {
if($stage == 0)
{
?>
@@ -185,51 +198,57 @@ if($stage == 0) {
</tr>
<?php
foreach ($modules as $extension) {
if (extension_loaded("$extension")) {
$ext_loaded = 'yes';
$row_class = 'success';
}
else {
$ext_loaded = 'no';
$row_class = 'danger';
$complete = 0;
}
foreach ($modules as $extension)
{
if (extension_loaded("$extension"))
{
$ext_loaded = 'yes';
$row_class = 'success';
} else {
$ext_loaded = 'no';
$row_class = 'danger';
$complete = 0;
}
echo(" <tr class='$row_class'>
<td>$extension</td>
<td>$ext_loaded</td>");
if($ext_loaded == 'no') {
echo("<td>apt-get install php5-$extension / yum install php-$extension</td>");
}
else {
echo("<td></td>");
}
echo("</tr>");
}
echo(" <tr class='$row_class'>
<td>$extension</td>
<td>$ext_loaded</td>");
if($ext_loaded == 'no')
{
echo("<td>apt-get install php5-$extension / yum install php-$extension</td>");
}
else
{
echo("<td></td>");
}
echo("</tr>");
}
// Check for pear install
require_once 'System.php';
// Check for pear install
include_once 'System.php';
if(class_exists('System')===true)
{
$ext_loaded = 'yes';
$row_class = 'success';
}
else
{
$ext_loaded = 'no';
$row_class = 'danger';
}
if(class_exists('System') === true) {
$ext_loaded = 'yes';
$row_class = 'success';
}
else {
$ext_loaded = 'no';
$row_class = 'danger';
}
echo(" <tr class='$row_class'>
<td>pear</td>
<td>$ext_loaded</td>");
if($ext_loaded == 'no') {
echo("<td>apt-get install php5-$extension / yum install php-$extension</td>");
}
else {
echo("<td></td>");
}
echo("</tr>");
echo(" <tr class='$row_class'>
<td>pear</td>
<td>$ext_loaded</td>");
if($ext_loaded == 'no')
{
echo("<td>apt-get install php5-$extension / yum install php-$extension</td>");
}
else
{
echo("<td></td>");
}
echo("</tr>");
?>
</table>
</div>
@@ -242,7 +261,7 @@ if($stage == 0) {
<div class="col-md-6">
<form class="form-inline" role="form" method="post">
<input type="hidden" name="stage" value="1">
<button type="submit" class="btn btn-success" <?php if($complete == '0') echo "disabled='disabled'"; ?>>Next Stage</button>
<button type="submit" class="btn btn-success" <?php if($complete == '0') { echo "disabled='disabled'"; } ?>>Next Stage</button>
</form>
</div>
<div class="col-md-3">
@@ -251,7 +270,8 @@ if($stage == 0) {
<?php
}
elseif($stage == 1) {
elseif($stage == 1)
{
?>
@@ -295,7 +315,8 @@ elseif($stage == 1) {
<?php
}
elseif($stage == "2") {
elseif($stage == "2")
{
?>
<div class="row">
<div class="col-md-3">
@@ -304,12 +325,12 @@ elseif($stage == "2") {
<h5 class="text-center">Importing MySQL DB</h5>
<?php
// Ok now let's set the db connection up
$config['db_host']=$dbhost;
$config['db_user']=$dbuser;
$config['db_pass']=$dbpass;
$config['db_name']=$dbname;
$sql_file = '../build.sql';
require('../build-base.php');
$config['db_host']=$dbhost;
$config['db_user']=$dbuser;
$config['db_pass']=$dbpass;
$config['db_name']=$dbname;
$sql_file = '../build.sql';
require('../build-base.php');
?>
</div>
<div class="col-md-3">
@@ -334,7 +355,8 @@ elseif($stage == "2") {
</div>
<?php
}
elseif($stage == "5") {
elseif($stage == "5")
{
?>
<div class="row">
@@ -388,24 +410,27 @@ $config_file = <<<"EOD"
#\$config\['update'\] = 0;
EOD;
if(!file_exists("../config.php")) {
if(!file_exists("../config.php"))
{
$conf = fopen("../config.php", 'w');
if ($conf != false) {
if(fwrite($conf, "<?php\n") === FALSE) {
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>&lt;?php\n".stripslashes($config_file)."</pre>");
}
else {
$config_file = stripslashes($config_file);
fwrite($conf,$config_file);
echo("<div class='alert alert-success'>The config file has been created</div>");
}
}
else {
if ($conf != false)
{
if(fwrite($conf, "<?php\n") === FALSE)
{
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>&lt;?php\n".stripslashes($config_file)."</pre>");
}
else
{
$config_file = stripslashes($config_file);
fwrite($conf,$config_file);
echo("<div class='alert alert-success'>The config file has been created</div>");
}
} else {
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>&lt;?php\n".stripslashes($config_file)."</pre>");
}
}
}
?>
<form class="form-horizontal" role="form" method="post">
<input type="hidden" name="stage" value="6">
@@ -425,7 +450,8 @@ if(!file_exists("../config.php")) {
<?php
}
elseif($stage == "3") {
elseif($stage == "3")
{
?>
<div class="row">
<div class="col-md-3">
@@ -463,32 +489,39 @@ elseif($stage == "3") {
</div>
<?php
}
elseif($stage == "4") {
$proceed = 1;
elseif($stage == "4")
{
$proceed = 1;
?>
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-6">
<?php
require 'includes/authenticate.inc.php';
if (auth_usermanagement()) {
if (!user_exists($add_user)) {
if (adduser($add_user,$add_pass,'10',$add_email)) {
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>");
}
}
else {
echo("<div class='alert alert-danger'>User $add_user already exists!</div>");
}
include("includes/authenticate.inc.php");
if (auth_usermanagement())
{
if (!user_exists($add_user))
{
if (adduser($add_user,$add_pass,'10',$add_email))
{
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>");
}
}
else {
echo("<div class='alert alert-danger'>Auth module isn't loaded</div>");
else
{
echo("<div class='alert alert-danger'>User $add_user already exists!</div>");
}
}
else
{
echo("<div class='alert alert-danger'>Auth module isn't loaded</div>");
}
?>
<form class="form-horizontal" role="form" method="post">
@@ -497,7 +530,7 @@ elseif($stage == "4") {
<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; ?>">
<button type="submit" class="btn btn-success" <?php if($proceed == "1") echo "disabled='disabled'"; ?>>Generate Config</button>
<button type="submit" class="btn btn-success" <?php if($proceed == "1") { echo "disabled='disabled'"; } ?>>Generate Config</button>
</form>
</div>
<div class="col-md-3">
@@ -505,7 +538,8 @@ elseif($stage == "4") {
</div>
<?php
}
elseif($stage == "6") {
elseif($stage == "6")
{
?>
<div class="row">
<div class="col-md-3">
@@ -522,3 +556,4 @@ elseif($stage == "6") {
</div>
</body>
</html>