From 4debd71281f5e3b8df2d160b20092a94353a515d Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 6 Dec 2019 08:26:49 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/compta/bank/card.php | 6 +- htdocs/core/class/doleditor.class.php | 156 ++++++++++---------- htdocs/core/class/html.formticket.class.php | 18 +-- htdocs/core/lib/images.lib.php | 140 +++++++++--------- htdocs/document.php | 88 +++++------ htdocs/product/list.php | 6 +- 6 files changed, 207 insertions(+), 207 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 2ba96a2cf8d..2897eb6e5c3 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -492,11 +492,11 @@ if ($action == 'create') $content = $object->code_guichet; } elseif ($val == 'BankAccountNumber') { $name = 'number'; - $sizecss = 'minwidth200'; + $sizecss = 'minwidth200'; $content = $object->number; } elseif ($val == 'BankAccountNumberKey') { $name = 'cle_rib'; - $sizecss = 'minwidth50'; + $sizecss = 'minwidth50'; $content = $object->cle_rib; } @@ -923,7 +923,7 @@ else $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); if (is_array($cats)) { - foreach($cats as $cat) { + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } } diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index d449e7a8424..29bb1c24dce 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -28,7 +28,7 @@ */ class DolEditor { - public $tool; // Store the selected tool + public $tool; // Store the selected tool // If using fckeditor public $editor; @@ -66,55 +66,55 @@ class DolEditor */ public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) { - global $conf,$langs; + global $conf, $langs; dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); - if (! $rows) $rows=round($height/20); - if (! $cols) $cols=($width?round($width/6):80); - $shorttoolbarname=preg_replace('/_encoded$/', '', $toolbarname); + if (!$rows) $rows = round($height / 20); + if (!$cols) $cols = ($width ?round($width / 6) : 80); + $shorttoolbarname = preg_replace('/_encoded$/', '', $toolbarname); // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') - $defaulteditor='ckeditor'; - $this->tool=empty($conf->global->FCKEDITOR_EDITORNAME)?$defaulteditor:$conf->global->FCKEDITOR_EDITORNAME; - $this->uselocalbrowser=$uselocalbrowser; - $this->readonly=$readonly; + $defaulteditor = 'ckeditor'; + $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; + $this->uselocalbrowser = $uselocalbrowser; + $this->readonly = $readonly; // Check if extended editor is ok. If not we force textarea if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; - if ($okforextendededitor === 'ace') $this->tool='ace'; + if ($okforextendededitor === 'ace') $this->tool = 'ace'; //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile // Define content and some properties if ($this->tool == 'ckeditor') { - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. + $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. } if ($this->tool == 'fckeditor') { require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. + $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. $this->editor = new FCKeditor($htmlname); - $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; - $this->editor->Value = $content; + $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/'; + $this->editor->Value = $content; $this->editor->Height = $height; - if (! empty($width)) $this->editor->Width = $width; - $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js - $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) + if (!empty($width)) $this->editor->Width = $width; + $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js + $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? - $modulepart='fckeditor'; + $modulepart = 'fckeditor'; $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; - $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; + $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/'; - $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); - $this->editor->Config['ImageBrowser']=($uselocalbrowser?'true':'false'); + $this->editor->Config['LinkBrowser'] = ($uselocalbrowser ? 'true' : 'false'); + $this->editor->Config['ImageBrowser'] = ($uselocalbrowser ? 'true' : 'false'); if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) { @@ -124,15 +124,15 @@ class DolEditor } // Define some properties - if (in_array($this->tool, array('textarea','ckeditor','ace'))) + if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) { - $this->content = $content; + $this->content = $content; $this->htmlname = $htmlname; - $this->toolbarname = $shorttoolbarname; + $this->toolbarname = $shorttoolbarname; $this->toolbarstartexpanded = $toolbarstartexpanded; $this->rows = max(ROWS_3, $rows); - $this->cols = (preg_match('/%/', $cols)?$cols:max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max - $this->height = $height; + $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max + $this->height = $height; $this->width = $width; } } @@ -152,45 +152,45 @@ class DolEditor public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $fullpage=false; + $fullpage = false; if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) { - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all + $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all } - $found=0; - $out=''; + $found = 0; + $out = ''; if ($this->tool == 'fckeditor') // not used anymore { - $found=1; + $found = 1; $this->editor->Create(); } - if (in_array($this->tool, array('textarea','ckeditor'))) + if (in_array($this->tool, array('textarea', 'ckeditor'))) { - $found=1; + $found = 1; //$out.= ''; + $out .= ''; - if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax) && ! empty($conf->fckeditor->enabled)) + if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) { - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); + if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); - if (! empty($conf->global->FCKEDITOR_SKIN)) { + if (!empty($conf->global->FCKEDITOR_SKIN)) { $skin = $conf->global->FCKEDITOR_SKIN; } else { $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa } - $htmlencode_force=preg_match('/_encoded$/', $this->toolbarname)?'true':'false'; + $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out.= ''."\n"; - $out.= ''."\n"; + $out .= ' })'.$morejs; + $out .= '});'."\n"; + $out .= ''."\n"; } } @@ -259,19 +259,19 @@ class DolEditor // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. if (preg_match('/^ace/', $this->tool)) { - $found=1; - $format=$option; + $found = 1; + $format = $option; - $out.= "\n".''."\n"; + $out .= "\n".''."\n"; if ($titlecontent) { - $out.= '
'.$titlecontent; - $out.= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; - $out.= '
'; - $out.= ''."\n"; + $out .= ''."\n"; } - $out.= '
htmlname.'aceeditorid" style="'.($this->width ? 'width: '.$this->width.'px; ' : '');
+            $out .= ($this->height ? ' height: '.$this->height.'px; ' : '');
             //$out.=" min-height: 100px;";
-            $out.= '">';
-        	$out.= htmlspecialchars($this->content);
-        	$out.= '
'; - $out.= ''; + $out .= '">'; + $out .= htmlspecialchars($this->content); + $out .= ''; + $out .= ''; - $out.= ''."\n"; + $out .= ''."\n"; } if (empty($found)) { - $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; + $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; } if ($noprint) return $out; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index cdea1c17e01..117af9e8f19 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -376,33 +376,33 @@ class FormTicket } $out = ''; - $out .= '' . $langs->trans("MailFile") . ''; + $out .= ''.$langs->trans("MailFile").''; $out .= ''; // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out .= '' . "\n"; + $out .= ''."\n"; $out .= '' . "\n"; + $out .= ''."\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { - $out .= '
'; - $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; + $out .= '
'; + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; if (!$this->withfilereadonly) { - $out .= ' '; + $out .= ' '; } $out .= '
'; } } else { - $out .= $langs->trans("NoAttachedFiles") . '
'; + $out .= $langs->trans("NoAttachedFiles").'
'; } if ($this->withfile == 2) { // Can add other files - $out .= ''; + $out .= ''; $out .= ' '; - $out .= ''; + $out .= ''; } $out .= "\n"; diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 93174a7c390..69b907036c1 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -23,8 +23,8 @@ */ // Define size of logo small and mini -$maxwidthsmall=270;$maxheightsmall=150; -$maxwidthmini=128;$maxheightmini=72; +$maxwidthsmall = 270; $maxheightsmall = 150; +$maxwidthmini = 128; $maxheightmini = 72; $quality = 80; @@ -37,14 +37,14 @@ $quality = 80; */ function image_format_supported($file) { - $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php + $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php // Case filename is not a format image $reg = array(); - if (! preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; + if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; // Case filename is a format image but not supported by this PHP - $imgfonction=''; + $imgfonction = ''; if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; @@ -52,10 +52,10 @@ function image_format_supported($file) if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; - if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available + if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available if ($imgfonction) { - if (! function_exists($imgfonction)) + if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP return 0; @@ -76,21 +76,21 @@ function image_format_supported($file) */ function dol_getImageSize($file, $url = false) { - $ret=array(); + $ret = array(); if (image_format_supported($file) < 0) return $ret; $filetoread = $file; if (!$url) { - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image } if ($filetoread) { $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image - $ret['width']=$infoImg[0]; // Largeur de l'image - $ret['height']=$infoImg[1]; // Hauteur de l'image + $ret['width'] = $infoImg[0]; // Largeur de l'image + $ret['height'] = $infoImg[1]; // Hauteur de l'image } return $ret; @@ -112,29 +112,29 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - global $conf,$langs; + global $conf, $langs; dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); // Clean parameters - $file=trim($file); + $file = trim($file); // Check parameters - if (! $file) + if (!$file) { // Si le fichier n'a pas ete indique return 'Bad parameter file'; } - elseif (! file_exists($file)) + elseif (!file_exists($file)) { // Si le fichier passe en parametre n'existe pas return $langs->trans("ErrorFileNotFound", $file); } - elseif(image_format_supported($file) < 0) + elseif (image_format_supported($file) < 0) { return 'This filename '.$file.' does not seem to be an image filename.'; } - elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) + elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) { return 'Wrong value for parameter newWidth or newHeight'; } @@ -147,7 +147,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, return 'Both newHeight or newWidth must be defined for croping'; } - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image $imgWidth = $infoImg[0]; // Largeur de l'image @@ -155,18 +155,18 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, if ($mode == 0) // If resize, we check parameters { - if ($newWidth <= 0) + if ($newWidth <= 0) { - $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio + $newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio } if ($newHeight <= 0) { - $newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio + $newHeight = intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio } } - $imgfonction=''; - switch($infoImg[2]) + $imgfonction = ''; + switch ($infoImg[2]) { case 1: // IMG_GIF $imgfonction = 'imagecreatefromgif'; @@ -183,7 +183,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } if ($imgfonction) { - if (! function_exists($imgfonction)) + if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; @@ -191,27 +191,27 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Initialisation des variables selon l'extension de l'image - switch($infoImg[2]) + switch ($infoImg[2]) { case 1: // Gif $img = imagecreatefromgif($filetoread); - $extImg = '.gif'; // File name extension of image - $newquality='NU'; // Quality is not used for this format + $extImg = '.gif'; // File name extension of image + $newquality = 'NU'; // Quality is not used for this format break; case 2: // Jpg $img = imagecreatefromjpeg($filetoread); $extImg = '.jpg'; - $newquality=100; // % quality maximum + $newquality = 100; // % quality maximum break; case 3: // Png $img = imagecreatefrompng($filetoread); $extImg = '.png'; - $newquality=0; // No compression (0-9) + $newquality = 0; // No compression (0-9) break; case 4: // Bmp $img = imagecreatefromwbmp($filetoread); $extImg = '.bmp'; - $newquality='NU'; // Quality is not used for this format + $newquality = 'NU'; // Quality is not used for this format break; } @@ -239,7 +239,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Initialisation des variables selon l'extension de l'image - switch($infoImg[2]) + switch ($infoImg[2]) { case 1: // Gif $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF @@ -250,7 +250,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, break; case 3: // Png imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel break; case 4: // Bmp $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); @@ -260,7 +260,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee - imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee + imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee $imgThumbName = $file; @@ -269,7 +269,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, //fclose($fp); // Create image on disk - switch($infoImg[2]) + switch ($infoImg[2]) { case 1: // Gif imagegif($imgThumb, $imgThumbName); @@ -286,13 +286,13 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Set permissions on file - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); // Free memory. This does not delete image. imagedestroy($img); imagedestroy($imgThumb); - clearstatcache(); // File was replaced by a modified one, so we clear file caches. + clearstatcache(); // File was replaced by a modified one, so we clear file caches. return $imgThumbName; } @@ -343,7 +343,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) break; } if ($deg) { - if($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case + if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case { imagealphablending($img, false); imagesavealpha($img, true); @@ -351,12 +351,12 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) imagealphablending($img, false); imagesavealpha($img, true); } - else{ + else { $img = imagerotate($img, $deg, 0); } } // then rewrite the rotated image back to the disk as $fileDest - if($fileDest === false){ + if ($fileDest === false) { return $img; } else @@ -365,7 +365,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) // Create image on disk $image = false; - switch($infoImg[2]) + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $image = imagegif($img, $fileDest); @@ -473,8 +473,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; } - $imgfonction=''; - switch($infoImg[2]) + $imgfonction = ''; + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $imgfonction = 'imagecreatefromgif'; @@ -494,7 +494,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } if ($imgfonction) { - if (! function_exists($imgfonction)) + if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; @@ -502,12 +502,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // On cree le repertoire contenant les vignettes - $dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes + $dirthumb = dirname($file).($outdir ? '/'.$outdir : ''); // Chemin du dossier contenant les vignettes dol_mkdir($dirthumb); // Initialisation des variables selon l'extension de l'image - $img=null; - switch($infoImg[2]) + $img = null; + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $img = imagecreatefromgif($filetoread); @@ -515,7 +515,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', break; case IMAGETYPE_JPEG: // 2 $img = imagecreatefromjpeg($filetoread); - $extImg = (preg_match('/\.jpeg$/', $file)?'.jpeg':'.jpg'); // Extension de l'image + $extImg = (preg_match('/\.jpeg$/', $file) ? '.jpeg' : '.jpg'); // Extension de l'image break; case IMAGETYPE_PNG: // 3 $img = imagecreatefrompng($filetoread); @@ -571,12 +571,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', imagealphablending($rotated, false); imagesavealpha($rotated, true); } - else{ + else { $rotated = imagerotate($img, $exifAngle, 0); } // replace image with good orientation - if(!empty($rotated)){ + if (!empty($rotated)) { $img = $rotated; $imgWidth = $trueImgWidth; $imgHeight = $trueImgHeight; @@ -584,14 +584,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Initialisation des dimensions de la vignette si elles sont superieures a l'original - if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } - if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; } + if ($maxWidth > $imgWidth) { $maxWidth = $imgWidth; } + if ($maxHeight > $imgHeight) { $maxHeight = $imgHeight; } - $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette - $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original + $whFact = $maxWidth / $maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette + $imgWhFact = $imgWidth / $imgHeight; // Facteur largeur/hauteur de l'original // Fixe les dimensions de la vignette - if($whFact < $imgWhFact) + if ($whFact < $imgWhFact) { // Si largeur determinante $thumbWidth = $maxWidth; @@ -603,11 +603,11 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $thumbHeight = $maxHeight; $thumbWidth = $thumbHeight * $imgWhFact; } - $thumbHeight=round($thumbHeight); - $thumbWidth=round($thumbWidth); + $thumbHeight = round($thumbHeight); + $thumbWidth = round($thumbWidth); // Define target format - if (empty($targetformat)) $targetformat=$infoImg[2]; + if (empty($targetformat)) $targetformat = $infoImg[2]; // Create empty image if ($targetformat == IMAGETYPE_GIF) @@ -634,35 +634,35 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Initialisation des variables selon l'extension de l'image // $targetformat is 0 by default, in such case, we keep original extension - switch($targetformat) + switch ($targetformat) { case IMAGETYPE_GIF: // 1 $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF imagecolortransparent($imgThumb, $trans_colour); $extImgTarget = '.gif'; - $newquality='NU'; + $newquality = 'NU'; break; case IMAGETYPE_JPEG: // 2 $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); - $extImgTarget = (preg_match('/\.jpeg$/i', $file)?'.jpeg':'.jpg'); - $newquality=$quality; + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg'); + $newquality = $quality; break; case IMAGETYPE_PNG: // 3 imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel $extImgTarget = '.png'; - $newquality=$quality-100; - $newquality=round(abs($quality-100)*9/100); + $newquality = $quality - 100; + $newquality = round(abs($quality - 100) * 9 / 100); break; case IMAGETYPE_BMP: // 6 // Not supported by PHP GD $extImgTarget = '.bmp'; - $newquality='NU'; + $newquality = 'NU'; break; case IMAGETYPE_WBMP: // 15 $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); $extImgTarget = '.bmp'; - $newquality='NU'; + $newquality = 'NU'; break; } if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); @@ -671,10 +671,10 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee - $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // On enleve extension quelquesoit la casse + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // On enleve extension quelquesoit la casse $fileName = basename($fileName); //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file - $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file + $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file // Check if permission are ok @@ -682,7 +682,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', //fclose($fp); // Create image on disk - switch($targetformat) + switch ($targetformat) { case IMAGETYPE_GIF: // 1 imagegif($imgThumb, $imgThumbName); @@ -702,7 +702,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Set permissions on file - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); // Free memory. This does not delete image. imagedestroy($img); diff --git a/htdocs/document.php b/htdocs/document.php index f196cb9eda9..c1ed149649e 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -32,24 +32,24 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // For direct external download link, we don't need to load/check we are into a login session -if (isset($_GET["hashp"]) && ! defined("NOLOGIN")) +if (isset($_GET["hashp"]) && !defined("NOLOGIN")) { - if (! defined("NOLOGIN")) define("NOLOGIN", 1); - if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - if (! defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip + if (!defined("NOLOGIN")) define("NOLOGIN", 1); + if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. + if (!defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // Some value of modulepart can be used to get resources that are public so no login are required. if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) { - if (! defined("NOLOGIN")) define("NOLOGIN", 1); - if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - if (! defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip + if (!defined("NOLOGIN")) define("NOLOGIN", 1); + if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. + if (!defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } /** @@ -71,30 +71,30 @@ function llxFooter() { } -require 'main.inc.php'; // Load $user and permissions +require 'main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $encoding = ''; -$action=GETPOST('action', 'alpha'); -$original_file=GETPOST('file', 'alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). -$hashp=GETPOST('hashp', 'aZ09'); -$modulepart=GETPOST('modulepart', 'alpha'); -$urlsource=GETPOST('urlsource', 'alpha'); -$entity=GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; +$action = GETPOST('action', 'alpha'); +$original_file = GETPOST('file', 'alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). +$hashp = GETPOST('hashp', 'aZ09'); +$modulepart = GETPOST('modulepart', 'alpha'); +$urlsource = GETPOST('urlsource', 'alpha'); +$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; // Security check if (empty($modulepart) && empty($hashp)) accessforbidden('Bad link. Bad value for parameter modulepart', 0, 0, 1); if (empty($original_file) && empty($hashp)) accessforbidden('Bad link. Missing identification to find file (original_file or hashp)', 0, 0, 1); -if ($modulepart == 'fckeditor') $modulepart='medias'; // For backward compatibility +if ($modulepart == 'fckeditor') $modulepart = 'medias'; // For backward compatibility -$socid=0; +$socid = 0; if ($user->socid > 0) $socid = $user->socid; // For some module part, dir may be privates -if (in_array($modulepart, array('facture_paiement','unpaid'))) +if (in_array($modulepart, array('facture_paiement', 'unpaid'))) { - if (! $user->rights->societe->client->voir || $socid) $original_file='private/'.$user->id.'/'.$original_file; // If user has no permission to see all, output dir is specific to user + if (!$user->rights->societe->client->voir || $socid) $original_file = 'private/'.$user->id.'/'.$original_file; // If user has no permission to see all, output dir is specific to user } @@ -111,27 +111,27 @@ if (in_array($modulepart, array('facture_paiement','unpaid'))) */ // If we have a hash public (hashp), we guess the original_file. -if (! empty($hashp)) +if (!empty($hashp)) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); + $ecmfile = new EcmFiles($db); $result = $ecmfile->fetch(0, '', '', '', $hashp); if ($result > 0) { - $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory + $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory // filepath can be 'users/X' or 'X/propale/PR11111' if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part. { $tmp = explode('/', $tmp[1], 2); } - $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path + $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. { if ($moduleparttocheck == $modulepart) { // We remove first level of directory - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir + $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir //var_dump($original_file); exit; } else @@ -142,7 +142,7 @@ if (! empty($hashp)) else { $modulepart = $moduleparttocheck; - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir + $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir } } else @@ -155,13 +155,13 @@ if (! empty($hashp)) // Define attachment (attachment=true to force choice popup 'open'/'save as') $attachment = true; if (preg_match('/\.(html|htm)$/i', $original_file)) $attachment = false; -if (isset($_GET["attachment"])) $attachment = GETPOST("attachment", 'alpha')?true:false; -if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; +if (isset($_GET["attachment"])) $attachment = GETPOST("attachment", 'alpha') ?true:false; +if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; // Define mime type $type = 'application/octet-stream'; -if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha'); -else $type=dol_mimetype($original_file); +if (GETPOST('type', 'alpha')) $type = GETPOST('type', 'alpha'); +else $type = dol_mimetype($original_file); // Security: Force to octet-stream if file is a dangerous file if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream'; @@ -169,7 +169,7 @@ if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream $original_file = str_replace("../", "/", $original_file); // Find the subdirectory name as the reference -$refname=basename(dirname($original_file)."/"); +$refname = basename(dirname($original_file)."/"); // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); @@ -178,11 +178,11 @@ if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; -$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name +$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name -if (! empty($hashp)) +if (!empty($hashp)) { - $accessallowed = 1; // When using hashp, link is public so we force $accessallowed + $accessallowed = 1; // When using hashp, link is public so we force $accessallowed $sqlprotectagainstexternals = ''; } else @@ -195,14 +195,14 @@ else $resql = $db->query($sqlprotectagainstexternals); if ($resql) { - $num=$db->num_rows($resql); - $i=0; + $num = $db->num_rows($resql); + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); if ($user->socid != $obj->fk_soc) { - $accessallowed=0; + $accessallowed = 0; break; } $i++; @@ -214,7 +214,7 @@ else // Security: // Limit access if permissions are wrong -if (! $accessallowed) +if (!$accessallowed) { accessforbidden(); } @@ -236,10 +236,10 @@ $filename = preg_replace('/\.noexe$/i', '', $filename); // Output file on browser dol_syslog("document.php download $fullpath_original_file filename=$filename content-type=$type"); -$fullpath_original_file_osencoded=dol_osencode($fullpath_original_file); // New file name encoded in OS encoding charset +$fullpath_original_file_osencoded = dol_osencode($fullpath_original_file); // New file name encoded in OS encoding charset // This test if file exists should be useless. We keep it to find bug more easily -if (! file_exists($fullpath_original_file_osencoded)) +if (!file_exists($fullpath_original_file_osencoded)) { dol_syslog("ErrorFileDoesNotExists: ".$fullpath_original_file); print "ErrorFileDoesNotExists: ".$original_file; @@ -264,8 +264,8 @@ if (!$attachment && !empty($conf->global->MAIN_USE_EXIF_ROTATION) && image_forma $readfile = !$imgres; } -if($readfile){ - header('Content-Length: ' . dol_filesize($fullpath_original_file)); +if ($readfile) { + header('Content-Length: '.dol_filesize($fullpath_original_file)); readfile($fullpath_original_file_osencoded); } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 05cc5752777..9a17a754dc1 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -488,7 +488,7 @@ if ($resql) { $oldtype = $type; $params = array(); - if ($type === "") $params['forcenohideoftext']=1; + if ($type === "") $params['forcenohideoftext'] = 1; if ($type === "") { $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', 1, $params); $type = Product::TYPE_SERVICE; @@ -853,7 +853,7 @@ if ($resql) $product_static->id = $obj->rowid; $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; // deprecated + $product_static->ref_fourn = $obj->ref_supplier; // deprecated $product_static->ref_supplier = $obj->ref_supplier; $product_static->label = $obj->label; $product_static->type = $obj->fk_product_type; @@ -886,7 +886,7 @@ if ($resql) { $option = 'nobatch'; if (empty($arrayfields['stock_virtual']['checked'])) $option .= ',novirtual'; - $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() } }