From d5ccb222e89b3090c405bc8d8e5382f3505aab66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Apr 2008 18:13:45 +0000 Subject: [PATCH] Reorganize functions --- htdocs/adherents/adherent.class.php | 2 + htdocs/adherents/fiche.php | 2 +- htdocs/adherents/htpasswd.php | 8 +- htdocs/admin/company.php | 2 +- htdocs/admin/import/import.php | 2 +- htdocs/admin/security.php | 1 + htdocs/comm/action/document.php | 2 +- htdocs/comm/propal/document.php | 2 +- htdocs/commande/document.php | 2 +- htdocs/compta/facture/document.php | 2 +- htdocs/compta/prelevement/fiche.php | 2 +- htdocs/contrat/document.php | 2 +- htdocs/ecm/docmine.php | 2 +- htdocs/ecm/docother.php | 2 +- htdocs/fichinter/fiche.php | 3 +- htdocs/fichinter/index.php | 1 + htdocs/fourn/facture/document.php | 2 +- htdocs/html.form.class.php | 2 + htdocs/lib/date.lib.php | 31 +++++ htdocs/lib/functions.lib.php | 111 +----------------- htdocs/lib/security.lib.php | 108 +++++++++++++++++ htdocs/main.inc.php | 19 +-- htdocs/master.inc.php | 8 +- htdocs/product.class.php | 2 +- htdocs/product/document.php | 2 +- htdocs/product/photos.php | 2 +- htdocs/societe/docsoc.php | 2 +- htdocs/telephonie/facturation/index.php | 2 +- .../ligne/commande/retour/index.php | 2 +- htdocs/user/fiche.php | 2 +- 30 files changed, 182 insertions(+), 150 deletions(-) create mode 100644 htdocs/lib/security.lib.php diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 3c5e061b207..6b7cee5d1c4 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -1386,6 +1386,8 @@ class Adherent extends CommonObject */ function add_to_spip() { + require_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php'); + dolibarr_syslog("Adherent::add_to_spip"); if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index c2a5f321076..c66bbd70aeb 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -176,7 +176,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"]) if (is_dir($conf->adherent->dir_output)) { $newfile=$conf->adherent->dir_output . "/" . $adh->id . ".jpg"; - if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile)) + if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile)) { $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; } diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index 12d305106e3..bce0259a805 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2006-2008 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,9 +16,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** @@ -26,10 +23,11 @@ \ingroup adherent \brief Page d'export htpasswd du fichier des adherents \author Rodolphe Quiedeville - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php'); llxHeader(); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 43793883069..81c60e8bac4 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -65,7 +65,7 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update') { create_exdir($conf->societe->dir_logos); } - if (doliMoveFileUpload($_FILES["logo"]["tmp_name"],$conf->societe->dir_logos.'/'.$original_file)) + if (dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->societe->dir_logos.'/'.$original_file)) { dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file); diff --git a/htdocs/admin/import/import.php b/htdocs/admin/import/import.php index 438504dff34..4612476606c 100644 --- a/htdocs/admin/import/import.php +++ b/htdocs/admin/import/import.php @@ -65,7 +65,7 @@ if ( $_POST["sendit"] && $conf->upload != 0) { $imp = new DolibarrImport($db); $imp->CreateBackupDir(); - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $imp->upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $imp->upload_dir . "/" . $_FILES['userfile']['name'])) { $imp->ImportClients($imp->upload_dir . "/" . $_FILES['userfile']['name']); diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 1fb86f8ebc5..a9dc0858539 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -26,6 +26,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php'); $langs->load("users"); $langs->load("admin"); diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 6bbe7cfa2ba..2702b7a913e 100755 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -64,7 +64,7 @@ if ( $_POST["sendit"] && $conf->upload ) if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; //print_r($_FILES); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index bf9bdc0887c..b2671ebce86 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -59,7 +59,7 @@ if ($_POST["sendit"] && $conf->upload) if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; //print_r($_FILES); diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index d6fbf966172..ae69461ff9f 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -66,7 +66,7 @@ if ($_POST["sendit"] && $conf->upload) if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; //print_r($_FILES); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index d2f6ffec3a8..8fdfc55d010 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -60,7 +60,7 @@ if ($_POST["sendit"] && $conf->upload) if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; //print_r($_FILES); diff --git a/htdocs/compta/prelevement/fiche.php b/htdocs/compta/prelevement/fiche.php index ecddd5cdc6f..5d877d08344 100644 --- a/htdocs/compta/prelevement/fiche.php +++ b/htdocs/compta/prelevement/fiche.php @@ -57,7 +57,7 @@ if ($_POST["action"] == 'infotrans') { $dir = $conf->prelevement->dir_output.'/bon/'; - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . $_FILES['userfile']['name'])) { $dt = mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 2d82b91fcb1..9b189bba14c 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -59,7 +59,7 @@ if ($_POST["sendit"] && $conf->upload) if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; //print_r($_FILES); diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php index a454af32b8b..e4da3398f9e 100644 --- a/htdocs/ecm/docmine.php +++ b/htdocs/ecm/docmine.php @@ -80,7 +80,7 @@ if ( $_POST["sendit"] && $conf->upload != 0) if (is_dir($upload_dir)) { - $result = doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']); + $result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']); if ($result == 1) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; diff --git a/htdocs/ecm/docother.php b/htdocs/ecm/docother.php index 8e3ddb466fc..84369f434d4 100644 --- a/htdocs/ecm/docother.php +++ b/htdocs/ecm/docother.php @@ -50,7 +50,7 @@ if ( $_POST["sendit"] && $conf->upload != 0) if (is_dir($upload_dir)) { - $result = doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']); + $result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']); if ($result == 1) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 676f1b2d0b4..68bc803164e 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -30,6 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); if ($conf->projet->enabled) { require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); @@ -601,7 +602,7 @@ elseif ($_GET["id"] > 0) print ''; } - // Dur�e + // Duration print ''.$langs->trans("TotalDuration").''.ConvertSecondToTime($fichinter->duree).''; // Description diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 6a2709fcc2c..3095b9c49c9 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -28,6 +28,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); $langs->load("companies"); $langs->load("interventions"); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 07c14ddfe85..c6d7beff3eb 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -61,7 +61,7 @@ if ($_POST['sendit'] && $conf->upload) if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . '/' . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . '/' . $_FILES['userfile']['name'])) { $mesg = '
'.$langs->trans('FileTransferComplete').'
'; //print_r($_FILES); diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 6947aa326a3..2ef2bb4d564 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -2694,6 +2694,8 @@ class Form { if ($iSecond) { + require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); + $hourSelected = ConvertSecondToTime($iSecond,'hour'); $minSelected = ConvertSecondToTime($iSecond,'min'); } diff --git a/htdocs/lib/date.lib.php b/htdocs/lib/date.lib.php index 08d072bd9c0..d735b305d95 100644 --- a/htdocs/lib/date.lib.php +++ b/htdocs/lib/date.lib.php @@ -24,6 +24,37 @@ */ +/** \brief Converti les heures et minutes en secondes + * \param iHours Heures + * \param iMinutes Minutes + * \param iSeconds Secondes + * \return iResult Temps en secondes + */ +function ConvertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0) +{ + $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; + return $iResult; +} + + +/** \brief Converti les secondes en heures et minutes + * \param iSecond Nombre de secondes + * \param format Choix de l'affichage (all:affichage complet, hour: n'affiche que les heures, min: n'affiche que les minutes) + * \return sTime Temps formaté + */ +function ConvertSecondToTime($iSecond,$format='all'){ + if ($format == 'all'){ + $sTime=date("H",$iSecond)-1; + $sTime.='h'.date("i",$iSecond); + }else if ($format == 'hour'){ + $sTime=date("H",$iSecond)-1; + }else if ($format == 'min'){ + $sTime=date("i",$iSecond); + } + return $sTime; +} + + /** \brief Return previous month * \param month Month * \param year Year diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 0cdb0fc81f5..efc299a4a22 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -1484,7 +1484,7 @@ function dolibarr_print_error($db='',$error='') \param dest_file fichier de destination \return int true=Deplacement OK, false=Pas de deplacement ou KO */ -function doliMoveFileUpload($src_file, $dest_file) +function dol_move_uploaded_file($src_file, $dest_file) { global $conf; @@ -2068,33 +2068,6 @@ function yn($yesno, $case=1, $color=0) } -/** - \brief Fonction pour initialiser un salt pour la fonction crypt - \param $type 2=>renvoi un salt pour cryptage DES - 12=>renvoi un salt pour cryptage MD5 - non defini=>renvoi un salt pour cryptage par defaut - \return string Chaine salt -*/ -function makesalt($type=CRYPT_SALT_LENGTH) -{ - dolibarr_syslog("functions.inc::makesalt type=".$type); - switch($type) - { - case 12: // 8 + 4 - $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; - case 8: // 8 + 4 (Pour compatibilite, ne devrait pas etre utilisé) - $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; - case 2: // 2 - default: // by default, fall back on Standard DES (should work everywhere) - $saltlen=2; $saltprefix=''; $saltsuffix=''; break; - } - $salt=''; - while(strlen($salt) < $saltlen) $salt.=chr(rand(64,126)); - - $result=$saltprefix.$salt.$saltsuffix; - dolibarr_syslog("functions.inc::makesalt return=".$result); - return $result; -} /** \brief Fonction pour qui retourne le rowid d'un departement par son code \param db handler d'accés base @@ -2587,57 +2560,6 @@ function dol_htmlentitiesbr_decode($stringtodecode) return $ret; } -/** - \brief Encode\decode le mot de passe de la base de données dans le fichier de conf - \param level niveau d'encodage : 0 non encodé, 1 encodé -*/ -function encodedecode_dbpassconf($level=0) -{ - $config = ''; - - if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','r')) - { - while(!feof($fp)) - { - $buffer = fgets($fp,4096); - - if (strstr($buffer,"\$dolibarr_main_db_encrypted_pass") && $level == 0) - { - $passwd = strstr($buffer,"$dolibarr_main_db_encrypted_pass="); - $passwd = substr(substr($passwd,2),0,-3); - $passwd = dolibarr_decode($passwd); - $config .= "\$dolibarr_main_db_pass=\"$passwd\";\n"; - } - else if (strstr($buffer,"\$dolibarr_main_db_pass") && $level == 1) - { - $passwd = strstr($buffer,"$dolibarr_main_db_pass="); - $passwd = substr(substr($passwd,2),0,-3); - $passwd = dolibarr_encode($passwd); - $config .= "\$dolibarr_main_db_encrypted_pass=\"$passwd\";\n"; - } - else - { - $config .= $buffer; - } - } - fclose($fp); - - if ($fp = @fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','w')) - { - fputs($fp, $config, strlen($config)); - fclose($fp); - return 1; - } - else - { - return -1; - } - } - else - { - return -2; - } -} /** \brief Encode une chaine de caractére @@ -2918,37 +2840,6 @@ function print_date_range($date_start,$date_end) } -/* - * \brief Converti les heures et minutes en secondes - * \param iHours Heures - * \param iMinutes Minutes - * \param iSeconds Secondes - * \return iResult Temps en secondes - */ -function ConvertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0) -{ - $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; - return $iResult; -} - -/* - * \brief Converti les secondes en heures et minutes - * \param iSecond Nombre de secondes - * \param format Choix de l'affichage (all:affichage complet, hour: n'affiche que les heures, min: n'affiche que les minutes) - * \return sTime Temps formaté - */ -function ConvertSecondToTime($iSecond,$format='all'){ - if ($format == 'all'){ - $sTime=date("H",$iSecond)-1; - $sTime.='h'.date("i",$iSecond); - }else if ($format == 'hour'){ - $sTime=date("H",$iSecond)-1; - }else if ($format == 'min'){ - $sTime=date("i",$iSecond); - } - return $sTime; -} - /* * */ diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php new file mode 100644 index 00000000000..3c66bd4d29d --- /dev/null +++ b/htdocs/lib/security.lib.php @@ -0,0 +1,108 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * or see http://www.gnu.org/ + */ + +/** + \file htdocs/lib/security.lib.php + \brief Ensemble de fonctions de securite de dolibarr sous forme de lib + \version $Id$ +*/ + + +/** + \brief Fonction pour initialiser un salt pour la fonction crypt + \param $type 2=>renvoi un salt pour cryptage DES + 12=>renvoi un salt pour cryptage MD5 + non defini=>renvoi un salt pour cryptage par defaut + \return string Chaine salt +*/ +function makesalt($type=CRYPT_SALT_LENGTH) +{ + dolibarr_syslog("security.lib.php::makesalt type=".$type); + switch($type) + { + case 12: // 8 + 4 + $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; + case 8: // 8 + 4 (Pour compatibilite, ne devrait pas etre utilisé) + $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; + case 2: // 2 + default: // by default, fall back on Standard DES (should work everywhere) + $saltlen=2; $saltprefix=''; $saltsuffix=''; break; + } + $salt=''; + while(strlen($salt) < $saltlen) $salt.=chr(rand(64,126)); + + $result=$saltprefix.$salt.$saltsuffix; + dolibarr_syslog("security.lib.php::makesalt return=".$result); + return $result; +} + +/** + \brief Encode\decode le mot de passe de la base de données dans le fichier de conf + \param level niveau d'encodage : 0 non encodé, 1 encodé +*/ +function encodedecode_dbpassconf($level=0) +{ + $config = ''; + + if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','r')) + { + while(!feof($fp)) + { + $buffer = fgets($fp,4096); + + if (strstr($buffer,"\$dolibarr_main_db_encrypted_pass") && $level == 0) + { + $passwd = strstr($buffer,"$dolibarr_main_db_encrypted_pass="); + $passwd = substr(substr($passwd,2),0,-3); + $passwd = dolibarr_decode($passwd); + $config .= "\$dolibarr_main_db_pass=\"$passwd\";\n"; + } + else if (strstr($buffer,"\$dolibarr_main_db_pass") && $level == 1) + { + $passwd = strstr($buffer,"$dolibarr_main_db_pass="); + $passwd = substr(substr($passwd,2),0,-3); + $passwd = dolibarr_encode($passwd); + $config .= "\$dolibarr_main_db_encrypted_pass=\"$passwd\";\n"; + } + else + { + $config .= $buffer; + } + } + fclose($fp); + + if ($fp = @fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','w')) + { + fputs($fp, $config, strlen($config)); + fclose($fp); + return 1; + } + else + { + return -1; + } + } + else + { + return -2; + } +} + + +?> \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 27a7e768fbe..2c886e701bc 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -87,7 +87,7 @@ foreach ($_POST as $key => $val) // This is to make Dolibarr working with Plesk set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); - +// Set and init common variables require_once("master.inc.php"); // Check if HTTPS @@ -111,8 +111,9 @@ if ($conf->main_force_https) } // Chargement des includes complementaire de presentation -if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php"); // Need 11ko memory -if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php"); // Need 800ko memory + +if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php"); // Need 11ko memory (11ko in 2.2) +if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php"); // Need 690ko memory (800ko in 2.2) if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_DOCUMENT_ROOT.'/lib/ajax.lib.php'); // Need 20ko memory //stopwithmem(); @@ -436,11 +437,8 @@ if ($user->statut < 1) dolibarr_syslog("Access to ".$_SERVER["PHP_SELF"],LOG_INFO); - -if (! defined('MAIN_INFO_SOCIETE_PAYS')) -{ - define('MAIN_INFO_SOCIETE_PAYS','1'); -} +// For backward compatibility +if (! defined('MAIN_INFO_SOCIETE_PAYS')) define('MAIN_INFO_SOCIETE_PAYS','1'); // If install not finished, we start again. if (defined("MAIN_NOT_INSTALLED")) @@ -458,8 +456,11 @@ $langs->load("dict"); // On charge les fichiers lang principaux $user->getrights(); +// Define some constants used for style of arrays +$bc[0]="class=\"impair\""; +$bc[1]="class=\"pair\""; -// Constantes utilise pour definir le nombre de lignes des textarea +// Constantes utilisees pour definir le nombre de lignes des textarea if (! eregi("firefox",$_SERVER["HTTP_USER_AGENT"])) { define('ROWS_1',1); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index f73ba293162..9a4a16cda15 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -109,9 +109,9 @@ if (! file_exists(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php")) */ // on décode le mot de passe de la base si besoin -require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); // Need 1.1 Mo memory +require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); // Need 970ko memory (1.1 in 2.2) if (! empty($dolibarr_main_db_encrypted_pass)) $dolibarr_main_db_pass = dolibarr_decode($dolibarr_main_db_encrypted_pass); -//stopwithmem(); +//print memory_get_usage(); require_once(DOL_DOCUMENT_ROOT."/conf/conf.class.php"); @@ -291,10 +291,6 @@ if (! defined('NOREQUIRESOC')) $yesno[0]="no"; $yesno[1]="yes"; -// Sert pour styles lignes tableaux -$bc[0]="class=\"impair\""; -$bc[1]="class=\"pair\""; - if ( ! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR'); ?> diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 3132ea7fd17..83fa3b26492 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -2228,7 +2228,7 @@ class Product extends CommonObject $originImage = $dir . $file['name']; // Cree fichier en taille origine - doliMoveFileUpload($file['tmp_name'], $originImage); + dol_move_uploaded_file($file['tmp_name'], $originImage); if (file_exists($originImage)) { diff --git a/htdocs/product/document.php b/htdocs/product/document.php index c0da709e9fb..ef5c6b98f40 100755 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -64,7 +64,7 @@ if ($_POST["sendit"] && $conf->upload) if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; //print_r($_FILES); diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index f001995f46b..d5b9fcf8869 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -53,7 +53,7 @@ if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && $conf->upload != 0) $product = new Product($db); $result = $product->fetch($_GET["id"]); - // if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + // if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) // var_dump($_FILES); diff --git a/htdocs/societe/docsoc.php b/htdocs/societe/docsoc.php index eb7ac80e7f6..7e42d827cea 100644 --- a/htdocs/societe/docsoc.php +++ b/htdocs/societe/docsoc.php @@ -57,7 +57,7 @@ if ( $_POST["sendit"] && $conf->upload != 0) if (is_dir($upload_dir)) { - $result = doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']); + $result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']); if ($result == 1) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; diff --git a/htdocs/telephonie/facturation/index.php b/htdocs/telephonie/facturation/index.php index 0e9d7222d72..a74a07e4092 100644 --- a/htdocs/telephonie/facturation/index.php +++ b/htdocs/telephonie/facturation/index.php @@ -35,7 +35,7 @@ if ( $_POST["sendit"] && $conf->upload != 0) if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { $mesg = "Le fichier est valide, et a été téléchargé avec succès.\n"; } diff --git a/htdocs/telephonie/ligne/commande/retour/index.php b/htdocs/telephonie/ligne/commande/retour/index.php index 1d03777ce86..5381783f801 100644 --- a/htdocs/telephonie/ligne/commande/retour/index.php +++ b/htdocs/telephonie/ligne/commande/retour/index.php @@ -42,7 +42,7 @@ if ( $_POST["sendit"] && $conf->upload != 0) $nextname = $upload_dir .'/backup'; - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { $mesg = "Le fichier est valide, et a été téléchargé avec succès.\n"; } diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index ed796e44255..69bc3536ca9 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -276,7 +276,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $caneditfield) if (is_dir($conf->users->dir_output)) { $newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg"; - if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile)) + if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile)) { $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; }