code cleaning and replace $_SERVER['SCRIPT_FILENAME'] by $_SERVER['PHP_SELF']

SCRIPT_FILENAME in a FPM environment is the CGI script
This commit is contained in:
sparkyx 2021-01-12 11:11:11 +01:00
parent 986e1a10b9
commit c7c518a19d
12 changed files with 1242 additions and 1092 deletions

View file

@ -96,7 +96,7 @@ if (isset($_POST['generate']))
}
else
{
$act->Update();
$act->update();
}
$doc_mod=$http->post('doc_mod',"number");
$act->generate_document($doc_mod, $_POST);
@ -117,12 +117,12 @@ if (isset($_POST['corr']))
// if this page is called from another menu (customer, supplier,...)
// a button back is added
//----------------------------------------------------------------------
// Update the detail
// update the detail
// Add a new action related to this one or update
//----------------------------------------------------------------------
if ($sub_action == "update")
{
// Update the modification
// update the modification
if (isset($_POST['save']))
{
$act2 = new Follow_Up($cn);
@ -138,7 +138,7 @@ if ($sub_action == "update")
put_global(array(array('key' => "sa", "value" => "detail")));
try {
$act2->verify() ;
$act2->Update() ;
$act2->update() ;
}
catch (Exception $e)
{

View file

@ -38,7 +38,7 @@ require_once NOALYSS_INCLUDE.'/class/user.class.php';
// display a search box
$base=basename($_SERVER['SCRIPT_NAME']);
$base=basename($_SERVER['PHP_SELF']);
$inside=false;
$tiers=$http->get("tiers", "string", "");
// With the amount id, we find the amount in a html elt

View file

@ -791,7 +791,6 @@ class Acc_Ledger extends jrn_def_sql
$op=new Pre_operation( $this->db);
$op->set_p_jrn($this->id);
$op->set_jrn_type("ODS");
$op->set_od_direct('t');
$url=http_build_query(
array('action'=>'use_opd',
@ -1652,7 +1651,7 @@ class Acc_Ledger extends jrn_def_sql
$filename="";
$doc->Generate($p_array, $p_array['e_pj']);
// Move the document to the jrn
$doc->MoveDocumentPj($internal);
$doc->moveDocumentPj($internal);
// Update the comment with invoice number, if the comment is empty
if (!isset($e_comm)||strlen(trim($e_comm))==0)
{

File diff suppressed because it is too large Load diff

View file

@ -53,14 +53,49 @@ class Fiche
var $fiche_def_ref; /*!< $fiche_def_ref Type */
var $row; /*! < All the row from the ledgers */
var $quick_code; /*!< quick_code of the card */
private $f_enable; /*!< if card is enable (fiche.f_enable) */
function __construct($p_cn,$p_id=0)
{
$this->cn=$p_cn;
$this->id=$p_id;
$this->quick_code='';
$this->attribut=array();
$f_enable='1';
}
/**
public function get_id()
{
return $this->id;
}
public function get_fiche_def_ref()
{
return $this->fiche_def_ref;
}
public function get_f_enable()
{
return $this->f_enable;
}
public function set_id($id)
{
$this->id=$id;
return $this;
}
public function set_fiche_def_ref($fiche_def_ref)
{
$this->fiche_def_ref=$fiche_def_ref;
return $this;
}
public function set_f_enable($f_enable)
{
$this->f_enable=$f_enable;
return $this;
}
/**
*@brief used with a usort function, to sort an array of Fiche on the name
*/
static function cmp_name(Fiche $o1,Fiche $o2)
@ -168,6 +203,7 @@ class Fiche
{
$row=Database::fetch_array($Ret,$i);
$this->fiche_def=$row['fd_id'];
$this->f_enable=$row['f_enable'];
$t=new Fiche_Attr ($this->cn);
$t->ad_id=$row['ad_id'];
$t->ad_text=$row['ad_text'];
@ -581,7 +617,7 @@ class Fiche
{
return 'FNT';
}
/* for each attribute */
foreach ($attr as $r)
{
@ -749,7 +785,16 @@ class Fiche
}
$ret.="<TR>".td(_($r->ad_text).$bulle,'class="'.$class.'"').td($w->input()." ".$msg)." </TR>";
}
// Display if the card is enable or not
$enable_is=new InputSwitch("f_enable");
$enable_is->value=$this->f_enable;
$enable_is->readOnly=$p_readonly;
$ret.=tr(
td(_("Actif")).td($enable_is->input())
);
$ret.="</table>";
return $ret;
@ -801,9 +846,10 @@ class Fiche
try
{
$this->cn->start();
$sql=sprintf("insert into fiche(f_id,fd_id)".
" values (%d,%d)", $fiche_id, $p_fiche_def);
$Ret=$this->cn->exec_sql($sql);
$Ret=$this->cn->exec_sql("insert into fiche(f_id,f_enable,fd_id) value ($1,$2,$3)",
array($fiche_id, $p_array['f_enable'],$p_fiche_def));
// parse the $p_array array
foreach ($p_array as $name=> $value)
{
@ -961,6 +1007,9 @@ class Fiche
try
{
$this->cn->start();
$this->cn->exec_sql("update fiche set f_enable=$1 where f_id=$2",array($p_array['f_enable'],$this->id));
// parse the $p_array array
foreach ($p_array as $name=> $value)
{

View file

@ -596,9 +596,9 @@ class Follow_Up
$act->save();
}
/* Upload the documents */
/* upload the documents */
$doc=new Document($this->db);
$doc->Upload($this->ag_id);
$doc->upload($this->ag_id);
if (trim($this->ag_comment)!='' && Document_Option::can_add_comment($this->ag_id))
{
$this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment) values ($1,$2,$3)"
@ -905,9 +905,9 @@ class Follow_Up
$this->ag_ref /* 11 */
));
}
// Upload documents
// upload documents
$doc=new Document($this->db);
$doc->Upload($this->ag_id);
$doc->upload($this->ag_id);
/* save action details */
$http=new HttpInput();

View file

@ -190,7 +190,8 @@ class User
if ($res == 0)
{
$cn->exec_sql($sql, array($_SESSION[SESSION_KEY.'g_user'], $_SERVER["REMOTE_ADDR"], $from, $_SERVER['REQUEST_URI'], 'FAIL'));
$cn->exec_sql($sql, array($_SESSION[SESSION_KEY.'g_user'], $_SERVER["REMOTE_ADDR"],
$from, $_SERVER['REQUEST_URI'], 'FAIL'));
if (!$silent)
{
echo '<script> alert(\''._('Utilisateur ou mot de passe incorrect').'\')</script>';
@ -203,7 +204,8 @@ class User
else
{
if ($from == 'LOGIN')
$cn->exec_sql($sql, array($_SESSION[SESSION_KEY.'g_user'], $_SERVER["REMOTE_ADDR"], $from, $_SERVER['REQUEST_URI'], 'SUCCESS'));
$cn->exec_sql($sql, array($_SESSION[SESSION_KEY.'g_user'], $_SERVER["REMOTE_ADDR"], $from,
$_SERVER['REQUEST_URI'], 'SUCCESS'));
$this->valid = 1;
}
@ -249,7 +251,8 @@ class User
if ($priv)
{
// the access is granted
$jnt=$cn->get_value("select jnt_id from jnt_use_dos where dos_id=$1 and use_id=$2", array($db_id, $this->id));
$jnt=$cn->get_value("select jnt_id from jnt_use_dos where dos_id=$1 and use_id=$2",
array($db_id, $this->id));
if ($cn->size()==0)
{
@ -312,6 +315,11 @@ class User
function get_ledger($p_type = 'ALL', $p_access = 3,$disable=TRUE)
{
$p_type=strtoupper($p_type);
if (! in_array($p_type, ["FIN","ALL","ODS","VEN",'ACH'])) {
record_log(sprintf("UGL1, p_type %s",$p_type));
throw new Exception("UGL1"._("Type incorrecte"));
}
if ($disable==TRUE) {
$sql_enable="";
} else {
@ -419,22 +427,26 @@ class User
function set_periode($p_periode)
{
$sql = "update user_local_pref set parameter_value='$p_periode' where user_id='$this->id' and parameter_type='PERIODE'";
$Res = $this->db->exec_sql($sql);
$sql = "update user_local_pref set parameter_value=$1 where user_id=$2 and parameter_type='PERIODE'";
$Res = $this->db->exec_sql($sql,[$p_periode,$this->id]);
}
private function set_default_periode()
{
/* get the first periode */
$sql = 'select min(p_id) as pid from parm_periode where p_closed = false and p_start = (select min(p_start) from parm_periode)';
$sql = 'select min(p_id) as pid '
. ' from parm_periode '
. ' where p_closed = false and p_start = (select min(p_start) from parm_periode)';
$Res = $this->db->exec_sql($sql);
$pid = Database::fetch_result($Res, 0, 0);
/* if all the periode are closed, then we use the last closed period */
if ($pid == null)
{
$sql = 'select min(p_id) as pid from parm_periode where p_start = (select max(p_start) from parm_periode)';
$sql = 'select min(p_id) as pid '
. 'from parm_periode '
. 'where p_start = (select max(p_start) from parm_periode)';
$Res2 = $this->db->exec_sql($sql);
$pid = Database::fetch_result($Res2, 0, 0);
if ($pid == null)
@ -532,7 +544,6 @@ class User
* \brief Get the default user's preferences
* \return array of (parameter_type => parameter_value)
*/
function get_preference()
{
$sql = "select parameter_type,parameter_value from user_local_pref where user_id=$1";
@ -544,7 +555,16 @@ class User
$type = $row['parameter_type'];
$l_array[$type] = $row['parameter_value'];
}
$repo=new Database();
$a_global_pref=$repo->get_array("select parameter_type,parameter_value from user_global_pref
where
upper(user_id) = upper($1)",[$this->login]);
$nb_global=count($a_global_pref);
for ( $i = 0 ;$i< $nb_global ; $i++) {
$idx=$a_global_pref[$i]['parameter_type'];
$value=$a_global_pref[$i]['parameter_value'];
$l_array[$idx]=$value;
}
return $l_array;
}
@ -601,9 +621,9 @@ class User
}
return 0;
}
if ($Count == 1)
return 1;
echo "<H2 class=\"error\"> Action Invalide !!! $Count select * from user_sec_act where ua_login='$p_login' and ua_act_id=$p_action_id </H2>";
if ($Count == 1) return 1;
echo_error(_("Action invalide"));
record_log("User:check_action".sprintf("login %s ua_act_id %s",$this->login,$p_action_id));
exit();
}
@ -620,7 +640,7 @@ class User
// Load everything in an array
$Res = $cn->exec_sql("select parameter_type,parameter_value from
user_global_pref
where user_id='" . $this->login . "'");
where user_id=$1",[$this->login]);
$Max = Database::num_row($Res);
if ($Max == 0)
{
@ -635,7 +655,6 @@ class User
$row = Database::fetch_array($Res, $i);
$type = $row['parameter_type'];
$line[$type] = $row['parameter_value'];
;
}
// save array into g_ variable
$array_pref = array('g_theme' => 'THEME',
@ -756,18 +775,17 @@ class User
$this->audit('FAIL');
if ($p_js == 1)
{
echo "<script>";
echo "alert ('Cette action ne vous est pas autorisée. Contactez votre responsable');";
echo "</script>";
echo create_script("alert_box(content[59])");
}
elseif ($p_js == 2) {
record_log(_("Access invalid").$p_action);
}
else
{
echo '<div class="redcontent">';
echo '<h2 class="error"> Cette action ne vous est pas autorisée Contactez votre responsable</h2>';
echo '</div>';
echo '<h2 class="error">',
htmlspecialchars(_("Cette action ne vous est pas autorisée Contactez votre responsable")),
'</h2>';
echo '</div>';
}
exit(-1);
}
@ -797,7 +815,6 @@ class User
* \param $p_action requested action
* \return nothing the program exits automatically
*/
function can_print($p_action, $p_js = 0)
{
if ($this->check_print($p_action) == 0)
@ -805,15 +822,15 @@ class User
$this->audit('FAIL');
if ($p_js == 1)
{
echo "<script>";
echo "alert ('Cette action ne vous est pas autorisée. Contactez votre responsable');";
echo "</script>";
echo create_script("alert_box(content[59])");
}
else
{
echo '<div class="redcontent">';
echo '<h2 class="error"> Cette action ne vous est pas autorisée Contactez votre responsable</h2>';
echo '</div>';
echo '<div class="redcontent">';
echo '<h2 class="error">',
htmlspecialchars(_("Cette action ne vous est pas autorisée Contactez votre responsable")),
'</h2>';
echo '</div>';
}
exit(-1);
}

View file

@ -50,7 +50,7 @@ if (isset($_POST['record_company']))
$m->MY_STOCK =$http->post("p_stock");
$m->MY_ANC_FILTER=$http->post("p_anc_filter");
try {
$m->Update();
$m->update();
} catch (Exception $e) {
alert($e->getMessage());
}

View file

@ -45,7 +45,7 @@ if ($action == 'sh')
$d_id=$http->request('d_id',"number");
// retrieve the document
$doc = new Document($cn, $d_id);
$doc->Send();
$doc->send();
}
}
/* remove the document */

View file

@ -68,7 +68,7 @@ class Sort_Table
{
if ($p_ind < 0 || $p_ind > $this->nb)
return 'ERREUR TRI';
$file = str_replace('extension.php', '', $_SERVER['SCRIPT_FILENAME']);
$file = str_replace('extension.php', '', $_SERVER['PHP_SELF']);
$base = $this->array[$p_ind]['url'];
$str = '';

View file

@ -115,7 +115,7 @@ function navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1,$p_javascript="")
$step=$p_size;
$offset=($e-1)*$step;
$r='<A class="mtitle" href="'.basename($_SERVER['SCRIPT_FILENAME'])."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'" '.$p_javascript.'>';
$r='<A class="mtitle" href="'.basename($_SERVER['PHP_SELF'])."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'" '.$p_javascript.'>';
$r.=" &larr;";
// $r.='<INPUT TYPE="IMAGE" width="12" SRC="image/go-previous.png">';
$r.="</A>&nbsp;&nbsp;";
@ -181,35 +181,6 @@ function CleanUrl()
{
// Compute the url
$url=http_build_query($_GET);
/* $get=$_GET;
if ( isset ($get) )
{
foreach ($get as $name=>$value )
{
// we clean the parameter offset, step, page and size
if ( ! in_array($name,array('offset','step','page','size','s','o','r_jrn')))
{
if (is_array($name)) {
} else {
$url.=$and.$name."=".$value;
}
$and="&";
}// if
}//foreach
if ( isset($_GET['r_jrn']))
{
$r_jrn=$_GET['r_jrn'];
if (count($r_jrn) > 0 )
{
foreach ($r_jrn as $key=>$value)
{
$url.=$and."r_jrn[$key]=".$value;
$and="&";
}
}
}
}// if*/
return $url;
}
function redirect($p_string,$p_time=0)
@ -219,7 +190,8 @@ function redirect($p_string,$p_time=0)
}
echo '<HTML><head><META HTTP-EQUIV="REFRESH" content="'.$p_time.'; url='.$p_string.'"></head><body> Connecting... </body></html>';
}
/*!\brief remove the useless space, change comma by period and try to return
/*!
* \brief remove the useless space, change comma by period and try to return
* a number
*\param $p_num number to format
*\return the formatted number

View file

@ -1,25 +1,31 @@
<?php
//This file is part of NOALYSS and is under GPL
//see licence.txt
?><div class="<?php echo $style_menu; ?>">
<?php if ( count($amenu) > 4 && $level == 0) :
<?php if ( count($amenu) > 4 && $level == 0) {
$style ='style= "width:100%"';
elseif ($level==0):
switch (count($amenu))
{
case 4:
case 3:
$width=count($amenu)*20;
$left=round((100-$width)/2);
$style="style=\"width:$width%;margin-left:$left%\"";
break;
default:
$style="";
}
elseif ($level==0){
$http=new HttpInput();
$access_code=$http->request("ac");
switch (count($amenu))
{
case 4:
case 3:
$width=count($amenu)*20;
$left=round((100-$width)/2);
$style="style=\"width:$width%;margin-left:$left%\"";
break;
default:
$style="";
}
}
else:
else {
$style=" class=\"mtitle\"";
endif;?>
}?>
<table <?php echo $style?> >
@ -28,55 +34,57 @@ $style="";
global $g_user;
// Display the menu
for($i=0;$i < count($amenu);$i++):
if ( (count($amenu)==1)):
if ( (count($amenu)==1)) {
$class="selectedcell";
?>
<td class="<?php echo $class?>">
<a class="mtitle" href="do.php?gDossier=<?php echo Dossier::id()?>&ac=<?php echo $_REQUEST['ac']?>" title="<?php echo h(gettext($amenu[$i]['me_description']))?>" >
<a class="mtitle" href="do.php?gDossier=<?php echo Dossier::id()?>&ac=<?php echo $access_code?>" title="<?php echo h(gettext($amenu[$i]['me_description']))?>" >
<?php echo gettext($amenu[$i]['me_menu'])?>
</a>
</td>
<?php
else:
$class="mtitle";
$js="";
if ( $amenu[$i]['me_url']!='')
{
$url=$amenu[$i]['me_url'];
}
elseif ($amenu[$i]['me_javascript'] != '')
{
$url="javascript:void(0)";
$js=sprintf(' onclick="%s"',$amenu[$i]['me_javascript']);
}
else
{
$a_request=explode('/', $_REQUEST['ac']);
if ( $level == 0) {
$url=$a_request[0];
if (count($a_request) > 1 &&
$url.'/'.$amenu[$i]['me_code'] == $a_request[0].'/'.$a_request[1])
$class="selectedcell";
} elseif ($level == 1)
}
else {
$class="mtitle";
$js="";
if ( $amenu[$i]['me_url']!='')
{
$url=$a_request[0].'/'.$a_request[1];
$url=$amenu[$i]['me_url'];
}
$url.='/'.$amenu[$i]['me_code'];
if ($url == $_REQUEST['ac']) $class="selectedcell";
$url="do.php?gDossier=".Dossier::id()."&ac=".$url;
}
elseif ($amenu[$i]['me_javascript'] != '')
{
$url="javascript:void(0)";
$js=sprintf(' onclick="%s"',$amenu[$i]['me_javascript']);
}
else
{
$a_request=explode('/', $access_code);
if ( $level == 0) {
$url=$a_request[0];
?> <td class="<?php echo $class?>">
<a class="mtitle" href="<?php echo $url;?>" <?php echo $js?> title="<?php echo h(gettext($amenu[$i]['me_description']))?>">
<?php echo gettext($amenu[$i]['me_menu'])?>
</a>
</td>
if (count($a_request) > 1 &&
$url.'/'.$amenu[$i]['me_code'] == $a_request[0].'/'.$a_request[1])
$class="selectedcell";
} elseif ($level == 1)
{
$url=$a_request[0].'/'.$a_request[1];
}
$url.='/'.$amenu[$i]['me_code'];
if ($url == $access_code ) $class="selectedcell";
$url="do.php?gDossier=".Dossier::id()."&ac=".$url;
}
?>
<td class="<?php echo $class?>">
<a class="mtitle" href="<?php echo $url;?>" <?php echo $js?> title="<?php echo h(gettext($amenu[$i]['me_description']))?>">
<?php echo gettext($amenu[$i]['me_menu'])?>
</a>
</td>
<?php
endif;
} // end elseif ($level==0)
?>
<?php