Merge pull request #19 from boxbilling/master

Merge boxbilling/master into timothygwebb/master
This commit is contained in:
Mr. Timothy G Webb Sr authored and GitHub committed 2020-11-21 13:56:51 -05:00
commit 788e87f2b4
12 files changed
+216 -59

No files matched your search

+2 -1
View File
@@ -43,6 +43,7 @@ jobs:
echo > ./src/bb-data/log/license.log
echo > ./src/bb-data/log/application.log
echo > ./src/bb-data/log/php_error.log
rm -rf ./src/install
- name: Run test suite for bb-modules
run: |
@@ -50,4 +51,4 @@ jobs:
- name: Run test suite for bb-library
run: |
php ./src/bb-vendor/bin/phpunit ./tests/bb-library/
php ./src/bb-vendor/bin/phpunit ./tests/bb-library/
+4
View File
@@ -32,6 +32,9 @@ logs: ## Show app logs
exec-php: ## Enter PHP container shell
$(DOCKER_PHP_CONTAINER_EXEC) bash
cache-flush: ## Flush Twig cache
$(DOCKER_PHP_CONTAINER_EXEC) rm -fr src/bb-data/cache/*
exec-db: ## Enter DB container shell
$(DOCKER_DB_CONTAINER_EXEC) bash
@@ -46,6 +49,7 @@ test: start ## Run app tests
echo "Running unit tests"
echo > ./src/bb-data/log/application.log
echo > ./src/bb-data/log/php_error.log
rm -rf src/install
$(DOCKER_PHP_CONTAINER_EXEC) composer install --working-dir=src --no-progress --no-suggest --prefer-dist
$(DOCKER_PHP_CONTAINER_EXEC) ./src/bb-vendor/bin/phpunit --dont-report-useless-tests ./tests/bb-modules/
+3 -4
View File
@@ -1,6 +1,5 @@
# Read documentation http://docs.boxbilling.com/ for more information
# Rename this file to .htaccess in order to work
# If you are receiving "Internal Server Error" message - make sure mod_rewrite is enabled in apache
# If you are receiving "Internal Server Error" message, make sure mod_rewrite is enabled in apache
Options -Indexes
Options +FollowSymLinks
@@ -24,7 +23,7 @@ RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
### re-direct to www
### Redirect to www
#RewriteCond %{HTTP_HOST} ^yourdomain.com
#RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
@@ -61,4 +60,4 @@ RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
</IfModule>
</IfModule>
+1 -1
View File
@@ -31,7 +31,7 @@ return array(
* Configure .htaccess file before enabling this feature
* Set to TRUE if using nginx
*/
'sef_urls' => false,
'sef_urls' => true,
/**
* Application timezone
+10 -1
View File
@@ -110,6 +110,15 @@ class Box_Requirements implements \Box\InjectionAwareInterface
return version_compare($current, $required, '>=');
}
public function isBoxVersionOk()
{
$current = Box_Version::VERSION;
if ($current == "0.0.1") {
return false;
}
return true;
}
/**
* What extensions must be loaded for BoxBilling o function correctly
*/
@@ -199,4 +208,4 @@ class Box_Requirements implements \Box\InjectionAwareInterface
return ($configmod == $perm);
}
}
}
+2 -1
View File
@@ -1,3 +1,4 @@
<?php
/** no direct access **/
defined('MECEXEC') or die();
@@ -2295,4 +2296,4 @@ if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'contype
{
header('Content-Type: application/pdf');
exit;
}
}
+157 -20
View File
@@ -47,21 +47,143 @@ function handler_exception($e)
}
$page = "<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<title>Error</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;min-height:180px;padding:30px 0 15px}* > body{padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0} em{font-weight:bold}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}pre{ width: 100%; overflow:auto; }
</style>
<a href=//www.boxbilling.com/ target='_blank'><img src='/bb-themes/boxbilling/assets/images/logo.png' alt='BoxBilling' style='height:60px'></a>
";
<html lang=\"en\">
<head>
<meta charset=\"utf-8\">
<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>An error ocurred</title>
<!-- Google font -->
<link href=\"https://fonts.googleapis.com/css?family=Nunito:400,700\" rel=\"stylesheet\">
<!-- Custom stlylesheet -->
<link type=\"text/css\" rel=\"stylesheet\" href=\"css/style.css\" />
<!--[if lt IE 9]>
<script src=\"https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js\"></script>
<script src=\"https://oss.maxcdn.com/respond/1.4.2/respond.min.js\"></script>
<![endif]-->
<style>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
padding: 0;
margin: 0;
}
#error {
position: relative;
height: 100vh;
}
#error .error {
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.error {
max-width: 560px;
width: 100%;
padding-left: 160px;
line-height: 1.1;
}
.error .error-container {
position: absolute;
left: 0;
top: 0;
display: inline-block;
width: 140px;
height: 140px;
background-image: url('/bb-themes/boxbilling/assets/images/box.png');
background-size: cover;
}
.error .error-container:before {
content: '';
position: absolute;
width: 100%;
height: 100%;
-webkit-transform: scale(2.4);
-ms-transform: scale(2.4);
transform: scale(2.4);
border-radius: 50%;
background-color: #f2f5f8;
z-index: -1;
}
.error h1 {
font-family: 'Nunito', sans-serif;
font-size: 65px;
font-weight: 700;
margin-top: 0px;
margin-bottom: 10px;
color: #151723;
text-transform: uppercase;
}
.error h2 {
font-family: 'Nunito', sans-serif;
font-size: 21px;
font-weight: 400;
margin: 0;
text-transform: uppercase;
color: #151723;
}
.error p {
font-family: 'Nunito', sans-serif;
color: #999fa5;
font-weight: 400;
}
.error a {
font-family: 'Nunito', sans-serif;
display: inline-block;
font-weight: 700;
border-radius: 40px;
text-decoration: none;
color: #388dbc;
}
@media only screen and (max-width: 767px) {
.error .error-container {
width: 110px;
height: 110px;
}
.error {
padding-left: 15px;
padding-right: 15px;
padding-top: 110px;
}
}
</style>
</head>
<body>
<div id=\"error\">
<div class=\"error\">
<div class=\"error-container\"></div>
<h1>Error</h1>";
$page = str_replace(PHP_EOL, "", $page);
print $page;
if($e->getCode()) {
print sprintf('<p>Code: <em>%s</em></p>', $e->getCode());
print sprintf('<h2>Error code: <em>%s</em></h1>', $e->getCode());
}
print sprintf('<p>%s</p>', $e->getMessage());
print sprintf('<p><a href="http://docs.boxbilling.com/en/latest/search.html?q=%s&check_keywords=yes&area=default" target="_blank">Look for detailed error explanation</a></p>', urlencode($e->getMessage()));
print sprintf('<center><p><a href="http://docs.boxbilling.com/en/latest/search.html?q=%s&check_keywords=yes&area=default" target="_blank">Look for detailed error explanation</a></p></center>', urlencode($e->getMessage()));
if(defined('BB_DEBUG') && BB_DEBUG) {
print sprintf('<em>%s</em>', 'Set BB_DEBUG to FALSE, to hide the message below');
@@ -70,13 +192,23 @@ function handler_exception($e)
print sprintf('<p>Line: "%s"</p>', $e->getLine());
print sprintf('Trace: <pre>%s</pre>', $e->getTraceAsString());
}
print("<center><hr><p>Powered by <a href=//www.boxbilling.com/>BoxBilling</a></p></center>
</body>
</html>");
}
set_exception_handler("handler_exception");
set_error_handler('handler_error');
// multisite support. Load new config depending on current host
// if run from cli first param must be hostname
// Check for Composer packages
$vendorPath = BB_PATH_ROOT.'/bb-vendor';
if(!file_exists($vendorPath)) {
throw new Exception("It seems like Composer packages are missing. You have to run \"<code>composer install</code>\" in order to install them. For detailed instruction, you can see <a href=\"https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies\">Composer's getting started guide</a>.<br /><br />If you have downloaded BoxBilling from <a href=\"https://github.com/boxbilling/boxbilling/releases\">GitHub releases</a>, this shouldn't happen.", 103);
}
// Multisite support. Load new configuration depending on the current hostname
// If being run from CLI, first parameter must be the hostname
$configPath = BB_PATH_ROOT.'/bb-config.php';
if((isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) || (php_sapi_name() == 'cli' && isset($argv[1]) ) ) {
if(php_sapi_name() == 'cli') {
@@ -91,20 +223,25 @@ if((isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) || (php_sapi_name() =
}
}
// check if config is available
if(!file_exists($configPath) || 0 == filesize( $configPath )) {
// Try to check if configuration is available
if(!file_exists($configPath) || 0 == filesize($configPath)) {
//try create empty config file
// Try to create an empty configuration file
@file_put_contents($configPath, '');
$base_url = "http://".$_SERVER['HTTP_HOST'];
$base_url .= preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])).'/';
$base_url .= preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME']));
$url = $base_url . 'install/index.php';
$configFile = pathinfo($configPath, PATHINFO_BASENAME);
$msg = sprintf("There doesn't seem to be a <em>$configFile</em> file or bb-config.php file does not contain required configuration parameters. I need this before we can get started. Need more help? <a target='_blank' href='http://docs.boxbilling.com/en/latest/reference/installation.html'>We got it</a>. You can create a <em>$configFile</em> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='%s' class='button'>Continue with BoxBilling installation</a>", $url);
$msg = sprintf("The <em>$configFile</em> path seems to be invalid. You may have not generated the configuration file yet, or the configuration file may not contain the required configuration parameters. BoxBilling needs to have a valid configuration file present in order to function properly.</p><p>Need some help with the installation? <a target='_blank' href='http://docs.boxbilling.com/en/latest/reference/installation.html'>We got it</a>. You can create the configuration file using the interactive installer, or manually create the configuration file.</p><p>If it's your first time setting up BoxBilling, you can <a href='%s' class='button'>continue with the web-based interactive BoxBilling installation</a>.", $url);
throw new Exception($msg, 101);
}
// Try to check if /install directory still exists, even after the installation was completed
if(file_exists($configPath) && 0 !== filesize($configPath) && file_exists(BB_PATH_ROOT.'/install/index.php')) {
throw new Exception("For safety reasons, you have to delete the <b><em>/install</em></b> directory to start using BoxBilling.</p><p>Please delete the <b><em>/install</em></b> directory from your web server.", 102);
}
$config = require_once $configPath;
require BB_PATH_VENDOR . '/autoload.php';
@@ -124,15 +261,15 @@ if($config['sef_urls']) {
}
if($config['debug']) {
error_reporting( E_ALL );
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
} else {
error_reporting( E_RECOVERABLE_ERROR );
error_reporting(E_RECOVERABLE_ERROR);
ini_set('display_errors', '0');
ini_set('display_startup_errors', '0');
}
ini_set('log_errors', '1');
ini_set('html_errors', FALSE);
ini_set('error_log', BB_PATH_LOG . '/php_error.log');
ini_set('error_log', BB_PATH_LOG . '/php_error.log');
@@ -1,3 +1,4 @@
{% import "macro_functions.phtml" as mf %}
<div class="rowElem">
<label>{% trans 'Domain action' %}:</label>
<div class="formRight domain-action-select">
@@ -44,4 +45,4 @@ $(function() {
});
});
</script>
</script>
+5 -1
View File
@@ -241,6 +241,10 @@ class Service
$msgs['info'][] = sprintf('Install module "%s" still exists. Please remove it for security reasons.', $install);
}
if($this->getVersion() == "0.0.1") {
$msgs['info'][] = 'BoxBilling couldn\'t find valid version information. This is okay if you\'ve brought a copy of BoxBilling directly from the master branch, and not from releases. But beware, master branch may not be stable enough to be used for production use.';
}
if(!extension_loaded('openssl')) {
$msgs['info'][] = sprintf('BoxBilling requires %s extension to be enabled on this server for security reasons.', 'php openssl');
}
@@ -1562,4 +1566,4 @@ class Service
$this->di['session']->delete('pending_messages');
return true;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

+12 -13
View File
@@ -78,13 +78,13 @@ final class Box_Installer
case 'install':
try {
//db
// Initializing database connection
$user = $_POST['db_user'];
$host = $_POST['db_host'];
$pass = $_POST['db_pass'];
$name = $_POST['db_name'];
if (!$this->canConnectToDatabase($host, $name, $user, $pass)) {
throw new Exception('Could not connect to database or database does not exist');
throw new Exception('Could not connect to the database, or the database does not exist');
} else {
$this->session->set('db_host', $host);
$this->session->set('db_name', $name);
@@ -92,12 +92,12 @@ final class Box_Installer
$this->session->set('db_pass', $pass);
}
// admin config
// Configuring administrator's account
$admin_email = $_POST['admin_email'];
$admin_pass = $_POST['admin_pass'];
$admin_name = $_POST['admin_name'];
if (!$this->isValidAdmin($admin_email, $admin_pass, $admin_name)) {
throw new Exception('Administrators account is not valid');
throw new Exception('Administrator\'s account is not valid');
} else {
$this->session->set('admin_email', $admin_email);
$this->session->set('admin_pass', $admin_pass);
@@ -128,6 +128,8 @@ final class Box_Installer
'files' => $se->files(),
'os' => PHP_OS,
'os_ok' => true,
'box_ver' => Box_Version::VERSION,
'box_ver_ok' => $se->isBoxVersionOk(),
'php_ver' => $options['php']['version'],
'php_ver_req' => $options['php']['min_version'],
'php_safe_mode' => $options['php']['safe_mode'],
@@ -263,12 +265,9 @@ final class Box_Installer
$pdo = $this->getPdo($ns->get('db_host'), $ns->get('db_name'), $ns->get('db_user'), $ns->get('db_pass'));
$sql = file_get_contents(BB_PATH_SQL);
if (!$sql) {
throw new Exception('Could not read structure.sql file');
}
$sql_content = file_get_contents(BB_PATH_SQL_DATA);
if (!$sql_content) {
if (!$sql || !$sql_content) {
throw new Exception('Could not read structure.sql file');
}
@@ -296,7 +295,7 @@ final class Box_Installer
try {
$this->_sendMail($ns);
} catch (Exception $e) {
// email was not sent but that is not a problem
// E-mail was not sent, but that is not a problem
error_log($e->getMessage());
}
@@ -313,7 +312,7 @@ final class Box_Installer
$content .= "You have successfully setup BoxBilling at " . BB_URL . PHP_EOL;
$content .= "Access client area at: " . BB_URL . PHP_EOL;
$content .= "Access admin area at: " . BB_URL_ADMIN . " with login details:" . PHP_EOL;
$content .= "Email: " . $admin_email . PHP_EOL;
$content .= "E-mail: " . $admin_email . PHP_EOL;
$content .= "Password: " . $admin_pass . PHP_EOL . PHP_EOL;
$content .= "Read BoxBilling documentation to get started https://docs.boxbilling.com/" . PHP_EOL;
@@ -328,7 +327,7 @@ final class Box_Installer
{
$output = $this->_getConfigOutput($data);
if (!@file_put_contents(BB_PATH_CONFIG, $output)) {
throw new Exception('Configuration file is not writable or does not exists. Please create file ' . BB_PATH_CONFIG . ' and make it writable', 101);
throw new Exception('Configuration file is not writable or does not exist. Please create the file at ' . BB_PATH_CONFIG . ' and make it writable', 101);
}
}
@@ -339,7 +338,7 @@ final class Box_Installer
'salt' => md5(uniqid()),
'url' => BB_URL,
'admin_area_prefix' => '/bb-admin',
'sef_urls' => false,
'sef_urls' => true,
'timezone' => 'UTC',
'locale' => 'en_US',
'locale_date_format' => '%A, %d %B %G',
+18 -16
View File
@@ -5,16 +5,16 @@
<div class="head"><h5 class="iAlert">BoxBilling installation</h5></div>
<div class="body">
<p>This setup will guide you through installation process of BoxBilling.</p>
<p>Check if your system meets minimum requirements to install and run billing software.</p>
<p>Check if your system meets minimum requirements to install and run BoxBilling.</p>
</div>
</div>
<div class="widget nomargin step step-2">
<div class="head"><h5 class="iAlert">Database configuration</h5></div>
<div class="body">
<p>BoxBilling stores data in SQL database. You should already have an existing database before this step. If you do not have database prepared, you should do that now.</p>
<p>BoxBilling stores data in a SQL database. You should already have an existing database before this step. If you do not have database prepared, you should do that now.</p>
<p>Installer will create all required tables in your database after correct connection details are provided.</p>
<h4 class="pt10">How to create database?</h4>
<h4 class="pt10">How to create a database?</h4>
<p>Depending on your hosting provider database can be created in different ways.</p>
<p>Best way is to check the documentation available with your webhosting account. You can contact their support if you really get stuck.</p>
</div>
@@ -85,6 +85,12 @@
<td>{% if not os_ok %}BoxBilling might not work properly on your operating system{% endif %}</td>
</tr>
<tr>
<td>BoxBilling version</td>
<td><strong class="{{ box_ver_ok ? 'green' : 'red'}}">{{ box_ver }}</strong></td>
<td>{% if not box_ver_ok %}BoxBilling couldn't find valid version information. This is okay if you've brought a copy of BoxBilling directly from the master branch, and not from releases. But beware, master branch may not be stable enough to be used for production use.{% endif %}</td>
</tr>
<tr>
<td>PHP version</td>
<td><strong class="{{ php_ver_ok ? 'green' : 'red'}}">{{ php_ver }}</strong></td>
@@ -97,15 +103,15 @@
<td>{% if php_safe_mode %}PHP safe mode should be OFF{% endif %}</td>
</tr>
{% for ext,loaded in extensions %}
{% for ext, loaded in extensions %}
<tr>
<td>PHP Extension: <strong>{{ ext }}</strong></td>
<td>PHP extension: <strong>{{ ext }}</strong></td>
<td><strong class="{{ loaded ? 'green' : 'red'}}">{{ loaded ? 'Ok' : 'Fail'}}</strong></td>
<td>{% if not loaded %}Contact your server administrator to enable <strong>PHP {{ ext }} extension</strong>{% endif %}</td>
</tr>
{% endfor %}
{% for file,writable in files %}
{% for file, writable in files %}
<tr>
<td>{{ file }}</td>
<td><strong class="{{ writable ? 'green' : 'red'}}">{{ writable ? 'Yes' : 'No'}}</strong></td>
@@ -113,7 +119,7 @@
</tr>
{% endfor %}
{% for folder,writable in folders %}
{% for folder, writable in folders %}
<tr>
<td>{{ folder }}</td>
<td><strong class="{{ writable ? 'green' : 'red'}}">{{ writable ? 'Yes' : 'No'}}</strong></td>
@@ -182,7 +188,7 @@
</div>
<div class="rowElem">
<label>Email:</label>
<label>E-mail:</label>
<div class="formRight">
<input type="text" name="admin_email" id="admin_email" value="{{ request.admin_email|default(admin_email) }}" autocomplete="off" required="required" placeholder="admin@yourdomain.com"/>
</div>
@@ -203,10 +209,10 @@
<div class="body">
<h1 class="pt10">Congratulations! BoxBilling was successfully installed.</h1>
<p>Even though BoxBilling was installed successfully you must take a few more actions.</p>
<p>Even though BoxBilling was installed successfully, you must take a few more actions.</p>
<h2 class="pt20">Remove installation module</h2>
<p>Remove installation module for security reasons.</p>
<p>For security reasons, you <b>have to</b> delete the installer from your web server before getting started.</p>
<pre>{{ install_module_path }}</pre>
<h2 class="pt20">Change configuration file permissions</h2>
@@ -216,10 +222,6 @@
<h2 class="pt20">Setup cron job</h2>
<p>Setup this cron job to run every five minutes</p>
<pre>*/5 * * * * php {{ cron_path }}</pre>
<h2 class="pt20">Disable directory listing with .htaccess</h2>
<p>Disable directory listing with .htaccess</p>
<pre>Rename file htaccess.txt to .htaccess</pre>
</div>
</div>
</div>
@@ -237,7 +239,7 @@
$(function() {
$('.wizard').smartWizard({
selected: 0, // Selected Step, 0 = first step
keyNavigation: true, // Enable/Disable key navigation(left and right keys are used if enabled)
keyNavigation: true, // Enable/Disable key navigation (left and right keys are used if enabled)
enableAllSteps: false, // Enable/Disable all steps on first load
transitionEffect: 'fade', // Effect on navigation, none/fade/slide/slideleft
contentURL:null, // specifying content url enables ajax content loading
@@ -347,4 +349,4 @@ $(function() {
}
</script>
{% endblock %}
{% endblock %}