getMessage() . PHP_EOL; return ; } error_log($e->getMessage()); if(defined('BB_MODE_API')) { $code = $e->getCode() ? $e->getCode() : 9998; $result = array('result'=>NULL, 'error'=>array('message'=>$e->getMessage(), 'code'=>$code)); print json_encode($result); return false; } $page = " Error BoxBilling "; $page = str_replace(PHP_EOL, "", $page); print $page; if($e->getCode()) { print sprintf('

Code: %s

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

%s

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

Look for detailed error explanation

', urlencode($e->getMessage())); if(defined('BB_DEBUG') && BB_DEBUG) { print sprintf('%s', 'Set BB_DEBUG to FALSE, to hide the message below'); print sprintf('

Class: "%s"

', get_class($e)); print sprintf('

File: "%s"

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

Line: "%s"

', $e->getLine()); print sprintf('Trace:
%s
', $e->getTraceAsString()); } } set_exception_handler("handler_exception"); set_error_handler('handler_error'); // multisite support. Load new config depending on current host // if run from cli first param must be hostname $configPath = BB_PATH_ROOT.'/bb-config.php'; if((isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) || (php_sapi_name() == 'cli' && isset($argv[1]) ) ) { if(php_sapi_name() == 'cli') { $host = $argv[1]; } else { $host = $_SERVER['HTTP_HOST']; } $predictConfigPath = BB_PATH_ROOT.'/bb-config-'.$host.'.php'; if(file_exists($predictConfigPath)) { $configPath = $predictConfigPath; } // check if config is available if(!file_exists($configPath) || 0 == filesize( $configPath )) { //try create empty config file @file_put_contents($configPath, ''); $base_url = "http://".$_SERVER['HTTP_HOST']; $base_url .= preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])).'/'; $url = $base_url . 'install/index.php'; $configFile = pathinfo($configPath, PATHINFO_BASENAME); $msg = sprintf("There doesn't seem to be a $configFile file or bb-config.php file does not contain required configuration parameters. I need this before we can get started. Need more help? We got it. You can create a $configFile file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.

Continue with BoxBilling installation", $url); throw new Exception($msg, 101); } $config = require_once $configPath; require BB_PATH_VENDOR . '/autoload.php'; date_default_timezone_set($config['timezone']); define('BB_DEBUG', $config['debug']); define('BB_URL', $config['url']); define('BB_SEF_URLS', $config['sef_urls']); define('BB_PATH_CACHE', $config['path_data'] . '/cache'); define('BB_PATH_LOG', $config['path_data'] . '/log'); define('BB_SSL', (substr($config['url'], 0, 5) === 'https')); if($config['sef_urls']) { define('BB_URL_API', $config['url'] . 'api/'); } else { define('BB_URL_API', $config['url'] . 'index.php?_url=/api/'); } if($config['debug']) { error_reporting( E_ALL ); 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'); } ini_set('log_errors', '1'); ini_set('html_errors', FALSE); ini_set('error_log', BB_PATH_LOG . '/php_error.log'); // Strip magic quotes from request data. /** Deprecated: Function get_magic_quotes_gpc() **/ //if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) // Create lamba style unescaping function (for portability) // $quotes_sybase = strtolower(ini_get('magic_quotes_sybase')); { // Create lamba style unescaping function (for portability) $quotes_sybase = strtolower(ini_get('magic_quotes_sybase')); /* create_function deprecated in PHP 7.2 $unescape_function = (empty($quotes_sybase) || $quotes_sybase === 'off') ? 'stripslashes($value)' : 'str_replace("\'\'","\'",$value)'; $stripslashes_deep = create_function('&$value, $fn', ' if (is_string($value)) { $value = ' . $unescape_function . '; } else if (is_array($value)) { foreach ($value as &$v) $fn($v, $fn); } '); */ $stripslashes_deep = function(&$value, $fn){ if (is_string($value)) { $value = (empty($quotes_sybase) || $quotes_sybase === 'off') ? stripslashes($value) : str_replace("\'\'","\'",$value); } else if (is_array($value)) { foreach ($value as &$v) $fn($v, $fn); } }; // Unescape data $stripslashes_deep($_POST, $stripslashes_deep); $stripslashes_deep($_GET, $stripslashes_deep); $stripslashes_deep($_COOKIE, $stripslashes_deep); $stripslashes_deep($_REQUEST, $stripslashes_deep); } ?>