Bug #0002219: Compatibilité PHP 8.2 , 8.1 , 8.0

This commit is contained in:
sparkyx 2023-02-01 16:49:24 +01:00
parent 1c7f0086a6
commit 21b1cb3d84
36 changed files with 103 additions and 100 deletions

View file

@ -267,7 +267,7 @@ case 'st':
{
$where=sprintf(' where frd_id in ('.sql_string ($cat).')');
}
elseif ( isset($fil) && strlen(trim($fil)) > 0 && $fil != -1 )
elseif ( isset($fil) && noalyss_strlentrim($fil) > 0 && $fil != -1 )
{
/* we filter thanks a given list of category of card
*/
@ -627,7 +627,7 @@ case 'scc':
$nom_mod=$http->get("nom_mod");
$class_base=$http->get("class_base");
$fd_description=$http->get("nom_mod");
if ( strlen(trim($nom_mod)) != 0 )
if ( noalyss_strlentrim($nom_mod) != 0 )
{
$array=array("FICHE_REF"=>$cat,
"nom_mod"=>$nom_mod,

View file

@ -94,19 +94,19 @@ case "sf":
}
}
/* show result */
if ( isset($q) && strlen(trim($q)) > 0)
if ( isset($q) && noalyss_strlentrim($q) > 0)
{
$q= sql_string($q);
$sql.=sprintf(" $sep ( pcm_val::text like '%s%%' or pcm_lib::text ilike '%%%s%%') ",
$q,$q);
}
$sql.=' group by pcm_val,pcm_lib,pcm_val_parent, pcm_type order by pcm_val::text limit 50';
if ( isset($q) && strlen(trim($q))> 0 )
if ( isset($q) && noalyss_strlentrim($q)> 0 )
{
$array=$cn->get_array($sql);
}
if ( ! isset($q) ) $array=array();
if ( isset($q) && strlen(trim($q))==0) $array=array();
if ( isset($q) && noalyss_strlentrim($q)==0) $array=array();
/* set the javascript */
for ($i=0;$i<count($array);$i++)

View file

@ -322,7 +322,7 @@ if ($action == 'save')
$csv_encoding=$http->post("csv_encoding");
$firstday=$http->post("selFirstDay","number");
if (strlen(trim($pass_1)) != 0 && strlen(trim($pass_2)) != 0)
if (noalyss_strlentrim($pass_1) != 0 && noalyss_strlentrim($pass_2) != 0)
{
if ( $g_user->save_password($_POST['pass_1'],$pass_2) )
{ $g_user->password_to_session() ;

View file

@ -682,7 +682,7 @@ class Acc_Account_Ledger
$l=new Acc_Ledger($this->db,$p_jrn);
$row=$l->get_propertie();
if ($l->get_type() != 'ODS') { return [];}
if ( $row == null || strlen(trim($row['jrn_def_class_deb'])) == 0 ) return array();
if ( $row == null || noalyss_strlentrim($row['jrn_def_class_deb']) == 0 ) return array();
$valid_account=explode(" ",$row['jrn_def_class_deb']);
return $valid_account;
}

View file

@ -329,7 +329,7 @@ class Acc_Bilan
// $a=(Impress::check_formula($buffer) == true)?"$buffer ok<br>":'<font color="red">'.'Pas ok '.$buffer."</font><br>";
// echo $a;
// blank line are skipped
if (strlen(trim($buffer))==0)
if (noalyss_strlentrim($buffer)==0)
continue;
// skip comment
if ( strpos($buffer,'#') === true )

View file

@ -1233,7 +1233,7 @@ class Acc_Ledger extends jrn_def_sql
if ($f->belong_ledger($p_jrn)<0)
throw new Exception("La fiche quick_code = ".
$f->quick_code." n'est pas dans ce journal", 4);
if (strlen(trim(${'qc_'.$i}))!=0&&isNumber(${'amount'.$i})==0)
if (noalyss_strlentrim(${'qc_'.$i})!=0&&isNumber(${'amount'.$i})==0)
throw new Exception(_('Montant invalide'), 3);
$strPoste=$f->strAttribut(ATTR_DEF_ACCOUNT);
@ -1248,7 +1248,7 @@ class Acc_Ledger extends jrn_def_sql
}
// Check if the account is permitted
if (isset(${'poste'.$i})&&strlen(trim(${'poste'.$i}))!=0)
if (isset(${'poste'.$i})&&noalyss_strlentrim(${'poste'.$i})!=0)
{
$p=new Acc_Account_Ledger($this->db, ${'poste'.$i});
if ($p->belong_ledger($p_jrn)<0) {
@ -1256,7 +1256,7 @@ class Acc_Ledger extends jrn_def_sql
_("Le poste %s n'est pas dans ce journal",$p->id)),
5);
}
if (strlen(trim(${'poste'.$i}))!=0&&isNumber(${'amount'.$i})==0)
if (noalyss_strlentrim(${'poste'.$i})!=0&&isNumber(${'amount'.$i})==0)
throw new Exception(_('Poste invalide ['.${'poste'.$i}.']'),
3);
if ($p->do_exist()==0)
@ -1408,7 +1408,7 @@ class Acc_Ledger extends jrn_def_sql
if ($check_periode==false)
$acc_op->periode=$oPeriode->p_id;
$acc_op->desc=null;
if (strlen(trim(${'ld'.$i}))!=0)
if (noalyss_strlentrim(${'ld'.$i})!=0)
$acc_op->desc=${'ld'.$i};
// Amount in default currency , usually EUR
@ -1516,7 +1516,7 @@ class Acc_Ledger extends jrn_def_sql
$acc_end->pj=$e_pj;
/* if e_suggest != e_pj then do not increment sequence */
if (strcmp($e_pj, $e_pj_suggest)==0&&strlen(trim($e_pj))!=0)
if (strcmp($e_pj, $e_pj_suggest)==0&&noalyss_strlentrim($e_pj)!=0)
{
$this->inc_seq_pj();
}
@ -1739,7 +1739,7 @@ class Acc_Ledger extends jrn_def_sql
$comma='';
foreach ($res as $item)
{
if (strlen(trim($item['deb']))!=0)
if (noalyss_strlentrim($item['deb'])!=0)
{
$card.=$comma.$item['deb'];
$comma=',';
@ -1920,7 +1920,7 @@ class Acc_Ledger extends jrn_def_sql
// Move the document to the jrn
$doc->moveDocumentPj($internal);
// Update the comment with invoice number, if the comment is empty
if (!isset($e_comm)||strlen(trim($e_comm))==0)
if (!isset($e_comm)||noalyss_strlentrim($e_comm)==0)
{
$sql="update jrn set jr_comment=' document ".$doc->d_number."' where jr_internal='$internal'";
$this->db->exec_sql($sql);

View file

@ -131,7 +131,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
//----------------------------------------
for ($i=0; $i<$nb_item; $i++)
{
if (strlen(trim(${'e_other'.$i}))==0)
if (noalyss_strlentrim(${'e_other'.$i})==0)
continue;
/* check if amount are numeric and */
if (isNumber(${'e_other'.$i.'_amount'})==0)
@ -214,7 +214,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
throw new Exception('Il n\'y a aucune opération', 12);
/* Check if the last_saldo and first_saldo are correct */
if (strlen(trim($last_sold))!=0&&isNumber($last_sold)&&strlen(trim($first_sold))!=0&&isNumber($first_sold)
if (noalyss_strlentrim($last_sold)!=0&&isNumber($last_sold)&&noalyss_strlentrim($first_sold)!=0&&isNumber($first_sold)
)
{
$diff=$last_sold-$first_sold;
@ -582,7 +582,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
$tiers=(isset(${"e_other".$i}))?${"e_other".$i}:""
;
if (strlen(trim($tiers))==0)
if (noalyss_strlentrim($tiers)==0)
continue;
$tiers_label="";
$tiers_amount=round(${"e_other$i"."_amount"}, 2);
@ -823,7 +823,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
{
// insert it into the database
// and quit the loop ?
if (strlen(trim(${"e_other$i"}))==0)
if (noalyss_strlentrim(${"e_other$i"})==0)
continue;
// get the currency_rate when each operation has its own date
@ -1084,7 +1084,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
}
} // for nbitem
// increment pj
if (strlen(trim($e_pj))!=0)
if (noalyss_strlentrim($e_pj)!=0)
{
$this->inc_seq_pj();
}

View file

@ -235,7 +235,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History
$poste=new Acc_Account_Ledger($this->db, $code['j_poste']);
// if card retrieve name if the account is not a VAT account
if (strlen(trim($code['j_qcode']))!=0&&$poste->isTva()==0)
if (noalyss_strlentrim($code['j_qcode'])!=0&&$poste->isTva()==0)
{
$fiche=new Fiche($this->db);
$fiche->get_by_qcode(trim($code['j_qcode']), false);
@ -556,7 +556,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History
$tot_op=$line['jr_montant'];
/* Check first if there is a quickcode */
if (strlen(trim($line['description']))==0&&strlen(trim($line['j_qcode']))
if (noalyss_strlentrim($line['description'])==0&&noalyss_strlentrim($line['j_qcode'])
!=0)
{
$fiche=new Fiche($this->db);

View file

@ -188,13 +188,13 @@ class Acc_Ledger_Info
function save_extra($p_jr_id,$p_array)
{
$this->jr_id=$p_jr_id;
if (strlen(trim($p_array['bon_comm'] )) != 0 )
if (noalyss_strlentrim($p_array['bon_comm'] ) != 0 )
{
$this->set_type('BON_COMMANDE');
$this->set_value($p_array['bon_comm']);
$this->insert();
}
if (strlen(trim($p_array['other_info'] )) != 0 )
if (noalyss_strlentrim($p_array['other_info'] ) != 0 )
{
$this->set_type('OTHER');
$this->set_value($p_array['other_info']);

View file

@ -66,7 +66,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
throw new Exception (_('Double Encodage'),5);
/* check if there is a customer */
if ( strlen(trim($e_client)) == 0 )
if ( noalyss_strlentrim($e_client)== 0 )
throw new Exception(_('Vous n\'avez pas donné de fournisseur'),11);
/* check if the date is valid */
@ -157,7 +157,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
//----------------------------------------
for ($i=0;$i< $nb_item;$i++)
{
if ( strlen(trim(${'e_march'.$i}))== 0) continue;
if ( noalyss_strlentrim(${'e_march'.$i})== 0) continue;
/* check if amount are numeric and */
if ( isNumber(${'e_march'.$i.'_price'}) == 0 )
throw new Exception(_('La fiche ').${'e_march'.$i}._('a un montant invalide').' ['.${'e_march'.$i}.']',6);
@ -600,7 +600,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
if ( $g_parameter->MY_TVA_USE=='Y')
{
$acc_amount->set_parameter('amount_vat_rate',$oTva->get_parameter('rate'));
if ( strlen(trim(${'e_march'.$i.'_tva_amount'})) ==0 || ${'e_march'.$i.'_tva_amount'} == 0)
if ( noalyss_strlentrim(${'e_march'.$i.'_tva_amount'}) ==0 || ${'e_march'.$i.'_tva_amount'} == 0)
{
// vat must computed and the amount is already converted to EUR
$acc_amount->compute_vat();
@ -921,7 +921,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
array($internal,$seq));
/**= e_pj then do not increment sequence */
if ( strcmp($e_pj,$e_pj_suggest) == 0 && strlen(trim($e_pj)) != 0 )
if ( strcmp($e_pj,$e_pj_suggest) == 0 && noalyss_strlentrim($e_pj) != 0 )
{
$this->inc_seq_pj();
}
@ -1029,7 +1029,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
/* insert into jrn */
$acc_pay->mt=$mt;
$acc_pay->desc=(!isset($e_comm_paiement) || strlen(trim($e_comm_paiement)) == 0) ?$e_comm:$e_comm_paiement;
$acc_pay->desc=(!isset($e_comm_paiement) || noalyss_strlentrim($e_comm_paiement) == 0) ?$e_comm:$e_comm_paiement;
// Add info for currency
$acc_pay->currency_id=$p_currency_code;
@ -1280,7 +1280,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
// retrieve e_client_label
//--
if ( strlen(trim($e_client)) != 0)
if ( noalyss_strlentrim($e_client) != 0)
{
$fClient=new Fiche($this->db);
$fClient->get_by_qcode($e_client);
@ -1349,7 +1349,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$march_label=(isset(${"e_march".$i."_label"}))?${"e_march".$i."_label"}:"";
// retrieve the tva label and name
//--
if ( strlen(trim($march))!=0 && strlen(trim($march_label))==0 )
if ( noalyss_strlentrim($march)!=0 && noalyss_strlentrim($march_label)==0 )
{
$fMarch=new Fiche($this->db);
$fMarch->get_by_qcode($march);
@ -1653,7 +1653,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
for ($i = 0; $i < $nb_item;$i++)
{
$tot_row=0;
if ( strlen(trim(${"e_march".$i})) == 0 ) continue;
if ( noalyss_strlentrim(${"e_march".$i}) == 0 ) continue;
/* retrieve information for card */
$fiche=new Fiche($this->db);

View file

@ -68,7 +68,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
throw new Exception(_('Accès interdit'), 20);
/* check if there is a customer */
if (strlen(trim($e_client)) == 0)
if (noalyss_strlentrim($e_client) == 0)
throw new Exception(_('Vous n\'avez pas donné de client'), 11);
/* check if the date is valid */
@ -141,7 +141,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
// foreach item
//----------------------------------------
for ($i = 0; $i < $nb_item; $i++) {
if (! isset (${'e_march' . $i}) || strlen(trim(${'e_march' . $i})) == 0)
if (! isset (${'e_march' . $i}) || noalyss_strlentrim(${'e_march' . $i}) == 0)
continue;
/* check if amount are numeric and */
if (isNumber(${'e_march' . $i . '_price'}) == 0)
@ -617,7 +617,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
/* * = e_pj then do not increment sequence */
/* and e_pj is not null */
if (strcmp($e_pj, $e_pj_suggest) == 0 && strlen(trim($e_pj)) != 0) {
if (strcmp($e_pj, $e_pj_suggest) == 0 && noalyss_strlentrim($e_pj) != 0) {
$this->inc_seq_pj();
}
@ -631,7 +631,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
/* Save the attachment or generate doc */
if (isset($_FILES['pj'])) {
if (strlen(trim($_FILES['pj']['name'])) != 0)
if (noalyss_strlentrim($_FILES['pj']['name']) != 0)
$this->db->save_receipt($seq);
else
/* Generate an invoice and save it into the database */
@ -728,7 +728,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
/* insert into jrn */
$acc_pay->mt = $mt;
$acjrn->grpt_id = $acseq;
$acc_pay->desc = (!isset($e_comm_paiement) || strlen(trim($e_comm_paiement)) == 0) ? $e_comm : $e_comm_paiement;
$acc_pay->desc = (!isset($e_comm_paiement) || noalyss_strlentrim($e_comm_paiement) == 0) ? $e_comm : $e_comm_paiement;
$mp_jr_id = $acc_pay->insert_jrn();
$acjrn->update_internal_code($acinternal);
// add an automatic PJ if ODS
@ -921,7 +921,7 @@ class Acc_Ledger_Sale extends Acc_Ledger {
$tot_amount = 0.0;
$tot_tva = 0.0;
for ($i = 0; $i < $nb_item; $i++) {
if (strlen(trim(${"e_march" . $i})) == 0)
if (noalyss_strlentrim(${"e_march" . $i}) == 0)
continue;
/* retrieve information for card */
@ -1180,7 +1180,7 @@ EOF;
}
/* if the paymethod is not 0 and if a quick code is given */
if ($e_mp != 0 && strlen(trim(${'e_mp_qcode_' . $e_mp})) != 0) {
if ($e_mp != 0 && noalyss_strlentrim(${'e_mp_qcode_' . $e_mp}) != 0) {
$r.=HtmlInput::hidden('e_mp_qcode_' . $e_mp, ${'e_mp_qcode_' . $e_mp});
$r.=HtmlInput::hidden('acompte', $acompte);
$r.=HtmlInput::hidden('e_comm_paiement', $e_comm_paiement);
@ -1393,7 +1393,7 @@ EOF;
// retrieve e_client_label
//--
if (strlen(trim($e_client)) != 0) {
if (noalyss_strlentrim($e_client) != 0) {
$fClient = new Fiche($this->db);
$fClient->get_by_qcode($e_client);
$e_client_label = $fClient->strAttribut(ATTR_DEF_NAME) . ' ' .
@ -1451,7 +1451,7 @@ EOF;
// retrieve the tva label and name
//--
if (strlen(trim($march)) != 0 && strlen(trim($march_label)) == 0) {
if (noalyss_strlentrim($march) != 0 && noalyss_strlentrim($march_label) == 0) {
$fMarch = new Fiche($this->db);
$fMarch->get_by_qcode($march);
$march_label = $fMarch->strAttribut(ATTR_DEF_NAME);

View file

@ -259,7 +259,7 @@ EOF;
*/
function set_pj()
{
if ( strlen(trim($this->pj)) == 0 )
if ( noalyss_strlentrim($this->pj) == 0 )
{
$sql="update jrn set jr_pj_number=$1 where jr_id=$2";
$this->db->exec_sql($sql,array(null,$this->jr_id));
@ -337,7 +337,7 @@ EOF;
return false;
}
$echeance=( isset( $this->echeance) && strlen(trim($this->echeance)) != 0)?$this->echeance:null;
$echeance=( isset( $this->echeance) && noalyss_strlentrim($this->echeance) != 0)?$this->echeance:null;
if ( ! isset($this->mt) )
{
$this->mt=microtime(true);
@ -475,7 +475,7 @@ EOF;
$r.='<td '.$border.'>';
// $a=($l['vw_name']=="")?$l['j_qcode']:$l['pcm_lib'];
$a=(strlen(trim($l['j_qcode']))==0)?$l['pcm_lib']:$l['vw_name'];
$a=(noalyss_strlentrim($l['j_qcode'])==0)?$l['pcm_lib']:$l['vw_name'];
$r_notable.=$a;
$r.=h($a);
$csv.='"'.$a.'";';

View file

@ -172,7 +172,7 @@ class Acc_Plan_MTable extends Manage_Table_SQL
$this->set_error("pcm_val", _("Poste comptable ne peut être vide"));
}
// Check size
if ( strlen(trim($this->table->pcm_val)) > 40) {
if ( noalyss_strlentrim($this->table->pcm_val) > 40) {
$this->set_error("pcm_val", _("Poste comptable trop long"));
}
if ( trim($this->table->parent_accounting) == "") {

View file

@ -197,7 +197,7 @@ class Acc_Report
function upload()
{
if ( empty ($_FILES) ) return;
if ( strlen(trim($_FILES['report']['tmp_name'])) == 0 )
if ( noalyss_strlentrim($_FILES['report']['tmp_name'])== 0 )
{
alert("Nom de fichier est vide");
return;

View file

@ -184,7 +184,7 @@ class Card_Property
} else {
// if there is a class base in fiche_def_ref, this account will be the
// the default one
if (noalyss_strlen(noalyss_trim($p_fiche_def->class_base)) != 0) {
if (noalyss_strlentrim($p_fiche_def->class_base) != 0) {
$result['msg'] .= " <span style=\"color:red\">" . _("Rappel: Poste par défaut sera ") .
$p_fiche_def->class_base .
" !</span> ";
@ -502,7 +502,7 @@ class Card_Property
continue;
}
// name
if ($value->ad_id==ATTR_DEF_NAME && strlen(trim($value->av_text))==0 )
if ($value->ad_id==ATTR_DEF_NAME && noalyss_strlentrim($value->av_text)==0 )
{
continue;
}
@ -598,7 +598,7 @@ class Card_Property
}
continue;
}
if (strlen(trim($v))==0)
if (noalyss_strlentrim($v)==0)
{
$sql=sprintf("select account_insert(%d,null)", $p_fiche->id);
@ -618,7 +618,7 @@ class Card_Property
if ($value->ad_id==ATTR_DEF_TVA)
{
// Verify if the rate exists, if not then do not update
if (strlen(trim($value->av_text))!=0)
if (noalyss_strlentrim($value->av_text)!=0)
{
if ($p_fiche->cn->get_value("select count(*) from tva_rate where tva_id=$1",[$value->av_text])==0)
{

View file

@ -1029,7 +1029,7 @@ class Document
$id='e_march'.$this->counter."_label";
// check if the march exists
if (!isset($p_array[$id])||(isset($p_array[$id])&&strlen(trim($p_array[$id]))==0))
if (!isset($p_array[$id])||(isset($p_array[$id])&&noalyss_strlentrim($p_array[$id])==0))
{
$id='e_march'.$this->counter;
// check if the march exists
@ -1109,7 +1109,7 @@ class Document
return "";
$qt='e_quant'.$this->counter;
$price='e_march'.$this->counter.'_price';
if ($p_array[$price]==0||$p_array[$qt]==0||strlen(trim($p_array[$price]))==0||strlen(trim($p_array[$qt]))==0)
if ($p_array[$price]==0||$p_array[$qt]==0||noalyss_strlentrim($p_array[$price])==0||noalyss_strlentrim($p_array[$qt])==0)
return "";
$r=$p_array[$id];
@ -1145,7 +1145,7 @@ class Document
if (!isset($p_array[$tva]))
return "";
// check that something is sold
if ($p_array[$price]==0||$p_array[$qt]==0||strlen(trim($p_array[$price]))==0||strlen(trim($p_array[$qt]))==0)
if ($p_array[$price]==0||$p_array[$qt]==0||noalyss_strlentrim($p_array[$price])==0||noalyss_strlentrim($p_array[$qt])==0)
return "";
$r=$p_array['e_march'.$this->counter.'_tva_amount'];
break;
@ -1160,7 +1160,7 @@ class Document
if (!isset($p_array[$tva]))
return "";
// check that something is sold
if ($p_array[$price]==0||$p_array[$qt]==0||strlen(trim($p_array[$price]))==0||strlen(trim($p_array[$qt]))==0)
if ($p_array[$price]==0||$p_array[$qt]==0||noalyss_strlentrim($p_array[$price])==0||noalyss_strlentrim($p_array[$qt])==0)
return "";
$oTva=new Acc_Tva($this->db, $p_array[$tva]);
if ($oTva->load()==-1)
@ -1177,7 +1177,7 @@ class Document
if (!isset($p_array['e_march'.$this->counter.'_tva_id']))
return "";
// check that something is sold
if ($p_array[$price]==0||$p_array[$qt]==0||strlen(trim($p_array[$price]))==0||strlen(trim($p_array[$qt]))==0)
if ($p_array[$price]==0||$p_array[$qt]==0||noalyss_strlentrim($p_array[$price])==0||noalyss_strlentrim($p_array[$qt])==0)
return "";
if (!isset($p_array['e_march'.$this->counter.'_tva_id']))
return '';
@ -1198,7 +1198,7 @@ class Document
if (!isset($p_array[$id]))
return "";
// check that something is sold
if ($p_array['e_march'.$this->counter.'_price']==0||$p_array['e_quant'.$this->counter]==0||strlen(trim($p_array['e_march'.$this->counter.'_price']))==0||strlen(trim($p_array['e_quant'.$this->counter]))==0)
if ($p_array['e_march'.$this->counter.'_price']==0||$p_array['e_quant'.$this->counter]==0||noalyss_strlentrim($p_array['e_march'.$this->counter.'_price'])==0||noalyss_strlentrim($p_array['e_quant'.$this->counter])==0)
return "";
$r=$p_array[$id];
break;
@ -1210,7 +1210,7 @@ class Document
return "";
// check that something is sold
if ($p_array['e_march'.$this->counter.'_price']==0||$p_array['e_quant'.$this->counter]==0||strlen(trim($p_array['e_march'.$this->counter.'_price']))==0||strlen(trim($p_array['e_quant'.$this->counter]))==0)
if ($p_array['e_march'.$this->counter.'_price']==0||$p_array['e_quant'.$this->counter]==0||noalyss_strlentrim($p_array['e_march'.$this->counter.'_price'])==0||noalyss_strlentrim($p_array['e_quant'.$this->counter])==0)
return "";
bcscale(4);
$r=bcmul($p_array[$id], $p_array[$quant]);
@ -1256,8 +1256,8 @@ class Document
if (!isset($p_array[$sell]))
break;
if (strlen(trim($p_array[$sell]))==0||
strlen(trim($p_array[$qt]))==0||
if (noalyss_strlentrim($p_array[$sell])==0||
noalyss_strlentrim($p_array[$qt])==0||
$p_array[$qt]==0||$p_array[$sell]==0)
continue;
$tmp1=bcmul($p_array[$sell], $p_array[$qt]);

View file

@ -242,7 +242,7 @@ class Dossier
public function update()
{
if (strlen(trim($this->dos_name))==0)
if (noalyss_strlentrim($this->dos_name)==0)
return;
if ($this->cn->get_value("select count(*) from ac_dossier "

View file

@ -1697,7 +1697,7 @@ class Fiche
{
$query=sql_string($query);
if (strlen(trim($query))>0)
if (noalyss_strlentrim($query)>0)
{
$query=str_replace(" ", "%", $query);
$filter_query=$and."(vw_name ilike '%$query%' or quick_code ilike ('%$query%') "
@ -1728,7 +1728,7 @@ class Fiche
$this->cn->commit();
}
/**
* return the letter C if amount is > 0, D if < 0 or =
* @brief return the letter C if amount is > 0, D if < 0 or =
* @param type $p_amount
* @return string
*/

View file

@ -231,13 +231,13 @@ $order
// Name can't be empty
if ( strlen(trim($p_nom_mod)) == 0 )
if ( noalyss_strlentrim($p_nom_mod) == 0 )
{
alert (_('Le nom de la catégorie ne peut pas être vide'));
return 1;
}
// $p_fiche_def can't be empty
if ( strlen(trim($p_fiche_def)) == 0 )
if ( noalyss_strlentrim($p_fiche_def) == 0 )
{
alert (_('Un modéle de catégorie est obligatoire'));
return 1;
@ -253,7 +253,7 @@ $order
}
// Set the value of fiche_def.fd_create_account
// automatic creation for 'poste comptable'
if ( $p_create == "on" && strlen(trim($p_class_base)) != 0)
if ( $p_create == "on" && noalyss_strlentrim($p_class_base) != 0)
$p_create='true';
else
$p_create='false';

View file

@ -260,7 +260,7 @@ class Follow_Up
$h2->readonly=($p_view=='NEW')?false:true;
$doc=new Document($this->db, $this->d_id);
$doc->get();
if (strlen(trim($doc->d_lob))!=0)
if (noalyss_strlentrim($doc->d_lob)!=0)
{
$d_id=new IHidden();
$doc_ref="<p> Document ".$doc->anchor().'</p>';
@ -327,7 +327,7 @@ class Follow_Up
$str_add_button=$f_add_button->input();
// f_id_dest sender
if ($this->qcode_dest!=NOTFOUND&&strlen(trim($this->qcode_dest))!=0)
if ($this->qcode_dest!=NOTFOUND&&noalyss_strlentrim($this->qcode_dest)!=0)
{
$tiers=new Fiche($this->db);
$tiers->get_by_qcode($this->qcode_dest);
@ -664,7 +664,7 @@ class Follow_Up
$ord=(!isset($_GET['ord']))?"dd":$_GET['ord'];
$sort=$table->get_sql_order($ord);
if (strlen(trim($p_filter))!=0)
if (noalyss_strlentrim($p_filter)!=0)
$p_filter_doc=" dt_id in ( $p_filter )";
else
$p_filter_doc=" 1=1 ";
@ -1372,7 +1372,7 @@ class Follow_Up
if (isset($p_array['qcode']))
{
// verify that qcode is not empty
if (strlen(trim($p_array['qcode']))!=0)
if (noalyss_strlentrim($p_array['qcode'])!=0)
{
$fiche=new Fiche($cn);

View file

@ -69,7 +69,7 @@ class Forecast
{
// Verify that the elt we want to add is correct
// the f_name must be unique (case insensitive)
if ( strlen(trim($this->f_name))==0) throw new Exception(_('Le nom ne peut pas être vide'));
if ( noalyss_strlentrim($this->f_name)==0) throw new Exception(_('Le nom ne peut pas être vide'));
return 0;
}

View file

@ -245,7 +245,7 @@ EOF;
if (isDate($p_date_start)==null ||
isDate($p_date_end)==null ||
strlen(trim($p_exercice))==0 ||
noalyss_strlentrim($p_exercice)==0 ||
isNumber($p_exercice) ==0 ||
$p_exercice<COMPTA_MIN_YEAR ||
$p_exercice>COMPTA_MAX_YEAR)

View file

@ -76,7 +76,7 @@ class Pre_op_ach extends Pre_operation_detail
for ($i=0;$i<$p_nb_item;$i++)
{
if ( strlen(trim($this->{"e_march".$i}))==0) continue;
if ( noalyss_strlentrim($this->{"e_march".$i})==0) continue;
$sql= 'insert into op_predef_detail (opd_poste,'
. 'opd_amount,'
. 'opd_tva_id,'
@ -224,7 +224,7 @@ class Pre_op_ach extends Pre_operation_detail
// retrieve e_client_label
//--
if ( strlen(trim($e_client)) != 0)
if ( noalyss_strlentrim($e_client) != 0)
{
$fClient=new Fiche($ledger->db);
$fClient->get_by_qcode($e_client);
@ -292,7 +292,7 @@ class Pre_op_ach extends Pre_operation_detail
// retrieve the tva label and name
//--
if ( strlen(trim($march))!=0 && strlen(trim($march_label))==0)
if ( noalyss_strlentrim($march)!=0 && noalyss_strlentrim($march_label)==0)
{
$fMarch=new Fiche($ledger->db);
$fMarch->get_by_qcode($march);

View file

@ -77,7 +77,7 @@ class Pre_op_ven extends Pre_operation_detail
$this->db->exec_sql($sql);
for ($i=0;$i<$p_nb_item;$i++)
{
if ( strlen(trim($this->{"e_march".$i}))== 0 ) continue;
if ( noalyss_strlentrim($this->{"e_march".$i})== 0 ) continue;
$sql= 'insert into op_predef_detail (opd_poste,'
. 'opd_amount,'
. 'opd_tva_id,'
@ -211,7 +211,7 @@ class Pre_op_ven extends Pre_operation_detail
// retrieve e_client_label
//--
if ( strlen(trim($e_client)) != 0)
if ( noalyss_strlentrim($e_client) != 0)
{
$fClient=new Fiche($ledger->db);
$fClient->get_by_qcode($e_client);
@ -279,7 +279,7 @@ class Pre_op_ven extends Pre_operation_detail
// retrieve the tva label and name
//--
if ( strlen(trim($march))!=0 && strlen(trim($march_label))==0)
if ( noalyss_strlentrim($march)!=0 && noalyss_strlentrim($march_label)==0)
{
$fMarch=new Fiche($ledger->db);
$fMarch->get_by_qcode($march);

View file

@ -79,7 +79,7 @@ class Todo_List
}
if ( strcmp ($p_idx, 'tl_date') == 0 )
{
if ( strlen(trim($p_value)) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) return false;
if ( noalyss_strlentrim($p_value) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) return false;
}
if ( strcmp ($p_idx, 'tl_title') == 0 )
{

View file

@ -395,7 +395,7 @@ if ( $sa == 'remove' && isNumber($dossier_id) == 1 && $dossier_id != -1 )
$cn=new Database();
$msg="dossier";
$name=$cn->get_value("select dos_name from ac_dossier where dos_id=$1",array($dossier_id));
if ( strlen(trim($name)) == 0 )
if ( noalyss_strlentrim($name) == 0 )
{
echo "<h2 class=\"error\"> $msg "._('inexistant')."</h2>";
return;

View file

@ -124,7 +124,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
}
$go=0;
// we ask a poste_id
if ( isset($_GET['poste_id']) && strlen(trim($_GET['poste_id'])) != 0 )
if ( isset($_GET['poste_id']) && noalyss_strlentrim($_GET['poste_id']) != 0 )
{
if ( isset ($_GET['poste_fille']) )
{
@ -139,7 +139,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
$go=1;
}
}
if ( strlen(trim($_GET['f_id'])) != 0 )
if ( noalyss_strlentrim($_GET['f_id']) != 0 )
{
// thanks the qcode we found the poste account
$fiche=new Fiche($cn);

View file

@ -235,7 +235,7 @@ function isNumber($p_int)
function isDate($p_date)
{
if (strlen(trim($p_date)) == 0)
if (noalyss_strlentrim($p_date) == 0)
return null;
if (preg_match("/^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}$/", $p_date) == 0)
{
@ -1474,7 +1474,7 @@ function generate_random_string($car)
$string="";
$chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-=";
srand((float) microtime(true)*1020030);
for ($i=0; $i<$car; $i++)
for ($i=0; $i<$p_length; $i++)
{
$string .= $chaine[rand()%strlen($chaine)];
}
@ -1593,6 +1593,10 @@ function noalyss_trim($p_string) {
if ($p_string===null) return "";
else return trim($p_string);
}
function noalyss_strlentrim($p_string) :int {
if (empty($p_string)) return 0;
return strlen(trim($p_string));
}
function noalyss_str_replace($search,$replace,$string) {
if ($string===null) return "";
else return str_replace($search,$replace,$string);

View file

@ -411,7 +411,7 @@ if ($sa == 'list')
$cn = new Database();
$msg = "dossier";
$name = $cn->get_value("select mod_name from modeledef where mod_id=$1", array($mod_id));
if (strlen(trim($name)) == 0)
if (noalyss_strlentrim($name) == 0)
{
echo "<h2 class=\"error\"> $msg inexistant</h2>";
return;

View file

@ -123,11 +123,11 @@ if (isset($_POST['save_name']))
$p_desc=$http->post('p_desc');
try
{
if (strlen(trim($p_name))==0)
if (noalyss_strlentrim($p_name)==0)
throw new Exception("Nom ne peut être vide");
if (isNumber($p_id)==0)
throw new Exception("profile Invalide");
$p_desc=(strlen(trim($p_desc))==0)?null:trim($p_desc);
$p_desc=(noalyss_strlentrim($p_desc)==0)?null:trim($p_desc);
if ($p_id!=-1)
{
$cn->exec_sql("update profile set p_name=$1,p_desc=$2,
@ -245,7 +245,7 @@ if (isset($_POST['mod']))
$me_code_dep=-1;
}
$cn->start();
$p_order=(strlen(trim($p_order))==0)?"0":$p_order;
$p_order=(noalyss_strlentrim($p_order)==0)?"0":$p_order;
if ($pm_default==1)
{
// reset all default

View file

@ -145,7 +145,7 @@ L\'email a été envoyé avec un lien et le nouveau mot de passe, vérifiez vos
elseif ($action=="req") :
$http=new HttpInput();
$request_id=$http->request("req","string", "");
if (strlen(trim($request_id))==SIZE_REQUEST) :
if (noalyss_strlentrim($request_id)==SIZE_REQUEST) :
$cn=new Database(0);
$value=$cn->get_value("select password from recover_pass where request=$1 and created_on > now() - interval '12 hours' and recover_on is null", array($request_id));

View file

@ -56,7 +56,7 @@ if ( isset ($_REQUEST['sa'] ))
exit();
}
if ( empty ($_FILES['file']['name']) ||
strlen(trim($_FILES['file']['name']))==0
noalyss_strlentrim($_FILES['file']['name'])==0
)
{
echo '<div class="content">';
@ -75,7 +75,7 @@ if ( isset ($_REQUEST['sa'] ))
$cn=new Database();
$id=$cn->get_next_seq('dossier_id');
if ( strlen(trim($_REQUEST['database'])) == 0 )
if ( noalyss_strlentrim($_REQUEST['database']) == 0 )
{
$lname=$id." Restauration :".sql_string($_FILES['file']['name']);
}
@ -84,7 +84,7 @@ if ( isset ($_REQUEST['sa'] ))
$lname=$id." ".$_REQUEST['database'];
}
if (strlen(trim($_REQUEST['desc']))==0)
if (noalyss_strlentrim($_REQUEST['desc'])==0)
{
$ldesc=$lname;
}
@ -149,7 +149,7 @@ if ( isset ($_REQUEST['sa'] ))
$cn=new Database();
$id=$cn->get_next_seq('s_modid');
if ( strlen(trim($_REQUEST['database'])) == 0 )
if ( noalyss_strlentrim($_REQUEST['database']) == 0 )
$lname=$id." Restauration :".$_FILES['file']['name'];
else
$lname=$id." ".$_REQUEST['database'];

View file

@ -40,7 +40,7 @@ if ($g_parameter->MY_STOCK == 'N')
if ( isset ($_POST['add_stock']))
{
$post_name=$http->post('r_name');
if ( strlen(trim($post_name)) != 0)
if ( noalyss_strlentrim($post_name) != 0)
{
$st=new Stock_Sql($cn);
$st->from_array($_POST);
@ -50,7 +50,7 @@ if ( isset ($_POST['add_stock']))
if ( isset ($_POST['mod_stock']))
{
$post_name=$http->post('r_name');
if ( strlen(trim($post_name)) != 0)
if ( noalyss_strlentrim($post_name) != 0)
{
$st=new Stock_Sql($cn,$http->post('r_id',"number"));

View file

@ -24,7 +24,7 @@
* Global variables
*/
global $g_connection,$g_parameter,$g_user;
if (!defined("DOSSIER"))define ("DOSSIER",101);
if (!defined("DOSSIER"))define ("DOSSIER",25);
$_REQUEST['gDossier'] = DOSSIER;
$g_connection=new Database(DOSSIER);

View file

@ -249,12 +249,12 @@ class Card_PropertyTest extends TestCase
public function testBuildInput2()
{
$g_connection=Dossier::connect();
$g_connection->exec_sql("update fiche_def set fd_create_account=false where fd_id=25");
$g_connection->exec_sql("update fiche_def set fd_create_account=false where fd_id=2");
$property=new \Card_Property($g_connection,ATTR_DEF_ACCOUNT);
$fiche_def=new \Fiche_Def($g_connection,25);
$fiche_def=new \Fiche_Def($g_connection,2);
$result=$property->build_input($fiche_def);
$g_connection->exec_sql("update fiche_def set fd_create_account=true where fd_id=25");
$g_connection->exec_sql("update fiche_def set fd_create_account=true where fd_id=2");
/*
$file_result=__CLASS__."-".__FUNCTION__.".txt";
$file_target='target-'.$file_result;

View file

@ -17,8 +17,7 @@ FUNCTION=""
COVERAGE=""
FOLDERTEST=""
PHPINI="/opt/php/8.1/bin/php "
# PHPINI="/opt/php/8.1/bin/php "
PHPINI="/usr/bin/php"
while getopts "f:i:cd:x" opt; do
case $opt in
d)