diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 027cc62ed..a9d1746a2 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -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/ \ No newline at end of file + php ./src/bb-vendor/bin/phpunit ./tests/bb-library/ diff --git a/Makefile b/Makefile index 994ff3543..6dc14c171 100644 --- a/Makefile +++ b/Makefile @@ -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/ diff --git a/src/htaccess.txt b/src/.htaccess similarity index 92% rename from src/htaccess.txt rename to src/.htaccess index 4ea01a860..fcd5b8b82 100644 --- a/src/htaccess.txt +++ b/src/.htaccess @@ -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] Header set Cache-Control "max-age=43200" - \ No newline at end of file + diff --git a/src/bb-config-sample.php b/src/bb-config-sample.php index fd2fda56c..8b14beedc 100755 --- a/src/bb-config-sample.php +++ b/src/bb-config-sample.php @@ -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 diff --git a/src/bb-library/Box/Requirements.php b/src/bb-library/Box/Requirements.php index e8c31c49a..3263f7a83 100644 --- a/src/bb-library/Box/Requirements.php +++ b/src/bb-library/Box/Requirements.php @@ -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); } -} \ No newline at end of file +} diff --git a/src/bb-library/tfpdf.php b/src/bb-library/tfpdf.php index c99daeb8f..3460a9a2f 100644 --- a/src/bb-library/tfpdf.php +++ b/src/bb-library/tfpdf.php @@ -1,3 +1,4 @@ + - - - Error - - BoxBilling - "; + + + + + + + + + An error ocurred + + + + + + + + + + + + +
+
+
+

Error

"; $page = str_replace(PHP_EOL, "", $page); print $page; if($e->getCode()) { - print sprintf('

Code: %s

', $e->getCode()); + print sprintf('

Error code: %s

', $e->getCode()); } print sprintf('

%s

', $e->getMessage()); - print sprintf('

Look for detailed error explanation

', urlencode($e->getMessage())); + print sprintf('

Look for detailed error explanation

', urlencode($e->getMessage())); if(defined('BB_DEBUG') && BB_DEBUG) { print sprintf('%s', 'Set BB_DEBUG to FALSE, to hide the message below'); @@ -70,13 +192,23 @@ function handler_exception($e) print sprintf('

Line: "%s"

', $e->getLine()); print sprintf('Trace:
%s
', $e->getTraceAsString()); } + print("

Powered by BoxBilling

+ + + "); } 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 \"composer install\" in order to install them. For detailed instruction, you can see Composer's getting started guide.

If you have downloaded BoxBilling from GitHub releases, 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 $configFile file or bb-config.php file does not contain required configuration parameters. I need this before we can get started. Need more help? We got it. You can create a $configFile file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.

Continue with BoxBilling installation", $url); + $msg = sprintf("The $configFile 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.

Need some help with the installation? We got it. You can create the configuration file using the interactive installer, or manually create the configuration file.

If it's your first time setting up BoxBilling, you can continue with the web-based interactive BoxBilling installation.", $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 /install directory to start using BoxBilling.

Please delete the /install 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'); \ No newline at end of file +ini_set('error_log', BB_PATH_LOG . '/php_error.log'); diff --git a/src/bb-modules/Servicedomain/html_admin/mod_servicedomain_order.phtml b/src/bb-modules/Servicedomain/html_admin/mod_servicedomain_order.phtml index 459fb5dc5..3933b0f87 100644 --- a/src/bb-modules/Servicedomain/html_admin/mod_servicedomain_order.phtml +++ b/src/bb-modules/Servicedomain/html_admin/mod_servicedomain_order.phtml @@ -1,3 +1,4 @@ +{% import "macro_functions.phtml" as mf %}

@@ -44,4 +45,4 @@ $(function() { }); }); - \ No newline at end of file + diff --git a/src/bb-modules/System/Service.php b/src/bb-modules/System/Service.php index c0f2833fc..63a62933c 100644 --- a/src/bb-modules/System/Service.php +++ b/src/bb-modules/System/Service.php @@ -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; } -} \ No newline at end of file +} diff --git a/src/bb-themes/boxbilling/assets/images/box.png b/src/bb-themes/boxbilling/assets/images/box.png new file mode 100644 index 000000000..1582275d3 Binary files /dev/null and b/src/bb-themes/boxbilling/assets/images/box.png differ diff --git a/src/install/index.php b/src/install/index.php index 28f1fff84..a6f7b46fe 100644 --- a/src/install/index.php +++ b/src/install/index.php @@ -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', diff --git a/src/install/install.phtml b/src/install/install.phtml index 355c93e41..0a63394a7 100644 --- a/src/install/install.phtml +++ b/src/install/install.phtml @@ -5,16 +5,16 @@
BoxBilling installation

This setup will guide you through installation process of BoxBilling.

-

Check if your system meets minimum requirements to install and run billing software.

+

Check if your system meets minimum requirements to install and run BoxBilling.

Database configuration
-

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.

+

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.

Installer will create all required tables in your database after correct connection details are provided.

-

How to create database?

+

How to create a database?

Depending on your hosting provider database can be created in different ways.

Best way is to check the documentation available with your webhosting account. You can contact their support if you really get stuck.

@@ -85,6 +85,12 @@ {% if not os_ok %}BoxBilling might not work properly on your operating system{% endif %} + + BoxBilling version + {{ box_ver }} + {% 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 %} + + PHP version {{ php_ver }} @@ -97,15 +103,15 @@ {% if php_safe_mode %}PHP safe mode should be OFF{% endif %} - {% for ext,loaded in extensions %} + {% for ext, loaded in extensions %} - PHP Extension: {{ ext }} + PHP extension: {{ ext }} {{ loaded ? 'Ok' : 'Fail'}} {% if not loaded %}Contact your server administrator to enable PHP {{ ext }} extension{% endif %} {% endfor %} - {% for file,writable in files %} + {% for file, writable in files %} {{ file }} {{ writable ? 'Yes' : 'No'}} @@ -113,7 +119,7 @@ {% endfor %} - {% for folder,writable in folders %} + {% for folder, writable in folders %} {{ folder }} {{ writable ? 'Yes' : 'No'}} @@ -182,7 +188,7 @@
- +
@@ -203,10 +209,10 @@

Congratulations! BoxBilling was successfully installed.

-

Even though BoxBilling was installed successfully you must take a few more actions.

+

Even though BoxBilling was installed successfully, you must take a few more actions.

Remove installation module

-

Remove installation module for security reasons.

+

For security reasons, you have to delete the installer from your web server before getting started.

{{ install_module_path }}

Change configuration file permissions

@@ -216,10 +222,6 @@

Setup cron job

Setup this cron job to run every five minutes

*/5 * * * * php {{ cron_path }}
- -

Disable directory listing with .htaccess

-

Disable directory listing with .htaccess

-
Rename file htaccess.txt to .htaccess
@@ -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() { } -{% endblock %} \ No newline at end of file +{% endblock %}