[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 03/03: 0001438: Remplacement de HtmlInput par
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 03/03: 0001438: Remplacement de HtmlInput par HttpInput |
Date: |
Sun, 11 Jun 2017 07:37:20 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit a28aea8f82d5933c7a27b46ecff4a90b48e99ab3
Author: Dany De Bontridder <address@hidden>
Date: Sun Jun 11 13:36:56 2017 +0200
0001438: Remplacement de HtmlInput par HttpInput
---
html/ajax_misc.php | 6 +-
html/do.php | 5 +-
html/install.php | 21 ++++---
include/ajax/ajax_pcmn_update.php | 108 ++++++++++++++++++--------------
include/class/class_acc_ledger.php | 18 +++---
include/class/class_acc_payment.php | 5 +-
include/class/class_anc_acc_link.php | 3 +-
include/class/class_anc_key.php | 3 +-
include/class/class_anc_operation.php | 3 +-
include/class/class_document.php | 3 +-
include/class/class_pre_op_advanced.php | 1 -
include/class/class_pre_operation.php | 4 +-
12 files changed, 106 insertions(+), 74 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index fafb003..cd2ba9d 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -44,6 +44,8 @@ require_once NOALYSS_INCLUDE.'/lib/class_iradio.php';
require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
require_once NOALYSS_INCLUDE.'/class/class_user.php';
+require_once NOALYSS_INCLUDE.'/lib/class_http_input.php';
+$http=new HttpInput();
mb_internal_encoding("UTF-8");
@@ -240,9 +242,9 @@ EOF;
/* others report */
$cal = new Calendar();
$cal->set_periode($per);
- $notitle=HtmlInput::default_value_get("notitle", 0);
+ $notitle=$http->get("notitle", "string",0);
$html = "";
- $html = $cal->display($_GET['t'],$notitle);
+ $html = $cal->display($http->get('t'),$notitle);
$html = escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
diff --git a/html/do.php b/html/do.php
index 6df0dd1..050856f 100644
--- a/html/do.php
+++ b/html/do.php
@@ -31,6 +31,9 @@ require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
require_once NOALYSS_INCLUDE.'/constant.security.php';
require_once NOALYSS_INCLUDE.'/lib/class_html_input.php';
+require_once NOALYSS_INCLUDE.'/lib/class_http_input.php';
+$http=new HttpInput();
+
mb_internal_encoding("UTF-8");
// if gDossier is not set redirect to form to choose a folder
@@ -94,7 +97,7 @@ if ( isset ($_POST['set_preference'])) {
$_SESSION['g_lang']=$lang;
$g_user->save_email($p_email);
}
-$style_user=HtmlInput::default_value_post("style_user",$_SESSION['g_theme']);
+$style_user=$http->post("style_user","string",$_SESSION['g_theme']);
html_page_start($style_user);
if ( DEBUG ) {
diff --git a/html/install.php b/html/install.php
index 073de1c..db9a07d 100644
--- a/html/install.php
+++ b/html/install.php
@@ -213,16 +213,17 @@ function create_htaccess_deprecated()
}
// Retrieve informations from the very screen
//
-$db_user=HtmlInput::default_value_request("cuser", "");
-$db_password=HtmlInput::default_value_request("cpasswd", "");
-$db_host=HtmlInput::default_value_request("chost", "");
-$db_port=HtmlInput::default_value_request("cport", "");
-$multi=HtmlInput::default_value_request("multi", "N");
-$locale=HtmlInput::default_value_request("clocale", "1");
-$ctmp=HtmlInput::default_value_request("ctmp", "/tmp");
-$cpath=HtmlInput::default_value_request("cpath", "/usr/bin");
-$db_name=HtmlInput::default_value_request("cdbname", "");
-$cadmin=HtmlInput::default_value_request("cadmin", "admin");
+$http=new HttpInput();
+$db_user=$http->request("cuser","string", "");
+$db_password=$http->request("cpasswd","string", "");
+$db_host=$http->request("chost","string", "");
+$db_port=$http->request("cport","string", "");
+$multi=$http->request("multi","string", "N");
+$locale=$http->request("clocale","string", "1");
+$ctmp=$http->request("ctmp","string", "/tmp");
+$cpath=$http->request("cpath","string", "/usr/bin");
+$db_name=$http->request("cdbname", "string","");
+$cadmin=$http->request("cadmin","string", "admin");
$cadmin=strtolower($cadmin);
//-------------------------------------------------------------------------
// warn only if we can not write in include
diff --git a/include/ajax/ajax_pcmn_update.php
b/include/ajax/ajax_pcmn_update.php
index ba4faf8..fb52736 100644
--- a/include/ajax/ajax_pcmn_update.php
+++ b/include/ajax/ajax_pcmn_update.php
@@ -1,4 +1,5 @@
<?php
+
/*
* This file is part of NOALYSS.
*
@@ -15,23 +16,23 @@
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ */
// Copyright 2015 Author Dany De Bontridder address@hidden
-
// require_once '.php';
-if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
global $g_user, $cn, $g_parameter;
// Security check if user can connect and update
-if ($g_user->check_module('CFGPCMN') == 0 )
+if ($g_user->check_module('CFGPCMN')==0)
{
- $html=h2(_('Action interdite'),' class="notice"');
- $html = escape_xml($response);
+ $html=h2(_('Action interdite'), ' class="notice"');
+ $html=escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
-echo <<<EOF
+ echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>pcmn_update</ctl>
@@ -41,55 +42,70 @@ echo <<<EOF
EOF;
return;
}
-
+$http=new HttpInput();
ob_start();
-$pcmn_val=HtmlInput::default_value_get('value', "-1");
-
-// if empty
-if ( $pcmn_val != "-1" )
+try
{
- // not set
-}
-$action='new';
-$val=new IText('p_valu');
-$parent=new IText('p_parentu');
-$lib=new IText('p_libu');
-$lib->size="60";
-$type=new ISelect('p_typeu');
-$type->value=Acc_Account::$type;
-if ( $pcmn_val != "")
-{
- $action='update';
- /*
- * Not empty, show the default value
- */
- $account = new Acc_Account($cn);
- $account->set_parameter('value',$pcmn_val);
- $account->load();
-
- $val->value=$account->get_parameter('value');
- $parent->value=$account->get_parameter('parent');
- $lib->value=$account->get_parameter('libelle');
- $type->selected=$account->get_parameter('type');
-
-}
+ $pcmn_val=$http->get('value', "string");
+
+ $action='new';
+ $val=new IText('p_valu');
+ $parent=new IText('p_parentu');
+ $lib=new IText('p_libu');
+ $lib->size="60";
+ $type=new ISelect('p_typeu');
+ $type->value=Acc_Account::$type;
-require NOALYSS_TEMPLATE.'/pcmn_update.php';
-$response = ob_get_clean();
-$html = escape_xml($response);
-if ( headers_sent() ) {
- echo $response;
- echo $html;
-} else {
+ if ($pcmn_val!="")
+ {
+ $action='update';
+ /*
+ * Not empty, show the default value
+ */
+ $account=new Acc_Account($cn);
+ $account->set_parameter('value', $pcmn_val);
+ $account->load();
+
+ $val->value=$account->get_parameter('value');
+ $parent->value=$account->get_parameter('parent');
+ $lib->value=$account->get_parameter('libelle');
+ $type->selected=$account->get_parameter('type');
+ }
+
+ require NOALYSS_TEMPLATE.'/pcmn_update.php';
+ $response=ob_get_clean();
+ $html=escape_xml($response);
+ if (headers_sent())
+ {
+ echo $response;
+ echo $html;
+ }
+ else
+ {
+ header('Content-type: text/xml; charset=UTF-8');
+ echo <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<data>
+<ctl></ctl>
+<code>$html</code>
+<status>ok</status>
+</data>
+EOF;
+ }
+}
+catch (Exception $exc)
+{
+ $html=$exc->getMessage();
+ $html=escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl></ctl>
<code>$html</code>
-<status>ok</status>
+<status>NOTALLOWED</status>
</data>
EOF;
- }
\ No newline at end of file
+}
diff --git a/include/class/class_acc_ledger.php
b/include/class/class_acc_ledger.php
index c140233..6c84ee1 100644
--- a/include/class/class_acc_ledger.php
+++ b/include/class/class_acc_ledger.php
@@ -43,6 +43,8 @@ require_once NOALYSS_INCLUDE.'/class/class_lettering.php';
require_once NOALYSS_INCLUDE.'/lib/class_sort_table.php';
require_once NOALYSS_INCLUDE.'/database/class_jrn_def_sql.php';
require_once NOALYSS_INCLUDE.'/class/class_acc_payment.php';
+require_once NOALYSS_INCLUDE.'/lib/class_http_input.php';
+
/** \file
* @brief Class for jrn, class acc_ledger for manipulating the ledger
*/
@@ -3664,13 +3666,14 @@ class Acc_Ledger extends jrn_def_sql
*/
function input_new()
{
- $retry=HtmlInput::default_value_post("sa", "");
+ $http=new HttpInput();
+ $retry=$http->post("sa","string", "");
// if ( $retry == "add") {
- $default_type=HtmlInput::default_value_post("p_jrn_type", -1);
-
$previous_jrn_def_pj_pref=HtmlInput::default_value_post("jrn_def_pj_pref","");
-
$previous_p_description=HtmlInput::default_value_post("p_description","");
-
$previous_p_jrn_name=HtmlInput::default_value_post('p_jrn_name','');
- $previous_p_jrn_type =
HtmlInput::default_value_post("p_jrn_type","");
+ $default_type=$http->post("p_jrn_type","string", -1);
+
$previous_jrn_def_pj_pref=$http->post("jrn_def_pj_pref","string","");
+
$previous_p_description=$http->post("p_description","string","");
+ $previous_p_jrn_name=$http->post('p_jrn_name',"string",'');
+ $previous_p_jrn_type = $http->post("p_jrn_type","string","");
// }
global $g_user;
$f_add_button=new ISmallButton('add_card');
@@ -3996,7 +3999,8 @@ class Acc_Ledger extends jrn_def_sql
);
echo HtmlInput::hidden("correct","copy");
// e_march
- $nb=HtmlInput::default_value_post("nb_item",0);
+ $http=new HttpInput();
+ $nb=$http->post("nb_item","number",0);
for ( $i=0;$i<$nb;$i++)
{
echo HtmlInput::post_to_hidden(
diff --git a/include/class/class_acc_payment.php
b/include/class/class_acc_payment.php
index 3700fd9..801c234 100644
--- a/include/class/class_acc_payment.php
+++ b/include/class/class_acc_payment.php
@@ -29,6 +29,8 @@ require_once NOALYSS_INCLUDE.'/class/class_acc_ledger.php';
require_once NOALYSS_INCLUDE.'/class/class_fiche.php';
require_once NOALYSS_INCLUDE.'/class/class_fiche_def.php';
require_once NOALYSS_INCLUDE.'/constant.php';
+require_once NOALYSS_INCLUDE.'/lib/class_http_input.php';
+
/*!\brief Handle the table mod_payment
*\note the private data member are accessed via
- mp_id ==> id ( Primary key )
@@ -302,6 +304,7 @@ class Acc_Payment
$r.='<ol>';
$r.='<li ><input type="radio" name="e_mp" value="0"
checked>'._('Paiement encodé plus tard');
+ $http=new HttpInput();
if ( empty($array ) == false )
{
foreach ($array as $row)
@@ -321,7 +324,7 @@ class Acc_Payment
$a->set_attribute('ipopup','ipopcard');
$a->set_attribute('label',$a->name.'_label');
if ( $p_select == $row->mp_id ) {
-
$a->value=HtmlInput::default_value_request("e_mp_qcode_".$p_select, "");
+ $a->value=$http->request("e_mp_qcode_".$p_select,
"string","");
}
$s=new ISpan();
$s->name=$a->name.'_label';
diff --git a/include/class/class_anc_acc_link.php
b/include/class/class_anc_acc_link.php
index 4adbcc8..7e490b1 100644
--- a/include/class/class_anc_acc_link.php
+++ b/include/class/class_anc_acc_link.php
@@ -37,7 +37,8 @@ class Anc_Acc_Link extends Anc_Print
function get_request()
{
parent::get_request();
- $this->card_poste=HtmlInput::default_value('card_poste',1,$_GET);
+ $http=new HttpInput();
+ $this->card_poste=$http->get('card_poste',"string",1);
}
function set_sql_filter()
{
diff --git a/include/class/class_anc_key.php b/include/class/class_anc_key.php
index 1ef4047..11cd371 100644
--- a/include/class/class_anc_key.php
+++ b/include/class/class_anc_key.php
@@ -213,7 +213,8 @@ class Anc_Key
$cn->start();
// for each row
$a_row=$p_array['row'];
- $a_ledger=HtmlInput::default_value("jrn",array(),$p_array);
+ $http=new HttpInput();
+ $a_ledger=$http->extract($p_array,"jrn","string",array());
$a_percent=$p_array['percent'];
$a_po_id=$p_array['po_id'];
$a_plan=$p_array['pa'];
diff --git a/include/class/class_anc_operation.php
b/include/class/class_anc_operation.php
index 119a2bd..7d9dd62 100644
--- a/include/class/class_anc_operation.php
+++ b/include/class/class_anc_operation.php
@@ -632,7 +632,8 @@ class Anc_Operation
* Add a button for distribution key
*
*/
- $ledger=HtmlInput::default_value_post("p_jrn", 0);
+ $http=new HttpInput();
+ $ledger=$http->post("p_jrn", "string",0);
if ($ledger==0) {
$ledger=$this->db->get_value('select j_jrn_def from jrnx where
j_id=$1',array($this->j_id));
}
diff --git a/include/class/class_document.php b/include/class/class_document.php
index 07ace7b..55c025e 100644
--- a/include/class/class_document.php
+++ b/include/class/class_document.php
@@ -1178,7 +1178,8 @@ class Document
$ret=$this->db->get_value('select r_phone from
public.stock_repository where r_id=$1',array($p_array['repo']));
return $ret;
case 'TITLE':
- $title=HtmlInput::default_value_request("ag_title", "");
+ $http=new HttpInput();
+ $title=$http->request("ag_title","string", "");
return $title;
case 'COMM_PAYMENT':
if ( isset($p_array["e_comm_paiement"])) {
diff --git a/include/class/class_pre_op_advanced.php
b/include/class/class_pre_op_advanced.php
index a728e39..97b0bf2 100644
--- a/include/class/class_pre_op_advanced.php
+++ b/include/class/class_pre_op_advanced.php
@@ -39,7 +39,6 @@ class Pre_Op_Advanced extends Pre_operation_detail
{
parent::get_post();
- extract($_POST, EXTR_SKIP);
for ($i=0;$i<$this->operation->nb_item;$i++)
{
diff --git a/include/class/class_pre_operation.php
b/include/class/class_pre_operation.php
index fd92697..f3e7ad7 100644
--- a/include/class/class_pre_operation.php
+++ b/include/class/class_pre_operation.php
@@ -87,8 +87,8 @@ class Pre_operation
}
function delete ()
{
- $sql="delete from op_predef where od_id=".$this->od_id;
- $this->db->exec_sql($sql);
+ $sql="delete from op_predef where od_id=$1";
+ $this->db->exec_sql($sql,array($this->od_id));
}
/*!\brief save the predef check first is the name is unique
* \return true op.success otherwise false