Reorganize code to reduce memory usage

This commit is contained in:
Laurent Destailleur 2009-02-19 18:57:54 +00:00
parent 52c0edeaca
commit d433c7120f
7 changed files with 61 additions and 64 deletions

View File

@ -34,6 +34,7 @@
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
/** /**

View File

@ -28,6 +28,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php");

View File

@ -25,6 +25,7 @@
*/ */
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php'; include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
/** /**

View File

@ -36,45 +36,6 @@ if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..');
if (! defined('ADODB_DATE_VERSION')) include_once(DOL_DOCUMENT_ROOT."/includes/adodbtime/adodb-time.inc.php"); if (! defined('ADODB_DATE_VERSION')) include_once(DOL_DOCUMENT_ROOT."/includes/adodbtime/adodb-time.inc.php");
/**
* \brief Return true if email syntax is ok
* \param address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* \return boolean true if email ok, false if ko
*/
function ValidEmail($address)
{
if (eregi(".*<(.+)>", $address, $regs)) {
$address = $regs[1];
}
if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|asso|aero|biz|com|coop|edu|gov|info|int|mil|name|net|org|pro)\$",$address))
{
return true;
}
else
{
return false;
}
}
/**
* \brief Renvoi vrai si l'email a un nom de domaine qui r<EFBFBD>soud via dns
* \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* \return boolean true si email valide, false sinon
*/
function check_mail($mail)
{
list($user, $domain) = split("@", $mail, 2);
if (checkdnsrr($domain, "MX"))
{
return true;
}
else
{
return false;
}
}
/** /**
* \brief Clean a string to use it as a file name. * \brief Clean a string to use it as a file name.
* \param str String to clean * \param str String to clean
@ -739,8 +700,6 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64)
if (empty($email)) return '&nbsp;'; if (empty($email)) return '&nbsp;';
if (! ValidEmail($email)) return "Bad email";
if (! empty($addlink)) if (! empty($addlink))
{ {
$newemail='<a href="'; $newemail='<a href="';

View File

@ -26,6 +26,44 @@
*/ */
/**
* \brief Return true if email syntax is ok
* \param address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* \return boolean true if email ok, false if ko
*/
function ValidEmail($address)
{
if (eregi(".*<(.+)>", $address, $regs)) {
$address = $regs[1];
}
if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|asso|aero|biz|com|coop|edu|gov|info|int|mil|name|net|org|pro)\$",$address))
{
return true;
}
else
{
return false;
}
}
/**
* \brief Renvoi vrai si l'email a un nom de domaine qui r<EFBFBD>soud via dns
* \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* \return boolean true si email valide, false sinon
*/
function CheckMailDomain($mail)
{
list($user, $domain) = split("@", $mail, 2);
if (checkdnsrr($domain, "MX"))
{
return true;
}
else
{
return false;
}
}
/** /**
* \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

View File

@ -28,6 +28,7 @@
require("../../master.inc.php"); require("../../master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/paybox/paybox.lib.php"); require_once(DOL_DOCUMENT_ROOT."/paybox/paybox.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]); $langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]);

View File

@ -17,28 +17,24 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/ */
/** /**
\file htdocs/telephonie/client/new.php \file htdocs/telephonie/client/new.php
\ingroup telephonie \ingroup telephonie
\brief Creation d'un nouveau client \brief Creation d'un nouveau client
\version $Revision$ \version $Id$
*/ */
require("pre.inc.php"); require("pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
if (!$user->rights->telephonie->ligne->creer) accessforbidden();
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
require_once(DOL_DOCUMENT_ROOT.'/companybankaccount.class.php'); require_once(DOL_DOCUMENT_ROOT.'/companybankaccount.class.php');
require_once(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); require_once(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
require_once(DOL_DOCUMENT_ROOT."/telephonie/telephonie.contrat.class.php"); require_once(DOL_DOCUMENT_ROOT."/telephonie/telephonie.contrat.class.php");
if (!$user->rights->telephonie->ligne->creer) accessforbidden();
$user->getrights('societe'); $user->getrights('societe');
$langs->load("companies"); $langs->load("companies");
@ -143,7 +139,7 @@ if ($_POST["action"] == 'add')
$verif = "nok"; $verif = "nok";
} }
if (!check_mail(trim($contact->email)) && $verif == 'ok') if (!CheckMailDomain(trim($contact->email)) && $verif == 'ok')
{ {
$mesg = "Email invalide (domaine invalide)"; $mesg = "Email invalide (domaine invalide)";
$verif = "nok"; $verif = "nok";