' . $error['title'] . '
-
' . __trans('Error Code: #:number', [':number' => $code]) . '
-
' . __trans('Component: :category', [':category' => $error['category']]) . '
+
+ - ' . "Instance ID: $instanceID" . '
+ - ' . "Error Code: #$code" . '
+ - ' . 'Component: '. $error['category'] . '
+
+
' . $error['message'] . '
' . $message . '
@@ -284,11 +311,11 @@ class ErrorPage
if (og.style.display === "none") {
og.style.display = "block";
specialized.style.display = "none";
- document.querySelector("#toggle").innerHTML = "' . __trans("Show specialized message") . '";
+ document.querySelector("#toggle").innerHTML = "Show specialized message";
} else {
og.style.display = "none";
specialized.style.display = "block";
- document.querySelector("#toggle").innerHTML = "' . __trans("Show original message") . '";
+ document.querySelector("#toggle").innerHTML = "Show original message";
}
}
diff --git a/src/library/FOSSBilling/Exception.php b/src/library/FOSSBilling/Exception.php
new file mode 100644
index 000000000..8ddb1c575
--- /dev/null
+++ b/src/library/FOSSBilling/Exception.php
@@ -0,0 +1,92 @@
+stackTrace($stackLength, $protected));
+ }
+
+ // Translate the exception
+ if (function_exists('__trans')) {
+ $message = __trans($message, $variables);
+ } elseif (is_array($variables)) {
+ $message = strtr($message, $variables);
+ }
+
+ // Pass the message to the parent
+ parent::__construct($message, $code);
+ }
+
+
+ /**
+ * Big thank you to jhurliman and jambroseclarke on Stack Overflow for this backtrace formatter.
+ * We have slightly modified it for our purposes
+ * https://stackoverflow.com/a/32365961
+ */
+ private function stackTrace($Length = 25, $protected = false)
+ {
+ $stack = debug_backtrace($Length);
+ $output = '';
+
+ $stackLen = count($stack);
+ for ($i = 1; $i < $stackLen; $i++) {
+ $entry = $stack[$i];
+
+ $func = $entry['function'] . '(';
+ if (isset($entry['args'])) {
+ $argsLen = count($entry['args']);
+ for ($j = 0; $j < $argsLen; $j++) {
+ $my_entry = $entry['args'][$j];
+ if ($protected) {
+ $func .= "***";
+ } else if (is_string($my_entry)) {
+ $func .= $my_entry;
+ }
+ if ($j < $argsLen - 1) $func .= ', ';
+ }
+ }
+ $func .= ')';
+
+ $entry_file = 'NO_FILE';
+ if (array_key_exists('file', $entry)) {
+ $entry_file = str_replace(PATH_ROOT, '', $entry['file']);
+ }
+ $entry_line = 'NO_LINE';
+ if (array_key_exists('line', $entry)) {
+ $entry_line = $entry['line'];
+ }
+ $output .= $entry_file . ':' . $entry_line . ' - ' . $func . PHP_EOL;
+ }
+ return $output;
+ }
+}
diff --git a/src/library/FOSSBilling/ExtensionManager.php b/src/library/FOSSBilling/ExtensionManager.php
index 0f3b521ee..8c66ad512 100644
--- a/src/library/FOSSBilling/ExtensionManager.php
+++ b/src/library/FOSSBilling/ExtensionManager.php
@@ -44,14 +44,15 @@ class ExtensionManager implements InjectionAwareInterface
*
* @return array The extension details
* @example https://extensions.fossbilling.org/api/extension/Example An example of the API response
- * @throws \Box_Exception
+ *
+ * @throws Exception
*/
public function getExtension(string $id): array
{
$manifest = $this->makeRequest('extension/' . $id);
if (empty($manifest)) {
- throw new \Box_Exception('Unable to fetch the extension details from the FOSSBilling extension directory.');
+ throw new Exception('Unable to fetch the extension details from the FOSSBilling extension directory.');
}
return $manifest;
@@ -64,14 +65,15 @@ class ExtensionManager implements InjectionAwareInterface
*
* @return array The list of releases of the extension
* @example https://extensions.fossbilling.org/api/extension/Example An example of the API response (the "releases" array)
- * @throws \Box_Exception
+ *
+ * @throws Exception
*/
public function getExtensionReleases(string $id): array
{
$releases = $this->getExtension($id)['releases'];
if (empty($releases) || !is_array($releases)) {
- throw new \Box_Exception('Unable to fetch the releases of the extension from the FOSSBilling extension directory.');
+ throw new Exception('Unable to fetch the releases of the extension from the FOSSBilling extension directory.');
}
return $releases;
@@ -84,7 +86,8 @@ class ExtensionManager implements InjectionAwareInterface
*
* @return array The latest release of the extension
* @example https://extensions.fossbilling.org/api/extension/Example An example of the API response (the first element in the "releases" array)
- * @throws \Box_Exception
+ *
+ * @throws Exception
*/
public function getLatestExtensionRelease(string $id): array
{
@@ -92,7 +95,7 @@ class ExtensionManager implements InjectionAwareInterface
$latest = reset($releases);
if (empty($latest) || !is_array($latest)) {
- throw new \Box_Exception('Unable to fetch the latest release of the extension.');
+ throw new Exception('Unable to fetch the latest release of the extension.');
}
return $latest;
@@ -129,7 +132,7 @@ class ExtensionManager implements InjectionAwareInterface
$latest = $this->getLatestExtensionRelease($extension);
if ($this->di['config']['update_branch'] === 'release') {
- if (version_compare(\FOSSBilling\Version::VERSION, $latest['min_fossbilling_version'], '<')) {
+ if (version_compare(Version::VERSION, $latest['min_fossbilling_version'], '<')) {
return false;
}
}
@@ -144,7 +147,8 @@ class ExtensionManager implements InjectionAwareInterface
* @param array $params The array of parameters to pass to the API endpoint
*
* @return array The API response
- * @throws \Box_Exception
+ *
+ * @throws Exception
*/
public function makeRequest(string $endpoint, array $params = []): array
{
@@ -165,15 +169,15 @@ class ExtensionManager implements InjectionAwareInterface
$json = $response->toArray();
if (is_null($json)) {
- throw new \Box_Exception('Unable to connect to the FOSSBilling extension directory.', null, 1545);
+ throw new Exception('Unable to connect to the FOSSBilling extension directory.', null, 1545);
}
if (isset($json['error']) && is_array($json['error'])) {
- throw new \Box_Exception($json['error']['message'], null, 746);
+ throw new Exception($json['error']['message'], null, 746);
}
if (!isset($json['result']) || !is_array($json['result'])) {
- throw new \Box_Exception('Invalid response from the FOSSBilling extension directory.', null, 746);
+ throw new Exception('Invalid response from the FOSSBilling extension directory.', null, 746);
}
return $json['result'];
diff --git a/src/library/FOSSBilling/InformationException.php b/src/library/FOSSBilling/InformationException.php
new file mode 100644
index 000000000..e1665c95c
--- /dev/null
+++ b/src/library/FOSSBilling/InformationException.php
@@ -0,0 +1,29 @@
+= Email::PRIORITY_HIGHEST && $priority <= Email::PRIORITY_LOWEST) {
$this->email->priority($priority);
} else {
- throw new \Box_Exception("Provided priority (:priority) is invalid. Please provide an integer between 1 and 5 or use the pre-defined symfony constants.", [':priority' => $priority]);
+ throw new InformationException("Provided priority (:priority) is invalid. Please provide an integer between 1 and 5 or use the pre-defined symfony constants.", [':priority' => $priority]);
}
}
@@ -145,7 +145,7 @@ class Mail implements InjectionAwareInterface
*
* @param array|null $options An optional array of options specific to the chosen transport method.
*
- * @throws \Box_Exception If the transport method is unknown or if required options for the selected transport aren't defined
+ * @throws InformationException If the transport method is unknown or if required options for the selected transport aren't defined
*/
public function send(array|null $options = null): void
{
@@ -153,7 +153,7 @@ class Mail implements InjectionAwareInterface
case 'sendmail':
$dsn = 'sendmail://default';
if (!function_exists('proc_open')) {
- throw new \Box_Exception("FOSSBilling requires the proc_open PHP function to be enabled when using the sendmail transport");
+ throw new InformationException("FOSSBilling requires the proc_open PHP function to be enabled when using the sendmail transport");
}
break;
case 'smtp':
@@ -161,18 +161,18 @@ class Mail implements InjectionAwareInterface
break;
case 'sendgrid':
if (empty($options['sendgrid_key'])) {
- throw new \Box_Exception("A Sendgrid API key is required to send emails via Sendgrid");
+ throw new InformationException("A Sendgrid API key is required to send emails via Sendgrid");
}
$dsn = 'sendgrid://' . $options['sendgrid_key'] . '@default';
break;
case 'custom':
if (empty($this->dsn)) {
- throw new \Box_Exception("Unable to send email: 'Custom' transport method was selected without a custom DSN");
+ throw new InformationException("Unable to send email: 'Custom' transport method was selected without a custom DSN");
}
$dsn = $this->dsn;
break;
default:
- throw new \Box_Exception('Unknown mail transport: :transport', [':transport' => $this->transport]);
+ throw new InformationException('Unknown mail transport: :transport', [':transport' => $this->transport]);
}
try {
@@ -180,7 +180,7 @@ class Mail implements InjectionAwareInterface
$mailer = new Mailer($transport);
$mailer->send($this->email);
} catch (TransportExceptionInterface $e) {
- throw new \Box_Exception("Failed to send email via :transport with the exception :e", [':transport' => $this->transport, ':e' => $e]);
+ throw new Exception("Failed to send email via :transport with the exception :e", [':transport' => $this->transport, ':e' => $e]);
}
}
@@ -189,14 +189,14 @@ class Mail implements InjectionAwareInterface
*
* @param array $options An associative array of SMTP options including 'smtp_host', 'smtp_port', 'smtp_username', and 'smtp_password'.
*
- * @throws \Box_Exception if the SMTP host or port is not configured.
+ * @throws InformationException if the SMTP host or port is not configured.
*
* @return string A string representing the DSN for the SMTP transport.
*/
private function __smtpDsn(array $options): string
{
if (empty($options['smtp_host']) || empty($options['smtp_port'])) {
- throw new \Box_Exception('SMTP host or port is not configured');
+ throw new InformationException('SMTP host or port is not configured');
}
$host = urlencode(trim($options['smtp_host']));
diff --git a/src/library/FOSSBilling/SentryHelper.php b/src/library/FOSSBilling/SentryHelper.php
new file mode 100644
index 000000000..34303fdcd
--- /dev/null
+++ b/src/library/FOSSBilling/SentryHelper.php
@@ -0,0 +1,208 @@
+ function (Event $event, ?EventHint $hint): ?Event {
+ if ($hint) {
+ $errorInfo = ErrorPage::getCodeInfo($hint->exception->getCode());
+
+ if (!$errorInfo['report']) {
+ return null;
+ }
+
+ if ($hint->exception instanceof InformationException) {
+ return null;
+ }
+ }
+
+ return $event;
+ },
+
+ 'environment' => Environment::getCurrentEnvironment(),
+ 'release' => Version::VERSION,
+
+ // This option is disabled by default, but we set it to false here to be explicit & ensure it can never change unexpectedly.
+ 'send_default_pii' => false,
+
+ // Stack traces are always sent for Exceptions, but if debug mode is enabled we will send them for errors too.
+ 'attach_stacktrace' => (bool)BB_DEBUG,
+ ];
+
+ /**
+ * Here we validate that the DSN is correctly set and that error reporting is enabled before passing it off to the Sentry SDK.
+ * It may look a bit odd, but the DSN placeholder value here is split into two strings and concatenated so we can easily perform a `sed` replacement of the placeholder without it effecting this check
+ */
+ if ($config['debug_and_monitoring']['report_errors'] && $sentryDSN !== '--replace--this--' . 'during--release--process--' && !empty($sentryDSN)) {
+ // Per Sentry documentation, not setting this results in the SDK simply not sending any information.
+ $options['dsn'] = $sentryDSN;
+ }
+
+ $options['server_name'] = INSTANCE_ID;
+ \Sentry\init($options);
+ }
+
+ /**
+ * Captures an exception and sends it to Sentry, adding additional information that we'd find useful.
+ *
+ * @param \Exception|\Error $e
+ */
+ public static function captureException(\Exception|\Error $e)
+ {
+ \Sentry\withScope(function (Scope $scope) use ($e): void {
+ $errorInfo = ErrorPage::getCodeInfo($e->getCode());
+ $exceptionPath = $e->getFile();
+
+ // Tag the event with the exception's category.
+ $scope->setTag('exception.category', $errorInfo['category']);
+
+ // If we can, tag the event with the module or library that threw the exception.
+ if (str_starts_with($exceptionPath, PATH_MODS)) {
+ $strippedPath = str_replace(PATH_MODS, '', $exceptionPath);
+ $level = 0;
+ $module = 'Unknown';
+
+ while ($level <= 10) {
+ if (dirname($strippedPath, ($level + 1)) === DIRECTORY_SEPARATOR) {
+ $module = trim(dirname($strippedPath, $level), DIRECTORY_SEPARATOR);
+ break;
+ }
+ $level++;
+ }
+ $scope->setTag('module.name', $module);
+ } else if (str_starts_with($exceptionPath, PATH_LIBRARY)) {
+ $scope->setTag('library.class', pathinfo($exceptionPath, PATHINFO_FILENAME));
+ }
+
+ // Finally tag the event with what is probably the webserver in use, then send the event to Sentry.
+ self::estimateWebServer($scope);
+ \Sentry\captureException($e);
+ });
+ }
+
+ /**
+ * Accepts a PHP error's number and returns what type of error it is.
+ */
+ public static function getErrorType(int $number): string
+ {
+ switch ($number) {
+ case E_ERROR:
+ return 'Error';
+ break;
+ case E_WARNING:
+ return 'Warning';
+ break;
+ case E_PARSE:
+ return 'Parse error';
+ break;
+ case E_NOTICE:
+ return 'Runtime notice';
+ break;
+ case E_CORE_ERROR:
+ return 'Fatal PHP startup error';
+ break;
+ case E_CORE_WARNING:
+ return 'PHP startup warning';
+ break;
+ case E_COMPILE_ERROR:
+ return 'Zend compile error';
+ break;
+ case E_COMPILE_WARNING:
+ return 'Zend compile warning';
+ break;
+ case E_USER_ERROR:
+ return 'User-generated error';
+ break;
+ case E_USER_WARNING:
+ return 'User-generated warning';
+ break;
+ case E_USER_NOTICE:
+ return 'User-generated notice';
+ break;
+ case E_STRICT:
+ return 'PHP Strict code checking';
+ break;
+ case E_RECOVERABLE_ERROR:
+ return 'Recoverable error';
+ break;
+ case E_DEPRECATED:
+ return 'PHP deprecation warning';
+ break;
+ case E_USER_DEPRECATED:
+ return 'User-generated deprecation warning';
+ break;
+ default:
+ return 'Unknown error';
+ break;
+ }
+ }
+
+ /**
+ * Returns the appropriate Sentry severity level for a given error type.
+ */
+ public static function getSeverityLevel(string $type): Severity
+ {
+ if (stripos($type, 'fatal') !== false) {
+ return Severity::fatal();
+ }
+ // We check for deprecation before warning because the message for them also includes 'warning'
+ if (stripos($type, 'deprecation') !== false) {
+ return Severity::info();
+ }
+ if (stripos($type, 'warning') !== false) {
+ return Severity::warning();
+ }
+
+ // Default to error
+ return Severity::error();
+ }
+
+ /**
+ * Tries to guess what type of webserver is being used and tags the Sentry event with it.
+ */
+ private static function estimateWebServer(Scope $scope): void
+ {
+ $serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? '';
+ if (function_exists('apache_get_version') || (stripos(strtolower($serverSoftware), 'apache') !== false)) {
+ $scope->setTag('webserver.used', 'Apache');
+ } else if (stripos(strtolower($serverSoftware), 'litespeed') !== false) {
+ $scope->setTag('webserver.used', 'Litespeed');
+ } else if (stripos(strtolower($serverSoftware), 'nginx') !== false) {
+ $scope->setTag('webserver.used', 'NGINX');
+ }
+ }
+}
diff --git a/src/library/FOSSBilling/Session.php b/src/library/FOSSBilling/Session.php
index e4ca24969..1d2687e66 100644
--- a/src/library/FOSSBilling/Session.php
+++ b/src/library/FOSSBilling/Session.php
@@ -121,7 +121,7 @@ class Session implements \FOSSBilling\InjectionAwareInterface
$sessionID = $_COOKIE['PHPSESSID'];
$maxAge = time() - $this->di['config']['security']['session_lifespan'];
- $fingerprint = new \FOSSBilling\Fingerprint;
+ $fingerprint = new Fingerprint;
/** @var \RedBeanPHP\OODBBean $session */
$session = $this->di['db']->findOne('session', 'id = :id', [':id' => $sessionID]);
@@ -150,7 +150,7 @@ class Session implements \FOSSBilling\InjectionAwareInterface
// Fix for the installer which temporarily uses FS sessions before FOSSBilling is completely setup.
if (!is_null($session)) {
- $fingerprint = new \FOSSBilling\Fingerprint;
+ $fingerprint = new Fingerprint;
$session->fingerprint = json_encode($fingerprint->fingerprint());
$this->di['db']->store($session);
}
diff --git a/src/library/FOSSBilling/Tools.php b/src/library/FOSSBilling/Tools.php
index 5526e9159..b6c1c74e2 100644
--- a/src/library/FOSSBilling/Tools.php
+++ b/src/library/FOSSBilling/Tools.php
@@ -69,7 +69,7 @@ class Tools
$class = 'Box_Mod_' . ucfirst($type) . '_Service';
$file = PATH_MODS . '/mod_' . $type . '/Service.php';
if (!file_exists($file)) {
- throw new \Box_Exception('Service class :class was not found in :path', array(':class' => $class, ':path' => $file));
+ throw new Exception('Service class :class was not found in :path', array(':class' => $class, ':path' => $file));
}
require_once $file;
return new $class();
@@ -246,7 +246,7 @@ class Tools
$class = 'Model_' . ucfirst($type) . 'Table';
$file = PATH_LIBRARY . '/Model/' . $type . 'Table.php';
if (!file_exists($file)) {
- throw new \Box_Exception('Service class :class was not found in :path', array(':class' => $class, ':path' => $file));
+ throw new Exception('Service class :class was not found in :path', array(':class' => $class, ':path' => $file));
}
require_once $file;
return new $class();
@@ -277,7 +277,7 @@ class Tools
if (!filter_var(idn_to_ascii($email), FILTER_VALIDATE_EMAIL)) {
if ($throw) {
$friendlyName = ucfirst(__trans('Email address'));
- throw new \Box_Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]);
+ throw new Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]);
} else {
return false;
}
diff --git a/src/library/FOSSBilling/Update.php b/src/library/FOSSBilling/Update.php
index 2fbd4a252..83e328eed 100644
--- a/src/library/FOSSBilling/Update.php
+++ b/src/library/FOSSBilling/Update.php
@@ -82,7 +82,7 @@ class Update implements InjectionAwareInterface
* @param string $branch The branch to return the latest information for;
* valid values are: 'preview' or 'release'.
*
- * @throws \Box_Exception if there is an error downloading the latest
+ * @throws Exception if there is an error downloading the latest
* version information.
*
* @return array
@@ -113,7 +113,7 @@ class Update implements InjectionAwareInterface
$releaseInfo = $response->toArray();
} catch (TransportExceptionInterface | HttpExceptionInterface $e) {
error_log($e->getMessage());
- throw new \Box_Exception('Failed to download the latest version information. Further details are available in the error log.');
+ throw new Exception('Failed to download the latest version information. Further details are available in the error log.');
}
return [
@@ -172,9 +172,9 @@ class Update implements InjectionAwareInterface
/**
* Perform system update.
*
- * @throws \Box_Exception if latest version already installed.
- * @throws \Box_Exception if unable to download the update archive.
- * @throws \Box_Exception if unable to extract the update archive.
+ * @throws InformationException if latest version already installed.
+ * @throws Exception if unable to download the update archive.
+ * @throws Exception if unable to extract the update archive.
*
* @return void
*/
@@ -182,7 +182,7 @@ class Update implements InjectionAwareInterface
{
$updateBranch = $this->getUpdateBranch();
if ($updateBranch !== 'preview' && !$this->isUpdateAvailable()) {
- throw new \Box_Exception('You have latest version of FOSSBilling. You do not need to update.');
+ throw new InformationException('You have latest version of FOSSBilling. You do not need to update.');
}
error_log('Started FOSSBilling auto-update script');
@@ -204,7 +204,7 @@ class Update implements InjectionAwareInterface
fclose($fileHandler);
} catch (TransportExceptionInterface | HttpExceptionInterface $e) {
error_log($e->getMessage());
- throw new \Box_Exception('Failed to download the update archive. Further details are available in the error log.');
+ throw new Exception('Failed to download the update archive. Further details are available in the error log.');
}
// @TODO - Validate downloaded file hash.
@@ -217,7 +217,7 @@ class Update implements InjectionAwareInterface
$zip->close();
} catch (ZipException $e) {
error_log($e->getMessage());
- throw new \Box_Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.');
+ throw new Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.');
}
// Apply system patches and migrate configuration file.
@@ -235,7 +235,7 @@ class Update implements InjectionAwareInterface
$filesystem->mkdir(PATH_CACHE, 0777);
} catch (IOException $e) {
error_log($e->getMessage());
- throw new \Box_Exception("Unable to clear cache and/or remove install folder. Further details are available in the error log.");
+ throw new Exception("Unable to clear cache and/or remove install folder. Further details are available in the error log.");
}
// Log off the current user and destroy the session.
diff --git a/src/library/FOSSBilling/UpdatePatcher.php b/src/library/FOSSBilling/UpdatePatcher.php
index 699d7e650..e15e6bbb3 100644
--- a/src/library/FOSSBilling/UpdatePatcher.php
+++ b/src/library/FOSSBilling/UpdatePatcher.php
@@ -14,6 +14,7 @@ namespace FOSSBilling;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
+use Ramsey\Uuid\Uuid;
class UpdatePatcher implements InjectionAwareInterface
{
@@ -45,18 +46,17 @@ class UpdatePatcher implements InjectionAwareInterface
{
$filesystem = new Filesystem();
- $configPath = PATH_ROOT . '/config.php';
- $currentConfig = include $configPath;
+ $currentConfig = include PATH_CONFIG;
if (!is_array($currentConfig)) {
- throw new \Box_Exception('Unable to load existing configuration');
+ throw new Exception('Unable to load existing configuration');
}
// Create backup of current configuration.
try {
- $filesystem->copy($configPath, substr($configPath, 0, -4) . '.old.php');
+ $filesystem->copy(PATH_CONFIG, substr(PATH_CONFIG, 0, -4) . '.old.php');
} catch (FileNotFoundException | IOException) {
- throw new \Box_Exception('Unable to create backup of configuration file');
+ throw new Exception('Unable to create backup of configuration file');
}
$newConfig = $currentConfig;
@@ -80,9 +80,15 @@ class UpdatePatcher implements InjectionAwareInterface
$newConfig['api']['rate_limit_login'] ??= 20;
$newConfig['api']['CSRFPrevention'] ??= true;
$newConfig['api']['rate_limit_whitelist'] ??= [];
+ $newConfig['debug_and_monitoring']['debug'] ??= $newConfig['debug'] ?? false;
+ $newConfig['debug_and_monitoring']['log_stacktrace'] ??= $newConfig['log_stacktrace'] ?? true;
+ $newConfig['debug_and_monitoring']['stacktrace_length'] ??= $newConfig['stacktrace_length'] ?? 25;
+ $newConfig['debug_and_monitoring']['report_errors'] ??= false;
+ $newConfig['info']['instance_id'] ??= Uuid::uuid4()->toString();
+ $newConfig['info']['salt'] ??= $newConfig['salt'];
// Remove depreciated config keys/subkeys.
- $depreciatedConfigKeys = ['guzzle', 'locale', 'locale_date_format', 'locale_time_format', 'timezone', 'sef_urls'];
+ $depreciatedConfigKeys = ['guzzle', 'locale', 'locale_date_format', 'locale_time_format', 'timezone', 'sef_urls', 'salt'];
$depreciatedConfigSubkeys = [
'security' => 'cookie_lifespan'
];
@@ -96,9 +102,9 @@ class UpdatePatcher implements InjectionAwareInterface
// Write updated configuration file.
try {
- $filesystem->dumpFile($configPath, $output);
+ $filesystem->dumpFile(PATH_CONFIG, $output);
} catch (IOException) {
- throw new \Box_Exception('Error when writing updated configuration file.');
+ throw new Exception('Error when writing updated configuration file.');
}
}
@@ -156,8 +162,10 @@ class UpdatePatcher implements InjectionAwareInterface
$statement = $this->di['pdo']->prepare($sql);
try {
$statement->execute();
- } catch (\Box_Exception $e) {
+ } catch (\Exception $e) {
+ // Log the error and then throw a user-friendly exception to prevent further patches from being applied.
error_log($e->getMessage());
+ throw new Exception('There was an error while applying database patches. Please check the error log for information on the error, correct it, and then perform the backup patching method to complete the update.');
}
}
@@ -302,6 +310,6 @@ class UpdatePatcher implements InjectionAwareInterface
];
ksort($patches, SORT_NATURAL);
- return array_filter($patches, fn($key) => $key > $patchLevel, ARRAY_FILTER_USE_KEY);
+ return array_filter($patches, fn ($key) => $key > $patchLevel, ARRAY_FILTER_USE_KEY);
}
}
diff --git a/src/library/FOSSBilling/Validate.php b/src/library/FOSSBilling/Validate.php
index e7de3dcb0..de7100940 100644
--- a/src/library/FOSSBilling/Validate.php
+++ b/src/library/FOSSBilling/Validate.php
@@ -48,23 +48,23 @@ class Validate
public function isPasswordStrong($pwd) : bool
{
if( strlen($pwd) < 8 ) {
- throw new \Box_Exception("Minimum password length is 8 characters.");
+ throw new InformationException("Minimum password length is 8 characters.");
}
if( strlen($pwd) > 256 ) {
- throw new \Box_Exception("Maximum password length is 256 characters.");
+ throw new InformationException("Maximum password length is 256 characters.");
}
if( !preg_match("#[0-9]+#", $pwd) ) {
- throw new \Box_Exception("Password must include at least one number.");
+ throw new InformationException("Password must include at least one number.");
}
if( !preg_match("#[a-z]+#", $pwd) ) {
- throw new \Box_Exception("Password must include at least one lowercase letter.");
+ throw new InformationException("Password must include at least one lowercase letter.");
}
if( !preg_match("#[A-Z]+#", $pwd) ) {
- throw new \Box_Exception("Password must include at least one uppercase letter.");
+ throw new InformationException("Password must include at least one uppercase letter.");
}
/*
@@ -80,22 +80,23 @@ class Validate
* @param array $data - Array to search for keys
* @param array $variables - Array of variables for message placeholders (:placeholder)
* @param integer $code - Exception code
- * @throws \Box_Exception
+ *
+ * @throws InformationException
*/
public function checkRequiredParamsForArray(array $required, array $data, array $variables = NULL, $code = 0)
{
foreach ($required as $key => $msg) {
if(!isset($data[$key])){
- throw new \Box_Exception($msg, $variables, $code);
+ throw new InformationException($msg, $variables, $code);
}
if (is_string($data[$key]) && strlen(trim($data[$key])) === 0){
- throw new \Box_Exception($msg, $variables, $code);
+ throw new InformationException($msg, $variables, $code);
}
if (!is_numeric($data[$key]) && empty($data[$key])){
- throw new \Box_Exception($msg, $variables, $code);
+ throw new InformationException($msg, $variables, $code);
}
}
}
@@ -104,7 +105,7 @@ class Validate
{
if (strlen(trim($birthday)) > 0 && strtotime($birthday) === false) {
$friendlyName = ucfirst(__trans('Birthdate'));
- throw new \Box_Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]);
+ throw new Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]);
}
return true;
}
diff --git a/src/library/FOSSBilling/i18n.php b/src/library/FOSSBilling/i18n.php
index 6705dd68d..fad8c4339 100644
--- a/src/library/FOSSBilling/i18n.php
+++ b/src/library/FOSSBilling/i18n.php
@@ -126,13 +126,13 @@ class i18n
*
* @return bool To indicate if it was successful,
*
- * @throws \Box_Exception
+ * @throws InformationException
*/
public static function toggleLocale(string $locale): bool
{
$basePath = PATH_LANGS . DIRECTORY_SEPARATOR . $locale;
if (!is_dir($basePath)) {
- throw new \Box_Exception('Unable to enable / disable the locale as it is not present in the locale folder.');
+ throw new InformationException('Unable to enable / disable the locale as it is not present in the locale folder.');
}
$disablePath = $basePath . DIRECTORY_SEPARATOR . '.disabled';
diff --git a/src/library/Model/ProductDomainTable.php b/src/library/Model/ProductDomainTable.php
index 09e081752..a989bde44 100644
--- a/src/library/Model/ProductDomainTable.php
+++ b/src/library/Model/ProductDomainTable.php
@@ -214,7 +214,7 @@ class Model_ProductDomainTable extends Model_ProductTable
$tld = '';
if (!isset($config['action'])) {
- throw new \Box_Exception('Could not determine domain price. Domain action is missing', null, 498);
+ throw new \FOSSBilling\Exception('Could not determine domain price. Domain action is missing', null, 498);
}
if ($config['action'] == 'owndomain') {
@@ -231,7 +231,7 @@ class Model_ProductDomainTable extends Model_ProductTable
$tld = $rtable->findOneByTld($tld);
if (!$tld instanceof Model_Tld) {
- throw new \Box_Exception('Unknown TLD. Could not determine registration price');
+ throw new \FOSSBilling\Exception('Unknown TLD. Could not determine registration price');
}
if ($config['action'] == 'register') {
@@ -252,6 +252,6 @@ class Model_ProductDomainTable extends Model_ProductTable
public function rm(Model_Product $product)
{
- throw new \Box_Exception('Domain product can not be removed.');
+ throw new \FOSSBilling\Exception('Domain product can not be removed.');
}
}
diff --git a/src/library/Model/ProductTable.php b/src/library/Model/ProductTable.php
index ddefdc90f..9938ce8ae 100644
--- a/src/library/Model/ProductTable.php
+++ b/src/library/Model/ProductTable.php
@@ -58,7 +58,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface
'3Y' => 'tria'
};
} catch (\UnhandledMatchError) {
- throw new Box_Exception('Unknown period selected ' . $code);
+ throw new FOSSBilling\Exception('Unknown period selected ' . $code);
}
}
@@ -70,7 +70,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface
return $service->toProductPaymentApiArray($productPayment);
}
- throw new \Box_Exception('Product pricing could not be determined. ' . static::class);
+ throw new \FOSSBilling\Exception('Product pricing could not be determined. ' . static::class);
}
/**
@@ -102,7 +102,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface
return $price;
}
- throw new \Box_Exception('Unknown period selected for setup price');
+ throw new \FOSSBilling\Exception('Unknown period selected for setup price');
}
/**
@@ -126,7 +126,7 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface
if ($pp->type == Model_ProductPayment::RECURRENT) {
if (!isset($config['period'])) {
- throw new \Box_Exception('Product :id payment type is recurrent, but period was not selected', array(':id' => $product->id));
+ throw new \FOSSBilling\Exception('Product :id payment type is recurrent, but period was not selected', array(':id' => $product->id));
}
$period = new Box_Period($config['period']);
@@ -138,6 +138,6 @@ class Model_ProductTable implements \FOSSBilling\InjectionAwareInterface
return $price;
}
- throw new \Box_Exception('Unknown Period selected for price');
+ throw new \FOSSBilling\Exception('Unknown Period selected for price');
}
}
diff --git a/src/library/Payment/Adapter/PayPalEmail.php b/src/library/Payment/Adapter/PayPalEmail.php
index 1e0d7a828..a970df9b7 100644
--- a/src/library/Payment/Adapter/PayPalEmail.php
+++ b/src/library/Payment/Adapter/PayPalEmail.php
@@ -28,7 +28,7 @@ class Payment_Adapter_PayPalEmail extends Payment_AdapterAbstract implements \FO
public function __construct(private $config)
{
if (!isset($this->config['email'])) {
- throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'PayPal', ':missing' => 'PayPal Email address']);
+ throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'PayPal', ':missing' => 'PayPal Email address'], 4001);
}
}
diff --git a/src/library/Payment/Adapter/Stripe.php b/src/library/Payment/Adapter/Stripe.php
index af876fc3f..f8727ce5e 100644
--- a/src/library/Payment/Adapter/Stripe.php
+++ b/src/library/Payment/Adapter/Stripe.php
@@ -30,19 +30,19 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface
{
if ($this->config['test_mode']) {
if (!isset($this->config['test_api_key'])) {
- throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Test API Key']);
+ throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Test API Key'], 4001);
}
if (!isset($this->config['test_pub_key'])) {
- throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Test publishable key']);
+ throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Test publishable key'], 4001);
}
$this->stripe = new StripeClient($this->config['test_api_key']);
} else {
if (!isset($this->config['api_key'])) {
- throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'API key']);
+ throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'API key'], 4001);
}
if (!isset($this->config['pub_key'])) {
- throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Publishable key']);
+ throw new Payment_Exception('The ":pay_gateway" payment gateway is not fully configured. Please configure the :missing', [':pay_gateway' => 'Stripe', ':missing' => 'Publishable key'], 4001);
}
$this->stripe = new StripeClient($this->config['api_key']);
@@ -125,7 +125,7 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface
$tx->updated_at = date('Y-m-d H:i:s');
$this->di['db']->store($tx);
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
error_log(json_encode($e->getJsonBody()));
}
throw new Exception($tx->error);
@@ -180,7 +180,7 @@ class Payment_Adapter_Stripe implements \FOSSBilling\InjectionAwareInterface
}
} catch (\Stripe\Exception\CardException | \Stripe\Exception\InvalidRequestException | \Stripe\Exception\AuthenticationException | \Stripe\Exception\ApiConnectionException | \Stripe\Exception\ApiErrorException $e) {
$this->logError($e, $tx);
- throw new \Box_Exception("There was an error when processing the transaction");
+ throw new \FOSSBilling\Exception("There was an error when processing the transaction");
}
$paymentStatus = match ($charge->status) {
diff --git a/src/library/Payment/Exception.php b/src/library/Payment/Exception.php
index a864bd232..3b68f4381 100644
--- a/src/library/Payment/Exception.php
+++ b/src/library/Payment/Exception.php
@@ -8,10 +8,10 @@
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
*/
-class Payment_Exception extends Box_Exception
+class Payment_Exception extends FOSSBilling\Exception
{
/**
- * Creates a new translated exception, using the Box_Exception class.
+ * Creates a new translated exception, using the FOSSBilling\Exception class.
*
* @param string $message error message
* @param array|null $variables translation variables
diff --git a/src/library/Registrar/Adapter/Email.php b/src/library/Registrar/Adapter/Email.php
index 11b8a73ea..a357b1de6 100644
--- a/src/library/Registrar/Adapter/Email.php
+++ b/src/library/Registrar/Adapter/Email.php
@@ -20,7 +20,7 @@ class Registrar_Adapter_Email extends Registrar_AdapterAbstract
$this->config['email'] = $options['email'];
unset($options['email']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Email', ':missing' => 'email']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Email', ':missing' => 'email'], 3001);
}
if(isset($options['use_whois'])) {
diff --git a/src/library/Registrar/Adapter/Internetbs.php b/src/library/Registrar/Adapter/Internetbs.php
index 3290d12e8..36dd6be40 100644
--- a/src/library/Registrar/Adapter/Internetbs.php
+++ b/src/library/Registrar/Adapter/Internetbs.php
@@ -15,14 +15,14 @@ class Registrar_Adapter_Internetbs extends Registrar_AdapterAbstract
$this->config['apikey'] = $options['apikey'];
unset($options['apikey']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Internetbs', ':missing' => 'Internetbs API key']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Internetbs', ':missing' => 'Internetbs API key'], 3001);
}
if(isset($options['password']) && !empty($options['password'])) {
$this->config['password'] = $options['password'];
unset($options['password']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Internetbs', ':missing' => 'Internetbs API password']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Internetbs', ':missing' => 'Internetbs API password'], 3001);
}
}
diff --git a/src/library/Registrar/Adapter/Namecheap.php b/src/library/Registrar/Adapter/Namecheap.php
index 9abb5f228..a2776e7e9 100644
--- a/src/library/Registrar/Adapter/Namecheap.php
+++ b/src/library/Registrar/Adapter/Namecheap.php
@@ -26,13 +26,13 @@ class Registrar_Adapter_Namecheap extends Registrar_AdapterAbstract
if (!empty($options['api-key'])) {
$this->config['api-key'] = $options['api-key'];
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'API Key']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'API Key'], 3001);
}
if (!empty($options['username'])) {
$this->config['username'] = $options['username'];
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'Username']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'Username'], 3001);
}
if (empty($options['api-user-id'])) {
@@ -44,7 +44,7 @@ class Registrar_Adapter_Namecheap extends Registrar_AdapterAbstract
if (!empty($options['ip'])) {
$this->config['ip'] = $options['ip'];
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'server IP address']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Namecheap', ':missing' => 'server IP address'], 3001);
}
}
diff --git a/src/library/Registrar/Adapter/Netearthone.php b/src/library/Registrar/Adapter/Netearthone.php
index cb6a1836d..403ff9905 100644
--- a/src/library/Registrar/Adapter/Netearthone.php
+++ b/src/library/Registrar/Adapter/Netearthone.php
@@ -8,14 +8,14 @@ class Registrar_Adapter_Netearthone extends Registrar_Adapter_Resellerclub
$this->config['userid'] = $options['userid'];
unset($options['userid']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'NetEarthOne', ':missing' => 'NetEarthOne Reseller ID']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'NetEarthOne', ':missing' => 'NetEarthOne Reseller ID'], 3001);
}
if(isset($options['api-key']) && !empty($options['api-key'])) {
$this->config['api-key'] = $options['api-key'];
unset($options['api-key']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'NetEarthOne', ':missing' => 'NetEarthOne API Key']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'NetEarthOne', ':missing' => 'NetEarthOne API Key'], 3001);
}
}
diff --git a/src/library/Registrar/Adapter/Resellbiz.php b/src/library/Registrar/Adapter/Resellbiz.php
index d56110f11..22afa4287 100644
--- a/src/library/Registrar/Adapter/Resellbiz.php
+++ b/src/library/Registrar/Adapter/Resellbiz.php
@@ -8,14 +8,14 @@ class Registrar_Adapter_Resellbiz extends Registrar_Adapter_Resellerclub
$this->config['userid'] = $options['userid'];
unset($options['userid']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Resell.biz', ':missing' => 'Resell.biz Reseller ID']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Resell.biz', ':missing' => 'Resell.biz Reseller ID'], 3001);
}
if(isset($options['api-key']) && !empty($options['api-key'])) {
$this->config['api-key'] = $options['api-key'];
unset($options['api-key']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Resell.biz', ':missing' => 'Resell.biz API Key']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'Resell.biz', ':missing' => 'Resell.biz API Key'], 3001);
}
}
diff --git a/src/library/Registrar/Adapter/Resellerclub.php b/src/library/Registrar/Adapter/Resellerclub.php
index d04c1c12c..05cb5c350 100644
--- a/src/library/Registrar/Adapter/Resellerclub.php
+++ b/src/library/Registrar/Adapter/Resellerclub.php
@@ -37,14 +37,14 @@ class Registrar_Adapter_Resellerclub extends Registrar_AdapterAbstract
$this->config['userid'] = $options['userid'];
unset($options['userid']);
} else {
- throw new Registrar_Exception('Domain registrar "ResellerClub" is not configured properly. Please update configuration parameter "ResellerClub Reseller ID" at "Configuration -> Domain registration".');
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerClub', ':missing' => 'ResellerClub Reseller ID'], 3001);
}
if(isset($options['api-key']) && !empty($options['api-key'])) {
$this->config['api-key'] = $options['api-key'];
unset($options['api-key']);
} else {
- throw new Registrar_Exception('Domain registrar "ResellerClub" is not configured properly. Please update configuration parameter "ResellerClub API Key" at "Configuration -> Domain registration".');
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerClub', ':missing' => 'ResellerClub API Key'], 3001);
}
}
diff --git a/src/library/Registrar/Adapter/Resellerid.php b/src/library/Registrar/Adapter/Resellerid.php
index 52209f9ae..d7e17a14f 100644
--- a/src/library/Registrar/Adapter/Resellerid.php
+++ b/src/library/Registrar/Adapter/Resellerid.php
@@ -8,14 +8,14 @@ class Registrar_Adapter_Resellerid extends Registrar_Adapter_Resellerclub
$this->config['userid'] = $options['userid'];
unset($options['userid']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerID', ':missing' => 'ResellerID Reseller ID']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerID', ':missing' => 'ResellerID Reseller ID'], 3001);
}
if(isset($options['api-key']) && !empty($options['api-key'])) {
$this->config['api-key'] = $options['api-key'];
unset($options['api-key']);
} else {
- throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerID', ':missing' => 'ResellerID API Key']);
+ throw new Registrar_Exception('The ":domain_registrar" domain registrar is not fully configured. Please configure the :missing', [':domain_registrar' => 'ResellerID', ':missing' => 'ResellerID API Key'], 3001);
}
}
diff --git a/src/library/Registrar/Exception.php b/src/library/Registrar/Exception.php
index 472ed33d5..c703d8f19 100644
--- a/src/library/Registrar/Exception.php
+++ b/src/library/Registrar/Exception.php
@@ -8,10 +8,10 @@
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
*/
-class Registrar_Exception extends Box_Exception
+class Registrar_Exception extends FOSSBilling\Exception
{
/**
- * Creates a new translated exception, using the Box_Exception class.
+ * Creates a new translated exception, using the FOSSBilling\Exception class.
*
* @param string $message error message
* @param array|null $variables translation variables
diff --git a/src/library/Server/Exception.php b/src/library/Server/Exception.php
index e26a99ee7..9de04be75 100644
--- a/src/library/Server/Exception.php
+++ b/src/library/Server/Exception.php
@@ -8,10 +8,10 @@
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
*/
-class Server_Exception extends Box_Exception
+class Server_Exception extends FOSSBilling\Exception
{
/**
- * Creates a new translated exception, using the Box_Exception class.
+ * Creates a new translated exception, using the FOSSBilling\Exception class.
*
* @param string $message error message
* @param array|null $variables translation variables
diff --git a/src/library/Server/Manager/CWP.php b/src/library/Server/Manager/CWP.php
index a16b00c2d..e0c797854 100644
--- a/src/library/Server/Manager/CWP.php
+++ b/src/library/Server/Manager/CWP.php
@@ -17,15 +17,15 @@ class Server_Manager_CWP extends Server_Manager
public function init()
{
if (empty($this->_config['ip'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'IP address']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'IP address'], 2001);
}
if (empty($this->_config['host'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'Hostname']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'Hostname'], 2001);
}
if (empty($this->_config['accesshash'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'API Key / Access Hash']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'CWP', ':missing' => 'API Key / Access Hash'], 2001);
} else {
$this->_config['accesshash'] = trim($this->_config['accesshash']);
}
diff --git a/src/library/Server/Manager/Directadmin.php b/src/library/Server/Manager/Directadmin.php
index 64d961625..614cf4bba 100644
--- a/src/library/Server/Manager/Directadmin.php
+++ b/src/library/Server/Manager/Directadmin.php
@@ -13,15 +13,15 @@ class Server_Manager_Directadmin extends Server_Manager
public function init()
{
if(empty($this->_config['host'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'hostname']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'hostname'], 2001);
}
if(empty($this->_config['username'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'username']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'username'], 2001);
}
if(empty($this->_config['password'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'password']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'DirectAdmin', ':missing' => 'password'], 2001);
}
}
diff --git a/src/library/Server/Manager/Whm.php b/src/library/Server/Manager/Whm.php
index e0940a540..1f1e78dc2 100644
--- a/src/library/Server/Manager/Whm.php
+++ b/src/library/Server/Manager/Whm.php
@@ -19,15 +19,15 @@ class Server_Manager_Whm extends Server_Manager
public function init()
{
if(empty($this->_config['host'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'hostname']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'hostname'], 2001);
}
if(empty($this->_config['username'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'username']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'username'], 2001);
}
if(empty($this->_config['password']) && empty($this->_config['accesshash'])) {
- throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'authentication credentials']);
+ throw new Server_Exception('The ":server_manager" server manager is not fully configured. Please configure the :missing', [':server_manager' => 'cPanel WHM', ':missing' => 'authentication credentials'], 2001);
}
// If port not set, use WHM default.
diff --git a/src/load.php b/src/load.php
index 51bafc1c5..69d891e84 100644
--- a/src/load.php
+++ b/src/load.php
@@ -1,4 +1,5 @@
exists(PATH_CONFIG) && $filesystem->exists('install/install.php') && Environment::isProduction()) {
// Throw exception only if debug mode is NOT enabled.
$config = require PATH_CONFIG;
- if (!$config['debug']) {
+ if (!$config['debug_and_monitoring']['debug']) {
throw new Exception('For security reasons, you have to delete the install directory before you can use FOSSBilling.', 2);
}
}
@@ -135,10 +136,24 @@ function checkWebServer()
*/
function errorHandler(int $number, string $message, string $file, int $line)
{
+ // Just some housekeeping to ensure a few things we rely on are loaded.
+ if (!class_exists('\FOSSBilling\ErrorPage')) {
+ require_once PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR . 'ErrorPage.php';
+ }
+
+ if (!class_exists('\FOSSBilling\SentryHelper')) {
+ require_once PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR . 'SentryHelper.php';
+ }
+
+ // Now we can handle the error appropriately.
if ($number === E_RECOVERABLE_ERROR) {
exceptionHandler(new ErrorException($message, $number, 0, $file, $line));
} else {
- error_log($number . ' ' . $message . ' ' . $file . ' ' . $line);
+ $errorType = FOSSBilling\SentryHelper::getErrorType($number);
+ $completedMessage = ($errorType . " ($number): " . $message . ' in ' . $file . ' on line ' . $line);
+
+ \Sentry\captureMessage($completedMessage, FOSSBilling\SentryHelper::getSeverityLevel($errorType));
+ error_log($completedMessage);
}
return false;
@@ -149,13 +164,17 @@ function errorHandler(int $number, string $message, string $file, int $line)
*/
function exceptionHandler($e)
{
- $message = htmlspecialchars($e->getMessage());
- if (getenv('APP_ENV') === 'test') {
- echo $message . PHP_EOL;
+ // Let Sentry capture the exception and then send it
+ \FOSSBilling\SentryHelper::captureException($e);
+ if (getenv('APP_ENV') === 'test') {
+ echo $e->getMessage() . PHP_EOL;
return;
+ } else {
+ error_log($e->getMessage());
}
- error_log($message);
+
+ $message = htmlspecialchars($e->getMessage());
if (defined('BB_MODE_API')) {
$code = $e->getCode() ?: 9998;
@@ -175,7 +194,8 @@ function exceptionHandler($e)
$prettyPage->setPageTitle('An error ocurred');
$prettyPage->addDataTable('FOSSBilling environment', [
'PHP Version' => PHP_VERSION,
- 'Error code' => $e->getCode(),
+ 'Error code' => $e->getCode(),
+ 'Instance ID' => INSTANCE_ID ?? 'Unknown',
]);
$whoops->pushHandler($prettyPage);
$whoops->allowQuit(false);
@@ -183,7 +203,6 @@ function exceptionHandler($e)
echo $whoops->handleException($e);
} else {
- include PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR . 'ErrorPage.php';
$errorPage = new \FOSSBilling\ErrorPage();
$errorPage->generatePage($e->getCode(), $message);
}
@@ -223,19 +242,27 @@ $config = require PATH_CONFIG;
// Config loaded - set globals and relevant settings.
date_default_timezone_set($config['i18n']['timezone'] ?? 'UTC');
-define('BB_DEBUG', $config['debug']);
+define('BB_DEBUG', (bool)$config['debug_and_monitoring']['debug']);
define('BB_URL', $config['url']);
define('PATH_CACHE', $config['path_data'] . DIRECTORY_SEPARATOR . 'cache');
define('PATH_LOG', $config['path_data'] . DIRECTORY_SEPARATOR . 'log');
define('BB_SSL', str_starts_with($config['url'], 'https'));
define('ADMIN_PREFIX', $config['admin_area_prefix']);
define('BB_URL_API', $config['url'] . 'api/');
+if(!empty($config['info']['instance_id'])){
+ define('INSTANCE_ID', $config['info']['instance_id']);
+} else {
+ define('INSTANCE_ID', 'Unknown');
+}
// Initial setup and checks passed, now we setup our custom autoloader.
include PATH_LIBRARY . DIRECTORY_SEPARATOR . 'FOSSBilling' . DIRECTORY_SEPARATOR . 'Autoloader.php';
$loader = new FOSSBilling\AutoLoader();
$loader->register();
+// Now that the config file is loaded, we can enable Sentry
+\FOSSBilling\SentryHelper::registerSentry($config);
+
// Verify the installer was removed.
checkInstaller();
@@ -246,12 +273,14 @@ checkSSL();
ini_set('log_errors', '1');
ini_set('html_errors', false);
ini_set('error_log', PATH_LOG . DIRECTORY_SEPARATOR . 'php_error.log');
-if ($config['debug']) {
- error_reporting(E_ALL);
+
+// We disable PHP's error reporting as our own error handler will log it and send it to Sentry.
+error_reporting(0);
+
+if (BB_DEBUG) {
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
} else {
- error_reporting(E_RECOVERABLE_ERROR);
ini_set('display_errors', '0');
ini_set('display_startup_errors', '0');
}
diff --git a/src/modules/Api/Controller/Client.php b/src/modules/Api/Controller/Client.php
index 1b8f16e06..2c178b769 100644
--- a/src/modules/Api/Controller/Client.php
+++ b/src/modules/Api/Controller/Client.php
@@ -45,7 +45,7 @@ class Client implements InjectionAwareInterface
public function show_error(\Box_App $app, $page)
{
- $exc = new \Box_Exception('Unknown API call :call', [':call' => $page], 879);
+ $exc = new \FOSSBilling\Exception('Unknown API call :call', [':call' => $page], 879);
return $this->renderJson(null, $exc);
}
@@ -80,6 +80,8 @@ class Client implements InjectionAwareInterface
try {
$this->_apiCall($role, $call, $p);
} catch (\Exception $exc) {
+ // Let Sentry capture the exception and then send it
+ \FOSSBilling\SentryHelper::captureException($exc);
$this->renderJson(null, $exc);
}
}
@@ -125,7 +127,7 @@ class Client implements InjectionAwareInterface
$url = strtolower(BB_URL);
$referer = isset($_SERVER['HTTP_REFERER']) ? strtolower($_SERVER['HTTP_REFERER']) : null;
if (!$referer || !str_starts_with($referer, $url)) {
- throw new \Box_Exception('Invalid request. Make sure request origin is :from', [':from' => BB_URL], 1004);
+ throw new \FOSSBilling\Exception('Invalid request. Make sure request origin is :from', [':from' => BB_URL], 1004);
}
}
@@ -136,7 +138,7 @@ class Client implements InjectionAwareInterface
{
$ips = $this->_api_config['allowed_ips'];
if (!empty($ips) && !in_array($this->_getIp(), $ips)) {
- throw new \Box_Exception('Unauthorized IP', null, 1002);
+ throw new \FOSSBilling\Exception('Unauthorized IP', null, 1002);
}
return true;
@@ -190,15 +192,15 @@ class Client implements InjectionAwareInterface
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
- throw new \Box_Exception('Authentication Failed', null, 201);
+ throw new \FOSSBilling\Exception('Authentication Failed', null, 201);
}
if (!isset($_SERVER['PHP_AUTH_PW'])) {
- throw new \Box_Exception('Authentication Failed', null, 202);
+ throw new \FOSSBilling\Exception('Authentication Failed', null, 202);
}
if (empty($_SERVER['PHP_AUTH_PW'])) {
- throw new \Box_Exception('Authentication Failed', null, 206);
+ throw new \FOSSBilling\Exception('Authentication Failed', null, 206);
}
return [$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']];
@@ -212,7 +214,7 @@ class Client implements InjectionAwareInterface
case 'client':
$model = $this->di['db']->findOne('Client', 'api_token = ?', [$password]);
if (!$model instanceof \Model_Client) {
- throw new \Box_Exception('Authentication Failed', null, 204);
+ throw new \FOSSBilling\Exception('Authentication Failed', null, 204);
}
$this->di['session']->set('client_id', $model->id);
@@ -221,7 +223,7 @@ class Client implements InjectionAwareInterface
case 'admin':
$model = $this->di['db']->findOne('Admin', 'api_token = ?', [$password]);
if (!$model instanceof \Model_Admin) {
- throw new \Box_Exception('Authentication Failed', null, 205);
+ throw new \FOSSBilling\Exception('Authentication Failed', null, 205);
}
$sessionAdminArray = [
'id' => $model->id,
@@ -235,20 +237,20 @@ class Client implements InjectionAwareInterface
case 'guest': // do not allow at the moment
default:
- throw new \Box_Exception('Authentication Failed', null, 203);
+ throw new \FOSSBilling\Exception('Authentication Failed', null, 203);
}
}
/**
* @param string $role
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
private function isRoleAllowed($role)
{
$allowed = ['guest', 'client', 'admin'];
if (!in_array($role, $allowed)) {
- new \Box_Exception('Unknown API call :call', [':call' => ''], 701);
+ new \FOSSBilling\Exception('Unknown API call :call', [':call' => ''], 701);
}
return true;
@@ -296,7 +298,7 @@ class Client implements InjectionAwareInterface
/**
* Checks if the CSRF token provided is valid.
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function _checkCSRFToken()
{
@@ -327,7 +329,7 @@ class Client implements InjectionAwareInterface
}
if (!is_null($expectedToken) && $expectedToken !== $token) {
- throw new \Box_Exception('CSRF token invalid', null, 403);
+ throw new \FOSSBilling\Exception('CSRF token invalid', null, 403);
}
}
}
diff --git a/src/modules/Cart/Api/Guest.php b/src/modules/Cart/Api/Guest.php
index af0936c13..8b0f929df 100644
--- a/src/modules/Cart/Api/Guest.php
+++ b/src/modules/Cart/Api/Guest.php
@@ -54,7 +54,7 @@ class Guest extends \Api_Abstract
$currencyService = $this->di['mod_service']('currency');
$currency = $currencyService->getByCode($data['currency']);
if (!$currency instanceof \Model_Currency) {
- throw new \Box_Exception('Currency not found');
+ throw new \FOSSBilling\Exception('Currency not found');
}
$cart = $this->getService()->getSessionCart();
@@ -93,15 +93,15 @@ class Guest extends \Api_Abstract
$promo = $this->getService()->findActivePromoByCode($data['promocode']);
if (!$promo instanceof \Model_Promo) {
- throw new \Box_Exception('Promo code is expired or does not exist');
+ throw new \FOSSBilling\InformationException('Promo code is expired or does not exist');
}
if (!$this->getService()->isPromoAvailableForClientGroup($promo)) {
- throw new \Box_Exception('Promo can not be applied to your account');
+ throw new \FOSSBilling\InformationException('Promo can not be applied to your account');
}
if (!$this->getService()->promoCanBeApplied($promo)) {
- throw new \Box_Exception('Promo code is expired or does not exist');
+ throw new \FOSSBilling\InformationException('Promo code is expired or does not exist');
}
$cart = $this->getService()->getSessionCart();
@@ -158,7 +158,7 @@ class Guest extends \Api_Abstract
$product = $this->di['db']->getExistingModelById('Product', $data['id'], 'Product not found');
if ($product->is_addon) {
- throw new \Box_Exception('Addon products cannot be added separately.');
+ throw new \FOSSBilling\InformationException('Addon products cannot be added separately.');
}
if (is_array($data['addons'] ?? '')) {
@@ -172,7 +172,7 @@ class Guest extends \Api_Abstract
$addonModel = $this->di['db']->getExistingModelById('Product', $addon, 'Addon not found');
if ($addonModel->status !== 'enabled' || !in_array($addon, $validAddons)) {
- throw new \Box_Exception('One or more of your selected addons are invalid for the associated product.');
+ throw new \FOSSBilling\InformationException('One or more of your selected addons are invalid for the associated product.');
}
}
}
diff --git a/src/modules/Cart/Service.php b/src/modules/Cart/Service.php
index b1dd64361..5cc107deb 100644
--- a/src/modules/Cart/Service.php
+++ b/src/modules/Cart/Service.php
@@ -81,14 +81,14 @@ class Service implements InjectionAwareInterface
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if (!$this->isPeriodEnabledForProduct($product, $data['period'])) {
- throw new \Box_Exception('Selected billing period is invalid');
+ throw new \FOSSBilling\InformationException('Selected billing period is invalid');
}
}
$qty = $data['quantity'] ?? 1;
// check stock
if (!$this->isStockAvailable($product, $qty)) {
- throw new \Box_Exception('This item is currently out of stock');
+ throw new \FOSSBilling\InformationException('This item is currently out of stock');
}
$addons = $data['addons'] ?? [];
@@ -121,7 +121,7 @@ class Service implements InjectionAwareInterface
$this->di['validator']->checkRequiredParamsForArray($required, $ac);
if (!$this->isPeriodEnabledForProduct($addon, $ac['period'])) {
- throw new \Box_Exception('Selected billing period is invalid for the selected addon');
+ throw new \FOSSBilling\InformationException('Selected billing period is invalid for the selected addon');
}
}
$ac['parent_id'] = $product->id;
@@ -215,7 +215,7 @@ class Service implements InjectionAwareInterface
$cartProduct = $this->di['db']->findOne('CartProduct', 'id = :id AND cart_id = :cart_id', $bindings);
if (!$cartProduct instanceof \Model_CartProduct) {
- throw new \Box_Exception('Product not found');
+ throw new \FOSSBilling\Exception('Product not found');
}
if ($removeAddons) {
@@ -277,7 +277,7 @@ class Service implements InjectionAwareInterface
}
if ($this->isEmptyCart($cart)) {
- throw new \Box_Exception('Add products to cart before applying promo code');
+ throw new \FOSSBilling\InformationException('Add products to cart before applying promo code');
}
$cart->promo_id = $promo->id;
@@ -422,15 +422,15 @@ class Service implements InjectionAwareInterface
if ($cart->promo_id) {
$promo = $this->di['db']->getExistingModelById('Promo', $cart->promo_id, 'Promo not found');
if (!$this->isClientAbleToUsePromo($client, $promo)) {
- throw new \Box_Exception('You have already used this promo code. Please remove promo code and checkout again.', null, 9874);
+ throw new \FOSSBilling\InformationException('You have already used this promo code. Please remove promo code and checkout again.', null, 9874);
}
if (!$promo instanceof \Model_Promo) {
- throw new \Box_Exception('Promo code is expired or does not exist');
+ throw new \FOSSBilling\InformationException('Promo code is expired or does not exist');
}
if (!$this->isPromoAvailableForClientGroup($promo)) {
- throw new \Box_Exception('Promo can not be applied to your account');
+ throw new \FOSSBilling\InformationException('Promo can not be applied to your account');
}
}
@@ -482,7 +482,7 @@ class Service implements InjectionAwareInterface
$cart = $this->getSessionCart();
$ca = $this->toApiArray($cart);
if ((is_countable($ca['items']) ? count($ca['items']) : 0) == 0) {
- throw new \Box_Exception('Can not checkout an empty cart');
+ throw new \FOSSBilling\InformationException('Can not checkout an empty cart');
}
$currency = $this->di['db']->getExistingModelById('Currency', $cart->currency_id, 'Currency not found.');
@@ -494,7 +494,7 @@ class Service implements InjectionAwareInterface
}
if ($client->currency != $currency->code) {
- throw new \Box_Exception('Selected currency :selected does not match your profile currency :code. Please change cart currency to continue.', [':selected' => $currency->code, ':code' => $client->currency]);
+ throw new \FOSSBilling\InformationException('Selected currency :selected does not match your profile currency :code. Please change cart currency to continue.', [':selected' => $currency->code, ':code' => $client->currency]);
}
$clientService = $this->di['mod_service']('client');
@@ -510,7 +510,7 @@ class Service implements InjectionAwareInterface
$product = $this->di['db']->getExistingModelById('Product', $item['product_id']);
if (is_null($product) || $product->status !== 'enabled') {
- throw new \Box_Exception('Unable to complete order. One or more of the selected products are invalid.');
+ throw new \FOSSBilling\InformationException('Unable to complete order. One or more of the selected products are invalid.');
}
/*
diff --git a/src/modules/Client/Api/Admin.php b/src/modules/Client/Api/Admin.php
index 8e720fb93..4d08a0bb7 100644
--- a/src/modules/Client/Api/Admin.php
+++ b/src/modules/Client/Api/Admin.php
@@ -146,7 +146,7 @@ class Admin extends \Api_Abstract
$service = $this->getService();
if ($service->emailAlreadyRegistered($data['email'])) {
- throw new \Box_Exception('Email is already registered.');
+ throw new \FOSSBilling\InformationException('Email is already registered.');
}
$validator->isPasswordStrong($data['password']);
@@ -236,7 +236,7 @@ class Admin extends \Api_Abstract
$email = $data['email'];
$email = $this->di['tools']->validateAndSanitizeEmail($email);
if ($service->emailAlreadyRegistered($email, $client)) {
- throw new \Box_Exception('Can not change email. It is already registered.');
+ throw new \FOSSBilling\InformationException('Can not change email. It is already registered.');
}
}
@@ -320,7 +320,7 @@ class Admin extends \Api_Abstract
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if ($data['password'] != $data['password_confirm']) {
- throw new \Box_Exception('Passwords do not match');
+ throw new \FOSSBilling\InformationException('Passwords do not match');
}
$this->di['validator']->isPasswordStrong($data['password']);
@@ -480,7 +480,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->getExistingModelById('ActivityClientHistory', $data['id']);
if (!$model instanceof \Model_ActivityClientHistory) {
- throw new \Box_Exception('Event not found');
+ throw new \FOSSBilling\Exception('Event not found');
}
$this->di['db']->trash($model);
@@ -564,7 +564,7 @@ class Admin extends \Api_Abstract
$clients = $this->di['db']->find('Client', 'client_group_id = :group_id', [':group_id' => $data['id']]);
if ((is_countable($clients) ? count($clients) : 0) > 0) {
- throw new \Box_Exception('Group has clients assigned. Please reassign them first.');
+ throw new \FOSSBilling\InformationException('Group has clients assigned. Please reassign them first.');
}
return $this->getService()->deleteGroup($model);
diff --git a/src/modules/Client/Api/Guest.php b/src/modules/Client/Api/Guest.php
index ebd3dddd2..f34585298 100644
--- a/src/modules/Client/Api/Guest.php
+++ b/src/modules/Client/Api/Guest.php
@@ -56,7 +56,7 @@ class Guest extends \Api_Abstract
$config = $this->di['mod_config']('client');
if (isset($config['disable_signup']) && $config['disable_signup']) {
- throw new \Box_Exception('New registrations are temporary disabled');
+ throw new \FOSSBilling\InformationException('New registrations are temporary disabled');
}
$required = [
@@ -68,7 +68,7 @@ class Guest extends \Api_Abstract
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if ($data['password'] != $data['password_confirm']) {
- throw new \Box_Exception('Passwords do not match.');
+ throw new \FOSSBilling\InformationException('Passwords do not match.');
}
$this->getService()->checkExtraRequiredFields($data);
@@ -81,7 +81,7 @@ class Guest extends \Api_Abstract
$email = $this->di['tools']->validateAndSanitizeEmail($email);
$email = strtolower(trim($email));
if ($service->clientAlreadyExists($email)) {
- throw new \Box_Exception('Email is already registered. You may want to login instead of registering.');
+ throw new \FOSSBilling\InformationException('Email is already registered. You may want to login instead of registering.');
}
$client = $service->guestCreateClient($data);
@@ -106,7 +106,7 @@ class Guest extends \Api_Abstract
*
* @return array - session data
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\InformationException
*/
public function login($data)
{
@@ -127,7 +127,7 @@ class Guest extends \Api_Abstract
if (!$client instanceof \Model_Client) {
$this->di['events_manager']->fire(['event' => 'onEventClientLoginFailed', 'params' => $event_params]);
- throw new \Box_Exception('Please check your login details.', [], 401);
+ throw new \FOSSBilling\InformationException('Please check your login details.', [], 401);
}
$this->di['events_manager']->fire(['event' => 'onAfterClientLogin', 'params' => ['id' => $client->id, 'ip' => $this->ip]]);
@@ -151,7 +151,7 @@ class Guest extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function reset_password($data)
{
@@ -225,16 +225,16 @@ class Guest extends \Api_Abstract
$validator->checkRequiredParamsForArray($required, $data);
if ($data['password'] != $data['password_confirm']) {
- throw new \Box_Exception('Passwords do not match');
+ throw new \FOSSBilling\InformationException('Passwords do not match');
}
$reset = $this->di['db']->findOne('ClientPasswordReset', 'hash = ?', [$data['hash']]);
if (!$reset instanceof \Model_ClientPasswordReset) {
- throw new \Box_Exception('The link has expired or you have already reset your password.');
+ throw new \FOSSBilling\InformationException('The link has expired or you have already reset your password.');
}
if (strtotime($reset->created_at) - time() + 900 < 0) {
- throw new \Box_Exception('The link has expired or you have already reset your password.');
+ throw new \FOSSBilling\InformationException('The link has expired or you have already reset your password.');
}
$c = $this->di['db']->getExistingModelById('Client', $reset->client_id, 'Client not found');
diff --git a/src/modules/Client/Service.php b/src/modules/Client/Service.php
index be5d7e114..740af3583 100644
--- a/src/modules/Client/Service.php
+++ b/src/modules/Client/Service.php
@@ -32,7 +32,7 @@ class Service implements InjectionAwareInterface
$db = $this->di['db'];
$result = $db->getRow('SELECT id, client_id FROM extension_meta WHERE extension = "mod_client" AND meta_key = "confirm_email" AND meta_value = :hash', [':hash' => $hash]);
if (!$result) {
- throw new \Box_Exception('Invalid email confirmation link');
+ throw new \FOSSBilling\InformationException('Invalid email confirmation link');
}
$db->exec('UPDATE client SET email_approved = 1 WHERE id = :id', ['id' => $result['client_id']]);
$db->exec('DELETE FROM extension_meta WHERE id = :id', ['id' => $result['id']]);
@@ -180,7 +180,7 @@ class Service implements InjectionAwareInterface
{
$limit = $data['per_page'] ?? 30;
if (!is_numeric($limit) || $limit < 1) {
- throw new \Box_Exception('Invalid per page number');
+ throw new \FOSSBilling\InformationException('Invalid per page number');
}
[$sql, $params] = $this->getSearchQuery($data, "SELECT c.id, CONCAT(c.company, ': (', c.first_name, ' ', c.last_name, ')') as client");
@@ -222,12 +222,12 @@ class Service implements InjectionAwareInterface
$invoice = $this->di['db']->findOne('Invoice', 'client_id = :client_id', [':client_id' => $model->id]);
if ($invoice instanceof \Model_Invoice) {
- throw new \Box_Exception('Currency can not be changed. Client already have invoices issued.');
+ throw new \FOSSBilling\InformationException('Currency can not be changed. Client already have invoices issued.');
}
$order = $this->di['db']->findOne('ClientOrder', 'client_id = :client_id', [':client_id' => $model->id]);
if ($order instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Currency can not be changed. Client already have orders.');
+ throw new \FOSSBilling\InformationException('Currency can not be changed. Client already have orders.');
}
return true;
@@ -236,15 +236,15 @@ class Service implements InjectionAwareInterface
public function addFunds(\Model_Client $client, $amount, $description, array $data = [])
{
if (!$client->currency) {
- throw new \Box_Exception('Define clients currency before adding funds.');
+ throw new \FOSSBilling\InformationException('Define clients currency before adding funds.');
}
if (!is_numeric($amount)) {
- throw new \Box_Exception('Funds amount is invalid');
+ throw new \FOSSBilling\InformationException('Funds amount is invalid');
}
if (empty($description)) {
- throw new \Box_Exception('Funds description is invalid');
+ throw new \FOSSBilling\InformationException('Funds description is invalid');
}
$credit = $this->di['db']->dispense('ClientBalance');
@@ -412,7 +412,7 @@ class Service implements InjectionAwareInterface
public function get($data)
{
if (!isset($data['id']) && !isset($data['email'])) {
- throw new \Box_Exception('Client ID or email is required');
+ throw new \FOSSBilling\InformationException('Client ID or email is required');
}
$db = $this->di['db'];
@@ -426,7 +426,7 @@ class Service implements InjectionAwareInterface
}
if (!$client instanceof \Model_Client) {
- throw new \Box_Exception('Client not found');
+ throw new \FOSSBilling\Exception('Client not found');
}
return $client;
@@ -469,7 +469,7 @@ class Service implements InjectionAwareInterface
{
$client = $this->di['db']->findOne('Client', 'client_group_id = ?', [$model->id]);
if ($client) {
- throw new \Box_Exception('Can not remove group with clients');
+ throw new \FOSSBilling\Exception('Can not remove group with clients');
}
$this->di['db']->trash($model);
@@ -629,7 +629,7 @@ class Service implements InjectionAwareInterface
&& isset($config['disable_change_email'])
&& $config['disable_change_email']
) {
- throw new \Box_Exception('Email can not be changed');
+ throw new \FOSSBilling\InformationException('Email can not be changed');
}
return true;
@@ -643,7 +643,7 @@ class Service implements InjectionAwareInterface
if (!isset($checkArr[$field]) || empty($checkArr[$field])) {
$name = ucwords(str_replace('_', ' ', $field));
- throw new \Box_Exception('Field :field cannot be empty', [':field' => $name]);
+ throw new \FOSSBilling\InformationException('Field :field cannot be empty', [':field' => $name]);
}
}
}
@@ -659,7 +659,7 @@ class Service implements InjectionAwareInterface
if (!isset($checkArr[$cFieldName]) || empty($checkArr[$cFieldName])) {
$name = isset($cField['title']) && !empty($cField['title']) ? $cField['title'] : ucwords(str_replace('_', ' ', $cFieldName));
- throw new \Box_Exception('Field :field cannot be empty', [':field' => $name]);
+ throw new \FOSSBilling\InformationException('Field :field cannot be empty', [':field' => $name]);
}
}
}
@@ -687,7 +687,7 @@ class Service implements InjectionAwareInterface
*
* @return bool|int
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\InformationException
*/
public function password_reset_valid($data)
{
@@ -699,7 +699,7 @@ class Service implements InjectionAwareInterface
$reset = $this->di['db']->findOne('ClientPasswordReset', 'hash = ?', [$data['hash']]);
if (!$reset instanceof \Model_ClientPasswordReset) {
- throw new \Box_Exception('The link has expired or you have already reset your password.');
+ throw new \FOSSBilling\InformationException('The link has expired or you have already reset your password.');
}
$c = $this->di['db']->findOne('Client', 'id = ?', [$reset->client_id]);
diff --git a/src/modules/Client/ServiceBalance.php b/src/modules/Client/ServiceBalance.php
index d7553981c..7aff34ea7 100644
--- a/src/modules/Client/ServiceBalance.php
+++ b/src/modules/Client/ServiceBalance.php
@@ -117,16 +117,16 @@ class ServiceBalance implements InjectionAwareInterface
*
* @return \Model_ClientBalance
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\InformationException
*/
public function deductFunds(\Model_Client $client, $amount, $description, array $data = null)
{
if (!is_numeric($amount)) {
- throw new \Box_Exception('Funds amount is invalid');
+ throw new \FOSSBilling\InformationException('Funds amount is invalid');
}
if (strlen(trim($description)) == 0) {
- throw new \Box_Exception('Funds description is invalid');
+ throw new \FOSSBilling\InformationException('Funds description is invalid');
}
$credit = $this->di['db']->dispense('ClientBalance');
diff --git a/src/modules/Cookieconsent/Api/Guest.php b/src/modules/Cookieconsent/Api/Guest.php
index ebe0df00d..08310903d 100644
--- a/src/modules/Cookieconsent/Api/Guest.php
+++ b/src/modules/Cookieconsent/Api/Guest.php
@@ -23,7 +23,7 @@ class Guest extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function message()
{
diff --git a/src/modules/Currency/Api/Admin.php b/src/modules/Currency/Api/Admin.php
index b80984e1b..9a863b81b 100644
--- a/src/modules/Currency/Api/Admin.php
+++ b/src/modules/Currency/Api/Admin.php
@@ -51,7 +51,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get($data)
{
@@ -64,7 +64,7 @@ class Admin extends \Api_Abstract
$model = $service->getByCode($data['code']);
if (!$model instanceof \Model_Currency) {
- throw new \Box_Exception('Currency not found');
+ throw new \FOSSBilling\Exception('Currency not found');
}
return $service->toApiArray($model);
@@ -90,7 +90,7 @@ class Admin extends \Api_Abstract
*
* @return string - currency code
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function create($data = [])
{
@@ -103,11 +103,11 @@ class Admin extends \Api_Abstract
$service = $this->getService();
if ($service->getByCode($data['code'] ?? null)) {
- throw new \Box_Exception('Currency already registered');
+ throw new \FOSSBilling\Exception('Currency already registered');
}
if (!array_key_exists($data['code'] ?? null, $service->getAvailableCurrencies())) {
- throw new \Box_Exception('Currency code is invalid');
+ throw new \FOSSBilling\Exception('Currency code is invalid');
}
$title = $data['title'] ?? null;
@@ -125,7 +125,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update($data)
{
@@ -205,7 +205,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function delete($data)
{
@@ -223,7 +223,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function set_default($data)
{
@@ -235,7 +235,7 @@ class Admin extends \Api_Abstract
$service = $this->getService();
$model = $service->getByCode($data['code']);
if (!$model instanceof \Model_Currency) {
- throw new \Box_Exception('Currency not found');
+ throw new \FOSSBilling\Exception('Currency not found');
}
return $service->setAsDefault($model);
diff --git a/src/modules/Currency/Api/Guest.php b/src/modules/Currency/Api/Guest.php
index cb9046164..bd1157510 100644
--- a/src/modules/Currency/Api/Guest.php
+++ b/src/modules/Currency/Api/Guest.php
@@ -44,7 +44,7 @@ class Guest extends \Api_Abstract
}
if (!$model instanceof \Model_Currency) {
- throw new \Box_Exception('Currency not found');
+ throw new \FOSSBilling\Exception('Currency not found');
}
return $service->toApiArray($model);
diff --git a/src/modules/Currency/Service.php b/src/modules/Currency/Service.php
index 50a74f42b..6c162d2fc 100644
--- a/src/modules/Currency/Service.php
+++ b/src/modules/Currency/Service.php
@@ -55,7 +55,7 @@ class Service implements InjectionAwareInterface
{
$f_rate = $this->getRateByCode($foreign_code);
if ($f_rate == 0) {
- throw new \Box_Exception('Currency conversion rate can not be zero');
+ throw new \FOSSBilling\InformationException('Currency conversion rate can not be zero');
}
return 1 / $f_rate;
@@ -121,7 +121,7 @@ class Service implements InjectionAwareInterface
}
if ($currency->code === null || empty($currency->code)) {
- throw new \Box_Exception('Currency code not provided');
+ throw new \FOSSBilling\Exception('Currency code not provided');
}
$sql1 = 'UPDATE currency SET is_default = 0 WHERE 1';
@@ -319,11 +319,11 @@ class Service implements InjectionAwareInterface
public function rm(\Model_Currency $model)
{
if ($model->is_default) {
- throw new \Box_Exception('Can not remove default currency');
+ throw new \FOSSBilling\InformationException('Can not remove default currency');
}
if ($model->code === null || empty($model->code)) {
- throw new \Box_Exception('Currency not found');
+ throw new \FOSSBilling\Exception('Currency not found');
}
$sql = 'DELETE FROM currency WHERE code = :code';
@@ -454,7 +454,7 @@ class Service implements InjectionAwareInterface
$model = $this->getByCode($code);
if (!$model instanceof \Model_Currency) {
- throw new \Box_Exception('Currency not found');
+ throw new \FOSSBilling\Exception('Currency not found');
}
if (isset($title)) {
@@ -472,7 +472,7 @@ class Service implements InjectionAwareInterface
if (isset($conversionRate)) {
if (!is_numeric($conversionRate) || $conversionRate <= 0) {
- throw new \Box_Exception('Currency rate is invalid', null, 151);
+ throw new \FOSSBilling\InformationException('Currency rate is invalid', null, 151);
}
$model->conversion_rate = $conversionRate;
}
@@ -537,7 +537,7 @@ class Service implements InjectionAwareInterface
}
}
- throw new \Box_Exception('Failed to get currency rates for :currency from the European Central Bank API', [':currency' => $to_Currency]);
+ throw new \FOSSBilling\Exception('Failed to get currency rates for :currency from the European Central Bank API', [':currency' => $to_Currency]);
} else {
$client = HttpClient::create();
$response = $client->request('GET', 'https://api.apilayer.com/currency_data/live', [
@@ -553,7 +553,7 @@ class Service implements InjectionAwareInterface
$array = $response->toArray();
if ($array['success'] !== true) {
- throw new \Box_Exception('
Currencylayer threw an error::errorInfo', [':errorInfo' => $array['error']['info']]);
+ throw new \FOSSBilling\Exception('
Currencylayer threw an error::errorInfo', [':errorInfo' => $array['error']['info']]);
} else {
return (float) $array['quotes'][$from_Currency . $to_Currency];
}
@@ -565,7 +565,7 @@ class Service implements InjectionAwareInterface
$model = $this->getByCode($code);
if (!$model instanceof \Model_Currency) {
- throw new \Box_Exception('Currency not found');
+ throw new \FOSSBilling\Exception('Currency not found');
}
$code = $model->code;
diff --git a/src/modules/Email/Api/Admin.php b/src/modules/Email/Api/Admin.php
index 9b360c7b0..42ae53895 100644
--- a/src/modules/Email/Api/Admin.php
+++ b/src/modules/Email/Api/Admin.php
@@ -99,7 +99,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function email_resend($data)
{
@@ -111,7 +111,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->findOne('ActivityClientEmail', 'id = ?', [$data['id']]);
if (!$model instanceof \Model_ActivityClientEmail) {
- throw new \Box_Exception('Email not found');
+ throw new \FOSSBilling\Exception('Email not found');
}
return $this->getService()->resend($model);
@@ -122,7 +122,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function email_delete($data)
{
@@ -134,7 +134,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->findOne('ActivityClientEmail', 'id = ?', [$data['id']]);
if (!$model instanceof \Model_ActivityClientEmail) {
- throw new \Box_Exception('Email not found');
+ throw new \FOSSBilling\Exception('Email not found');
}
$id = $model->id;
@@ -175,7 +175,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function template_get($data)
{
@@ -194,7 +194,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function template_delete($data)
{
@@ -206,7 +206,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->findOne('EmailTemplate', 'id = ?', [$data['id']]);
if (!$model instanceof \Model_EmailTemplate) {
- throw new \Box_Exception('Email template not found');
+ throw new \FOSSBilling\Exception('Email template not found');
}
$id = $model->id;
@@ -223,7 +223,7 @@ class Admin extends \Api_Abstract
*
* @return int - newly created template id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function template_create($data)
{
@@ -247,7 +247,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
* = */
public function template_update($data)
{
@@ -382,7 +382,7 @@ class Admin extends \Api_Abstract
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if (!isset($data['to']) && !isset($data['to_staff']) && !isset($data['to_client'])) {
- throw new \Box_Exception('Receiver is not defined. Define to or to_client or to_staff parameter');
+ throw new \FOSSBilling\InformationException('Receiver is not defined. Define to or to_client or to_staff parameter');
}
return $this->getService()->sendTemplate($data);
diff --git a/src/modules/Email/Api/Client.php b/src/modules/Email/Api/Client.php
index 4fd76b0ad..330a337a0 100644
--- a/src/modules/Email/Api/Client.php
+++ b/src/modules/Email/Api/Client.php
@@ -51,7 +51,7 @@ class Client extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get($data)
{
@@ -63,7 +63,7 @@ class Client extends \Api_Abstract
$model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']);
if (!$model instanceof \Model_ActivityClientEmail) {
- throw new \Box_Exception('Email not found');
+ throw new \FOSSBilling\Exception('Email not found');
}
return $this->getService()->toApiArray($model);
@@ -74,7 +74,7 @@ class Client extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function resend($data)
{
@@ -85,7 +85,7 @@ class Client extends \Api_Abstract
$model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']);
if (!$model instanceof \Model_ActivityClientEmail) {
- throw new \Box_Exception('Email not found');
+ throw new \FOSSBilling\Exception('Email not found');
}
return $this->getService()->resend($model);
@@ -96,7 +96,7 @@ class Client extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function delete($data)
{
@@ -107,7 +107,7 @@ class Client extends \Api_Abstract
$model = $this->getService()->findOneForClientById($this->getIdentity(), $data['id']);
if (!$model instanceof \Model_ActivityClientEmail) {
- throw new \Box_Exception('Email not found');
+ throw new \FOSSBilling\Exception('Email not found');
}
return $this->getService()->rm($model);
diff --git a/src/modules/Email/Service.php b/src/modules/Email/Service.php
index 70c3deae6..8c1994d64 100644
--- a/src/modules/Email/Service.php
+++ b/src/modules/Email/Service.php
@@ -109,7 +109,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
public function setVars($t, $vars)
{
$config = $this->di['config'];
- $t->vars = $this->di['crypt']->encrypt(json_encode($vars), $config['salt']);
+ $t->vars = $this->di['crypt']->encrypt(json_encode($vars), $config['info']['salt']);
$this->di['db']->store($t);
return true;
@@ -121,7 +121,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
public function getVars($t)
{
$config = $this->di['config'];
- $json = $this->di['crypt']->decrypt($t->vars, $config['salt']);
+ $json = $this->di['crypt']->decrypt($t->vars, $config['info']['salt']);
return $this->di['tools']->decodeJ($json);
}
@@ -134,7 +134,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if (!isset($data['to']) && !isset($data['to_staff']) && !isset($data['to_client']) && !isset($data['to_admin'])) {
- throw new \Box_Exception('Receiver is not defined. Define to or to_client or to_staff or to_admin parameter');
+ throw new \FOSSBilling\InformationException('Receiver is not defined. Define to or to_client or to_staff or to_admin parameter');
}
$vars = $data;
unset($vars['to'], $vars['to_client'], $vars['to_staff'], $vars['to_name'], $vars['from'], $vars['from_name'], $vars['to_admin']);
@@ -193,7 +193,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$sent = false;
if (!$from) {
- throw new \Box_Exception('From email address can not be empty');
+ throw new \FOSSBilling\InformationException('From email address can not be empty');
}
if (isset($staff)) {
@@ -448,7 +448,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$t = $this->di['db']->findOne('EmailTemplate', 'action_code = :action', [':action' => $code]);
if (!$t instanceof \Model_EmailTemplate) {
- throw new \Box_Exception('Email template :code was not found', [':code' => $code]);
+ throw new \FOSSBilling\Exception('Email template :code was not found', [':code' => $code]);
}
$d = ['code' => $code];
@@ -463,7 +463,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
{
$model = $this->di['db']->findOne('ActivityClientEmail', 'id = ?', [$id]);
if (!$model instanceof \Model_ActivityClientEmail) {
- throw new \Box_Exception('Email not found');
+ throw new \FOSSBilling\Exception('Email not found');
}
return $model;
@@ -637,7 +637,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
// If the error message is long, truncate it and inform the user the rest is in the error log.
$truncated = (strlen($message) > 350) ? __trans('Error message truncated due to length, please check the error log for the complete message: ') . substr($message, 0, 350) . '...' : $message;
- throw new \Box_Exception($truncated);
+ throw new \FOSSBilling\Exception($truncated);
}
}
diff --git a/src/modules/Extension/Api/Admin.php b/src/modules/Extension/Api/Admin.php
index 5b9c94661..2160b7220 100644
--- a/src/modules/Extension/Api/Admin.php
+++ b/src/modules/Extension/Api/Admin.php
@@ -95,7 +95,7 @@ class Admin extends \Api_Abstract
*
* @param array $data The post data sent to the API. Should contain a key named `locale_id` which is set to the locale ID to change. (`en_US` for example)
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function toggle_language(array $data): bool
{
@@ -129,7 +129,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update($data)
{
@@ -148,7 +148,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function activate($data)
{
@@ -169,7 +169,7 @@ class Admin extends \Api_Abstract
*
* @return bool - true
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function deactivate($data)
{
@@ -210,7 +210,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function install($data)
{
@@ -243,7 +243,7 @@ class Admin extends \Api_Abstract
*
* @return array - configuration parameters
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function config_get($data)
{
@@ -269,7 +269,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function config_save($data)
{
@@ -292,7 +292,7 @@ class Admin extends \Api_Abstract
$service = $this->getService();
$ext = $service->findExtension($data['type'], $data['id']);
if (!$ext instanceof \Model_Extension) {
- throw new \Box_Exception('Extension not found');
+ throw new \FOSSBilling\Exception('Extension not found');
}
return $ext;
diff --git a/src/modules/Extension/Api/Guest.php b/src/modules/Extension/Api/Guest.php
index 625b323b3..cd3cb4313 100644
--- a/src/modules/Extension/Api/Guest.php
+++ b/src/modules/Extension/Api/Guest.php
@@ -51,12 +51,12 @@ class Guest extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function settings($data)
{
if (!isset($data['ext'])) {
- throw new \Box_Exception('Parameter ext is missing');
+ throw new \FOSSBilling\Exception('Parameter ext is missing');
}
$service = $this->getService();
$config = $service->getConfig($data['ext']);
diff --git a/src/modules/Extension/Service.php b/src/modules/Extension/Service.php
index eaaf3b248..d0f47cd3a 100644
--- a/src/modules/Extension/Service.php
+++ b/src/modules/Extension/Service.php
@@ -317,7 +317,7 @@ class Service implements InjectionAwareInterface
public function update(\Model_Extension $model)
{
- throw new \Box_Exception('Visit the extension directory for more information on updating this extension.', null, 252);
+ throw new \FOSSBilling\InformationException('Visit the extension directory for more information on updating this extension.', null, 252);
}
public function activate(\Model_Extension $ext)
@@ -366,13 +366,13 @@ class Service implements InjectionAwareInterface
case \FOSSBilling\ExtensionManager::TYPE_MOD:
$mod = $ext->name;
if ($this->isCoreModule($mod)) {
- throw new \Box_Exception('FOSSBilling core modules can not be managed');
+ throw new \FOSSBilling\InformationException('FOSSBilling core modules can not be managed');
}
try {
$mm = $this->di['mod']($mod);
$mm->uninstall();
- } catch (\Box_Exception $e) {
+ } catch (\FOSSBilling\Exception $e) {
if ($e->getCode() != 408) {
throw $e;
}
@@ -431,7 +431,7 @@ class Service implements InjectionAwareInterface
$code = $response->getStatusCode();
if ($code !== 200) {
- throw new \Box_Exception('Failed to download the extension with error :code', [':code' => $code]);
+ throw new \FOSSBilling\Exception('Failed to download the extension with error :code', [':code' => $code]);
}
foreach ($client->stream($response) as $chunk) {
@@ -448,7 +448,7 @@ class Service implements InjectionAwareInterface
} catch (\PhpZip\Exception\ZipException $e) {
error_log($e->getMessage());
- throw new \Box_Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.');
+ throw new \FOSSBilling\Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.');
}
switch ($type) {
@@ -472,13 +472,13 @@ class Service implements InjectionAwareInterface
if (isset($destination)) {
if (file_exists($destination)) {
- throw new \Box_Exception('Extension :id seems to be already installed.', [':id' => $id], 436);
+ throw new \FOSSBilling\Exception('Extension :id seems to be already installed.', [':id' => $id], 436);
}
if (!rename($extractedPath, $destination)) {
- throw new \Box_Exception('Failed to move extension to it\'s final destination. Please check permissions for the destination folder. (:destination)', [':destination' => $destination], 437);
+ throw new \FOSSBilling\Exception('Failed to move extension to it\'s final destination. Please check permissions for the destination folder. (:destination)', [':destination' => $destination], 437);
}
} else {
- throw new \Box_Exception('Extension type (:type) cannot be automatically installed.', [':type' => $type]);
+ throw new \FOSSBilling\InformationException('Extension type (:type) cannot be automatically installed.', [':type' => $type]);
}
if (file_exists($zipPath)) {
@@ -509,12 +509,12 @@ class Service implements InjectionAwareInterface
$mod = $this->di['mod']($ext->name);
if ($mod->isCore()) {
- throw new \Box_Exception('FOSSBilling core modules can not be installed or removed');
+ throw new \FOSSBilling\InformationException('FOSSBilling core modules can not be installed or removed');
}
$info = $mod->getManifest();
if (isset($info['minimum_boxbilling_version']) && \FOSSBilling\Version::compareVersion($info['minimum_boxbilling_version']) > 0) {
- throw new \Box_Exception('Module can not be installed. It requires at least :min version of FOSSBilling. You are using :v', [':min' => $info['minimum_boxbilling_version'], ':v' => \FOSSBilling\Version::VERSION]);
+ throw new \FOSSBilling\InformationException('Module can not be installed. It requires at least :min version of FOSSBilling. You are using :v', [':min' => $info['minimum_boxbilling_version'], ':v' => \FOSSBilling\Version::VERSION]);
}
// Allow install module even if no installer exists
@@ -522,7 +522,7 @@ class Service implements InjectionAwareInterface
// perform install script if available
try {
$mod->install();
- } catch (\Box_Exception $e) {
+ } catch (\FOSSBilling\Exception $e) {
if ($e->getCode() != 408) {
throw $e;
}
@@ -611,7 +611,7 @@ class Service implements InjectionAwareInterface
private function _getSalt()
{
- return $this->di['config']['salt'];
+ return $this->di['config']['info']['salt'];
}
public function getCoreAndActiveModules()
diff --git a/src/modules/Formbuilder/Api/Admin.php b/src/modules/Formbuilder/Api/Admin.php
index 73c14e59e..3005aa75a 100644
--- a/src/modules/Formbuilder/Api/Admin.php
+++ b/src/modules/Formbuilder/Api/Admin.php
@@ -23,7 +23,7 @@ class Admin extends \Api_Abstract
*
* @return int - ID of the created form
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function create_form($data)
{
@@ -33,7 +33,7 @@ class Admin extends \Api_Abstract
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if (isset($data['type']) && (strtolower($data['type']) != 'horizontal' || strtolower($data['type']) != 'default')) {
- throw new \Box_Exception('Form style was not found in predefined list', null, 3657);
+ throw new \FOSSBilling\Exception('Form style was not found in predefined list', null, 3657);
}
$service = $this->getService();
@@ -65,19 +65,19 @@ class Admin extends \Api_Abstract
*
* @return int - ID of created field
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function add_field($data)
{
$service = $this->getService();
if (!isset($data['type']) || !$service->typeValidation($data['type'])) {
- throw new \Box_Exception('Form field type is invalid', null, 2684);
+ throw new \FOSSBilling\Exception('Form field type is invalid', null, 2684);
}
if (isset($data['options']) && is_array($data['options']) && !$service->isArrayUnique($data['options'])) {
- throw new \Box_Exception('This input type must have unique values', null, 3658);
+ throw new \FOSSBilling\InformationException('This input type must have unique values', null, 3658);
}
if (!isset($data['form_id'])) {
- throw new \Box_Exception('Form id was not passed', null, 9846);
+ throw new \FOSSBilling\InformationException('Form id was not passed', null, 9846);
}
$fieldId = $service->addNewField($data);
@@ -90,7 +90,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get_form($data)
{
@@ -109,7 +109,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get_form_fields($data)
{
@@ -129,7 +129,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get_field($data)
{
@@ -149,7 +149,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get_forms()
{
@@ -164,7 +164,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function delete_form($data)
{
@@ -184,7 +184,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function delete_field($data)
{
@@ -223,7 +223,7 @@ class Admin extends \Api_Abstract
*
* @return int - The ID of the updated field
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update_field($data)
{
@@ -234,7 +234,7 @@ class Admin extends \Api_Abstract
$service = $this->getService();
if (isset($data['options']) && !$service->isArrayUnique($data['options'])) {
- throw new \Box_Exception('This input type must have unique values', null, 3658);
+ throw new \FOSSBilling\InformationException('This input type must have unique values', null, 3658);
}
$fieldId = $service->updateField($data);
@@ -257,15 +257,15 @@ class Admin extends \Api_Abstract
*
* @return int - ID of the new form
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function copy_form($data)
{
if (!isset($data['form_id'])) {
- throw new \Box_Exception('Form id was not passed', null, 9958);
+ throw new \FOSSBilling\InformationException('Form id was not passed', null, 9958);
}
if (!isset($data['name'])) {
- throw new \Box_Exception('Form name was not passed', null, 9842);
+ throw new \FOSSBilling\InformationException('Form name was not passed', null, 9842);
}
$service = $this->getService();
@@ -282,18 +282,18 @@ class Admin extends \Api_Abstract
public function update_form_settings($data)
{
if (!isset($data['form_id']) || (trim($data['form_id']) == '')) {
- throw new \Box_Exception('Form id was not passed', null, 1654);
+ throw new \FOSSBilling\InformationException('Form id was not passed', null, 1654);
}
if (!isset($data['form_name'])) {
- throw new \Box_Exception('Form name was not passed', null, 9241);
+ throw new \FOSSBilling\InformationException('Form name was not passed', null, 9241);
}
if (!isset($data['type'])) {
- throw new \Box_Exception('Form type was not passed', null, 3794);
+ throw new \FOSSBilling\InformationException('Form type was not passed', null, 3794);
}
if ($data['type'] != 'horizontal' && $data['type'] != 'default') {
- throw new \Box_Exception('Field type not supported', null, 3207);
+ throw new \FOSSBilling\Exception('Field type not supported', null, 3207);
}
$service = $this->getService();
diff --git a/src/modules/Formbuilder/Api/Guest.php b/src/modules/Formbuilder/Api/Guest.php
index 1e1fcd0a2..ef4350c1a 100644
--- a/src/modules/Formbuilder/Api/Guest.php
+++ b/src/modules/Formbuilder/Api/Guest.php
@@ -21,7 +21,7 @@ class Guest extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get($data)
{
diff --git a/src/modules/Formbuilder/Service.php b/src/modules/Formbuilder/Service.php
index 9df4628c0..e4d43d1dc 100644
--- a/src/modules/Formbuilder/Service.php
+++ b/src/modules/Formbuilder/Service.php
@@ -136,11 +136,11 @@ class Service implements InjectionAwareInterface
$text = preg_replace('~[^\-\w]+~', '', $text);
if (is_numeric(substr($text, 0, 1))) {
- throw new \Box_Exception('Field name can not start with number.', null, 1649);
+ throw new \FOSSBilling\InformationException('Field name can not start with number.', null, 1649);
}
if (empty($text)) {
- throw new \Box_Exception('Field name can not be empty. Please make sure it is not empty and does not contain special characters.', null, 3502);
+ throw new \FOSSBilling\InformationException('Field name can not be empty. Please make sure it is not empty and does not contain special characters.', null, 3502);
}
return $text;
@@ -157,7 +157,7 @@ class Service implements InjectionAwareInterface
$field['form_id'] = $get_field['form_id'];
if ($this->formFieldNameExists(['form_id' => $field['form_id'], 'field_name' => $field['name'], 'field_id' => $fieldId])) {
- throw new \Box_Exception('Unfortunately field with this name exists in this form already. Form must have different field names.', null, 7628);
+ throw new \FOSSBilling\InformationException('Unfortunately field with this name exists in this form already. Form must have different field names.', null, 7628);
}
$field['options'] = isset($field['options']) ? json_encode($field['options']) : '';
@@ -168,10 +168,10 @@ class Service implements InjectionAwareInterface
if (isset($field['type'])) {
if ($field['type'] == 'checkbox' || $field['type'] == 'radio' || $field['type'] == 'select') {
if (!$this->isArrayUnique(array_filter($field['values'], 'strlen'))) {
- throw new \Box_Exception(ucfirst($field['type']) . ' values must be unique', null, 1597);
+ throw new \FOSSBilling\InformationException(ucfirst($field['type']) . ' values must be unique', null, 1597);
}
if (!$this->isArrayUnique(array_filter($field['labels'], 'strlen'))) {
- throw new \Box_Exception(ucfirst($field['type']) . ' labels must be unique', null, 1598);
+ throw new \FOSSBilling\InformationException(ucfirst($field['type']) . ' labels must be unique', null, 1598);
}
$field['options'] = array_combine($field['labels'], $field['values']);
$field['options'] = array_filter($field['options'], 'strlen');
@@ -179,7 +179,7 @@ class Service implements InjectionAwareInterface
}
if ($field['type'] == 'textarea') {
if ((is_countable($field['textarea_size']) ? count($field['textarea_size']) : 0) != count((array) array_filter($field['textarea_size'], 'is_numeric'))) {
- throw new \Box_Exception('Textarea size options must be integer values', null, 3510);
+ throw new \FOSSBilling\InformationException('Textarea size options must be integer values', null, 3510);
}
$field['options'] = array_combine($field['textarea_option'], $field['textarea_size']);
$field['options'] = json_encode($field['options'], JSON_FORCE_OBJECT);
diff --git a/src/modules/Hook/Api/Admin.php b/src/modules/Hook/Api/Admin.php
index 833dec4dd..4d121d6cf 100644
--- a/src/modules/Hook/Api/Admin.php
+++ b/src/modules/Hook/Api/Admin.php
@@ -47,7 +47,7 @@ class Admin extends \Api_Abstract
$event = $data['event'];
$params = $data['params'] ?? null;
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
try {
$this->di['logger']->info($event . ': ' . var_export($params, 1));
} catch (\Exception $e) {
diff --git a/src/modules/Hook/Service.php b/src/modules/Hook/Service.php
index 7dfbb3efb..1dc08a5e2 100644
--- a/src/modules/Hook/Service.php
+++ b/src/modules/Hook/Service.php
@@ -115,7 +115,7 @@ class Service implements InjectionAwareInterface
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
private function connect($data)
{
diff --git a/src/modules/Invoice/Api/Admin.php b/src/modules/Invoice/Api/Admin.php
index 8878d5b1e..4e1fa0749 100644
--- a/src/modules/Invoice/Api/Admin.php
+++ b/src/modules/Invoice/Api/Admin.php
@@ -230,7 +230,7 @@ class Admin extends \Api_Abstract
*
* @return string - invoice id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function renewal_invoice($data)
{
@@ -242,7 +242,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->getExistingModelById('ClientOrder', $data['id'], 'Order not found');
if ($model->price <= 0) {
- throw new \Box_Exception('Order :id is free. No need to generate invoice.', [':id' => $model->id]);
+ throw new \FOSSBilling\InformationException('Order :id is free. No need to generate invoice.', [':id' => $model->id]);
}
return $this->getService()->renewInvoice($model, $data);
@@ -606,7 +606,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function gateway_get($data)
{
@@ -625,7 +625,7 @@ class Admin extends \Api_Abstract
/**
* Copy gateway from existing one.
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function gateway_copy($data)
{
@@ -652,7 +652,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function gateway_update($data)
{
@@ -672,7 +672,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function gateway_delete($data)
{
@@ -718,7 +718,7 @@ class Admin extends \Api_Abstract
*
* @return int - id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\InformationException
*/
public function subscription_create($data)
{
@@ -733,7 +733,7 @@ class Admin extends \Api_Abstract
$payGateway = $this->di['db']->getExistingModelById('PayGateway', $data['gateway_id'], 'Payment gateway not found');
if ($client->currency != $data['currency']) {
- throw new \Box_Exception('Client currency must match subscription currency. Check if clients currency is defined.');
+ throw new \FOSSBilling\InformationException('Client currency must match subscription currency. Check if clients currency is defined.');
}
$subscriptionService = $this->di['mod_service']('Invoice', 'Subscription');
@@ -751,7 +751,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function subscription_update($data)
{
@@ -771,7 +771,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function subscription_get($data)
{
@@ -792,7 +792,7 @@ class Admin extends \Api_Abstract
}
if (!$model instanceof \Model_Subscription) {
- throw new \Box_Exception('Subscription not found');
+ throw new \FOSSBilling\Exception('Subscription not found');
}
$subscriptionService = $this->di['mod_service']('Invoice', 'Subscription');
@@ -805,7 +805,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function subscription_delete($data)
{
@@ -825,7 +825,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function tax_delete($data)
{
diff --git a/src/modules/Invoice/Api/Client.php b/src/modules/Invoice/Api/Client.php
index bef804637..b6bcb4062 100644
--- a/src/modules/Invoice/Api/Client.php
+++ b/src/modules/Invoice/Api/Client.php
@@ -41,7 +41,7 @@ class Client extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get($data)
{
@@ -52,7 +52,7 @@ class Client extends \Api_Abstract
$model = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]);
if (!$model) {
- throw new \Box_Exception('Invoice was not found');
+ throw new \FOSSBilling\Exception('Invoice was not found');
}
return $this->getService()->toApiArray($model, true, $this->getIdentity());
@@ -65,7 +65,7 @@ class Client extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update($data)
{
@@ -76,10 +76,10 @@ class Client extends \Api_Abstract
$invoice = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]);
if (!$invoice) {
- throw new \Box_Exception('Invoice was not found');
+ throw new \FOSSBilling\Exception('Invoice was not found');
}
if ($invoice->status == 'paid') {
- throw new \Box_Exception('Paid Invoice can not be modified');
+ throw new \FOSSBilling\InformationException('Paid Invoice can not be modified');
}
$updateParams = [];
@@ -95,7 +95,7 @@ class Client extends \Api_Abstract
*
* @return string - invoice hash
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function renewal_invoice($data)
{
@@ -107,10 +107,10 @@ class Client extends \Api_Abstract
$model = $this->di['db']->findOne('ClientOrder', 'client_id = ? and id = ?', [$this->getIdentity()->id, $data['order_id']]);
if (!$model instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Order not found');
+ throw new \FOSSBilling\Exception('Order not found');
}
if ($model->price <= 0) {
- throw new \Box_Exception('Order :id is free. No need to generate invoice.', [':id' => $model->id]);
+ throw new \FOSSBilling\InformationException('Order :id is free. No need to generate invoice.', [':id' => $model->id]);
}
$service = $this->getService();
$invoice = $service->generateForOrder($model);
@@ -135,7 +135,7 @@ class Client extends \Api_Abstract
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if (!is_numeric($data['amount'])) {
- throw new \Box_Exception('You need to enter numeric value');
+ throw new \FOSSBilling\InformationException('You need to enter numeric value');
}
$service = $this->getService();
@@ -151,7 +151,7 @@ class Client extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function delete($data)
{
@@ -162,7 +162,7 @@ class Client extends \Api_Abstract
$model = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]);
if (!$model) {
- throw new \Box_Exception('Invoice was not found');
+ throw new \FOSSBilling\Exception('Invoice was not found');
}
return $this->getService()->deleteInvoiceByClient($model);
diff --git a/src/modules/Invoice/Api/Guest.php b/src/modules/Invoice/Api/Guest.php
index 81626024a..46b6d9ec3 100644
--- a/src/modules/Invoice/Api/Guest.php
+++ b/src/modules/Invoice/Api/Guest.php
@@ -21,7 +21,7 @@ class Guest extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get($data)
{
@@ -32,7 +32,7 @@ class Guest extends \Api_Abstract
$model = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]);
if (!$model) {
- throw new \Box_Exception('Invoice was not found');
+ throw new \FOSSBilling\Exception('Invoice was not found');
}
return $this->getService()->toApiArray($model, true, $this->getIdentity());
@@ -45,7 +45,7 @@ class Guest extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update($data)
{
@@ -56,10 +56,10 @@ class Guest extends \Api_Abstract
$invoice = $this->di['db']->findOne('Invoice', 'hash = :hash', ['hash' => $data['hash']]);
if (!$invoice) {
- throw new \Box_Exception('Invoice was not found');
+ throw new \FOSSBilling\Exception('Invoice was not found');
}
if ($invoice->status == 'paid') {
- throw new \Box_Exception('Paid Invoice can not be modified');
+ throw new \FOSSBilling\InformationException('Paid Invoice can not be modified');
}
$updateParams = [];
@@ -94,16 +94,16 @@ class Guest extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function payment($data)
{
if (!isset($data['hash'])) {
- throw new \Box_Exception('Invoice hash not passed. Missing param hash', null, 810);
+ throw new \FOSSBilling\Exception('Invoice hash not passed. Missing param hash', null, 810);
}
if (!isset($data['gateway_id'])) {
- throw new \Box_Exception('Payment method not found. Missing param gateway_id', null, 811);
+ throw new \FOSSBilling\Exception('Payment method not found. Missing param gateway_id', null, 811);
}
return $this->getService()->processInvoice($data);
@@ -112,7 +112,7 @@ class Guest extends \Api_Abstract
/**
* Generates PDF for given invoice.
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function pdf($data)
{
diff --git a/src/modules/Invoice/Service.php b/src/modules/Invoice/Service.php
index eaec25871..950a981ac 100644
--- a/src/modules/Invoice/Service.php
+++ b/src/modules/Invoice/Service.php
@@ -414,7 +414,7 @@ class Service implements InjectionAwareInterface
if ($r instanceof \Model_Invoice && is_numeric($r->nr)) {
$next_nr = intval($r->nr) + 1;
} else {
- throw new \Box_Exception('Unable to determine the next invoice number');
+ throw new \FOSSBilling\Exception('Unable to determine the next invoice number');
}
}
@@ -559,7 +559,7 @@ class Service implements InjectionAwareInterface
$epsilon = 0.05;
if (abs($balance - $required) < $epsilon) {
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
error_log(sprintf('Setting invoice %s as paid with credits', $invoice->id));
}
$this->markAsPaid($invoice);
@@ -568,14 +568,14 @@ class Service implements InjectionAwareInterface
}
if ($balance - $required > 0.00001) {
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
error_log(sprintf('Setting invoice %s as paid with credits', $invoice->id));
}
$this->markAsPaid($invoice);
return true;
}
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
error_log(sprintf('Invoice %s could not be paid with credits. Money in balance %s Required: %s', $invoice->id, $balance, $required));
}
}
@@ -628,7 +628,7 @@ class Service implements InjectionAwareInterface
case 'negative_invoice':
$total = $this->getTotalWithTax($invoice);
if ($total <= 0) {
- throw new \Box_Exception('Can not refund invoice with negative amount');
+ throw new \FOSSBilling\InformationException('Can not refund invoice with negative amount');
}
$new = $this->di['db']->dispense('Invoice');
@@ -708,7 +708,7 @@ class Service implements InjectionAwareInterface
break;
case 'manual':
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
error_log('Refunds are managed manually. No actions performed');
}
@@ -843,7 +843,7 @@ class Service implements InjectionAwareInterface
$invoiceItem = $this->di['db']->find('InvoiceItem', 'invoice_id = ?', [$model->id]);
foreach ($invoiceItem as $item) {
if ($item->type == \Model_InvoiceItem::TYPE_ORDER) {
- throw new \Box_Exception('Invoice is related to order #:id. Please cancel order first.', [':id' => $item->rel_id]);
+ throw new \FOSSBilling\InformationException('Invoice is related to order #:id. Please cancel order first.', [':id' => $item->rel_id]);
}
}
@@ -876,7 +876,7 @@ class Service implements InjectionAwareInterface
$model = $this->di['db']->getExistingModelById('Invoice', $proforma['id']);
$this->tryPayWithCredits($model);
} catch (\Exception $e) {
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
error_log($e->getMessage());
}
}
@@ -910,7 +910,7 @@ class Service implements InjectionAwareInterface
}
if ($order->price <= 0) {
- throw new \Box_Exception('Invoices are not generated for 0 amount orders');
+ throw new \FOSSBilling\InformationException('Invoices are not generated for 0 amount orders');
}
$client = $this->di['db']->getExistingModelById('Client', $order->client_id, 'Client not found');
@@ -1078,7 +1078,7 @@ class Service implements InjectionAwareInterface
public function generateFundsInvoice(\Model_Client $client, $amount)
{
if (!$client->currency) {
- throw new \Box_Exception('You must have at least one active order before you can add funds so you cannot proceed at the current time!');
+ throw new \FOSSBilling\InformationException('You must have at least one active order before you can add funds so you cannot proceed at the current time!');
}
$systemService = $this->di['mod_service']('system');
@@ -1087,11 +1087,11 @@ class Service implements InjectionAwareInterface
$max_amount = $systemService->getParamValue('funds_max_amount', null);
if ($min_amount && $amount < $min_amount) {
- throw new \Box_Exception('Amount must be at least :min_amount', [':min_amount' => $min_amount], 981);
+ throw new \FOSSBilling\InformationException('Amount must be at least :min_amount', [':min_amount' => $min_amount], 981);
}
if ($max_amount && $amount > $max_amount) {
- throw new \Box_Exception('Amount cannot exceed :max_amount', [':max_amount' => $max_amount], 982);
+ throw new \FOSSBilling\InformationException('Amount cannot exceed :max_amount', [':max_amount' => $max_amount], 982);
}
$proforma = $this->di['db']->dispense('Invoice');
@@ -1117,16 +1117,16 @@ class Service implements InjectionAwareInterface
$invoice = $this->di['db']->findOne('Invoice', 'hash = ?', [$data['hash']]);
if (!$invoice instanceof \Model_Invoice) {
- throw new \Box_Exception('Invoice not found', null, 812);
+ throw new \FOSSBilling\Exception('Invoice not found', null, 812);
}
$gtw = $this->di['db']->load('PayGateway', $data['gateway_id']);
if (!$gtw instanceof \Model_PayGateway) {
- throw new \Box_Exception('Payment method not found', null, 813);
+ throw new \FOSSBilling\Exception('Payment method not found', null, 813);
}
if (!$gtw->enabled) {
- throw new \Box_Exception('Payment method not enabled', null, 814);
+ throw new \FOSSBilling\Exception('Payment method not enabled', null, 814);
}
$subscribeService = $this->di['mod_service']('Invoice', 'Subscription');
@@ -1185,7 +1185,7 @@ class Service implements InjectionAwareInterface
$invoice = $this->di['db']->findOne('Invoice', 'hash = :hash', [':hash' => $hash]);
if (!$invoice instanceof \Model_Invoice) {
- throw new \Box_Exception('Invoice not found');
+ throw new \FOSSBilling\Exception('Invoice not found');
}
if (isset($invoice->currency)) {
diff --git a/src/modules/Invoice/ServiceInvoiceItem.php b/src/modules/Invoice/ServiceInvoiceItem.php
index 5316e4d1e..1cad98d8b 100644
--- a/src/modules/Invoice/ServiceInvoiceItem.php
+++ b/src/modules/Invoice/ServiceInvoiceItem.php
@@ -58,7 +58,7 @@ class ServiceInvoiceItem implements InjectionAwareInterface
$order_id = $this->getOrderId($item);
$order = $this->di['db']->load('ClientOrder', $order_id);
if (!$order instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Could not activate proforma item. Order :id not found', [':id' => $order_id]);
+ throw new \FOSSBilling\Exception('Could not activate proforma item. Order :id not found', [':id' => $order_id]);
}
$orderService = $this->di['mod_service']('Order');
switch ($item->task) {
@@ -125,7 +125,7 @@ class ServiceInvoiceItem implements InjectionAwareInterface
{
$title = $data['title'] ?? '';
if (empty($title)) {
- throw new \Box_Exception('Invoice item title is missing');
+ throw new \FOSSBilling\InformationException('Invoice item title is missing');
}
$period = $data['period'] ?? 0;
diff --git a/src/modules/Invoice/ServicePayGateway.php b/src/modules/Invoice/ServicePayGateway.php
index 32d833122..885d0346a 100644
--- a/src/modules/Invoice/ServicePayGateway.php
+++ b/src/modules/Invoice/ServicePayGateway.php
@@ -95,7 +95,7 @@ class ServicePayGateway implements InjectionAwareInterface
{
$available = $this->getAvailable();
if (!in_array($code, $available)) {
- throw new \Box_Exception('Payment gateway is not available for installation.');
+ throw new \FOSSBilling\Exception('Payment gateway is not available for installation.');
}
$new = $this->di['db']->dispense('PayGateway');
@@ -249,7 +249,7 @@ class ServicePayGateway implements InjectionAwareInterface
$class = $this->getAdapterClassName($pg);
if (!class_exists($class)) {
- throw new \Box_Exception('Payment gateway :adapter was not found', [':adapter' => $class]);
+ throw new \FOSSBilling\Exception('Payment gateway :adapter was not found', [':adapter' => $class]);
}
$adapter = new $class($config);
@@ -278,12 +278,12 @@ class ServicePayGateway implements InjectionAwareInterface
$class = $this->getAdapterClassName($pg);
if (!file_exists(PATH_LIBRARY . '/Payment/Adapter/' . $pg->gateway . '.php')) {
if (!file_exists(PATH_LIBRARY . '/Payment/Adapter/' . $pg->gateway . '/' . $pg->gateway . '.php')) {
- throw new \Box_Exception('Payment gateway :adapter was not found', [':adapter' => $pg->gateway]);
+ throw new \FOSSBilling\Exception('Payment gateway :adapter was not found', [':adapter' => $pg->gateway]);
}
}
if (!class_exists($class)) {
- throw new \Box_Exception("Payment gateway class $class was not found");
+ throw new \FOSSBilling\Exception("Payment gateway class $class was not found");
}
if (!method_exists($class, 'getConfig')) {
diff --git a/src/modules/Invoice/ServiceTransaction.php b/src/modules/Invoice/ServiceTransaction.php
index 4ca932ff8..74b0a8222 100644
--- a/src/modules/Invoice/ServiceTransaction.php
+++ b/src/modules/Invoice/ServiceTransaction.php
@@ -79,11 +79,11 @@ class ServiceTransaction implements InjectionAwareInterface
$skip_validation = isset($data['skip_validation']) ? (bool) $data['skip_validation'] : false;
if (!$skip_validation) {
if (!isset($data['bb_invoice_id'])) {
- throw new \Box_Exception('Transaction invoice id is missing');
+ throw new \FOSSBilling\InformationException('Transaction invoice id is missing');
}
if (!isset($data['bb_gateway_id'])) {
- throw new \Box_Exception('Payment gateway id is missing');
+ throw new \FOSSBilling\InformationException('Payment gateway id is missing');
}
$this->di['db']->getExistingModelById('Invoice', $data['bb_invoice_id'], 'Invoice was not found');
$this->di['db']->getExistingModelById('PayGateway', $data['bb_gateway_id'], 'Gateway was not found');
@@ -314,7 +314,7 @@ class ServiceTransaction implements InjectionAwareInterface
{
try {
$output = $this->processTransaction($model->id);
- } catch (\Box_Exception $e) {
+ } catch (\FOSSBilling\Exception $e) {
$model->status = \Model_Transaction::STATUS_ERROR;
$model->error = $e->getMessage();
$model->error_code = $e->getCode();
@@ -337,29 +337,29 @@ class ServiceTransaction implements InjectionAwareInterface
*
* @param int $id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function processTransaction($id)
{
/** @var \Model_Transaction $tx */
$tx = $this->di['db']->load('Transaction', $id);
if (!$tx) {
- throw new \Box_Exception('Transaction :id not found.', ['id' => $id], 404);
+ throw new \FOSSBilling\Exception('Transaction :id not found.', ['id' => $id], 404);
}
if (empty($tx->gateway_id)) {
- throw new \Box_Exception('Could not determine transaction origin. Transaction payment gateway is unknown.', null, 701);
+ throw new \FOSSBilling\Exception('Could not determine transaction origin. Transaction payment gateway is unknown.', null, 701);
}
$gtw = $this->di['db']->load('PayGateway', $tx->gateway_id);
if (!$gtw instanceof \Model_PayGateway) {
- throw new \Box_Exception('Can not handle transaction received from unknown payment gateway: :id', [':id' => $tx->gateway_id], 704);
+ throw new \FOSSBilling\Exception('Can not handle transaction received from unknown payment gateway: :id', [':id' => $tx->gateway_id], 704);
}
$payGatewayService = $this->di['mod_service']('Invoice', 'PayGateway');
$adapter = $payGatewayService->getPaymentAdapter($gtw);
if (!method_exists($adapter, 'processTransaction')) {
- throw new \Box_Exception('Payment adapter :adapter does not support action :action', [':adapter' => $gtw->name, ':action' => 'processTransaction'], 705);
+ throw new \FOSSBilling\Exception('Payment adapter :adapter does not support action :action', [':adapter' => $gtw->name, ':action' => 'processTransaction'], 705);
}
$ipn = json_decode($tx->ipn, 1);
@@ -393,7 +393,7 @@ class ServiceTransaction implements InjectionAwareInterface
\Payment_Transaction::TXTYPE_REFUND => $this->_refund($transaction),
\Payment_Transaction::TXTYPE_SUBSCR_CREATE => $this->_subscribe($transaction),
\Payment_Transaction::TXTYPE_SUBSCR_CANCEL => $this->_unsubscribe($transaction),
- default => throw new \Box_Exception('Unknown transaction #:id type: :type', [':id' => $transaction->id, ':type' => $transaction->type], 632),
+ default => throw new \FOSSBilling\Exception('Unknown transaction #:id type: :type', [':id' => $transaction->id, ':type' => $transaction->type], 632),
};
} catch (\Exception $e) {
$transaction->status = \Model_Transaction::STATUS_ERROR;
@@ -468,12 +468,12 @@ class ServiceTransaction implements InjectionAwareInterface
$ipn = $this->di['tools']->decodeJ($tx->ipn);
if (empty($tx->gateway_id)) {
- throw new \Box_Exception('Could not determine transaction origin. Transaction payment gateway is unknown.', null, 701);
+ throw new \FOSSBilling\Exception('Could not determine transaction origin. Transaction payment gateway is unknown.', null, 701);
}
$gtw = $this->di['db']->load('PayGateway', $tx->gateway_id);
if (!$gtw instanceof \Model_PayGateway) {
- throw new \Box_Exception('Can not handle transaction received from unknown payment gateway: :id', [':id' => $tx->gateway_id], 704);
+ throw new \FOSSBilling\Exception('Can not handle transaction received from unknown payment gateway: :id', [':id' => $tx->gateway_id], 704);
}
$adapter = $payGatewayService->getPaymentAdapter($gtw);
@@ -482,12 +482,12 @@ class ServiceTransaction implements InjectionAwareInterface
}
if (!$tx->invoice_id) {
- throw new \Box_Exception('Transaction :id is not associated with an invoice.', [':id' => $tx->id], 702);
+ throw new \FOSSBilling\Exception('Transaction :id is not associated with an invoice.', [':id' => $tx->id], 702);
}
$invoice = $this->di['db']->load('Invoice', $tx->invoice_id);
if (!$invoice instanceof \Model_Invoice) {
- throw new \Box_Exception('Invoice #:id not found', [':id' => $tx->invoice_id], 703);
+ throw new \FOSSBilling\Exception('Invoice #:id not found', [':id' => $tx->invoice_id], 703);
}
$adapter = $payGatewayService->getPaymentAdapter($gtw, $invoice);
@@ -497,18 +497,18 @@ class ServiceTransaction implements InjectionAwareInterface
if (!$adapter->isIpnValid($ipn, $mpi)) {
$tx->output = $adapter->getOutput();
- throw new \Box_Exception('Instant payment notification (IPN) did not pass gateway :id validation', [':id' => $gtw->gateway], 706);
+ throw new \FOSSBilling\Exception('Instant payment notification (IPN) did not pass gateway :id validation', [':id' => $gtw->gateway], 706);
}
$tx->output = $adapter->getOutput();
}
if (!method_exists($adapter, 'getTransaction')) {
- throw new \Box_Exception('Payment adapter :adapter does not support action :action', [':adapter' => $gtw->name, ':action' => 'getTransaction'], 705);
+ throw new \FOSSBilling\Exception('Payment adapter :adapter does not support action :action', [':adapter' => $gtw->name, ':action' => 'getTransaction'], 705);
}
$response = $adapter->getTransaction($ipn, $mpi);
if (!$response instanceof \Payment_Transaction) {
- throw new \Box_Exception('Payment gateway :id method getTransaction should return Payment_Transaction object', [':id' => $gtw->gateway], 705);
+ throw new \FOSSBilling\Exception('Payment gateway :id method getTransaction should return Payment_Transaction object', [':id' => $gtw->gateway], 705);
}
// if tx type is already defined, do not set them again
@@ -561,7 +561,7 @@ class ServiceTransaction implements InjectionAwareInterface
$invoiceService = $this->di['mod_service']('Invoice');
$invoiceService->tryPayWithCredits($tx->Invoice);
} catch (\Exception $e) {
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
error_log($e->getMessage());
}
}
@@ -596,7 +596,7 @@ class ServiceTransaction implements InjectionAwareInterface
$this->_validateApprovedTransaction($tx);
if (empty($tx->s_id)) {
- throw new \Box_Exception('Can not create subscription. Subscription id from payment gateway was not received');
+ throw new \FOSSBilling\Exception('Can not create subscription. Subscription id from payment gateway was not received');
}
$invoice = $this->di['db']->load('Invoice', $tx->invoice_id);
@@ -631,7 +631,7 @@ class ServiceTransaction implements InjectionAwareInterface
$serviceSubscription = $this->di['mod_service']('Subscription');
$model = $this->di['db']->load('Subscription', $tx->s_id);
if (!$model instanceof \Model_Subscription) {
- throw new \Box_Exception('Subscription #:id was not found. Could not unsubscribe', [':id' => $tx->s_id]);
+ throw new \FOSSBilling\Exception('Subscription #:id was not found. Could not unsubscribe', [':id' => $tx->s_id]);
}
$serviceSubscription->unsubscribe($model);
@@ -644,23 +644,23 @@ class ServiceTransaction implements InjectionAwareInterface
private function _validateApprovedTransaction(\Model_Transaction $tx)
{
if ($tx->status != \Model_Transaction::STATUS_APPROVED) {
- throw new \Box_Exception('Only approved transaction can be processed');
+ throw new \FOSSBilling\Exception('Only approved transaction can be processed');
}
if (empty($tx->invoice_id)) {
- throw new \Box_Exception('Transaction :id is not associated with an invoice.', [':id' => $tx->id], 7022);
+ throw new \FOSSBilling\Exception('Transaction :id is not associated with an invoice.', [':id' => $tx->id], 7022);
}
$invoice = $this->di['db']->load('Invoice', $tx->invoice_id);
// check that payment currency is correct
if ($invoice->currency != $tx->currency) {
- throw new \Box_Exception('Transaction currency :code do not match required currency :required', [':code' => $tx->currency, ':required' => $invoice->currency], 709);
+ throw new \FOSSBilling\Exception('Transaction currency :code do not match required currency :required', [':code' => $tx->currency, ':required' => $invoice->currency], 709);
}
// check that payment status is completed if
if ($tx->txn_status == \Payment_Transaction::STATUS_PENDING) {
- throw new \Box_Exception('Transaction status on payment gateway is Pending. Only Complete or Unknown transactions can be processed.', null, 712);
+ throw new \FOSSBilling\Exception('Transaction status on payment gateway is Pending. Only Complete or Unknown transactions can be processed.', null, 712);
}
}
@@ -670,12 +670,12 @@ class ServiceTransaction implements InjectionAwareInterface
$client = $this->di['db']->load('Client', $proforma->client_id);
if ($client->currency != $proforma->currency) {
- throw new \Box_Exception('Client currency do not match invoice currency');
+ throw new \FOSSBilling\Exception('Client currency do not match invoice currency');
}
// do not debit negative or zero amount
if ($tx->amount < 0) {
- throw new \Box_Exception('Can not add negative amount to client balance for debit transaction');
+ throw new \FOSSBilling\Exception('Can not add negative amount to client balance for debit transaction');
}
$credit = $this->di['db']->dispense('ClientBalance');
diff --git a/src/modules/Kb/Api/Admin.php b/src/modules/Kb/Api/Admin.php
index 9984e56d1..ad72f0e86 100644
--- a/src/modules/Kb/Api/Admin.php
+++ b/src/modules/Kb/Api/Admin.php
@@ -52,7 +52,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->findOne('KbArticle', 'id = ?', [$data['id']]);
if (!$model instanceof \Model_KbArticle) {
- throw new \Box_Exception('Article not found');
+ throw new \FOSSBilling\Exception('Article not found');
}
return $this->getService()->toApiArray($model, true, $this->getIdentity());
@@ -126,7 +126,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->findOne('KbArticle', 'id = ?', [$data['id']]);
if (!$model instanceof \Model_KbArticle) {
- throw new \Box_Exception('Article not found');
+ throw new \FOSSBilling\Exception('Article not found');
}
$this->getService()->rm($model);
@@ -168,7 +168,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->findOne('KbArticleCategory', 'id = ?', [$data['id']]);
if (!$model instanceof \Model_KbArticleCategory) {
- throw new \Box_Exception('Article Category not found');
+ throw new \FOSSBilling\Exception('Article Category not found');
}
return $this->getService()->categoryToApiArray($model);
@@ -213,7 +213,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->findOne('KbArticleCategory', 'id = ?', [$data['id']]);
if (!$model instanceof \Model_KbArticleCategory) {
- throw new \Box_Exception('Article Category not found');
+ throw new \FOSSBilling\Exception('Article Category not found');
}
$title = $data['title'] ?? null;
@@ -238,7 +238,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->findOne('KbArticleCategory', 'id = ?', [$data['id']]);
if (!$model instanceof \Model_KbArticleCategory) {
- throw new \Box_Exception('Category not found');
+ throw new \FOSSBilling\Exception('Category not found');
}
return $this->getService()->categoryRm($model);
diff --git a/src/modules/Kb/Api/Guest.php b/src/modules/Kb/Api/Guest.php
index 5f0fb107a..4ea1eb152 100644
--- a/src/modules/Kb/Api/Guest.php
+++ b/src/modules/Kb/Api/Guest.php
@@ -50,7 +50,7 @@ class Guest extends \Api_Abstract
public function article_get($data)
{
if (!isset($data['id']) && !isset($data['slug'])) {
- throw new \Box_Exception('ID or slug is missing');
+ throw new \FOSSBilling\Exception('ID or slug is missing');
}
$id = $data['id'] ?? null;
@@ -64,7 +64,7 @@ class Guest extends \Api_Abstract
}
if (!$model instanceof \Model_KbArticle) {
- throw new \Box_Exception('Article item not found');
+ throw new \FOSSBilling\Exception('Article item not found');
}
$this->getService()->hitView($model);
@@ -112,7 +112,7 @@ class Guest extends \Api_Abstract
public function category_get($data)
{
if (!isset($data['id']) && !isset($data['slug'])) {
- throw new \Box_Exception('Category ID or slug is missing');
+ throw new \FOSSBilling\Exception('Category ID or slug is missing');
}
$id = $data['id'] ?? null;
@@ -126,7 +126,7 @@ class Guest extends \Api_Abstract
}
if (!$model instanceof \Model_KbArticleCategory) {
- throw new \Box_Exception('Knowledge base category not found');
+ throw new \FOSSBilling\Exception('Knowledge base category not found');
}
return $this->getService()->categoryToApiArray($model, $this->getIdentity());
diff --git a/src/modules/Kb/Service.php b/src/modules/Kb/Service.php
index 9fb550c98..4c627e754 100644
--- a/src/modules/Kb/Service.php
+++ b/src/modules/Kb/Service.php
@@ -144,7 +144,7 @@ class Service
$model = $this->di['db']->findOne('KbArticle', 'id = ?', [$id]);
if (!$model instanceof \Model_KbArticle) {
- throw new \Box_Exception('Article not found');
+ throw new \FOSSBilling\Exception('Article not found');
}
if (isset($articleCategoryId)) {
@@ -241,7 +241,7 @@ class Service
$articlesCount = $this->di['db']->getCell('SELECT count(*) as cnt FROM kb_article WHERE kb_article_category_id = :kb_article_category_id', $bindings);
if ($articlesCount > 0) {
- throw new \Box_Exception('Can not remove category which has articles');
+ throw new \FOSSBilling\InformationException('Can not remove category which has articles');
}
$id = $model->id;
diff --git a/src/modules/Massmailer/Api/Admin.php b/src/modules/Massmailer/Api/Admin.php
index f069b4fa5..b2ef22298 100644
--- a/src/modules/Massmailer/Api/Admin.php
+++ b/src/modules/Massmailer/Api/Admin.php
@@ -69,7 +69,7 @@ class Admin extends \Api_Abstract
if (isset($data['from_name'])) {
if (empty($data['from_name'])) {
- throw new \Box_Exception('Message from name can not be empty');
+ throw new \FOSSBilling\InformationException('Message from name can not be empty');
}
$model->from_name = $data['from_name'];
}
@@ -151,7 +151,7 @@ Order our services at {{ "order"|link }}
$client_id = $this->_getTestClientId();
if (empty($model->content)) {
- throw new \Box_Exception('Add some content before sending message');
+ throw new \FOSSBilling\InformationException('Add some content before sending message');
}
$this->getService()->sendMessage($model, $client_id);
@@ -172,7 +172,7 @@ Order our services at {{ "order"|link }}
$model = $this->_getMessage($data);
if (empty($model->content)) {
- throw new \Box_Exception('Add some content before sending message');
+ throw new \FOSSBilling\InformationException('Add some content before sending message');
}
$mod = $this->di['mod']('massmailer');
diff --git a/src/modules/Massmailer/Service.php b/src/modules/Massmailer/Service.php
index 0357fa6de..69e4bc54d 100644
--- a/src/modules/Massmailer/Service.php
+++ b/src/modules/Massmailer/Service.php
@@ -158,11 +158,11 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$extensionService = $this->di['mod_service']('extension');
if ($extensionService->isExtensionActive('mod', 'demo')) {
- throw new \Box_Exception('Disabled for security reasons (Demo mode enabled)');
+ throw new \FOSSBilling\InformationException('Disabled for security reasons (Demo mode enabled)');
}
if (!Environment::isProduction()) {
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
error_log('Skip email sending. Application ENV: ' . Environment::getCurrentEnvironment());
}
diff --git a/src/modules/News/Api/Admin.php b/src/modules/News/Api/Admin.php
index e5d41c756..ae57730e0 100644
--- a/src/modules/News/Api/Admin.php
+++ b/src/modules/News/Api/Admin.php
@@ -43,7 +43,7 @@ class Admin extends \Api_Abstract
public function get($data)
{
if (!isset($data['id']) && !isset($data['slug'])) {
- throw new \Box_Exception('ID or slug is missing');
+ throw new \FOSSBilling\Exception('ID or slug is missing');
}
$id = $data['id'] ?? null;
@@ -59,7 +59,7 @@ class Admin extends \Api_Abstract
}
if (!$model instanceof \Model_Post) {
- throw new \Box_Exception('News item not found');
+ throw new \FOSSBilling\Exception('News item not found');
}
return $this->getService()->toApiArray($model, 'admin');
diff --git a/src/modules/News/Api/Guest.php b/src/modules/News/Api/Guest.php
index e563cfbd9..ebf007146 100644
--- a/src/modules/News/Api/Guest.php
+++ b/src/modules/News/Api/Guest.php
@@ -44,7 +44,7 @@ class Guest extends \Api_Abstract
public function get($data)
{
if (!isset($data['id']) && !isset($data['slug'])) {
- throw new \Box_Exception('ID or slug is missing');
+ throw new \FOSSBilling\Exception('ID or slug is missing');
}
$id = $data['id'] ?? null;
@@ -57,7 +57,7 @@ class Guest extends \Api_Abstract
}
if (!$model || $model->status !== 'active') {
- throw new \Box_Exception('News item not found');
+ throw new \FOSSBilling\Exception('News item not found');
}
return $this->getService()->toApiArray($model);
diff --git a/src/modules/Notification/Api/Admin.php b/src/modules/Notification/Api/Admin.php
index 559f7dd5b..043484a97 100644
--- a/src/modules/Notification/Api/Admin.php
+++ b/src/modules/Notification/Api/Admin.php
@@ -39,7 +39,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get($data)
{
@@ -50,7 +50,7 @@ class Admin extends \Api_Abstract
$meta = $this->di['db']->load('extension_meta', $data['id']);
if ($meta->extension != 'mod_notification' || $meta->meta_key != 'message') {
- throw new \Box_Exception('Notification message was not found');
+ throw new \FOSSBilling\Exception('Notification message was not found');
}
return $this->getService()->toApiArray($meta);
@@ -77,7 +77,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function delete($data)
{
@@ -88,7 +88,7 @@ class Admin extends \Api_Abstract
$meta = $this->di['db']->load('extension_meta', $data['id']);
if ($meta->extension != 'mod_notification' || $meta->meta_key != 'message') {
- throw new \Box_Exception('Notification message was not found');
+ throw new \FOSSBilling\Exception('Notification message was not found');
}
$this->di['db']->trash($meta);
@@ -100,7 +100,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function delete_all()
{
diff --git a/src/modules/Order/Api/Admin.php b/src/modules/Order/Api/Admin.php
index b1aebc3d7..3f48b2b2d 100644
--- a/src/modules/Order/Api/Admin.php
+++ b/src/modules/Order/Api/Admin.php
@@ -163,7 +163,7 @@ class Admin extends \Api_Abstract
{
$order = $this->_getOrder($data);
if ($order->status != \Model_ClientOrder::STATUS_SUSPENDED) {
- throw new \Box_Exception('Only suspended orders can be unsuspended');
+ throw new \FOSSBilling\InformationException('Only suspended orders can be unsuspended');
}
return $this->getService()->unsuspendFromOrder($order);
@@ -195,7 +195,7 @@ class Admin extends \Api_Abstract
{
$order = $this->_getOrder($data);
if ($order->status != \Model_ClientOrder::STATUS_CANCELED) {
- throw new \Box_Exception('Only canceled orders can be uncanceled');
+ throw new \FOSSBilling\InformationException('Only canceled orders can be uncanceled');
}
return $this->getService()->uncancelFromOrder($order);
@@ -254,7 +254,7 @@ class Admin extends \Api_Abstract
$order = $this->_getOrder($data);
if (!isset($data['config']) || !is_array($data['config'])) {
- throw new \Box_Exception('Order config not passed');
+ throw new \FOSSBilling\Exception('Order config not passed');
}
$config = $data['config'];
diff --git a/src/modules/Order/Api/Client.php b/src/modules/Order/Api/Client.php
index 4f6462787..481b4f271 100644
--- a/src/modules/Order/Api/Client.php
+++ b/src/modules/Order/Api/Client.php
@@ -103,7 +103,7 @@ class Client extends \Api_Abstract
{
$model = $this->_getOrder($data);
if (!in_array($model->status, [\Model_ClientOrder::STATUS_PENDING_SETUP, \Model_ClientOrder::STATUS_FAILED_SETUP])) {
- throw new \Box_Exception('Only pending and failed setup orders can be deleted.');
+ throw new \FOSSBilling\InformationException('Only pending and failed setup orders can be deleted.');
}
return $this->getService()->deleteFromOrder($model);
@@ -118,7 +118,7 @@ class Client extends \Api_Abstract
$order = $this->getService()->findForClientById($this->getIdentity(), $data['id']);
if (!$order instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Order not found');
+ throw new \FOSSBilling\Exception('Order not found');
}
return $order;
diff --git a/src/modules/Order/Service.php b/src/modules/Order/Service.php
index 65aed621f..555acf9a7 100644
--- a/src/modules/Order/Service.php
+++ b/src/modules/Order/Service.php
@@ -495,7 +495,7 @@ class Service implements InjectionAwareInterface
$currency = $currencyService->getDefault();
}
if (!$currency instanceof \Model_Currency) {
- throw new \Box_Exception('Currency could not be determined for order');
+ throw new \FOSSBilling\Exception('Currency could not be determined for order');
}
$this->di['events_manager']->fire(['event' => 'onBeforeAdminOrderCreate', 'params' => $data, 'subject' => $product->type]);
@@ -511,19 +511,19 @@ class Service implements InjectionAwareInterface
$cartService = $this->di['mod_service']('cart');
// check stock
if (!$cartService->isStockAvailable($product, $qty)) {
- throw new \Box_Exception('Product :id is out of stock.', [':id' => $product->id], 831);
+ throw new \FOSSBilling\InformationException('Product :id is out of stock.', [':id' => $product->id], 831);
}
// Addons must have defined master order
$parent_order = false;
if ($product->is_addon && empty($group_id)) {
- throw new \Box_Exception('Group ID parameter is missing for addon product order', null, 832);
+ throw new \FOSSBilling\Exception('Group ID parameter is missing for addon product order', null, 832);
}
if (!empty($group_id)) {
$parent_order = $this->getMasterOrderForClient($client, $group_id);
if (!$parent_order instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Parent order :group_id was not found', [':group_id' => $group_id]);
+ throw new \FOSSBilling\Exception('Parent order :group_id was not found', [':group_id' => $group_id]);
}
}
@@ -673,7 +673,7 @@ class Service implements InjectionAwareInterface
];
if (!in_array($order->status, $statues)) {
if (!isset($data['force']) || !$data['force']) {
- throw new \Box_Exception('Only pending setup or failed orders can be activated');
+ throw new \FOSSBilling\Exception('Only pending setup or failed orders can be activated');
}
}
@@ -701,7 +701,7 @@ class Service implements InjectionAwareInterface
if (method_exists($s, 'create') || method_exists($s, 'action_create')) {
$service = $this->_callOnService($order, \Model_ClientOrder::ACTION_CREATE);
if (!is_object($service)) {
- throw new \Box_Exception('Error creating ' . $order->service_type . ' service for order ' . $order->id);
+ throw new \FOSSBilling\Exception('Error creating ' . $order->service_type . ' service for order ' . $order->id);
}
$order->service_id = $service->id;
@@ -770,7 +770,7 @@ class Service implements InjectionAwareInterface
if (in_array($order->service_type, $core_services)) {
$m = 'action_' . $action;
if (!method_exists($repo, $m) || !is_callable([$repo, $m])) {
- throw new \Box_Exception('Service ' . $order->service_type . ' do not support ' . $m);
+ throw new \FOSSBilling\Exception('Service ' . $order->service_type . ' do not support ' . $m);
}
return $repo->$m($order);
@@ -975,7 +975,7 @@ class Service implements InjectionAwareInterface
}
if ($order->status != \Model_ClientOrder::STATUS_ACTIVE) {
- throw new \Box_Exception('Only active orders can be suspended');
+ throw new \FOSSBilling\InformationException('Only active orders can be suspended');
}
$this->_callOnService($order, \Model_ClientOrder::ACTION_SUSPEND);
@@ -1027,7 +1027,7 @@ class Service implements InjectionAwareInterface
}
if (in_array($order->status, [\Model_ClientOrder::STATUS_CANCELED, \Model_ClientOrder::STATUS_PENDING_SETUP, \Model_ClientOrder::STATUS_FAILED_SETUP])) {
- throw new \Box_Exception('Can not cancel ' . $order->status . ' order');
+ throw new \FOSSBilling\Exception('Can not cancel ' . $order->status . ' order');
}
$this->_callOnService($order, \Model_ClientOrder::ACTION_CANCEL);
diff --git a/src/modules/Paidsupport/Service.php b/src/modules/Paidsupport/Service.php
index d6dd0cbd7..5c0666841 100644
--- a/src/modules/Paidsupport/Service.php
+++ b/src/modules/Paidsupport/Service.php
@@ -120,7 +120,7 @@ class Service implements InjectionAwareInterface
$clientBalance = $clientBalanceService->getClientBalance($client);
if ($this->getTicketPrice() > $clientBalance) {
- throw new \Box_Exception($this->getErrorMessage());
+ throw new \FOSSBilling\Exception($this->getErrorMessage());
}
return true;
diff --git a/src/modules/Product/Api/Admin.php b/src/modules/Product/Api/Admin.php
index a5aecdba2..4cf0237e1 100644
--- a/src/modules/Product/Api/Admin.php
+++ b/src/modules/Product/Api/Admin.php
@@ -78,7 +78,7 @@ class Admin extends \Api_Abstract
*
* @return int - new product id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function prepare($data)
{
@@ -93,13 +93,13 @@ class Admin extends \Api_Abstract
if ($data['type'] == 'domain') {
$model = $service->getMainDomainProduct();
if ($model instanceof \Model_Product) {
- throw new \Box_Exception('You have already created domain product.', null, 413);
+ throw new \FOSSBilling\InformationException('You have already created domain product.', null, 413);
}
}
$types = $service->getTypes();
if (!array_key_exists($data['type'], $types)) {
- throw new \Box_Exception('Product type :type is not registered', [':type' => $data['type']], 413);
+ throw new \FOSSBilling\Exception('Product type :type is not registered', [':type' => $data['type']], 413);
}
$categoryId = $data['product_category_id'] ?? null;
@@ -128,7 +128,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update($data)
{
@@ -143,12 +143,12 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update_priority($data)
{
if (!isset($data['priority']) || !is_array($data['priority'])) {
- throw new \Box_Exception('priority params is missing');
+ throw new \FOSSBilling\Exception('priority params is missing');
}
$service = $this->getService();
@@ -187,7 +187,7 @@ class Admin extends \Api_Abstract
*
* @return int - new addon id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function addon_create($data)
{
@@ -212,7 +212,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function addon_get($data)
{
@@ -223,7 +223,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->load('Product', $data['id']);
if (!$model instanceof \Model_Product || !$model->is_addon) {
- throw new \Box_Exception('Addon not found');
+ throw new \FOSSBilling\Exception('Addon not found');
}
$service = $this->getService();
@@ -251,7 +251,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function addon_update($data)
{
@@ -262,7 +262,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->load('Product', $data['id']);
if (!$model instanceof \Model_Product || !$model->is_addon) {
- throw new \Box_Exception('Addon not found');
+ throw new \FOSSBilling\Exception('Addon not found');
}
$this->di['logger']->info('Updated addon #%s', $model->id);
@@ -311,7 +311,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function category_update($data)
{
@@ -336,7 +336,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function category_get($data)
{
@@ -358,7 +358,7 @@ class Admin extends \Api_Abstract
*
* @return int - new category id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function category_create($data)
{
@@ -381,7 +381,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function category_delete($data)
{
@@ -430,7 +430,7 @@ class Admin extends \Api_Abstract
*
* @return int - new promo code id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function promo_create($data)
{
@@ -464,7 +464,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function promo_get($data)
{
@@ -497,7 +497,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function promo_update($data)
{
@@ -518,7 +518,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function promo_delete($data)
{
diff --git a/src/modules/Product/Api/Guest.php b/src/modules/Product/Api/Guest.php
index 382352e0b..f0237ea2c 100644
--- a/src/modules/Product/Api/Guest.php
+++ b/src/modules/Product/Api/Guest.php
@@ -60,12 +60,12 @@ class Guest extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get($data)
{
if (!isset($data['id']) && !isset($data['slug'])) {
- throw new \Box_Exception('Product ID or slug is missing');
+ throw new \FOSSBilling\Exception('Product ID or slug is missing');
}
$id = $data['id'] ?? null;
@@ -79,7 +79,7 @@ class Guest extends \Api_Abstract
}
if (!$model instanceof \Model_Product) {
- throw new \Box_Exception('Product not found');
+ throw new \FOSSBilling\Exception('Product not found');
}
return $service->toApiArray($model);
diff --git a/src/modules/Product/Service.php b/src/modules/Product/Service.php
index fff5c87ed..ec7db07af 100644
--- a/src/modules/Product/Service.php
+++ b/src/modules/Product/Service.php
@@ -203,7 +203,7 @@ class Service implements InjectionAwareInterface
$types = $this->getPaymentTypes();
if (!isset($data['pricing']['type']) || !array_key_exists($data['pricing']['type'], $types)) {
- throw new \Box_Exception('Pricing type is required');
+ throw new \FOSSBilling\InformationException('Pricing type is required');
}
$productPayment = $this->di['db']->getExistingModelById('ProductPayment', $model->product_payment_id, 'Product payment not found');
@@ -414,7 +414,7 @@ class Service implements InjectionAwareInterface
{
$orderService = $this->di['mod_service']('order');
if ($orderService->productHasOrders($product)) {
- throw new \Box_Exception('Can not remove product which has active orders.');
+ throw new \FOSSBilling\InformationException('Can not remove product which has active orders.');
}
$id = $product->id;
$this->di['db']->trash($product);
@@ -473,7 +473,7 @@ class Service implements InjectionAwareInterface
{
$model = $this->di['db']->findOne('Product', 'product_category_id = :category_id', [':category_id' => $category->id]);
if ($model instanceof \Model_Product) {
- throw new \Box_Exception('Can not remove product category with products');
+ throw new \FOSSBilling\InformationException('Can not remove product category with products');
}
$id = $category->id;
$this->di['db']->trash($category);
@@ -877,7 +877,7 @@ class Service implements InjectionAwareInterface
public function createPromo($code, $type, $value, $products, $periods, $clientGroups, $data)
{
if ($this->di['db']->findOne('Promo', 'code = :code', [':code' => $code])) {
- throw new \Box_Exception('This promotion code already exists.');
+ throw new \FOSSBilling\InformationException('This promotion code already exists.');
}
$systemService = $this->di['mod_service']('system');
diff --git a/src/modules/Profile/Api/Admin.php b/src/modules/Profile/Api/Admin.php
index 659185a43..15629d4a7 100644
--- a/src/modules/Profile/Api/Admin.php
+++ b/src/modules/Profile/Api/Admin.php
@@ -67,7 +67,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update($data)
{
@@ -93,7 +93,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function change_password($data)
{
@@ -107,13 +107,13 @@ class Admin extends \Api_Abstract
$validator->isPasswordStrong($data['new_password']);
if ($data['new_password'] != $data['confirm_password']) {
- throw new \Exception('Passwords do not match');
+ throw new \FOSSBilling\InformationException('Passwords do not match');
}
$staff = $this->getIdentity();
if (!$this->di['password']->verify($data['current_password'], $staff->pass)) {
- throw new \Exception('Current password incorrect');
+ throw new \FOSSBilling\InformationException('Current password incorrect');
}
$this->getService()->invalidateSessions();
diff --git a/src/modules/Profile/Api/Client.php b/src/modules/Profile/Api/Client.php
index 06ddf237b..4678f2ff3 100644
--- a/src/modules/Profile/Api/Client.php
+++ b/src/modules/Profile/Api/Client.php
@@ -63,7 +63,7 @@ class Client extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update($data)
{
@@ -97,7 +97,7 @@ class Client extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function change_password($data)
{
@@ -110,13 +110,13 @@ class Client extends \Api_Abstract
$this->di['validator']->isPasswordStrong($data['new_password']);
if ($data['new_password'] != $data['confirm_password']) {
- throw new \Exception('Passwords do not match');
+ throw new \FOSSBilling\InformationException('Passwords do not match');
}
$client = $this->getIdentity();
if (!$this->di['password']->verify($data['current_password'], $client->pass)) {
- throw new \Exception('Current password incorrect');
+ throw new \FOSSBilling\InformationException('Current password incorrect');
}
$this->getService()->invalidateSessions();
diff --git a/src/modules/Profile/Service.php b/src/modules/Profile/Service.php
index 6efd115b7..6d8d2a4ea 100644
--- a/src/modules/Profile/Service.php
+++ b/src/modules/Profile/Service.php
@@ -114,7 +114,7 @@ class Service implements InjectionAwareInterface
&& isset($config['disable_change_email'])
&& $config['disable_change_email']
) {
- throw new \Box_Exception('Email can not be changed');
+ throw new \FOSSBilling\InformationException('Email can not be changed');
}
if (!empty($email)) {
@@ -122,7 +122,7 @@ class Service implements InjectionAwareInterface
$clientService = $this->di['mod_service']('client');
if ($clientService->emailAlreadyRegistered($email, $client)) {
- throw new \Box_Exception('Can not change email. It is already registered.');
+ throw new \FOSSBilling\InformationException('Can not change email. It is already registered.');
}
$client->email = $email;
@@ -134,7 +134,7 @@ class Service implements InjectionAwareInterface
$birthday = $data['birthday'] ?? null;
if (strlen(trim($birthday)) > 0 && strtotime($birthday) === false) {
- throw new \Box_Exception('Invalid birthdate value');
+ throw new \FOSSBilling\InformationException('Invalid birthdate value');
}
$client->birthday = $birthday;
@@ -226,7 +226,7 @@ class Service implements InjectionAwareInterface
} elseif ($auth->isClientLoggedIn()) {
$type = 'client';
} else {
- throw new \Box_Exception('Unable to invalidate sessions, nobody is logged in');
+ throw new \FOSSBilling\Exception('Unable to invalidate sessions, nobody is logged in');
}
}
@@ -245,7 +245,7 @@ class Service implements InjectionAwareInterface
}
if ($type !== 'admin' && $type !== 'client') {
- throw new \Box_Exception('Unable to invalidate sessions, an invalid type was used');
+ throw new \FOSSBilling\Exception('Unable to invalidate sessions, an invalid type was used');
}
$sessions = $this->getSessions();
diff --git a/src/modules/Queue/Api/Admin.php b/src/modules/Queue/Api/Admin.php
index db3c0446f..b84cfe1f3 100644
--- a/src/modules/Queue/Api/Admin.php
+++ b/src/modules/Queue/Api/Admin.php
@@ -93,7 +93,7 @@ class Admin extends \Api_Abstract
$service = $mod->getService();
$handler = $data['handler'] ?? $data['queue'];
if (!method_exists($service, $handler)) {
- throw new \Box_Exception('Message handler function :method does not exists', [':ext' => $data['mod'], ':method' => $service::class . ':' . $handler]);
+ throw new \FOSSBilling\Exception('Message handler function :method does not exists', [':ext' => $data['mod'], ':method' => $service::class . ':' . $handler]);
}
$interval = isset($data['interval']) ? (int) $data['interval'] : 30;
diff --git a/src/modules/Redirect/Api/Admin.php b/src/modules/Redirect/Api/Admin.php
index eac2cef4b..656b275d6 100644
--- a/src/modules/Redirect/Api/Admin.php
+++ b/src/modules/Redirect/Api/Admin.php
@@ -128,7 +128,7 @@ class Admin extends \Api_Abstract
$bean = $this->di['db']->findOne('extension_meta', $sql, $values);
if (!$bean) {
- throw new \Box_Exception('Redirect not found');
+ throw new \FOSSBilling\Exception('Redirect not found');
}
return $bean;
diff --git a/src/modules/Serviceapikey/Service.php b/src/modules/Serviceapikey/Service.php
index c4195c14d..11e7cfbfe 100644
--- a/src/modules/Serviceapikey/Service.php
+++ b/src/modules/Serviceapikey/Service.php
@@ -51,7 +51,7 @@ class Service implements InjectionAwareInterface
{
$config = json_decode($order->config, 1);
if (!is_object($model)) {
- throw new \Box_Exception('Order does not exist.');
+ throw new \FOSSBilling\Exception('Order does not exist.');
}
$model->api_key = $this->generateKey($config);
@@ -113,12 +113,12 @@ class Service implements InjectionAwareInterface
public function isValid(array $data): bool
{
if (empty($data['key'])) {
- throw new \Box_Exception('You must provide an API key to check it\'s validity.');
+ throw new \FOSSBilling\Exception('You must provide an API key to check it\'s validity.');
}
$model = $this->di['db']->findOne('service_apikey', 'api_key = :api_key', [':api_key' => $data['key']]);
if (is_null($model)) {
- throw new \Box_Exception('API key does not exist');
+ throw new \FOSSBilling\Exception('API key does not exist');
}
return $this->isActive($model);
@@ -132,12 +132,12 @@ class Service implements InjectionAwareInterface
public function getInfo(array $data): array
{
if (empty($data['key'])) {
- throw new \Box_Exception('You must provide an API key to check it\'s validity.');
+ throw new \FOSSBilling\Exception('You must provide an API key to check it\'s validity.');
}
$model = $this->di['db']->findOne('service_apikey', 'api_key = :api_key', [':api_key' => $data['key']]);
if (is_null($model)) {
- throw new \Box_Exception('API key does not exist');
+ throw new \FOSSBilling\Exception('API key does not exist');
}
// Load the stored JSON config from the DB
@@ -177,7 +177,7 @@ class Service implements InjectionAwareInterface
public function resetApiKey(array $data): bool
{
if (empty($data['key']) && empty($data['order_id'])) {
- throw new \Box_Exception('You must provide either the API key or API key order ID in order to reset it.');
+ throw new \FOSSBilling\Exception('You must provide either the API key or API key order ID in order to reset it.');
} elseif (!empty($data['order_id'])) {
$order = $this->di['db']->getExistingModelById('ClientOrder', $data['order_id'], 'Order not found');
$orderService = $this->di['mod_service']('order');
@@ -187,7 +187,7 @@ class Service implements InjectionAwareInterface
}
if (is_null($model)) {
- throw new \Box_Exception('API key does not exist');
+ throw new \FOSSBilling\Exception('API key does not exist');
}
try {
@@ -198,7 +198,7 @@ class Service implements InjectionAwareInterface
}
if (!is_null($client) && $client->id !== $model->client_id) {
- throw new \Box_Exception('API key does not exist');
+ throw new \FOSSBilling\Exception('API key does not exist');
}
$config = json_decode($model->config, true);
@@ -220,7 +220,7 @@ class Service implements InjectionAwareInterface
public function updateApiKey(array $data): bool
{
if (empty($data['order_id'])) {
- throw new \Box_Exception('You must provide the API key order ID in order to update it.');
+ throw new \FOSSBilling\Exception('You must provide the API key order ID in order to update it.');
}
$order = $this->di['db']->getExistingModelById('ClientOrder', $data['order_id'], 'Order not found');
@@ -228,11 +228,11 @@ class Service implements InjectionAwareInterface
$model = $orderService->getOrderService($order);
if (is_null($model)) {
- throw new \Box_Exception('API key does not exist');
+ throw new \FOSSBilling\Exception('API key does not exist');
}
if (isset($data['api_key']) && $model->api_key !== $data['api_key']) {
- throw new \Box_Exception('To change the API key, please use the reset function rather than updating it.');
+ throw new \FOSSBilling\Exception('To change the API key, please use the reset function rather than updating it.');
}
$config = !empty($data['config']) ? json_encode($data['config']) : $model->config;
@@ -295,7 +295,7 @@ class Service implements InjectionAwareInterface
do {
// Try 10 times to generate a unique API key. Fail if we are unable to.
if ($i++ >= 10) {
- throw new \Box_Exception('Maximum number of iterations reached while generating API key');
+ throw new \FOSSBilling\Exception('Maximum number of iterations reached while generating API key');
}
// Generate random bytes half the length of the configured length, as the length will doubled when converted to a hex string.
@@ -330,7 +330,7 @@ class Service implements InjectionAwareInterface
break;
default:
- throw new \Box_Exception("Unknown uppercase option ':case:'. API generator only accepts 'lower', 'upper', or 'mixed'.", [':case:' => $case]);
+ throw new \FOSSBilling\Exception("Unknown uppercase option ':case:'. API generator only accepts 'lower', 'upper', or 'mixed'.", [':case:' => $case]);
}
} while ($this->di['db']->findOne('service_apikey', 'api_key = :api_key', [':api_key' => $apiKey]) !== null);
@@ -341,7 +341,7 @@ class Service implements InjectionAwareInterface
{
$order = $this->di['db']->findOne('ClientOrder', 'service_id = :id AND service_type = "apikey"', [':id' => $model->id]);
if (is_null($order)) {
- throw new \Box_Exception('API key does not exist');
+ throw new \FOSSBilling\Exception('API key does not exist');
}
return $order->status === 'active';
diff --git a/src/modules/Servicecustom/Api/Admin.php b/src/modules/Servicecustom/Api/Admin.php
index 486f9b896..34d846590 100644
--- a/src/modules/Servicecustom/Api/Admin.php
+++ b/src/modules/Servicecustom/Api/Admin.php
@@ -23,7 +23,7 @@ class Admin extends \Api_Abstract
public function update($data)
{
if (!isset($data['order_id'])) {
- throw new \Box_Exception('Order id is required');
+ throw new \FOSSBilling\Exception('Order id is required');
}
if (isset($data['config']) && is_array($data['config'])) {
@@ -37,18 +37,18 @@ class Admin extends \Api_Abstract
* Universal method to call method from plugin
* Pass any other params and they will be passed to plugin.
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function __call($name, $arguments)
{
if (!isset($arguments[0])) {
- throw new \Box_Exception('API call is missing arguments', null, 7103);
+ throw new \FOSSBilling\Exception('API call is missing arguments', null, 7103);
}
$data = $arguments[0];
if (!isset($data['order_id'])) {
- throw new \Box_Exception('Order id is required');
+ throw new \FOSSBilling\Exception('Order id is required');
}
$model = $this->getService()->getServiceCustomByOrderId($data['order_id']);
diff --git a/src/modules/Servicecustom/Api/Client.php b/src/modules/Servicecustom/Api/Client.php
index 5fa94ed3c..d8a10904f 100644
--- a/src/modules/Servicecustom/Api/Client.php
+++ b/src/modules/Servicecustom/Api/Client.php
@@ -19,18 +19,18 @@ class Client extends \Api_Abstract
* Universal method to call method from plugin
* Pass any other params and they will be passed to plugin.
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function __call($name, $arguments)
{
if (!isset($arguments[0])) {
- throw new \Box_Exception('API call is missing arguments', null, 7103);
+ throw new \FOSSBilling\Exception('API call is missing arguments', null, 7103);
}
$data = $arguments[0];
if (!isset($data['order_id'])) {
- throw new \Box_Exception('Order id is required');
+ throw new \FOSSBilling\Exception('Order id is required');
}
$model = $this->getService()->getServiceCustomByOrderId($data['order_id']);
diff --git a/src/modules/Servicecustom/Service.php b/src/modules/Servicecustom/Service.php
index cb182b48d..51808aa2b 100644
--- a/src/modules/Servicecustom/Service.php
+++ b/src/modules/Servicecustom/Service.php
@@ -35,14 +35,14 @@ class Service implements \FOSSBilling\InjectionAwareInterface
if ($field['required'] == 1) {
$field_name = $field['name'];
if (!isset($data[$field_name]) || empty($data[$field_name])) {
- throw new \Box_Exception('You must fill in all required fields. ' . $field['label'] . ' is missing', null, 9684);
+ throw new \FOSSBilling\InformationException('You must fill in all required fields. ' . $field['label'] . ' is missing', null, 9684);
}
}
if ($field['readonly'] == 1) {
$field_name = $field['name'];
if ($data[$field_name] != $field['default_value']) {
- throw new \Box_Exception('Field ' . $field['label'] . ' is read only. You can not change its value', null, 5468);
+ throw new \FOSSBilling\InformationException('Field ' . $field['label'] . ' is read only. You can not change its value', null, 5468);
}
}
}
@@ -76,7 +76,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Could not activate order. Service was not created', null, 7456);
+ throw new \FOSSBilling\Exception('Could not activate order. Service was not created', null, 7456);
}
$this->callOnAdapter($model, 'activate');
@@ -216,7 +216,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
'activate',
];
if (in_array($method, $forbidden_methods)) {
- throw new \Box_Exception('Custom plugin method :method is forbidden', [':method' => $method], 403);
+ throw new \FOSSBilling\Exception('Custom plugin method :method is forbidden', [':method' => $method], 403);
}
return $this->callOnAdapter($model, $method, $params);
@@ -225,7 +225,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
public function updateConfig($orderId, $config)
{
if (!is_array($config)) {
- throw new \Box_Exception('Config must be an array');
+ throw new \FOSSBilling\Exception('Config must be an array');
}
$model = $this->getServiceCustomByOrderId($orderId);
@@ -245,7 +245,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$s = $orderService->getOrderService($order);
if (!$s instanceof \Model_ServiceCustom) {
- throw new \Box_Exception('Order is not activated');
+ throw new \FOSSBilling\Exception('Order is not activated');
}
return $s;
@@ -262,7 +262,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
// check if plugin exists. If plugin does not exist, do not throw error. Simply add to log
$file = sprintf('Plugin/%s/%s.php', $plugin, $plugin);
if (!Environment::isTesting() && !file_exists(PATH_LIBRARY . DIRECTORY_SEPARATOR . $file)) {
- $e = new \Box_Exception('Plugin class file :file was not found', [':file' => $file], 3124);
+ $e = new \FOSSBilling\Exception('Plugin class file :file was not found', [':file' => $file], 3124);
if (BB_DEBUG) {
error_log($e->getMessage());
}
@@ -276,7 +276,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$adapter = new $plugin($config);
if (!method_exists($adapter, $method)) {
- throw new \Box_Exception('Plugin :plugin does not support action :action', [':plugin' => $plugin, ':action' => $method], 3125);
+ throw new \FOSSBilling\Exception('Plugin :plugin does not support action :action', [':plugin' => $plugin, ':action' => $method], 3125);
}
$orderService = $this->di['mod_service']('order');
@@ -292,7 +292,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]);
+ throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]);
}
return $model;
diff --git a/src/modules/Servicedomain/Api/Admin.php b/src/modules/Servicedomain/Api/Admin.php
index a53016258..68aff7869 100644
--- a/src/modules/Servicedomain/Api/Admin.php
+++ b/src/modules/Servicedomain/Api/Admin.php
@@ -148,7 +148,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function tld_get($data)
{
@@ -164,7 +164,7 @@ class Admin extends \Api_Abstract
$model = $this->getService()->tldFindOneByTld($tld);
if (!$model instanceof \Model_Tld) {
- throw new \Box_Exception('TLD not found');
+ throw new \FOSSBilling\Exception('TLD not found');
}
return $this->getService()->tldToApiArray($model);
@@ -175,7 +175,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function tld_get_id($data)
{
@@ -186,7 +186,7 @@ class Admin extends \Api_Abstract
$model = $this->getService()->tldFindOneById($data['id']);
if (!$model instanceof \Model_Tld) {
- throw new \Box_Exception('ID not found');
+ throw new \FOSSBilling\Exception('ID not found');
}
return $this->getService()->tldToApiArray($model);
@@ -197,7 +197,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function tld_delete($data)
{
@@ -209,13 +209,13 @@ class Admin extends \Api_Abstract
$model = $this->getService()->tldFindOneByTld($data['tld']);
if (!$model instanceof \Model_Tld) {
- throw new \Box_Exception('TLD not found');
+ throw new \FOSSBilling\Exception('TLD not found');
}
// check if tld is used by any domain
$service_domains = $this->di['db']->find('ServiceDomain', 'tld = ?', ['tld' => $model->tld]);
$count = is_countable($service_domains) ? count($service_domains) : 0;
if ($count > 0) {
- throw new \Box_Exception('TLD is used by :count: domains', [':count:' => $count], 707);
+ throw new \FOSSBilling\InformationException('TLD is used by :count: domains', [':count:' => $count], 707);
}
return $this->getService()->tldRm($model);
@@ -226,7 +226,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function tld_create($data)
{
@@ -240,7 +240,7 @@ class Admin extends \Api_Abstract
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if ($this->getService()->tldAlreadyRegistered($data['tld'])) {
- throw new \Box_Exception('Tld already registered');
+ throw new \FOSSBilling\InformationException('Tld already registered');
}
return $this->getService()->tldCreate($data);
@@ -256,7 +256,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function tld_update($data)
{
@@ -267,7 +267,7 @@ class Admin extends \Api_Abstract
$model = $this->getService()->tldFindOneByTld($data['tld']);
if (!$model instanceof \Model_Tld) {
- throw new \Box_Exception('TLD not found');
+ throw new \FOSSBilling\Exception('TLD not found');
}
return $this->getService()->tldUpdate($model, $data);
@@ -330,7 +330,7 @@ class Admin extends \Api_Abstract
$code = $data['code'];
if (!in_array($code, $this->getService()->registrarGetAvailable())) {
- throw new \Box_Exception('Registrar is not available for installation.');
+ throw new \FOSSBilling\Exception('Registrar is not available for installation.');
}
return $this->getService()->registrarCreate($data['code']);
@@ -357,7 +357,7 @@ class Admin extends \Api_Abstract
$count = is_array($service_domains) ? count($service_domains) : 0; // Handle the case where $service_domains might be null
if ($count > 0) {
- throw new \Box_Exception('Registrar is used by :count: domains', [':count:' => $count], 707);
+ throw new \FOSSBilling\InformationException('Registrar is used by :count: domains', [':count:' => $count], 707);
}
return $this->getService()->registrarRm($model);
@@ -443,7 +443,7 @@ class Admin extends \Api_Abstract
$s = $orderService->getOrderService($order);
if (!$s instanceof \Model_ServiceDomain) {
- throw new \Box_Exception('Domain order is not activated');
+ throw new \FOSSBilling\Exception('Domain order is not activated');
}
return $s;
diff --git a/src/modules/Servicedomain/Api/Client.php b/src/modules/Servicedomain/Api/Client.php
index 3338f5191..18797a487 100644
--- a/src/modules/Servicedomain/Api/Client.php
+++ b/src/modules/Servicedomain/Api/Client.php
@@ -113,18 +113,18 @@ class Client extends \Api_Abstract
protected function _getService($data)
{
if (!isset($data['order_id'])) {
- throw new \Box_Exception('Order id is required');
+ throw new \FOSSBilling\Exception('Order id is required');
}
$orderService = $this->di['mod_service']('order');
$order = $orderService->findForClientById($this->getIdentity(), $data['order_id']);
if (!$order instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Order not found');
+ throw new \FOSSBilling\Exception('Order not found');
}
$s = $orderService->getOrderService($order);
if (!$s instanceof \Model_ServiceDomain) {
- throw new \Box_Exception('Order is not activated');
+ throw new \FOSSBilling\Exception('Order is not activated');
}
return $s;
diff --git a/src/modules/Servicedomain/Api/Guest.php b/src/modules/Servicedomain/Api/Guest.php
index a436f298c..9ffe4149c 100644
--- a/src/modules/Servicedomain/Api/Guest.php
+++ b/src/modules/Servicedomain/Api/Guest.php
@@ -64,7 +64,7 @@ class Guest extends \Api_Abstract
$model = $this->getService()->tldFindOneByTld($data['tld']);
if (!$model instanceof \Model_Tld) {
- throw new \Box_Exception('TLD not found');
+ throw new \FOSSBilling\Exception('TLD not found');
}
return $this->getService()->tldToApiArray($model);
@@ -87,16 +87,16 @@ class Guest extends \Api_Abstract
$sld = htmlspecialchars($data['sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8');
$validator = $this->di['validator'];
if (!$validator->isSldValid($sld)) {
- throw new \Box_Exception('Domain :domain is invalid', [':domain' => $sld]);
+ throw new \FOSSBilling\InformationException('Domain :domain is invalid', [':domain' => $sld]);
}
$tld = $this->getService()->tldFindOneByTld($data['tld']);
if (!$tld instanceof \Model_Tld) {
- throw new \Box_Exception('Domain availability could not be determined. TLD is not active.');
+ throw new \FOSSBilling\InformationException('Domain availability could not be determined. TLD is not active.');
}
if (!$this->getService()->isDomainAvailable($tld, $sld)) {
- throw new \Box_Exception('Domain is not available.');
+ throw new \FOSSBilling\InformationException('Domain is not available.');
}
return true;
@@ -118,10 +118,10 @@ class Guest extends \Api_Abstract
$tld = $this->getService()->tldFindOneByTld($data['tld']);
if (!$tld instanceof \Model_Tld) {
- throw new \Box_Exception('TLD is not active.');
+ throw new \FOSSBilling\InformationException('TLD is not active.');
}
if (!$this->getService()->canBeTransferred($tld, $data['sld'])) {
- throw new \Box_Exception('Domain can not be transferred.');
+ throw new \FOSSBilling\InformationException('Domain can not be transferred.');
}
return true;
diff --git a/src/modules/Servicedomain/Service.php b/src/modules/Servicedomain/Service.php
index fe4577911..c70a09563 100644
--- a/src/modules/Servicedomain/Service.php
+++ b/src/modules/Servicedomain/Service.php
@@ -52,18 +52,18 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$action = $data['action'];
if (!in_array($action, ['register', 'transfer', 'owndomain'])) {
- throw new \Box_Exception('Invalid domain action.');
+ throw new \FOSSBilling\Exception('Invalid domain action.');
}
if ($action == 'owndomain') {
if (!isset($data['owndomain_sld'])) {
- throw new \Box_Exception('Order data must contain :field configuration field', [':field' => 'owndomain_sld']);
+ throw new \FOSSBilling\Exception('Order data must contain :field configuration field', [':field' => 'owndomain_sld']);
}
if (!$validator->isSldValid($data['owndomain_sld'])) {
$safe_dom = htmlspecialchars($data['owndomain_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8');
- throw new \Box_Exception('Domain name :domain is invalid', [':domain' => $safe_dom]);
+ throw new \FOSSBilling\InformationException('Domain name :domain is invalid', [':domain' => $safe_dom]);
}
$required = [
@@ -75,13 +75,13 @@ class Service implements \FOSSBilling\InjectionAwareInterface
if ($action == 'transfer') {
if (!isset($data['transfer_sld'])) {
- throw new \Box_Exception('Order data must contain :field configuration field', [':field' => 'transfer_sld']);
+ throw new \FOSSBilling\InformationException('Order data must contain :field configuration field', [':field' => 'transfer_sld']);
}
if (!$validator->isSldValid($data['transfer_sld'])) {
$safe_dom = htmlspecialchars($data['transfer_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8');
- throw new \Box_Exception('Domain name :domain is invalid', [':domain' => $safe_dom]);
+ throw new \FOSSBilling\InformationException('Domain name :domain is invalid', [':domain' => $safe_dom]);
}
$required = [
@@ -92,12 +92,12 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$tld = $this->tldFindOneByTld($data['transfer_tld']);
if (!$tld instanceof \Model_Tld) {
- throw new \Box_Exception('TLD not found');
+ throw new \FOSSBilling\Exception('TLD not found');
}
$domain = $data['transfer_sld'] . $tld->tld;
if (!$this->canBeTransferred($tld, $data['transfer_sld'])) {
- throw new \Box_Exception(':domain can not be transferred!', [':domain' => $domain]);
+ throw new \FOSSBilling\InformationException(':domain can not be transferred!', [':domain' => $domain]);
}
// return by reference
@@ -107,13 +107,13 @@ class Service implements \FOSSBilling\InjectionAwareInterface
if ($action == 'register') {
if (!isset($data['register_sld'])) {
- throw new \Box_Exception('Order data must contain :field configuration field', [':field' => 'register_sld']);
+ throw new \FOSSBilling\InformationException('Order data must contain :field configuration field', [':field' => 'register_sld']);
}
if (!$validator->isSldValid($data['register_sld'])) {
$safe_dom = htmlspecialchars($data['register_sld'], ENT_QUOTES | ENT_HTML5, 'UTF-8');
- throw new \Box_Exception('Domain name :domain is invalid', [':domain' => $safe_dom]);
+ throw new \FOSSBilling\InformationException('Domain name :domain is invalid', [':domain' => $safe_dom]);
}
$required = [
@@ -125,17 +125,17 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$tld = $this->tldFindOneByTld($data['register_tld']);
if (!$tld instanceof \Model_Tld) {
- throw new \Box_Exception('TLD not found');
+ throw new \FOSSBilling\Exception('TLD not found');
}
$years = (int) $data['register_years'];
if ($years < $tld->min_years) {
- throw new \Box_Exception(':tld can be registered for at least :years years', [':tld' => $tld->tld, ':years' => $tld->min_years]);
+ throw new \FOSSBilling\Exception(':tld can be registered for at least :years years', [':tld' => $tld->tld, ':years' => $tld->min_years]);
}
$domain = $data['register_sld'] . $tld->tld;
if (!$this->isDomainAvailable($tld, $data['register_sld'])) {
- throw new \Box_Exception(':domain is already registered!', [':domain' => $domain]);
+ throw new \FOSSBilling\InformationException(':domain is already registered!', [':domain' => $domain]);
}
// return by reference
@@ -163,7 +163,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$systemService = $this->di['mod_service']('system');
$ns = $systemService->getNameservers();
if (empty($ns)) {
- throw new \Box_Exception('Default domain nameservers are not configured');
+ throw new \FOSSBilling\InformationException('Default domain nameservers are not configured');
}
$tldModel = $this->tldFindOneByTld($tld);
@@ -215,7 +215,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \Model_ServiceDomain) {
- throw new \Box_Exception('Could not activate order. Service was not created');
+ throw new \FOSSBilling\Exception('Could not activate order. Service was not created');
}
// @adapterAction
@@ -249,7 +249,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]);
+ throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]);
}
// @adapterAction
[$domain, $adapter] = $this->_getD($model);
@@ -288,7 +288,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]);
+ throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]);
}
// @adapterAction
[$domain, $adapter] = $this->_getD($model);
@@ -364,10 +364,10 @@ class Service implements \FOSSBilling\InjectionAwareInterface
public function updateNameservers(\Model_ServiceDomain $model, $data)
{
if (!isset($data['ns1'])) {
- throw new \Box_Exception('Nameserver 1 is required');
+ throw new \FOSSBilling\InformationException('Nameserver 1 is required');
}
if (!isset($data['ns2'])) {
- throw new \Box_Exception('Nameserver 2 is required');
+ throw new \FOSSBilling\InformationException('Nameserver 2 is required');
}
$ns1 = $data['ns1'];
@@ -521,11 +521,11 @@ class Service implements \FOSSBilling\InjectionAwareInterface
public function canBeTransferred(\Model_Tld $model, $sld)
{
if (empty($sld)) {
- throw new \Box_Exception('Domain name is invalid');
+ throw new \FOSSBilling\InformationException('Domain name is invalid');
}
if (!$model->allow_transfer) {
- throw new \Box_Exception('Domain can not be transferred', null, 403);
+ throw new \FOSSBilling\InformationException('Domain can not be transferred', null, 403);
}
// @adapterAction
@@ -542,18 +542,18 @@ class Service implements \FOSSBilling\InjectionAwareInterface
public function isDomainAvailable(\Model_Tld $model, $sld)
{
if (empty($sld)) {
- throw new \Box_Exception('Domain name is invalid');
+ throw new \FOSSBilling\InformationException('Domain name is invalid');
}
$validator = $this->di['validator'];
if (!$validator->isSldValid($sld)) {
$safe_dom = htmlspecialchars($sld, ENT_QUOTES | ENT_HTML5, 'UTF-8');
- throw new \Box_Exception('Domain name :domain is invalid', [':domain' => $safe_dom]);
+ throw new \FOSSBilling\InformationException('Domain name :domain is invalid', [':domain' => $safe_dom]);
}
if (!$model->allow_register) {
- throw new \Box_Exception('Domain can not be registered', null, 403);
+ throw new \FOSSBilling\InformationException('Domain can not be registered', null, 403);
}
// @adapterAction
@@ -945,12 +945,12 @@ class Service implements \FOSSBilling\InjectionAwareInterface
private function registrarGetRegistrarAdapterClassName(\Model_TldRegistrar $model)
{
if (!file_exists(PATH_LIBRARY . '/Registrar/Adapter/' . $model->registrar . '.php')) {
- throw new \Box_Exception('Domain registrar :adapter was not found', [':adapter' => $model->registrar]);
+ throw new \FOSSBilling\Exception('Domain registrar :adapter was not found', [':adapter' => $model->registrar]);
}
$class = sprintf('Registrar_Adapter_%s', $model->registrar);
if (!class_exists($class)) {
- throw new \Box_Exception('Registrar :adapter was not found', [':adapter' => $class]);
+ throw new \FOSSBilling\Exception('Registrar :adapter was not found', [':adapter' => $class]);
}
return $class;
@@ -962,7 +962,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$class = $this->registrarGetRegistrarAdapterClassName($r);
$registrar = new $class($config);
if (!$registrar instanceof \Registrar_AdapterAbstract) {
- throw new \Box_Exception('Registrar adapter :adapter should extend Registrar_AdapterAbstract', [':adapter' => $class]);
+ throw new \FOSSBilling\Exception('Registrar adapter :adapter should extend Registrar_AdapterAbstract', [':adapter' => $class]);
}
$registrar->setLog($this->di['logger']);
@@ -1025,7 +1025,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
{
$domains = $this->di['db']->find('ServiceDomain', 'tld_registrar_id = :registrar_id', [':registrar_id' => $model->id]);
if ((is_countable($domains) ? count($domains) : 0) > 0) {
- throw new \Box_Exception('Can not remove registrar which has domains');
+ throw new \FOSSBilling\InformationException('Can not remove registrar which has domains');
}
$name = $model->name;
diff --git a/src/modules/Servicedownloadable/Api/Admin.php b/src/modules/Servicedownloadable/Api/Admin.php
index e2d369288..ccf404367 100644
--- a/src/modules/Servicedownloadable/Api/Admin.php
+++ b/src/modules/Servicedownloadable/Api/Admin.php
@@ -32,7 +32,7 @@ class Admin extends \Api_Abstract
$model = $this->di['db']->getExistingModelById('Product', $data['id'], 'Product not found');
if (!isset($_FILES['file_data'])) {
- throw new \Box_Exception('File was not uploaded');
+ throw new \FOSSBilling\Exception('File was not uploaded');
}
$service = $this->getService();
@@ -61,7 +61,7 @@ class Admin extends \Api_Abstract
$orderService = $this->di['mod_service']('order');
$serviceDownloadable = $orderService->getOrderService($order);
if (!$serviceDownloadable instanceof \Model_ServiceDownloadable) {
- throw new \Box_Exception('Order is not activated');
+ throw new \FOSSBilling\Exception('Order is not activated');
}
$service = $this->getService();
diff --git a/src/modules/Servicedownloadable/Api/Client.php b/src/modules/Servicedownloadable/Api/Client.php
index e1616a7c8..eec670e63 100644
--- a/src/modules/Servicedownloadable/Api/Client.php
+++ b/src/modules/Servicedownloadable/Api/Client.php
@@ -24,18 +24,18 @@ class Client extends \Api_Abstract
public function send_file($data)
{
if (!isset($data['order_id'])) {
- throw new \Box_Exception('Order id is required');
+ throw new \FOSSBilling\Exception('Order id is required');
}
$identity = $this->getIdentity();
$order = $this->di['db']->findOne('ClientOrder', 'id = :id AND client_id = :client_id', [':id' => $data['order_id'], ':client_id' => $identity->id]);
if (!$order instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Order not found');
+ throw new \FOSSBilling\Exception('Order not found');
}
$orderService = $this->di['mod_service']('order');
$s = $orderService->getOrderService($order);
if (!$s instanceof \Model_ServiceDownloadable || $order->status !== 'active') {
- throw new \Box_Exception('Order is not activated');
+ throw new \FOSSBilling\Exception('Order is not activated');
}
$service = $this->getService();
diff --git a/src/modules/Servicedownloadable/Service.php b/src/modules/Servicedownloadable/Service.php
index 3477a5252..3d6b5cf33 100644
--- a/src/modules/Servicedownloadable/Service.php
+++ b/src/modules/Servicedownloadable/Service.php
@@ -56,7 +56,7 @@ class Service implements InjectionAwareInterface
{
$c = json_decode($order->config, 1);
if (!is_array($c)) {
- throw new \Box_Exception(sprintf('Order #%s config is missing', $order->id));
+ throw new \FOSSBilling\Exception(sprintf('Order #%s config is missing', $order->id));
}
$this->validateOrderData($c);
@@ -166,7 +166,7 @@ class Service implements InjectionAwareInterface
{
$request = $this->di['request'];
if ($request->hasFiles() == 0) {
- throw new \Box_Exception('Error uploading file');
+ throw new \FOSSBilling\Exception('Error uploading file');
}
$files = $request->getUploadedFiles();
$file = $files[0];
@@ -213,13 +213,13 @@ class Service implements InjectionAwareInterface
/**
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function updateProductFile(\Model_ServiceDownloadable $serviceDownloadable, \Model_ClientOrder $order)
{
$request = $this->di['request'];
if ($request->hasFiles() == 0) {
- throw new \Box_Exception('Error uploading file');
+ throw new \FOSSBilling\Exception('Error uploading file');
}
$productService = $this->di['mod_service']('product');
$files = $request->getUploadedFiles();
@@ -272,7 +272,7 @@ class Service implements InjectionAwareInterface
$filename = $info['filename'];
$path = $info['path'];
if (!file_exists($path)) {
- throw new \Box_Exception('File can not be downloaded at the moment. Please contact support', null, 404);
+ throw new \FOSSBilling\Exception('File can not be downloaded at the moment. Please contact support', null, 404);
}
$this->hitDownload($serviceDownloadable);
$this->sendDownload($filename, $path);
diff --git a/src/modules/Servicehosting/Api/Admin.php b/src/modules/Servicehosting/Api/Admin.php
index e2101fae6..2e64a1b1b 100644
--- a/src/modules/Servicehosting/Api/Admin.php
+++ b/src/modules/Servicehosting/Api/Admin.php
@@ -23,7 +23,7 @@ class Admin extends \Api_Abstract
public function change_plan($data)
{
if (!isset($data['plan_id'])) {
- throw new \Box_Exception('plan_id is missing');
+ throw new \FOSSBilling\Exception('plan_id is missing');
}
[$order, $s] = $this->_getService($data);
@@ -175,7 +175,7 @@ class Admin extends \Api_Abstract
*
* @return int - server id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function server_create($data)
{
@@ -196,7 +196,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function server_get($data)
{
@@ -216,7 +216,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function server_delete($data)
{
@@ -232,7 +232,7 @@ class Admin extends \Api_Abstract
$count = is_array($hosting_services) ? count($hosting_services) : 0; // Handle the case where $hosting_services might be null
if ($count > 0) {
- throw new \Box_Exception('Hosting server is used by :count: service hostings', [':count:' => $count], 704);
+ throw new \FOSSBilling\InformationException('Hosting server is used by :count: service hostings', [':count:' => $count], 704);
}
return (bool) $this->getService()->deleteServer($model);
@@ -256,7 +256,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function server_update($data)
{
@@ -280,7 +280,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function server_test_connection($data)
{
@@ -327,7 +327,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\InformationException
*/
public function hp_delete($data)
{
@@ -344,7 +344,7 @@ class Admin extends \Api_Abstract
// Ensure $hosting_services is an array before counting its elements
$count = is_array($hosting_services) ? count($hosting_services) : 0; // Handle the case where $hosting_services might be null
if ($count > 0) {
- throw new \Box_Exception('Hosting plan is used by :count: service hostings', [':count:' => $count], 704);
+ throw new \FOSSBilling\InformationException('Hosting plan is used by :count: service hostings', [':count:' => $count], 704);
}
return (bool) $this->getService()->deleteHp($model);
@@ -355,7 +355,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function hp_get($data)
{
@@ -376,7 +376,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function hp_update($data)
{
@@ -397,7 +397,7 @@ class Admin extends \Api_Abstract
*
* @return int - new hosting plan id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function hp_create($data)
{
@@ -422,7 +422,7 @@ class Admin extends \Api_Abstract
$orderService = $this->di['mod_service']('order');
$s = $orderService->getOrderService($order);
if (!$s instanceof \Model_ServiceHosting) {
- throw new \Box_Exception('Order is not activated');
+ throw new \FOSSBilling\Exception('Order is not activated');
}
return [$order, $s];
diff --git a/src/modules/Servicehosting/Api/Client.php b/src/modules/Servicehosting/Api/Client.php
index b8fe45861..baa599cf4 100644
--- a/src/modules/Servicehosting/Api/Client.php
+++ b/src/modules/Servicehosting/Api/Client.php
@@ -64,18 +64,18 @@ class Client extends \Api_Abstract
public function _getService($data)
{
if (!isset($data['order_id'])) {
- throw new \Box_Exception('Order id is required');
+ throw new \FOSSBilling\Exception('Order id is required');
}
$identity = $this->getIdentity();
$order = $this->di['db']->findOne('ClientOrder', 'id = ? and client_id = ?', [$data['order_id'], $identity->id]);
if (!$order instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Order not found');
+ throw new \FOSSBilling\Exception('Order not found');
}
$orderService = $this->di['mod_service']('order');
$s = $orderService->getOrderService($order);
if (!$s instanceof \Model_ServiceHosting) {
- throw new \Box_Exception('Order is not activated');
+ throw new \FOSSBilling\Exception('Order is not activated');
}
return [$order, $s];
diff --git a/src/modules/Servicehosting/Api/Guest.php b/src/modules/Servicehosting/Api/Guest.php
index 1dcff8756..3deac02e5 100644
--- a/src/modules/Servicehosting/Api/Guest.php
+++ b/src/modules/Servicehosting/Api/Guest.php
@@ -20,7 +20,7 @@ class Guest extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function free_tlds($data = [])
{
@@ -35,7 +35,7 @@ class Guest extends \Api_Abstract
if ($product->type !== \Model_Product::HOSTING) {
$friendlyName = ucfirst(__trans('Product type'));
- throw new \Box_Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]);
+ throw new \FOSSBilling\Exception(':friendlyName: is invalid', [':friendlyName:' => $friendlyName]);
}
return $this->getService()->getFreeTlds($product);
diff --git a/src/modules/Servicehosting/Service.php b/src/modules/Servicehosting/Service.php
index a5b608a07..41e41f4f3 100644
--- a/src/modules/Servicehosting/Service.php
+++ b/src/modules/Servicehosting/Service.php
@@ -43,16 +43,16 @@ class Service implements InjectionAwareInterface
public function validateOrderData(array &$data)
{
if (!isset($data['server_id'])) {
- throw new \Box_Exception('Hosting product is not configured completely. Configure server for hosting product.', null, 701);
+ throw new \FOSSBilling\InformationException('Hosting product is not configured completely. Configure server for hosting product.', null, 701);
}
if (!isset($data['hosting_plan_id'])) {
- throw new \Box_Exception('Hosting product is not configured completely. Configure hosting plan for hosting product.', null, 702);
+ throw new \FOSSBilling\InformationException('Hosting product is not configured completely. Configure hosting plan for hosting product.', null, 702);
}
if (!isset($data['sld']) || empty($data['sld'])) {
- throw new \Box_Exception('Domain name is invalid.', null, 703);
+ throw new \FOSSBilling\InformationException('Domain name is invalid.', null, 703);
}
if (!isset($data['tld']) || empty($data['tld'])) {
- throw new \Box_Exception('Domain extension is invalid.', null, 704);
+ throw new \FOSSBilling\InformationException('Domain extension is invalid.', null, 704);
}
}
@@ -91,7 +91,7 @@ class Service implements InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]);
+ throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]);
}
$pass = $this->di['tools']->generatePassword(10, 4);
@@ -136,7 +136,7 @@ class Service implements InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]);
+ throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]);
}
// @todo ?
@@ -154,7 +154,7 @@ class Service implements InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]);
+ throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]);
}
[$adapter, $account] = $this->_getAM($model);
$adapter->suspendAccount($account);
@@ -173,7 +173,7 @@ class Service implements InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]);
+ throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]);
}
[$adapter, $account] = $this->_getAM($model);
$adapter->unsuspendAccount($account);
@@ -192,7 +192,7 @@ class Service implements InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$model = $orderService->getOrderService($order);
if (!$model instanceof \RedBeanPHP\SimpleModel) {
- throw new \Box_Exception('Order :id has no active service', [':id' => $order->id]);
+ throw new \FOSSBilling\Exception('Order :id has no active service', [':id' => $order->id]);
}
[$adapter, $account] = $this->_getAM($model);
$adapter->cancelAccount($account);
@@ -252,7 +252,7 @@ class Service implements InjectionAwareInterface
public function changeAccountUsername(\Model_ClientOrder $order, \Model_ServiceHosting $model, $data)
{
if (!isset($data['username']) || empty($data['username'])) {
- throw new \Box_Exception('Account username is missing or is invalid');
+ throw new \FOSSBilling\InformationException('Account username is missing or is invalid');
}
$u = strtolower($data['username']);
@@ -274,7 +274,7 @@ class Service implements InjectionAwareInterface
public function changeAccountIp(\Model_ClientOrder $order, \Model_ServiceHosting $model, $data)
{
if (!isset($data['ip']) || empty($data['ip'])) {
- throw new \Box_Exception('Account ip is missing or is invalid');
+ throw new \FOSSBilling\InformationException('Account ip is missing or is invalid');
}
$ip = $data['ip'];
@@ -298,7 +298,7 @@ class Service implements InjectionAwareInterface
!isset($data['tld']) || empty($data['tld'])
|| !isset($data['sld']) || empty($data['sld'])
) {
- throw new \Box_Exception('Domain sld or tld is missing');
+ throw new \FOSSBilling\InformationException('Domain sld or tld is missing');
}
$sld = $data['sld'];
@@ -324,7 +324,7 @@ class Service implements InjectionAwareInterface
!isset($data['password']) || !isset($data['password_confirm'])
|| $data['password'] != $data['password_confirm']
) {
- throw new \Box_Exception('Account password is missing or is invalid');
+ throw new \FOSSBilling\InformationException('Account password is missing or is invalid');
}
$newPassword = $data['password'];
@@ -722,7 +722,7 @@ class Service implements InjectionAwareInterface
public function getServerManager(\Model_ServiceHostingServer $model)
{
if (empty($model->manager)) {
- throw new \Box_Exception('Invalid server manager. Server was not configured properly.', null, 654);
+ throw new \FOSSBilling\Exception('Invalid server manager. Server was not configured properly.', null, 654);
}
$config = [];
@@ -742,7 +742,7 @@ class Service implements InjectionAwareInterface
$manager = $this->di['server_manager']($model->manager, $config);
if (!$manager instanceof \Server_Manager) {
- throw new \Box_Exception('Server manager :adapter is invalid', [':adapter' => $model->manager]);
+ throw new \FOSSBilling\Exception('Server manager :adapter is invalid', [':adapter' => $model->manager]);
}
return $manager;
@@ -782,7 +782,7 @@ class Service implements InjectionAwareInterface
$id = $model->id;
$serviceHosting = $this->di['db']->findOne('ServiceHosting', 'service_hosting_hp_id = ?', [$model->id]);
if ($serviceHosting) {
- throw new \Box_Exception('Can not remove hosting plan which has active accounts');
+ throw new \FOSSBilling\InformationException('Can not remove hosting plan which has active accounts');
}
$this->di['db']->trash($model);
$this->di['logger']->info('Deleted hosting plan %s', $id);
@@ -967,7 +967,7 @@ class Service implements InjectionAwareInterface
$table = $this->di['mod_service']('product');
$d = $table->getMainDomainProduct();
if (!$d instanceof \Model_Product) {
- throw new \Box_Exception('Could not find main domain product');
+ throw new \FOSSBilling\Exception('Could not find main domain product');
}
return ['product' => $d, 'config' => $dc];
diff --git a/src/modules/Servicelicense/Api/Admin.php b/src/modules/Servicelicense/Api/Admin.php
index 55ae97e23..81f035610 100644
--- a/src/modules/Servicelicense/Api/Admin.php
+++ b/src/modules/Servicelicense/Api/Admin.php
@@ -70,7 +70,7 @@ class Admin extends \Api_Abstract
/**
* @return \Model_ServiceLicense
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function _getService(array $data)
{
@@ -82,7 +82,7 @@ class Admin extends \Api_Abstract
$orderService = $this->di['mod_service']('order');
$s = $orderService->getOrderService($order);
if (!$s instanceof \Model_ServiceLicense) {
- throw new \Box_Exception('Order is not activated');
+ throw new \FOSSBilling\Exception('Order is not activated');
}
return $s;
diff --git a/src/modules/Servicelicense/Api/Client.php b/src/modules/Servicelicense/Api/Client.php
index d4f0935f9..7ef181248 100644
--- a/src/modules/Servicelicense/Api/Client.php
+++ b/src/modules/Servicelicense/Api/Client.php
@@ -42,13 +42,13 @@ class Client extends \Api_Abstract
$order = $this->di['db']->findOne('ClientOrder', 'id = :id AND client_id = :client_id', $bindings);
if (!$order instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Order not found');
+ throw new \FOSSBilling\Exception('Order not found');
}
$orderService = $this->di['mod_service']('order');
$s = $orderService->getOrderService($order);
if (!$s instanceof \Model_ServiceLicense) {
- throw new \Box_Exception('Order is not activated');
+ throw new \FOSSBilling\Exception('Order is not activated');
}
return $s;
diff --git a/src/modules/Servicelicense/Service.php b/src/modules/Servicelicense/Service.php
index 10740ce39..ae1832268 100644
--- a/src/modules/Servicelicense/Service.php
+++ b/src/modules/Servicelicense/Service.php
@@ -109,17 +109,17 @@ class Service implements InjectionAwareInterface
$iterations = $c['iterations'] ?? 10;
$model = $orderService->getOrderService($order);
if (!$model instanceof \Model_ServiceLicense) {
- throw new \Box_Exception('Could not activate order. Service was not created');
+ throw new \FOSSBilling\Exception('Could not activate order. Service was not created');
}
$plugin = $this->_getPlugin($model);
if (!is_object($plugin)) {
- throw new \Box_Exception('License plugin :plugin was not found', [':plugin' => $model->plugin]);
+ throw new \FOSSBilling\Exception('License plugin :plugin was not found', [':plugin' => $model->plugin]);
}
if (!method_exists($plugin, 'generate')) {
- throw new \Box_Exception('License plugin do not have generate method');
+ throw new \FOSSBilling\Exception('License plugin do not have generate method');
}
if (method_exists($plugin, 'setDi')) {
@@ -130,7 +130,7 @@ class Service implements InjectionAwareInterface
do {
$licenseKey = $plugin->generate($model, $order, $c);
if ($i++ >= $iterations) {
- throw new \Box_Exception('Maximum number of iterations reached while generating license key');
+ throw new \FOSSBilling\Exception('Maximum number of iterations reached while generating license key');
}
} while ($this->di['db']->findOne('ServiceLicense', 'license_key = :license_key', [':license_key' => $licenseKey]) !== null);
@@ -431,7 +431,7 @@ class Service implements InjectionAwareInterface
{
$result = [];
$log = $this->di['logger']->setChannel('license');
- if ($this->di['config']['debug']) {
+ if (BB_DEBUG) {
$log->debug(print_r($data, 1));
}
diff --git a/src/modules/Spamchecker/Service.php b/src/modules/Spamchecker/Service.php
index 2613e7340..90565e7aa 100644
--- a/src/modules/Spamchecker/Service.php
+++ b/src/modules/Spamchecker/Service.php
@@ -54,7 +54,7 @@ class Service implements InjectionAwareInterface
$blocked_ips = explode(PHP_EOL, $config['blocked_ips']);
$blocked_ips = array_map('trim', $blocked_ips);
if (in_array($di['request']->getClientAddress(), $blocked_ips)) {
- throw new \Box_Exception('Your IP address (:ip) is blocked. Please contact our support to lift your block.', [':ip' => $di['request']->getClientAddress()], 403);
+ throw new \FOSSBilling\InformationException('Your IP address (:ip) is blocked. Please contact our support to lift your block.', [':ip' => $di['request']->getClientAddress()], 403);
}
}
}
@@ -75,11 +75,11 @@ class Service implements InjectionAwareInterface
if (isset($config['captcha_enabled']) && $config['captcha_enabled']) {
if (isset($config['captcha_version']) && 2 == $config['captcha_version']) {
if (!isset($config['captcha_recaptcha_privatekey']) || '' == $config['captcha_recaptcha_privatekey']) {
- throw new \Box_Exception("To use reCAPTCHA you must get an API key from
here");
+ throw new \FOSSBilling\InformationException("To use reCAPTCHA you must get an API key from
here");
}
if (!isset($params['g-recaptcha-response']) || '' == $params['g-recaptcha-response']) {
- throw new \Box_Exception('You have to complete the CAPTCHA to continue');
+ throw new \FOSSBilling\InformationException('You have to complete the CAPTCHA to continue');
}
$client = HttpClient::create();
@@ -93,10 +93,10 @@ class Service implements InjectionAwareInterface
$content = $response->toArray();
if (!$content['success']) {
- throw new \Box_Exception('reCAPTCHA verification failed.');
+ throw new \FOSSBilling\InformationException('reCAPTCHA verification failed.');
}
} else {
- throw new \Box_Exception('reCAPTCHA verification failed.');
+ throw new \FOSSBilling\InformationException('reCAPTCHA verification failed.');
}
}
@@ -127,13 +127,13 @@ class Service implements InjectionAwareInterface
}
if (isset($json->username->appears) && $json->username->appears) {
- throw new \Box_Exception('Your username is blacklisted in the Stop Forum Spam database');
+ throw new \FOSSBilling\InformationException('Your username is blacklisted in the Stop Forum Spam database');
}
if (isset($json->email->appears) && $json->email->appears) {
- throw new \Box_Exception('Your e-mail is blacklisted in the Stop Forum Spam database');
+ throw new \FOSSBilling\InformationException('Your e-mail is blacklisted in the Stop Forum Spam database');
}
if (isset($json->ip->appears) && $json->ip->appears) {
- throw new \Box_Exception('Your IP address is blacklisted in the Stop Forum Spam database');
+ throw new \FOSSBilling\InformationException('Your IP address is blacklisted in the Stop Forum Spam database');
}
return false;
diff --git a/src/modules/Staff/Api/Admin.php b/src/modules/Staff/Api/Admin.php
index 6fcfa1a75..0b29551f9 100644
--- a/src/modules/Staff/Api/Admin.php
+++ b/src/modules/Staff/Api/Admin.php
@@ -40,7 +40,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function get($data)
{
@@ -65,7 +65,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update($data)
{
@@ -88,7 +88,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function delete($data)
{
@@ -107,7 +107,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\InformationException
*/
public function change_password($data)
{
@@ -120,7 +120,7 @@ class Admin extends \Api_Abstract
$validator->checkRequiredParamsForArray($required, $data);
if ($data['password'] != $data['password_confirm']) {
- throw new \Box_Exception('Passwords do not match');
+ throw new \FOSSBilling\InformationException('Passwords do not match');
}
$validator->isPasswordStrong($data['password']);
@@ -137,7 +137,7 @@ class Admin extends \Api_Abstract
*
* @return int - ID of newly created staff member
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function create($data)
{
@@ -229,7 +229,7 @@ class Admin extends \Api_Abstract
*
* @return int - new staff group ID
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function group_create($data)
{
@@ -246,7 +246,7 @@ class Admin extends \Api_Abstract
*
* @return array - group details
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function group_get($data)
{
@@ -265,7 +265,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function group_delete($data)
{
@@ -286,7 +286,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function group_update($data)
{
diff --git a/src/modules/Staff/Api/Guest.php b/src/modules/Staff/Api/Guest.php
index eadcd0829..d379face4 100644
--- a/src/modules/Staff/Api/Guest.php
+++ b/src/modules/Staff/Api/Guest.php
@@ -29,7 +29,7 @@ class Guest extends \Api_Abstract
{
$allow = (!is_countable($this->di['db']->findOne('Admin', '1=1')) || count($this->di['db']->findOne('Admin', '1=1')) == 0);
if (!$allow) {
- throw new \Box_Exception('Administrator account already exists', null, 55);
+ throw new \FOSSBilling\InformationException('Administrator account already exists', null, 55);
}
$required = [
'email' => 'Administrator email is missing.',
@@ -56,7 +56,7 @@ class Guest extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function login($data)
{
@@ -76,7 +76,7 @@ class Guest extends \Api_Abstract
if ($allowed_ips) {
$allowed_ips = array_map('trim', $allowed_ips);
if (!in_array($this->getIp(), $allowed_ips)) {
- throw new \Box_Exception('You are not allowed to login to admin area from :ip address', [':ip' => $this->getIp()], 403);
+ throw new \FOSSBilling\InformationException('You are not allowed to login to admin area from :ip address', [':ip' => $this->getIp()], 403);
}
}
}
@@ -88,7 +88,7 @@ class Guest extends \Api_Abstract
{
$config = $this->getMod()->getConfig();
if (isset($config['public']['reset_pw']) && $config['public']['reset_pw'] == '0') {
- throw new \Box_Exception('Password reset has been disabled');
+ throw new \FOSSBilling\InformationException('Password reset has been disabled');
}
$this->di['events_manager']->fire(['event' => 'onBeforePasswordResetStaff']);
$required = [
@@ -101,16 +101,16 @@ class Guest extends \Api_Abstract
$validator->checkRequiredParamsForArray($required, $data);
if ($data['password'] != $data['password_confirm']) {
- throw new \Box_Exception('Passwords do not match');
+ throw new \FOSSBilling\InformationException('Passwords do not match');
}
$reset = $this->di['db']->findOne('AdminPasswordReset', 'hash = ?', [$data['code']]);
if (!$reset instanceof \Model_AdminPasswordReset) {
- throw new \Box_Exception('The link have expired or you have already confirmed password reset.');
+ throw new \FOSSBilling\InformationException('The link have expired or you have already confirmed password reset.');
}
if (strtotime($reset->created_at) - time() + 900 < 0) {
- throw new \Box_Exception('The link have expired or you have already confirmed password reset.');
+ throw new \FOSSBilling\InformationException('The link have expired or you have already confirmed password reset.');
}
$c = $this->di['db']->getExistingModelById('Admin', $reset->admin_id, 'User not found');
@@ -133,7 +133,7 @@ class Guest extends \Api_Abstract
{
$config = $this->getMod()->getConfig();
if (isset($config['public']['reset_pw']) && $config['public']['reset_pw'] == '0') {
- throw new \Box_Exception('Password reset has been disabled');
+ throw new \FOSSBilling\InformationException('Password reset has been disabled');
}
$this->di['events_manager']->fire(['event' => 'onBeforePasswordResetStaff']);
$required = [
diff --git a/src/modules/Staff/Controller/Admin.php b/src/modules/Staff/Controller/Admin.php
index 2dcbb2672..60ed09dc6 100644
--- a/src/modules/Staff/Controller/Admin.php
+++ b/src/modules/Staff/Controller/Admin.php
@@ -118,16 +118,16 @@ class Admin implements InjectionAwareInterface
$mod = $this->di['mod']('staff');
$config = $mod->getConfig();
if (isset($config['public']['reset_pw']) && $config['public']['reset_pw'] == '0') {
- throw new \Box_Exception('Password reset has been disabled');
+ throw new \FOSSBilling\InformationException('Password reset has been disabled');
}
// send confirmation email
$service = $this->di['mod_service']('staff');
$reset = $this->di['db']->findOne('AdminPasswordReset', 'hash = ?', [$hash]);
if (!$reset instanceof \Model_AdminPasswordReset) {
- throw new \Box_Exception('The link have expired or you have already confirmed password reset.');
+ throw new \FOSSBilling\InformationException('The link have expired or you have already confirmed password reset.');
}
if (strtotime($reset->created_at) - time() + 900 < 0) {
- throw new \Box_Exception('The link have expired or you have already confirmed password reset.');
+ throw new \FOSSBilling\InformationException('The link have expired or you have already confirmed password reset.');
}
$admin = $this->di['db']->getExistingModelById('Admin', $reset->admin_id, 'User not found');
$data['hash'] = $reset->hash;
diff --git a/src/modules/Staff/Service.php b/src/modules/Staff/Service.php
index 3b2b00c18..af2353acf 100644
--- a/src/modules/Staff/Service.php
+++ b/src/modules/Staff/Service.php
@@ -38,7 +38,7 @@ class Service implements InjectionAwareInterface
if (!$model instanceof \Model_Admin) {
$this->di['events_manager']->fire(['event' => 'onEventAdminLoginFailed', 'params' => $event_params]);
- throw new \Box_Exception('Check your login details', null, 403);
+ throw new \FOSSBilling\InformationException('Check your login details', null, 403);
}
$this->di['events_manager']->fire(['event' => 'onAfterAdminLogin', 'params' => ['id' => $model->id, 'ip' => $ip]]);
@@ -421,7 +421,7 @@ class Service implements InjectionAwareInterface
public function delete(\Model_Admin $model)
{
if ($model->protected) {
- throw new \Box_Exception('This administrator account is protected and can not be removed');
+ throw new \FOSSBilling\InformationException('This administrator account is protected and can not be removed');
}
$this->di['events_manager']->fire(['event' => 'onBeforeAdminStaffDelete', 'params' => ['id' => $model->id]]);
@@ -476,7 +476,7 @@ class Service implements InjectionAwareInterface
try {
$newId = $this->di['db']->store($model);
} catch (\RedBeanPHP\RedException) {
- throw new \Box_Exception('Staff member with email :email is already registered', [':email' => $data['email']], 788954);
+ throw new \FOSSBilling\InformationException('Staff member with email :email is already registered', [':email' => $data['email']], 788954);
}
$this->di['events_manager']->fire(['event' => 'onAfterAdminStaffCreate', 'params' => ['id' => $newId]]);
@@ -561,7 +561,7 @@ class Service implements InjectionAwareInterface
{
$id = $model->id;
if ($model->id == 1) {
- throw new \Box_Exception('Administrators group can not be removed');
+ throw new \FOSSBilling\InformationException('Administrators group can not be removed');
}
$sql = 'SELECT count(1)
@@ -569,7 +569,7 @@ class Service implements InjectionAwareInterface
WHERE admin_group_id = :id';
$staffMembersInGroup = $this->di['db']->getCell($sql, ['id' => $model->id]);
if ($staffMembersInGroup > 0) {
- throw new \Box_Exception('Can not remove group which has staff members');
+ throw new \FOSSBilling\InformationException('Can not remove group which has staff members');
}
$this->di['db']->trash($model);
diff --git a/src/modules/Support/Api/Admin.php b/src/modules/Support/Api/Admin.php
index 889ed4e02..ab4d63e09 100644
--- a/src/modules/Support/Api/Admin.php
+++ b/src/modules/Support/Api/Admin.php
@@ -259,7 +259,7 @@ class Admin extends \Api_Abstract
*
* @return int - inquiry id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function public_ticket_create($data)
{
@@ -279,7 +279,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function public_ticket_get($data)
{
@@ -298,7 +298,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function public_ticket_delete($data)
{
@@ -317,7 +317,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function public_ticket_close($data)
{
@@ -339,7 +339,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function public_ticket_update($data)
{
@@ -358,7 +358,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function public_ticket_reply($data)
{
@@ -413,7 +413,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function helpdesk_get($data)
{
@@ -438,7 +438,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function helpdesk_update($data)
{
@@ -462,7 +462,7 @@ class Admin extends \Api_Abstract
*
* @return int - id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function helpdesk_create($data)
{
@@ -479,7 +479,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function helpdesk_delete($data)
{
@@ -533,7 +533,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function canned_get($data)
{
@@ -552,7 +552,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function canned_delete($data)
{
@@ -573,7 +573,7 @@ class Admin extends \Api_Abstract
*
* @return int
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function canned_create($data)
{
@@ -597,7 +597,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function canned_update($data)
{
@@ -626,7 +626,7 @@ class Admin extends \Api_Abstract
*
* @return array
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function canned_category_get($data)
{
@@ -647,7 +647,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function canned_category_update($data)
{
@@ -668,7 +668,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function canned_category_delete($data)
{
@@ -687,7 +687,7 @@ class Admin extends \Api_Abstract
*
* @return int - new category id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function canned_category_create($data)
{
@@ -704,7 +704,7 @@ class Admin extends \Api_Abstract
*
* @return int - new note id
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function note_create($data)
{
@@ -724,7 +724,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function note_delete($data)
{
@@ -743,7 +743,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function task_complete($data)
{
diff --git a/src/modules/Support/Api/Client.php b/src/modules/Support/Api/Client.php
index 5be981ae4..f2575ac08 100644
--- a/src/modules/Support/Api/Client.php
+++ b/src/modules/Support/Api/Client.php
@@ -121,11 +121,11 @@ class Client extends \Api_Abstract
$ticket = $this->di['db']->findOne('SupportTicket', 'id = :id AND client_id = :client_id', $bindings);
if (!$ticket instanceof \Model_SupportTicket) {
- throw new \Box_Exception('Ticket not found');
+ throw new \FOSSBilling\Exception('Ticket not found');
}
if (!$this->getService()->canBeReopened($ticket)) {
- throw new \Box_Exception('Ticket can not be reopened.');
+ throw new \FOSSBilling\InformationException('Ticket can not be reopened.');
}
$result = $this->getService()->ticketReply($ticket, $client, $data['content']);
diff --git a/src/modules/Support/Api/Guest.php b/src/modules/Support/Api/Guest.php
index 224725686..e49c830f0 100644
--- a/src/modules/Support/Api/Guest.php
+++ b/src/modules/Support/Api/Guest.php
@@ -32,7 +32,7 @@ class Guest extends \Api_Abstract
$this->di['validator']->checkRequiredParamsForArray($required, $data);
if (strlen($data['message']) < 4) {
- throw new \Box_Exception('Please enter your message');
+ throw new \FOSSBilling\InformationException('Please enter your message');
}
return $this->getService()->ticketCreateForGuest($data);
diff --git a/src/modules/Support/Service.php b/src/modules/Support/Service.php
index abe848d06..166c08537 100644
--- a/src/modules/Support/Service.php
+++ b/src/modules/Support/Service.php
@@ -244,7 +244,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$ticket = $this->di['db']->findOne('SupportTicket', 'id = :id AND client_id = :client_id', $bindings);
if (!$ticket instanceof \Model_SupportTicket) {
- throw new \Box_Exception('Ticket not found');
+ throw new \FOSSBilling\Exception('Ticket not found');
}
return $ticket;
@@ -648,7 +648,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$tickets = $this->di['db']->find('SupportTicket', 'support_helpdesk_id = :support_helpdesk_id', [':support_helpdesk_id' => $model->id]);
if ((is_countable($tickets) ? count($tickets) : 0) > 0) {
- throw new \Box_Exception('Can not remove helpdesk which has tickets');
+ throw new \FOSSBilling\InformationException('Can not remove helpdesk which has tickets');
}
$this->di['db']->trash($model);
$this->di['logger']->info('Deleted helpdesk #%s', $id);
@@ -855,7 +855,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$timeSinceLast = round(abs(strtotime($lastTicket->created_at) - strtotime(date('Y-m-d H:i:s'))) / 3600, 0);
if ($timeSinceLast < $hours) {
- throw new \Box_Exception(sprintf('You can submit one ticket per %s hours. %s hours left', $hours, $hours - $timeSinceLast));
+ throw new \FOSSBilling\InformationException(sprintf('You can submit one ticket per %s hours. %s hours left', $hours, $hours - $timeSinceLast));
}
return true;
@@ -871,7 +871,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$orderService = $this->di['mod_service']('order');
$o = $orderService->findForClientById($client, $rel_id);
if (!$o instanceof \Model_ClientOrder) {
- throw new \Box_Exception('Order ID does not exist');
+ throw new \FOSSBilling\Exception('Order ID does not exist');
}
}
@@ -881,7 +881,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
if ($rel_task == 'upgrade') {
if (empty($o) || empty($rel_new_value)) {
- throw new \Box_Exception('You must provide both an order ID and a new product ID in order to request an upgrade.');
+ throw new \FOSSBilling\Exception('You must provide both an order ID and a new product ID in order to request an upgrade.');
}
$product = $this->di['db']->getExistingModelById('Product', $o->product_id);
@@ -889,13 +889,13 @@ class Service implements \FOSSBilling\InjectionAwareInterface
if (!in_array($rel_new_value, $allowedUpgrades)) {
$upgrade = $this->di['db']->getExistingModelById('Product', $rel_new_value);
- throw new \Box_Exception('Sorry, but ":product" is not allowed to be upgraded to ":upgrade"', [':product' => $product->title, ':upgrade' => $upgrade->title ?? 'unknown']);
+ throw new \FOSSBilling\InformationException('Sorry, but ":product" is not allowed to be upgraded to ":upgrade"', [':product' => $product->title, ':upgrade' => $upgrade->title ?? 'unknown']);
}
}
// check if support ticket with same uncompleted task already exists
if ($rel_id && $rel_type && $rel_task && $this->checkIfTaskAlreadyExists($client, $rel_id, $rel_type, $rel_task)) {
- throw new \Box_Exception('We have already received this request.');
+ throw new \FOSSBilling\InformationException('We have already received this request.');
}
$mod = $this->di['mod']('support');
@@ -970,7 +970,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
} elseif ($identity instanceof \Model_Client) {
$msg->client_id = $identity->id;
} else {
- throw new \Box_Exception('Identity is invalid');
+ throw new \FOSSBilling\Exception('Identity is invalid');
}
$msg->content = $content;
$msg->ip = $this->di['request']->getClientAddress();
@@ -999,7 +999,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
$publicTicket = $this->di['db']->findOne('SupportPTicket', 'hash = :hash', $bindings);
if (!$publicTicket instanceof \Model_SupportPTicket) {
- throw new \Box_Exception('Public ticket not found');
+ throw new \FOSSBilling\Exception('Public ticket not found');
}
return $publicTicket;
diff --git a/src/modules/System/Api/Admin.php b/src/modules/System/Api/Admin.php
index 5d2969750..1e5b2a8e2 100644
--- a/src/modules/System/Api/Admin.php
+++ b/src/modules/System/Api/Admin.php
@@ -14,6 +14,8 @@
namespace Box\Mod\System\Api;
+use Symfony\Component\Filesystem\Filesystem;
+
class Admin extends \Api_Abstract
{
/**
@@ -117,7 +119,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function is_allowed($data)
{
@@ -171,13 +173,13 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function update_core($data)
{
$updater = $this->di['updater'];
if ($updater->getUpdateBranch() !== 'preview' && !$updater->isUpdateAvailable()) {
- throw new \Box_Exception('You have latest version of FOSSBilling. You do not need to update.');
+ throw new \FOSSBilling\InformationException('You have latest version of FOSSBilling. You do not need to update.');
}
$new_version = $updater->getLatestVersion();
@@ -195,7 +197,7 @@ class Admin extends \Api_Abstract
*
* @return bool
*
- * @throws \Box_Exception
+ * @throws \FOSSBilling\Exception
*/
public function manual_update()
{
@@ -207,4 +209,50 @@ class Admin extends \Api_Abstract
return true;
}
+
+ /**
+ * Returns the unique instance ID for this FOSSBilling installation.
+ *
+ * @return string
+ */
+ public function instance_id(): string
+ {
+ return INSTANCE_ID;
+ }
+
+ /**
+ * Returns if error reporting is enabled or not on this FOSSBilling instance.
+ */
+ public function error_reporting_enabled(): bool
+ {
+ return (bool)$this->di['config']['debug_and_monitoring']['report_errors'];
+ }
+
+ /**
+ * Toggles error reporting on this FOSSBilling instance.
+ */
+ public function toggle_error_reporting(): bool
+ {
+ $filesystem = new Filesystem();
+ $config = include PATH_CONFIG;
+
+ // Invert the current config value
+ $config['debug_and_monitoring']['report_errors'] = !$config['debug_and_monitoring']['report_errors'];
+
+ // Create the output file
+ $output = 'dumpFile(PATH_CONFIG, $output);
+ return true;
+ }
+
+ /**
+ * Returns the last FOSSBilling version number that changed error reporting behavior.
+ */
+ public function last_error_reporting_change(): string
+ {
+ return \FOSSBilling\SentryHelper::last_change;
+ }
}
diff --git a/src/modules/System/Service.php b/src/modules/System/Service.php
index d4d1b2037..02bd3de88 100644
--- a/src/modules/System/Service.php
+++ b/src/modules/System/Service.php
@@ -11,6 +11,8 @@
namespace Box\Mod\System;
use FOSSBilling\Environment;
+use FOSSBilling\SentryHelper;
+use FOSSBilling\Version;
use Pimple\Container;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\Cache\ItemInterface;
@@ -31,7 +33,7 @@ class Service
public function getParamValue($param, $default = null)
{
if (empty($param)) {
- throw new \Box_Exception('Parameter key is missing');
+ throw new \FOSSBilling\Exception('Parameter key is missing');
}
$query = 'SELECT value
@@ -95,7 +97,7 @@ class Service
}
foreach ($params as $param) {
if (!preg_match('/^[a-z0-9_]+$/', $param)) {
- throw new \Box_Exception('Invalid parameter name, received: param_', ['param_' => $param]);
+ throw new \FOSSBilling\InformationException('Invalid parameter name, received: param_', ['param_' => $param]);
}
}
$query = "SELECT param, value
@@ -259,12 +261,12 @@ class Service
// And now return the correctly message for the given situation
if (!$last_exec) {
return [
- 'text' => 'Cron was never executed, please ensure you have configured the cronjob or else scheduled tasks within FOSSBilling will not behave correctly. (Message is cached for 15 minutes)',
+ 'text' => 'Cron was never executed, please ensure you have configured the cronjob or else scheduled tasks within FOSSBilling will not behave correctly. (Message will remain for 15 minutes)',
'url' => $cronUrl,
];
} elseif ((time() - strtotime($last_exec)) / 60 >= 15) {
return [
- 'text' => 'FOSSBilling has detected that cron hasn\'t been run in an abnormal time period. Please ensure the cronjob is configured to be run every 5 minutes. (Message is cached for 15 minutes)',
+ 'text' => 'FOSSBilling has detected that cron hasn\'t been run in an abnormal time period. Please ensure the cronjob is configured to be run every 5 minutes. (Message will remain for 15 minutes)',
'url' => $cronUrl,
];
} else {
@@ -277,6 +279,44 @@ class Service
}
}
+ /**
+ * The below logic is to help ensure that we nudge the user when needed about error reporting.
+ */
+ if (Environment::isProduction()) {
+ // Get the last time we've nudged the user about error reporting
+ $lastErrorReportingNudge = $this->getParamValue('last_error_reporting_nudge');
+
+ $result = $this->di['cache']->get('error_reporting_nudge', function (ItemInterface $item) use ($lastErrorReportingNudge) {
+ $item->expiresAfter(15 * 60);
+ $url = $this->di['url']->adminLink('extension/settings/system');
+ $this->setParamValue('last_error_reporting_nudge', Version::VERSION);
+
+ if (!$lastErrorReportingNudge) {
+ // The user upgraded from a version that didn't have error reporting functionality, so let's nudge them about it now.
+ return [
+ 'text' => 'We\'d apreciate it if you\'d consider opting into error reporting for FOSSBilling. Doing so will help us improve the software and provide you with a better experience. (Message will remain for 15 minutes)',
+ 'url' => $url,
+ ];
+ } elseif ((version_compare(SentryHelper::last_change, $lastErrorReportingNudge) === 1) && $this->di['config']['debug_and_monitoring']['report_errors']) {
+ /**
+ * The installation already had error reporting enabled, but something has changed so we should nudge the user to review the changes.
+ * This message is cached for a full 24 hours to help ensure it is seen.
+ */
+ $item->expiresAfter(60 * 60 * 24);
+ return [
+ 'text' => 'Error reporting in FOSSBilling has changed since you last reviewed it. You may want to consider reviewing the changes to see what\'s been changed. (This message will remain for 24 hours)',
+ 'url' => $url,
+ ];
+ } else {
+ return [];
+ }
+ });
+
+ if ($result) {
+ $msgs['info'][] = $result;
+ }
+ }
+
$install = PATH_ROOT . '/install';
if (file_exists(PATH_ROOT . '/install')) {
$msgs['danger'][] = [
@@ -308,7 +348,7 @@ class Service
{
try {
return $this->di['central_alerts']->filterAlerts();
- } catch (\Box_Exception $e) {
+ } catch (\FOSSBilling\Exception $e) {
return [
[
'type' => 'warning',
@@ -467,7 +507,7 @@ class Service
$stmt->execute(['param' => $param]);
$results = $stmt->fetchColumn();
if ($results === false) {
- throw new \Box_Exception('Parameter :param does not exist', [':param' => $param]);
+ throw new \FOSSBilling\Exception('Parameter :param does not exist', [':param' => $param]);
}
return $results;
@@ -1360,7 +1400,7 @@ class Service
if (array_key_exists($data['country'], $codes)) {
return $codes[$data['country']];
} else {
- throw new \Box_Exception('Country :code phone code is not registered', [':code' => $data['country']]);
+ throw new \FOSSBilling\InformationException('Country :code phone code is not registered', [':code' => $data['country']]);
}
}
diff --git a/src/modules/System/html_admin/mod_system_settings.html.twig b/src/modules/System/html_admin/mod_system_settings.html.twig
index d11dadc87..5f5c766e4 100644
--- a/src/modules/System/html_admin/mod_system_settings.html.twig
+++ b/src/modules/System/html_admin/mod_system_settings.html.twig
@@ -31,7 +31,7 @@
{{ 'Company details'|trans }}
- {{ 'Company Legal'|trans }}
+ {{ 'Company legal'|trans }}
{{ 'Countries'|trans }}
@@ -42,6 +42,9 @@
{{ 'About'|trans }}
+
+ {{ 'Error reporting'|trans }}
+
@@ -512,21 +515,56 @@ ZW=Zimbabwe
-
FOSSBilling version
+
{{ 'FOSSBilling version'|trans }}
{{ FOSSBillingVersion }}
-
PHP version
+
{{ 'PHP version'|trans }}
{{ constant('PHP_VERSION') }}
-
License
+
{{ 'Instance ID'|trans }}
+
{{ admin.system_instance_id }}
+
+
+
+
+
+ {% set last_change = admin.system_last_error_reporting_change %}
+ {% if admin.system_error_reporting_enabled %}
+
+
{{ 'Error reporting is enabled.'|trans}}
+
{{ 'This FOSSBilling instance is automatically sending errors which allows us to more easily improve the software and keep it stable. Thanks!'|trans }}
+
{{'Disable error reporting'|trans}}
+
+ {% else %}
+
+
{{ 'Error reporting is disabled.'|trans}}
+
{{ 'Please consider enabling error reporting. Doing so allows us to provide you with better technical support and helps us to proactively improve FOSSBilling.'|trans }}
+
{{'Enable error reporting'|trans}}
+
+ {% endif %}
+
{{ 'FOSSBilling optionally includes autoamted error reporting to help aid the project\'s development and stability. To find the most up-to-date information about it, you should review the links and information below.'|trans }}
+
+
{{ 'The last applicable behavior change represents the most recent FOSSBilling version that changed error reporting which also applies to this current version. There may have been more recent changes than what\'s listed.'|trans }}
+
+
+