diff --git a/html/do.php b/html/do.php index 412cd18e8..397359d8c 100644 --- a/html/do.php +++ b/html/do.php @@ -70,7 +70,7 @@ if ( ! $cn->exist_table('version')) { $style_user=$http->post("style_user","string",$_SESSION[SESSION_KEY.'g_theme']); html_page_start($style_user); -if ( DEBUG ) { +if ( DEBUGNOALYSS > 1 ) { /** * Debug Design */ diff --git a/html/index.php b/html/index.php index 5a2f40db7..5be012e45 100644 --- a/html/index.php +++ b/html/index.php @@ -157,7 +157,7 @@ $my_domain=""; require_once '../include/constant.php'; require_once '../include/config.inc.php'; require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; -if (file_exists("install.php")&&!DEBUG) +if ( file_exists("install.php")&& DEBUGNOALYSS == 0 ) { // At the end of the installation procedure , the install file must be removed if (isset($_GET['remove_install'])) @@ -186,7 +186,7 @@ if (file_exists("install.php")&&!DEBUG) /** * Debug Design */ -if (DEBUG) +if ( DEBUGNOALYSS == 0 ) { echo <<Small diff --git a/html/install.php b/html/install.php index 148a2a12e..b96cc589c 100644 --- a/html/install.php +++ b/html/install.php @@ -555,7 +555,7 @@ else if ($account == 0 ) { echo "Creation of ".domaine."account_repository"; - if ( ! DEBUG) ob_start(); + if ( DEBUGNOALYSS == 0 ) ob_start(); $cn->exec_sql("create database ".domaine."account_repository encoding='utf8'"); $cn=new Database(); $cn->start(); @@ -570,13 +570,13 @@ if ($account == 0 ) { $cn->commit($cn); - if (!DEBUG) + if ( DEBUGNOALYSS == 0 ) { ob_end_clean(); } echo _("Creation of Modele 1"); - if (!DEBUG) + if ( DEBUGNOALYSS == 0 ) { ob_start(); } @@ -589,7 +589,7 @@ if ($account == 0 ) { $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/constraint.sql'); $cn->commit(); - if (!DEBUG) + if ( DEBUGNOALYSS == 0 ) { ob_end_clean(); } @@ -598,13 +598,13 @@ if ($account == 0 ) { $cn->exec_sql("create database ".domaine."mod2 encoding='utf8'"); $cn=new Database(2,'mod'); $cn->start(); - if ( ! DEBUG) { ob_start(); } + if ( DEBUGNOALYSS == 0 ) { ob_start(); } $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/schema.sql'); $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod2/data.sql'); $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/constraint.sql'); $cn->commit(); - if ( ! DEBUG) ob_end_clean(); + if ( DEBUGNOALYSS == 0 ) ob_end_clean(); echo '

'._('Important').'

'; echo '

'._('Utilisateur administrateur'),' ',NOALYSS_ADMINISTRATOR,'

'; echo '

',_('Mot de passe')," ",NOALYSS_ADMIN_PASSWORD,'

'; @@ -623,10 +623,10 @@ if (defined("MULTI") && MULTI == 0) $db = new Database(); if ($db->exist_table("repo_version") == false) { - if ( ! DEBUG) { ob_start(); } + if ( DEBUGNOALYSS > 0 ) { ob_start(); } $db->execute_script(NOALYSS_INCLUDE.'/sql/mono/mono.sql'); - if ( ! DEBUG) ob_end_clean(); + if ( DEBUGNOALYSS > 0 ) ob_end_clean(); } @@ -651,7 +651,7 @@ if (defined("MULTI") && MULTI == 0) echo "

"._("Tout est installé"). $succeed; echo "

"._("Mise à jour Repository")."

"; - if ( DEBUG == false ) ob_start(); + if ( DEBUGNOALYSS == 0 ) ob_start(); $MaxVersion=DBVERSIONREPO-1; for ($i=4;$i<= $MaxVersion;$i++) { @@ -662,6 +662,9 @@ if (defined("MULTI") && MULTI == 0) $db->exec_sql("update ac_users set use_login=$1,use_pass=md5($2) where use_id=1", array(strtolower(NOALYSS_ADMINISTRATOR),NOALYSS_ADMIN_PASSWORD)); + + if ( DEBUGNOALYSS == 0 ) ob_end_clean(); + echo '

'._('Important').'

'; echo '

'._('Utilisateur administrateur'),' ',NOALYSS_ADMINISTRATOR,'

'; diff --git a/include/ajax/ajax_action_concerned_list.php b/include/ajax/ajax_action_concerned_list.php index 55548a1a2..357a8b9c0 100644 --- a/include/ajax/ajax_action_concerned_list.php +++ b/include/ajax/ajax_action_concerned_list.php @@ -51,7 +51,7 @@ echo HtmlInput::button_anchor(_("Export CSV"), $csv,"",' title="Export Contacts echo HtmlInput::button_close("action_concerned_list_dv"); $response = ob_get_clean(); -if ( headers_sent() && DEBUG) { +if ( headers_sent() && DEBUGNOALYSS > 0) { echo $response; } $html = escape_xml($response); @@ -63,4 +63,4 @@ echo <<$html EOF; -?> \ No newline at end of file +?> diff --git a/include/ajax/ajax_action_remove_concerned.php b/include/ajax/ajax_action_remove_concerned.php index 08251710e..a07e00afc 100644 --- a/include/ajax/ajax_action_remove_concerned.php +++ b/include/ajax/ajax_action_remove_concerned.php @@ -60,7 +60,7 @@ echo $follow->button_action_add_concerned_card( ); $response = ob_get_clean(); -if (headers_sent() && DEBUG) { +if (headers_sent() && DEBUGNOALYSS > 0) { echo $response; } $html = escape_xml($response); @@ -72,4 +72,4 @@ echo <<$html EOF; -?> \ No newline at end of file +?> diff --git a/include/ajax/ajax_admin.php b/include/ajax/ajax_admin.php index 6e958fea3..44e8d012a 100644 --- a/include/ajax/ajax_admin.php +++ b/include/ajax/ajax_admin.php @@ -354,10 +354,10 @@ if ($op=='upgradeCore') $progress->set_value(5); $core->download(); $progress->set_value(55); - if (!DEBUG ) + if ( DEBUGNOALYSS > 0 ) { $core->install(); - } + } $progress->set_value(100); $url=sprintf(' install.php', NOALYSS_URL."/install.php"); @@ -414,4 +414,4 @@ if ($op=="installTemplate") echo _("Modèle installé"); return; } -?> \ No newline at end of file +?> diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index 809ac727e..d4acd9d93 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -288,7 +288,7 @@ case 'st': if ( empty($array)) { $html=_("Aucune catégorie de fiche ne correspond à votre demande"); - if ( DEBUG ) $html.=$sql; + if ( DEBUGNOALYSS > 0 ) $html.=$sql; } else { @@ -793,7 +793,7 @@ case 'upr': } // switch $xml=escape_xml($html); -if (DEBUG && headers_sent()) { +if (DEBUGNOALYSS > 0 && headers_sent()) { echo $html;return; } header('Content-type: text/xml; charset=UTF-8'); diff --git a/include/ajax/ajax_history.php b/include/ajax/ajax_history.php index 2951e102e..26d58b986 100644 --- a/include/ajax/ajax_history.php +++ b/include/ajax/ajax_history.php @@ -221,7 +221,7 @@ if ( isset($_REQUEST['pcm_val'])) } } $xml=escape_xml($html); -if (DEBUG && headers_sent()) { +if (DEBUGNOALYSS > 0 && headers_sent()) { echo $html;return; } header('Content-type: text/xml; charset=UTF-8'); diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php index d9ac3ec99..16ee64f1f 100644 --- a/include/ajax/ajax_ledger.php +++ b/include/ajax/ajax_ledger.php @@ -514,7 +514,7 @@ case 'save': catch (Exception $e) { record_log($e); - if ( DEBUG ) echo $e->getMessage(); + if ( DEBUGNOALYSS > 0 ) echo $e->getMessage(); alert(_( "Changement impossible: on ne peut pas changer la date dans une période fermée")); } $html=ob_get_contents(); diff --git a/include/ajax/ajax_operation_tag.php b/include/ajax/ajax_operation_tag.php index 7c0a0d21f..c44451364 100644 --- a/include/ajax/ajax_operation_tag.php +++ b/include/ajax/ajax_operation_tag.php @@ -67,7 +67,7 @@ switch ($op) echo HtmlInput::button_close("tag_div"); $response=ob_get_clean(); - if (headers_sent()&&DEBUG) + if (headers_sent()&& DEBUGNOALYSS > 0 ) { echo $response; } @@ -116,7 +116,7 @@ EOF; $tag_operation->tag_cell($ctl); $response=ob_get_clean(); - if (headers_sent()&&DEBUG) + if (headers_sent()&& DEBUGNOALYSS > 0) { echo $response; } @@ -145,7 +145,7 @@ EOF; $tag_operation->tag_cell($pref); $response=ob_get_clean(); - if (headers_sent()&&DEBUG) + if (headers_sent()&& DEBUGNOALYSS > 0) { echo $response; } @@ -163,4 +163,4 @@ EOF; EOF; return; break; -} \ No newline at end of file +} diff --git a/include/ajax/ajax_poste.php b/include/ajax/ajax_poste.php index 899dbadb8..8ecaaa6a1 100644 --- a/include/ajax/ajax_poste.php +++ b/include/ajax/ajax_poste.php @@ -152,7 +152,7 @@ case "sf": break; } $xml=escape_xml($html); -if (headers_sent() && DEBUG ) { +if (headers_sent() && DEBUGNOALYSS > 0) { echo $html; } else diff --git a/include/ajax/ajax_tag_detail.php b/include/ajax/ajax_tag_detail.php index 7f2a9cc27..a05bb3e80 100644 --- a/include/ajax/ajax_tag_detail.php +++ b/include/ajax/ajax_tag_detail.php @@ -45,7 +45,7 @@ else : 0 ) { echo $response; }else { header('Content-type: text/xml; charset=UTF-8'); @@ -59,4 +59,4 @@ if (headers_sent() && DEBUG ) { EOF; exit(); - ?> \ No newline at end of file + ?> diff --git a/include/ajax/ajax_tag_list.php b/include/ajax/ajax_tag_list.php index 794b21a88..0babe10a0 100644 --- a/include/ajax/ajax_tag_list.php +++ b/include/ajax/ajax_tag_list.php @@ -35,7 +35,7 @@ if ( $g_user->check_action(TAGADD) == 1) { echo HtmlInput::button("tag_add", _(" echo HtmlInput::button_close("tag_div"); $response= ob_get_clean(); -if (headers_sent() && DEBUG ){ +if (headers_sent() && DEBUGNOALYSS > 0 ){ echo $response; } else { header('Content-type: text/xml; charset=UTF-8'); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 3a4c5ba44..99a540535 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -773,12 +773,12 @@ class Acc_Ledger_Purchase extends Acc_Ledger $operation_currency->insert(); $tot_amount_cur=round(bcadd($tot_amount_cur,$acc_amount->amount_currency),2); $tot_amount_cur=round(bcadd($tot_amount_cur,$acc_amount->amount_vat_currency),2); - if (DEBUG ) { + if ( DEBUGNOALYSS > 0 ) { echo __LINE__." insert into operation currency oc_amount:{$acc_amount->amount_currency} oc_vat_amount {$acc_amount->amount_vat_currency}
"; } } // end loop : save all items /* save total customer */ - if ( DEBUG ) { + if ( DEBUGNOALYSS > 0 ) { echo __LINE__." tot_amount $tot_amount
"; echo __LINE__." tot_tva $tot_tva
"; @@ -861,7 +861,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger // Total DEB $acc_operation->amount=$this->db->get_value("select sum(j_montant) from jrnx where j_grpt = $1 and j_debit='t'", array($seq)); - if ( DEBUG ) { + if ( DEBUGNOALYSS > 0 ) { echo __LINE__." amount ".$acc_operation->amount."
"; } diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index a86b4fbe6..bc713a6f0 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -314,7 +314,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $tot_amount = bcadd($tot_amount, $amount); $tot_amount = round($tot_amount, 2); - if ( DEBUG ) { echo __LINE__." tot_amount $tot_amount
";} + if ( DEBUGNOALYSS > 0 ) { echo __LINE__." tot_amount $tot_amount
";} $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; $sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT); @@ -462,7 +462,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { /* save total customer */ $cust_amount = bcadd($tot_amount, $tot_tva); $cust_amount = round($cust_amount,2); - if ( DEBUG ) { + if ( DEBUGNOALYSS > 0 ) { echo __LINE__." cust_amount $cust_amount
"; echo __LINE__." tot_amount $tot_amount
"; echo __LINE__." tot_tva $tot_tva
"; @@ -499,7 +499,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { * if if ($g_parameter->MY_TVA_USE == 'Y' ) */ if ($g_parameter->MY_TVA_USE == 'Y') { - if (DEBUG ) { + if ( DEBUGNOALYSS > 0 ) { var_dump($tva); } foreach ($tva as $i => $value) { @@ -524,7 +524,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $tot_debit=round($tot_debit, 2); } $acc_operation->insert_jrnx(); - if ( DEBUG ) { + if ( DEBUGNOALYSS > 0 ) { echo __LINE__." tot_tva $tot_tva
"; } @@ -553,7 +553,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { */ /* insert into jrn */ - if ( DEBUG ) { echo __LINE__." tot_debit ".round($tot_debit,2)."
"; } + if ( DEBUGNOALYSS > 0 ) { echo __LINE__." tot_debit ".round($tot_debit,2)."
"; } $acc_operation = new Acc_Operation($this->db); $acc_operation->date = $e_date; $acc_operation->echeance = $e_ech; diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index 9b0ae6cf5..314c1a125 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -187,7 +187,7 @@ class Acc_Operation { $this->type=($this->type=='d')?'c':'d'; } - if ( DEBUG ) { + if ( DEBUGNOALYSS > 0 ) { echo "insert_jrnx = [{ $this->poste}] {$this->amount} rounded ".round($this->amount,2)." type {$this->type}
"; } $this->amount=abs($this->amount); @@ -284,7 +284,7 @@ class Acc_Operation function insert_jrn() { $p_comment=$this->desc; - if (DEBUG ) { + if ( DEBUGNOALYSS > 0 ) { echo "insert_jrn = {$this->amount}
"; } $diff=$this->db->get_value("select check_balance ($1)",array($this->grpt)); diff --git a/include/class/anc_key.class.php b/include/class/anc_key.class.php index 4fec773ed..a040e5090 100644 --- a/include/class/anc_key.class.php +++ b/include/class/anc_key.class.php @@ -267,7 +267,7 @@ class Anc_Key catch (Exception $e) { - if ( DEBUG ) { echo $e->getTraceAsString(); } else { echo _('erreur').$e->getMessage();} + if ( DEBUGNOALYSS > 0 ) { echo $e->getTraceAsString(); } else { echo _('erreur').$e->getMessage();} record_log($e); $cn->rollback(); } diff --git a/include/class/database.class.php b/include/class/database.class.php index 30da3f448..7d6808d27 100644 --- a/include/class/database.class.php +++ b/include/class/database.class.php @@ -147,7 +147,7 @@ class Database extends DatabaseCore $this->execute_script(NOALYSS_INCLUDE . '/sql/patch/upgrade' . $i . '.sql'); echo $succeed; - if (!DEBUG) + if ( DEBUGNOALYSS == 0) ob_start(); // specific for version 4 if ($i == 4) { @@ -224,7 +224,7 @@ class Database extends DatabaseCore $this->execute_script(NOALYSS_INCLUDE . "/sql/patch/upgrade141." . $country . ".sql"); } - if (!DEBUG) + if (DEBUGNOALYSS == 0 ) ob_end_clean(); } diff --git a/include/class/dossier.class.php b/include/class/dossier.class.php index 031f91573..d82f2cebb 100644 --- a/include/class/dossier.class.php +++ b/include/class/dossier.class.php @@ -349,7 +349,7 @@ class Dossier //---------------------------------------------------------------------- echo "

"._("Mise à jour de la base de données principale")."

"; $cn=new Database(); - if (DEBUG==false) + if (DEBUGNOALYSS == 0) ob_start(); $MaxVersion=DBVERSIONREPO-1; for ($i=4; $i<=$MaxVersion; $i++) @@ -359,7 +359,7 @@ class Dossier $cn->execute_script(NOALYSS_INCLUDE.'/sql/patch/ac-upgrade'.$i.'.sql'); } } - + if (DEBUGNOALYSS == 0) ob_end_clean(); //---------------------------------------------------------------------- // Upgrade the folders //---------------------------------------------------------------------- diff --git a/include/constant.php b/include/constant.php index 099249552..672e3de17 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,9 +88,10 @@ define ('SMALLX','×'); define ('BUTTONADD',"✚"); define ('SVNINFO',NOALYSS_VERSION); -if ( ! defined ('DEBUG')) { - define ("DEBUG",false); +if ( ! defined ('DEBUGNOALYSS')) { + define ("DEBUGNOALYSS",0); } + if ( ! defined ('LOGINPUT')) { define ("LOGINPUT",false); } @@ -132,21 +133,31 @@ if ( ! defined ('MAX_SEARCH_CARD') ) { define ('MAX_FOLDER_TO_SHOW',80); define ('MAX_ACTION_SHOW',20); -if ( DEBUG ) { +if ( DEBUGNOALYSS == 0 ) { + // PRODUCTION : nothing is displaid , report only errors and warning + // Rapporte les erreurs d'exécution de script + error_reporting(E_ERROR | E_WARNING ); + ini_set("display_errors",0); + ini_set("html_errors",0); + ini_set('log_errors',1); + ini_set('log_errors_max_len',0); +}elseif (DEBUGNOALYSS==1) { + /* DEVELOPPEMENT : display all errors warning notice deprecated ...*/ error_reporting(2147483647); ini_set("display_errors",1); ini_set("display_startup_errors",1); ini_set("html_errors",1); ini_set('log_errors',1); ini_set('log_errors_max_len',0); -} -else { - // Rapporte les erreurs d'exécution de script - error_reporting(E_ERROR | E_WARNING | E_PARSE|E_NOTICE); - ini_set("display_errors",0); - ini_set("html_errors",0); +} elseif (DEBUGNOALYSS == 2 ) { + // like level 1 plus extra info (filename, ...) + error_reporting(2147483647); + ini_set("display_errors",1); + ini_set("display_startup_errors",1); + ini_set("html_errors",1); ini_set('log_errors',1); ini_set('log_errors_max_len',0); + } // Erreur define ("NOERROR",0); @@ -339,4 +350,4 @@ if ( ! defined ("NOALYSS_URL")) { } if (!defined ("DEFAULT_SERVER_VIDEO_CONF")) { define ("DEFAULT_SERVER_VIDEO_CONF","https://www.free-solutions.org/"); -} \ No newline at end of file +} diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 04823f2d9..6c9a2d369 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -1180,7 +1180,11 @@ function display_menu($p_menuid) } tracedebug("'menu", $file[0]['me_file'],__FUNCTION__.__LINE__."line"); tracedebug("'menu", $file[0]['me_parameter'],__FUNCTION__.__LINE__."parm "); - if ( DEBUG ) { echo $file[0]['me_file']," param : ",$file[0]['me_parameter'] ;} + if ( DEBUGNOALYSS == 2) + { + echo $file[0]['me_file']," param : ",$file[0]['me_parameter'] ; + + } /* * Log the file we input to put in the folder test-noalyss for replaying it */ diff --git a/include/lib/config_file.php b/include/lib/config_file.php index b70da1715..36e41ebe9 100644 --- a/include/lib/config_file.php +++ b/include/lib/config_file.php @@ -172,7 +172,19 @@ function display_file_config($p_array,$from_setup=1,$p_os=1) print ( 'define ("LOCALE",'.$clocale.');'); print ("\r\n"); - + echo <<db = pg_connect("dbname=$p_dbname host='$p_host' user='$p_user' password='$p_password' port=$p_port"); if ($this->db == false) { - if (DEBUG) { + if ( DEBUGNOALYSS > 0 ) { echo '

'._('Impossible de se connecter à postgreSql').'

'; echo '

'; @@ -160,7 +160,7 @@ class DatabaseCore $this->array = $p_array; if ($p_array == null) { - if (!DEBUG) + if ( DEBUGNOALYSS == 0 ) $this->ret = pg_query($this->db, $p_string); else $this->ret = @pg_query($this->db, $p_string); @@ -169,7 +169,7 @@ class DatabaseCore if (!is_array($p_array)) { throw new Exception(_("Erreur : exec_sql attend un array")); } - if (!DEBUG) + if ( DEBUGNOALYSS == 0 ) $this->ret =@pg_query_params($this->db, $p_string, $p_array); else $this->ret = pg_query_params($this->db, $p_string, $p_array); @@ -179,7 +179,7 @@ class DatabaseCore throw new Exception(" SQL ERROR $p_string " . $str_error, 1); } } catch (Exception $a) { - if (DEBUG) { + if ( DEBUGNOALYSS > 0 ) { print_r($p_string); print_r($p_array); echo $a->getMessage(); @@ -277,7 +277,7 @@ class DatabaseCore function execute_script($script) { - if (!DEBUG) { + if ( DEBUGNOALYSS == 0 ) { ob_start(); } else { $debug = fopen("/tmp/debug.log", "w+"); @@ -335,11 +335,11 @@ class DatabaseCore $buffer = str_replace(';', '', $buffer); } $sql .= $buffer; - if (DEBUG) fwrite($debug, $sql); + if ( DEBUGNOALYSS > 0 ) fwrite($debug, $sql); if ($this->exec_sql($sql) == false) { $this->rollback(); - if (!DEBUG) + if ( DEBUGNOALYSS == 0 ) ob_end_clean(); print "ERROR : $sql"; throw new Exception("ERROR : $sql"); @@ -349,7 +349,7 @@ class DatabaseCore print "


"; } // while (feof) fclose($hf); - if (!DEBUG) + if ( DEBUGNOALYSS == 0 ) ob_end_clean(); }