From 582d4d21b70b53ca14877046e149de72bd13952a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Apr 2011 00:03:16 +0000 Subject: [PATCH] Perf: Another speed enhancement to win 6 ms. --- htdocs/lib/functions.lib.php | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index a0fef38cb7a..220a4222347 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -3594,26 +3594,22 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') */ function verifCond($strRights) { - global $user,$conf,$langs,$leftmenu; - global $rights; // To export to dol_eval function + global $user,$conf,$langs; + global $leftmenu; + global $rights; // To export to dol_eval function //print $strRights."
\n"; - if ($strRights != "") + $rights = true; + if ($strRights != '') { - $rights = true; - $tab_rights = explode("||", $strRights); - $i = 0; - while (($i < count($tab_rights)) && ($rights == true)) { + //$tab_rights = explode('&&', $strRights); + //$i = 0; + //while (($i < count($tab_rights)) && ($rights == true)) { $str = 'if(!(' . $strRights . ')) { $rights = false; }'; dol_eval($str); - $i++; - } + // $i++; + //} } - else - { - $rights = true; - } - return $rights; } @@ -3621,22 +3617,16 @@ function verifCond($strRights) * Replace eval function to add more security. * This function is called by verifCond(). * @param string $s - * @return int 1 */ function dol_eval($s) { // Only global variables can be changed by eval function and returned to caller global $langs, $user, $conf; + global $leftmenu; global $rights; - global $leftmenu; - - // \todo - // Warning. We must add code to exclude test if it contains = (affectation) that is not == (compare) //print $s."
\n"; eval($s); - - return 1; }