From 7d5b36c3d903e2281f87d988e25115f764a59f39 Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Thu, 19 Jul 2007 17:15:04 +0000
Subject: [PATCH] =?UTF-8?q?Fix:=20remplacement=20de=20LIKE=20dans=20la=20r?=
 =?UTF-8?q?equete=20sql=20par=20REGEXP=20afin=20de=20palier=20au=20diff=E9?=
 =?UTF-8?q?rent=20format=20de=20num=E9rotation=20je=20vais=20corriger=20le?=
 =?UTF-8?q?s=20autres=20modules=20de=20num=E9rotation=20param=E9trable?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 htdocs/includes/modules/fichinter/mod_arctic.php | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/htdocs/includes/modules/fichinter/mod_arctic.php b/htdocs/includes/modules/fichinter/mod_arctic.php
index e3152c18564..e81e9314161 100644
--- a/htdocs/includes/modules/fichinter/mod_arctic.php
+++ b/htdocs/includes/modules/fichinter/mod_arctic.php
@@ -175,7 +175,7 @@ function info()
           $searchyy='';
           $sql = "SELECT MAX(ref)";
           $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
-          if ($conf->global->FICHEINTER_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref like '".$this->searchLast."%'";
+          if ($conf->global->FICHEINTER_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref REGEXP '^".$this->searchLast."'";
           $resql=$db->query($sql);
           if ($resql)
           {
@@ -189,7 +189,7 @@ function info()
             $previousyy='';
             $sql = "SELECT MAX(ref)";
             $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
-            $sql.= " WHERE ref like '".$this->searchLastWithPreviousYear."%'";
+            $sql.= " WHERE ref REGEXP '^".$this->searchLastWithPreviousYear."'";
             $resql=$db->query($sql);
             if ($resql)
             {
@@ -204,7 +204,7 @@ function info()
             // Recherche rapide car restreint par un like sur champ index�
             $sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))";
             $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
-            $sql.= " WHERE ref like '${searchyy}%'";
+            $sql.= " WHERE ref REGEXP '^".$searchyy."'";
             $resql=$db->query($sql);
             if ($resql)
             {
@@ -377,9 +377,9 @@ function info()
         					// On r�cup�re le mois si besoin
         					$this->mm = strftime("%m",time());
         					$this->numMatrice[$k] = '$mm';
-        					$this->searchLast .= $this->mm;
+        					$this->searchLast .= '[0-9][0-9]';
         					$this->searchLastWithNoYear .= '[0-9][0-9]';
-        					$this->searchLastWithPreviousYear .= $this->mm;
+        					$this->searchLastWithPreviousYear .= '[0-9][0-9]';
         					$k++;
         				}
         				else if ($idMatrice == 'counter')
-- 
GitLab