From ccfbdbd9f55876e255b3727abb85dfd03d1fff5b Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 5 Sep 2019 18:16:10 +0200 Subject: [PATCH] PHP 7.3 upgrade, bugs fixed, improved JS log --- debian/changelog | 2 +- debian/control | 2 +- debian/postinst | 2 +- forms/cms/home/home.js | 8 +- js/hedera/app.js | 210 +++++++++++++++++---------------------- package.json | 2 +- rest/core/locale/mn.json | 5 - rest/core/log.php | 27 +++-- rest/core/login.php | 3 + rest/misc/contact.php | 3 +- rest/misc/mail.php | 2 +- rest/tpv/transaction.php | 2 +- web/mailer.php | 5 +- 13 files changed, 126 insertions(+), 147 deletions(-) delete mode 100644 rest/core/locale/mn.json diff --git a/debian/changelog b/debian/changelog index e5a6f225..b5cd0eb9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.406.61) stable; urgency=low +hedera-web (1.406.62) stable; urgency=low * Initial Release. diff --git a/debian/control b/debian/control index c1cf7596..ae93fd0c 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Vcs-Git: https://git.verdnatura.es/hedera-web Package: hedera-web Architecture: all -Depends: apache2 | httpd, nodejs, php-cli, php-vn-lib, php-apcu, php-ldap, php-ssh2, php-mcrypt, php-imap +Depends: apache2 | httpd, nodejs, php-cli, php-vn-lib, php-apcu, php-ldap, php-ssh2, php-imap Suggests: php-text-captcha, php-soap, libphp-phpmailer, php-gd Section: misc Priority: optional diff --git a/debian/postinst b/debian/postinst index 8eb5c02d..948ee5e9 100755 --- a/debian/postinst +++ b/debian/postinst @@ -10,6 +10,6 @@ then apache2_invoke enconf hedera-web.conf fi -service php7.0-fpm restart +#service php7.3-fpm restart service cron restart diff --git a/forms/cms/home/home.js b/forms/cms/home/home.js index d8a544d8..48de8272 100644 --- a/forms/cms/home/home.js +++ b/forms/cms/home/home.js @@ -1,11 +1,9 @@ -Hedera.Home = new Class -({ +Hedera.Home = new Class({ Extends: Hedera.Form - ,onStartOrderClick: function () - { - this.hash.set ({'form': 'ecomerce/catalog'}); + ,onStartOrderClick: function() { + this.hash.set({'form': 'ecomerce/catalog'}); } }); diff --git a/js/hedera/app.js b/js/hedera/app.js index 7713cf2e..872d3a7e 100644 --- a/js/hedera/app.js +++ b/js/hedera/app.js @@ -1,225 +1,199 @@ -var Login = require ('./login'); -var Gui = require ('./gui'); +var Login = require('./login'); +var Gui = require('./gui'); -module.exports = new Class -({ +module.exports = new Class({ Extends: Vn.Object, Properties: { conn: { type: Db.Connection - ,get: function () - { + ,get: function() { return this._conn; } } } - ,initialize: function () - { - window.onerror = this._onWindowError.bind (this); - window.onunload = this._onWindowUnload.bind (this); - Vn.Hash.initialize (); + ,initialize: function() { + window.onerror = this._onWindowError.bind(this); + window.onunload = this._onWindowUnload.bind(this); + Vn.Hash.initialize(); - var conn = new Db.Connection (); - this.link ({_conn: conn}, {'error': this._onConnError}); + var conn = new Db.Connection(); + this.link({_conn: conn}, {'error': this._onConnError}); - this.initAutoLogin (); + this.initAutoLogin(); } - ,run: function () - { - if (this.tryAutoLogin ()) + ,run: function() { + if (this.tryAutoLogin()) return; - var login = this._login = new Login ({conn: this._conn}); - login.on ('login', this._onLogin, this); - login.show (); + var login = this._login = new Login({conn: this._conn}); + login.on('login', this._onLogin, this); + login.show(); } - ,_onLogin: function () - { - this._freeLogin (); + ,_onLogin: function() { + this._freeLogin(); if (this._gui) return; - var gui = this._gui = new Gui ({conn: this._conn}); - gui.on ('logout', this._onLogout, this); - gui.show (); + var gui = this._gui = new Gui({conn: this._conn}); + gui.on('logout', this._onLogout, this); + gui.show(); } - ,_onLogout: function () - { - this.clearAutoLogin (); - this._freeGui (); - this.run (); + ,_onLogout: function() { + this.clearAutoLogin(); + this._freeGui(); + this.run(); } - ,_onWindowUnload: function () - { - this.unref (); + ,_onWindowUnload: function() { + this.unref(); } - ,_onWindowError: function (message, file, line, col, err) - { - var error = new Error (message); + ,_onWindowError: function(message, file, line, col, err) { + var error = new Error(message); error.fileName = file; error.lineNumber = line; - this._notifyError (error); + this._notifyError(error); } - ,_onConnError: function (conn, error) - { + ,_onConnError: function(conn, error) { if (error instanceof Vn.JsonException) - switch (error.exception) - { + switch (error.exception) { case 'BadLogin': - Htk.Toast.showError (_('Invalid login')); - this._logout (); + Htk.Toast.showError(_('Invalid login')); + this._logout(); break; case 'SessionExpired': - Htk.Toast.showError (_('You\'ve been too idle')); - this._logout (); + Htk.Toast.showError(_('You\'ve been too idle')); + this._logout(); break; case 'OutdatedVersion': - this._newVersion (error); + this._newVersion(error); break; default: - Htk.Toast.showError (error.message); + Htk.Toast.showError(error.message); } - else - { - console.error (error); - this._notifyError (error); + else { + console.error(error); + this._notifyError(error); } } - ,_logout: function () - { + ,_logout: function() { if (this._gui) - this._gui.logout (); + this._gui.logout(); } - ,_newVersion: function () - { + ,_newVersion: function() { if (this.ignoreVersion) return; this.ignoreVersion = true; - var dialog = new Htk.Dialog ({ + var dialog = new Htk.Dialog({ message: _('New version available') ,buttons: Htk.Dialog.Button.ACCEPT ,icon: 'warning' }); - dialog.on ('response', this._onNewVersionResponse, this); - dialog.open (); + dialog.on('response', this._onNewVersionResponse, this); + dialog.open(); } - ,_onNewVersionResponse: function () - { - location.reload (); + ,_onNewVersionResponse: function() { + location.reload(); } - ,_notifyError: function (error) - { - Htk.Toast.showError (_('Something went wrong')); + ,_notifyError: function(error) { + Htk.Toast.showError(_('Something went wrong')); var params = { file: error.fileName ,line: error.lineNumber ,message: error.message ,stack: error.stack + ,agent: navigator.userAgent + ,location: location.href }; - this._conn.send ('core/log', params); + this._conn.send('core/log', params); } - ,_freeLogin: function () - { - if (this._login) - { - this._login.disconnectByInstance (this); - this._login.hide (); - this._login.unref (); + ,_freeLogin: function() { + if (this._login) { + this._login.disconnectByInstance(this); + this._login.hide(); + this._login.unref(); this._login = null; } } - ,_freeGui: function () - { - if (this._gui) - { - this._gui.disconnectByInstance (this); - this._gui.hide (); - this._gui.unref (); + ,_freeGui: function() { + if (this._gui) { + this._gui.disconnectByInstance(this); + this._gui.hide(); + this._gui.unref(); this._gui = null; } } - ,_destroy: function () - { - this._freeLogin (); - this._freeGui (); - this.deinitAutoLogin (); - this._conn.unref (); + ,_destroy: function() { + this._freeLogin(); + this._freeGui(); + this.deinitAutoLogin(); + this._conn.unref(); } // Auto login functionality ,_firstLogin: true - ,initAutoLogin: function () - { - var isGuest = new Vn.HashParam - ({ + ,initAutoLogin: function() { + var isGuest = new Vn.HashParam({ type: Boolean, key: 'guest' }); - this.link ({_isGuest: isGuest}, {'changed': this._onGuestChange}); + this.link({_isGuest: isGuest}, {'changed': this._onGuestChange}); - var token = new Vn.HashParam - ({ + var token = new Vn.HashParam({ type: String, key: 'token' }); - this.link ({_token: token}, {'changed': this._onTokenChange}); + this.link({_token: token}, {'changed': this._onTokenChange}); } - ,_onGuestChange: function () - { + ,_onGuestChange: function() { if (this._isGuest.value) - setTimeout (this.tryAutoLogin.bind (this)); + setTimeout(this.tryAutoLogin.bind(this)); } - ,_onTokenChange: function () - { + ,_onTokenChange: function() { if (this._token.value) - setTimeout (this.tryAutoLogin.bind (this)); + setTimeout(this.tryAutoLogin.bind(this)); } - ,deinitAutoLogin: function () - { - this._isGuest.unref (); - this._token.unref (); + ,deinitAutoLogin: function() { + this._isGuest.unref(); + this._token.unref(); } - ,autoLogin: function () - { - var guest = localStorage.getItem ('hederaGuest'); + ,autoLogin: function() { + var guest = localStorage.getItem('hederaGuest'); - if (this._isGuest.value || guest) - { - localStorage.setItem ('hederaGuest', true); + if (this._isGuest.value || guest) { + localStorage.setItem('hederaGuest', true); return true; } if (this._token.value) this._conn.token = this._token.value; else - this._conn.fetchToken (); + this._conn.fetchToken(); if (this._conn.token) return true; @@ -227,9 +201,8 @@ module.exports = new Class return false; } - ,tryAutoLogin: function () - { - var ok = this.autoLogin (); + ,tryAutoLogin: function() { + var ok = this.autoLogin(); this._firstLogin = false; this._isGuest.value = undefined; @@ -238,13 +211,12 @@ module.exports = new Class if (!ok) return false; - this._onLogin (); + this._onLogin(); return true; } - ,clearAutoLogin: function () - { - localStorage.removeItem ('hederaGuest'); + ,clearAutoLogin: function() { + localStorage.removeItem('hederaGuest'); } }); diff --git a/package.json b/package.json index 6396f35d..455a3641 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.406.61", + "version": "1.406.62", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/rest/core/locale/mn.json b/rest/core/locale/mn.json deleted file mode 100644 index 75f9e384..00000000 --- a/rest/core/locale/mn.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "InvalidAction": "Invalid action" - - ,"EmptyQuery": "Empty query" -} diff --git a/rest/core/log.php b/rest/core/log.php index 12b44a69..abddcf2b 100644 --- a/rest/core/log.php +++ b/rest/core/log.php @@ -2,21 +2,30 @@ class Log extends Vn\Web\JsonRequest { const PARAMS = [ - 'file' + 'message' + ,'file' ,'line' - ,'message' + ,'location' + ,'agent' ,'stack' ]; function run($db) { $user = isset($_SESSION['user']) ? $_SESSION['user'] : 'guest'; - error_log(sprintf("Javascript: User: %s: %s(%d): %s.\n%s" - ,$user - ,$_REQUEST['file'] - ,$_REQUEST['line'] - ,$_REQUEST['message'] - ,$_REQUEST['stack'] - )); + $message = $_REQUEST['message']; + $file = $_REQUEST['file']; + $line = $_REQUEST['line']; + $location = $_REQUEST['location']; + $agent = $_REQUEST['agent']; + $stack = $_REQUEST['stack']; + + error_log( + "Javascript: $message in $file($line)" + ."\nLocation: $location" + ."\nAgent: $agent" + ."\nUser: $user" + ."\nStack: $stack" + ); return TRUE; } } diff --git a/rest/core/login.php b/rest/core/login.php index c5b01538..7ba660c0 100644 --- a/rest/core/login.php +++ b/rest/core/login.php @@ -4,6 +4,9 @@ include __DIR__.'/account.php'; class Login extends Vn\Web\JsonRequest { function run($db) { + if (!$_POST['user']) + throw new Vn\Web\BadLoginException(); + try { Account::trySync($db ,strtolower($_POST['user']) diff --git a/rest/misc/contact.php b/rest/misc/contact.php index 4705c930..f26eed8b 100644 --- a/rest/misc/contact.php +++ b/rest/misc/contact.php @@ -1,8 +1,9 @@ getObject('CALL myTpvTransaction_start(#, #)', diff --git a/web/mailer.php b/web/mailer.php index 464db10b..e388b6ab 100644 --- a/web/mailer.php +++ b/web/mailer.php @@ -2,9 +2,10 @@ namespace Vn\Web; -require_once 'libphp-phpmailer/PHPMailerAutoload.php'; +require_once 'libphp-phpmailer/autoload.php'; use Vn\Lib\UserException; +use PHPMailer\PHPMailer\PHPMailer; class Mailer { private $conf; @@ -19,7 +20,7 @@ class Mailer { function createObject($mailTo, $body, $subject) { $conf = $this->conf; - $mail = new \PHPMailer(); + $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = $conf->host;