mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 20:27:07 +09:00
Merge pull request #312 from Tautve/Improved_code_style
Improved code style by adding missing return types, replacing funcs w…
This commit is contained in:
8 files changed
+170
-175
No files matched your search
@@ -90,9 +90,9 @@ return [
|
||||
/**
|
||||
* Set location to store sensitive data.
|
||||
*/
|
||||
'path_data' => dirname(__FILE__).'/bb-data',
|
||||
'path_data' => __DIR__ .'/bb-data',
|
||||
|
||||
'path_logs' => dirname(__FILE__).'/bb-data/log/application.log',
|
||||
'path_logs' => __DIR__ .'/bb-data/log/application.log',
|
||||
|
||||
'log_to_db' => true,
|
||||
|
||||
@@ -131,7 +131,7 @@ return [
|
||||
'twig' => [
|
||||
'debug' => false,
|
||||
'auto_reload' => false,
|
||||
'cache' => dirname(__FILE__).'/bb-data/cache',
|
||||
'cache' => __DIR__ .'/bb-data/cache',
|
||||
],
|
||||
|
||||
'api' => [
|
||||
|
||||
+5
-5
@@ -12,25 +12,25 @@
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/bb-load.php';
|
||||
$di = include dirname(__FILE__).'/bb-di.php';
|
||||
require_once __DIR__ .'/bb-load.php';
|
||||
$di = include __DIR__ .'/bb-di.php';
|
||||
|
||||
$di['translate']();
|
||||
|
||||
try {
|
||||
if ('cli' == php_sapi_name()) {
|
||||
if ('cli' === PHP_SAPI) {
|
||||
echo "\e[33m- Welcome to FOSSBilling.\n";
|
||||
}
|
||||
$interval = $argv[1] ?? null;
|
||||
$service = $di['mod_service']('cron');
|
||||
if ('cli' == php_sapi_name()) {
|
||||
if ('cli' === PHP_SAPI) {
|
||||
echo "\e[34mLast executed: ".$service->getLastExecutionTime().".\e[0m";
|
||||
}
|
||||
$service->runCrons($interval);
|
||||
} catch (Exception $exception) {
|
||||
throw new Exception($exception);
|
||||
} finally {
|
||||
if ('cli' == php_sapi_name()) {
|
||||
if ('cli' === PHP_SAPI) {
|
||||
echo "\e[32mSuccessfully ran the cron jobs.\e[0m";
|
||||
} else {
|
||||
$login_url = $di['url']->link('bb-admin');
|
||||
|
||||
+8
-6
@@ -15,6 +15,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use RedBeanPHP\Facade;
|
||||
|
||||
$di = new Box_Di();
|
||||
|
||||
$di['config'] = function () {
|
||||
@@ -75,7 +77,7 @@ $di['pdo'] = function () use ($di) {
|
||||
$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['Box_DbLoggedPDOStatement']);
|
||||
}
|
||||
|
||||
if ('mysql' == $c['type']) {
|
||||
if ('mysql' === $c['type']) {
|
||||
$pdo->exec('SET NAMES "utf8"');
|
||||
$pdo->exec('SET CHARACTER SET utf8');
|
||||
$pdo->exec('SET CHARACTER_SET_CONNECTION = utf8');
|
||||
@@ -89,14 +91,14 @@ $di['pdo'] = function () use ($di) {
|
||||
};
|
||||
|
||||
$di['db'] = function () use ($di) {
|
||||
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'rb.php';
|
||||
require_once __DIR__ .DIRECTORY_SEPARATOR.'rb.php';
|
||||
R::setup($di['pdo']);
|
||||
\RedBeanPHP\Util\DispenseHelper::setEnforceNamingPolicy(false);
|
||||
|
||||
$helper = new Box_BeanHelper();
|
||||
$helper->setDi($di);
|
||||
|
||||
$mapper = new \RedBeanPHP\Facade();
|
||||
$mapper = new Facade();
|
||||
$mapper->getRedBean()->setBeanHelper($helper);
|
||||
$freeze = isset($di['config']['db']['freeze']) ? (bool) $di['config']['db']['freeze'] : true;
|
||||
$mapper->freeze($freeze);
|
||||
@@ -190,7 +192,7 @@ $di['twig'] = $di->factory(function () use ($di) {
|
||||
->setTimezone($config['timezone']);
|
||||
|
||||
// add globals
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH']) {
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['HTTP_X_REQUESTED_WITH']) {
|
||||
$_GET['ajax'] = true;
|
||||
}
|
||||
|
||||
@@ -243,7 +245,7 @@ $di['loggedin_client'] = function () use ($di) {
|
||||
};
|
||||
|
||||
$di['loggedin_admin'] = function () use ($di) {
|
||||
if ('cli' == php_sapi_name() || 'cgi' == substr(php_sapi_name(), 0, 3)) {
|
||||
if ('cli' === php_sapi_name() || 'cgi' === substr(php_sapi_name(), 0, 3)) {
|
||||
return $di['mod_service']('staff')->getCronAdmin();
|
||||
}
|
||||
|
||||
@@ -411,7 +413,7 @@ $di['password'] = function () { return new Box_Password(); };
|
||||
|
||||
$di['translate'] = $di->protect(function ($textDomain = '') use ($di) {
|
||||
$tr = new Box_Translate();
|
||||
|
||||
|
||||
if (!empty($textDomain)) {
|
||||
$tr->setDomain($textDomain);
|
||||
}
|
||||
|
||||
+11
-23
@@ -12,25 +12,13 @@
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/bb-load.php';
|
||||
$di = include dirname(__FILE__).'/bb-di.php';
|
||||
require_once __DIR__ .'/bb-load.php';
|
||||
$di = include __DIR__ .'/bb-di.php';
|
||||
$di['translate']();
|
||||
|
||||
$bb_invoice_id = null;
|
||||
if (isset($_GET['bb_invoice_id'])) {
|
||||
$bb_invoice_id = $_GET['bb_invoice_id'];
|
||||
}
|
||||
if (isset($_POST['bb_invoice_id'])) {
|
||||
$bb_invoice_id = $_POST['bb_invoice_id'];
|
||||
}
|
||||
$bb_invoice_id = $_POST['bb_invoice_id'] ?? $_GET['bb_invoice_id'] ?? null;
|
||||
|
||||
$bb_gateway_id = null;
|
||||
if (isset($_GET['bb_gateway_id'])) {
|
||||
$bb_gateway_id = $_GET['bb_gateway_id'];
|
||||
}
|
||||
if (isset($_POST['bb_gateway_id'])) {
|
||||
$bb_gateway_id = $_POST['bb_gateway_id'];
|
||||
}
|
||||
$bb_gateway_id = $_POST['bb_gateway_id'] ?? $_GET['bb_gateway_id'] ?? null;
|
||||
|
||||
$ipn = [
|
||||
'skip_validation' => true,
|
||||
@@ -52,14 +40,14 @@ try {
|
||||
}
|
||||
|
||||
// redirect to invoice if gateways requires
|
||||
if (isset($_GET['bb_redirect']) && isset($_GET['bb_invoice_hash'])) {
|
||||
if (isset($_GET['bb_redirect'], $_GET['bb_invoice_hash'])) {
|
||||
$url = $di['url']->link('invoice/'.$_GET['bb_invoice_hash']);
|
||||
header("Location: $url");
|
||||
exit;
|
||||
} else {
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($res);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($res);
|
||||
exit;
|
||||
+43
-39
@@ -11,16 +11,20 @@
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
define('BB_PATH_ROOT', dirname(__FILE__));
|
||||
define('BB_PATH_VENDOR', BB_PATH_ROOT.'/vendor');
|
||||
define('BB_PATH_LIBRARY', BB_PATH_ROOT.'/bb-library');
|
||||
define('BB_PATH_THEMES', BB_PATH_ROOT.'/bb-themes');
|
||||
define('BB_PATH_MODS', BB_PATH_ROOT.'/bb-modules');
|
||||
define('BB_PATH_LANGS', BB_PATH_ROOT.'/bb-locale');
|
||||
define('BB_PATH_UPLOADS', BB_PATH_ROOT.'/bb-uploads');
|
||||
define('BB_PATH_DATA', BB_PATH_ROOT.'/bb-data');
|
||||
define('isCLI', 'cli' == php_sapi_name());
|
||||
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\Run;
|
||||
|
||||
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ?: 'production'));
|
||||
const BB_PATH_ROOT = __DIR__;
|
||||
const BB_PATH_VENDOR = BB_PATH_ROOT . '/vendor';
|
||||
const BB_PATH_LIBRARY = BB_PATH_ROOT . '/bb-library';
|
||||
const BB_PATH_THEMES = BB_PATH_ROOT . '/bb-themes';
|
||||
const BB_PATH_MODS = BB_PATH_ROOT . '/bb-modules';
|
||||
const BB_PATH_LANGS = BB_PATH_ROOT . '/bb-locale';
|
||||
const BB_PATH_UPLOADS = BB_PATH_ROOT . '/bb-uploads';
|
||||
const BB_PATH_DATA = BB_PATH_ROOT . '/bb-data';
|
||||
const isCLI = 'cli' === PHP_SAPI;
|
||||
|
||||
function handler_error(int $number, string $message, string $file, int $line)
|
||||
{
|
||||
@@ -43,7 +47,7 @@ function handler_exception($e)
|
||||
if (isCLI) {
|
||||
echo 'Error #['.$e->getCode().'] occurred in ['.$e->getFile().'] at line ['.$e->getLine().']: ['.trim(strip_tags($e->getMessage())).']';
|
||||
} else {
|
||||
if (APPLICATION_ENV == 'testing') {
|
||||
if (APPLICATION_ENV === 'testing') {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
|
||||
return;
|
||||
@@ -51,7 +55,7 @@ function handler_exception($e)
|
||||
error_log($e->getMessage());
|
||||
|
||||
if (defined('BB_MODE_API')) {
|
||||
$code = $e->getCode() ? $e->getCode() : 9998;
|
||||
$code = $e->getCode() ?: 9998;
|
||||
$result = ['result' => null, 'error' => ['message' => $e->getMessage(), 'code' => $code]];
|
||||
echo json_encode($result);
|
||||
|
||||
@@ -63,11 +67,11 @@ function handler_exception($e)
|
||||
* If advanced debugging is enabled, print Whoops instead of our error page.
|
||||
* flip/whoops documentation: https://github.com/filp/whoops/blob/master/docs/API%20Documentation.md.
|
||||
*/
|
||||
$whoops = new \Whoops\Run();
|
||||
$prettyPage = new \Whoops\Handler\PrettyPageHandler();
|
||||
$whoops = new Run();
|
||||
$prettyPage = new PrettyPageHandler();
|
||||
$prettyPage->setPageTitle('An error ocurred');
|
||||
$prettyPage->addDataTable('FOSSBilling environment', [
|
||||
'PHP Version' => phpversion(),
|
||||
'PHP Version' => PHP_VERSION,
|
||||
'Error code' => $e->getCode(),
|
||||
]);
|
||||
$whoops->pushHandler($prettyPage);
|
||||
@@ -78,15 +82,15 @@ function handler_exception($e)
|
||||
} else {
|
||||
$page = "<!DOCTYPE html>
|
||||
<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\">
|
||||
|
||||
@@ -95,17 +99,17 @@ function handler_exception($e)
|
||||
-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%;
|
||||
@@ -114,14 +118,14 @@ function handler_exception($e)
|
||||
-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;
|
||||
@@ -133,7 +137,7 @@ function handler_exception($e)
|
||||
background-repeat: no-repeat;
|
||||
background-size: 124px 144px;
|
||||
}
|
||||
|
||||
|
||||
.error .error-container:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
@@ -146,7 +150,7 @@ function handler_exception($e)
|
||||
background-color: #f2f5f8;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
|
||||
.error h1 {
|
||||
font-family: 'Nunito', sans-serif;
|
||||
font-size: 65px;
|
||||
@@ -156,7 +160,7 @@ function handler_exception($e)
|
||||
color: #151723;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
|
||||
.error h2 {
|
||||
font-family: 'Nunito', sans-serif;
|
||||
font-size: 21px;
|
||||
@@ -165,13 +169,13 @@ function handler_exception($e)
|
||||
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;
|
||||
@@ -180,7 +184,7 @@ function handler_exception($e)
|
||||
text-decoration: none;
|
||||
color: #388dbc;
|
||||
}
|
||||
|
||||
|
||||
@media only screen and (max-width: 767px) {
|
||||
.error .error-container {
|
||||
width: 110px;
|
||||
@@ -200,7 +204,7 @@ function handler_exception($e)
|
||||
padding: 2px;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -220,7 +224,7 @@ function handler_exception($e)
|
||||
echo sprintf('<center><p><a href="https://docs.fossbilling.org/en/latest/search.html?q=%s&check_keywords=yes&area=default" target="_blank">Look for detailed error explanation</a></p></center>', urlencode($e->getMessage()));
|
||||
echo '<center><hr><p>Powered by <a href="https://fossbilling.org">FOSSBilling</a></p></center>
|
||||
</body>
|
||||
|
||||
|
||||
</html>';
|
||||
}
|
||||
}
|
||||
@@ -237,8 +241,8 @@ if (!file_exists(BB_PATH_VENDOR)) {
|
||||
// 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']) || ('cli' == php_sapi_name() && isset($argv[1]))) {
|
||||
if ('cli' == php_sapi_name()) {
|
||||
if ((isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) || ('cli' === PHP_SAPI && isset($argv[1]))) {
|
||||
if ('cli' === PHP_SAPI) {
|
||||
$host = $argv[1];
|
||||
} else {
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
@@ -251,12 +255,12 @@ if ((isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) || ('cli' == php_sap
|
||||
}
|
||||
|
||||
// Try to check if configuration is available
|
||||
if (!file_exists($configPath) || 0 == filesize($configPath)) {
|
||||
if (!file_exists($configPath) || 0 === filesize($configPath)) {
|
||||
// Try to create an empty configuration file
|
||||
@file_put_contents($configPath, '');
|
||||
|
||||
$base_url = 'http'.(isset($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'] || 1 == $_SERVER['HTTPS']) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ? 's' : '').'://'.$_SERVER['HTTP_HOST'];
|
||||
$base_url .= preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME']));
|
||||
$base_url = 'http'.((isset($_SERVER['HTTPS']) && ('on' === $_SERVER['HTTPS'] || 1 == $_SERVER['HTTPS'])) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO']) ? 's' : '').'://'.$_SERVER['HTTP_HOST'];
|
||||
$base_url .= rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
|
||||
$url = $base_url.'/install/index.php';
|
||||
|
||||
if (file_exists(BB_PATH_ROOT.'/install/index.php')) {
|
||||
@@ -264,7 +268,7 @@ if (!file_exists($configPath) || 0 == filesize($configPath)) {
|
||||
}
|
||||
|
||||
$configFile = pathinfo($configPath, PATHINFO_BASENAME);
|
||||
$msg = sprintf("Your <b><em>$configFile</em></b> file seems to be invalid. It's possible that your preexisting configuration file may not contain the required configuration parameters or have become corrupted. FOSSBilling needs to have a valid configuration file present in order to function properly.</p> <p>Please use the example config as reference <a target='_blank' href='https://raw.githubusercontent.com/FOSSBilling/FOSSBilling/master/src/bb-config-sample.php'>here</a>. You may need to manually restore a old config file or fix your existing one.</p>");
|
||||
$msg = "Your <b><em>$configFile</em></b> file seems to be invalid. It's possible that your preexisting configuration file may not contain the required configuration parameters or have become corrupted. FOSSBilling needs to have a valid configuration file present in order to function properly.</p> <p>Please use the example config as reference <a target='_blank' href='https://raw.githubusercontent.com/FOSSBilling/FOSSBilling/master/src/bb-config-sample.php'>here</a>. You may need to manually restore a old config file or fix your existing one.</p>";
|
||||
throw new Exception($msg, 101);
|
||||
}
|
||||
|
||||
@@ -273,7 +277,7 @@ if (file_exists($configPath) && 0 !== filesize($configPath) && file_exists(BB_PA
|
||||
throw new Exception('For safety reasons, you have to delete the <b><em>/install</em></b> directory to start using FOSSBilling.</p><p>Please delete the <b><em>/install</em></b> directory from your web server.', 102);
|
||||
}
|
||||
|
||||
$config = require_once $configPath;
|
||||
$config = require $configPath;
|
||||
require BB_PATH_VENDOR.'/autoload.php';
|
||||
|
||||
date_default_timezone_set($config['timezone']);
|
||||
@@ -283,7 +287,7 @@ define('BB_URL', $config['url']);
|
||||
define('BB_SEF_URLS', $config['sef_urls']);
|
||||
define('BB_PATH_CACHE', $config['path_data'].'/cache');
|
||||
define('BB_PATH_LOG', $config['path_data'].'/log');
|
||||
define('BB_SSL', ('https' === substr($config['url'], 0, 5)));
|
||||
define('BB_SSL', (str_starts_with($config['url'], 'https')));
|
||||
|
||||
if ($config['sef_urls']) {
|
||||
define('BB_URL_API', $config['url'].'api/');
|
||||
|
||||
+37
-37
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
class BBPatch_25 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
// Change table data storage engine
|
||||
$query = 'ALTER TABLE `activity_admin_history` ENGINE = INNODB;
|
||||
@@ -96,7 +96,7 @@ class BBPatch_25 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_24 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
// Initializing meta description support for announcements
|
||||
$q = 'ALTER TABLE `post` ADD `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER `title`';
|
||||
@@ -114,7 +114,7 @@ class BBPatch_24 extends BBPatchAbstract
|
||||
|
||||
class BBPatch_23 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE mod_email_queue CHANGE `from` sender varchar(255) ;';
|
||||
$this->execSql($q);
|
||||
@@ -129,7 +129,7 @@ class BBPatch_23 extends BBPatchAbstract
|
||||
|
||||
class BBPatch_22 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `client_balance` CHANGE `rel_id` `rel_id` VARCHAR(20) NULL DEFAULT NULL;';
|
||||
$this->execSql($q);
|
||||
@@ -141,7 +141,7 @@ class BBPatch_22 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_21 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'CREATE TABLE IF NOT EXISTS `mod_email_queue` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
@@ -168,7 +168,7 @@ class BBPatch_21 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_20 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$tables = [
|
||||
'activity_admin_history' => ['created_at', 'updated_at'],
|
||||
@@ -246,7 +246,7 @@ class BBPatch_20 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_19 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `client` MODIFY `birthday` date;';
|
||||
$this->execSql($q);
|
||||
@@ -258,7 +258,7 @@ class BBPatch_19 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_18 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `promo` ADD `client_groups` TEXT NULL AFTER `products`;';
|
||||
$this->execSql($q);
|
||||
@@ -270,7 +270,7 @@ class BBPatch_18 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_17 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = "CREATE TABLE IF NOT EXISTS `session` (
|
||||
`id` varchar(32) NOT NULL DEFAULT '',
|
||||
@@ -287,7 +287,7 @@ class BBPatch_17 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_16 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'CREATE TABLE IF NOT EXISTS `form` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
@@ -339,7 +339,7 @@ class BBPatch_16 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_15 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'CREATE TABLE IF NOT EXISTS `client_order_meta` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
@@ -385,7 +385,7 @@ class BBPatch_15 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_14 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `service_license` ADD `checked_at` VARCHAR( 35 ) DEFAULT NULL AFTER `plugin`;';
|
||||
$this->execSql($q);
|
||||
@@ -397,7 +397,7 @@ class BBPatch_14 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_13 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `forum` ADD `category` VARCHAR( 255 ) NOT NULL AFTER `id`;';
|
||||
$this->execSql($q);
|
||||
@@ -415,7 +415,7 @@ class BBPatch_13 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_12 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `admin` ADD `permissions` TEXT NULL DEFAULT NULL AFTER `api_token`;';
|
||||
$this->execSql($q);
|
||||
@@ -427,7 +427,7 @@ class BBPatch_12 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_11 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `client_order` ADD `referred_by` VARCHAR( 255 ) NULL AFTER `config`;';
|
||||
$this->execSql($q);
|
||||
@@ -475,7 +475,7 @@ class BBPatch_11 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_10 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `client` ADD `auth_type` VARCHAR( 255 ) NULL AFTER `role`;';
|
||||
$this->execSql($q);
|
||||
@@ -489,7 +489,7 @@ class BBPatch_10 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_9 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = "UPDATE currency SET format = REPLACE(format, '%price%' , '{{price}}' ) WHERE 1;";
|
||||
$this->execSql($q);
|
||||
@@ -501,7 +501,7 @@ class BBPatch_9 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_8 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `client` ADD `salt` VARCHAR(255) NULL AFTER `pass`;';
|
||||
$this->execSql($q);
|
||||
@@ -516,7 +516,7 @@ class BBPatch_8 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_7 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `email_template` ADD `description` TEXT NULL AFTER `content`;';
|
||||
$this->execSql($q);
|
||||
@@ -556,7 +556,7 @@ class BBPatch_7 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_6 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `transaction` CHANGE `amount` `amount` VARCHAR( 255 ) NULL DEFAULT NULL;';
|
||||
$this->execSql($q);
|
||||
@@ -594,7 +594,7 @@ class BBPatch_6 extends BBPatchAbstract
|
||||
*/
|
||||
class BBPatch_5 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `extension_meta` ADD `client_id` INT NULL DEFAULT NULL AFTER `id`;';
|
||||
$this->execSql($q);
|
||||
@@ -663,7 +663,7 @@ class BBPatch_5 extends BBPatchAbstract
|
||||
|
||||
class BBPatch_4 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = "INSERT INTO `email_template` (`action_code`, `category`, `enabled`, `subject`, `content`) VALUES ('support_ticket_admin_close', 'support', 1, 'Support Ticket Closed', '<p>Ticket ID: #{{ticket.id}}<br/> closed</p>\n<hr/>\n<p>{{company.signature}}</p>');";
|
||||
$this->execSql($q);
|
||||
@@ -720,7 +720,7 @@ class BBPatch_4 extends BBPatchAbstract
|
||||
|
||||
class BBPatch_3 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = "INSERT INTO `extension` (`type`, `name`, `status`, `version`) VALUES
|
||||
('mod', 'branding', 'installed', '1.0.0');";
|
||||
@@ -743,7 +743,7 @@ class BBPatch_3 extends BBPatchAbstract
|
||||
|
||||
class BBPatch_2 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$q = 'ALTER TABLE `client_order` CHANGE `group_id` `group_id` VARCHAR( 255 ) NULL DEFAULT NULL;';
|
||||
$this->execSql($q);
|
||||
@@ -776,7 +776,7 @@ class BBPatch_2 extends BBPatchAbstract
|
||||
|
||||
class BBPatch_1 extends BBPatchAbstract
|
||||
{
|
||||
public function patch()
|
||||
public function patch(): void
|
||||
{
|
||||
$query = "
|
||||
INSERT INTO `email_template` (`action_code`, `category`, `enabled`, `subject`, `content`) VALUES
|
||||
@@ -791,9 +791,9 @@ class BBPatch_1 extends BBPatchAbstract
|
||||
|
||||
abstract class BBPatchAbstract
|
||||
{
|
||||
protected $pdo = null;
|
||||
private $version = 0;
|
||||
private $k = 'last_patch';
|
||||
protected mixed $pdo;
|
||||
private int $version;
|
||||
private string $k = 'last_patch';
|
||||
|
||||
public function __construct($di)
|
||||
{
|
||||
@@ -805,12 +805,12 @@ abstract class BBPatchAbstract
|
||||
|
||||
abstract public function patch();
|
||||
|
||||
public function donePatching()
|
||||
public function donePatching(): void
|
||||
{
|
||||
$this->setParamValue($this->k, $this->version);
|
||||
}
|
||||
|
||||
protected function execSql($sql)
|
||||
protected function execSql($sql): void
|
||||
{
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
try {
|
||||
@@ -820,17 +820,17 @@ abstract class BBPatchAbstract
|
||||
}
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
public function getVersion(): int
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
public function isPatched()
|
||||
public function isPatched(): bool
|
||||
{
|
||||
return $this->getParamValue($this->k, 0) >= $this->version;
|
||||
}
|
||||
|
||||
private function setParamValue($param, $value)
|
||||
private function setParamValue($param, $value): void
|
||||
{
|
||||
if (is_null($this->getParamValue($param))) {
|
||||
$query = 'INSERT INTO setting (param, value, public, updated_at, created_at) VALUES (:param, :value, 1, :u, :c)';
|
||||
@@ -862,13 +862,13 @@ abstract class BBPatchAbstract
|
||||
|
||||
$patches = [];
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if (false !== strpos($class, 'BBPatch_')) {
|
||||
if (str_contains($class, 'BBPatch_')) {
|
||||
$patches[] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/bb-load.php';
|
||||
$di = include dirname(__FILE__) . '/bb-di.php';
|
||||
require_once __DIR__ . '/bb-load.php';
|
||||
$di = include __DIR__ . '/bb-di.php';
|
||||
|
||||
error_log('Executing FOSSBilling update script');
|
||||
natsort($patches);
|
||||
@@ -888,4 +888,4 @@ foreach ($patches as $class) {
|
||||
}
|
||||
error_log('FOSSBilling update completed');
|
||||
|
||||
echo 'Update completed. You are using FOSSBilling ' . Box_Version::VERSION . PHP_EOL;
|
||||
echo 'Update completed. You are using FOSSBilling ' . Box_Version::VERSION . PHP_EOL;
|
||||
+3
-4
@@ -12,18 +12,17 @@
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/bb-load.php';
|
||||
$di = include dirname(__FILE__).'/bb-di.php';
|
||||
require_once __DIR__ .'/bb-load.php';
|
||||
$di = include __DIR__ .'/bb-di.php';
|
||||
$url = $di['request']->getQuery('_url');
|
||||
$admin_prefix = $di['config']['admin_area_prefix'];
|
||||
if (0 === strncasecmp($url, $admin_prefix, strlen($admin_prefix))) {
|
||||
$url = str_replace($admin_prefix, '', preg_replace('/\?.+/', '', $url));
|
||||
$app = new Box_AppAdmin();
|
||||
$app->setUrl($url);
|
||||
} else {
|
||||
$app = new Box_AppClient();
|
||||
$app->setUrl($url);
|
||||
}
|
||||
$app->setUrl($url);
|
||||
$di['translate']();
|
||||
$app->setDi($di);
|
||||
echo $app->run();
|
||||
|
||||
+60
-58
@@ -13,16 +13,19 @@
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
use Box\Mod\Email\Service;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @see http://stackoverflow.com/a/2886224/2728507
|
||||
*/
|
||||
function isSSL()
|
||||
function isSSL(): bool
|
||||
{
|
||||
return
|
||||
(!empty($_SERVER['HTTPS']) && 'off' !== $_SERVER['HTTPS'])
|
||||
|| 443 == $_SERVER['SERVER_PORT'];
|
||||
|| 443 === $_SERVER['SERVER_PORT'];
|
||||
}
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
@@ -31,7 +34,7 @@ error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', '1');
|
||||
ini_set('error_log', dirname(__FILE__) . '/logs/php_error.log');
|
||||
ini_set('error_log', __DIR__ . '/logs/php_error.log');
|
||||
|
||||
$protocol = isSSL() ? 'https' : 'http';
|
||||
$url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
@@ -39,30 +42,30 @@ $current_url = pathinfo($url, PATHINFO_DIRNAME);
|
||||
$root_url = str_replace('/install', '', $current_url) . '/';
|
||||
|
||||
define('BB_URL', $root_url);
|
||||
define('BB_URL_INSTALL', BB_URL . 'install/');
|
||||
define('BB_URL_ADMIN', BB_URL . 'index.php?_url=/bb-admin');
|
||||
const BB_URL_INSTALL = BB_URL . 'install/';
|
||||
const BB_URL_ADMIN = BB_URL . 'index.php?_url=/bb-admin';
|
||||
|
||||
define('BB_PATH_ROOT', realpath(dirname(__FILE__) . '/..'));
|
||||
define('BB_PATH_LIBRARY', BB_PATH_ROOT . '/bb-library');
|
||||
define('BB_PATH_VENDOR', BB_PATH_ROOT . '/vendor');
|
||||
define('BB_PATH_INSTALL_THEMES', BB_PATH_ROOT . '/install');
|
||||
define('BB_PATH_THEMES', BB_PATH_ROOT . '/bb-themes');
|
||||
define('BB_PATH_LICENSE', BB_PATH_ROOT . '/LICENSE');
|
||||
define('BB_PATH_SQL', BB_PATH_ROOT . '/install/sql/structure.sql');
|
||||
define('BB_PATH_SQL_DATA', BB_PATH_ROOT . '/install/sql/content.sql');
|
||||
define('BB_PATH_INSTALL', BB_PATH_ROOT . '/install');
|
||||
define('BB_PATH_CONFIG', BB_PATH_ROOT . '/bb-config.php');
|
||||
define('BB_PATH_CRON', BB_PATH_ROOT . '/bb-cron.php');
|
||||
define('BB_PATH_LANGS', BB_PATH_ROOT . '/bb-locale');
|
||||
define('BB_PATH_ROOT', dirname(__DIR__));
|
||||
const BB_PATH_LIBRARY = BB_PATH_ROOT . '/bb-library';
|
||||
const BB_PATH_VENDOR = BB_PATH_ROOT . '/vendor';
|
||||
const BB_PATH_INSTALL_THEMES = BB_PATH_ROOT . '/install';
|
||||
const BB_PATH_THEMES = BB_PATH_ROOT . '/bb-themes';
|
||||
const BB_PATH_LICENSE = BB_PATH_ROOT . '/LICENSE';
|
||||
const BB_PATH_SQL = BB_PATH_ROOT . '/install/sql/structure.sql';
|
||||
const BB_PATH_SQL_DATA = BB_PATH_ROOT . '/install/sql/content.sql';
|
||||
const BB_PATH_INSTALL = BB_PATH_ROOT . '/install';
|
||||
const BB_PATH_CONFIG = BB_PATH_ROOT . '/bb-config.php';
|
||||
const BB_PATH_CRON = BB_PATH_ROOT . '/bb-cron.php';
|
||||
const BB_PATH_LANGS = BB_PATH_ROOT . '/bb-locale';
|
||||
|
||||
/*
|
||||
Config paths & templates
|
||||
*/
|
||||
define('BB_PATH_HTACCESS', BB_PATH_ROOT . '/.htaccess');
|
||||
define('BB_PATH_HTACCESS_TEMPLATE', BB_PATH_ROOT . '/htaccess.txt');
|
||||
const BB_PATH_HTACCESS = BB_PATH_ROOT . '/.htaccess';
|
||||
const BB_PATH_HTACCESS_TEMPLATE = BB_PATH_ROOT . '/htaccess.txt';
|
||||
|
||||
define('BB_HURAGA_CONFIG', BB_PATH_THEMES . '/huraga/config/settings_data.json');
|
||||
define('BB_HURAGA_CONFIG_TEMPLATE', BB_PATH_THEMES . '/huraga/config/settings_data.json.txt');
|
||||
const BB_HURAGA_CONFIG = BB_PATH_THEMES . '/huraga/config/settings_data.json';
|
||||
const BB_HURAGA_CONFIG_TEMPLATE = BB_PATH_THEMES . '/huraga/config/settings_data.json.txt';
|
||||
|
||||
// Ensure library/ is on include_path
|
||||
set_include_path(implode(PATH_SEPARATOR, [
|
||||
@@ -74,7 +77,7 @@ require BB_PATH_VENDOR . '/autoload.php';
|
||||
|
||||
final class Box_Installer
|
||||
{
|
||||
private $session;
|
||||
private Session $session;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -82,7 +85,7 @@ final class Box_Installer
|
||||
$this->session = new Session();
|
||||
}
|
||||
|
||||
public function run($action)
|
||||
public function run($action): void
|
||||
{
|
||||
switch ($action) {
|
||||
case 'check-db':
|
||||
@@ -115,26 +118,26 @@ final class Box_Installer
|
||||
$name = $_POST['db_name'];
|
||||
if (!$this->canConnectToDatabase($host.';'.$port, $name, $user, $pass)) {
|
||||
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_port', $port);
|
||||
$this->session->set('db_name', $name);
|
||||
$this->session->set('db_user', $user);
|
||||
$this->session->set('db_pass', $pass);
|
||||
}
|
||||
|
||||
$this->session->set('db_host', $host);
|
||||
$this->session->set('db_port', $port);
|
||||
$this->session->set('db_name', $name);
|
||||
$this->session->set('db_user', $user);
|
||||
$this->session->set('db_pass', $pass);
|
||||
|
||||
// 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('Administrator\'s account is not valid');
|
||||
} else {
|
||||
$this->session->set('admin_email', $admin_email);
|
||||
$this->session->set('admin_pass', $admin_pass);
|
||||
$this->session->set('admin_name', $admin_name);
|
||||
}
|
||||
|
||||
$this->session->set('admin_email', $admin_email);
|
||||
$this->session->set('admin_pass', $admin_pass);
|
||||
$this->session->set('admin_name', $admin_name);
|
||||
|
||||
$this->session->set('license', 'FOSSBilling CE');
|
||||
$this->makeInstall($this->session);
|
||||
$this->generateEmailTemplates();
|
||||
@@ -145,8 +148,8 @@ final class Box_Installer
|
||||
if (is_dir($dir)) {
|
||||
$contents = scandir($dir);
|
||||
foreach ($contents as $content) {
|
||||
if ('.' != $content && '..' != $content) {
|
||||
if ('dir' == filetype($dir . '/' . $content)) {
|
||||
if ('.' !== $content && '..' !== $content) {
|
||||
if ('dir' === filetype($dir . '/' . $content)) {
|
||||
rmAllDir($dir . '/' . $content);
|
||||
} else {
|
||||
unlink($dir . '/' . $content);
|
||||
@@ -159,7 +162,7 @@ final class Box_Installer
|
||||
}
|
||||
try {
|
||||
rmAllDir('../install');
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception) {
|
||||
// do nothing
|
||||
}
|
||||
echo 'ok';
|
||||
@@ -215,7 +218,7 @@ final class Box_Installer
|
||||
}
|
||||
}
|
||||
|
||||
private function render($name, $vars = [])
|
||||
private function render($name, $vars = []): string
|
||||
{
|
||||
$options = [
|
||||
'paths' => [BB_PATH_INSTALL_THEMES],
|
||||
@@ -226,7 +229,7 @@ final class Box_Installer
|
||||
'auto_reload' => true,
|
||||
'cache' => false,
|
||||
];
|
||||
$loader = new \Twig\Loader\FilesystemLoader($options['paths']);
|
||||
$loader = new FilesystemLoader($options['paths']);
|
||||
$twig = new Twig\Environment($loader, $options);
|
||||
// $twig->addExtension(new Twig_Extension_Optimizer());
|
||||
$twig->addGlobal('request', $_REQUEST);
|
||||
@@ -235,7 +238,7 @@ final class Box_Installer
|
||||
return $twig->render($name, $vars);
|
||||
}
|
||||
|
||||
private function getLicense()
|
||||
private function getLicense(): bool|string
|
||||
{
|
||||
$path = BB_PATH_LICENSE;
|
||||
if (!file_exists($path)) {
|
||||
@@ -245,15 +248,15 @@ final class Box_Installer
|
||||
return file_get_contents($path);
|
||||
}
|
||||
|
||||
private function getPdo($host, $db, $user, $pass)
|
||||
private function getPdo($host, $db, $user, $pass): PDO
|
||||
{
|
||||
$pdo = new \PDO('mysql:host=' . $host,
|
||||
$pdo = new PDO('mysql:host=' . $host,
|
||||
$user,
|
||||
$pass,
|
||||
[
|
||||
\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -277,11 +280,11 @@ final class Box_Installer
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
private function canConnectToDatabase($host, $db, $user, $pass)
|
||||
private function canConnectToDatabase($host, $db, $user, $pass): bool
|
||||
{
|
||||
try {
|
||||
$this->getPdo($host, $db, $user, $pass);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
|
||||
return false;
|
||||
@@ -290,7 +293,7 @@ final class Box_Installer
|
||||
return true;
|
||||
}
|
||||
|
||||
private function isValidAdmin($email, $pass, $name)
|
||||
private function isValidAdmin($email, $pass, $name): bool
|
||||
{
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
return false;
|
||||
@@ -307,7 +310,7 @@ final class Box_Installer
|
||||
return true;
|
||||
}
|
||||
|
||||
private function makeInstall($ns)
|
||||
private function makeInstall($ns): bool
|
||||
{
|
||||
$this->_isValidInstallData($ns);
|
||||
$this->_createConfigurationFile($ns);
|
||||
@@ -325,16 +328,15 @@ final class Box_Installer
|
||||
|
||||
$sql = preg_split('/\;[\r]*\n/ism', $sql);
|
||||
$sql = array_map('trim', $sql);
|
||||
$err = '';
|
||||
foreach ($sql as $query) {
|
||||
if (!trim($query)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$res = $pdo->query($query);
|
||||
$pdo->query($query);
|
||||
}
|
||||
|
||||
$passwordObject = new \Box_Password();
|
||||
$passwordObject = new Box_Password();
|
||||
$stmt = $pdo->prepare("INSERT INTO admin (role, name, email, pass, protected, created_at, updated_at) VALUES('admin', :admin_name, :admin_email, :admin_pass, 1, NOW(), NOW());");
|
||||
$stmt->execute([
|
||||
'admin_name' => $ns->get('admin_name'),
|
||||
@@ -363,7 +365,7 @@ final class Box_Installer
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _sendMail($ns)
|
||||
private function _sendMail($ns): void
|
||||
{
|
||||
$admin_name = $ns->get('admin_name');
|
||||
$admin_email = $ns->get('admin_email');
|
||||
@@ -384,7 +386,7 @@ final class Box_Installer
|
||||
@mail($admin_email, $subject, $content);
|
||||
}
|
||||
|
||||
private function _createConfigurationFile($data)
|
||||
private function _createConfigurationFile($data): void
|
||||
{
|
||||
$output = $this->_getConfigOutput($data);
|
||||
if (!@file_put_contents(BB_PATH_CONFIG, $output)) {
|
||||
@@ -392,7 +394,7 @@ final class Box_Installer
|
||||
}
|
||||
}
|
||||
|
||||
private function _getConfigOutput($ns)
|
||||
private function _getConfigOutput($ns): string
|
||||
{
|
||||
// TODO: Why not just take the defaults from the bb.config.example.php file and modify accordingly? Also this method doesn't preserve the comments in the example config.
|
||||
$data = [
|
||||
@@ -453,7 +455,7 @@ final class Box_Installer
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function _isValidInstallData($ns)
|
||||
private function _isValidInstallData($ns): void
|
||||
{
|
||||
if (!$this->canConnectToDatabase($ns->get('db_host'), $ns->get('db_name'), $ns->get('db_user'), $ns->get('db_pass'))) {
|
||||
throw new Exception('Can not connect to database');
|
||||
@@ -464,12 +466,12 @@ final class Box_Installer
|
||||
}
|
||||
}
|
||||
|
||||
private function generateEmailTemplates()
|
||||
private function generateEmailTemplates(): bool
|
||||
{
|
||||
define('BB_PATH_MODS', BB_PATH_ROOT . '/bb-modules');
|
||||
|
||||
$emailService = new \Box\Mod\Email\Service();
|
||||
$di = $di = include BB_PATH_ROOT . '/bb-di.php';
|
||||
$emailService = new Service();
|
||||
$di = include BB_PATH_ROOT . '/bb-di.php';
|
||||
$di['translate']();
|
||||
$emailService->setDi($di);
|
||||
|
||||
|
||||
Reference in new issue
Block a user