From b6d0f859af2852f8f4d3cf8132ac536247ce51af Mon Sep 17 00:00:00 2001 From: Philippe Grand <philippe.grand@atoo-net.com> Date: Tue, 24 Aug 2010 19:51:56 +0000 Subject: [PATCH] task #6689, strlen problem replace strlen with dol_strlen --- htdocs/lib/ldap.class.php | 6 +++--- htdocs/lib/memory.lib.php | 2 +- htdocs/lib/security.lib.php | 14 +++++++------- htdocs/lib/viewfiles.lib.php | 6 +++--- htdocs/lib/xcal.lib.php | 8 ++++---- .../canvas/default/product.default.class.php | 4 ++-- .../canvas/service/product.service.class.php | 4 ++-- htdocs/product/class/product.class.php | 8 ++++---- htdocs/product/liste.php | 6 +++--- htdocs/product/reassort.php | 4 ++-- htdocs/projet/class/project.class.php | 2 +- htdocs/public/demo/index.php | 4 ++-- htdocs/societe/class/societe.class.php | 6 +++--- htdocs/societe/lien.php | 2 +- htdocs/societe/soc.php | 8 ++++---- htdocs/societe/societe.php | 2 +- htdocs/user/class/user.class.php | 6 +++--- htdocs/user/class/usergroup.class.php | 4 ++-- htdocs/user/group/perms.php | 4 ++-- htdocs/user/perms.php | 4 ++-- .../email_unpaid_invoices_to_representatives.php | 2 +- 21 files changed, 53 insertions(+), 53 deletions(-) diff --git a/htdocs/lib/ldap.class.php b/htdocs/lib/ldap.class.php index 760ee1aa618..d79b09efb1f 100644 --- a/htdocs/lib/ldap.class.php +++ b/htdocs/lib/ldap.class.php @@ -1030,7 +1030,7 @@ class Ldap * Indispensable pour Active Directory */ function littleEndian($hex) { - for ($x=strlen($hex)-2; $x >= 0; $x=$x-2) { + for ($x=dol_strlen($hex)-2; $x >= 0; $x=$x-2) { $result .= substr($hex,$x,2); } return $result; @@ -1250,11 +1250,11 @@ class Ldap function setDn($peopleOrGroups) { if ($peopleOrGroups) { - if ( isset($this->people) && (strlen($this->people) > 0) ) { + if ( isset($this->people) && (dol_strlen($this->people) > 0) ) { $checkDn = "ou=" .$this->people. ", " .$this->dn; } } else { - if ( isset($this->groups) && (strlen($this->groups) > 0) ) { + if ( isset($this->groups) && (dol_strlen($this->groups) > 0) ) { $checkDn = "ou=" .$this->groups. ", " .$this->dn; } } diff --git a/htdocs/lib/memory.lib.php b/htdocs/lib/memory.lib.php index b81d5106925..01f20c99df6 100644 --- a/htdocs/lib/memory.lib.php +++ b/htdocs/lib/memory.lib.php @@ -201,7 +201,7 @@ function dol_setshmop($memoryid,$data) { $shm_bytes_written1=shmop_write($handle,str_pad($size,6),0); $shm_bytes_written2=shmop_write($handle,$newdata,6); - if (($shm_bytes_written1 + $shm_bytes_written2) != (6+strlen($newdata))) + if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata))) { print "Couldn't write the entire length of data\n"; } diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php index 1f5cffa02a7..6ec18dd64d1 100644 --- a/htdocs/lib/security.lib.php +++ b/htdocs/lib/security.lib.php @@ -237,7 +237,7 @@ function makesalt($type=CRYPT_SALT_LENGTH) $saltlen=2; $saltprefix=''; $saltsuffix=''; break; } $salt=''; - while(strlen($salt) < $saltlen) $salt.=chr(mt_rand(64,126)); + while(dol_strlen($salt) < $saltlen) $salt.=chr(mt_rand(64,126)); $result=$saltprefix.$salt.$saltsuffix; dol_syslog("security.lib.php::makesalt return=".$result); @@ -325,7 +325,7 @@ function encodedecode_dbpassconf($level=0) $file=DOL_DOCUMENT_ROOT.'/conf/conf.php'; if ($fp = @fopen($file,'w')) { - fputs($fp, $config, strlen($config)); + fputs($fp, $config, dol_strlen($config)); fclose($fp); // It's config file, so we set read permission for creator only. // Should set permission to web user and groups for users used by batch @@ -353,7 +353,7 @@ function encodedecode_dbpassconf($level=0) */ function dol_encode($chain) { - for($i=0;$i<strlen($chain);$i++) + for($i=0;$i<dol_strlen($chain);$i++) { $output_tab[$i] = chr(ord(substr($chain,$i,1))+17); } @@ -371,7 +371,7 @@ function dol_decode($chain) { $chain = base64_decode($chain); - for($i=0;$i<strlen($chain);$i++) + for($i=0;$i<dol_strlen($chain);$i++) { $output_tab[$i] = chr(ord(substr($chain,$i,1))-17); } @@ -472,7 +472,7 @@ function dol_efc_config() foreach ($available["$avCipher"] as $avMode) $v .= " '".$avMode."', "; - $i = strlen($v) - 2; + $i = dol_strlen($v) - 2; if ($v[$i] == ",") $v = substr($v, 2, $i - 3); } @@ -480,8 +480,8 @@ function dol_efc_config() $strAv .= "'".$avCipher."' => Array (".$v."),\n "; } $strAv = rtrim($strAv); - if ($strAv[strlen($strAv) - 1] == ",") - $strAv = substr($strAv, 0, strlen($strAv) - 1); + if ($strAv[dol_strlen($strAv) - 1] == ",") + $strAv = substr($strAv, 0, dol_strlen($strAv) - 1); $strAv .= " );\n\n"; $strAv .= "?>"; diff --git a/htdocs/lib/viewfiles.lib.php b/htdocs/lib/viewfiles.lib.php index f53533445fe..a192a0ce1f5 100644 --- a/htdocs/lib/viewfiles.lib.php +++ b/htdocs/lib/viewfiles.lib.php @@ -31,14 +31,14 @@ function make_alpha_from_numbers($number) { $numeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - if($number<strlen($numeric)) + if($number<dol_strlen($numeric)) { return $numeric[$number]; } else { - $dev_by = floor($number/strlen($numeric)); - return "" . make_alpha_from_numbers($dev_by-1) . make_alpha_from_numbers($number-($dev_by*strlen($numeric))); + $dev_by = floor($number/dol_strlen($numeric)); + return "" . make_alpha_from_numbers($dev_by-1) . make_alpha_from_numbers($number-($dev_by*dol_strlen($numeric))); } } diff --git a/htdocs/lib/xcal.lib.php b/htdocs/lib/xcal.lib.php index 3c321725318..5afcc3fe5fc 100644 --- a/htdocs/lib/xcal.lib.php +++ b/htdocs/lib/xcal.lib.php @@ -388,11 +388,11 @@ function CalEncode($line) } else { - for ($j = 0; $j <= strlen($line) - 1; $j++) + for ($j = 0; $j <= dol_strlen($line) - 1; $j++) { $char = substr ( $line, $j, 1 ); // Take char at position $j - if ( ( strlen ( $newpara ) + strlen ( $char ) ) >= 75 ) + if ( ( dol_strlen ( $newpara ) + dol_strlen ( $char ) ) >= 75 ) { $out .= $newpara . "\r\n "; // CRLF + Space for cal $newpara = ''; @@ -415,7 +415,7 @@ function QPEncode($str,$forcal=0) { $newpara = ''; - for ($j = 0; $j <= strlen($line) - 1; $j++) + for ($j = 0; $j <= dol_strlen($line) - 1; $j++) { $char = substr ( $line, $j, 1 ); $ascii = ord ( $char ); @@ -423,7 +423,7 @@ function QPEncode($str,$forcal=0) if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) $char = '=' . strtoupper ( sprintf("%02X", $ascii ) ); - if ( ( strlen ( $newpara ) + strlen ( $char ) ) >= 76 ) + if ( ( dol_strlen ( $newpara ) + dol_strlen ( $char ) ) >= 76 ) { $out .= $newpara . '=' . "\r\n"; // CRLF if ($forcal) $out .= " "; // + Space for cal diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php index ec28fff6cd6..8501d973c17 100644 --- a/htdocs/product/canvas/default/product.default.class.php +++ b/htdocs/product/canvas/default/product.default.class.php @@ -224,11 +224,11 @@ class ProductDefault extends Product } } - if (isset($_GET["tosell"]) && strlen($_GET["tosell"]) > 0) + if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) { $sql.= " AND p.tosell = ".addslashes($_GET["tosell"]); } - if (isset($_GET["canvas"]) && strlen($_GET["canvas"]) > 0) + if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0) { $sql.= " AND p.canvas = '".addslashes($_GET["canvas"])."'"; } diff --git a/htdocs/product/canvas/service/product.service.class.php b/htdocs/product/canvas/service/product.service.class.php index ca76ae1f992..c0530de2e2c 100644 --- a/htdocs/product/canvas/service/product.service.class.php +++ b/htdocs/product/canvas/service/product.service.class.php @@ -160,11 +160,11 @@ class ProductService extends Product if ($sref) $sql.= " AND p.ref like '%".$sref."%'"; if ($sbarcode) $sql.= " AND p.barcode like '%".$sbarcode."%'"; if ($snom) $sql.= " AND p.label like '%".addslashes($snom)."%'"; - if (isset($_GET["tosell"]) && strlen($_GET["tosell"]) > 0) + if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) { $sql.= " AND p.tosell = ".addslashes($_GET["tosell"]); } - if (isset($_GET["canvas"]) && strlen($_GET["canvas"]) > 0) + if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0) { $sql.= " AND p.canvas = '".addslashes($_GET["canvas"])."'"; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 630c7d743e9..ca16b594313 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -168,10 +168,10 @@ class Product extends CommonObject $this->ref = dol_sanitizeFileName(stripslashes($this->ref)); $err = 0; - if (strlen(trim($this->ref)) == 0) + if (dol_strlen(trim($this->ref)) == 0) $err++; - if (strlen(trim($this->libelle)) == 0) + if (dol_strlen(trim($this->libelle)) == 0) $err++; if ($err > 0) @@ -1010,7 +1010,7 @@ class Product extends CommonObject $this->finished = $result["finished"]; $this->hidden = $result["hidden"]; $this->duration = $result["duration"]; - $this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1); + $this->duration_value = substr($result["duration"],0,dol_strlen($result["duration"])-1); $this->duration_unit = substr($result["duration"],-1); $this->seuil_stock_alerte = $result["seuil_stock_alerte"]; $this->canvas = $result["canvas"]; @@ -1441,7 +1441,7 @@ class Product extends CommonObject // $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0); $month = "0".($month - 1); - if (strlen($month) == 3) + if (dol_strlen($month) == 3) { $month = substr($month,1); } diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 8563cba1686..b93338763b5 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -141,7 +141,7 @@ if ($sall) $sql.= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')"; } # if the type is not 1, we show all products (type = 0,2,3) -if (strlen($_GET["type"]) || strlen($_POST["type"])) +if (dol_strlen($_GET["type"]) || dol_strlen($_POST["type"])) { if ($type==1) { $sql.= " AND p.fk_product_type = '1'"; @@ -152,11 +152,11 @@ if (strlen($_GET["type"]) || strlen($_POST["type"])) if ($sref) $sql.= " AND p.ref like '%".$sref."%'"; if ($sbarcode) $sql.= " AND p.barcode like '%".$sbarcode."%'"; if ($snom) $sql.= " AND p.label like '%".addslashes($snom)."%'"; -if (isset($_GET["tosell"]) && strlen($_GET["tosell"]) > 0) +if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) { $sql.= " AND p.tosell = ".addslashes($_GET["tosell"]); } -if (isset($_GET["canvas"]) && strlen($_GET["canvas"]) > 0) +if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0) { $sql.= " AND p.canvas = '".addslashes($_GET["canvas"])."'"; } diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 0adc5d89358..bed34f109f2 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -124,11 +124,11 @@ if ($snom) { $sql.= " AND p.label like '%".addslashes($snom)."%'"; } -if (isset($_GET["tosell"]) && strlen($_GET["tosell"]) > 0) +if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) { $sql.= " AND p.tosell = ".$_GET["tosell"]; } -if (isset($_GET["tobuy"]) && strlen($_GET["tobuy"]) > 0) +if (isset($_GET["tobuy"]) && dol_strlen($_GET["tobuy"]) > 0) { $sql.= " AND p.tobuy = ".$_GET["tobuy"]; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8ad60bfb8e1..df1befdf722 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -151,7 +151,7 @@ class Project extends CommonObject $this->title = trim($this->title); $this->description = trim($this->description); - if (strlen(trim($this->ref)) > 0) + if (dol_strlen(trim($this->ref)) > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet SET"; $sql.= " ref='".$this->ref."'"; diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index e2f97530158..fbb87ba83f3 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -147,9 +147,9 @@ foreach ($dirlist as $dirroot) while (($file = readdir($handle))!==false) { //print "$i ".$file."\n<br>"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { - $modName = substr($file, 0, strlen($file) - 10); + $modName = substr($file, 0, dol_strlen($file) - 10); if ($modName) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e748e2850b9..12430835b49 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -390,7 +390,7 @@ class Societe extends CommonObject $this->localtax2_assuj=trim($this->localtax2_assuj); $this->capital=trim($this->capital); - if (strlen($this->capital) == 0) $this->capital = 0; + if (dol_strlen($this->capital) == 0) $this->capital = 0; $this->effectif_id=trim($this->effectif_id); $this->forme_juridique_code=trim($this->forme_juridique_code); @@ -1769,7 +1769,7 @@ class Societe extends CommonObject $chaine=trim($this->siren); $chaine=preg_replace('/(\s)/','',$chaine); - if (strlen($chaine) != 9) return -1; + if (dol_strlen($chaine) != 9) return -1; $sum = 0; @@ -1798,7 +1798,7 @@ class Societe extends CommonObject $chaine=trim($this->siret); $chaine=preg_replace('/(\s)/','',$chaine); - if (strlen($chaine) != 14) return -1; + if (dol_strlen($chaine) != 14) return -1; } return $ok; diff --git a/htdocs/societe/lien.php b/htdocs/societe/lien.php index 6372a3c9f6e..747cd18d5ac 100644 --- a/htdocs/societe/lien.php +++ b/htdocs/societe/lien.php @@ -188,7 +188,7 @@ if($_GET["socid"]) $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."c_typent as te"; $sql.= " WHERE s.fk_typent = te.id"; - if (strlen(trim($_GET["search_nom"]))) + if (dol_strlen(trim($_GET["search_nom"]))) { $sql .= " AND s.nom LIKE '%".$_GET["search_nom"]."%'"; } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b121cb7062e..94c3cde543c 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -368,7 +368,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, strlen($module)-4); + $module = substr($module, 0, dol_strlen($module)-4); } require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); $modCodeClient = new $module; @@ -376,7 +376,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, strlen($module)-4); + $module = substr($module, 0, dol_strlen($module)-4); } require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); $modCodeFournisseur = new $module; @@ -761,7 +761,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, strlen($module)-4); + $module = substr($module, 0, dol_strlen($module)-4); } require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); $modCodeClient = new $module; @@ -774,7 +774,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, strlen($module)-4); + $module = substr($module, 0, dol_strlen($module)-4); } require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); $modCodeFournisseur = new $module; diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php index abe01d1522c..23aa84675f2 100644 --- a/htdocs/societe/societe.php +++ b/htdocs/societe/societe.php @@ -163,7 +163,7 @@ $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.entity = ".$conf->entity; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; -if (strlen($stcomm)) +if (dol_strlen($stcomm)) { $sql.= " AND s.fk_stcomm=".$stcomm; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 7969300c620..fd23742d9e4 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -538,10 +538,10 @@ class User extends CommonObject { $row = $this->db->fetch_row($result); - if (strlen($row[1]) > 0) + if (dol_strlen($row[1]) > 0) { - if (strlen($row[2]) > 0) + if (dol_strlen($row[2]) > 0) { $this->rights->$row[0]->$row[1]->$row[2] = 1; } @@ -1688,7 +1688,7 @@ class User extends CommonObject $info["phpgwContactCatId"] = 0; $info["phpgwContactAccess"] = "public"; - if (strlen($this->egroupware_id) == 0) + if (dol_strlen($this->egroupware_id) == 0) { $this->egroupware_id = 1; } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 0f2a7d5b9e8..6634fcf8b00 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -417,10 +417,10 @@ class UserGroup extends CommonObject { $row = $this->db->fetch_row($resql); - if (strlen($row[1]) > 0) + if (dol_strlen($row[1]) > 0) { - if (strlen($row[2]) > 0) + if (dol_strlen($row[2]) > 0) { $this->rights->$row[0]->$row[1]->$row[2] = 1; } diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 7a8974d25cd..dbe72944921 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -93,9 +93,9 @@ if ($_GET["id"]) { while (($file = readdir($handle))!==false) { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { - $modName = substr($file, 0, strlen($file) - 10); + $modName = substr($file, 0, dol_strlen($file) - 10); if ($modName) { diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index c36deca038b..07f4dd8e081 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -124,9 +124,9 @@ foreach($listdir as $dirroot) $handle=opendir($dir); while (($file = readdir($handle))!==false) { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { - $modName = substr($file, 0, strlen($file) - 10); + $modName = substr($file, 0, dol_strlen($file) - 10); if ($modName) { diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index f837a64d61b..4fe4752b09b 100644 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -77,7 +77,7 @@ if ($resql) if ($obj->email <> $oldemail) { - if (strlen($oldemail)) + if (dol_strlen($oldemail)) { envoi_mail($oldemail,$message,$total); } -- GitLab