Skip to content

Commit

Permalink
Fix scrutinizer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 4, 2018
1 parent 5839ced commit 6338328
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 33 deletions.
2 changes: 2 additions & 0 deletions htdocs/core/boxes/box_graph_invoices_permonth.php
Expand Up @@ -91,6 +91,8 @@ function loadBox($max=5)

if ($user->rights->facture->lire)
{
$mesg = '';

$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/commondocgenerator.class.php
Expand Up @@ -319,7 +319,7 @@ function get_substitutionarray_other($outputlangs)

foreach($conf->global as $key => $val)
{
if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****';
if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****';
else $newval = $val;
$array_other['__['.$key.']__'] = $newval;
}
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/class/commonobject.class.php
Expand Up @@ -4691,7 +4691,8 @@ function insertExtraFields($trigger='', $userused=null)
if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']))
{
// If there is an encryption choice, we use it to crypt data before insert
$algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']));
$tmparrays = array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])
$algo=reset($tmparrays);
if ($algo != '')
{
//global $action; // $action may be 'create', 'update', 'update_extras'...
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/class/extrafields.class.php
Expand Up @@ -235,6 +235,7 @@ private function create($attrname, $type='varchar', $length=255, $elementtype='m
$lengthdb='11';
} elseif ($type=='html') {
$typedb='text';
$lengthdb=$length;
} elseif($type=='password') {
$typedb='varchar';
$lengthdb='128';
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/class/html.formactions.class.php
Expand Up @@ -194,6 +194,7 @@ function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecs
$projectid = $object->fk_project;
if ($typeelement == 'project') $projectid = $object->id;

$buttontoaddnewevent='';
if (! empty($conf->agenda->enabled))
{
$buttontoaddnewevent = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:'').($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'">';
Expand Down
7 changes: 3 additions & 4 deletions htdocs/core/class/html.formwebsite.class.php
Expand Up @@ -164,7 +164,7 @@ function selectTypeOfContainer($htmlname, $selected='', $useempty=0, $moreattrib
*
* @param string $htmlname Name of select zone
* @param string $selected Selected value
* @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
* @param int $useempty 1=Add an empty value in list
* @param string $moreattrib More attributes on HTML select tag
* @return void
*/
Expand All @@ -177,9 +177,9 @@ function selectSampleOfContainer($htmlname, $selected='', $useempty=0, $moreattr
$arrayofsamples=array('corporatehome'=>'CorporateHomePage', 'empty'=>'EmptyPage');

$out = '';

$out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
if ($useempty == 1 || ($useempty == 2 && $num > 1))

if ($useempty == 1 || $useempty == 2)
{
$out .= '<option value="-1">&nbsp;</option>';
}
Expand All @@ -196,7 +196,6 @@ function selectSampleOfContainer($htmlname, $selected='', $useempty=0, $moreattr
}
$out .= $langs->trans($val);
$out .= '</option>';
$i++;
}
$out .= "</select>";

Expand Down
5 changes: 3 additions & 2 deletions htdocs/core/lib/admin.lib.php
Expand Up @@ -1288,9 +1288,10 @@ function complete_elementList_with_modules(&$elementList)

$modules[$i] = $objMod;
$filename[$i]= $modName;
$orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module
$orders[$i] = $objMod->family."_".$j; // Sort on family then module number
$dirmod[$i] = $dir;
//print "x".$modName." ".$orders[$i]."\n<br>";
$dirmod[$i] = $dirroot;

if (! empty($objMod->module_parts['contactelement']))
{
$elementList[$objMod->name] = $langs->trans($objMod->name);
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/lib/website.lib.php
Expand Up @@ -177,6 +177,7 @@ function redirectToContainer($containerref, $containeraliasalt='',$containerid=0
global $db, $website;

$newurl = '';
$result=0;

// We make redirect using the alternative alias, we must find the real $containerref
if ($containeraliasalt)
Expand Down
45 changes: 21 additions & 24 deletions htdocs/societe/class/societe.class.php
Expand Up @@ -1169,7 +1169,7 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='
$sql .= ' WHERE s.entity IN ('.getEntity($this->element).')';
if ($rowid) $sql .= ' AND s.rowid = '.$rowid;
if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'";
if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'";
if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($ref_alias)."'";
if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'";
if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'";
Expand Down Expand Up @@ -2833,10 +2833,10 @@ function id_prof_check($idprof,$soc)

//Check NIF
if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string))
if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1))
return 1;
else
return -1;
if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1))
return 1;
else
return -1;

//algorithm checking type code CIF
$sum = $num[2] + $num[4] + $num[6];
Expand All @@ -2846,31 +2846,31 @@ function id_prof_check($idprof,$soc)

//Chek special NIF
if (preg_match('/^[KLM]{1}/', $string))
if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1))
return 1;
else
return -1;
if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1))
return 1;
else
return -1;

//Check CIF
if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string))
if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1))
return 2;
else
return -2;
if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1))
return 2;
else
return -2;

//Check NIE T
if (preg_match('/^[T]{1}/', $string))
if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string))
return 3;
else
return -3;
if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string))
return 3;
else
return -3;

//Check NIE XYZ
if (preg_match('/^[XYZ]{1}/', $string))
if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1))
return 3;
else
return -3;
if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1))
return 3;
else
return -3;

//Can not be verified
return -4;
Expand All @@ -2894,9 +2894,6 @@ function id_prof_check($idprof,$soc)
else {
return -1;
}

//Wrong format
return 0;
}

return $ok;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/website/class/website.class.php
Expand Up @@ -616,7 +616,7 @@ public function createFromClone($user, $fromid, $newref)

// Generate the index.php page to be the home page
//-------------------------------------------------
$result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl);
$result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl);
}
}

Expand Down

0 comments on commit 6338328

Please sign in to comment.