Upload files to "install"

Signed-off-by: kevinowino869 <kevinowino869@www.codelab.nestict.africa>
This commit is contained in:
kevinowino869 2025-04-13 12:40:18 +02:00
parent c2688b32e2
commit 1ae90f4338
3 changed files with 373 additions and 0 deletions

155
install/step4.php Normal file
View File

@ -0,0 +1,155 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
**/
//error_reporting (0);
$appurl = $_POST['appurl'];
$db_host = $_POST['dbhost'];
$db_user = $_POST['dbuser'];
$db_pass = $_POST['dbpass'];
$db_name = $_POST['dbname'];
$cn = '0';
try {
$dbh = new pdo(
"mysql:host=$db_host;dbname=$db_name",
"$db_user",
"$db_pass",
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
);
$cn = '1';
} catch (PDOException $ex) {
$cn = '0';
}
if ($cn == '1') {
if (isset($_POST['radius']) && $_POST['radius'] == 'yes') {
$input = '<?php
$protocol = (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off" || $_SERVER["SERVER_PORT"] == 443) ? "https://" : "http://";
$host = $_SERVER["HTTP_HOST"];
$baseDir = rtrim(dirname($_SERVER["SCRIPT_NAME"]), "/\\\\");
define("APP_URL", $protocol . $host . $baseDir);
// Live, Dev, Demo
$_app_stage = "Live";
// Database PHPNuxBill
$db_host = "' . $db_host . '";
$db_user = "' . $db_user . '";
$db_pass = "' . $db_pass . '";
$db_name = "' . $db_name . '";
// Database Radius
$radius_host = "' . $db_host . '";
$radius_user = "' . $db_user . '";
$radius_pass = "' . $db_pass . '";
$radius_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);
}';
} else {
$input = '<?php
$protocol = (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off" || $_SERVER["SERVER_PORT"] == 443) ? "https://" : "http://";
$host = $_SERVER["HTTP_HOST"];
$baseDir = rtrim(dirname($_SERVER["SCRIPT_NAME"]), "/\\\\");
define("APP_URL", $protocol . $host . $baseDir);
// Live, Dev, Demo
$_app_stage = "Live";
// Database PHPNuxBill
$db_host = "' . $db_host . '";
$db_user = "' . $db_user . '";
$db_pass = "' . $db_pass . '";
$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";
$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);
$sql = file_get_contents('phpnuxbill.sql');
$qr = $dbh->exec($sql);
if (isset($_POST['radius']) && $_POST['radius'] == 'yes') {
$sql = file_get_contents('radius.sql');
$qrs = $dbh->exec($sql);
}
} else {
header("location: step3.php?_error=1");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>PHPNuxBill Installer</title>
<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]-->
<link type='text/css' href='css/style.css' rel='stylesheet' />
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body style='background-color: #FBFBFB;'>
<div id='main-container'>
<img src="img/logo.png" class="img-responsive" alt="Logo" />
<hr>
<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>
</body>
</html>

112
install/step5.php Normal file
View File

@ -0,0 +1,112 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>PHPNuxBill Installer</title>
<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]-->
<link type='text/css' href='css/style.css' rel='stylesheet' />
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
</head>
<?php
$sourceDir = $_SERVER['DOCUMENT_ROOT'].'/pages_template';
$targetDir = $_SERVER['DOCUMENT_ROOT'].'/pages';
function copyDir($src, $dst) {
$dir = opendir($src);
if (!$dir) {
throw new Exception("Cannot open directory: $src");
}
if (!file_exists($dst)) {
if (!mkdir($dst, 0777, true)) {
throw new Exception("Failed to create directory: $dst");
}
}
while (false !== ($file = readdir($dir))) {
if (($file != '.') && ($file != '..')) {
if (is_dir($src . '/' . $file)) {
copyDir($src . '/' . $file, $dst . '/' . $file);
} else {
if (!copy($src . '/' . $file, $dst . '/' . $file)) {
throw new Exception("Failed to copy $src/$file to $dst/$file");
}
}
}
}
closedir($dir);
}
function removeDir($dir) {
if (!is_dir($dir)) return;
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object == '.' || $object == '..') continue;
if (is_dir($dir . '/' . $object))
removeDir($dir . '/' . $object);
else
if (!unlink($dir . '/' . $object)) {
throw new Exception("Failed to delete file: $dir/$object");
}
}
if (!rmdir($dir)) {
throw new Exception("Failed to remove directory: $dir");
}
}
try {
if (!file_exists($sourceDir)) {
throw new Exception("Source directory does not exist.");
}
copyDir($sourceDir, $targetDir);
removeDir($sourceDir);
} catch (Exception $e) {
echo 'Error: ', $e->getMessage(), "\n";
}
?>
<body style='background-color: #FBFBFB;'>
<div id='main-container'>
<img src="img/logo.png" class="img-responsive" alt="Logo" />
<hr>
<div class="span12">
<h4> PHPNuxBill Installer </h4>
<p>
<strong>Congratulations!</strong><br>
You have just install PHPNuxBill !<br><br>
<span class="text-danger">But wait!!<br>
<ol>
<li>Don't forget to rename folder <b>pages_example</b> to <b>pages</b>.<br>
if it not yet renamed</li>
<li>Activate <a href="https://github.com/hotspotbilling/phpnuxbill/wiki/Cron-Jobs" target="_blank">Cronjob</a> for Expired and Reminder.</li>
<li>Check <a href="https://github.com/hotspotbilling/phpnuxbill/wiki/How-It-Works---Cara-kerja" target="_blank">how PHPNuxbill Works</a></li>
<li><a href="https://github.com/hotspotbilling/phpnuxbill/wiki#login-page-mikrotik" target="_blank">how to link Mikrotik Login to PHPNuxBill</a></li>
<li>or use <a href="https://github.com/hotspotbilling/phpnuxbill-mikrotik-login-template" target="_blank">Mikrotik Login Template for PHPNuxBill</a></li>
</ol>
</span><br><br>
To Login Admin Portal:<br>
Use this link -
<?php
$cururl = (((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$appurl = str_replace('/install/step5.php', '', $cururl);
$appurl = str_replace('/system', '', $appurl);
echo '<a href="' . $appurl . '/admin">' . $appurl . '/admin</a>';
?>
<br>
Username: admin<br>
Password: admin<br>
For security, Delete the <b>install</b> directory inside system folder.
</p>
</div>
</div>
<div class="footer">Copyright &copy; 2021 PHPNuxBill. All Rights Reserved<br /><br /></div>
</body>
</html>

106
install/update.php Normal file
View File

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>PHPNuxBill Updaters</title>
<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]-->
<link type='text/css' href='css/style.css' rel='stylesheet' />
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body style='background-color: #FBFBFB;'>
<div id='main-container'>
<img src="img/logo.png" class="img-responsive" alt="Logo" />
<hr>
<div class="span12">
<h4> PHPNuxBill Updater </h4>
<pre><?php
include '../config.php';
try{
$dbh = new pdo( "mysql:host=$db_host;dbname=$db_name",
"$db_user",
"$db_pass",
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
echo "CREATE TABLE `tbl_payment_gateway` (
`id` int(11) NOT NULL,
`username` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
`gateway` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'xendit | midtrans',
`gateway_trx_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`plan_id` int(11) NOT NULL,
`plan_name` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
`routers_id` int(11) NOT NULL,
`routers` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
`price` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
`pg_url_payment` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`payment_method` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`payment_channel` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`pg_request` text COLLATE utf8mb4_general_ci,
`pg_paid_response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`expired_date` datetime DEFAULT NULL,
`created_date` datetime NOT NULL,
`paid_date` datetime DEFAULT NULL,
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1 unpaid 2 paid 3 failed 4 canceled'
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;\n\n";
$dbh->exec("CREATE TABLE
`tbl_payment_gateway` (
`id` int(11) NOT NULL,
`username` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
`gateway` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'xendit | midtrans',
`gateway_trx_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`plan_id` int(11) NOT NULL,
`plan_name` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
`routers_id` int(11) NOT NULL,
`routers` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
`price` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
`pg_url_payment` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`payment_method` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`payment_channel` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`pg_request` text COLLATE utf8mb4_general_ci,
`pg_paid_response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`expired_date` datetime DEFAULT NULL,
`created_date` datetime NOT NULL,
`paid_date` datetime DEFAULT NULL,
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1 unpaid 2 paid 3 failed 4 canceled'
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;");
echo "ALTER TABLE `tbl_payment_gateway` ADD PRIMARY KEY (`id`);\n\n";
$dbh->exec("ALTER TABLE `tbl_payment_gateway` ADD PRIMARY KEY (`id`);");
echo "ALTER TABLE `tbl_payment_gateway` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;\n\n";
$dbh->exec("ALTER TABLE `tbl_payment_gateway` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;");
echo "ALTER TABLE `tbl_customers` ADD `email` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' AFTER `phonenumber`;\n\n";
$dbh->exec("ALTER TABLE `tbl_customers` ADD `email` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' AFTER `phonenumber`;");
echo "ALTER TABLE `tbl_plans` CHANGE `validity_unit` `validity_unit` ENUM('Mins','Hrs','Days','Months') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;\n\n";
$dbh->exec("ALTER TABLE `tbl_plans` CHANGE `validity_unit` `validity_unit` ENUM('Mins','Hrs','Days','Months') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL");
echo "ALTER TABLE `tbl_plans` ADD `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' AFTER `pool`;\n\n";
$dbh->exec("ALTER TABLE `tbl_plans` ADD `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' AFTER `pool`;");
echo "ALTER TABLE `tbl_routers` ADD `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' AFTER `description`;\n\n";
$dbh->exec("ALTER TABLE `tbl_routers` ADD `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' AFTER `description`;");
echo "ALTER TABLE `tbl_routers` CHANGE `description` `description` VARCHAR(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;";
$dbh->exec("ALTER TABLE `tbl_routers` CHANGE `description` `description` VARCHAR(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;");
echo "ALTER TABLE `tbl_user_recharges` CHANGE `method` `method` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';\n\n";
$dbh->exec("ALTER TABLE `tbl_user_recharges` CHANGE `method` `method` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';");
echo "ALTER TABLE `tbl_transactions` CHANGE `method` `method` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;\n\n";
$dbh->exec("ALTER TABLE `tbl_transactions` CHANGE `method` `method` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;");
echo "Success update database for new system <a href='/admin/'>Back To Home</a>";
}catch(PDOException $ex){
echo "Error Failed to connect to database: ".$ex->getMessage()."\n";
}
?></pre>
</div>
</div>
<div class="footer">Copyright &copy; 2021 PHPNuxBill. All Rights Reserved<br /><br /></div>
</body>
</html>