Qual: Reduce too much memory used on all pages for only 1 test is 5 files (move function into functions2.lib.php instead of functions.lib.php, functions.php is always loaded, functions2 is loaded on demand).
Fix: Removed test on url to allow to input url with no http before
This commit is contained in:
parent
203336b839
commit
a37297a83f
@ -22,13 +22,13 @@
|
|||||||
\version $Id$
|
\version $Id$
|
||||||
\brief File of class to manage dynamic menu entries
|
\brief File of class to manage dynamic menu entries
|
||||||
\remarks Initialy built by build_class_from_table on 2008-01-12 14:19
|
\remarks Initialy built by build_class_from_table on 2008-01-12 14:19
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class Menubase
|
\class Menubase
|
||||||
\brief Class to manage menu entries
|
\brief Class to manage menu entries
|
||||||
*/
|
*/
|
||||||
class Menubase
|
class Menubase
|
||||||
{
|
{
|
||||||
var $db; // To store db handler
|
var $db; // To store db handler
|
||||||
@ -412,7 +412,7 @@ class Menubase
|
|||||||
$tabMenu[$b][0] = $menu['rowid'];
|
$tabMenu[$b][0] = $menu['rowid'];
|
||||||
$tabMenu[$b][1] = $menu['fk_menu'];
|
$tabMenu[$b][1] = $menu['fk_menu'];
|
||||||
$tabMenu[$b][2] = $menu['url'];
|
$tabMenu[$b][2] = $menu['url'];
|
||||||
if (!valid_url($tabMenu[$b][2],1))
|
if (! eregi($tabMenu[$b][2],"^(http:\/\/|https:\/\/)"))
|
||||||
{
|
{
|
||||||
if (eregi('\?',$tabMenu[$b][2])) $tabMenu[$b][2].='&idmenu='.$menu['rowid'];
|
if (eregi('\?',$tabMenu[$b][2])) $tabMenu[$b][2].='&idmenu='.$menu['rowid'];
|
||||||
else $tabMenu[$b][2].='?idmenu='.$menu['rowid'];
|
else $tabMenu[$b][2].='?idmenu='.$menu['rowid'];
|
||||||
@ -483,9 +483,9 @@ class Menubase
|
|||||||
|
|
||||||
if ($leftmenuConstraint)
|
if ($leftmenuConstraint)
|
||||||
{
|
{
|
||||||
// print "x".$pere." ".$tab[$x][6];
|
// print "x".$pere." ".$tab[$x][6];
|
||||||
|
|
||||||
$this->newmenu->add_submenu((!valid_url($tab[$x][2],1)) ? DOL_URL_ROOT . $tab[$x][2] : $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5]);
|
$this->newmenu->add_submenu((! eregi($tab[$x][2],"^(http:\/\/|https:\/\/)")) ? DOL_URL_ROOT . $tab[$x][2] : $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5]);
|
||||||
$this->recur($tab, $tab[$x][0], $rang +1);
|
$this->recur($tab, $tab[$x][0], $rang +1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class MenuTop {
|
|||||||
if ($tabMenu[$i]['right'] == true)
|
if ($tabMenu[$i]['right'] == true)
|
||||||
{
|
{
|
||||||
// Define url
|
// Define url
|
||||||
if (valid_url($tabMenu[$i]['url'],1))
|
if (eregi($tabMenu[$i]['url'],"^(http:\/\/|https:\/\/)"))
|
||||||
{
|
{
|
||||||
$url = $tabMenu[$i]['url'];
|
$url = $tabMenu[$i]['url'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class MenuTop {
|
|||||||
if ($tabMenu[$i]['right'] == true)
|
if ($tabMenu[$i]['right'] == true)
|
||||||
{
|
{
|
||||||
// Define url
|
// Define url
|
||||||
if (valid_url($tabMenu[$i]['url'],1))
|
if (eregi($tabMenu[$i]['url'],"^(http:\/\/|https:\/\/)"))
|
||||||
{
|
{
|
||||||
$url = $tabMenu[$i]['url'];
|
$url = $tabMenu[$i]['url'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -364,7 +364,7 @@ class MenuTop {
|
|||||||
$idsel=(empty($tabMenu[$i]['mainmenu'])?'id="none" ':'id="'.$tabMenu[$i]['mainmenu'].'" ');
|
$idsel=(empty($tabMenu[$i]['mainmenu'])?'id="none" ':'id="'.$tabMenu[$i]['mainmenu'].'" ');
|
||||||
if ($tabMenu[$i]['right'] == true)
|
if ($tabMenu[$i]['right'] == true)
|
||||||
{
|
{
|
||||||
if (valid_url($tabMenu[$i]['url'],1))
|
if (eregi($tabMenu[$i]['url'],"^(http:\/\/|https:\/\/)"))
|
||||||
{
|
{
|
||||||
$url = $tabMenu[$i]['url'];
|
$url = $tabMenu[$i]['url'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -365,7 +365,7 @@ class MenuTop {
|
|||||||
if ($tabMenu[$i]['right'] == true)
|
if ($tabMenu[$i]['right'] == true)
|
||||||
{
|
{
|
||||||
// Define url
|
// Define url
|
||||||
if (valid_url($tabMenu[$i]['url'],1))
|
if (eregi($tabMenu[$i]['url'],"^(http:\/\/|https:\/\/)"))
|
||||||
{
|
{
|
||||||
$url = $tabMenu[$i]['url'];
|
$url = $tabMenu[$i]['url'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -365,7 +365,7 @@ class MenuTop {
|
|||||||
$idsel=(empty($tabMenu[$i]['mainmenu'])?'id="none" ':'id="'.$tabMenu[$i]['mainmenu'].'" ');
|
$idsel=(empty($tabMenu[$i]['mainmenu'])?'id="none" ':'id="'.$tabMenu[$i]['mainmenu'].'" ');
|
||||||
if ($tabMenu[$i]['right'] == true)
|
if ($tabMenu[$i]['right'] == true)
|
||||||
{
|
{
|
||||||
if (valid_url($tabMenu[$i]['url'],1))
|
if (eregi($tabMenu[$i]['url'],"^(http:\/\/|https:\/\/)"))
|
||||||
{
|
{
|
||||||
$url = $tabMenu[$i]['url'];
|
$url = $tabMenu[$i]['url'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2323,13 +2323,13 @@ function create_exdir($dir)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog("functions.lib::create_exdir: Directory '".$ccdir."' created",LOG_DEBUG);
|
dol_syslog("functions.lib::create_exdir: Directory '".$ccdir."' created",LOG_DEBUG);
|
||||||
$nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les <EFBFBD>checs pr<70>c<EFBFBD>dents peuvent etre ignor<6F>s
|
$nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignore
|
||||||
$nbcreated++;
|
$nbcreated++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les <EFBFBD>checs pr<70>c<EFBFBD>dents peuvent etre ignor<6F>s
|
$nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignores
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2347,93 +2347,6 @@ function picto_required()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Clean an url string
|
|
||||||
* \param url Url
|
|
||||||
* \param http 1: keep http, 0: remove also http
|
|
||||||
* \return string CleanUrl
|
|
||||||
*/
|
|
||||||
function clean_url($url,$http=1)
|
|
||||||
{
|
|
||||||
// Fixed by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-cleaning-url.html)
|
|
||||||
// To include the minus sign in a char class, we must not escape it but put it at the end of the class
|
|
||||||
// Also, there's no need of escape a dot sign in a class
|
|
||||||
if (eregi('^(https?:[\\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?',$url,$regs))
|
|
||||||
{
|
|
||||||
$proto=$regs[1];
|
|
||||||
$domain=$regs[2];
|
|
||||||
$port=$regs[3];
|
|
||||||
//print $url." -> ".$proto." - ".$domain." - ".$port;
|
|
||||||
//$url = dol_string_nospecial(trim($url));
|
|
||||||
$url = trim($url);
|
|
||||||
|
|
||||||
// Si http: defini on supprime le http (Si https on ne supprime pas)
|
|
||||||
$newproto=$proto;
|
|
||||||
if ($http==0)
|
|
||||||
{
|
|
||||||
if (eregi('^http:[\\\/]+',$url))
|
|
||||||
{
|
|
||||||
$url = eregi_replace('^http:[\\\/]+','',$url);
|
|
||||||
$newproto = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// On passe le nom de domaine en minuscule
|
|
||||||
$CleanUrl = eregi_replace('^'.$proto.$domain, $newproto.strtolower($domain), $url);
|
|
||||||
|
|
||||||
return $CleanUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Url string validation
|
|
||||||
* \remarks <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor]
|
|
||||||
* \param url Url
|
|
||||||
* \param http 1: verify http, 0: not verify http
|
|
||||||
* \param pass 1: verify user and pass, 0: not verify user and pass
|
|
||||||
* \param port 1: verify port, 0: not verify port
|
|
||||||
* \param path 1: verify path, 0: not verify path
|
|
||||||
* \param query 1: verify query, 0: not verify query
|
|
||||||
* \param anchor 1: verify anchor, 0: not verify anchor
|
|
||||||
* \return string ValidUrl
|
|
||||||
*/
|
|
||||||
function valid_url($url,$http=0,$pass=0,$port=0,$path=0,$query=0,$anchor=0)
|
|
||||||
{
|
|
||||||
$ValidUrl = 0;
|
|
||||||
$urlregex = '';
|
|
||||||
|
|
||||||
// SCHEME
|
|
||||||
if ($http) $urlregex .= "^(http:\/\/|https:\/\/)";
|
|
||||||
|
|
||||||
// USER AND PASS
|
|
||||||
if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)";
|
|
||||||
|
|
||||||
// HOSTNAME OR IP
|
|
||||||
//$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // http://x = allowed (ex. http://localhost, http://routerlogin)
|
|
||||||
//$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)+"; // http://x.x = minimum
|
|
||||||
$urlregex .= "([a-z0-9+\$_-]+\.)*[a-z0-9+\$_-]{2,3}"; // http://x.xx(x) = minimum
|
|
||||||
//use only one of the above
|
|
||||||
|
|
||||||
// PORT
|
|
||||||
if ($port) $urlregex .= "(\:[0-9]{2,5})";
|
|
||||||
// PATH
|
|
||||||
if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/";
|
|
||||||
// GET Query
|
|
||||||
if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)";
|
|
||||||
// ANCHOR
|
|
||||||
if($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)\$";
|
|
||||||
|
|
||||||
// check
|
|
||||||
if (eregi($urlregex, $url))
|
|
||||||
{
|
|
||||||
$ValidUrl = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ValidUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Clean a string from all HTML tags and entities
|
* \brief Clean a string from all HTML tags and entities
|
||||||
* \param StringHtml String to clean
|
* \param StringHtml String to clean
|
||||||
|
|||||||
@ -155,6 +155,93 @@ function isValidMailDomain($mail)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Url string validation
|
||||||
|
* \remarks <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor]
|
||||||
|
* \param url Url
|
||||||
|
* \param http 1: verify http, 0: not verify http
|
||||||
|
* \param pass 1: verify user and pass, 0: not verify user and pass
|
||||||
|
* \param port 1: verify port, 0: not verify port
|
||||||
|
* \param path 1: verify path, 0: not verify path
|
||||||
|
* \param query 1: verify query, 0: not verify query
|
||||||
|
* \param anchor 1: verify anchor, 0: not verify anchor
|
||||||
|
* \return int 1=Check is OK, 0=Check is KO
|
||||||
|
*/
|
||||||
|
function isValidUrl($url,$http=0,$pass=0,$port=0,$path=0,$query=0,$anchor=0)
|
||||||
|
{
|
||||||
|
$ValidUrl = 0;
|
||||||
|
$urlregex = '';
|
||||||
|
|
||||||
|
// SCHEME
|
||||||
|
if ($http) $urlregex .= "^(http:\/\/|https:\/\/)";
|
||||||
|
|
||||||
|
// USER AND PASS
|
||||||
|
if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)";
|
||||||
|
|
||||||
|
// HOSTNAME OR IP
|
||||||
|
//$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // http://x = allowed (ex. http://localhost, http://routerlogin)
|
||||||
|
//$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)+"; // http://x.x = minimum
|
||||||
|
$urlregex .= "([a-z0-9+\$_-]+\.)*[a-z0-9+\$_-]{2,3}"; // http://x.xx(x) = minimum
|
||||||
|
//use only one of the above
|
||||||
|
|
||||||
|
// PORT
|
||||||
|
if ($port) $urlregex .= "(\:[0-9]{2,5})";
|
||||||
|
// PATH
|
||||||
|
if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/";
|
||||||
|
// GET Query
|
||||||
|
if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)";
|
||||||
|
// ANCHOR
|
||||||
|
if($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)\$";
|
||||||
|
|
||||||
|
// check
|
||||||
|
if (eregi($urlregex, $url))
|
||||||
|
{
|
||||||
|
$ValidUrl = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ValidUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Clean an url string
|
||||||
|
* \param url Url
|
||||||
|
* \param http 1: keep http://, 0: remove also http://
|
||||||
|
* \return string Cleaned url
|
||||||
|
*/
|
||||||
|
function clean_url($url,$http=1)
|
||||||
|
{
|
||||||
|
// Fixed by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-cleaning-url.html)
|
||||||
|
// To include the minus sign in a char class, we must not escape it but put it at the end of the class
|
||||||
|
// Also, there's no need of escape a dot sign in a class
|
||||||
|
if (eregi('^(https?:[\\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?',$url,$regs))
|
||||||
|
{
|
||||||
|
$proto=$regs[1];
|
||||||
|
$domain=$regs[2];
|
||||||
|
$port=$regs[3];
|
||||||
|
//print $url." -> ".$proto." - ".$domain." - ".$port;
|
||||||
|
//$url = dol_string_nospecial(trim($url));
|
||||||
|
$url = trim($url);
|
||||||
|
|
||||||
|
// Si http: defini on supprime le http (Si https on ne supprime pas)
|
||||||
|
$newproto=$proto;
|
||||||
|
if ($http==0)
|
||||||
|
{
|
||||||
|
if (eregi('^http:[\\\/]+',$url))
|
||||||
|
{
|
||||||
|
$url = eregi_replace('^http:[\\\/]+','',$url);
|
||||||
|
$newproto = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On passe le nom de domaine en minuscule
|
||||||
|
$CleanUrl = eregi_replace('^'.$proto.$domain, $newproto.strtolower($domain), $url);
|
||||||
|
|
||||||
|
return $CleanUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return lines of an html table from an array
|
* \brief Return lines of an html table from an array
|
||||||
* \remarks Used by array2table function only
|
* \remarks Used by array2table function only
|
||||||
|
|||||||
@ -227,8 +227,8 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Verification lors de la modification
|
* \brief Check properties of third party are ok
|
||||||
* \return int 0 si OK, <0 si KO
|
* \return int 0 if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
function verify()
|
function verify()
|
||||||
{
|
{
|
||||||
@ -242,6 +242,7 @@ class Societe extends CommonObject
|
|||||||
$this->errors[] = 'ErrorBadThirdPartyName';
|
$this->errors[] = 'ErrorBadThirdPartyName';
|
||||||
$result = -2;
|
$result = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->client && $this->codeclient_modifiable())
|
if ($this->client && $this->codeclient_modifiable())
|
||||||
{
|
{
|
||||||
// On ne verifie le code client que si la societe est un client / prospect et que le code est modifiable
|
// On ne verifie le code client que si la societe est un client / prospect et que le code est modifiable
|
||||||
@ -268,6 +269,7 @@ class Societe extends CommonObject
|
|||||||
$result = -3;
|
$result = -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->fournisseur && $this->codefournisseur_modifiable())
|
if ($this->fournisseur && $this->codefournisseur_modifiable())
|
||||||
{
|
{
|
||||||
// On ne verifie le code fournisseur que si la societe est un fournisseur et que le code est modifiable
|
// On ne verifie le code fournisseur que si la societe est un fournisseur et que le code est modifiable
|
||||||
@ -294,11 +296,6 @@ class Societe extends CommonObject
|
|||||||
$result = -3;
|
$result = -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (valid_url($this->url) == 0)
|
|
||||||
{
|
|
||||||
$this->errors[] = 'ErrorUrlNotValid';
|
|
||||||
$result = -4;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -314,6 +311,8 @@ class Societe extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0)
|
function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0)
|
||||||
{
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
|
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
dol_syslog("Societe::Update id=".$id." call_trigger=".$call_triger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
|
dol_syslog("Societe::Update id=".$id." call_trigger=".$call_triger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user