Skip to content

Commit

Permalink
Mirgate to PSR12 and other small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andpavlenko committed Apr 1, 2022
1 parent 84ae07b commit f4c4f6b
Show file tree
Hide file tree
Showing 184 changed files with 16,533 additions and 13,869 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ composer.phar
public
report/*
data/db

### phpunit/phpunit ###
.phpunit.result.cache

### node_moduels ###
### node_modules ###
node_modules
npm-debug.log
.history/

### friendsofphp/php-cs-fixer ###
src/.php-cs-fixer.cache
82 changes: 82 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
# Change these settings to your own preference
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.feature]
indent_style = space
indent_size = 4

[*.js]
indent_style = space
indent_size = 2

[*.json]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[*.neon]
indent_style = space
indent_size = 4

[*.php]
indent_style = space
indent_size = 4

[*.sh]
indent_style = space
indent_size = 4

[*.{yaml,yml}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[.babelrc]
indent_style = space
indent_size = 2

[.gitmodules]
indent_style = tab
indent_size = 4

[.php_cs{,.dist}]
indent_style = space
indent_size = 4

[composer.json]
indent_style = space
indent_size = 4

[package.json]
indent_style = space
indent_size = 2

[phpspec.yml{,.dist}]
indent_style = space
indent_size = 4

[phpstan.neon]
indent_style = space
indent_size = 4

[phpunit.xml{,.dist}]
indent_style = space
indent_size = 4
26 changes: 26 additions & 0 deletions src/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

return (new PhpCsFixer\Config())
->setRules([
'@PHP71Migration' => true,
'@Symfony' => true,
'protected_to_private' => false,
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => false],
'phpdoc_to_comment' => false,
])
->setRiskyAllowed(false)
->setFinder(
(new PhpCsFixer\Finder())
->in(__DIR__)
->exclude([
'bb-data',
'bb-library',
'bb-locale',
'bb-themes',
'bb-vendor',
'install',
'bb-modules/Wysiwyg'
])
->notPath('rb.php')
)
;
141 changes: 71 additions & 70 deletions src/bb-config-sample.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* BoxBilling configuration file example
* BoxBilling configuration file example.
*
* If you are not using the web installer, you can rename this file
* to "bb-config.php" and fill in the values.
Expand All @@ -10,190 +10,191 @@
* Remove /install directory
*/

return array(

'salt' => '',
return [
'salt' => '',

/**
* Full URL where BoxBilling is installed with trailing slash
* Full URL where BoxBilling is installed with trailing slash.
*/
'url' => 'http://localhost/',
'url' => 'http://localhost/',

/**
* The URL prefix to access the BB admin area. Ex: '/bb-admin' for https://example.com/bb-admin
* The URL prefix to access the BB admin area. Ex: '/bb-admin' for https://example.com/bb-admin.
*/
'admin_area_prefix' => '/bb-admin',
'admin_area_prefix' => '/bb-admin',

/**
* Enable or disable displaying advanced debugging messages.
* You should keep this disabled unless you're making tests as it can reveal some information about your server.
*/
'debug' => false,
'debug' => false,

'maintenance_mode' => array(
'maintenance_mode' => [
/**
* Enable or disable the system maintenance mode.
* Enabling this will block public access to your website, and API endpoints except the allowed ones won't work
* However, this will not block access to the administrator area.
*
*
* @since 4.22.0
*/
'enabled' => false,
'enabled' => false,

/**
* Don't block these URLs when the maintenance is going on.
* Supports wildcard (e.g. '/api/guest/staff/*')
* Supports wildcard (e.g. '/api/guest/staff/*').
*
* @since 4.22.0
*/
'allowed_urls' => array(),
'allowed_urls' => [],

/**
* Don't block these IP/Subnet addresses when the maintenance is going on.
* Supported formats: 127.0.0.1、127.0.0.1/32
* Supported formats: 127.0.0.1、127.0.0.1/32.
*
* @since 4.22.0
*/
'allowed_ips' => array(),
),
'allowed_ips' => [],
],

/**
* Enable or disable search engine friendly URLs.
* Configure .htaccess file before enabling this feature
* Set to TRUE if using nginx
* Set to TRUE if using nginx.
*/
'sef_urls' => true,
'sef_urls' => true,

/**
* System timezone
* System timezone.
*/
'timezone' => 'UTC',
'timezone' => 'UTC',

/**
* BoxBilling locale
* BoxBilling locale.
*/
'locale' => 'en_US',
'locale' => 'en_US',

/**
* Set default date format for localized strings
* Set default date format for localized strings.
*
* @see http://php.net/manual/en/function.strftime.php
*/
'locale_date_format' => '%A, %d %B %G',
'locale_date_format' => '%A, %d %B %G',

/**
* Set default time format for localized strings
* Set default time format for localized strings.
*
* @see http://php.net/manual/en/function.strftime.php
*/
'locale_time_format' => ' %T',
'locale_time_format' => ' %T',

/**
* Set location to store sensitive data
* Set location to store sensitive data.
*/
'path_data' => dirname(__FILE__) . '/bb-data',
'path_data' => dirname(__FILE__).'/bb-data',

'path_logs' => dirname(__FILE__) . '/bb-data/log/application.log',
'path_logs' => dirname(__FILE__).'/bb-data/log/application.log',

'log_to_db' => true,
'log_to_db' => true,

'db' => array(
'db' => [
/**
* Database type. Don't change this if in doubt.
*/
'type' => 'mysql',
'type' => 'mysql',

/**
* Database hostname. Don't change this if in doubt.
*/
'host' => getenv('DB_HOST') ?: '127.0.0.1',
'host' => getenv('DB_HOST') ?: '127.0.0.1',

/**
* The name of the database for BoxBilling
* The name of the database for BoxBilling.
*/
'name' => getenv('DB_NAME') ?: 'boxbilling',
'name' => getenv('DB_NAME') ?: 'boxbilling',

/**
* Database username
* Database username.
*/
'user' => getenv('DB_USER') ?: 'foo',
'user' => getenv('DB_USER') ?: 'foo',

/**
* Database password
* Database password.
*/
'password' => getenv('DB_PASS') ?: 'foo',
'password' => getenv('DB_PASS') ?: 'foo',

/**
* Database Port
* Database Port.
*/
'port' => getenv('DB_PORT') ?: '3306',
),
'port' => getenv('DB_PORT') ?: '3306',
],

'twig' => array(
'debug' => false,
'auto_reload' => false,
'cache' => dirname(__FILE__) . '/bb-data/cache',
),
'twig' => [
'debug' => false,
'auto_reload' => false,
'cache' => dirname(__FILE__).'/bb-data/cache',
],

'api' => array(
'api' => [
// All requests made to the API must have referrer request header with the same URL as the BoxBilling installation
'require_referrer_header' => false,
'require_referrer_header' => false,

// Empty array will allow all IPs to access the API
'allowed_ips' => array(),
'allowed_ips' => [],

// Time span for limit in seconds
'rate_span' => 60 * 60,
'rate_span' => 60 * 60,

// How many requests allowed per time span
'rate_limit' => 1000,
'rate_limit' => 1000,

/**
* Note about rate-limiting login attempts:
* When the limit is reached, a default delay of 2 seconds is added to the request.
* When the limit is reached, a default delay of 2 seconds is added to the request.
* This makes brute-forcing a password useless while not outright blocking legitimate traffic.
* When calculating, ensure the rate-limited traffic can still make enough requests to stay rate limited
* Ex: One request every 2 seconds is more than 20 times in 1 minute, so the IP will remain throttled
* Ex: One request every 2 seconds is more than 20 times in 1 minute, so the IP will remain throttled.
*
* @since 4.22.0
*/

// Throttling delay
'throttle_delay' => 2,
'throttle_delay' => 2,

// Time span login for limit in seconds
'rate_span_login' => 60,
'rate_span_login' => 60,

// How many login requests allowed per time span
'rate_limit_login' => 20,
),
'rate_limit_login' => 20,
],

'guzzle' => array(
'guzzle' => [
/**
* The user agent to be used when making requests to external services
* The user agent to be used when making requests to external services.
*
* @since 4.22.0
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
*/
'user_agent' => 'Mozilla/5.0 (RedHatEnterpriseLinux; Linux x86_64; BoxBilling; +http://boxbilling.org) Gecko/20100101 Firefox/93.0',
'user_agent' => 'Mozilla/5.0 (RedHatEnterpriseLinux; Linux x86_64; BoxBilling; +http://boxbilling.org) Gecko/20100101 Firefox/93.0',

/**
* Default request timeout
* Setting 0 will disable this limitation
* Setting 0 will disable this limitation.
*
* @since 4.22.0
* @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout
*/
'timeout' => 0,
'timeout' => 0,

/**
* The HTTP Upgrade-Insecure-Requests header sends a signal to the server
* expressing the client’s preference for an encrypted response.
*
*
* 0: don't ask for an encrypted response
* 1: ask for an encrypted response
*
*
* @since 4.22.0
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade-Insecure-Requests
*/
'upgrade_insecure_requests' => 0
),
);
'upgrade_insecure_requests' => 0,
],
];
Loading

0 comments on commit f4c4f6b

Please sign in to comment.