diff --git a/debian/changelog b/debian/changelog index fee3a56f..4deef374 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.26) stable; urgency=low +hedera-web (1.405.27) stable; urgency=low * Initial Release. diff --git a/js/vn/json-connection.js b/js/vn/json-connection.js index 4b583e73..ffd4912a 100644 --- a/js/vn/json-connection.js +++ b/js/vn/json-connection.js @@ -54,9 +54,9 @@ module.exports = new Class if (user !== null && user !== undefined) { var params = { - 'user': user - ,'password': pass - ,'remember': remember + user: user + ,password: pass + ,remember: remember }; } else @@ -125,7 +125,7 @@ module.exports = new Class **/ ,supplantUser: function (user, callback) { - var params = {'supplantUser': user}; + var params = {supplantUser: user}; this.send ('core/supplant', params, this._onUserSupplant.bind (this, callback)); } @@ -160,9 +160,9 @@ module.exports = new Class if (!params) params = {}; - params['srv'] = 'json:'+ restService; + params.srv = 'json:'+ restService; - this.sendWithUrl (params, callback, 'post', '.'); + this.sendWithUrl (params, callback, 'POST', '.'); } ,sendForm: function (form, callback) @@ -174,7 +174,7 @@ module.exports = new Class if (elements[i].name) params[elements[i].name] = elements[i].value; - this.sendWithUrl (params, callback, 'post', form.action); + this.sendWithUrl (params, callback, 'POST', form.action); } ,sendFormMultipart: function (form, callback) @@ -185,7 +185,7 @@ module.exports = new Class formData.append ('token', this.token); var request = new XMLHttpRequest (); - request.open ('post', form.action, true); + request.open ('POST', form.action, true); request.onreadystatechange = this._onStateChange.bind (this, request, callback); request.send (formData); @@ -199,7 +199,7 @@ module.exports = new Class formData.append ('token', this.token); var request = new XMLHttpRequest (); - request.open ('post', '', true); + request.open ('POST', '', true); request.onreadystatechange = this._onStateChange.bind (this, request, callback); request.send (formData); diff --git a/package.json b/package.json index 6fd0f08e..d219f4ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.405.26", + "version": "1.405.27", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/pages/production/main.js b/pages/production/main.js index d48c53e0..f776ecfb 100644 --- a/pages/production/main.js +++ b/pages/production/main.js @@ -5,9 +5,15 @@ var INTERVAL = 5; var requestInterval = INTERVAL; +var failedRequests = 0; var timeoutId = null; var request = null; +function onBodyLoad () +{ + updateText (); +} + function onSettingsClick () { var deviceId = localStorage.getItem ('hederaDeviceId'); @@ -36,11 +42,6 @@ function onSettingsClick () updateText (); } -function onBodyLoad () -{ - updateText (); -} - function updateText () { var deviceId = localStorage.getItem ('hederaDeviceId'); @@ -56,7 +57,7 @@ function updateText () formData.append ('deviceId', deviceId); request = new XMLHttpRequest(); - request.open ('post', '', true); + request.open ('POST', '', true); request.onreadystatechange = onRequestChange.bind (null, request); request.send (formData); @@ -74,6 +75,7 @@ function onRequestChange (request) var json = JSON.parse (request.responseText); display (json.data); requestInterval = INTERVAL; + failedRequests = 0; break; case 400: var json = JSON.parse (request.responseText); @@ -86,8 +88,9 @@ function onRequestChange (request) { display (e.message, true); console.error (e.message); + failedRequests++; - if (requestInterval < 60) + if (failedRequests > 10 && requestInterval < 60) { requestInterval += parseInt (Math.random() * 10) + 1; console.warn ('Request interval increased to %d seconds.', requestInterval); diff --git a/pages/production/style.css b/pages/production/style.css index 2c424c77..7ca55cda 100644 --- a/pages/production/style.css +++ b/pages/production/style.css @@ -23,7 +23,7 @@ body #text { color: white; - font-size: 20em; + font-size: 15em; text-align: center; font-weight: bold; text-overflow: ellipsis; diff --git a/pages/production/ui.php b/pages/production/ui.php index 3a0c8897..54c6b119 100644 --- a/pages/production/ui.php +++ b/pages/production/ui.php @@ -4,16 +4,14 @@ + + - - - - - - + + Production diff --git a/pages/update-browser/ui.php b/pages/update-browser/ui.php index cdf53f03..49e6e1f5 100755 --- a/pages/update-browser/ui.php +++ b/pages/update-browser/ui.php @@ -3,8 +3,9 @@ + - + Verdnatura diff --git a/pages/version-menu/ui.php b/pages/version-menu/ui.php index 9e7665ca..12be46ae 100755 --- a/pages/version-menu/ui.php +++ b/pages/version-menu/ui.php @@ -3,8 +3,9 @@ + - + Verdnatura diff --git a/rest/core/account.php b/rest/core/account.php index f902bcc3..17403c97 100755 --- a/rest/core/account.php +++ b/rest/core/account.php @@ -42,9 +42,6 @@ class Account */ static function ldapSync ($db, $userName, $password) { - if (empty ($password)) - return; - // Gets LDAP configuration parameters $conf = $db->getObject ( @@ -58,81 +55,114 @@ class Account if (!$ds) throw new Exception ("Can't connect to LDAP server: ". ldapError ($ds)); - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); - $bind = ldap_bind ($ds, $conf->rdn, base64_decode ($conf->password)); + try { + ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + $bind = ldap_bind ($ds, $conf->rdn, base64_decode ($conf->password)); - if (!$bind) - throw new Exception ("Authentication failed on LDAP server: ". ldapError ($ds)); + if (!$bind) + throw new Exception ("Authentication failed on LDAP server: ". ldapError ($ds)); - // Prepares the data + // Prepares the data - $domain = $db->getValue ('SELECT domain FROM account.mailConfig'); + $domain = $db->getValue ('SELECT domain FROM account.mailConfig'); - $user = $db->getObject ( - 'SELECT id, nickname, lang - FROM account.user - WHERE name = #', - [$userName] - ); + $user = $db->getObject ( + 'SELECT id, nickname, lang + FROM account.user + WHERE name = #', + [$userName] + ); - $nameArgs = explode (' ', $user->nickname); - $givenName = $nameArgs[0]; + $cn = empty ($user->nickname) ? $userName : $user->nickname; - if (count ($nameArgs) > 1) - $sn = $nameArgs[1]; - if (empty ($sn)) - $sn = 'Empty'; + $nameArgs = explode (' ', $user->nickname); + $givenName = $nameArgs[0]; - $info = [ - 'cn' => $user->nickname, - 'displayName' => $user->nickname, - 'givenName' => $givenName, - 'sn' => $sn, - 'mail' => "$userName@{$domain}", - 'userPassword' => sshaEncode ($password), - 'preferredLanguage' => $user->lang - ]; + if (count ($nameArgs) > 1) + $sn = $nameArgs[1]; + if (empty ($sn)) + $sn = 'Empty'; - // Search the user entry + $attrs = [ + 'cn' => $cn, + 'displayName' => $user->nickname, + 'givenName' => $givenName, + 'sn' => $sn, + 'mail' => "$userName@{$domain}", + 'userPassword' => sshaEncode ($password), + 'preferredLanguage' => $user->lang + ]; - $filter = "uid=$userName"; + // Search the user entry - if (!empty($conf->filter)) - $filter = "(&($filter)($conf->filter))"; + $filter = "uid=$userName"; - $res = ldap_search ($ds, $conf->baseDn, $filter); + if (!empty($conf->filter)) + $filter = "(&($filter)($conf->filter))"; - if (!$res) - throw new Exception ("Can't get the LDAP entry: ". ldapError ($ds)); + $res = ldap_search ($ds, $conf->baseDn, $filter); - $dn = "uid=$userName,{$conf->baseDn}"; - $entry = ldap_first_entry ($ds, $res); + if (!$res) + throw new Exception ("Can't get the LDAP entry: ". ldapError ($ds)); - $classes = ldap_get_values ($ds, $entry, 'objectClass'); + $dn = "uid=$userName,{$conf->baseDn}"; + $entry = ldap_first_entry ($ds, $res); - if (!in_array ('inetOrgPerson', $classes)) - { - ldap_delete ($ds, $dn); - $entry = NULL; + $classes = ldap_get_values ($ds, $entry, 'objectClass'); + + if (!in_array ('inetOrgPerson', $classes)) + { + ldap_delete ($ds, $dn); + $entry = NULL; + } + + if ($entry) + { + $modifs = []; + $curAttrs = ldap_get_attributes ($ds, $entry); + + foreach ($attrs as $attribute => $value) + if (!empty ($value)) + { + $modifs[] = [ + 'attrib' => $attribute, + 'modtype' => LDAP_MODIFY_BATCH_REPLACE, + 'values' => [$value] + ]; + } + elseif (isset ($curAttrs[$attribute])) + { + $modifs[] = [ + 'attrib' => $attribute, + 'modtype' => LDAP_MODIFY_BATCH_REMOVE_ALL + ]; + } + + $updated = ldap_modify_batch ($ds, $dn, $modifs); + } + else + { + $addAttrs = []; + + foreach ($attrs as $attribute => $value) + if (!empty ($value)) + $addAttrs[$attribute] = $value; + + $addAttrs = array_merge ($addAttrs, [ + 'objectClass' => ['inetOrgPerson'], + 'uid' => $userName + ]); + $updated = ldap_add ($ds, $dn, $addAttrs); + } + + if (!$updated) + throw new Exception ("Can't update the LDAP entry: ". ldapError ($ds)); } - - if ($entry) + catch (Exception $e) { - $updated = ldap_modify ($ds, $dn, $info); + ldap_unbind ($ds); + throw $e; } - else - { - $info = array_merge ($info, [ - 'objectClass' => ['inetOrgPerson'], - 'uid' => $userName - ]); - $updated = ldap_add ($ds, $dn, $info); - } - - if (!$updated) - throw new Exception ("Can't update the LDAP entry: ". ldapError ($ds)); - - ldap_unbind ($ds); } /** diff --git a/web/html.php b/web/html.php index 39414add..f18b6e1b 100644 --- a/web/html.php +++ b/web/html.php @@ -1,15 +1,16 @@ getVersion(); function getUrl ($fileName) { if (file_exists ($fileName)) - $mTime = '?'. strftime ('%G%m%d%H%M%S', filemtime ($fileName)); + $fileVersion = strftime ('%G%m%d%H%M%S', filemtime ($fileName)); else - $mTime = '?'. $this->getVersion (); + $fileVersion = $version; - return $fileName.$mTime; + return "$fileName?$fileVersion"; } function js ($fileName)