phpnuxbill/install/step4.php

148 lines
4.3 KiB
PHP
Raw Normal View History

2022-09-19 10:31:35 +08:00
<?php
2023-09-29 15:11:44 +08:00
2022-09-19 10:31:35 +08:00
/**
2023-10-12 16:55:42 +08:00
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
2023-09-29 15:11:44 +08:00
**/
2023-10-12 16:55:42 +08:00
2022-09-19 10:31:35 +08:00
//error_reporting (0);
$appurl = $_POST['appurl'];
$db_host = $_POST['dbhost'];
$db_user = $_POST['dbuser'];
$db_password = $_POST['dbpass'];
$db_name = $_POST['dbname'];
$cn = '0';
2023-09-29 15:11:44 +08:00
try {
$dbh = new pdo(
"mysql:host=$db_host;dbname=$db_name",
2022-09-19 10:31:35 +08:00
"$db_user",
"$db_password",
2023-09-29 15:11:44 +08:00
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
);
2022-09-19 10:31:35 +08:00
$cn = '1';
2023-09-29 15:11:44 +08:00
} catch (PDOException $ex) {
2022-09-19 10:31:35 +08:00
$cn = '0';
}
if ($cn == '1') {
2023-10-27 11:36:10 +08:00
if (isset($_POST['radius']) && $_POST['radius'] == 'yes') {
2023-09-29 15:11:44 +08:00
$input = '<?php
2022-10-04 11:06:38 +08:00
2022-10-05 11:51:18 +08:00
define(\'APP_URL\', \'' . $appurl . '\');
$_app_stage = \'Live\';
// Database PHPNuxBill
2022-09-19 10:31:35 +08:00
$db_host = \'' . $db_host . '\';
$db_user = \'' . $db_user . '\';
$db_password = \'' . $db_password . '\';
$db_name = \'' . $db_name . '\';
2022-10-05 11:51:18 +08:00
// Database Radius
$radius_host = \'' . $db_host . '\';
$radius_user = \'' . $db_user . '\';
$radius_pass = \'' . $db_password . '\';
$radius_name = \'' . $db_name . '\';
2022-10-04 11:06:38 +08:00
if($_app_stage!=\'Live\'){
error_reporting(E_ERROR);
ini_set(\'display_errors\', 1);
ini_set(\'display_startup_errors\', 1);
}else{
error_reporting(E_ERROR);
ini_set(\'display_errors\', 0);
ini_set(\'display_startup_errors\', 0);
}
';
2023-09-29 15:11:44 +08:00
} else {
$input = '<?php
define(\'APP_URL\', \'' . $appurl . '\');
$_app_stage = \'Live\';
// Database PHPNuxBill
$db_host = \'' . $db_host . '\';
$db_user = \'' . $db_user . '\';
$db_password = \'' . $db_password . '\';
$db_name = \'' . $db_name . '\';
if($_app_stage!=\'Live\'){
error_reporting(E_ERROR);
ini_set(\'display_errors\', 1);
ini_set(\'display_startup_errors\', 1);
}else{
error_reporting(E_ERROR);
ini_set(\'display_errors\', 0);
ini_set(\'display_startup_errors\', 0);
}
';
}
$wConfig = "../config.php";
2022-09-19 10:31:35 +08:00
$fh = fopen($wConfig, 'w') or die("Can't create config file, your server does not support 'fopen' function,
please create a file named - config.php with following contents- <br/>$input");
fwrite($fh, $input);
fclose($fh);
2022-10-16 15:48:21 +08:00
$sql = file_get_contents('phpnuxbill.sql');
2022-09-19 10:31:35 +08:00
$qr = $dbh->exec($sql);
2023-10-27 11:36:10 +08:00
if (isset($_POST['radius']) && $_POST['radius'] == 'yes') {
2023-09-29 15:11:44 +08:00
$sql = file_get_contents('radius.sql');
$qrs = $dbh->exec($sql);
}
2022-09-19 10:31:35 +08:00
} else {
header("location: step3.php?_error=1");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
2023-09-29 15:11:44 +08:00
2022-09-19 10:31:35 +08:00
<head>
2023-09-29 15:11:44 +08:00
<title>PHPNuxBill Installer</title>
2022-09-19 10:31:35 +08:00
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
2023-09-29 15:11:44 +08:00
<link type='text/css' href='css/style.css' rel='stylesheet' />
2022-09-19 10:31:35 +08:00
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body style='background-color: #FBFBFB;'>
2023-09-29 15:11:44 +08:00
<div id='main-container'>
2023-08-28 16:21:57 +08:00
<img src="img/logo.png" class="img-responsive" alt="Logo" />
<hr>
2022-09-19 10:31:35 +08:00
2023-09-29 15:11:44 +08:00
<div class="span12">
<h4> PHPNuxBill Installer </h4>
<?php
if ($cn == '1') {
?>
<p><strong>Config File Created and Database Imported.</strong><br></p>
<form action="step5.php" method="post">
<fieldset>
<legend>Click Continue</legend>
<button type='submit' class='btn btn-primary'>Continue</button>
</fieldset>
</form>
<?php
} elseif ($cn == '2') {
?>
<p> MySQL Connection was successfull. An error occured while adding data on MySQL. Unsuccessfull
Installation. Please refer manual installation in the website github.com/ibnux/phpnuxbill/wiki or Contact Telegram @ibnux for
helping on installation</p>
<?php
} else {
?>
<p> MySQL Connection Failed.</p>
<?php
}
?>
</div>
</div>
<div class="footer">Copyright &copy; 2021 PHPNuxBill. All Rights Reserved<br /><br /></div>
2022-09-19 10:31:35 +08:00
</body>
2023-09-29 15:11:44 +08:00
</html>