@@ -70,14 +70,14 @@ public function __construct(&$wiki)
7070 public function file_upload_max_size ()
7171 {
7272 static $ max_size = -1 ;
73-
73+
7474 if ($ max_size < 0 ) {
7575 // Start with post_max_size.
7676 $ post_max_size = $ this ->parse_size (ini_get ('post_max_size ' ));
7777 if ($ post_max_size > 0 ) {
7878 $ max_size = $ post_max_size ;
7979 }
80-
80+
8181 // If upload_max_size is less, then reduce. Except if upload_max_size is
8282 // zero, which indicates no limit.
8383 $ upload_max = $ this ->parse_size (ini_get ('upload_max_filesize ' ));
@@ -291,7 +291,7 @@ public function isWma()
291291 {
292292 return preg_match ("/.( " . $ this ->attachConfig ["ext_wma " ] . ")$/i " , $ this ->file ) == 1 ;
293293 }
294-
294+
295295 /**
296296 * Test si le fichier est un fichier pdf
297297 */
@@ -497,7 +497,7 @@ public function showAsImage($fullFilename)
497497 $ width = $ width - 20 ;
498498 $ height = $ height - 20 ;
499499 }
500-
500+
501501 //c'est une image : balise <IMG..../>
502502 $ img = "<img class= \"img-responsive \" src= \"" . $ this ->GetScriptPath () . $ img_name . "\" " .
503503 "alt= \"" . $ this ->desc . ($ this ->link ? "\nLien vers: $ this ->link " : "" ) . "\" width= \"" . $ width . "\" height= \"" . $ height . "\" /> " ;
@@ -544,7 +544,7 @@ public function showAsImage($fullFilename)
544544 }
545545
546546 $ notAligned = (strpos ($ this ->classes , 'left ' ) === false && strpos ($ this ->classes , 'right ' ) == false && strpos ($ this ->classes , 'center ' ) == false );
547- $ output = ($ notAligned ? '<div> ' : '' ).(isset ($ link ) ? $ link : '' )."<figure class= \"$ this ->classes \" $ data> $ img$ caption$ legend</figure> " .(isset ($ link ) ? '</a> ' : '' ).($ notAligned ? '</div> ' :'' );
547+ $ output = ($ notAligned ? '<div> ' : '' ).(isset ($ link ) ? $ link : '' )."<figure class= \"$ this ->classes \" $ data> $ img$ caption$ legend</figure> " .(isset ($ link ) ? '</a> ' : '' ).($ notAligned ? '</div> ' : '' );
548548
549549 echo $ output ;
550550 //$this->showUpdateLink();
@@ -595,7 +595,7 @@ public function showAsWma($fullFilename)
595595 }
596596
597597 // End Paste
598-
598+
599599 // Affiche le fichier liee comme un fichier pdf
600600 public function showAsPDF ($ fullFilename )
601601 {
@@ -624,12 +624,12 @@ public function showAsPDF($fullFilename)
624624 $ newclass = str_replace ('left ' , 'pull-left ' , $ this ->classes ) ;
625625 }
626626 }
627-
627+
628628 // define class
629629 if ($ newclass != '' ) {
630630 $ this ->wiki ->setParameter ('class ' , $ newclass ) ;
631631 }
632-
632+
633633 // Call pdf actions
634634 $ params = $ this ->wiki ->parameter ;
635635 echo $ this ->wiki ->Action ('pdf ' , 0 , $ params ) ;
@@ -745,39 +745,39 @@ public function performUpload()
745745 }
746746 }
747747 switch ($ _FILES ['upFile ' ]['error ' ]) {
748- case 0 :
749- $ srcFile = $ _FILES ['upFile ' ]['tmp_name ' ];
750- if (move_uploaded_file ($ srcFile , $ destFile )) {
751- chmod ($ destFile , 0644 );
752- if ($ ext === 'svg ' || $ ext === 'xml ' ) {
753- $ purifier = $ this ->wiki ->services ->get (HtmlPurifierService::class);
754- $ purifier ->cleanFile ($ destFile , $ ext );
748+ case 0 :
749+ $ srcFile = $ _FILES ['upFile ' ]['tmp_name ' ];
750+ if (move_uploaded_file ($ srcFile , $ destFile )) {
751+ chmod ($ destFile , 0644 );
752+ if ($ ext === 'svg ' || $ ext === 'xml ' ) {
753+ $ purifier = $ this ->wiki ->services ->get (HtmlPurifierService::class);
754+ $ purifier ->cleanFile ($ destFile , $ ext );
755+ }
756+ header ("Location: " . $ this ->wiki ->href ("" , $ this ->wiki ->GetPageTag (), "" ));
757+ } else {
758+ echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_MOVING_TEMPORARY_FILE ' ) . "</div> \n" ;
755759 }
756- header ("Location: " . $ this ->wiki ->href ("" , $ this ->wiki ->GetPageTag (), "" ));
757- } else {
758- echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_MOVING_TEMPORARY_FILE ' ) . "</div> \n" ;
759- }
760- break ;
761- case 1 :
762- echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_UPLOAD_MAX_FILESIZE ' ) . "</div> \n" ;
763- break ;
764- case 2 :
765- echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_MAX_FILE_SIZE ' ) . "</div> \n" ;
766- break ;
767- case 3 :
768- echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_PARTIAL_UPLOAD ' ) . "</div> \n" ;
769- break ;
770- case 4 :
771- echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_NO_FILE_UPLOADED ' ) . "</div> \n" ;
772- break ;
773- case 5 :
774- $ t = array ();
775- foreach ($ this ->wiki ->config ['authorized-extensions ' ] as $ ext => $ des ) {
776- $ t [] = $ ext .' ( ' .$ des .') ' ;
777- }
778- $ these = implode (', ' , $ t );
779- echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_NOT_AUTHORIZED_EXTENSION ' ). $ these . '.</div> ' ;
780- break ;
760+ break ;
761+ case 1 :
762+ echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_UPLOAD_MAX_FILESIZE ' ) . "</div> \n" ;
763+ break ;
764+ case 2 :
765+ echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_MAX_FILE_SIZE ' ) . "</div> \n" ;
766+ break ;
767+ case 3 :
768+ echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_PARTIAL_UPLOAD ' ) . "</div> \n" ;
769+ break ;
770+ case 4 :
771+ echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_NO_FILE_UPLOADED ' ) . "</div> \n" ;
772+ break ;
773+ case 5 :
774+ $ t = array ();
775+ foreach ($ this ->wiki ->config ['authorized-extensions ' ] as $ ext => $ des ) {
776+ $ t [] = $ ext .' ( ' .$ des .') ' ;
777+ }
778+ $ these = implode (', ' , $ t );
779+ echo "<div class= \"alert alert-error alert-danger \"> " . _t ('ERROR_NOT_AUTHORIZED_EXTENSION ' ). $ these . '.</div> ' ;
780+ break ;
781781 }
782782 echo $ this ->wiki ->Format (_t ('ATTACH_BACK_TO_PAGE ' ) . " " . $ this ->wiki ->GetPageTag ());
783783 }
@@ -981,7 +981,7 @@ public function fmDelete(string $rawFileName = "")
981981 // delete cache files
982982 $ cachePath = $ this ->GetCachePath ();
983983 $ fileInfo = $ this ->decodeLongFilename ($ filename );
984-
984+
985985 $ filenamesToDelete = [];
986986 // vignettes
987987 $ filenamesToDelete [] = $ this ->getResizedFilename ($ filename , "[0-9][0-9][0-9] " , "[0-9][0-9][0-9] " , "fit " );
@@ -1000,11 +1000,11 @@ public function fmDelete(string $rawFileName = "")
10001000 $ filenamesToDelete [] = $ cachePath ."/image_[0-9][0-9][0-9][x_][0-9][0-9][0-9][0-9]_ " .basename ($ filename );
10011001 $ filenamesToDelete [] = $ cachePath ."/image_[0-9][0-9][0-9][0-9][x_][0-9][0-9][0-9]_ " .basename ($ filename );
10021002 $ filenamesToDelete [] = $ cachePath ."/image_[0-9][0-9][0-9][0-9][x_][0-9][0-9][0-9][0-9]_ " .basename ($ filename );
1003- // old tempaltes .functions.php getImageFromBody
1003+ // old templates .functions.php getImageFromBody
10041004 $ filenamesToDelete [] = $ cachePath ."/[0-9][0-9][0-9]x[0-9][0-9][0-9]- " .basename ($ filename );
1005- $ filenamesToDelete [] = $ cachePath ."/[0-9][0-9][0-9]0-9]x[0-9][0-9][0-9]- " .basename ($ filename );
1005+ $ filenamesToDelete [] = $ cachePath ."/[0-9][0-9][0-9][ 0-9]x[0-9][0-9][0-9]- " .basename ($ filename );
10061006 $ filenamesToDelete [] = $ cachePath ."/[0-9][0-9][0-9]x[0-9]0-9][0-9][0-9]- " .basename ($ filename );
1007- $ filenamesToDelete [] = $ cachePath ."/[0-9][0-9][0-9]0-9]x[0-9]0-9][0-9][0-9]- " .basename ($ filename );
1007+ $ filenamesToDelete [] = $ cachePath ."/[0-9][0-9][0-9][ 0-9]x[0-9]0-9][0-9][0-9]- " .basename ($ filename );
10081008 foreach ($ filenamesToDelete as $ path ) {
10091009 array_map ('unlink ' , glob ($ path ));
10101010 }
@@ -1088,24 +1088,24 @@ public function redimensionner_image($image_src, $image_dest, $largeur, $hauteur
10881088 $ imgTrans ->handle_exif_orientation_tag = true ;
10891089 $ imgTrans ->source_path = $ image_src ;
10901090 $ imgTrans ->target_path = $ image_dest ;
1091-
1091+
10921092 if ($ mode == "crop " ) {
10931093 $ wantedRatio = $ largeur /$ hauteur ;
10941094 // get image info except for webp (code copier from Zebra_Image)
10951095 if (
1096- !(
1097- version_compare (PHP_VERSION , '7.0.0 ' ) >= 0 &&
1098- version_compare (PHP_VERSION , '7.1.0 ' ) < 0 &&
1099- (
1100- $ imgTrans ->source_type = strtolower (substr ($ imgTrans ->source_path , strrpos ($ imgTrans ->source_path , '. ' ) + 1 ))
1101- ) === 'webp '
1102- ) &&
1103- !list ($ sourceImageWidth , $ sourceImageHeight , $ sourceImageType ) = @getimagesize ($ imgTrans ->source_path )
1104- ) {
1096+ !(
1097+ version_compare (PHP_VERSION , '7.0.0 ' ) >= 0 &&
1098+ version_compare (PHP_VERSION , '7.1.0 ' ) < 0 &&
1099+ (
1100+ $ imgTrans ->source_type = strtolower (substr ($ imgTrans ->source_path , strrpos ($ imgTrans ->source_path , '. ' ) + 1 ))
1101+ ) === 'webp '
1102+ ) &&
1103+ !list ($ sourceImageWidth , $ sourceImageHeight , $ sourceImageType ) = @getimagesize ($ imgTrans ->source_path )
1104+ ) {
11051105 return false ;
11061106 }
11071107 $ imageRatio = $ sourceImageWidth /$ sourceImageHeight ;
1108-
1108+
11091109 if ($ imageRatio != $ wantedRatio ) {
11101110 if ($ imageRatio > $ wantedRatio ) {
11111111 // width too large, keep height
@@ -1131,7 +1131,7 @@ public function redimensionner_image($image_src, $image_dest, $largeur, $hauteur
11311131 }
11321132 }
11331133 $ result = $ imgTrans ->resize (intval ($ largeur ), intval ($ hauteur ), ZEBRA_IMAGE_NOT_BOXED , '#FFFFFF ' );
1134-
1134+
11351135 if ($ mode == "crop " && !empty ($ tempFileName ) && file_exists ($ tempFileName )) {
11361136 unlink ($ tempFileName );
11371137 }
0 commit comments