diff --git a/ajax.php b/ajax.php index b904d3ec9..7de5896be 100755 --- a/ajax.php +++ b/ajax.php @@ -45,7 +45,7 @@ switch (filter('op')) { } if (!$found) { - $_SESSION[$array[0]][$array[1]][] = $value; + $_SESSION[$array[0]][$array[1]][] = $value; } // print_r($_SESSION[$array[0]][$array[1]]); diff --git a/assets/src/js/functions/functions.js b/assets/src/js/functions/functions.js index c57c65811..94099c1f6 100755 --- a/assets/src/js/functions/functions.js +++ b/assets/src/js/functions/functions.js @@ -606,3 +606,17 @@ function apriTab(link) { parent.find(".tab-pane").removeClass("active"); parent.find(".tab-pane#" + tab).addClass("active"); } + +/** + * + * @param xhr + * @param error + * @param thrown + */ +function ajaxError(xhr, error, thrown) { + swal({ + title: globals.translations.errorTitle, + html: globals.translations.errorMessage + (xhr.responseJSON ? ".
" + xhr.responseJSON.exception[0].message + "" : ''), + type: "error", + }); +} diff --git a/bug.php b/bug.php index 44a94f8ba..a97419d77 100755 --- a/bug.php +++ b/bug.php @@ -88,8 +88,7 @@ if (filter('op') == 'send') { } redirect_legacy(base_url().'/bug.php'); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } $pageTitle = tr('Bug'); diff --git a/core.php b/core.php index fb094cb7e..5dd78ae10 100755 --- a/core.php +++ b/core.php @@ -30,8 +30,7 @@ if (version_compare(phpversion(), $minimum) < 0) {

Stai utilizzando la versione PHP '.phpversion().', non compatibile con OpenSTAManager.

Aggiorna PHP alla versione >= '.$minimum.'.

'; - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } // Caricamento delle impostazioni personalizzabili @@ -55,8 +54,7 @@ $config = AppLegacy::getConfig(); if (!empty($config['redirectHTTPS']) && !isHTTPS(true)) { header('HTTP/1.1 301 Moved Permanently'); header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } /* GESTIONE DEGLI ERRORI */ @@ -167,7 +165,7 @@ if (!$continue && getURLPath() != slashes(base_url().'/index.php') && !Permissio } redirect_legacy(base_url().'/index.php'); - throw new \App\Exceptions\LegacyExitException; + throw new \App\Exceptions\LegacyExitException(); } /* INIZIALIZZAZIONE GENERALE */ diff --git a/include/init/configuration.php b/include/init/configuration.php index f4c5a4a8d..793fae45c 100755 --- a/include/init/configuration.php +++ b/include/init/configuration.php @@ -110,8 +110,7 @@ if (post('db_host') !== null) { } echo $state; - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } // Creazione della configurazione @@ -196,7 +195,7 @@ if (post('db_host') !== null) { "generated" : "true", "icons" : [ { - "src": "assets/dist/img/logo_completo.png", + "src": "assets/img/logo.png", "type": "image/png", "sizes": "489x91" } @@ -205,8 +204,7 @@ if (post('db_host') !== null) { file_put_contents('manifest.json', $manifest); redirect_legacy(base_url().'/index.php'); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } } } @@ -611,5 +609,4 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) { include_once AppLegacy::filepath('include|custom|', 'bottom.php'); -throw new \App\Exceptions\LegacyExitException; - +throw new \App\Exceptions\LegacyExitException(); diff --git a/include/init/init.php b/include/init/init.php index 0c3c181ab..6c3cc8c1c 100755 --- a/include/init/init.php +++ b/include/init/init.php @@ -115,8 +115,7 @@ if (post('action') == 'init') { } redirect_legacy(base_url(), 'js'); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } $img = AppLegacy::getPaths()['img']; @@ -263,5 +262,4 @@ echo ' include_once AppLegacy::filepath('include|custom|', 'bottom.php'); -throw new \App\Exceptions\LegacyExitException; - +throw new \App\Exceptions\LegacyExitException(); diff --git a/include/init/update.php b/include/init/update.php index ebad6f993..a248d7d94 100755 --- a/include/init/update.php +++ b/include/init/update.php @@ -109,8 +109,7 @@ if (filter('action') == 'do_update') { '; } - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } elseif (Update::isUpdateAvailable()) { // Controllo se l'aggiornamento è in esecuzione if (Update::isUpdateLocked() && filter('force') === null) { @@ -132,8 +131,7 @@ if (filter('action') == 'do_update') { include_once AppLegacy::filepath('include|custom|', 'bottom.php'); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } $firstuse = !$dbo->isInstalled() ? 'true' : 'false'; diff --git a/index.php b/index.php index 8490fc1c3..2d242be12 100755 --- a/index.php +++ b/index.php @@ -32,10 +32,10 @@ switch ($op) { $password = post('password'); $user = User::where('username', $username)->first(); - if (!empty($user) && Hash::check($password, $user->getAuthPassword())){ + if (!empty($user) && Hash::check($password, $user->getAuthPassword())) { auth()->loginUsingId($user->id, true); - // Rimozione log vecchi + // Rimozione log vecchi //$dbo->query('DELETE FROM `zz_operations` WHERE DATE_ADD(`created_at`, INTERVAL 30*24*60*60 SECOND) <= NOW()'); } else { $status = auth()->user(); @@ -43,8 +43,7 @@ switch ($op) { //flash()->error(auth()->getStatus()[$status]['message']); redirect_legacy(base_url().'/index.php'); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } break; @@ -53,9 +52,7 @@ switch ($op) { auth()->logout(); redirect_legacy(base_url().'/index.php'); - throw new \App\Exceptions\LegacyExitException; - - + throw new \App\Exceptions\LegacyExitException(); break; } @@ -67,8 +64,7 @@ if (auth()->check() && isset($dbo) && $dbo->isConnected() && $dbo->isInstalled() } else { redirect_legacy(base_url().'/index.php?op=logout'); } - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } // Procedura di installazione diff --git a/lib/functions.php b/lib/functions.php index ea901698d..d340ac425 100755 --- a/lib/functions.php +++ b/lib/functions.php @@ -323,8 +323,7 @@ function redirectOperation($id_module, $id_record) redirect_legacy(base_url().'/controller.php?id_module='.$id_module.$hash); } - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } } diff --git a/lib/helpers.php b/lib/helpers.php index 24bc569a5..157cddbb0 100755 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -33,7 +33,7 @@ use Models\Module; */ function database() { - if (!app()->has(Database::class)){ + if (!app()->has(Database::class)) { app()->instance(Database::class, new Database()); } @@ -137,7 +137,7 @@ function flash() */ function formatter() { - if (!app()->has(Formatter::class)){ + if (!app()->has(Formatter::class)) { $formatter = new Formatter( app()->getLocale(), empty($options['timestamp']) ? 'd/m/Y H:i' : $options['timestamp'], @@ -149,12 +149,12 @@ function formatter() ] : $options['number'] ); - $formatter->setPrecision(auth()->check() ? setting('Cifre decimali per importi') : 2); + //$formatter->setPrecision(auth()->check() ? setting('Cifre decimali per importi') : 2); + $formatter->setPrecision(2); app()->instance(Formatter::class, $formatter); } - return app()->get(Formatter::class); } @@ -176,15 +176,14 @@ function tr($string, $parameters = [], $operations = []) return replace($result, $parameters); } -// Retrocompatibilità (con la funzione gettext) +// Retro-compatibilità (con la funzione gettext) if (!function_exists('_')) { function _($string, $parameters = [], $operations = []) { - return _i($string, $parameters); + return tr($string, $parameters); } } - /** * Restituisce il numero indicato formattato secondo la configurazione del sistema. * diff --git a/modules/dashboard/ajax.php b/modules/dashboard/ajax.php index 201fba2be..734f8f15c 100644 --- a/modules/dashboard/ajax.php +++ b/modules/dashboard/ajax.php @@ -35,9 +35,9 @@ switch (filter('op')) { $stati = session('dashboard.idstatiintervento', ["'-1'"]); $stati[] = prepare(''); - $tipi = session('dashboard.idtipiintervento', ["'-1'"]); - $zone = session('dashboard.idzone', ["'-1'"]); - $tecnici = session('dashboard.idtecnici', ["'-1'"]); + $tipi = session('dashboard.idtipiintervento', ["'-1'"]); + $zone = session('dashboard.idzone', ["'-1'"]); + $tecnici = session('dashboard.idtecnici', ["'-1'"]); $query = 'SELECT in_interventi_tecnici.id, diff --git a/modules/interventi/modals/anteprima_firma.php b/modules/interventi/modals/anteprima_firma.php index f6cc323d6..61f103355 100644 --- a/modules/interventi/modals/anteprima_firma.php +++ b/modules/interventi/modals/anteprima_firma.php @@ -26,8 +26,7 @@ if (get('anteprima') !== null) { if (empty($rs)) { echo tr('Intervento inesistente!'); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } // Gestione della stampa diff --git a/plugins/importFE/actions.php b/plugins/importFE/actions.php index 8955622d9..14e472e74 100755 --- a/plugins/importFE/actions.php +++ b/plugins/importFE/actions.php @@ -47,8 +47,7 @@ switch (filter('op')) { echo json_encode([ 'id' => 1, ]); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } else { $content = file_get_contents($temp_name); diff --git a/reset.php b/reset.php index 7f10ec51d..e98f0f363 100755 --- a/reset.php +++ b/reset.php @@ -60,8 +60,7 @@ switch (post('op')) { } redirect_legacy(base_url().'/index.php'); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); break; case 'update': @@ -78,8 +77,7 @@ switch (post('op')) { flash()->info(tr('Password cambiata!')); redirect_legacy(base_url().'/index.php'); - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); break; } diff --git a/src/AppLegacy.php b/src/AppLegacy.php index f3aa04f37..4ae999e52 100644 --- a/src/AppLegacy.php +++ b/src/AppLegacy.php @@ -27,6 +27,10 @@ use Util\Messages; */ class AppLegacy { + /** + * @var \Intl\Formatter + */ + public static $formatter; /** @var string Simbolo della valuta corrente */ protected static $currency; @@ -63,10 +67,6 @@ class AppLegacy 'i18n/fullcalendar/|lang|.min.js', ], ]; - /** - * @var \Intl\Formatter - */ - public static $formatter; /** * Restituisce la configurazione dell'installazione in utilizzo del progetto. @@ -164,7 +164,7 @@ class AppLegacy // Impostazione dei percorsi $paths = self::getPaths(); - $lang = App::getLocale();; + $lang = App::getLocale(); // Sezioni: nome - percorso $sections = [ @@ -188,7 +188,7 @@ class AppLegacy foreach ($sections as $section => $dir) { $result = array_unique(array_merge( self::$assets[$section], - isset($config['assets']) ? ($config['assets'][$section] ?:[]) :[] + isset($config['assets']) ? ($config['assets'][$section] ?: []) : [] )); foreach ($result as $key => $element) { @@ -286,6 +286,25 @@ class AppLegacy return slashes($result); } + /** + * Restituisce il simbolo della valuta del gestione. + * + * @since 2.4.9 + * + * @return string + */ + public static function getCurrency() + { + if (!isset(self::$currency)) { + $id = setting('Valuta'); + $valuta = database()->fetchOne('SELECT symbol FROM zz_currencies WHERE id = '.prepare($id)); + + self::$currency = $valuta['symbol']; + } + + return self::$currency; + } + /** * Restituisce la configurazione di default del progetto. * @@ -316,24 +335,4 @@ class AppLegacy return get_defined_vars(); } - - /** - * Restituisce il simbolo della valuta del gestione. - * - * @since 2.4.9 - * - * @return string - */ - public static function getCurrency() - { - if (!isset(self::$currency)) { - $id = setting('Valuta'); - $valuta = database()->fetchOne('SELECT symbol FROM zz_currencies WHERE id = '.prepare($id)); - - self::$currency = $valuta['symbol']; - } - - return self::$currency; - } - } diff --git a/src/Database.php b/src/Database.php index 836601622..9e544e130 100755 --- a/src/Database.php +++ b/src/Database.php @@ -17,7 +17,6 @@ * along with this program. If not, see . */ -use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; @@ -43,7 +42,6 @@ class Database protected $mysql_version; /** - * * @since 2.3 */ public function __construct() @@ -62,7 +60,6 @@ class Database return DB::connection()->getPDO(); } - /** * Controlla se la connessione è valida e andata a buon fine. * @@ -74,9 +71,10 @@ class Database { try { DB::connection()->getPdo(); + return true; } catch (\Exception $e) { - return false; + return false; } } diff --git a/src/HTMLBuilder/HTMLBuilder.php b/src/HTMLBuilder/HTMLBuilder.php index f97606cfb..101080da4 100755 --- a/src/HTMLBuilder/HTMLBuilder.php +++ b/src/HTMLBuilder/HTMLBuilder.php @@ -121,7 +121,7 @@ class HTMLBuilder foreach ($managers[0] as $value) { $json = self::decode($value, 'manager'); - if (empty($json)){ + if (empty($json)) { continue; } diff --git a/src/Permissions.php b/src/Permissions.php index ea5153249..b0025c4be 100755 --- a/src/Permissions.php +++ b/src/Permissions.php @@ -87,8 +87,7 @@ class Permissions if (!auth()->check() && getURLPath() == slashes(base_url().'/index.php')) { redirect_legacy(base_url().'/index.php'); $result = false; - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } else { if (!empty(self::$permissions)) { foreach (self::$permissions as $module) { diff --git a/src/Prints.php b/src/Prints.php index 7e488a3e7..773a3979c 100755 --- a/src/Prints.php +++ b/src/Prints.php @@ -180,8 +180,7 @@ class Prints echo '

'.$error.'

'; - throw new \App\Exceptions\LegacyExitException; - + throw new \App\Exceptions\LegacyExitException(); } if (self::isCompletelyCustom($print)) { diff --git a/src/Util/Messages.php b/src/Util/Messages.php index 5a4520680..b79ee4ad8 100755 --- a/src/Util/Messages.php +++ b/src/Util/Messages.php @@ -28,7 +28,8 @@ use Illuminate\Support\Facades\Session; */ class Messages { - public function __contruct($name){ + public function __contruct($name) + { } public function info($message) @@ -46,14 +47,16 @@ class Messages Session::push('messages.error', $message); } - public function getMessage($type){ + public function getMessage($type) + { $messages = Session::get('messages.'.$type); Session::remove('messages.'.$type); return $messages; } - public function getMessages(){ + public function getMessages() + { $messages = Session::get('messages'); Session::remove('messages');