From e83b22b29b96436e2823732289128fa14a77bd69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Feb 2009 20:28:16 +0000 Subject: [PATCH] Added XDebug tools --- htdocs/admin/system/pre.inc.php | 23 +++--- htdocs/admin/system/xdebug.php | 71 ++++++++++++++++++ htdocs/admin/tools/eaccelerator.php | 27 +++---- htdocs/comm/mailing/index.php | 3 +- htdocs/conf/conf.class.php | 34 ++++----- .../menus/barre_left/eldy_backoffice.php | 1 + .../menus/barre_left/eldy_frontoffice.php | 1 + htdocs/install/licence.php | 5 +- htdocs/lib/functions.lib.php | 32 ++++---- htdocs/lib/functions2.lib.php | 74 +++++++++++++++---- htdocs/main.inc.php | 30 ++++---- htdocs/master.inc.php | 4 +- htdocs/translate.class.php | 64 ++-------------- 13 files changed, 222 insertions(+), 147 deletions(-) create mode 100644 htdocs/admin/system/xdebug.php diff --git a/htdocs/admin/system/pre.inc.php b/htdocs/admin/system/pre.inc.php index 6f987064d84..48d73a9705e 100644 --- a/htdocs/admin/system/pre.inc.php +++ b/htdocs/admin/system/pre.inc.php @@ -33,34 +33,37 @@ function llxHeader($head = "", $urlp = "") $langs->load("admin"); - + top_menu($head); - + $menu = new Menu(); - + $menu->add(DOL_URL_ROOT."/admin/system/index.php", $langs->trans("Summary")); - + // Dolibarr $menu->add(DOL_URL_ROOT."/admin/system/dolibarr.php", "Dolibarr"); $menu->add_submenu(DOL_URL_ROOT."/admin/system/constall.php", $langs->trans("AllParameters")); $menu->add_submenu(DOL_URL_ROOT."/admin/system/modules.php", $langs->trans("Modules")); $menu->add_submenu(DOL_URL_ROOT."/admin/triggers.php", $langs->trans("Triggers")); $menu->add_submenu(DOL_URL_ROOT."/about.php", $langs->trans("About")); - + // OS $menu->add(DOL_URL_ROOT."/admin/system/os.php", $langs->trans("OS")); - + // Web server $menu->add(DOL_URL_ROOT."/admin/system/web.php", $langs->trans("WebServer")); - + // PHP $menu->add(DOL_URL_ROOT."/admin/system/phpinfo.php", $langs->trans("Php")); - - // Database + + // XDebug + //$menu->add(DOL_URL_ROOT."/admin/system/xdebug.php", $langs->trans("XDebug")); + + // Database $menu->add(DOL_URL_ROOT."/admin/system/database.php", $langs->trans("Database")); $menu->add_submenu(DOL_URL_ROOT."/admin/system/database-tables.php", $langs->trans("Tables")); $menu->add_submenu(DOL_URL_ROOT."/admin/system/database-tables-contraintes.php", $langs->trans("Constraints")); - + left_menu($menu->liste); } diff --git a/htdocs/admin/system/xdebug.php b/htdocs/admin/system/xdebug.php new file mode 100644 index 00000000000..a6cdd960e51 --- /dev/null +++ b/htdocs/admin/system/xdebug.php @@ -0,0 +1,71 @@ + + * + * 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. + */ + +/** + \file htdocs/admin/system/xdebug.php + \brief Page administration XDebug + \version $Id$ +*/ + +require("./pre.inc.php"); + +$langs->load("admin"); + +if (!$user->admin) + accessforbidden(); + + +/* +* View +*/ + +llxHeader(); + +print_fiche_titre("XDebug",'','setup'); + +print "
\n"; + + +if (!function_exists('xdebug_is_enabled')) +{ + print 'XDebug seems to be not installed. Function xdebug_is_enabled not found.'; + llxfooter('$Date$ - $Revision$'); + exit; +} + + +if (function_exists('socket_create')) +{ + $address = '127.0.0.1'; + $port = 9000; + $sock = socket_create(AF_INET, SOCK_STREAM, 0); + socket_bind($sock, $address, $port) or die('Unable to bind'); + socket_listen($sock); + $client = socket_accept($sock); + echo "connection established: $client"; + socket_close($client); + socket_close($sock); +} +else +{ + print "Can't test if PHPDebug is OK as PHP socket functions are not enabled."; +} + + +llxfooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 8ec51a3f619..d7f7eee7ac8 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -1,8 +1,5 @@ - - * - * $Id$ - * $Source$ * * 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 @@ -22,7 +19,7 @@ /** \file htdocs/admin/tools/eaccelerator.php \brief Page administration de eaccelerator - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -34,7 +31,7 @@ if (!$user->admin) /* -* Affichage page +* View */ llxHeader(); @@ -100,13 +97,13 @@ function revcompare($x, $y) else return -1; } - + function create_script_table($list) { global $sortby,$bc,$langs; $var=true; - + if (isset($_GET['order']) && ($_GET['order'] == "asc" || $_GET['order'] =="desc")) { $order = $_GET['order']; } else { @@ -149,7 +146,7 @@ function revcompare($x, $y) default: $sortby = "file"; ($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare')); - + } foreach($list as $script) { ?> @@ -162,7 +159,7 @@ function revcompare($x, $y) - KB - Information > - Caching enabled + Caching enabled > @@ -225,7 +222,7 @@ $var=true; > Memory usage - % + % ( MB / MB) @@ -238,7 +235,7 @@ $var=true; > - Removed scripts + Removed scripts > @@ -287,7 +284,7 @@ $res=eaccelerator_cached_scripts(); // If success return an array if (is_array($res)) create_script_table($res); else print "Check in your php.ini that eaccelerator.allowed_admin_path parameter is "._FILE; ?> - +

Removed scripts
diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 649d3e7754e..e306d654cbc 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -25,6 +25,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); $langs->load("commercial"); $langs->load("orders"); @@ -202,7 +203,7 @@ $db->close(); if ($langs->file_exists("html/spam.html",0)) { print "



".$langs->trans("Note")."
"; print '
'; - $langs->print_file("html/spam.html",0); + dol_print_file($langs,"html/spam.html",0); print '
'; print '
'; diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index d1dba4dd38f..88cd5bdec2a 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -49,12 +49,12 @@ class Conf var $css; // Used to store current css (from theme) var $top_menu; var $left_menu; - + var $css_modules=array(); var $tabs_modules=array(); - + var $logbuffer=array(); - + /** * \brief Positionne toutes les variables de configuration @@ -63,7 +63,7 @@ class Conf */ function setValues($db) { - dolibarr_syslog("Conf::setValues"); + dol_syslog("Conf::setValues"); // Par defaut, a oui $this->global->PRODUIT_CONFIRM_DELETE_LINE=1; @@ -79,7 +79,7 @@ class Conf { $numr = $db->num_rows($result); $i = 0; - + while ($i < $numr) { $objp = $db->fetch_object($result); @@ -101,7 +101,7 @@ class Conf $this->tabs_modules[$params[0]][]=$value; //print 'xxx'.$params[0].'-'.$value; } - // If this is a module constant + // If this is a module constant if (eregi('^MAIN_MODULE_([A-Z]+)$',$key,$reg) && $value) { $module=strtolower($reg[1]); @@ -114,7 +114,7 @@ class Conf } $db->free($result); - + // On reprend parametres du fichier de config conf.php // \TODO Mettre tous les param de conf DB dans une propriete de la classe @@ -139,13 +139,13 @@ class Conf // Other global parameters $this->users->dir_output=DOL_DATA_ROOT."/users"; - + // For backward compatibility $this->comptaexpert->enabled=defined("MAIN_MODULE_COMPTABILITE_EXPERT")?MAIN_MODULE_COMPTABILITE_EXPERT:0; $this->compta->enabled=defined("MAIN_MODULE_COMPTABILITE")?MAIN_MODULE_COMPTABILITE:0; $this->webcal->enabled=defined('MAIN_MODULE_WEBCALENDAR')?MAIN_MODULE_WEBCALENDAR:0; $this->propal->enabled=defined("MAIN_MODULE_PROPALE")?MAIN_MODULE_PROPALE:0; - + // Module agenda $this->agenda->dir_temp=DOL_DATA_ROOT."/agenda/temp"; @@ -214,7 +214,7 @@ class Conf // Module service $this->service->dir_output=DOL_DATA_ROOT."/produit"; $this->service->dir_temp =DOL_DATA_ROOT."/produit/temp"; - + // Module droipret $this->droitpret->cat=defined('DROITPRET_CAT')?DROITPRET_CAT:''; $this->droitpret->cat=defined('DROITPRET_MAIL')?DROITPRET_MAIL:''; @@ -286,7 +286,7 @@ class Conf $this->boutique->album->enabled=defined("BOUTIQUE_ALBUM")?BOUTIQUE_ALBUM:0; // Module Barcode $this->barcode->dir_temp=DOL_DATA_ROOT."/barcode/temp"; - + /* * Modification de quelques variable de conf en fonction des Constantes */ @@ -305,7 +305,7 @@ class Conf // conf->box_max_lines $this->box_max_lines=5; if (isset($this->global->MAIN_BOXES_MAXLINES)) $this->box_max_lines=$this->global->MAIN_BOXES_MAXLINES; - + // conf->use_preview_tabs $this->use_preview_tabs=0; if (isset($this->global->MAIN_USE_PREVIEW_TABS)) $this->use_preview_tabs=$this->global->MAIN_USE_PREVIEW_TABS; @@ -314,7 +314,7 @@ class Conf $this->use_javascript_ajax=1; if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax=! $this->global->MAIN_DISABLE_JAVASCRIPT; // If no javascript_ajax, Ajax features are disabled. - if (! $this->use_javascript_ajax) + if (! $this->use_javascript_ajax) { $this->global->PRODUIT_USE_SEARCH_TO_SELECT=0; $this->global->MAIN_CONFIRM_AJAX=0; @@ -357,7 +357,7 @@ class Conf if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME="eldy"; $this->theme=$this->global->MAIN_THEME; $this->css = "theme/".$this->theme."/".$this->theme.".css"; - + // $this->email_from = email pour envoi par dolibarr des mails automatiques $this->email_from = "dolibarr-robot@domain.com"; if (! empty($this->global->MAIN_MAIL_EMAIL_FROM)) @@ -383,7 +383,7 @@ class Conf { $this->global->MAIN_GRAPH_LIBRARY = 'artichow'; } - + // Format de la date // \todo Mettre les 4 formats dans fichier langue $this->format_date_short="%d/%m/%Y"; @@ -393,7 +393,7 @@ class Conf $this->format_date_hour_short="%d/%m/%Y %H:%M"; $this->format_date_hour_text_short="%d %b %Y %H:%M"; $this->format_date_hour_text="%d %B %Y %H:%M"; - + $this->format_date_short_java="dd/MM/yyyy"; // Limites decimales si non definie (peuvent etre egale a 0) @@ -403,7 +403,7 @@ class Conf // Define umask if (empty($conf->global->MAIN_UMASK)) $conf->global->MAIN_UMASK='0664'; - + /* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de desactiver la fonction TVA * (pour particuliers ou liberaux en franchise) * En attendant, valeur forcee a 1 car toujours interessant a avoir meme ceux qui veulent pas. diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index 30c7d62a817..8d66568cff2 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -148,6 +148,7 @@ class MenuLeft { if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/os.php", $langs->trans("OS")); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/web.php", $langs->trans("WebServer")); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/phpinfo.php", $langs->trans("Php")); + //if ($leftmenu=="system" && function_exists('xdebug_is_enabled')) $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/xdebug.php", $langs->trans("XDebug")); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/database.php", $langs->trans("Database")); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/database-tables.php", $langs->trans("Tables"),2); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/database-tables-contraintes.php", $langs->trans("Constraints"),2); diff --git a/htdocs/includes/menus/barre_left/eldy_frontoffice.php b/htdocs/includes/menus/barre_left/eldy_frontoffice.php index 47da757ac86..097095768c3 100644 --- a/htdocs/includes/menus/barre_left/eldy_frontoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_frontoffice.php @@ -150,6 +150,7 @@ class MenuLeft { if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/os.php", $langs->trans("OS")); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/web.php", $langs->trans("WebServer")); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/phpinfo.php", $langs->trans("Php")); + //if ($leftmenu=="system" && function_exists('xdebug_is_enabled')) $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/xdebug.php", $langs->trans("XDebug")); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/database.php", $langs->trans("Database")); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/database-tables.php", $langs->trans("Tables"),2); if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/database-tables-contraintes.php", $langs->trans("Constraints"),2); diff --git a/htdocs/install/licence.php b/htdocs/install/licence.php index e126d09082c..4bdf971bedb 100644 --- a/htdocs/install/licence.php +++ b/htdocs/install/licence.php @@ -25,6 +25,7 @@ */ include_once("./inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); $setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto'); $langs->setDefaultLang($setuplang); @@ -45,12 +46,12 @@ pHeader($langs->trans("License"),"fileconf"); //print '
';
-$result=$langs->print_file("html/gpl.html",1);
+$result=dol_print_file($langs,"html/gpl.html",1);
 if (! $result)
 {
 	print '
'."\n"; print ''; print '
'."\n"; } diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 9f3f0e972ca..eebad430d8b 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -380,7 +380,7 @@ function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodeto || eregi('^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$',$time,$reg)) { // This part of code should not be used. - dolibarr_syslog("Functions.lib::dolibarr_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); + dol_syslog("Functions.lib::dolibarr_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' $syear = $reg[1]; $smonth = $reg[2]; @@ -444,7 +444,7 @@ function dol_stringtotime($string) if (eregi('^([0-9]+)\/([0-9]+)\/([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?',$string,$reg)) { // This part of code should not be used. - dolibarr_syslog("Functions.lib::dol_stringtotime call to function with deprecated parameter", LOG_WARN); + dol_syslog("Functions.lib::dol_stringtotime call to function with deprecated parameter", LOG_WARN); // Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS' // Date est au format 'DD/MM/YYYY' ou 'DD/MM/YYYY HH:MM:SS' $sday = $reg[1]; @@ -1450,7 +1450,7 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='', } else { - dolibarr_syslog("functions.lib::restrictedArea sql=".$sql, LOG_ERR); + dol_syslog("functions.lib::restrictedArea sql=".$sql, LOG_ERR); accessforbidden(); } } @@ -1591,7 +1591,7 @@ function dol_print_error($db='',$error='') } } - dolibarr_syslog("Error ".$syslog, LOG_ERR); + dol_syslog("Error ".$syslog, LOG_ERR); } @@ -1630,7 +1630,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite) // les noms de fichiers. if (eregi('^\.',$src_file) || eregi('\.\.',$src_file) || eregi('[<>|]',$src_file)) { - dolibarr_syslog("Refused to deliver file ".$src_file); + dol_syslog("Refused to deliver file ".$src_file); return -1; } @@ -1639,7 +1639,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite) // les noms de fichiers. if (eregi('^\.',$dest_file) || eregi('\.\.',$dest_file) || eregi('[<>|]',$dest_file)) { - dolibarr_syslog("Refused to deliver file ".$dest_file); + dol_syslog("Refused to deliver file ".$dest_file); return -1; } @@ -1648,7 +1648,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite) { if (file_exists($file_name)) { - dolibarr_syslog("Functions.lib::dol_move_uploaded_file File ".$file_name." already exists", LOG_WARNING); + dol_syslog("Functions.lib::dol_move_uploaded_file File ".$file_name." already exists", LOG_WARNING); return -2; } } @@ -1658,12 +1658,12 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite) if ($return) { if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name, octdec($conf->global->MAIN_UMASK)); - dolibarr_syslog("Functions.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); + dol_syslog("Functions.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); return 1; } else { - dolibarr_syslog("Functions.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR); + dol_syslog("Functions.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR); return -3; } } @@ -1898,8 +1898,8 @@ function dol_delete_file($file) foreach (glob($file) as $filename) { $ok=unlink($filename); - if ($ok) dolibarr_syslog("Removed file $filename",LOG_DEBUG); - else dolibarr_syslog("Failed to remove file $filename",LOG_ERR); + if ($ok) dol_syslog("Removed file $filename",LOG_DEBUG); + else dol_syslog("Failed to remove file $filename",LOG_ERR); } return $ok; } @@ -2157,7 +2157,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $ if (!is_object($societe_vendeuse)) return -1; if (!is_object($societe_acheteuse)) return -1; - dolibarr_syslog("get_default_tva vendeur_assujeti=".$societe_vendeuse->tva_assuj." pays_vendeur=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", pays_acheteur=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", taux_produit(deprecated)=".$taux_produit.", idprod=".$idprod); + dol_syslog("get_default_tva vendeur_assujeti=".$societe_vendeuse->tva_assuj." pays_vendeur=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", pays_acheteur=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", taux_produit(deprecated)=".$taux_produit.", idprod=".$idprod); // Si vendeur non assujeti a TVA (tva_assuj vaut 0/1 ou franchise/reel) if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) return 0; @@ -2267,7 +2267,7 @@ function create_exdir($dir) { global $conf; - dolibarr_syslog("functions.lib::create_exdir: dir=".$dir,LOG_INFO); + dol_syslog("functions.lib::create_exdir: dir=".$dir,LOG_INFO); if (@is_dir($dir)) return 0; @@ -2288,7 +2288,7 @@ function create_exdir($dir) { if (! @is_dir($ccdir)) { - dolibarr_syslog("functions.lib::create_exdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.",LOG_DEBUG); + dol_syslog("functions.lib::create_exdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.",LOG_DEBUG); umask(0); $dirmaskdec=octdec('0755'); @@ -2297,12 +2297,12 @@ function create_exdir($dir) if (! @mkdir($ccdir, $dirmaskdec)) { // Si le is_dir a renvoye une fausse info, alors on passe ici. - dolibarr_syslog("functions.lib::create_exdir: Fails to create directory '".$ccdir."' or directory already exists.",LOG_WARNING); + dol_syslog("functions.lib::create_exdir: Fails to create directory '".$ccdir."' or directory already exists.",LOG_WARNING); $nberr++; } else { - dolibarr_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 �checs pr�c�dents peuvent etre ignor�s $nbcreated++; } diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php index 46a697caa6f..93115725668 100644 --- a/htdocs/lib/functions2.lib.php +++ b/htdocs/lib/functions2.lib.php @@ -26,6 +26,54 @@ */ +/** + * \brief Renvoi le fichier $filename dans la version de la langue courante, sinon alternative + * \param filename nom du fichier a rechercher + * \param searchalt cherche aussi dans langue alternative + * \return boolean + */ +function dol_print_file($langs,$filename,$searchalt=0) +{ + global $conf; + + // Test if file is in lang directory + foreach($langs->dir as $searchdir) + { + $htmlfile=($searchdir."/langs/".$langs->defaultlang."/".$filename); + dol_syslog('Translate::print_file search file '.$htmlfile, LOG_DEBUG); + if (is_readable($htmlfile)) + { + $content=file_get_contents($htmlfile); + $isutf8=utf8_check($content); + if (! $isutf8 && $conf->character_set_client == 'UTF-8') print utf8_encode($content); + elseif ($isutf8 && $conf->character_set_client == 'ISO-8859-1') print utf8_decode($content); + else print $content; + return true; + } + else dol_syslog('Translate::print_file not found', LOG_DEBUG); + + if ($searchalt) { + // Test si fichier dans repertoire de la langue alternative + if ($langs->defaultlang != "en_US") $htmlfilealt = $searchdir."/langs/en_US/".$filename; + else $htmlfilealt = $searchdir."/langs/fr_FR/".$filename; + dol_syslog('Translate::print_file search alt file '.$htmlfilealt, LOG_DEBUG); + //print 'getcwd='.getcwd().' htmlfilealt='.$htmlfilealt.' X '.file_exists(getcwd().'/'.$htmlfilealt); + if (is_readable($htmlfilealt)) + { + $content=file_get_contents($htmlfilealt); + $isutf8=utf8_check($content); + if (! $isutf8 && $conf->character_set_client == 'UTF-8') print utf8_encode($content); + elseif ($isutf8 && $conf->character_set_client == 'ISO-8859-1') print utf8_decode($content); + else print $content; + return true; + } + else dol_syslog('Translate::print_file not found', LOG_DEBUG); + } + } + + return false; +} + /** * \brief Show informations on an object * \param object Objet to show @@ -155,7 +203,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='',$date= { // Clean parameters if ($date == '') $date=mktime(); // We use local year and month of PHP server to search numbers - // but we should use local year and month of user + // but we should use local year and month of user // Extract value for mask counter, mask raz and mask offset if (! eregi('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$mask,$reg)) return 'ErrorBadMask'; @@ -261,7 +309,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='',$date= if ($sqlwhere) $sql.=' AND '.$sqlwhere; //print $sql; - dolibarr_syslog("functions2::get_next_value sql=".$sql, LOG_DEBUG); + dol_syslog("functions2::get_next_value sql=".$sql, LOG_DEBUG); $resql=$db->query($sql); if ($resql) { @@ -304,7 +352,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='',$date= if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; - dolibarr_syslog("functions2::get_next_value maskrefclient_sql=".$maskrefclient_sql, LOG_DEBUG); + dol_syslog("functions2::get_next_value maskrefclient_sql=".$maskrefclient_sql, LOG_DEBUG); $maskrefclient_resql=$db->query($maskrefclient_sql); if ($maskrefclient_resql) { @@ -342,7 +390,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='',$date= $numFinal = str_replace($maskrefclient_maskbefore,$maskrefclient_maskafter,$numFinal); } - dolibarr_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG); + dol_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG); return $numFinal; } @@ -438,7 +486,7 @@ function check_value($mask,$value) if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",strlen($maskrefclient),"_"),$maskLike); - dolibarr_syslog("functions2::check_value result=".$result,LOG_DEBUG); + dol_syslog("functions2::check_value result=".$result,LOG_DEBUG); return $result; } @@ -607,15 +655,15 @@ function weight_convert($weight,&$from_unit,$to_unit) { if ($from_unit > $to_unit) { - $weight = $weight * 10; - $from_unit = $from_unit - 1; - $weight = weight_convert($weight,$from_unit, $to_unit); + $weight = $weight * 10; + $from_unit = $from_unit - 1; + $weight = weight_convert($weight,$from_unit, $to_unit); } if ($from_unit < $to_unit) { - $weight = $weight / 10; - $from_unit = $from_unit + 1; - $weight = weight_convert($weight,$from_unit, $to_unit); + $weight = $weight / 10; + $from_unit = $from_unit + 1; + $weight = weight_convert($weight,$from_unit, $to_unit); } } @@ -649,7 +697,7 @@ function dol_set_user_param($db, &$user, $tab) $i++; } $sql.= ")"; - dolibarr_syslog("functions2.lib::dol_set_user_param sql=".$sql, LOG_DEBUG); + dol_syslog("functions2.lib::dol_set_user_param sql=".$sql, LOG_DEBUG); $resql=$db->query($sql); if (! $resql) @@ -667,7 +715,7 @@ function dol_set_user_param($db, &$user, $tab) $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,param,value)"; $sql.= " VALUES (".$user->id.","; $sql.= " '".$key."','".addslashes($value)."');"; - dolibarr_syslog("functions2.lib::dol_set_user_param sql=".$sql, LOG_DEBUG); + dol_syslog("functions2.lib::dol_set_user_param sql=".$sql, LOG_DEBUG); $result=$db->query($sql); if (! $result) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 81b70d48524..1618d8795ab 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -122,7 +122,7 @@ if ($conf->main_force_https) { $newurl=eregi_replace('^http:','https:',$_SERVER["SCRIPT_URI"]); - dolibarr_syslog("dolibarr_main_force_https is on, we make a redirect to ".$newurl,LOG_DEBUG); + dol_syslog("dolibarr_main_force_https is on, we make a redirect to ".$newurl,LOG_DEBUG); header("Location: ".$newurl); exit; } @@ -138,7 +138,7 @@ if ($conf->main_force_https) $newurl='https://'.$domaineport.$_SERVER["REQUEST_URI"]; //print 'eee'.$newurl; exit; - dolibarr_syslog("dolibarr_main_force_https is on, we make a redirect to ".$newurl,LOG_DEBUG); + dol_syslog("dolibarr_main_force_https is on, we make a redirect to ".$newurl,LOG_DEBUG); header("Location: ".$newurl); exit; } @@ -157,7 +157,7 @@ $sessionname="DOLSESSID_".$dolibarr_main_db_name; if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) ini_set('session.gc_maxlifetime',$conf->global->MAIN_SESSION_TIMEOUT); session_name($sessionname); session_start(); -dolibarr_syslog("Start session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".(isset($_SESSION["dol_login"])?$_SESSION["dol_login"]:'').", ".ini_get("session.gc_maxlifetime")); +dol_syslog("Start session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".(isset($_SESSION["dol_login"])?$_SESSION["dol_login"]:'').", ".ini_get("session.gc_maxlifetime")); // Disable modules (this must be after session_start) if (! empty($_REQUEST["disablemodules"])) $_SESSION["disablemodules"]=$_REQUEST["disablemodules"]; @@ -192,7 +192,7 @@ $authmode=split(',',$dolibarr_main_authentication); if (! sizeof($authmode)) { $langs->load('main'); - dolibarr_print_error('',$langs->trans("ErrorConfigParameterNotDefined",'dolibarr_main_authentication')); + dol_print_error('',$langs->trans("ErrorConfigParameterNotDefined",'dolibarr_main_authentication')); exit; } @@ -218,7 +218,7 @@ if (! isset($_SESSION["dol_login"])) // Verifie code if (! $object->check('dol_antispam_value',$_POST['code'],true)) { - dolibarr_syslog('Bad value for code, connexion refused'); + dol_syslog('Bad value for code, connexion refused'); $langs->load('main'); $langs->load('other'); @@ -265,7 +265,7 @@ if (! isset($_SESSION["dol_login"])) } else { - dolibarr_syslog("Authentification ko - failed to load file '".$authfile."'",LOG_ERR); + dol_syslog("Authentification ko - failed to load file '".$authfile."'",LOG_ERR); sleep(1); $langs->load('main'); $langs->load('other'); @@ -276,7 +276,7 @@ if (! isset($_SESSION["dol_login"])) if (! $login) { - dolibarr_syslog('Bad password, connexion refused',LOG_DEBUG); + dol_syslog('Bad password, connexion refused',LOG_DEBUG); $langs->load('main'); $langs->load('other'); @@ -305,7 +305,7 @@ if (! isset($_SESSION["dol_login"])) $resultFetchUser=$user->fetch($login); if ($resultFetchUser <= 0) { - dolibarr_syslog('User not found, connexion refused'); + dol_syslog('User not found, connexion refused'); session_destroy(); session_name($sessionname); session_start(); @@ -342,11 +342,11 @@ else $login=$_SESSION["dol_login"]; $resultFetchUser=$user->fetch($login); - dolibarr_syslog("This is an already logged session. _SESSION['dol_login']=".$login); + dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login); if ($resultFetchUser <= 0) { // Account has been removed after login - dolibarr_syslog("Can't load user even if session logged. _SESSION['dol_login']=".$login, LOG_WARNING); + dol_syslog("Can't load user even if session logged. _SESSION['dol_login']=".$login, LOG_WARNING); session_destroy(); session_name($sessionname); session_start(); @@ -385,7 +385,7 @@ if (! isset($_SESSION["dol_login"])) // Nouvelle session pour ce login $_SESSION["dol_login"]=$user->login; $_SESSION["dol_authmode"]=$conf->authmode; - dolibarr_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id()); + dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id()); $db->begin(); @@ -402,7 +402,7 @@ if (! isset($_SESSION["dol_login"])) { $db->rollback(); session_destroy(); - dolibarr_print_error($db,'Error in some triggers on action USER_LOGIN',LOG_ERR); + dol_print_error($db,'Error in some triggers on action USER_LOGIN',LOG_ERR); exit; } else @@ -543,7 +543,7 @@ if ($conf->global->MAIN_NEED_SMARTY) } else { - dolibarr_print_error('',"Library Smarty ".$smarty_libs." not found. Check parameter dolibarr_smarty_libs_dir in conf file."); + dol_print_error('',"Library Smarty ".$smarty_libs." not found. Check parameter dolibarr_smarty_libs_dir in conf file."); } } @@ -556,13 +556,13 @@ if ($user->statut < 1) { // Si non actif, on delogue le user $langs->load("other"); - dolibarr_syslog ("Authentification ko car login desactive"); + dol_syslog ("Authentification ko car login desactive"); accessforbidden($langs->trans("ErrorLoginDisabled")); exit; } -dolibarr_syslog("Access to ".$_SERVER["PHP_SELF"],LOG_INFO); +dol_syslog("Access to ".$_SERVER["PHP_SELF"],LOG_INFO); // For backward compatibility if (! defined('MAIN_INFO_SOCIETE_PAYS')) define('MAIN_INFO_SOCIETE_PAYS','1'); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 4f415dafa8f..bf406b74a67 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -187,7 +187,7 @@ if (! defined('NOREQUIREDB')) if ($db->error) { - dolibarr_print_error($db,"host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error); + dol_print_error($db,"host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error); exit; } } @@ -272,7 +272,7 @@ if (! defined('NOREQUIRESOC')) $mysoc->pays_code=$obj->code; } else { - dolibarr_print_error($db); + dol_print_error($db); } } // Si dans MAIN_INFO_SOCIETE_PAYS on a deja un code, tout est fait diff --git a/htdocs/translate.class.php b/htdocs/translate.class.php index a6a2b70d230..a6e7afc9474 100644 --- a/htdocs/translate.class.php +++ b/htdocs/translate.class.php @@ -98,7 +98,7 @@ class Translate { */ function setDefaultLang($srclang='fr_FR') { - //dolibarr_syslog("Translate::setDefaultLang ".$this->defaultlang,LOG_DEBUG); + //dol_syslog("Translate::setDefaultLang ".$this->defaultlang,LOG_DEBUG); $this->origlang=$srclang; @@ -145,7 +145,7 @@ class Translate { */ function setPhpLang() { - //dolibarr_syslog("Translate::setPhpLang ".$this->defaultlang,LOG_DEBUG); + //dol_syslog("Translate::setPhpLang ".$this->defaultlang,LOG_DEBUG); return; /* $code_lang_tiret=ereg_replace('_','-',$this->defaultlang); @@ -177,12 +177,12 @@ class Translate { */ function Load($domain,$alt=0) { - //dolibarr_syslog("Translate::Load domain=".$domain." alt=".$alt); + //dol_syslog("Translate::Load domain=".$domain." alt=".$alt); // Check parameters if (empty($domain)) { - dolibarr_print_error('',"Translate::Load ErrorWrongParameters"); + dol_print_error('',"Translate::Load ErrorWrongParameters"); exit; } @@ -285,7 +285,7 @@ class Translate { if (! $newalt && $this->defaultlang != "fr_FR" && $this->defaultlang != "en_US") { // This function must not contains call to syslog - dolibarr_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$domain.".lang file)", LOG_DEBUG); + dol_print_error("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$domain.".lang file)", LOG_DEBUG); $this->load($domain,1); } @@ -312,7 +312,7 @@ class Translate { */ function UnLoad($domain) { - dolibarr_syslog("Translate::UnLoad domain=".$domain." marked as not loaded", LOG_DEBUG); + dol_syslog("Translate::UnLoad domain=".$domain." marked as not loaded", LOG_DEBUG); $this->tab_loaded[$domain]=0; } @@ -530,54 +530,6 @@ class Translate { } - /** - * \brief Renvoi le fichier $filename dans la version de la langue courante, sinon alternative - * \param filename nom du fichier a rechercher - * \param searchalt cherche aussi dans langue alternative - * \return boolean - */ - function print_file($filename,$searchalt=0) - { - global $conf; - - // Test if file is in lang directory - foreach($this->dir as $searchdir) - { - $htmlfile=($searchdir."/langs/".$this->defaultlang."/".$filename); - dolibarr_syslog('Translate::print_file search file '.$htmlfile, LOG_DEBUG); - if (is_readable($htmlfile)) - { - $content=file_get_contents($htmlfile); - $isutf8=utf8_check($content); - if (! $isutf8 && $conf->character_set_client == 'UTF-8') print utf8_encode($content); - elseif ($isutf8 && $conf->character_set_client == 'ISO-8859-1') print utf8_decode($content); - else print $content; - return true; - } - else dolibarr_syslog('Translate::print_file not found', LOG_DEBUG); - - if ($searchalt) { - // Test si fichier dans repertoire de la langue alternative - if ($this->defaultlang != "en_US") $htmlfilealt = $searchdir."/langs/en_US/".$filename; - else $htmlfilealt = $searchdir."/langs/fr_FR/".$filename; - dolibarr_syslog('Translate::print_file search alt file '.$htmlfilealt, LOG_DEBUG); - //print 'getcwd='.getcwd().' htmlfilealt='.$htmlfilealt.' X '.file_exists(getcwd().'/'.$htmlfilealt); - if (is_readable($htmlfilealt)) - { - $content=file_get_contents($htmlfilealt); - $isutf8=utf8_check($content); - if (! $isutf8 && $conf->character_set_client == 'UTF-8') print utf8_encode($content); - elseif ($isutf8 && $conf->character_set_client == 'ISO-8859-1') print utf8_decode($content); - else print $content; - return true; - } - else dolibarr_syslog('Translate::print_file not found', LOG_DEBUG); - } - } - - return false; - } - /** * \brief Return a label for a key. Store key-label in a cache. * \param db Database handler @@ -609,7 +561,7 @@ class Translate { $sql = "SELECT ".$fieldlabel." as label"; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; $sql.= " WHERE ".$fieldkey." = '".$key."'"; - dolibarr_syslog('Translate::getLabelFromKey sql='.$sql,LOG_DEBUG); + dol_syslog('Translate::getLabelFromKey sql='.$sql,LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -622,7 +574,7 @@ class Translate { else { $this->error=$db->lasterror(); - dolibarr_syslog("Translate::getLabelFromKey error=".$this->error,LOG_ERR); + dol_syslog("Translate::getLabelFromKey error=".$this->error,LOG_ERR); return -1; } }