From 6bf7d46acef369efbcb6a911a9207431a5c3d9ea Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 18 Nov 2019 15:04:52 +0100 Subject: [PATCH 1/9] - Added securimage via composer - Added securimage in application/views/templates/FHC-Header.php --- application/views/templates/FHC-Header.php | 51 ++++--- composer.json | 2 + composer.lock | 153 ++++++++++++++------- 3 files changed, 137 insertions(+), 69 deletions(-) diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index 3c1327d5f..03ee011b7 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -18,6 +18,7 @@ $addons = isset($addons) ? $addons : false; $ajaxlib = isset($ajaxlib) ? $ajaxlib : false; $bootstrap = isset($bootstrap) ? $bootstrap : false; + $captcha = isset($captcha) ? $captcha : false; $dialoglib = isset($dialoglib) ? $dialoglib : false; $filterwidget = isset($filterwidget) ? $filterwidget : false; $fontawesome = isset($fontawesome) ? $fontawesome : false; @@ -62,12 +63,6 @@ // Font Awesome CSS if ($fontawesome === true) generateCSSsInclude('vendor/components/font-awesome/css/font-awesome.min.css'); - // PivotUI CSS - if ($pivotui === true) - { - generateCSSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.css'); - } - // SB Admin 2 template CSS if ($sbadmintemplate === true) { @@ -75,6 +70,15 @@ generateCSSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/dist/css/sb-admin-2.min.css'); } + // Securimage CSS + if ($captcha === true) generateCSSsInclude('vendor/dapphp/securimage/securimage.css'); + + // PivotUI CSS + if ($pivotui === true) + { + generateCSSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.css'); + } + // Table sorter CSS if ($tablesorter === true) { @@ -107,6 +111,9 @@ // Eventually required CSS generateCSSsInclude($customCSSs); // Eventually required CSS + // CSS End + // -------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------- // Javascripts @@ -132,19 +139,32 @@ } // jQuery checkboxes + // NOTE: keep it after jQuery includes if ($jquerycheckboxes === true) { generateJSsInclude('vendor/rmariuzzo/jquery-checkboxes/dist/jquery.checkboxes-1.0.7.min.js'); } - // Bootstrap JS - if ($bootstrap === true) generateJSsInclude('vendor/twbs/bootstrap/dist/js/bootstrap.min.js'); - // jQuery treetable // NOTE: keep it after jQuery includes if ($jquerytreetable === true) generateJSsInclude('vendor/ludo/jquery-treetable/jquery.treetable.js'); - // MomentJS + // Bootstrap JS + if ($bootstrap === true) generateJSsInclude('vendor/twbs/bootstrap/dist/js/bootstrap.min.js'); + + // SB Admin 2 template JS + if ($sbadmintemplate === true) + { + generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/vendor/metisMenu/metisMenu.min.js'); + generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/dist/js/sb-admin-2.min.js'); + generateBackwardCompatibleJSMsIe('vendor/afarkas/html5shiv/dist/html5shiv.min.js'); + generateBackwardCompatibleJSMsIe('vendor/scottjehl/Respond/dest/respond.min.js'); + } + + // Securimage JS + if ($captcha === true) generateJSsInclude('vendor/dapphp/securimage/securimage.js'); + + // Moment JS if ($momentjs === true) { generateJSsInclude('vendor/moment/momentjs/min/moment.min.js'); @@ -152,7 +172,7 @@ generateJSsInclude('vendor/moment/momentjs/locale/en-ie.js'); } - // PivotUI CSS + // PivotUI JS if ($pivotui === true) { generateJSsInclude('vendor/nicolaskruchten/pivottable/dist/pivot.min.js'); @@ -176,15 +196,6 @@ // Tinymce JS if ($tinymce === true) generateJSsInclude('vendor/tinymce/tinymce/tinymce.min.js'); - // SB Admin 2 template JS - if ($sbadmintemplate === true) - { - generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/vendor/metisMenu/metisMenu.min.js'); - generateJSsInclude('vendor/BlackrockDigital/startbootstrap-sb-admin-2/dist/js/sb-admin-2.min.js'); - generateBackwardCompatibleJSMsIe('vendor/afarkas/html5shiv/dist/html5shiv.min.js'); - generateBackwardCompatibleJSMsIe('vendor/scottjehl/Respond/dest/respond.min.js'); - } - // -------------------------------------------------------------------------------------------------------- // From public folder diff --git a/composer.json b/composer.json index 636c6da42..7fcf8d970 100644 --- a/composer.json +++ b/composer.json @@ -258,6 +258,8 @@ "components/font-awesome": "^4.7", "components/angular.js": "1.3.16", + "dapphp/securimage": "3.6.7", + "easyrdf/easyrdf": "0.9.*", "fgelinas/timepicker": "^0.3.3", diff --git a/composer.lock b/composer.lock index 0b869361a..3c4c83d6a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "44a02c1e72626f05e682de2030c8adad", - "content-hash": "e0898c2ba3d18593851989029e54bedb", + "hash": "75b3277334ef6564aee20c9d2983d35d", + "content-hash": "68bb70c839d177e462a61df013b980c2", "packages": [ { "name": "BlackrockDigital/startbootstrap-sb-admin-2", @@ -47,7 +47,7 @@ ], "description": "Defacto way to enable use of HTML5 sectioning elements in legacy Internet Explorer.", "homepage": "http://paulirish.com/2011/the-history-of-the-html5-shiv/", - "time": "2015-07-20T20:04:00+00:00" + "time": "2015-07-20 20:04:00" }, { "name": "alvaro-prieto/colResizable", @@ -126,7 +126,7 @@ }, "type": "library", "notification-url": "https://packagist.org/downloads/", - "time": "2016-09-02T11:31:54+00:00" + "time": "2016-09-02 11:31:54" }, { "name": "codeigniter/framework", @@ -159,7 +159,7 @@ ], "description": "The CodeIgniter framework", "homepage": "https://codeigniter.com", - "time": "2019-01-16T15:49:35+00:00" + "time": "2019-01-16 15:49:35" }, { "name": "components/angular.js", @@ -463,7 +463,7 @@ ], "description": "Shim repository for Angular.js", "homepage": "http://angularjs.org", - "time": "2015-06-07T20:10:38+00:00" + "time": "2015-06-07 20:10:38" }, { "name": "components/font-awesome", @@ -498,7 +498,7 @@ "OFL-1.1" ], "description": "The iconic font designed for use with Twitter Bootstrap.", - "time": "2016-10-25T10:56:23+00:00" + "time": "2016-10-25 10:56:23" }, { "name": "components/jquery", @@ -540,7 +540,7 @@ ], "description": "jQuery JavaScript Library", "homepage": "http://jquery.com", - "time": "2018-03-04T13:23:48+00:00" + "time": "2018-03-04 13:23:48" }, { "name": "components/jqueryui", @@ -625,7 +625,56 @@ } ], "description": "jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.", - "time": "2016-09-16T05:47:55+00:00" + "time": "2016-09-16 05:47:55" + }, + { + "name": "dapphp/securimage", + "version": "3.6.7", + "source": { + "type": "git", + "url": "https://github.com/dapphp/securimage.git", + "reference": "1ecb884797c66e01a875c058def46c85aecea45b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dapphp/securimage/zipball/1ecb884797c66e01a875c058def46c85aecea45b", + "reference": "1ecb884797c66e01a875c058def46c85aecea45b", + "shasum": "" + }, + "require": { + "ext-gd": "*", + "php": ">=5.4" + }, + "suggest": { + "ext-pdo": "For database storage support", + "ext-pdo_mysql": "For MySQL database support", + "ext-pdo_sqlite": "For SQLite3 database support" + }, + "type": "library", + "autoload": { + "classmap": [ + "securimage.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Drew Phillips", + "email": "drew@drew-phillips.com" + } + ], + "description": "PHP CAPTCHA Library", + "homepage": "https://www.phpcaptcha.org", + "keywords": [ + "Forms", + "anti-spam", + "captcha", + "security" + ], + "time": "2018-03-09 06:07:41" }, { "name": "easyrdf/easyrdf", @@ -687,7 +736,7 @@ "rdfa", "sparql" ], - "time": "2015-02-27T09:45:49+00:00" + "time": "2015-02-27 09:45:49" }, { "name": "fgelinas/timepicker", @@ -697,12 +746,6 @@ "url": "https://github.com/fgelinas/timepicker", "reference": "9aebe413b784696639220bc36b7c1e8a30fda129" }, - "dist": { - "type": "zip", - "url": "https://fgelinas.com/code/timepicker/releases/jquery-ui-timepicker-0.3.3.zip", - "reference": null, - "shasum": null - }, "type": "library" }, { @@ -753,7 +796,7 @@ "faker", "fixtures" ], - "time": "2018-07-12T10:23:15+00:00" + "time": "2018-07-12 10:23:15" }, { "name": "joeldbirch/superfish", @@ -895,7 +938,7 @@ "json", "schema" ], - "time": "2014-08-25T02:48:14+00:00" + "time": "2014-08-25 02:48:14" }, { "name": "kevinlebrun/colors.php", @@ -946,7 +989,7 @@ "console", "shell" ], - "time": "2018-05-30T08:34:23+00:00" + "time": "2018-05-30 08:34:23" }, { "name": "kingsquare/json-schema-form", @@ -980,11 +1023,17 @@ } ], "description": "A framework-agnostic PHP Implementation for generating simple forms based on json-schema", - "time": "2014-07-10T12:27:19+00:00" + "time": "2014-07-10 12:27:19" }, { "name": "ludo/jquery-treetable", "version": "3.2.0", + "dist": { + "type": "zip", + "url": "https://github.com/ludo/jquery-treetable/archive/3.2.0.zip", + "reference": null, + "shasum": null + }, "type": "library" }, { @@ -1036,7 +1085,7 @@ "keywords": [ "markdown" ], - "time": "2015-03-01T12:03:08+00:00" + "time": "2015-03-01 12:03:08" }, { "name": "ml/iri", @@ -1083,7 +1132,7 @@ "uri", "url" ], - "time": "2014-01-21T13:43:39+00:00" + "time": "2014-01-21 13:43:39" }, { "name": "ml/json-ld", @@ -1132,7 +1181,7 @@ "JSON-LD", "jsonld" ], - "time": "2018-11-18T20:26:18+00:00" + "time": "2018-11-18 20:26:18" }, { "name": "moment/momentjs", @@ -1194,7 +1243,7 @@ "sorting", "table" ], - "time": "2018-11-20T21:54:28+00:00" + "time": "2018-11-20 21:54:28" }, { "name": "nategood/httpful", @@ -1244,7 +1293,7 @@ "rest", "restful" ], - "time": "2015-10-26T16:11:30+00:00" + "time": "2015-10-26 16:11:30" }, { "name": "netcarver/textile", @@ -1297,7 +1346,7 @@ "plaintext", "textile" ], - "time": "2019-01-26T17:03:58+00:00" + "time": "2019-01-26 17:03:58" }, { "name": "nicolaskruchten/pivottable", @@ -1340,7 +1389,7 @@ "pivottable", "table" ], - "time": "2018-11-04T18:21:09+00:00" + "time": "2018-11-04 18:21:09" }, { "name": "olifolkerd/tabulator", @@ -1443,7 +1492,7 @@ "x.509", "x509" ], - "time": "2019-03-10T16:53:45+00:00" + "time": "2019-03-10 16:53:45" }, { "name": "psr/log", @@ -1490,7 +1539,7 @@ "psr", "psr-3" ], - "time": "2018-11-20T15:27:04+00:00" + "time": "2018-11-20 15:27:04" }, { "name": "rdlowrey/auryn", @@ -1551,11 +1600,17 @@ "dic", "ioc" ], - "time": "2017-05-15T06:26:46+00:00" + "time": "2017-05-15 06:26:46" }, { "name": "rmariuzzo/jquery-checkboxes", "version": "1.0.7", + "dist": { + "type": "zip", + "url": "https://github.com/rmariuzzo/checkboxes.js/archive/v1.0.7.zip", + "reference": null, + "shasum": null + }, "type": "library" }, { @@ -1607,7 +1662,7 @@ "php", "template" ], - "time": "2016-02-01T16:31:13+00:00" + "time": "2016-02-01 16:31:13" }, { "name": "rougin/combustor", @@ -1672,7 +1727,7 @@ "generator", "php" ], - "time": "2016-02-14T10:36:58+00:00" + "time": "2016-02-14 10:36:58" }, { "name": "rougin/describe", @@ -1725,7 +1780,7 @@ "describe", "php" ], - "time": "2016-03-24T18:17:47+00:00" + "time": "2016-03-24 18:17:47" }, { "name": "rougin/refinery", @@ -1790,7 +1845,7 @@ "php", "refinery" ], - "time": "2016-03-04T16:55:32+00:00" + "time": "2016-03-04 16:55:32" }, { "name": "rougin/spark-plug", @@ -1849,7 +1904,7 @@ "php", "spark-plug" ], - "time": "2015-10-23T08:27:10+00:00" + "time": "2015-10-23 08:27:10" }, { "name": "scottjehl/Respond", @@ -1921,7 +1976,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-11-20T15:55:20+00:00" + "time": "2018-11-20 15:55:20" }, { "name": "symfony/debug", @@ -1978,7 +2033,7 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-07-30T07:22:48+00:00" + "time": "2016-07-30 07:22:48" }, { "name": "symfony/polyfill-ctype", @@ -2036,7 +2091,7 @@ "polyfill", "portable" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-02-06 07:57:58" }, { "name": "symfony/polyfill-mbstring", @@ -2095,7 +2150,7 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-02-06 07:57:58" }, { "name": "symfony/yaml", @@ -2145,7 +2200,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" + "time": "2018-11-11 11:18:13" }, { "name": "tapmodo/Jcrop", @@ -2202,7 +2257,7 @@ "tinymce", "wysiwyg" ], - "time": "2019-03-20T13:56:58+00:00" + "time": "2019-03-20 13:56:58" }, { "name": "tomazdragar/SimpleCropper", @@ -2263,7 +2318,7 @@ "responsive", "web" ], - "time": "2019-02-13T15:55:38+00:00" + "time": "2019-02-13 15:55:38" }, { "name": "twig/twig", @@ -2329,7 +2384,7 @@ "keywords": [ "templating" ], - "time": "2019-05-14T11:59:08+00:00" + "time": "2019-05-14 11:59:08" }, { "name": "zetacomponents/base", @@ -2393,7 +2448,7 @@ ], "description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.", "homepage": "https://github.com/zetacomponents", - "time": "2017-11-28T11:30:00+00:00" + "time": "2017-11-28 11:30:00" }, { "name": "zetacomponents/database", @@ -2470,7 +2525,7 @@ ], "description": "A lightweight database layer on top of PHP's PDO that allows you to utilize a database without having to take care of differences in SQL dialects.", "homepage": "https://github.com/zetacomponents", - "time": "2017-11-28T10:55:26+00:00" + "time": "2017-11-28 10:55:26" }, { "name": "zetacomponents/document", @@ -2521,7 +2576,7 @@ ], "description": "The Document components provides a general conversion framework for different semantic document markup languages like XHTML, Docbook, RST and similar.", "homepage": "https://github.com/zetacomponents", - "time": "2013-12-19T11:40:00+00:00" + "time": "2013-12-19 11:40:00" }, { "name": "zetacomponents/workflow", @@ -2587,7 +2642,7 @@ ], "description": "The purpose of the Workflow component is to provide the core functionality of an activity-based workflow system including the definition and execution of workflow specifications.", "homepage": "https://github.com/zetacomponents", - "time": "2014-09-27T19:26:10+00:00" + "time": "2014-09-27 19:26:10" }, { "name": "zetacomponents/workflow-database-tiein", @@ -2654,7 +2709,7 @@ ], "description": "Contains the database backend for the Workflow component.", "homepage": "https://github.com/zetacomponents", - "time": "2014-09-27T19:26:10+00:00" + "time": "2014-09-27 19:26:10" }, { "name": "zetacomponents/workflow-event-log-tiein", @@ -2714,7 +2769,7 @@ ], "description": "Contains the EventLog listener for the Workflow component.", "homepage": "https://github.com/zetacomponents", - "time": "2007-12-17T09:04:44+00:00" + "time": "2007-12-17 09:04:44" } ], "packages-dev": [], From ceb3f212c94da92c7302607bb8ea5df80a1cbdf2 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 22 Nov 2019 12:05:07 +0100 Subject: [PATCH 2/9] - Added support for language in session in function getUserLanguage from helper hlp_language_helper - If the language is loaded from database then it is checked that the language is enabled --- application/helpers/hlp_language_helper.php | 42 +++++++++++++++------ application/models/person/Person_model.php | 22 ++--------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/application/helpers/hlp_language_helper.php b/application/helpers/hlp_language_helper.php index 4dfb53c7b..8090e1e8b 100644 --- a/application/helpers/hlp_language_helper.php +++ b/application/helpers/hlp_language_helper.php @@ -18,28 +18,48 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** * Function to retrieve the language of the logged user - * If is not possible to retrieve it, then the default system language is returnd - * If as parameter is given a valid language the it's returned useful to avoid - * to write the same control structures for the language + * If is not possible to retrieve it, then the default system language is returned + * NOTE: If the given parameter is a valid language then it is returned + * It is useful to avoid to write a lot of "if else" structures */ function getUserLanguage($language = null) { + // If the given parameter is a valid language then return it if (!isEmptyString($language)) return $language; - $ci =& get_instance(); // get CI instance - - // Use the default system language, if it's possible retrieves the language for the logged user + // Use the default system language as fallback $language = DEFAULT_LANGUAGE; - // Checks if the user is authenticated to retrieve the users's language - // NOTE: this helper could be called when the user is not logged in the system - // so this is why is checked if the function getAuthUID exists - if (function_exists('getAuthUID')) + + // If the language is present in the session and it is valid + if (isset($_SESSION['sprache']) && !isEmptyString($_SESSION['sprache'])) { + $language = $_SESSION['sprache']; // then use it + } + // Otherwise checks if the user is authenticated to retrieve the users's language + // NOTE: this helper could be called when the user is NOT logged in the system + // therefore is checked if the user is logged + elseif (isLogged()) + { + $ci =& get_instance(); // get CI instance + // NOTE: Stores the loaded model with the alias PersonModelLanguage to avoid to overwrite // an already loaded PersonModel used somewhere else $ci->load->model('person/Person_model', 'PersonModelLanguage'); - $language = $ci->PersonModelLanguage->getLanguage(getAuthUID()); + // Retrieves language/s for the logged user + $languagesDB = $ci->PersonModelLanguage->getLanguage(getAuthUID()); + if (hasData($languagesDB)) + { + // Looks for the first valid language + foreach (getData($languagesDB) as $languageDB) + { + if (!isEmptyString($languageDB->sprache)) + { + $language = $languageDB->sprache; + break; + } + } + } } return $language; diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 1291427b6..c935cfbaa 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -207,28 +207,12 @@ class Person_model extends DB_Model */ public function getLanguage($uid) { - $language = DEFAULT_LANGUAGE; - + $this->addSelect('public.tbl_person.sprache'); $this->addJoin('public.tbl_benutzer', 'person_id'); + $this->addJoin('public.tbl_sprache', 'sprache'); $this->addOrder('public.tbl_person.updateamum', 'DESC'); $this->addOrder('public.tbl_person.insertvon', 'DESC'); - $persons = $this->loadWhere(array('uid' => $uid)); - - if (hasData($persons)) - { - for ($i = 0; $i < count($persons->retval); $i++) - { - $person = $persons->retval[$i]; - - if (!isEmptyString($person->sprache)) - { - $language = $person->sprache; - break; - } - } - } - - return $language; + return $this->loadWhere(array('uid' => $uid, 'content' => true)); } } From 0f9b29c52ed7086a14c458d23b289de5e8250b87 Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 25 Nov 2019 16:25:10 +0100 Subject: [PATCH 3/9] - Added private method _checkHTTPS to core/FHC_Controller - Method _checkHTTPS is called in core/FHC_Controller constructor immediately after the parent constructor call - Method _checkHTTPS checks if the HTTPS protocol is enabled and used, if NOT then an error is raised and the execution is terminated --- application/core/FHC_Controller.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 234cf6a6f..93c324b21 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -21,6 +21,9 @@ abstract class FHC_Controller extends CI_Controller { parent::__construct(); + // NOTE: placed here before performing anything else!!! + $this->_checkHTTPS(); + $this->_controllerId = null; // set _controllerId as null by default // Loads helper message to manage returning messages @@ -129,4 +132,20 @@ abstract class FHC_Controller extends CI_Controller { $this->output->set_content_type('application/json')->set_output(json_encode($mixed)); } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Checks if the call is performed via web and if HTTPS is enabled and used + * If NOT then an error is raised and the execution is terminated + */ + private function _checkHTTPS() + { + // If NOT called from command line and if the HTTPS protocol is NOT enabled + if (!$this->input->is_cli_request() && !isset($_SERVER['HTTPS'])) + { + show_error('This web site cannot work correctly without the HTTPS protocol enabled'); + } + } } From 0319d0cc2aead3884193e71c36157f07c5a75f5b Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 26 Nov 2019 15:24:26 +0100 Subject: [PATCH 4/9] - Added new constants in config/constants.php: - LANG_SESSION_ACTIVE_LANGUAGES - LANG_SESSION_CURRENT_LANGUAGE - Added new functions in helper hlp_language_helper: - setUserLanguage - getDBActiveLanguages - getActiveLanguages - Adapted code to make use of them - Added new controller controllers/widgets/Language --- application/config/constants.php | 4 +- application/controllers/widgets/Language.php | 31 ++++++ application/helpers/hlp_language_helper.php | 99 ++++++++++++++++---- 3 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 application/controllers/widgets/Language.php diff --git a/application/config/constants.php b/application/config/constants.php index ac2ecc649..621f58ecb 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -64,7 +64,9 @@ define('LDAP_TOO_MANY_USER_DN', 11); |-------------------------------------------------------------------------- */ define('LANG_SESSION_NAME', 'LANGUAGE'); -define('LANG_SESSION_INDEXES', 'LANGUAGE_INDEXES'); +define('LANG_SESSION_INDEXES', 'INDEXES'); +define('LANG_SESSION_ACTIVE_LANGUAGES', 'ACTIVE_LANGUAGES'); +define('LANG_SESSION_CURRENT_LANGUAGE', 'sprache'); // NOTE: it is not under LANG_SESSION_NAME /* |-------------------------------------------------------------------------- diff --git a/application/controllers/widgets/Language.php b/application/controllers/widgets/Language.php new file mode 100644 index 000000000..8269d3b2d --- /dev/null +++ b/application/controllers/widgets/Language.php @@ -0,0 +1,31 @@ +input->post('language'); + + $this->outputJson(setUserLanguage($language)); + } +} diff --git a/application/helpers/hlp_language_helper.php b/application/helpers/hlp_language_helper.php index 8090e1e8b..1678a4102 100644 --- a/application/helpers/hlp_language_helper.php +++ b/application/helpers/hlp_language_helper.php @@ -31,9 +31,9 @@ function getUserLanguage($language = null) $language = DEFAULT_LANGUAGE; // If the language is present in the session and it is valid - if (isset($_SESSION['sprache']) && !isEmptyString($_SESSION['sprache'])) + if (isset($_SESSION[LANG_SESSION_CURRENT_LANGUAGE]) && !isEmptyString($_SESSION[LANG_SESSION_CURRENT_LANGUAGE])) { - $language = $_SESSION['sprache']; // then use it + $language = $_SESSION[LANG_SESSION_CURRENT_LANGUAGE]; // then use it } // Otherwise checks if the user is authenticated to retrieve the users's language // NOTE: this helper could be called when the user is NOT logged in the system @@ -82,31 +82,21 @@ function getPhraseByLanguage($phraseLanguagesArray, $language) $langArray = getSessionElement(LANG_SESSION_NAME, LANG_SESSION_INDEXES); if ($langArray == null) // If not already loaded in session { - // Loads the Sprache_model to retrieve the language settings from the DB - // NOTE: Stores the loaded model with the alias SpracheModelLanguage to avoid to overwrite - // an already loaded SpracheModel used somewhere else - $ci->load->model('system/Sprache_model', 'SpracheModelLanguage'); - - // Add order clause by index and select only the sprache column - $ci->SpracheModelLanguage->addOrder('index'); - $ci->SpracheModelLanguage->addSelect('sprache'); - - // Retrieves from public.tbl_sprache - $dbLanguages = $ci->SpracheModelLanguage->load(); + // Retrieves active languages + $dbLanguages = getDBActiveLanguages(); if (hasData($dbLanguages)) // If everything is ok and contains data { $index = 0; // Incremental integer - $languageIndexes = array(); // Array that will contains languages and their indexes + $langArray = array(); // Array that will contains languages and their indexes // Loops through database results foreach (getData($dbLanguages) as $dbLanguage) { - $languageIndexes[$dbLanguage->sprache] = $index++; // set $languageIndexes array elements + $langArray[$dbLanguage->sprache] = $index++; // set $languageIndexes array elements } } - $langArray = $languageIndexes; // copy $languageIndexes to $langArray - // Set session element $_SESSION['LANG']['LANG_INDEXES'] with $languageIndexes + // Set session element $_SESSION['LANG']['LANG_INDEXES'] with $langArray setSessionElement(LANG_SESSION_NAME, LANG_SESSION_INDEXES, $langArray); } @@ -120,3 +110,78 @@ function getPhraseByLanguage($phraseLanguagesArray, $language) return $phrase; } + +/** + * Tries to load active languages from session, if not present then loads them from database and stores them in session + */ +function getActiveLanguages() +{ + $languagesArray = getSessionElement(LANG_SESSION_NAME, LANG_SESSION_ACTIVE_LANGUAGES); + if ($languagesArray == null) + { + $languagesArray = array(); + + // Retrieves from public.tbl_sprache + $dbLanguages = getDBActiveLanguages(); + if (hasData($dbLanguages)) + { + // Loops through database results + foreach (getData($dbLanguages) as $dbLanguage) + { + $languagesArray[$dbLanguage->sprache] = $dbLanguage->bezeichnung; // set $languageIndexes array elements + } + } + + // Set session element $_SESSION['LANG']['LANG_SESSION_ACTIVE_LANGUAGES'] with $languagesArray + setSessionElement(LANG_SESSION_NAME, LANG_SESSION_ACTIVE_LANGUAGES, $languagesArray); + } + + return $languagesArray; +} + +/** + * Loads active languages from database + */ +function getDBActiveLanguages() +{ + $ci =& get_instance(); // get CI instance + + // Loads the Sprache_model to retrieve the language settings from the DB + // NOTE: Stores the loaded model with the alias SpracheModelLanguage to avoid to overwrite + // an already loaded SpracheModel used somewhere else + $ci->load->model('system/Sprache_model', 'SpracheModelLanguage'); + + // Add order clause by index and select only the sprache column + $ci->SpracheModelLanguage->addOrder('index'); + $ci->SpracheModelLanguage->addSelect('sprache, bezeichnung'); + + // Retrieves from public.tbl_sprache + return $ci->SpracheModelLanguage->loadWhere(array('content' => true)); +} + +/** + * Sets the current language to render the GUI in session + */ +function setUserLanguage($language) +{ + $languageValid = false; + + // Checks if the given language is valid (present between active languages) + foreach (getActiveLanguages() as $languageName => $languageTranslation) + { + if ($language == $languageName) + { + $languageValid = true; + break; + } + } + + if ($languageValid) // if the provided language is valid + { + $_SESSION[LANG_SESSION_CURRENT_LANGUAGE] = $language; // stores it in session + + return success('Language successfully changed'); // return success!! + } + + return error('The given language is not valid'); // return an error +} From e910be58e31e964906c228652246cf11a55095ca Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 29 Nov 2019 16:37:33 +0100 Subject: [PATCH 5/9] Added phrases for account activation --- system/phrasesupdate.php | 140 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 4ec315575..10265f6f6 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -4074,6 +4074,146 @@ When on hold, the date is only a reminder.', 'insertvon' => 'system' ) ) + ), + array( + 'app' => 'core', + 'category' => 'account', + 'phrase' => 'title', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Account Aktivierung', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Account Activation', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'account', + 'phrase' => 'usage', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Bitte wählen Sie ein Passwort für Ihren Account.
Das Passwort muss zumindest 8 Zeichen enthalten, davon mindestens 1 Großbuchstabe, 1 Kleinbuchstabe und eine Ziffer.
Das Passwort darf keine Leerzeichen und Umlaute enthalten.
Erlaubte Sonderzeichen sind: -$#[]{}!().,*:;_', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Please choose a password for your account
The password must contain at least 8 characters, of which 1 must be upper case, 1 lower case and 1 a numeral.
The password may not include spaces or umlauts.
The following special characters are allowed: -$#[]{}!().,*:;_', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'account', + 'phrase' => 'username', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Username', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Username', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'account', + 'phrase' => 'code', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Code', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Code', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'captcha', + 'phrase' => 'label', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Tippen Sie die angezeigten
Zeichen in das untere Feld.', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Enter the characters in
the field below.', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'captcha', + 'phrase' => 'reload', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Ich kann das Bild nicht lesen - neu laden', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Reload picture', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'account', + 'phrase' => 'activate', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Abschicken', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Activate', + 'description' => '', + 'insertvon' => 'system' + ) + ) ) ); From 5c3aed92f00c027ccabefd0c9e2332e2e29081a7 Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 3 Dec 2019 16:07:45 +0100 Subject: [PATCH 6/9] Added missing phrase --- system/phrasesupdate.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 10265f6f6..8d36e8a43 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -3769,7 +3769,7 @@ When on hold, the date is only a reminder.', ), array( 'sprache' => 'English', - 'text' => 'Please enter the old an new password', + 'text' => 'Please enter the old and the new password', 'description' => '', 'insertvon' => 'system' ) @@ -4214,6 +4214,26 @@ When on hold, the date is only a reminder.', 'insertvon' => 'system' ) ) + ), + array( + 'app' => 'core', + 'category' => 'password', + 'phrase' => 'wrongCaptcha', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Captcha code falsch ', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Captcha code is wrong', + 'description' => '', + 'insertvon' => 'system' + ) + ) ) ); From 4cf6ed9e0c83942cba1011d267e57b403e1e2ae1 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 4 Dec 2019 13:27:49 +0100 Subject: [PATCH 7/9] Added new CryptLib as a collection of different encryption/hashing algorithms based on phpseclib --- application/libraries/CryptLib.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 application/libraries/CryptLib.php diff --git a/application/libraries/CryptLib.php b/application/libraries/CryptLib.php new file mode 100644 index 000000000..ea19f3e5b --- /dev/null +++ b/application/libraries/CryptLib.php @@ -0,0 +1,28 @@ +setBlockLength(256); + $cipher->setKey($key); + + if ($paddingDisabled === true) $cipher->disablePadding(); + + return $cipher->encrypt($value); + } +} From 64976c31df063a873341e669a6a1401881600d20 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 4 Dec 2019 13:56:10 +0100 Subject: [PATCH 8/9] Added new weblogservice type: API --- system/dbupdate_3.3.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index f73517090..0cc307bf2 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -3449,6 +3449,20 @@ if(!$result = @$db->db_query("SELECT 1 FROM fue.tbl_projekttyp LIMIT 1")) echo '
fue.tbl_projekttyp hinzugefuegt.'; } +// Add new webservice type in system.tbl_webservicetyp +if ($result = @$db->db_query("SELECT 1 FROM system.tbl_webservicetyp WHERE webservicetyp_kurzbz = 'API';")) +{ + if ($db->db_num_rows($result) == 0) + { + $qry = "INSERT INTO system.tbl_webservicetyp(webservicetyp_kurzbz, beschreibung) VALUES('API', 'Cronjob');"; + + if (!$db->db_query($qry)) + echo 'system.tbl_webservicetyp '.$db->db_last_error().'
'; + else + echo ' system.tbl_webservicetyp: Added webservice type "API"
'; + } +} + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; From 6e89a917ae1293dab2d5f5fa5e3263667664eaf5 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 4 Dec 2019 15:12:19 +0100 Subject: [PATCH 9/9] Added missing phrases --- system/phrasesupdate.php | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 8d36e8a43..0ddd71019 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -4234,7 +4234,47 @@ When on hold, the date is only a reminder.', 'insertvon' => 'system' ) ) - ) + ), + array( + 'app' => 'core', + 'category' => 'account', + 'phrase' => 'missingParameters', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Bitte geben Sie Benutzername, Code und Passwort ein', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Please enter username, code and password', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'account', + 'phrase' => 'wrongActivationCode', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Der angegebene Aktivierungscode ist falsch', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'The provided activation code is wrong', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ) );