From 51096cbe434198b656a21d2b42348458dca77fe6 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 11 Jan 2023 16:35:14 +0100 Subject: [PATCH 01/14] Bug : default accounting override existing one --- include/class/card_property.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class/card_property.class.php b/include/class/card_property.class.php index b01dc73f6..45b362f74 100644 --- a/include/class/card_property.class.php +++ b/include/class/card_property.class.php @@ -188,7 +188,7 @@ class Card_Property $result['msg'] .= " " . _("Rappel: Poste par défaut sera ") . $p_fiche_def->class_base . " ! "; - $result['input']->value = $p_fiche_def->class_base; + $result['input']->value = (empty ($result['input']->value)) ?$p_fiche_def->class_base:$result['input']->value; } } $result['label']=_("Poste comptable"); From 1a20f95ca0ce60049111e53fbf64128d9ab3f63c Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 11 Jan 2023 16:35:14 +0100 Subject: [PATCH 02/14] Bug : default accounting override existing one --- include/class/card_property.class.php | 4 +- unit-test/include/class/card_propertyTest.php | 47 +++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/include/class/card_property.class.php b/include/class/card_property.class.php index 45b362f74..6ee51211c 100644 --- a/include/class/card_property.class.php +++ b/include/class/card_property.class.php @@ -49,11 +49,11 @@ class Card_Property var $cn; //!< cn database connexion protected $display_mode; - //!< display mode determine if there link + //!< display mode values are large , window , display Property depending of this mode. function __construct($cn, $ad_id=0) { $this->cn=$cn; - $this->ad_id=0; + $this->ad_id=$ad_id; $this->display_mode='window'; } public function __toString(): string diff --git a/unit-test/include/class/card_propertyTest.php b/unit-test/include/class/card_propertyTest.php index 48f82bd20..4e8e89898 100644 --- a/unit-test/include/class/card_propertyTest.php +++ b/unit-test/include/class/card_propertyTest.php @@ -217,4 +217,51 @@ class Card_PropertyTest extends TestCase 'count of card properties must be the same than the card category (fiche_def )'); } + /** + * @testdox Build Input for automatic account , for a new card , the account is null + * @return void + */ + public function testBuildInput1() + { + $g_connection=Dossier::connect(); + + + $property=new \Card_Property($g_connection,ATTR_DEF_ACCOUNT); + $g_connection->exec_sql("update fiche_def set fd_create_account=true where fd_id=25"); + $fiche_def=new \Fiche_Def($g_connection,25); + + $result=$property->build_input($fiche_def); + + /* + $file_result=__CLASS__."-".__FUNCTION__.".txt"; + $file_target='target-'.$file_result; + \Noalyss\Facility::save_file(__DIR__."/file",$file_result,var_export($result,true)); + $this->assertFileEquals(__DIR__."/file/$file_target",__DIR__."/file/$file_result","Card_Property::build_input failed"); + */ + $this->assertEquals("",$result["input"]->value," Accounting incorrect "); + + } + /** + * @testdox Build Input for default account , for a new card , the account is the account of the category + * @return void + */ + + public function testBuildInput2() + { + $g_connection=Dossier::connect(); + $g_connection->exec_sql("update fiche_def set fd_create_account=false where fd_id=25"); + + $property=new \Card_Property($g_connection,ATTR_DEF_ACCOUNT); + $fiche_def=new \Fiche_Def($g_connection,25); + $result=$property->build_input($fiche_def); + $g_connection->exec_sql("update fiche_def set fd_create_account=true where fd_id=25"); + /* + $file_result=__CLASS__."-".__FUNCTION__.".txt"; + $file_target='target-'.$file_result; + \Noalyss\Facility::save_file(__DIR__."/file",$file_result,var_export($result,true)); + $this->assertFileEquals(__DIR__."/file/$file_target",__DIR__."/file/$file_result","Card_Property::build_input failed"); + */ + $this->assertEquals("600",$result["input"]->value," Accounting incorrect "); + } + } From 6620a4cd077b72fb2064da5fa756ed053249b734 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 14 Jan 2023 12:59:26 +0100 Subject: [PATCH 03/14] NEW #0002205 Mode maintenance --- block.html-example | 5 +++++ html/admin-noalyss.php | 3 +++ html/ajax.php | 4 +++- html/compute.php | 3 +++ html/direct.php | 2 ++ html/do.php | 6 ++++-- html/export.php | 3 +++ html/extension.raw.php | 2 ++ html/fid.php | 3 ++- html/fid_card.php | 3 +++ html/index.php | 2 ++ html/login.php | 3 ++- html/mobile.php | 5 ++++- html/recherche.php | 2 ++ html/user_login.php | 2 ++ include/lib/ac_common.php | 12 ++++++++++++ unit-test/global.php | 2 +- 17 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 block.html-example diff --git a/block.html-example b/block.html-example new file mode 100644 index 000000000..886160f1d --- /dev/null +++ b/block.html-example @@ -0,0 +1,5 @@ +

Nous sommes en maintenance

+

+ Le site est actuellement en maintenance. +

+ diff --git a/html/admin-noalyss.php b/html/admin-noalyss.php index c6d273783..bafab207b 100644 --- a/html/admin-noalyss.php +++ b/html/admin-noalyss.php @@ -31,6 +31,7 @@ if (file_exists("../include/config.inc.php") ) { define ('ALLOWED',1); define ('ALLOWED_ADMIN',1); require_once '../include/constant.php'; + require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; \Noalyss\Dbg::echo_file(__FILE__); if ( DEBUGNOALYSS > 1 ) { @@ -41,6 +42,8 @@ if (file_exists("../include/config.inc.php") ) { \Noalyss\Dbg::display_request(); \Noalyss\Dbg::display_global(); } //<--- if DEBUG + + MaintenanceMode("block.html"); require_once NOALYSS_INCLUDE.'/admin_repo.inc.php'; } else { // Redirect to install file , if this file exists then diff --git a/html/ajax.php b/html/ajax.php index ecac8dc10..2d32d7521 100644 --- a/html/ajax.php +++ b/html/ajax.php @@ -14,12 +14,13 @@ */ if ( ! defined ('ALLOWED') ) define ('ALLOWED',1); require_once '../include/constant.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; require_once NOALYSS_INCLUDE.'/class/extension.class.php'; if ( !isset ($_REQUEST['gDossier'])) exit(); - +MaintenanceMode("block.html"); require_once NOALYSS_INCLUDE.'/class/noalyss_parameter_folder.class.php'; mb_internal_encoding("UTF-8"); /** @@ -29,6 +30,7 @@ if ( ! isset($_SESSION[SESSION_KEY."g_user"])) { echo "NOCONX"; die(); } + global $g_user,$cn,$g_parameter; $cn=Dossier::connect(); $g_parameter=new Noalyss_Parameter_Folder($cn); diff --git a/html/compute.php b/html/compute.php index 8f4ad674e..7d70e99dd 100644 --- a/html/compute.php +++ b/html/compute.php @@ -37,6 +37,9 @@ require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; require_once NOALYSS_INCLUDE.'/class/acc_tva.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + // Check if the needed field does exist extract ($_GET, EXTR_SKIP ); foreach (array('t','c','p','q','n','gDossier') as $a) diff --git a/html/direct.php b/html/direct.php index 3148e2226..1f10466a4 100644 --- a/html/direct.php +++ b/html/direct.php @@ -24,6 +24,8 @@ require_once '../include/constant.php'; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); $cn=Dossier::connect(); global $g_user; diff --git a/html/do.php b/html/do.php index d24e5bf0d..68e9b21c2 100644 --- a/html/do.php +++ b/html/do.php @@ -23,13 +23,15 @@ define('ALLOWED',1); * \brief Main file */ require_once '../include/constant.php'; +require_once NOALYSS_INCLUDE.'/constant.security.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; + +MaintenanceMode("block.html"); require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; require_once NOALYSS_INCLUDE.'/lib/user_common.php'; -require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; require_once NOALYSS_INCLUDE.'/lib/function_javascript.php'; -require_once NOALYSS_INCLUDE.'/constant.security.php'; require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; diff --git a/html/export.php b/html/export.php index e56a3423e..dda4479b4 100644 --- a/html/export.php +++ b/html/export.php @@ -26,6 +26,9 @@ */ define ('ALLOWED',1); require_once '../include/constant.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + global $g_user,$cn,$g_parameter; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; diff --git a/html/extension.raw.php b/html/extension.raw.php index b484ff547..2b639dc90 100644 --- a/html/extension.raw.php +++ b/html/extension.raw.php @@ -33,6 +33,8 @@ require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/iselect.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; +MaintenanceMode("block.html"); + global $g_user,$cn,$g_parameter; $http=new HttpInput(); $cn=Dossier::connect(); diff --git a/html/fid.php b/html/fid.php index 1f18cfa29..854b6a512 100644 --- a/html/fid.php +++ b/html/fid.php @@ -33,7 +33,8 @@ *\note if the j is -1 then all the card are shown */ require_once '../include/constant.php'; - +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); /** * if not connected, session is expired then exit with a message NOCONX */ diff --git a/html/fid_card.php b/html/fid_card.php index 27bfc71a3..fa8a98694 100644 --- a/html/fid_card.php +++ b/html/fid_card.php @@ -40,6 +40,9 @@ require_once '../include/constant.php'; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + /** * if not connected, session is expired then exit with a message NOCONX */ diff --git a/html/index.php b/html/index.php index 501e843c6..81d11a029 100644 --- a/html/index.php +++ b/html/index.php @@ -158,6 +158,8 @@ $my_domain=""; require_once '../include/constant.php'; require_once '../include/config.inc.php'; require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + if ( file_exists("install.php")&& DEBUGNOALYSS == 0 ) { // At the end of the installation procedure , the install file must be removed diff --git a/html/login.php b/html/login.php index 7fb03441a..d3588d023 100644 --- a/html/login.php +++ b/html/login.php @@ -19,7 +19,8 @@ // Copyright Author Dany De Bontridder danydb@aevalys.eu require_once '../include/constant.php'; -include_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); /*! \file * \brief Login page diff --git a/html/mobile.php b/html/mobile.php index 5c19d8ef3..a62d688a6 100644 --- a/html/mobile.php +++ b/html/mobile.php @@ -23,8 +23,11 @@ * @file * @brief only for mobile device */ - + require_once '../include/constant.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + global $g_user; $cn=new Database(); diff --git a/html/recherche.php b/html/recherche.php index c914bdf0d..5d04bf7ec 100644 --- a/html/recherche.php +++ b/html/recherche.php @@ -28,6 +28,8 @@ require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php'; require_once NOALYSS_INCLUDE.'/class/acc_ledger_search.class.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; +MaintenanceMode("block.html"); + if ( ! isset ($_SESSION[SESSION_KEY.'g_theme'])) { echo "

"._('Vous êtes déconnecté')."

"; diff --git a/html/user_login.php b/html/user_login.php index 3582a17c9..e4477ff43 100644 --- a/html/user_login.php +++ b/html/user_login.php @@ -30,6 +30,8 @@ require_once NOALYSS_INCLUDE.'/lib/function_javascript.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; @html_page_start($_SESSION[SESSION_KEY.'g_theme']); +MaintenanceMode("block.html"); + $rep=new Database(); require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; $User=new Noalyss_user($rep); diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index a2659f714..98ec334db 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -1686,3 +1686,15 @@ function linkTo($p_url) return $p_url; } } +/** + * @brief When you want to prevent users to connect, create a file in noalyss/ (NOALYSS_BASE) with the + * message in Html + * @param string $p_file file in NOALYSS_BASE + */ +function MaintenanceMode($p_file) +{ + if ( file_exists(NOALYSS_BASE."/".$p_file )) { + include NOALYSS_BASE."/".$p_file; + exit; + } +} diff --git a/unit-test/global.php b/unit-test/global.php index 2eeeb83aa..13d094206 100644 --- a/unit-test/global.php +++ b/unit-test/global.php @@ -24,7 +24,7 @@ * Global variables */ global $g_connection,$g_parameter,$g_user; -if (!defined("DOSSIER"))define ("DOSSIER",25); +if (!defined("DOSSIER"))define ("DOSSIER",101); $_REQUEST['gDossier'] = DOSSIER; $g_connection=new Database(DOSSIER); From f7b3dc6534a5beecf83cd68bc471350a357491dd Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 14 Jan 2023 14:04:06 +0100 Subject: [PATCH 04/14] Fix : generate_random_string returns always same value , due to a change in srand() --- include/lib/ac_common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 98ec334db..581d8b30d 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -1473,7 +1473,7 @@ function generate_random_string($car) { $string=""; $chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-="; - srand((int) microtime()*1020030); + srand((float) microtime(true)*1020030); for ($i=0; $i<$car; $i++) { $string .= $chaine[rand()%strlen($chaine)]; From e0c0649fdf85d4254633257234df7a0e1c9f717d Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 14 Jan 2023 14:07:06 +0100 Subject: [PATCH 05/14] Improve security : function isAdmin recheck the password --- html/user_login.php | 4 ++-- include/ajax/ajax_admin.php | 2 +- include/class/noalyss_user.class.php | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/html/user_login.php b/html/user_login.php index e4477ff43..126a4ebec 100644 --- a/html/user_login.php +++ b/html/user_login.php @@ -98,7 +98,7 @@ if ( $version < DBVERSIONREPO ) echo ''.$a.''; } -if ( $User->Admin() == 1) +if ( $User->isAdmin() == 1) { if (SITE_UPDATE !="") { $update=@file_get_contents(SITE_UPDATE); @@ -137,7 +137,7 @@ load_all_script(); $result=""; $result.=""; $result.=''; -if ( $User->Admin() == 1 ) +if ( $User->isAdmin() == 1 ) { $result.=""; } diff --git a/include/ajax/ajax_admin.php b/include/ajax/ajax_admin.php index 5715b3c29..b49d96053 100644 --- a/include/ajax/ajax_admin.php +++ b/include/ajax/ajax_admin.php @@ -28,7 +28,7 @@ if (!defined('ALLOWED')) * @see admin-noalyss.php ajax_misc.php admin.js */ global $g_user; -if ($g_user->Admin()==0) +if ($g_user->isAdmin()==0) { die(); } diff --git a/include/class/noalyss_user.class.php b/include/class/noalyss_user.class.php index f7bce1716..0394287d0 100644 --- a/include/class/noalyss_user.class.php +++ b/include/class/noalyss_user.class.php @@ -657,25 +657,25 @@ class Noalyss_User * synomym for isAdmin, * @deprecated */ - function Admin() + function Admin():int { return $this->isAdmin(); } /** - * @brief Check if an user is an admin + * @brief Check if an user is an admin and check also his password * * @return 1 for yes 0 for no */ - function isAdmin() + function isAdmin():int { $this->admin=0; $pass5=$this->password; $sql="select count(*) from ac_users where use_login=$1 - and use_active=1 and use_admin=1 "; + and use_active=1 and use_admin=1 and use_pass=$2 "; $cn=new Database(); - $this->admin=$cn->get_value($sql, array($this->login)); + $this->admin=$cn->get_value($sql, array($this->login,$pass5)); return $this->admin; } From 67e179c9956d5c67ecc972c93c0585e5a86aaa36 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 14 Jan 2023 14:07:34 +0100 Subject: [PATCH 06/14] Improve security : replace $_POST by Http_Input --- include/dossier.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dossier.inc.php b/include/dossier.inc.php index f27008a1d..e00d460c7 100644 --- a/include/dossier.inc.php +++ b/include/dossier.inc.php @@ -82,7 +82,7 @@ if ( isset ($_POST["DATABASE"]) ) { alert(_('Désolé vous devez migrer ce modèle en unicode')); echo ''; - echo _('le modele ').domaine.'mod'.$_POST["FMOD_ID"]._(" doit être migré en unicode."); + echo _('le modele ').domaine.'mod'.$http->post("FMOD_ID","number")._(" doit être migré en unicode."); echo _('Pour le passer en unicode, faites-en une sauvegarde puis restaurez le fichier reçu').''; echo HtmlInput::button_anchor('Retour','admin-noalyss.php?action=dossier_mgt'); return; From 1468f26239df074c14e4e75bffc24fdecdb8dfb1 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 15 Jan 2023 17:00:51 +0100 Subject: [PATCH 07/14] Fix : the select range select also the hidden element --- html/js/noalyss_checkbox.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/html/js/noalyss_checkbox.js b/html/js/noalyss_checkbox.js index 04c44b26e..61272c176 100644 --- a/html/js/noalyss_checkbox.js +++ b/html/js/noalyss_checkbox.js @@ -58,7 +58,15 @@ function checkbox_set_range(evt, elt, p_name) { } var check = (aName[from].checked) ? true : false; for (x = from; x <= end; x++) { - aName[x].checked = check; + if (aName[x].parentNode.parentNode ) + { + if ( window.getComputedStyle(aName[x].parentNode.parentNode).display != "none" ) { + /* console.debug(window.getComputedStyle(aName[x].parentNode.parentNode).display);*/ + aName[x].checked = check; + } + } else { + aName[x].checked = check; + } } } From a8e8f0bbe8bf4d914094cb61fb660f299be6a75d Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 15 Jan 2023 22:24:54 +0100 Subject: [PATCH 08/14] Documentation --- include/lib/data_sql.class.php | 53 +++++++++++++++++++++++++- include/lib/manage_table_sql.class.php | 3 +- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/include/lib/data_sql.class.php b/include/lib/data_sql.class.php index 37b0bc1f5..55d0353d3 100644 --- a/include/lib/data_sql.class.php +++ b/include/lib/data_sql.class.php @@ -38,7 +38,31 @@ * - type = array , match between column and type of data * - default = array of column with a default value * - date_format = format of the date - * + * + * if you give a SQL or a View you have to give a primary key, usually , the best is to use a key composed of + * different PK of the tables + * Example : in this SQL (or view) the PK is id and it is composed with the PK f_id and sg_id , remember that the + * pk cannot be null and must be unique ! For SQL , the value is computed , so you need a subselect like this + @code + select + ssw.sg_id::text||'-'||vfp.f_id::text id, + vfp.f_id,vfp.f_enable,vfp.person_name ,vfp.person_fname ,vfp.person_qcode ,ssw.sg_id + from rash.vw_fiche_person vfp + join rash.security_social_worker ssw using(f_id) ; + @endcode + * + * For SQL , the value is computed , so you need a subselect like this +@code + select * from ( + select + ssw.sg_id::text||'-'||vfp.f_id::text id, + vfp.f_id,vfp.f_enable,vfp.person_name ,vfp.person_fname ,vfp.person_qcode ,ssw.sg_id + from rash.vw_fiche_person vfp + join rash.security_social_worker ssw using(f_id))sub1 +@encode + * + * + * * After you call the parent constructor * @note the view or the table must include an unique key, otherwise the load * doesn't work. @@ -199,6 +223,33 @@ abstract class Data_SQL return $this->$pk; } + /** + * @brief Load the current row return false if not found + * @code + $pk=$this->primary_key; + if ( $this->get_limit_fiche_qcode() != 0 ) + { + $sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode()); + } else + { + $sql=sprintf($this->sql," "); + } + $result=$this->cn->get_array($sql. " where id=$1",array ($this->$pk)); + if ($this->cn->count()==0) + { + $this->$pk=-1; + return false; + } + + foreach ($result[0] as $key=> $value) + { + $this->$key=$value; + } + return true; + * + * @endcode + * @return bool + */ abstract function load():bool; public function get_info() diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index ba52307db..45cffff6f 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -31,7 +31,7 @@ \code $objet->set_pk($p_id); // It is very important to set the name of the javascript variable - // Contained in the http_input variable "ctl" + // Contained in the http_input variable "ctl" , without this the list cannot be updated $objet->set_object_name($objet_name); // Set the ajax to call @@ -51,6 +51,7 @@ $json=json_encode($aJson); $objet->param_set($json); + // Display the box header('Content-type: text/xml; charset=UTF-8'); $xml=$objet->ajax_input(); From bb76801304f4d9b795465b8b8e1c97c8f91d5cd4 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 15 Jan 2023 22:25:28 +0100 Subject: [PATCH 09/14] Fix : if there is no stock there is an exception instead of a warning --- include/class/stock_goods.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/class/stock_goods.class.php b/include/class/stock_goods.class.php index 1e2d8da7d..668f07985 100644 --- a/include/class/stock_goods.class.php +++ b/include/class/stock_goods.class.php @@ -74,10 +74,10 @@ class Stock_Goods extends Stock_Goods_Sql $motif->size = 80; $idepo = HtmlInput::select_stock($cn, "p_depot", "W"); $idepo->setReadOnly($p_readonly); - if (count($idepo->value) == 0) + if (empty($idepo->value) ) { - NoAccess(); - die(); + echo_warning(_("Aucun stock disponible")); + return; } $idepo->selected = $p_depot; if ($p_readonly ) { From 4a52a6847138969bba53c1d6bb8ecdc178122d1c Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 21 Jan 2023 14:05:10 +0100 Subject: [PATCH 10/14] Cosmetic : improve CSS for enrich text --- html/css/style-classic7.css | 43 ++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/html/css/style-classic7.css b/html/css/style-classic7.css index 494cb253a..d09d9b863 100644 --- a/html/css/style-classic7.css +++ b/html/css/style-classic7.css @@ -3307,7 +3307,7 @@ li.li-active { margin-left:2rem !important; } - div.nicEdit-main hr { + * div.nicEdit-main hr { background-color: #756f6f !important; width:90% !important; margin-left:5% !important; @@ -3316,13 +3316,50 @@ li.li-active { height:2px; } - div.nicEdit-main h2 { + * div.nicEdit-main h2 { margin: 0px; padding: 0px; + margin-left:2rem; font-size: 1.6em; font-style: normal; margin-bottom: .5rem; font-size: 2rem !important; - background-color: white; + background-color: transparent; color: navy; + text-decoration: underline; } + + * div.nicEdit-main h1 { + margin: 0px; + padding: 0px; + margin-left:1rem; + font-style: normal; + margin-bottom: .5rem; + font-size: 2.5rem !important; + background-color: transparent; + color: navy; + text-decoration: underline double; + } + + * div.nicEdit-main h3 { + margin: 0px; + padding: 0px; + font-style: normal; + margin-bottom: .5rem; + font-size: 1.5 rem !important; + background-color: transparent; + color: navy; + text-decoration: underline dashed; + margin-left:3rem; + } + * div.nicEdit-main h4 { + margin: 0px; + padding: 0px; + font-style: normal; + margin-bottom: .5rem; + font-size: 1.1 rem !important; + background-color: transparent; + color: navy; + text-decoration: underline wavy; + margin-left:4rem; + } \ No newline at end of file From 58959469976e72f9f8129c731ce1a0740a02a491 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 30 Jan 2023 19:19:55 +0100 Subject: [PATCH 11/14] Task #0002219: Compatibilit PHP 8.2 --- include/lib/manage_table_sql.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index 45cffff6f..8e405ef64 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -1170,7 +1170,7 @@ function check() { $text=new IText($key); $text->value=$value; - $min_size=(strlen($value)<30)?30:strlen($value)+5; + $min_size=(noalyss_strlen($value)<30)?30:strlen($value)+5; $text->size=$min_size; echo $text->input(); } @@ -1178,7 +1178,7 @@ function check() { $text=new INum($key); $text->value=$value; - $min_size=(strlen($value)<10)?10:strlen($value)+1; + $min_size=(noalyss_strlen($value)<10)?10:strlen($value)+1; $text->size=$min_size; echo $text->input(); } @@ -1187,7 +1187,7 @@ function check() $text=new INum($key); $text->prec=4; $text->value=$value; - $min_size=(strlen($value)<10)?10:strlen($value)+1; + $min_size=(noalyss_strlen($value)<10)?10:strlen($value)+1; $text->size=$min_size; echo $text->input(); } @@ -1196,7 +1196,7 @@ function check() $text=new INum($key); $text->prec=6; $text->value=$value; - $min_size=(strlen($value)<10)?10:strlen($value)+1; + $min_size=(noalyss_strlen($value)<10)?10:strlen($value)+1; $text->size=$min_size; echo $text->input(); } From f25e0434b37870c83dfdec86057dc59fab2d95be Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 30 Jan 2023 19:34:33 +0100 Subject: [PATCH 12/14] Bug #0002206: CA - impossible de supprimer un poste analytique --- include/class/anc_account_table.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/class/anc_account_table.class.php b/include/class/anc_account_table.class.php index 98ac210b2..b6769962f 100644 --- a/include/class/anc_account_table.class.php +++ b/include/class/anc_account_table.class.php @@ -122,6 +122,8 @@ class Anc_Account_Table extends Manage_Table_SQL je1.status = 'CL' and oa.po_id=$1 ",[$this->table->po_id]); if ( $count_closed > 0 ) { throw new \Exception(_("Effacement impossible : le poste est utilisé dans une période fermée")); + } else { + $cn->exec_sql("delete from public.poste_analytique where po_id=$1",[$this->table->po_id]); } } From 7893d2395f355f9d142c144615b5dd296adc07d0 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 30 Jan 2023 23:26:46 +0100 Subject: [PATCH 13/14] =?UTF-8?q?Task=20#0002209:=20CG=20=E2=80=93=20Dans?= =?UTF-8?q?=20le=20menu=20d'actions=20sur=20une=20op=C3=A9ration,=20rempla?= =?UTF-8?q?cer=20=C2=ABEffacer=C2=BB=20par=20=C2=ABSupprimer=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/template/ledger_detail_bottom.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index 73c434aed..78bce0fb4 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -11,7 +11,7 @@ * Variables : $div = popup or box (det[0-9] * */ - +\Noalyss\Dbg::echo_file(__FILE__); $select_box=new \Select_Box("sb_".$jr_id, _("Autre action")); $select_box->set_position("normal"); $cn=Dossier::connect(); @@ -349,7 +349,7 @@ if ( $div != 'popup' ) { if ( $per->is_closed() == 0 && $owner->MY_STRICT=='N' && $g_user->check_action(RMOPER)==1) { $javascript="return confirm_box(null,content[50],function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})"; - $select_box->add_javascript(_("Effacer"), $javascript); + $select_box->add_javascript(_("Supprimer"), $javascript); } //---------------------------------------------------- // Extourne @@ -359,7 +359,7 @@ if ( $div != 'popup' ) { //------------------------------------------------------------------- // Duplicate //------------------------------------------------------------------- - $select_box->add_javascript(_("Duplicate"),sprintf("duplicate_operation('%s','%s')",Dossier::id(),$obj->jr_id)); + $select_box->add_javascript(_("Dupliquer"),sprintf("duplicate_operation('%s','%s')",Dossier::id(),$obj->jr_id)); //------------------------------------------------------------------- // Export PDF From 89368f334fe5dc82dc01fadff7acb7a3d280cd74 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 30 Jan 2023 23:27:57 +0100 Subject: [PATCH 14/14] =?UTF-8?q?Bug=20#0002219:=20Compatibilit=C3=A9=20PH?= =?UTF-8?q?P=208.2=20,=208.1=20,=208.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/securimage/securimage.php | 64 ++++++++++++++++++++++------------ include/config.inc.example | 3 ++ include/lib/ac_common.php | 2 +- include/lib/config_file.php | 2 ++ 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/html/securimage/securimage.php b/html/securimage/securimage.php index 046e35258..43c5b8391 100644 --- a/html/securimage/securimage.php +++ b/html/securimage/securimage.php @@ -503,7 +503,7 @@ class Securimage { * * */ - function Securimage() + function __construct() { // Initialize session or attach to existing if ( session_id() == '' ) { // no session has been started yet, which is needed for validation @@ -538,10 +538,10 @@ class Securimage { $this->image_bg_color = new Securimage_Color(0xff, 0xff, 0xff); $this->text_color = new Securimage_Color(0x3d, 0x3d, 0x3d); $this->multi_text_color = array(new Securimage_Color(0x0, 0x20, 0xCC), - new Securimage_Color(0x0, 0x30, 0xEE), - new Securimage_color(0x0, 0x40, 0xCC), - new Securimage_Color(0x0, 0x50, 0xEE), - new Securimage_Color(0x0, 0x60, 0xCC)); + new Securimage_Color(0x0, 0x30, 0xEE), + new Securimage_color(0x0, 0x40, 0xCC), + new Securimage_Color(0x0, 0x50, 0xEE), + new Securimage_Color(0x0, 0x60, 0xCC)); $this->use_multi_text = false; $this->use_transparent_text = false; @@ -651,7 +651,7 @@ class Securimage { */ function doImage() { - if ($this->use_gd_font == true) { + if ($this->use_gd_font == true || $this->iscale == null || $this->iscale == 0) { $this->iscale = 1; } if($this->use_transparent_text == true || $this->bgimg != "") { @@ -692,24 +692,42 @@ class Securimage { function allocateColors() { // allocate bg color first for imagecreate - $this->gdbgcolor = imagecolorallocate($this->im, $this->image_bg_color->r, $this->image_bg_color->g, $this->image_bg_color->b); - + $this->gdbgcolor = imagecolorallocate($this->im, $this->image_bg_color->r??0, $this->image_bg_color->g??0, $this->image_bg_color->b??0); + + $this->text_color->r=$this->text_color->r??rand(0,255); + $this->text_color->g=$this->text_color->g??rand(0,255); + $this->text_color->b=$this->text_color->b??rand(0,255); + $this->line_color->r=$this->line_color->r??rand(0,255); + $this->line_color->g=$this->line_color->g??rand(0,255); + $this->line_color->b=$this->line_color->b??rand(0,255); + + + $alpha = intval($this->text_transparency_percentage / 100 * 127); if ($this->use_transparent_text == true) { - $this->gdtextcolor = imagecolorallocatealpha($this->im, $this->text_color->r, $this->text_color->g, $this->text_color->b, $alpha); - $this->gdlinecolor = imagecolorallocatealpha($this->im, $this->line_color->r, $this->line_color->g, $this->line_color->b, $alpha); - } else { + $this->gdtextcolor = imagecolorallocatealpha($this->im, $this->text_color->r, $this->text_color->g, $this->text_color->b, $alpha); + $this->gdlinecolor = imagecolorallocatealpha($this->im, $this->line_color->r, $this->line_color->g, $this->line_color->b, $alpha); + } elseif ( $this->text_color != null ) { $this->gdtextcolor = imagecolorallocate($this->im, $this->text_color->r, $this->text_color->g, $this->text_color->b); - $this->gdlinecolor = imagecolorallocate($this->im, $this->line_color->r, $this->line_color->g, $this->line_color->b); - } + $this->gdlinecolor = imagecolorallocate($this->im, $this->line_color->r, $this->line_color->g, $this->line_color->b); + } else { + $red=rand(0,255); + $green=rand(0,255); + $blue=rand(0,255); + $this->gdtextcolor = imagecolorallocate($this->im, $red, $green,$blue); + $this->gdlinecolor = imagecolorallocate($this->im, $red, $green, $blue); + } - $this->gdsignaturecolor = imagecolorallocate($this->im, $this->signature_color->r, $this->signature_color->g, $this->signature_color->b); + $this->gdsignaturecolor = imagecolorallocate($this->im, $this->signature_color->r??0, $this->signature_color->g??0, $this->signature_color->b??0); if ($this->use_multi_text == true) { $this->gdmulticolor = array(); - foreach($this->multi_text_color as $color) { + foreach($this->multi_text_color??[] as $color) { + $color->r=$color->r??rand(0,255); + $color->g= $color->g??rand(0,255); + $color->b=$color->b??rand(0,255); if ($this->use_transparent_text == true) { $this->gdmulticolor[] = imagecolorallocatealpha($this->im, $color->r, $color->g, $color->b, $alpha); } else { @@ -837,9 +855,9 @@ class Securimage { $width2 = $this->image_width * $this->iscale; $height2 = $this->image_height * $this->iscale; - if ($this->use_gd_font == true || !is_readable($this->ttf_file)) { + if ($this->use_gd_font == true || !is_readable($this->ttf_file??"")) { if (!is_int($this->gd_font_file)) { //is a file name - $font = @imageloadfont($this->gd_font_file); + $font = @imageloadfont($this->gd_font_file??""); if ($font == false) { trigger_error("Failed to load GD Font file {$this->gd_font_file} ", E_USER_WARNING); return; @@ -897,7 +915,7 @@ class Securimage { $max_x = $font_size + ($this->iscale * 5); } - $x += rand($min_x, $max_x); + $x += rand((int)$min_x,(int) $max_x); } //for loop } // angled or multi-color } //else ttf font @@ -921,9 +939,9 @@ class Securimage { // make array of poles AKA attractor points for ($i = 0; $i < $numpoles; ++$i) { - $px[$i] = rand($this->image_width * 0.3, $this->image_width * 0.7); - $py[$i] = rand($this->image_height * 0.3, $this->image_height * 0.7); - $rad[$i] = rand($this->image_width * 0.4, $this->image_width * 0.7); + $px[$i] = rand((int) ($this->image_width * 0.3), (int)( $this->image_width * 0.7)); + $py[$i] = rand((int) ($this->image_height * 0.3),(int) ($this->image_height * 0.7)); + $rad[$i] = rand((int) ($this->image_width * 0.4), (int) ($this->image_width * 0.7)); $tmp = -$this->frand() * 0.15 - 0.15; $amp[$i] = $this->perturbation * $tmp; } @@ -958,7 +976,7 @@ class Securimage { $y *= $this->iscale; if ($x >= 0 && $x < $width2 && $y >= 0 && $y < $height2) { - $c = imagecolorat($this->tmpimg, $x, $y); + $c = imagecolorat($this->tmpimg, (int) $x,(int) $y); } if ($c != $bgCol) { // only copy pixels of letters to preserve any background image @@ -1001,7 +1019,7 @@ class Securimage { { $code = ''; - for($i = 1, $cslen = strlen($this->charset); $i <= $len; ++$i) { + for($i = 1, $cslen = strlen($this->charset??""); $i <= $len; ++$i) { $code .= $this->charset[rand(0, $cslen - 1)]; } return $code; diff --git a/include/config.inc.example b/include/config.inc.example index ea16393aa..114108b1b 100644 --- a/include/config.inc.example +++ b/include/config.inc.example @@ -86,3 +86,6 @@ define ("DEBUGNOALYSS",0); // // Audit everything // define ("AUDIT_ENABLE",true); +// +// display a captcha +// define ("NOALYSS_CAPTCHA",true); \ No newline at end of file diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 581d8b30d..7e788d5f2 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -1469,7 +1469,7 @@ function remove_divide_zero($p_formula) * @brief Create randomly a string * @param int $p_length length of the generate string */ -function generate_random_string($car) +function generate_random_string($p_length) { $string=""; $chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-="; diff --git a/include/lib/config_file.php b/include/lib/config_file.php index 7384844d3..1aefa53c7 100644 --- a/include/lib/config_file.php +++ b/include/lib/config_file.php @@ -257,6 +257,8 @@ function display_file_config($p_array,$from_setup=1,$p_os=1) print ("// Uncomment and define if you want to Name of the sender of the email \r\n"); print ("// if you activate the possibility to reinitialize password by email\r\n"); print ("// define('ADMIN_WEB', 'www-data@localhost');\r\n"); + print ("// Define a random session key if you work with different version of NOALYSS\r\n"); + printf ("define ('SESSION_KEY','%s')",generate_random_string(10)) ; } /*!\brief create the config file
"._("Administration")."