Merge master

This commit is contained in:
sparkyx 2023-12-05 13:57:01 +01:00
commit 1b69d6dcc8
46 changed files with 524 additions and 412 deletions

View file

@ -113,7 +113,22 @@ if ($op == "progressBar") {
return;
}
//-------------------------------------------------------------------------------------------
// check password
//-------------------------------------------------------------------------------------------
if ($op=='password_chk') {
$cnt = $http->request("pass");
$result=check_password_strength($cnt)['msg'];
if (count($result) == 0) {
echo json_response(["password" => "ok", "msg" => 0]);
} else {
$str="";
foreach ($result as $item) {$str.=sprintf("<li>%s</li>",$item);}
echo json_response(["password" => "nok", "msg" => '<ol>'.$str.'</ol>']);
}
return;
}
$html = var_export($_REQUEST, true);
set_language();
if ( LOGINPUT)

View file

@ -912,7 +912,7 @@ a#smallanchorbutton, .smallbutton, a.smallbutton,div.content a.smallbutton .butt
font-family: SansationLight;
}
td.tool {
border: 1px solid gray;
border: 1px grey solid ;
background-color: #FFFFFF;
border-bottom-width: 2px;
text-align:center;
@ -927,7 +927,7 @@ td.tool {
}
}
td.toolselected {
border: 1px solid gray;
border: 1px grey solid;
color: #FFFFFF;
border-bottom-width: 2px;
text-align:center;
@ -2388,11 +2388,12 @@ td.selectedmenu {
}
.v-large { display: none;}
/*
* Comment in follow-up
*/
.field_follow_up
{
margin-top:1px;
white-space: -moz-pre-wrap;
white-space: pre-wrap;
border:1px solid blue;
}
@ -2420,7 +2421,7 @@ td.selectedmenu {
* go_up
*/
#go_up {
background-color: gray;
background-color: grey;
border:0px;
box-shadow: none;
color:blue;
@ -2433,7 +2434,6 @@ td.selectedmenu {
text-decoration: none;
color:blue;
font-size:1.7em;
font-size: 1.7rem;
padding: 0px;
margin: 0px;
background-color: inherit;
@ -3388,3 +3388,11 @@ li.li-active {
text-decoration: underline wavy;
margin-left:4rem;
}
/**
* result of password strength
*/
#info_passid {
position:absolute;
background-color: yellow;
color:red;
}

View file

@ -29,10 +29,11 @@ MaintenanceMode("block.html");
$cn=Dossier::connect();
global $g_user;
$http=new \HttpInput();
$g_user=new Noalyss_user($cn);
$g_user->Check();
$g_user->check_dossier($_GET['gDossier']);
$res=$cn->exec_sql("select distinct code,description from get_profile_menu($1) where code ~* $2 or description ~* $3 order by code limit 5 ",array($g_user->get_profile(),$_POST['acs'],$_POST['acs']));
$g_user->check_dossier($http->get('gDossier'));
$res=$cn->exec_sql("select distinct code,description from get_profile_menu($1) where code ~* $2 or description ~* $2 order by code limit 5 ",array($g_user->get_profile(),$http->post("acs")));
$nb=Database::num_row($res);
echo "<ul>";
set_language();
@ -41,7 +42,7 @@ for ($i = 0;$i< $nb;$i++)
$row=Database::fetch_array($res,$i);
echo "<li>";
echo $row['code'];
echo '<span class="informal"> '._($row['description']).'</span></li>';
echo '<span class="informal"> '._($row['description']??"").'</span></li>';
}
echo "</ul>";
if ( $nb == 0 ) {

View file

@ -233,7 +233,19 @@ if (isset($_POST['save_config'])) {
$err++;
}
// check strenght password admin
$passw_error=check_password_strength($cpassword_admin);
if ( count($passw_error['msg'])>0) {
echo '<h2 class="warning">';
echo _("Mot de passe trop faible");
echo '</h2>';
echo '<ol>';
foreach ($passw_error['msg'] as $error) {
echo "<li>",$error,"</li>";
}
echo '</ol>';
$err++;
}
// check password and admin not containing quote or double quote
//
if ( strpos($cpassword_admin,'"') !== false

View file

@ -1246,6 +1246,7 @@ function op_save(obj)
onFailure: null,
onSuccess: function (req){
if (req.responseText !=='OK') {
console.error("D2. op_save")
smoke.alert(req.responseText);
}
}
@ -1283,6 +1284,7 @@ function op_save(obj)
$(divid).innerHTML.evalScripts();
remove_waiting_box();
} catch (e) {
console.error("D1. op_save")
alert_box("1038"+e.message)
}
}
@ -1294,6 +1296,7 @@ function op_save(obj)
return false;
} catch (e)
{
console.error("F1. op_save")
alert_box(e.message);
}
}

View file

@ -3786,9 +3786,13 @@ function updatePreference()
method: "post",
parameters: param,
onSuccess: function (req) {
var style = req.responseText.evalJSON();
var answer = req.responseText.evalJSON();
// $('pagestyle').setAttribute('href', style.style);
removeDiv('preference_div');
if ( answer['psw']=='NOK') {
smoke.alert(answer['msg']);
} else {
removeDiv('preference_div');
}
}
});
} catch (e)
@ -4224,4 +4228,50 @@ function event_display_main(p_dossier) {
{
alert_box(e.message);
}
}
/**
* @brief check if password is strong or not, update a DIV element
* @param p_pass_domid DOM ID of the INPUT element with the password
* @param p_result_domid DOM ID of the element to update
*/
function check_password_strength(p_pass_domid,p_result_domid,details)
{
try
{
if ( $(p_pass_domid).value=="") { $(p_result_domid).update("");return;}
var queryString= {
'op':"password_chk"
,pass:$(p_pass_domid).value
};
var action = new Ajax.Request(
"ajax_misc.php" ,
{
method:'GET',
parameters:queryString,
onFailure:ajax_misc_failure,
onSuccess:function(req){
remove_waiting_box();
if (req.responseText == 'NOCONX') {
return;
}
var answer=req.responseJSON;
console.debug(answer);
if (answer['password']=='nok') {
$(p_pass_domid).setStyle("background-color:red");
if ( details) {
$(p_result_domid).update(answer['msg'])
}
return;
}
$(p_pass_domid).setStyle("background-color: lightgreen");
$(p_result_domid).update("")
}
}
);
}catch( e)
{
alert_box(e.message);
}
}

View file

@ -31,7 +31,7 @@ global $g_user;
/*
* Ajax for modifying the description , does not support ITextarea + enrich text
*
*
*/
if ($op=='update_comment_followUp')
{
$input=$http->request('input');
@ -75,7 +75,7 @@ if ($op=='update_comment_followUp')
}
return;
}
*/
// Modify followup
if ($op == 'followup_comment_oneedit') {

View file

@ -84,8 +84,9 @@ if ( $action == 'display_form' )
<tr><td>
Mot de passe :
</td>
<td><input type="password" value="" class="input_text" name="pass_1" nohistory>
<td><input type="password" value="" class="input_text" name="pass_1" id="pass_1" nohistory onkeyup=check_password_strength('pass_1','info_passid',1)>
<input type="password" value="" class="input_text" name="pass_2" nohistory>
<span id="info_passid"></span>
</td>
</tr>
@ -321,20 +322,32 @@ if ($action == 'save')
$csv_decimal=$http->post("csv_decimal","number");
$csv_encoding=$http->post("csv_encoding");
$firstday=$http->post("selFirstDay","number");
$password="OK";
$msg ="";
if (noalyss_strlentrim($pass_1) != 0 && noalyss_strlentrim($pass_2) != 0)
{
if ( $g_user->save_password($_POST['pass_1'],$pass_2) )
{ $g_user->password_to_session() ;
{
$g_user->password_to_session() ;
} else {
/**
* password not changed
*/
*/
$password="NOK";
$msg="";
if ( $_POST['pass_1'] !== $pass_2) {
$msg = _("Mot de passe ne correspondent pas");
$msg .="<br/>";
}
$a_pass_error=check_password_strength($_POST['pass_1']);
if ( count($a_pass_error['msg']) != 0 ) {
foreach($a_pass_error['msg'] as $pass_error) {
$msg.=$pass_error."<br/>";
}
}
}
}
if ( $inside_dossier)
{
@ -366,6 +379,6 @@ if ($action == 'save')
{
$style = "style-classic7.css";
}
json_response(["style"=>$style]);
json_response(["style"=>$style,'psw'=>$password,'msg'=>$msg]);
}

View file

@ -453,6 +453,9 @@ class Acc_Bilan
$lt="&lt;";
$gt="&gt;";
$header_txt=mb_convert_encoding(header_txt($this->db),'UTF-8','ISO8859-1');
$header_txt=iconv('ISO-8859-1','UTF-8//IGNORE',header_txt($this->db));
while ( !feof($p_file) )
{

View file

@ -1051,7 +1051,8 @@ if ( $g_parameter->MY_TVA_USE=="Y") {
</td>
</tr>
EOF;
$sql_currency=new Currency_SQL($this->cn,$p_currency_code);
$iso_code=$sql_currency->getp("cr_code_iso");
if ($p_currency_code !=0) {
$r.=<<<EOF
@ -1067,13 +1068,15 @@ EOF;
{$rate} {$p_currency_rate}
</td>
<td class="num">
{$tot_eur} EUR
{$tot_eur} {$iso_code}
</td>
</tr>
EOF;
}
} else {
$sql_currency=new Currency_SQL($this->cn,$p_currency_code);
$iso_code=$sql_currency->getp("cr_code_iso");
// without VAT
$r.=<<<EOF
<tr class="highlight">
@ -1102,7 +1105,7 @@ EOF;
{$rate} {$p_currency_rate}
</td>
<td class="num">
{$tot_eur} EUR
{$tot_eur} {$iso_code}
</td>
</tr>
EOF;

View file

@ -105,7 +105,8 @@ class Acc_Ledger_Search
*/
function search_form()
{
global $g_user;
global $g_user,$g_parameter;
$g_parameter=new Noalyss_Parameter_Folder($this->cn);
$http=new HttpInput();
$r="";
$bledger_param=json_encode(array(

View file

@ -50,11 +50,10 @@ class Dossier
$this->dos_id=$p_id;
}
/*!\brief return the $_REQUEST['gDossier'] after a check */
/*!\brief return the 'gDossier' value after a check */
static function id()
{
self::check();
$http=new HttpInput();
return $http->request('gDossier','number');
@ -127,11 +126,12 @@ class Dossier
return $nb_folder;
}
/*!
* \brief Return all the users
* as an array
/**
* \brief Return all the users as an array but NOALYSS_ADMINISTRATOR, that user cannot be changed by the
* interface for administrating user
* \param SQL $sql sql string to add to the query :
* \note that string MUST be the result of Database::escape_string
*/
function get_user_folder($sql="")
{
@ -162,20 +162,21 @@ class Dossier
return $res;
}
/*!\brief check if gDossier is set */
/*!\brief check if gDossier is set
* ?? dead code ???
*/
static function check()
{
if (!isset($_REQUEST['gDossier']))
{
echo_error('Dossier inconnu ');
exit('Dossier invalide ');
try {
$http=new HttpInput();
$id=$http->request("gDossier","number");
if ($id > 999999 || $id < 0) throw new \Exception(_("Dossier max dépassé "));
} catch (\Exception $e) {
die('Dossier invalide ');
}
$id=$_REQUEST['gDossier'];
if (is_numeric($id)==0||
strlen($id)>6||
$id>999999)
exit('gDossier Invalide : '.$id);
}
/*!
@ -184,27 +185,30 @@ class Dossier
static function get()
{
self::check();
return "gDossier=".$_REQUEST['gDossier'];
$http=new \HttpInput();
return "gDossier=".$http->request("gDossier","number");
}
/*!\brief return a string to set gDossier into a FORM */
/*!
* \brief return a string to set gDossier into a FORM
*/
static function hidden()
{
self::check();
return '<input type="hidden" id="gDossier" name="gDossier" value="'.$_REQUEST['gDossier'].'">';
$http=new \HttpInput();
return '<input type="hidden" id="gDossier" name="gDossier" value="'.$http->request("gDossier","number").'">';
}
/*!\brief retrieve the name of the current dossier */
static function name($id=0)
{
self::check();
$http=new \HttpInput();
$cn=new Database();
$id=($id==0)?$_REQUEST['gDossier']:$id;
$name=$cn->get_value("select dos_name from ac_dossier where dos_id=$1", array($_REQUEST['gDossier']));
$id=($id==0)?$http->request("gDossier","number"):$id;
$name=$cn->get_value("select dos_name from ac_dossier where dos_id=$1", array($id));
return $name;
}
@ -419,9 +423,9 @@ class Dossier
*/
static function set_current($p_dossier) {
self::check($p_dossier);
put_global([ [ "key"=>"gDossier","value"=>$p_dossier]]);
self::check();
}
}

View file

@ -148,6 +148,7 @@ class Extension extends Menu_Ref_sql
throw new Exception(_('Profil inexistant'), 10);
}
// Menu exists
\Noalyss\Dbg::echo_var(1,__FILE__.__LINE__. "p_module to find $p_module");
$module=new Menu_Ref($cn, $p_module);
if ($module->me_code==null)
{

View file

@ -1636,11 +1636,12 @@ class Noalyss_User
* @brief Save the password of the current user
* @param string $p_pass1 password (clear)
* @param string $p_pass2 for confirming password (clear)
* @see check_password_strength()
* @return true : password successfully changed otherwise false
*/
function save_password($p_pass1, $p_pass2)
{
if ($p_pass1==$p_pass2)
if ($p_pass1==$p_pass2 && count(check_password_strength($p_pass1)['msg'])==0)
{
$repo=new Database();
$l_pass=md5($p_pass1);

View file

@ -72,7 +72,7 @@ class PDF extends PDF_Core
parent::Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
parent::Ln(3);
// Created by NOALYSS
parent::Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
parent::Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'C',false,'https://www.noalyss.eu');
}
/**
*@brief retrieve the client name and quick_code

View file

@ -71,7 +71,7 @@ class PDFLand extends PDF
$this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
$this->Ln(3);
// Created by NOALYSS
$this->Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
$this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'C',false,'https://www.noalyss.eu');
}
}

View file

@ -54,11 +54,11 @@ class Periode
{
$r=<<<EOF
Object Periode [
\$jrn_def_id=>$jrn_def_id,
\$p_id=>$p_id,
\$status => $status,
\$p_start => $p_start,
\$p_end => $p_end,
\$jrn_def_id=>$this->jrn_def_id,
\$p_id=>$this->p_id,
\$status => $this->status,
\$p_start => $this->p_start,
\$p_end => $this->p_end,
]
EOF;
return $r;

View file

@ -64,7 +64,7 @@ class Print_Ledger_Detail extends Print_Ledger
//Page number
$this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
// Created by NOALYSS
$this->Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'R',false,'http://www.noalyss.eu');
$this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
}

View file

@ -75,7 +75,7 @@ class Print_Ledger_Detail_Item extends Print_Ledger
//Page number
$this->Cell(30,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
// Created by NOALYSS
$this->Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'R',false,'http://www.noalyss.eu');
$this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
}

View file

@ -89,7 +89,7 @@ class Print_Ledger_Financial extends Print_Ledger
$this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
$this->Ln(3);
// Created by NOALYSS
$this->Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
$this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'C',false,'https://www.noalyss.eu');
}
/**

View file

@ -62,7 +62,7 @@ class Print_Ledger_Misc extends Print_Ledger
$this->Cell(0,6,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
$this->Ln(3);
// Created by NOALYSS
$this->Cell(0,6,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
$this->Cell(0,6,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'C',false,'https://www.noalyss.eu');
}
/**
*@brief print the pdf

View file

@ -243,7 +243,7 @@ class Print_Ledger_Simple extends \Print_Ledger
//Page number
$this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
// Created by NOALYSS
$this->Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'R',false,'http://www.noalyss.eu');
$this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
}

View file

@ -135,7 +135,7 @@ class Print_Ledger_Simple_Without_Vat extends Print_Ledger
//Page number
$this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
// Created by NOALYSS
$this->Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'R',false,'http://www.noalyss.eu');
$this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
}
/**

View file

@ -106,9 +106,9 @@ $version_noalyss = SVNINFO;
// If you don't want to be notified of the update
if (!defined("SITE_UPDATE"))
define("SITE_UPDATE", 'http://www.noalyss.eu/last_version.txt');
define("SITE_UPDATE", 'https://www.noalyss.eu/last_version.txt');
if (!defined("SITE_UPDATE_PLUGIN"))
define("SITE_UPDATE_PLUGIN", 'http://www.noalyss.eu/plugin_last_version.txt');
define("SITE_UPDATE_PLUGIN", 'https://www.noalyss.eu/plugin_last_version.txt');
if (!defined("NOALYSS_PACKAGE_REPOSITORY")) {
define("NOALYSS_PACKAGE_REPOSITORY", "https://package.noalyss.eu/");
}
@ -116,7 +116,7 @@ if (!defined("NOALYSS_PACKAGE_REPOSITORY")) {
if (!defined("SYSINFO_DISPLAY")) {
define("SYSINFO_DISPLAY", TRUE);
}
define("DBVERSION", 189);
define("DBVERSION", 190);
define("MONO_DATABASE", 25);
define("DBVERSIONREPO", 20);
define('NOTFOUND', '--not found--');

View file

@ -32,10 +32,16 @@ $gDossier=dossier::id();
$cn=Dossier::connect();
$g_user->Check();
$g_user->check_dossier($gDossier);
$name=$cn->get_value('select fd_label from fiche_def where fd_id=$1',array($_GET['cat']));
$http=new HttpInput();
$cat = $http->get("cat");
$histo = $http->get("histo");
$name=$cn->get_value('select fd_label from fiche_def where fd_id=$1',array($cat));
$pdf=new PDF($cn);
$pdf->setDossierInfo(" Periode : ".$_GET['start']." - ".$_GET['end']);
$pdf->setDossierInfo(" Periode : ".$http->get('start')." - ".$http->get('end'));
$pdf->AliasNbPages();
$pdf->AddPage();
@ -46,9 +52,9 @@ $allcard=(isset($_GET['allcard']))?1:0;
/*
* Balance
*/
if ( $_GET['histo'] == 4 || $_GET['histo']==5)
if ($histo == 4 || $histo==5)
{
$fd=new Fiche_Def($cn,$_REQUEST['cat']);
$fd=new Fiche_Def($cn,$http->request('cat'));
if ($allcard==1 && $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
{
$pdf->write_cell(0,10, "Cette catégorie n'ayant pas de poste comptable n'a pas de balance");
@ -64,7 +70,7 @@ if ( $_GET['histo'] == 4 || $_GET['histo']==5)
}
else
{
$afiche[0]=array('fd_id'=>$_REQUEST['cat']);
$afiche[0]=array('fd_id'=>$http->request('cat'));
}
if ( $allcard==0 && empty($afiche))
@ -96,26 +102,16 @@ if ( $_GET['histo'] == 4 || $_GET['histo']==5)
$idx=0;$sum_deb=0;$sum_cred=0;bcscale(4);
for ($i=0;$i < count($aCard);$i++)
{
if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null ) exit;
$filter= " (j_date >= to_date('".$_REQUEST['start']."','DD.MM.YYYY') ".
" and j_date <= to_date('".$_REQUEST['end']."','DD.MM.YYYY')) ";
if ( isDate($http->request('start')) == null || isDate ($http->request('end')) == null ) exit;
$filter= " (j_date >= to_date('".$http->request('start')."','DD.MM.YYYY') ".
" and j_date <= to_date('".$http->request('end')."','DD.MM.YYYY')) ";
$oCard=new Fiche($cn,$aCard[$i]['f_id']);
$solde=$oCard->get_solde_detail($filter);
if ( $solde['debit'] == 0 && $solde['credit']==0) continue;
/* only not purged card */
if ($_GET['histo'] == 5 && $solde['debit'] == $solde['credit']) continue;
if ( $idx % 2 == 0 )
{
$pdf->SetFillColor(220,221,255);
$fill=1;
}
else
{
$pdf->SetFillColor(0,0,0);
$fill=0;
}
$idx++;
if ($histo == 5 && $solde['debit'] == $solde['credit']) continue;
$fill=$pdf->is_fill($idx);
$idx++;
$side='';
if(bcsub($solde['credit'],$solde['debit']) < 0) $side='Deb.';
if(bcsub($solde['credit'],$solde['debit']) > 0) $side='Cred.';
@ -132,16 +128,8 @@ if ( $_GET['histo'] == 4 || $_GET['histo']==5)
$pdf->write_cell(20,7,$side,0,0,'C',$fill);
$pdf->line_new();
}
if ( $idx % 2 == 0 )
{
$pdf->SetFillColor(220,221,255);
$fill=1;
}
else
{
$pdf->SetFillColor(0,0,0);
$fill=0;
}
$fill=$pdf->is_fill($idx);
$idx++;
// Sum by category
$pdf->write_cell(30,7,"",0,0,'L',$fill);
@ -173,7 +161,7 @@ else
}
else
{
$afiche[0] = array('fd_id' => $_REQUEST['cat']);
$afiche[0] = array('fd_id' => $http->request('cat'));
}
$fic=new Fiche($cn);
for ($e = 0; $e < count($afiche); $e++)
@ -194,25 +182,25 @@ else
$fic = new Fiche($cn, $row_fiche['f_id']);
$letter = new Lettering_Card($cn);
$letter->set_parameter('quick_code', $fic->strAttribut(ATTR_DEF_QUICKCODE));
$letter->set_parameter('start', $_GET['start']);
$letter->set_parameter('end', $_GET['end']);
$letter->set_parameter('start',$http->request('start'));
$letter->set_parameter('end',$http->request('end'));
// all
if ($_GET['histo'] == 0)
if ($histo == 0)
{
$letter->get_all();
}
// lettered
if ($_GET['histo'] == 1)
if ($histo == 1)
{
$letter->get_letter();
}
// unlettered
if ($_GET['histo'] == 2)
if ($histo == 2)
{
$letter->get_unletter();
}
if ($_GET['histo'] == 6)
if ($histo == 6)
{
$letter->get_letter_diff();
}
@ -240,16 +228,7 @@ else
$prog=0;
for ($i = 0; $i < count($letter->content); $i++)
{
if ($i % 2 == 0)
{
$pdf->SetFillColor(220, 221, 255);
$fill = 1;
}
else
{
$pdf->SetFillColor(0, 0, 0);
$fill = 0;
}
$fill=$pdf->is_fill($i);
$pdf->SetFont('DejaVuCond', '', 7);
$row = $letter->content[$i];
$str_date = shrink_date($row['j_date_fmt']);

View file

@ -1,233 +0,0 @@
<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 Author Dany De Bontridder danydb@aevalys.eu
/*!\file
* \brief Called by impress->category, export in PDF the history of a category
* of card
* @bug NOT USED MUST BE REMOVED
*/
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
// Security we check if user does exist and his privilege
require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
/* Security */
$gDossier=dossier::id();
$cn=Dossier::connect();
$g_user->Check();
$g_user->check_dossier($gDossier);
$pdf=new PDF($cn);
$pdf->setDossierInfo(" Periode : ".$_GET['start']." - ".$_GET['end']);
$pdf->AliasNbPages();
$pdf->AddPage();
$name=$cn->get_value('select fd_label from fiche_def where fd_id=$1',array($_GET['cat']));
$pdf->SetFont('DejaVu','BI',14);
$pdf->write_cell(0,8,$name,0,1,'C');
$pdf->SetTitle($name,1);
$pdf->SetAuthor('NOALYSS');
$http=new HttpInput();
$start=$http->request('start');
$end=$http->request('end');
if ( isDate($start) == null || isDate ($end) == null ) return;
/* balance */
if ( $_GET['histo'] == 4 )
{
$cat=$http->request('cat');
$fd=new Fiche_Def($cn,$cat);
if ( $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
{
$pdf->write_cell(0,10, _("Cette catégorie n'ayant pas de poste comptable n'a pas de balance"));
//Save PDF to file
$fDate=date('dmy-Hi');
$pdf->Output("category-$fDate.pdf", 'D');
exit;
}
$aCard=$cn->get_array("select f_id,ad_value from fiche join fiche_Detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 ",array($cat));
if ( empty($aCard))
{
$pdf->write_cell(0,10, _("Aucune fiche trouvée"));//Save PDF to file
$fDate=date('dmy-Hi');
$pdf->Output("category-$fDate.pdf", 'D');
exit;
}
$pdf->SetFont('DejaVuCond','',7);
$pdf->write_cell(30,7,'Quick Code',0,0,'L',0);
$pdf->write_cell(80,7,'Libellé',0,0,'L',0);
$pdf->write_cell(20,7,'Débit',0,0,'R',0);
$pdf->write_cell(20,7,'Crédit',0,0,'R',0);
$pdf->write_cell(20,7,'Solde',0,0,'R',0);
$pdf->write_cell(20,7,'D/C',0,0,'C',0);
$pdf->line_new();
$idx=0;
$filter= " (j_date >= to_date('".$start."','DD.MM.YYYY') ".
" and j_date <= to_date('".$end."','DD.MM.YYYY')) ";
for ($i=0;$i < count($aCard);$i++)
{
$oCard=new Fiche($cn,$aCard[$i]['f_id']);
$solde=$oCard->get_solde_detail($filter);
if ( $solde['debit'] == 0 && $solde['credit']==0) continue;
if ( $idx % 2 == 0 )
{
$pdf->SetFillColor(220,221,255);
$fill=1;
}
else
{
$pdf->SetFillColor(0,0,0);
$fill=0;
}
$idx++;
$pdf->write_cell(30,7,$oCard->strAttribut(ATTR_DEF_QUICKCODE),0,0,'L',$fill);
$pdf->write_cell(80,7,$oCard->strAttribut(ATTR_DEF_NAME),0,0,'L',$fill);
$pdf->write_cell(20,7,sprintf('%.02f',$solde['debit']),0,0,'R',$fill);
$pdf->write_cell(20,7,sprintf('%.02f',$solde['credit']),0,0,'R',$fill);
$pdf->write_cell(20,7,sprintf('%.02f',abs($solde['solde'])),0,0,'R',$fill);
$pdf->write_cell(20,7,(($solde['solde']<0)?'CRED':'DEB'),0,0,'C',$fill);
$pdf->line_new();
}
}
else
{
$array=Fiche::get_fiche_def($cn,$_GET['cat'],'name_asc');
/*
* You show now the result
*/
if ($array == null )
{
exit();
}
$tab=array(13,25,55,20,20,12,20);
$align=array('L','L','L','R','R','R','R');
foreach($array as $row_fiche)
{
$row=new Fiche($cn,$row_fiche['f_id']);
$letter=new Lettering_Card($cn);
$letter->set_parameter('quick_code',$row->strAttribut(ATTR_DEF_QUICKCODE));
$letter->set_parameter('start',$_GET['start']);
$letter->set_parameter('end',$_GET['end']);
// all
if ( $_GET['histo'] == 0 )
{
$letter->get_all();
}
// lettered
if ( $_GET['histo'] == 1 )
{
$letter->get_letter();
}
// unlettered
if ( $_GET['histo'] == 2 )
{
$letter->get_unletter();
}
/* skip if nothing to display */
if (count($letter->content) == 0 ) continue;
$pdf->SetFont('DejaVuCond','',10);
$fiche=new Fiche($cn,$row_fiche['f_id']);
$pdf->write_cell(0,7,$fiche->strAttribut(ATTR_DEF_NAME),1,1,'C');
$pdf->SetFont('DejaVuCond','',7);
$pdf->write_cell($tab[0],7,'Date');
$pdf->write_cell($tab[1],7,'ref');
$pdf->write_cell($tab[1],7,'Int.');
$pdf->write_cell($tab[2],7,'Comm');
$pdf->write_cell(40,7,'Montant',0,0,'C');
$pdf->write_cell($tab[5],7,'Let.',0,0,'R');
$pdf->write_cell($tab[6],7,'Som. Let.',0,0,'R');
$pdf->line_new();
$amount_deb=0;
$amount_cred=0;
for ($i=0;$i<count($letter->content);$i++)
{
if ( $i % 2 == 0 )
{
$pdf->SetFillColor(220,221,255);
$fill=1;
}
else
{
$pdf->SetFillColor(0,0,0);
$fill=0;
}
$pdf->SetFont('DejaVuCond','',7);
$row=$letter->content[$i];
$str_date=shrink_date($row['j_date_fmt']);
$pdf->write_cell($tab[0],4,$str_date,0,0,$align[0],$fill);
$pdf->write_cell($tab[1],4,$row['jr_pj_number'],0,0,$align[1],$fill);
$pdf->write_cell($tab[1],4,$row['jr_internal'],0,0,$align[1],$fill);
$pdf->write_cell($tab[2],4,$row['jr_comment'],0,0,$align[2],$fill);
if ( $row['j_debit'] == 't')
{
$pdf->write_cell($tab[3],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill);
$amount_deb+=$row['j_montant'];
$pdf->write_cell($tab[4],4,"",0,0,'C',$fill);
}
else
{
$pdf->write_cell($tab[3],4,"",0,0,'C',$fill);
$pdf->write_cell($tab[4],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill);
$amount_cred+=$row['j_montant'];
}
if ($row['letter'] != -1 )
{
$pdf->write_cell($tab[5],4,strtoupper(base_convert($row['letter'],10,36)),0,0,$align[5],$fill);
// get sum for this lettering
$sql="select sum(j_montant) from jrnx where j_debit=$1 and j_id in ".
" (select j_id from jnt_letter join letter_deb using (jl_id) where jl_id=$2 union ".
" select j_id from jnt_letter join letter_cred using (jl_id) where jl_id=$3)";
$sum=$cn->get_value($sql,array($row['j_debit'],$row['letter'],$row['letter']));
$pdf->write_cell($tab[6],4,sprintf('%.2f',$sum),'0','0','R',$fill);
}
else
$pdf->write_cell($tab[5],4,"",0,0,'R',$fill);
$pdf->line_new();
}
$pdf->SetFillColor(0,0,0);
$pdf->SetFont('DejaVuCond','B',8);
$debit =sprintf('Debit : % 12.2f',$amount_deb);
$credit=sprintf('Credit : % 12.2f',$amount_cred);
if ( $amount_deb>$amount_cred) $s='solde débiteur';
else $s='solde crediteur';
$solde =sprintf('%s : % 12.2f',$s,(abs(round($amount_cred-$amount_deb,2))));
$pdf->write_cell(0,6,$debit,0,0,'R');
$pdf->line_new(4);
$pdf->write_cell(0,6,$credit,0,0,'R');
$pdf->line_new(4);
$pdf->write_cell(0,6,$solde,0,0,'R');
$pdf->line_new(4);
$pdf->line_new();
}
}
//Save PDF to file
$fDate=date('dmy-Hi');
$pdf->Output("category-$fDate.pdf", 'D');
exit;

View file

@ -35,6 +35,9 @@ function header_txt($p_cn)
$date=date('d / m / Y H:i ');
$dossier=mb_convert_encoding(" Dossier : ".dossier::name(),'ISO-8859-1','UTF-8');
// convert to latin1
$dossier=iconv('UTF-8','ISO-8859-1//IGNORE',$str);
return $dossier." ".$soc." ".$date;
}

View file

@ -1374,7 +1374,7 @@ if(!function_exists('tracedebug')) {
}
}
/**
* @brief encode the string for RTF, return a stringu
* @brief encode the string for RTF, return a string
* @param $p_string string to convert
* @return string
*/
@ -1382,6 +1382,9 @@ function convert_to_rtf($p_string)
{
$result="";
$p_string2=mb_convert_encoding($p_string,'ISO-8859-1','UTF-8');
$p_string2=iconv('UTF-8','ISO-8859-1//IGNORE',$p_string);
$nb_result=strlen($p_string2);
for ($i = 0 ; $i < $nb_result ; $i++ ){
if (ord($p_string[$i]) < 127 ) {
@ -1413,10 +1416,13 @@ function remove_divide_zero($p_formula)
* @brief Create randomly a string
* @param int $p_length length of the generate string
*/
function generate_random_string($p_length)
function generate_random_string($p_length,$special=1)
{
$string="";
$chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-=";
if ($special == 1)
$chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-=";
if ($special == 0)
$chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789";
$microtime=microtime(true)*microtime(true)*100;
srand(0);
srand((int)$microtime);
@ -1660,3 +1666,111 @@ function MaintenanceMode($p_file)
exit;
}
}
/**
* @brief returns an double array with the error found and code , if the count is 0 then the password is very string, 5 means it is
* empty ,4 weak, ... the array contains the errors, [msg]=>array message [code] => array of code
* Codes are
* - 1 : too short
* - 2 : missing digit
* - 3 : missing lowercase letter
* - 4 : missing uppercase letter
* - 5 : too many time same letter or symbol..
* - 6 : missing special char
*
* If the password is strong returns an empty array
*
* @param $password string
* @code
$error = check_password_strength($password);
if ( count($error['msg']) > 0 ) {
echo "password to weak";
foreach ($error['msg'] as $item_error) {
echo "error $item_error";
}
} else {
echo "OK password strong";
}
* @endcode
*/
function check_password_strength($password) {
$errors=array();
$error_code=array();
$len=strlen($password??"");
if ( $len < 8) {
$errors[] = _("mot de passe de 8 lettres minimum");
$error_code[]=1;
}
if (!preg_match("#[0-9]+#", $password)) {
$errors[] = _("mot de passe doit inclure au moins un chiffre");
$error_code[]=2;
}
if (!preg_match("#[a-z]+#", $password)) {
$errors[] = _("mot de passe doit inclure au moins une minuscule");
$error_code[]=3;
}
if (!preg_match("#[A-Z]+#", $password)) {
$errors[] = _("mot de passe doit inclure au moins une majuscule");
$error_code[]=4;
}
if ( $len > 0 ) {
$cnt_diff=count(count_chars($password,1));
$ratio_diff=$len/$cnt_diff;
if ($ratio_diff > 2) {
$errors[] = _("Trop souvent le(s) même(s) symbole(s)");
$error_code[]=5;
}
$special_char=preg_replace('/[[:alnum:]]/','',$password);
if ( strlen($special_char??"")==0)
{
$errors[] = _("mot de passe doit inclure au moins un caractére spécial '+-/*[...'");
$error_code[]=6;
}
}
return array( 'msg'=>$errors, 'code'=>$error_code);
}
/**
* @brief generate a strong random password
* @param $car int length of the password, minimum 8
*
*/
function generate_random_password($car):string
{
$string="";
$car=($car < 8 )?8:$car;
$max_loop=20;$loop=0;
do
{
$loop++;
$string="";
$chaine="abcdefghijklmnpqrstuvwxy";
// srand( (int)microtime()*1020030);
for ($i=0; $i<$car; $i++)
{
$string .= $chaine[rand()%strlen($chaine)];
}
$chaine="ABCDEFGHIJKLMNPQRSTUVWXY";
for ($i=0;$i<2;$i++) {
$string[rand()%$car]=$chaine[rand()%strlen($chaine)];;
}
$chaine="0123456789";
for ($i=0;$i<2;$i++) {
$string[rand()%$car]=$chaine[rand()%strlen($chaine)];;
}
$special_set="+-/*;,.=:&()[]";
$special_car=$special_set[rand()%strlen($special_set)];
$string[rand()%$car]=$special_car;
// echo $string."\n";
}while ( count(check_password_strength($string)['msg'])> 0 && $loop<$max_loop);
return $string;
}

View file

@ -169,7 +169,7 @@ class DatabaseCore
return $this;
}
/**
/**
* \brief send a sql string to the database
* \param $p_string sql string
* \param $p_array array for the SQL string (see pg_query_params)
@ -480,7 +480,7 @@ class DatabaseCore
}
/**
* Returns only one row from a query
* @brief Returns only one row from a query
* @param string $p_sql
* @param array $p_array
* @return array , idx = column of the table or null if nothing is found
@ -735,7 +735,8 @@ class DatabaseCore
return false;
}
/**\brief wrapper for the function pg_num_rows
/**
* \brief wrapper for the function pg_num_rows
* \param $ret is the result of a exec_sql
* \return number of line affected
*/
@ -745,7 +746,8 @@ class DatabaseCore
return pg_num_rows($ret);
}
/**\brief wrapper for the function pg_fetch_array
/**
* \brief wrapper for the function pg_fetch_array
* \param $ret is the result of a pg_exec
* \param $p_indice is the index
* \param $p_indice is the index
@ -757,7 +759,8 @@ class DatabaseCore
return pg_fetch_array($ret, $p_indice,$p_mode);
}
/**\brief wrapper for the function pg_fetch_all
/**
* \brief wrapper for the function pg_fetch_all
* \param $ret is the result of pg_exec (exec_sql)
* \return double array (row x col ) or false
*/
@ -767,7 +770,8 @@ class DatabaseCore
return pg_fetch_all($ret);
}
/**\brief wrapper for the function pg_fetch_all
/**
* \brief wrapper for the function pg_fetch_all
* \param $ret is the result of pg_exec (exec_sql)
* \param $p_row is the indice of the row
* \param $p_col is the indice of the col
@ -790,7 +794,8 @@ class DatabaseCore
return pg_fetch_row($ret, $p_row);
}
/**\brief wrapper for the function pg_lo_unlink
/**
* \brief wrapper for the function pg_lo_unlink
* \param $p_oid is the of oid
* \return return the result of the operation
*/
@ -838,7 +843,8 @@ class DatabaseCore
return pg_lo_export($this->db, $p_oid, $tmp_file);
}
/**\brief wrapper for the function pg_lo_export
/**
* \brief wrapper for the function pg_lo_export
* \param $p_filename is the filename
* \param $tmp is the file
* \return result of the operation
@ -849,7 +855,8 @@ class DatabaseCore
return pg_lo_import($this->db, $p_filename);
}
/**\brief wrapper for the function pg_escape_string
/**
* \brief wrapper for the function pg_escape_string
* \param $p_string is the string to escape
* \return escaped string
*/
@ -861,7 +868,8 @@ class DatabaseCore
return pg_escape_string($cn->db,$p_string);
}
/**\brief wrapper for the function pg_close
/**
* \brief wrapper for the function pg_close
*/
function close()
@ -870,7 +878,8 @@ class DatabaseCore
$this->is_open = FALSE;
}
/**\brief
/**
* \brief
* \param
* \return
* \note

View file

@ -101,7 +101,8 @@ class HtmlInput
$this->readOnly=$p_read;
}
/*!\brief set the extra javascript property for the INPUT field
/*!
* \brief set the extra javascript property for the INPUT field
* \param $p_name name of the parameter
* \param $p_value default value of this parameter
*/
@ -439,7 +440,7 @@ class HtmlInput
}
/**
* close button for the HTML popup
* @brief close button for the HTML popup
* @see add_div modify_operation
* @param $div_name is the name of the div to remove
*/
@ -469,7 +470,7 @@ class HtmlInput
}
/**
* Return a html string with an anchor which close the inside popup. (top-right corner)
* @brief Return a html string with an anchor which close the inside popup. (top-right corner)
* @param name of the DIV to close
* @deprecated
* @see Icon_Action::close
@ -480,7 +481,7 @@ class HtmlInput
}
/**
* Anchor Html with javascript
* @brief Anchor Html with javascript
* @param $action action action to perform (message) without onclick
* @param $javascript javascript to execute
* @param $id is the DOM element id
@ -500,7 +501,7 @@ class HtmlInput
}
/**
* button Html with javascript
* @brief button Html with javascript
* @param $action action action to perform (message) without onclick
* @param $javascript javascript to execute
* @param $id is the DOM element id
@ -520,7 +521,7 @@ class HtmlInput
}
/**
* Image to click ,
* @brief Image to click ,
* @param string $p_image filename of the image under image/
* @param string $p_js javascript when the image is clicked
* @param string $p_message Message
@ -533,7 +534,7 @@ class HtmlInput
}
/**
* button Html image
* @brief button Html image
* @param $javascript javascript to execute
* @param $id id of the button
* @param $class class of the button
@ -552,7 +553,7 @@ class HtmlInput
}
/**
* Return a html string with an anchor to hide a div, put it in the right corner
* @brief Return a html string with an anchor to hide a div, put it in the right corner
* @param $action action action to perform (message)
* @param $javascript javascript
* @note not protected against html
@ -576,7 +577,7 @@ class HtmlInput
}
/**
* show the detail of a card
* @brief show the detail of a card
*/
static function card_detail($p_qcode, $pname='', $p_style="",
$p_nohistory=false)
@ -590,7 +591,7 @@ class HtmlInput
}
/**
* transform request data to hidden
* @brief transform request data to hidden
* @param $array is an of indices
* @param $request name of the superglobal $_POST $_GET $_REQUEST(default)
* @return html string with the hidden data
@ -624,7 +625,7 @@ class HtmlInput
return $r;
}
/**
* Transform a double array as a HTML string with hidden html value
* @brief Transform a double array as a HTML string with hidden html value
* array has the formarray ["name"]="x",array['value']="y") the key name will be the hidden input name;
* @param double $array
*/
@ -651,7 +652,7 @@ class HtmlInput
}
/**
* transform $_GET data to hidden
* @brief transform $_GET data to hidden
* @param $array is an of indices
* @see HtmlInput::request_to_hidden
* @return html string with the hidden data
@ -1166,7 +1167,7 @@ class HtmlInput
}
/**
* Insert attribute inside a INPUT TYPE, these attribute can be retrieved
* @brief Insert attribute inside a INPUT TYPE, these attribute can be retrieved
* in javascript with element.getAttribute or changed with element.setAttribute
* example insert my_attribute into a checkbox <input type="checkbox" "my_attribute"="XX">
* @return string to insert into the HTML node

View file

@ -30,7 +30,11 @@
* You need an ajax to response and modify the data. Some parameters will be sent
* by default when you click on the element
* - input : htmlInput object serialized
* - action : ok or cancel , nothing if you just want to display the input
* - ieaction : ok or cancel , nothing if you just want to display the input
*
* Very important it is the DOM ID of the HtmlInput element, it must unique. For the date
* set a uniq dom id, otherwise it fails
* $id_limit_date->id=uniqid("date");
*
* @example inplace_edit.test.php
*/
@ -111,7 +115,7 @@ EOF;
function value()
{
$v=$this->input->get_value();
$v=html_entity_decode($v);
$v=html_entity_decode($v??"");
if ( $this->input instanceof ITextarea) {
echo '<pre class="field_follow_up">';

View file

@ -75,6 +75,26 @@
* @endcode
*
* The afterSaveFct is the function called after saving, the param is the HTML Element
@code PHP
// to redirect : we take the pk_id and redirect to another location
$obj=$this->get_object_name();
$url=DRIVINGSCHOOL_URL;
$script=<<<EOF
(function(){
{$obj}.afterSaveFct=function(p_param) {
let student=p_param.attributes["ctl_pk_id"].value;
window.location="{$url}/do.php?do=student&student_id="+student+"&act=detail";
}})();
EOF;
echo create_script($script);
{$obj}.afterSaveFct=function(p_param) {
let student=p_param.attributes["ctl_pk_id"].value;
window.location="{$url}/do.php?do=student&student_id="+student+"&act=detail";
}})();
@endcode
*/
class Manage_Table_SQL
@ -824,8 +844,10 @@ function check()
}
$nb_order=count($this->a_order);
$virg=""; $result="";
// filter only on visible column
$visible=0;
$visible=($this->icon_mod=='left')?1:0;
$visible=$visible+( ($this->icon_del=='left')?1:0);
for ($e=0; $e<$nb_order; $e++)
{
if ($this->get_property_visible($this->a_order[$e])==TRUE)

View file

@ -264,7 +264,7 @@ class PDF_Core extends TFPDF
$this->bigger=0;
}
/**
* If the step is even then return 1 and set the backgroup color to blue , otherwise
* @brief If the step is even then return 1 and set the backgroup color to blue , otherwise
* returns 0, and set the background color to white
* It is use to compute alternated colored row , it the parameter fill in write_cell and
* cell
@ -281,7 +281,7 @@ class PDF_Core extends TFPDF
$this->SetFillColor(255, 255, 255);
$fill = 0;
}
return $p_step;
return $fill;
}

View file

@ -17,27 +17,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright (2014) Author Dany De Bontridder <dany@alchimerys.be>
require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
if (!defined('RECOVER'))
die('Appel direct ne sont pas permis');
define('SIZE_REQUEST', 70);
/**
* @brief generate a random string of char
* @param $car int length of the string
*/
function generate_random($car)
{
$string="";
$chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789";
srand((double) microtime()*1020030);
for ($i=0; $i<$car; $i++)
{
$string .= $chaine[rand()%strlen($chaine)];
}
return $string;
}
$http=new HttpInput();
/**
* @file
@ -89,8 +76,8 @@ elseif ($action=="send_email") :
if ($valid==true):
$request_id=generate_random(SIZE_REQUEST);
$user_password=generate_random(10);
$request_id=generate_random_string(SIZE_REQUEST,special: 0);
$user_password=generate_random_password(10);
// exist a valid request for this user ?
$exist_request= $cn->get_array("select request , password from recover_pass
where use_id=$1 and created_on > now() - interval '12 hours'",[$user_id]);

View file

@ -0,0 +1,6 @@
begin;
delete from menu_ref where me_code='PDF:fiche';
insert into version (val,v_description) values (190,'remove dead code');
commit;

View file

@ -1,7 +1,7 @@
<?php
//This file is part of NOALYSS and is under GPL
//see licence.txt
global $g_parameter;
?>
<table id="<?=$this->div?>table_search">

View file

@ -124,7 +124,7 @@ endif;?>
}
?>
<li class="<?php echo $style?>">
<a class="nav-link" href="<?php echo $url?>" title="<?php echo _($row['me_description'])?>" <?php echo $js?> ><?php echo gettext($row['me_menu'])?></a>
<a class="nav-link" href="<?php echo $url?>" title="<?php echo _($row['me_description']??''); ?>" <?php echo $js?> ><?php echo gettext($row['me_menu'])?></a>
</li>
<?php
endforeach;
@ -168,7 +168,7 @@ endif;?>
}
?>
<li class="<?php echo $style?>">
<a class="nav-link" href="<?php echo $url?>" title="<?php echo _($row['me_description'])?>" <?php echo $js?> ><?php echo gettext($row['me_menu'])?></a>
<a class="nav-link" href="<?php echo $url?>" title="<?php echo _($row['me_description']??"")?>" <?php echo $js?> ><?php echo gettext($row['me_menu'])?></a>
</li>
<?php
endforeach;

View file

@ -69,7 +69,7 @@ $http=new HttpInput();
?>
</span>
<p>
<?php echo _($row['me_description'])?>
<?php echo _($row['me_description']??"")?>
</p>
<p>
<?php echo $url?>

View file

@ -59,12 +59,12 @@
<?php echo $row['r_name']?>
</td>
<td>
<?php if (trim($row['qcode'])!='') : ?>
<?php if (trim($row['qcode']??"")!='') : ?>
<?php echo HtmlInput::card_detail($row['qcode'],$row['fname'],' class="line" ')?>
<?php endif; ?>
</td>
<td>
<?php if (trim($row['jr_internal'])!='') : ?>
<?php if (trim($row['jr_internal']??"")!='') : ?>
<?php echo HtmlInput::detail_op($row['jr_id'],$row['jr_internal'])?>
<?php endif; ?>
</td>

View file

@ -89,7 +89,7 @@
<?php echo _("DIFF")?> :
</td>
<td class="num">
<?php echo nbm((bcsub($array[0]['s_qin'],$array[0]['s_qout'])))?>
<?php echo nbm((bcsub($array[0]['s_qin']??0,$array[0]['s_qout']??0)))?>
</td>
</tr>
</table>

View file

@ -2252,14 +2252,14 @@ function UTF8ToUTF16BE($str, $setbom=true) {
if ($setbom) {
$outstr .= "\xFE\xFF"; // Byte Order Mark (BOM)
}
$outstr .= mb_convert_encoding($str, 'UTF-16BE', 'UTF-8');
$outstr .= mb_convert_encoding($str??"", 'UTF-16BE', 'UTF-8');
return $outstr;
}
// Converts UTF-8 strings to codepoints array
function UTF8StringToArray($str) {
$out = array();
$len = strlen($str);
$len = strlen($str??"");
for ($i = 0; $i < $len; $i++) {
$uni = -1;
$h = ord($str[$i]);

View file

@ -35,6 +35,7 @@ echo '<div class="content" >';
if ( isset ($_POST["ADD"]) )
{
$cn=new Database();
$a_result =check_password_strength($_POST['PASS']);
$pass5=md5($_POST['PASS']);
$new_user=new Noalyss_user($cn,0);
$new_user->first_name=$http->post('FNAME');
@ -45,11 +46,18 @@ if ( isset ($_POST["ADD"]) )
$login=str_replace(" ","",$login);
$login=strtolower($login);
$new_user->login=$login;
$new_user->setPassword($pass5);
$new_user->email=$http->post('EMAIL',"string",'');
if ( trim($login)=="")
{
alert(_("Le login ne peut pas être vide"));
}elseif (count($a_result['msg']) > 0){
// password too weak
$msg='<span class="warning">'._("Mot de passe inchangé").'</span>';
foreach ($a_result['msg'] as $result ) {
$msg.="$result <br/>";
}
alert($msg);
}
else
{
@ -101,8 +109,18 @@ if ($sbaction == "save")
}
if ( trim($_POST['password'])<>'')
{
$UserChange->setPassword(md5($_POST['password']));
$UserChange->save();
$a_result =check_password_strength($_POST['password']);
if (count($a_result['msg']) > 0){
// password too weak
$msg='<span class="warning">'._("Mot de passe inchangé").'</span>';
foreach ($a_result['msg'] as $result ) {
$msg.="$result <br/>";
}
alert($msg);
} else {
$UserChange->setPassword(md5($_POST['password']));
$UserChange->save();
}
}
else
{
@ -168,9 +186,19 @@ if ( isset($_REQUEST['det']) && $sbaction=="")
<TR><TD style="text-align: right"> <?php echo _('login')?></TD><TD><INPUT id="input_login" class="input_text" TYPE="TEXT" NAME="LOGIN"></TD></tr>
<TR><TD style="text-align: right"> <?php echo _('Prénom')?></TD><TD><INPUT class="input_text" TYPE="TEXT" NAME="FNAME"></TD></tr>
<TR><TD style="text-align: right"> <?php echo _('Nom')?></TD><TD><INPUT class="input_text" TYPE="TEXT" NAME="LNAME"></TD></TR>
<TR><TD style="text-align: right"> <?php echo _('Mot de passe')?></TD><TD> <INPUT id="input_password" class="input_text" TYPE="TEXT" NAME="PASS"></TD></TR>
<TR>
<TD style="text-align: right"> <?php echo _('Mot de passe')?>
<?=\Icon_Action::tips("Mot de passe : longueur minimale = 8 dont au moins 1 majuscule, 1 minuscule,1 chiffre et 1 car.spécial")?>
</TD>
<TD> <INPUT id="input_password" class="input_text" TYPE="TEXT" NAME="PASS"
onkeyup=check_password_strength('input_password','info_passid')
>
<span id="info_passid"></span>
</TD></TR>
<TR><TD style="text-align: right"> <?php echo _('Email')?></TD><TD> <INPUT class="input_text" TYPE="TEXT" NAME="EMAIL"></TD></TR>
</TABLE>
<?php
echo HtmlInput::submit("ADD",_('Créer Utilisateur'),"",'button');
echo HtmlInput::button_action(_("Fermer"), "$('create_user').style.display='none';");

View file

@ -42,6 +42,7 @@ if ($UserChange->id == false)
$UserChange->load();
$it_pass=new IText('password');
$it_pass->javascript='onkeyup="check_password_strength(\'password\',\'password_info\',1)"';
$it_pass->value="";
?>
<FORM id="user_detail_frm" METHOD="POST">
@ -81,6 +82,7 @@ $it_pass->value="";
</td>
<td>
<?php echo $it_pass->input();?>
<span id="password_info" style="background-color: yellow;color:red;position:absolute"></span>
</td>
</tr>
<tr>

View file

@ -59,4 +59,37 @@ class DossierTest extends TestCase
$obj->load();
$this->assertEquals(DOSSIER,$obj->get_parameter("id"),"Not the right folder");
}
/**
* @testdox check
*/
public function testCheck()
{
$_REQUEST['gDossier']='14';
\Dossier::check();
$this->assertTrue(true, 'check has failed');
}
/**
* @testdox hidden function
*/
function testHidden()
{
$_REQUEST['gDossier']='14';
$this->assertEquals('<input type="hidden" id="gDossier" name="gDossier" value="14">', \Dossier::hidden());
}
/**
* @testdox get function
*/
function testGet()
{
$_REQUEST['gDossier']='14';
$this->assertEquals('gDossier=14', \Dossier::get());
}
/**
* @testdox set current dossier
*/
function testSetCurrentDossier()
{
\Dossier::set_current(15);
$this->assertEquals(15, \Dossier::id());
}
}

View file

@ -424,4 +424,46 @@ EOF;
$this->assertEquals(strtoupper($expect),strtoupper(preg_replace("/\s+/",'',faxTo('123'))),);
}
/**
* supply data for user password
* @return array[$password, $weakness] 0 means strong password
*/
public function dataCheck_password_strength()
{
return array(
["AAAAAAA",5]
,["123456789",3]
,["Az123456789",1]
,["",4]
,["+",4]
,["AAAA121212abx",2]
,["Az&123456789",0]
,["l5F8Cny=",0]
);
}
/**
* @testDoc test the check_password_strength function
* @dataProvider dataCheck_password_strength()
*/
public function testCheck_password_strength($p_password,$p_cnt)
{
$count=count(check_password_strength($p_password)['msg']);
$this->assertTrue($count ==$p_cnt,"error : $p_password weak password $count" );
}
public function testGenerate_strong_password()
{
for ($i = 0; $i < 100; $i++)
{
$pass=generate_random_password(5);
$this->assertTrue( count(check_password_strength($pass)['msg'])==0
,"error cannot generate strong password get $pass");
}
}
}