From aeb1488a56bd16e1d19f05de608c0e7413a9e770 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 15 Dec 2008 20:55:44 +0000 Subject: [PATCH] Reduce memory usage --- htdocs/lib/security.lib.php | 182 ++++++++++++++++++++++++++++++++++- htdocs/main.inc.php | 183 +----------------------------------- 2 files changed, 183 insertions(+), 182 deletions(-) diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php index 1aa02eafa6e..54254455501 100644 --- a/htdocs/lib/security.lib.php +++ b/htdocs/lib/security.lib.php @@ -19,11 +19,191 @@ /** * \file htdocs/lib/security.lib.php - * \brief Ensemble de fonctions de securite de dolibarr sous forme de lib + * \brief Set of function used for dolibarr security * \version $Id$ */ +/** + * \brief Show Dolibarr default login page + * \param langs Lang object + * \param conf Conf object + * \param mysoc Company object + * \remarks You must change HTML code in this page to change design of logon page. + */ +function dol_loginfunction($langs,$conf,$mysoc) +{ + $langs->load("main"); + $langs->load("other"); + + $conf->css = "theme/".$conf->theme."/".$conf->theme.".css"; + // Si feuille de style en php existe + if (file_exists(DOL_DOCUMENT_ROOT.'/'.$conf->css.".php")) $conf->css.=".php"; + + header('Cache-Control: Public, must-revalidate'); + + if (! empty($_REQUEST["urlfrom"])) $_SESSION["urlfrom"]=$_REQUEST["urlfrom"]; + else unset($_SESSION["urlfrom"]); + + // Ce DTD est KO car inhibe document.body.scrollTop + //print ''; + // Ce DTD est OK + print ''."\n"; + + // En tete html + print "\n"; + print "\n"; + print ''."\n"; // Evite indexation par robots + print "".$langs->trans("Login")."\n"; + + print ''."\n"; + + print ''."\n"; + print ''."\n"; + print ''."\n"; + + // Body + print ''; + + // Start Form + print '
'; + + // Table 1 + print ''; + $title='Dolibarr '.DOL_VERSION; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; + print ''; + print '
'.$title.'
'; + print '
'; + + // Table 2 + print ''; + + print ''; + + print ''; + + // Login field + print ''; + print ''; + + $title=$langs->trans("SessionName").': '.session_name(); + if ($conf->main_authentication) $title.=", ".$langs->trans("AuthenticationMode").': '.$conf->main_authentication; + + // Show logo (search in order: small company logo, large company logo, theme logo, common logo) + $width=0; + $urllogo=DOL_URL_ROOT.'/theme/login_logo.png'; + if (! empty($mysoc->logo_small) && is_readable($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_small)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode('thumbs/'.$mysoc->logo_small); + } + elseif (! empty($mysoc->logo_small) && is_readable($conf->societe->dir_logos.'/'.$mysoc->logo)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode($mysoc->logo); + $width=96; + } + elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png')) + { + $urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png'; + } + print ''; + print ''."\n"; + + // Password field + print ''; + print ''; + + print ''."\n"; + + // Security graphical code + $disabled=! $conf->global->MAIN_SECURITY_ENABLECAPTCHA; + if (function_exists("imagecreatefrompng") && ! $disabled) + { + //print "Info session: ".session_name().session_id();print_r($_SESSION); + print ''; + print ''; + print ''; + } + + print ''; + + if (! $conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) + { + print ''; + } + + print '
 
  '.$langs->trans("Login").'  
  '.$langs->trans("Password").'   '; + print '
 
  '.$langs->trans("SecurityCode").''; + + print ''; + print ''; + print ''; + print ''; + print '
'.img_refresh().'
'; + + print '

'; + print ''; + print '
('.$langs->trans("PasswordForgotten").')
'; + + // Hidden fields + print ''; + + print '
'; + + // Message + if ($_SESSION["dol_loginmesg"]) + { + print '
'; + print $_SESSION["dol_loginmesg"]; + $_SESSION["dol_loginmesg"]=""; + print '
'; + } + if ($conf->global->MAIN_HOME) + { + print '
'; + print nl2br($conf->global->MAIN_HOME); + print '

'; + } + + print "\n"; + print ''; + + // Fin entete html + print "\n\n"; +} + + /** * \brief Fonction pour initialiser un salt pour la fonction crypt * \param $type 2=>renvoi un salt pour cryptage DES diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 25d6380d621..939722df623 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -283,6 +283,7 @@ if (! isset($_SESSION["dol_login"])) if (! $login) { // We show login page + include_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php"); dol_loginfunction($langs,$conf,$mysoc); exit; } @@ -565,7 +566,7 @@ if (defined("MAIN_NOT_INSTALLED")) $langs->load("main"); $langs->load("dict"); -// On charge les fichiers lang principaux +// Load permissions $user->getrights(); // Define some constants used for style of arrays @@ -599,186 +600,6 @@ else } -/** - * \brief Show Dolibarr default login page - * \param langs Lang object - * \param conf Conf object - * \param mysoc Company object - * \remarks You must change HTML code in this page to change design of logon page. - */ -function dol_loginfunction($langs,$conf,$mysoc) -{ - $langs->load("main"); - $langs->load("other"); - - $conf->css = "theme/".$conf->theme."/".$conf->theme.".css"; - // Si feuille de style en php existe - if (file_exists(DOL_DOCUMENT_ROOT.'/'.$conf->css.".php")) $conf->css.=".php"; - - header('Cache-Control: Public, must-revalidate'); - - if (! empty($_REQUEST["urlfrom"])) $_SESSION["urlfrom"]=$_REQUEST["urlfrom"]; - else unset($_SESSION["urlfrom"]); - - // Ce DTD est KO car inhibe document.body.scrollTop - //print ''; - // Ce DTD est OK - print ''."\n"; - - // En tete html - print "\n"; - print "\n"; - print ''."\n"; // Evite indexation par robots - print "".$langs->trans("Login")."\n"; - - print ''."\n"; - - print ''."\n"; - print ''."\n"; - print ''."\n"; - - // Body - print ''; - - // Start Form - print '
'; - - // Table 1 - print ''; - $title='Dolibarr '.DOL_VERSION; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; - print ''; - print '
'.$title.'
'; - print '
'; - - // Table 2 - print ''; - - print ''; - - print ''; - - // Login field - print ''; - print ''; - - $title=$langs->trans("SessionName").': '.session_name(); - if ($conf->main_authentication) $title.=", ".$langs->trans("AuthenticationMode").': '.$conf->main_authentication; - - // Show logo (search in order: small company logo, large company logo, theme logo, common logo) - $width=0; - $urllogo=DOL_URL_ROOT.'/theme/login_logo.png'; - if (! empty($mysoc->logo_small) && is_readable($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_small)) - { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode('thumbs/'.$mysoc->logo_small); - } - elseif (! empty($mysoc->logo_small) && is_readable($conf->societe->dir_logos.'/'.$mysoc->logo)) - { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&file='.urlencode($mysoc->logo); - $width=96; - } - elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png')) - { - $urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png'; - } - print ''; - print ''."\n"; - - // Password field - print ''; - print ''; - - print ''."\n"; - - // Security graphical code - $disabled=! $conf->global->MAIN_SECURITY_ENABLECAPTCHA; - if (function_exists("imagecreatefrompng") && ! $disabled) - { - //print "Info session: ".session_name().session_id();print_r($_SESSION); - print ''; - print ''; - print ''; - } - - print ''; - - if (! $conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) - { - print ''; - } - - print '
 
  '.$langs->trans("Login").'  
  '.$langs->trans("Password").'   '; - print '
 
  '.$langs->trans("SecurityCode").''; - - print ''; - print ''; - print ''; - print ''; - print '
'.img_refresh().'
'; - - print '

'; - print ''; - print '
('.$langs->trans("PasswordForgotten").')
'; - - // Hidden fields - print ''; - - print '
'; - - // Message - if ($_SESSION["dol_loginmesg"]) - { - print '
'; - print $_SESSION["dol_loginmesg"]; - $_SESSION["dol_loginmesg"]=""; - print '
'; - } - if ($conf->global->MAIN_HOME) - { - print '
'; - print nl2br($conf->global->MAIN_HOME); - print '

'; - } - - print "\n"; - print ''; - - // Fin entete html - print "\n\n"; -} - - /** * \brief Show HTML header * \param head Optionnal head lines