From e6f3599847d961b28606c4e4fbd705fc97bf909e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 4 Dec 2011 22:25:49 +0100 Subject: [PATCH] Qual: Some code cleaning --- htdocs/compta/bank/graph.php | 6 +----- htdocs/core/class/conf.class.php | 14 ++++---------- htdocs/core/class/dolgraph.class.php | 19 +++++++------------ htdocs/core/lib/xcal.lib.php | 5 +---- htdocs/install/etape2.php | 8 -------- htdocs/master.inc.php | 15 +++++++-------- htdocs/public/members/public_card.php | 4 ++-- htdocs/public/members/public_list.php | 4 ++-- htdocs/public/paypal/newpayment.php | 14 -------------- htdocs/support/inc.php | 8 ++++++-- 10 files changed, 30 insertions(+), 67 deletions(-) diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index df4f4f951c9..496c1605cf7 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -54,11 +54,7 @@ llxHeader(); $form = new Form($db); -// If lib forced -if (! empty($_GET["lib"])) $conf->global->MAIN_GRAPH_LIBRARY=$_GET["lib"]; - - -$datetime = time(); +$datetime = dol_now(); $year = dol_print_date($datetime, "%Y"); $month = dol_print_date($datetime, "%m"); $day = dol_print_date($datetime, "%d"); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index ecb6820f267..d7fae4fa9d6 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -255,15 +255,15 @@ class Conf $this->$module->dir_temp=$rootfordata."/".$module."/temp"; } - // For mycompany setup + // For mycompany storage $this->mycompany->dir_output=$rootfordata."/mycompany"; $this->mycompany->dir_temp=$rootfordata."/mycompany/temp"; - // For admin features + // For admin storage $this->admin->dir_output=$rootfordata.'/admin'; $this->admin->dir_temp=$rootfordata.'/admin/temp'; - // Module user + // For user storage $this->user->dir_output=$rootforuser."/users"; $this->user->dir_temp=$rootforuser."/users/temp"; @@ -309,10 +309,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) - { - $this->global->PRODUIT_USE_SEARCH_TO_SELECT=0; - } + if (! $this->use_javascript_ajax) $this->global->PRODUIT_USE_SEARCH_TO_SELECT=0; // conf->currency if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR'; @@ -346,9 +343,6 @@ class Conf $this->mailing->email_from=$this->email_from; if (! empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from=$this->global->MAILING_EMAIL_FROM; - // Defini MAIN_GRAPH_LIBRARY - if (empty($this->global->MAIN_GRAPH_LIBRARY)) $this->global->MAIN_GRAPH_LIBRARY = 'artichow'; - if (! isset($this->global->FCKEDITOR_EDITORNAME)) $this->global->FCKEDITOR_EDITORNAME='ckeditor'; // fckeditor to switch // Format for date (used by default when not found or searched in lang) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 2ef8ec650c9..dfae7d72d17 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -66,15 +66,15 @@ class DolGraph var $Legend=array(); var $LegendWidthMin=0; - var $graph; // Objet Graph (Artichow, Phplot...) + var $graph; // Objet Graph (Artichow, Phplot...) var $error; - var $library=''; // Par defaut on utiliser PHPlot + var $library='artichow'; // Graphic library to use - var $bordercolor; // array(R,G,B) - var $bgcolor; // array(R,G,B) - var $bgcolorgrid; // array(R,G,B) - var $datacolor; // array(array(R,G,B),...) + var $bordercolor; // array(R,G,B) + var $bgcolor; // array(R,G,B) + var $bgcolorgrid; // array(R,G,B) + var $datacolor; // array(array(R,G,B),...) /** @@ -85,7 +85,6 @@ class DolGraph global $conf; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; - // Test si module GD present $modules_list = get_loaded_extensions(); $isgdinstalled=0; @@ -99,15 +98,11 @@ class DolGraph return -1; } - - // Defini proprietes de l'objet graphe - $this->library=$conf->global->MAIN_GRAPH_LIBRARY; - $this->bordercolor = array(235,235,224); $this->datacolor = array(array(120,130,150), array(160,160,180), array(190,190,220)); $this->bgcolor = array(235,235,224); - $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php"; + $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/graph-color.php'; if (is_readable($color_file)) { include_once($color_file); diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index c0bb1c5eb7b..3b527142ac7 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -386,7 +386,6 @@ function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='' /** * Encode for cal export - * string must be encoded in conf->file->character_set_client * * @param string $format vcal or ical * @param string $string string to encode @@ -396,10 +395,8 @@ function format_cal($format,$string) { global $conf; - if ($conf->file->character_set_client == 'ISO-8859-1') $newstring=utf8_encode($string); - else $newstring=$string; + $newstring=$string; - // Now newstring is always UTF8 string if ($format == 'vcal') { $newstring=quotedPrintEncode($newstring); diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index 8f81e55614c..b56c016d7c2 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -197,10 +197,6 @@ if ($action == "set") //print "<tr><td>Creation de la table $name/td>"; $requestnb++; - if ($conf->file->character_set_client == "UTF-8") - { - $buffer=utf8_encode($buffer); - } dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG); $resql=$db->query($buffer,0,'dml'); @@ -344,10 +340,6 @@ if ($action == "set") //print "<tr><td>Creation des cles et index de la table $name: '$buffer'</td>"; $requestnb++; - if ($conf->file->character_set_client == "UTF-8") - { - $buffer=utf8_encode($buffer); - } dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG); $resql=$db->query($buffer,0,'dml'); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 5ee36650668..d995a768d99 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -56,16 +56,12 @@ $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; $conf->file->main_limit_users = $dolibarr_main_limit_users; $conf->file->mailing_limit_sendbyweb = $dolibarr_mailing_limit_sendbyweb; -if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type=constant('TEST_DB_FORCE_TYPE'); // For test purpose -// Identifiant autres +// Identification mode $conf->file->main_authentication = empty($dolibarr_main_authentication)?'':$dolibarr_main_authentication; // Force https $conf->file->main_force_https = empty($dolibarr_main_force_https)?'':$dolibarr_main_force_https; -// Define charset for HTML Output (can set hidden value force_charset in conf file) -$conf->file->character_set_client = strtoupper($force_charset_do_notuse); // Cookie cryptkey $conf->file->cookie_cryptkey = empty($dolibarr_main_cookie_cryptkey)?'':$dolibarr_main_cookie_cryptkey; - // Define array of document root directories $conf->file->dol_document_root = array('main' => DOL_DOCUMENT_ROOT); if (! empty($dolibarr_main_document_root_alt)) @@ -77,6 +73,8 @@ if (! empty($dolibarr_main_document_root_alt)) $conf->file->dol_document_root['alt']=$value; } } +// Force db type (for test purpose) +if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type=constant('TEST_DB_FORCE_TYPE'); // Multi-Company transverse mode $conf->multicompany->transverse_mode = empty($multicompany_transverse_mode)?'':$multicompany_transverse_mode; @@ -91,7 +89,7 @@ if (! defined('NOREQUIRESOC')) require_once(DOL_DOCUMENT_ROOT ."/societe/class/ */ if (! defined('NOREQUIRETRAN')) { - $langs = new Translate("",$conf); // A mettre apres lecture de la conf + $langs = new Translate('',$conf); // A mettre apres lecture de la conf } /* @@ -107,9 +105,10 @@ if (! defined('NOREQUIREDB')) exit; } } + // Now database connexion is known, so we can forget password -//$dolibarr_main_db_pass=''; // Comment this because this constant is used in a lot of pages -$conf->db->pass=''; // This is to avoid password to be shown in memory/swap dump +//unset($dolibarr_main_db_pass); // We comment this because this constant is used in a lot of pages +unset($conf->db->pass); // This is to avoid password to be shown in memory/swap dump /* * Creation objet $user diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index 284b67825e5..b0ae5a8832b 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -119,8 +119,8 @@ llxFooterVierge(); /** * Show header for card member * - * @param string $title - * @param string $head + * @param string $title Title + * @param string $head More info into header * @return void */ function llxHeaderVierge($title, $head = "") diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index cec6d3e1896..1cbc014ce59 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -41,8 +41,8 @@ $langs->load("other"); /** * Show header for member list * - * @param string $title - * @param string $head + * @param string $title Title + * @param string $head More info into header * @return void */ function llxHeaderVierge($title, $head = "") diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 3a614385e0a..e098fbf43cc 100755 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -218,25 +218,11 @@ if (GETPOST("action") == 'dopayment') dol_syslog("email: $email", LOG_DEBUG); dol_syslog("desc: $desc", LOG_DEBUG); - /*header("Content-type: text/html; charset=".$conf->file->character_set_client); - - print '<html>'."\n"; - print '<head>'."\n"; - print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$conf->file->character_set_client."\">\n"; - print '</head>'."\n"; - print '<body>'."\n"; - print "\n"; - */ - $_SESSION["Payment_Amount"]=$PAYPAL_API_PRICE; // A redirect is added if API call successfull print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); - /*print '</body></html>'."\n"; - print "\n"; - */ - exit; } } diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index 7a372fd8ab8..cac281581ce 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -193,7 +193,6 @@ function conf($dolibarr_main_document_root) $conf->db->user = trim($dolibarr_main_db_user); $conf->db->pass = trim($dolibarr_main_db_pass); - if (empty($conf->file->character_set_client)) $conf->file->character_set_client="UTF-8"; if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation='latin1_swedish_ci'; return 1; @@ -201,7 +200,12 @@ function conf($dolibarr_main_document_root) /** - * \brief Show HTML header + * Show HTML header + * + * @param string $soutitre Title + * @param string $next Next + * @param string $action Action + * @return void */ function pHeader($soutitre,$next,$action='none') { -- GitLab