noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 02/07: PHP 8.1 Deprecated


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 02/07: PHP 8.1 Deprecated
Date: Sat, 27 Aug 2022 08:03:45 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit e93283ba65245cde3cca20f0cc7adc84e7d2ea9b
Author: Dany De Bontridder <dany@alchimerys.be>
AuthorDate: Wed Aug 24 22:26:12 2022 +0200

    PHP 8.1 Deprecated
    
    Adapt for 8.1
---
 include/admin_repo.inc.php                 | 2 +-
 include/export/export_fiche_detail_csv.php | 2 +-
 include/export/export_fiche_detail_pdf.php | 3 ++-
 include/lib/ac_common.php                  | 5 +++--
 include/lib/database_core.class.php        | 4 +++-
 include/lib/ibutton.class.php              | 2 +-
 include/lib/noalyss_csv.class.php          | 3 ++-
 include/template/ledger_detail_fin.php     | 4 ++--
 8 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/include/admin_repo.inc.php b/include/admin_repo.inc.php
index b47789b69..ae9b3294c 100644
--- a/include/admin_repo.inc.php
+++ b/include/admin_repo.inc.php
@@ -174,7 +174,7 @@ hr {width: 600px; background-color: #cccccc; border: 0px; 
height: 1px; color: #0
     $a_table=$html->getElementsByTagName("table");
     
     // For PHP  < 7 , we must change the attribute "width"
-    if ( substr(phpversion(),0,1) != "7" )
+    if ( substr(phpversion(),0,1) < 7 )
     {
         for ( $i = 0 ; $i < $a_table->length;$i++) {
             $node=$a_table->item($i);
diff --git a/include/export/export_fiche_detail_csv.php 
b/include/export/export_fiche_detail_csv.php
index 0a0146d6d..fe028253d 100644
--- a/include/export/export_fiche_detail_csv.php
+++ b/include/export/export_fiche_detail_csv.php
@@ -141,7 +141,7 @@ if ( ! isset ($_REQUEST['oper_detail']))
         $export->add($op['deb_montant'],"number");
         $export->add($op['cred_montant'],"number");
         $export->add(abs($progress),"number");
-        if ($op['letter'] !=-1){
+        if ( $op['letter'] !=-1 && ! empty($op['letter'])){
             $export->add(strtoupper(base_convert($op['letter'],10,36)));
         } else {
             $export->add("");
diff --git a/include/export/export_fiche_detail_pdf.php 
b/include/export/export_fiche_detail_pdf.php
index aed0f0f6b..7034c644a 100644
--- a/include/export/export_fiche_detail_pdf.php
+++ b/include/export/export_fiche_detail_pdf.php
@@ -149,7 +149,8 @@ for ($e=0;$e<count($array);$e++)
     
$pdf->LongLine($size[$l],6,($description.'('.$row['jr_internal'].")"),0,$align[$l]);
 
     $l++;
-    
$pdf->LongLine($size[$l],6,(($row['letter']!=-1)?strtoupper(base_convert($row['letter'],10,36)):''),0,$align[$l]);
+
+    $pdf->LongLine($size[$l],6,((!empty($row['letter']) && 
$row['letter']!=-1)?strtoupper(base_convert($row['letter'],10,36)):''),0,$align[$l]);
     $l++;
     $pdf->LongLine($size[$l],6,(sprintf('% 
12.2f',$row['deb_montant'])),0,$align[$l]);
     $l++;
diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php
index 3482c8629..0c65d0689 100644
--- a/include/lib/ac_common.php
+++ b/include/lib/ac_common.php
@@ -34,7 +34,7 @@ require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
  */
 function h($p_string)
 {
-    return htmlspecialchars($p_string,ENT_QUOTES|ENT_HTML5,'UTF-8',true);
+    return ( $p_string == 
null)?"":htmlspecialchars($p_string,ENT_QUOTES|ENT_HTML5,'UTF-8',true);
 }
 function p($p_string)
 {
@@ -852,6 +852,7 @@ function smaller_date($p_date)
  */
 function format_date($p_date, $p_from_format = 
'YYYY-MM-DD',$p_to_format='DD.MM.YYYY')
 {
+    if (empty($p_date)) {return $p_date;}
     if ($p_from_format == 'YYYY-MM-DD')
     {
         $date = explode('-', $p_date);
@@ -1478,7 +1479,7 @@ function generate_random_string($car)
 {
     $string="";
     $chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-=";
-    srand((double) microtime()*1020030);
+    srand((int) microtime()*1020030);
     for ($i=0; $i<$car; $i++)
     {
         $string .= $chaine[rand()%strlen($chaine)];
diff --git a/include/lib/database_core.class.php 
b/include/lib/database_core.class.php
index b3c0a6994..c21a9da90 100644
--- a/include/lib/database_core.class.php
+++ b/include/lib/database_core.class.php
@@ -846,7 +846,9 @@ class DatabaseCore
 
     static function escape_string($p_string)
     {
-        return pg_escape_string($p_string);
+        static $cn=null;
+        if ( $cn==null) $cn=new Database();
+        return pg_escape_string($cn->db,$p_string);
     }
 
     /**\brief wrapper for the function pg_close
diff --git a/include/lib/ibutton.class.php b/include/lib/ibutton.class.php
index f2c48b69e..18fdb7a00 100644
--- a/include/lib/ibutton.class.php
+++ b/include/lib/ibutton.class.php
@@ -36,7 +36,7 @@ class IButton extends HtmlInput
     {
         $this->name=($p_name==null)?$this->name:$p_name;
         $this->value=($p_value==null)?$this->value:$p_value;
-       $this->label=(trim($this->label) != '')?$this->label:$this->value;
+           $this->label=(!empty($this->label))?$this->label:$this->value;
         $this->class=($p_class != "")?$p_class:$this->class;
         $this->class=($this->class=="")?"smallbutton ":$this->class;
         if ( $this->readOnly==true) return $this->display();
diff --git a/include/lib/noalyss_csv.class.php 
b/include/lib/noalyss_csv.class.php
index 7e5675782..181a09175 100644
--- a/include/lib/noalyss_csv.class.php
+++ b/include/lib/noalyss_csv.class.php
@@ -142,8 +142,9 @@ class Noalyss_Csv
             }
             else
             {
+                
$export=($this->element[$i]['value']==null)?"":$this->element[$i]['value'];
                 // remove break-line, 
-                $export=str_replace("\n"," ",$this->element[$i]['value']);
+                $export=str_replace("\n"," ",$export);
                 $export=str_replace("\r"," ", $export);
                 // remove double quote
                 $export=str_replace('"',"", $export);
diff --git a/include/template/ledger_detail_fin.php 
b/include/template/ledger_detail_fin.php
index b7dc615f5..2b6696747 100644
--- a/include/template/ledger_detail_fin.php
+++ b/include/template/ledger_detail_fin.php
@@ -46,7 +46,7 @@ echo td(_('Tiers')).td($view_card_detail);
 <tr>
 <?php 
   $itext=new IText('lib');
-  $itext->value=strip_tags($obj->det->jr_comment);
+  
$itext->value=(!empty($obj->det->jr_comment))?strip_tags($obj->det->jr_comment):'';
   $itext->size=40;
   echo td(_('Libellé')).td($itext->input(),' colspan="2" style="width:auto"');
 
@@ -59,7 +59,7 @@ echo td(_('Tiers')).td($view_card_detail);
 <tr>
 <?php 
 $itext=new IText('npj');
-$itext->value=strip_tags($obj->det->jr_pj_number);
+$itext->value=(!empty($obj->det->jr_pj_number))?strip_tags($obj->det->jr_pj_number):'';
 echo td(_('Pièce')).td($itext->input());
 ?>
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]