[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 01/04: Task #1044 - Implementation de Test Te
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 01/04: Task #1044 - Implementation de Test Test files : ajout ajax |
Date: |
Sat, 15 Nov 2014 17:46:53 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 0b4ecc56a7475376aa589bd12567b71b2dc40904
Author: Dany De Bontridder <address@hidden>
Date: Sat Nov 15 17:04:09 2014 +0100
Task #1044 - Implementation de Test
Test files : ajout ajax
---
html/ajax_card.php | 28 ++++++++++++--
html/ajax_history.php | 29 ++++++++++++--
html/ajax_ledger.php | 22 ++++++++++-
html/ajax_misc.php | 21 ++++++++++-
html/ajax_poste.php | 22 ++++++++++-
html/test.php | 99 ++++++++++++++++++++++++++----------------------
6 files changed, 163 insertions(+), 58 deletions(-)
diff --git a/html/ajax_card.php b/html/ajax_card.php
index ed34e23..00a21f0 100644
--- a/html/ajax_card.php
+++ b/html/ajax_card.php
@@ -53,7 +53,7 @@
* - ref if we want to refresh the window
*\see fiche fiche::Save constant.php
*/
-define ('ALLOWED',1);
+if ( ! defined('ALLOWED')) define ('ALLOWED',1);
require_once '../include/constant.php';
require_once('class_database.php');
@@ -94,6 +94,24 @@ $g_user=new User($cn);
$g_user->check(true);
$g_user->check_dossier($gDossier,true);
$html=var_export($_REQUEST,true);
+if ( LOGINPUT)
+ {
+
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
+ fwrite ($file_loginput,"<?php \n");
+ fwrite ($file_loginput,'//@description:'.$op."\n");
+ fwrite($file_loginput, '$_GET='.var_export($_GET,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST='.var_export($_POST,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
+ fclose($file_loginput);
+ }
switch($op)
{
/* ------------------------------------------------------------ */
@@ -519,13 +537,15 @@ case 'upc':
}
}
} // switch
-$html=escape_xml($html);
-
+$xml=escape_xml($html);
+if (DEBUG && headers_sent()) {
+ echo $html;return;
+}
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>$ctl</ctl>
-<code>$html</code>
+<code>$xml</code>
</data>
EOF;
diff --git a/html/ajax_history.php b/html/ajax_history.php
index cf2169e..3ff482c 100644
--- a/html/ajax_history.php
+++ b/html/ajax_history.php
@@ -23,6 +23,8 @@
* \brief show the history of a card of an accounting
* for the card f_id is set and for an accounting : pcm_val
*/
+if ( ! defined('ALLOWED')) define ('ALLOWED',1);
+
require_once '../include/constant.php';
require_once('class_database.php');
require_once('class_user.php');
@@ -33,7 +35,6 @@ require_once('class_acc_account.php');
require_once('class_exercice.php');
$div=$_REQUEST['div'];
mb_internal_encoding("UTF-8");
-define ('ALLOWED',1);
/**
*if $_SESSION['g_user'] is not set : echo a warning
@@ -46,7 +47,24 @@ $g_user=new User($cn);
if ( $g_user->check_dossier(dossier::id(),true) == 'X' ) exit();
$from_div = (isset($_REQUEST['ajax'])) ? 1 : $_GET['l'];
-
+if ( LOGINPUT)
+ {
+
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
+ fwrite ($file_loginput,"<?php \n");
+ fwrite ($file_loginput,"//@description:\n");
+ fwrite($file_loginput, '$_GET='.var_export($_GET,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST='.var_export($_POST,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
+ fclose($file_loginput);
+ }
///////////////////////////////////////////////////////////////////////////
/* first detail for a card */
///////////////////////////////////////////////////////////////////////////
@@ -189,12 +207,15 @@ if ( isset($_REQUEST['pcm_val']))
ob_end_clean();
}
}
-$html=escape_xml($html);
+$xml=escape_xml($html);
+if (DEBUG && headers_sent()) {
+ echo $html;return;
+}
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>$div</ctl>
-<code>$html</code>
+<code>$xml</code>
</data>
EOF;
diff --git a/html/ajax_ledger.php b/html/ajax_ledger.php
index a28aa3a..2c319c7 100644
--- a/html/ajax_ledger.php
+++ b/html/ajax_ledger.php
@@ -28,7 +28,8 @@
- for reconcialiation
- update of analytic content
*/
-define ('ALLOWED',1);
+if ( ! defined('ALLOWED')) define ('ALLOWED',1);
+
require_once '../include/constant.php';
require_once('class_database.php');
require_once('class_user.php');
@@ -63,7 +64,24 @@ ajax_disconnected($div);
$cn=new Database(dossier::id());
$g_parameter=new Own($cn);
-
+if ( LOGINPUT)
+ {
+
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
+ fwrite ($file_loginput,"<?php \n");
+ fwrite ($file_loginput,'//@description:'.$action."\n");
+ fwrite($file_loginput, '$_GET='.var_export($_GET,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST='.var_export($_POST,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
+ fclose($file_loginput);
+ }
// check if the user is valid and can access this folder
global $g_user;
$g_user=new User($cn);
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 57119fb..490e4d0 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -34,7 +34,8 @@
* dl : display form to modify, add and delete lettering for a given operation
*
*/
-define ('ALLOWED',1);
+if ( ! defined('ALLOWED')) define ('ALLOWED',1);
+
require_once '../include/constant.php';
require_once('class_database.php');
require_once ('class_fiche.php');
@@ -69,6 +70,24 @@ if ($gDossier<>0) {
}
$html = var_export($_REQUEST, true);
+if ( LOGINPUT)
+ {
+
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
+ fwrite ($file_loginput,"<?php \n");
+ fwrite ($file_loginput,'//@description:'.$op."\n");
+ fwrite($file_loginput, '$_GET='.var_export($_GET,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST='.var_export($_POST,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
+ fclose($file_loginput);
+ }
switch ($op)
{
case "remove_anc":
diff --git a/html/ajax_poste.php b/html/ajax_poste.php
index 7001651..faa61f2 100644
--- a/html/ajax_poste.php
+++ b/html/ajax_poste.php
@@ -32,7 +32,8 @@
*
*
*/
-define ('ALLOWED',1);
+if ( ! defined('ALLOWED')) define ('ALLOWED',1);
+
require_once '../include/constant.php';
require_once ("ac_common.php");
require_once('class_acc_ledger.php');
@@ -65,7 +66,24 @@ $g_user=new User($cn);
$g_user->Check();
if ($g_user->check_dossier(dossier::id()) == 'X') exit();
$xml="";
-
+if ( LOGINPUT)
+ {
+
$file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
+ fwrite ($file_loginput,"<?php \n");
+ fwrite ($file_loginput,'//@description:'.$op."\n");
+ fwrite($file_loginput, '$_GET='.var_export($_GET,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST='.var_export($_POST,true));
+ fwrite($file_loginput,";\n");
+ fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
+ fwrite($file_loginput,"\n");
+ fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
+ fclose($file_loginput);
+ }
switch ($op)
{
/*----------------------------------------------------------------------
diff --git a/html/test.php b/html/test.php
index 76774e4..2dc2fb5 100644
--- a/html/test.php
+++ b/html/test.php
@@ -58,6 +58,36 @@ if (!file_exists('authorized_debug'))
}
define('ALLOWED', 1);
html_page_start();
+
+/*
+ * Loading of all scenario
+ */
+$scan=scandir('../scenario/');
+$maxscan=count($scan);
+$cnt_scenario=0;$scenario=array();
+
+for ($e_scan=0; $e_scan<$maxscan; $e_scan++)
+ {
+ if (is_file('../scenario/'.$scan[$e_scan])&&strpos($scan[$e_scan],
'.php')==true)
+ {
+ $description="";
+ $a_description=file('../scenario/'.$scan[$e_scan]);
+ $max_description=count($a_description);
+ for ($w=0; $w<$max_description; $w++)
+ {
+ if (strpos($a_description[$w], '@description:')==true)
+ {
+ $description=$a_description[$w];
+ $description=str_replace('//@description:', '',
$description);
+ }
+ }
+ $scenario[$cnt_scenario]['file']=$scan[$e_scan];
+ $scenario[$cnt_scenario]['desc']=$description;
+ $cnt_scenario++;
+
+
+ }
+ }
$script=HtmlInput::default_value_get('script', '');
if ($script=="")
{
@@ -66,8 +96,7 @@ if ($script=="")
* cherche pour fichier a include, s'il y en a alors les affiche
* avec une description
*/
- $scan=scandir('../scenario/');
- $max=count($scan);
+
echo '<table>';
$get='test.php?'.http_build_query(array('script'=>"all",
'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts"));
@@ -80,62 +109,36 @@ if ($script=="")
echo '<td>Tous les scripts</td>';
echo '</tr>';
- for ($e=0; $e<$max; $e++)
+ for ($e=0; $e<$cnt_scenario; $e++)
{
- if (is_file('../scenario/'.$scan[$e])&&strpos($scan[$e], '.php')==true)
- {
- $description="";
- $a_description=file('../scenario/'.$scan[$e]);
- $max_description=count($a_description);
- for ($w=0; $w<$max_description; $w++)
- {
- if (strpos($a_description[$w], '@description:')==true)
- {
- $description=$a_description[$w];
- $description=str_replace('//@description:', '',
$description);
- }
- }
- $get='test.php?'.http_build_query(array('script'=>$scan[$e],
'gDossier'=>$gDossierLogInput, 'description'=>$description));
+
+
$get='test.php?'.http_build_query(array('script'=>$scenario[$e]['file'],
'gDossier'=>$gDossierLogInput, 'description'=>$scenario[$e]['desc']));
echo '<tr>';
echo '<td>';
+ echo $e;
+ echo '</td>';
+ echo '<td>';
echo '<a href="'.$get.'" target="_blank">';
- echo $scan[$e];
+ echo $scenario[$e]['file'];
echo '</a>';
echo '</td>';
- echo '<td>'.$description.'</td>';
+ echo '<td>'.$scenario[$e]['desc'].'</td>';
echo '</tr>';
- }
+
}
echo '</table>';
}
else if ($script=='all')
{
- $scan=scandir('../scenario/');
- $maxscan=count($scan);
-
- echo '<table>';
- for ($e_scan=0; $e_scan<$maxscan; $e_scan++)
- {
- if (is_file('../scenario/'.$scan[$e_scan])&&strpos($scan[$e_scan],
'.php')==true)
- {
- $description="";
- $a_description=file('../scenario/'.$scan[$e_scan]);
- $max_description=count($a_description);
- for ($w=0; $w<$max_description; $w++)
- {
- if (strpos($a_description[$w], '@description:')==true)
- {
- $description=$a_description[$w];
- $description=str_replace('//@description:', '',
$description);
- }
- }
+ $nb=HtmlInput::default_value_get('nb_script', 0);
+
$start_mem=memory_get_usage();
$start_time=microtime(true);
$script=str_replace('../', '', $script);
-
- echo '<h1>'.$script."</h1>";
- echo '<h2> description = '.$description.'</h2>';
- include '../scenario/'.$scan[$e_scan];
+
+ echo '<h1>'.$nb." ".$scenario[$nb]['file']."</h1>";
+ echo '<h2> description = '.$scenario[$nb]["desc"].'</h2>';
+ include '../scenario/'.$scenario[$nb]['file'];
echo '</div>';
echo '</div>';
$end_mem=memory_get_usage();
@@ -150,8 +153,14 @@ else if ($script=='all')
echo "<p>Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))."
Mbytes ";
echo '</p>';
echo "<p>Execution script ".$script." time =
".(round(($end_time-$start_time), 4))." secondes</p>";
- }
- }
+ $nb++;
+ if ( $nb == $maxscan ) {
+ echo "Dernier test";
+ } else {
+ $get='test.php?'.http_build_query(array('script'=>"all",
'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb));
+ echo '<a href="'.$get.'" target="_blank">';
+ echo $scenario[$nb]['file'];
+ }
}
else
{