Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #137 from CraftMyWebsite/guedesite-patch-1
Browse files Browse the repository at this point in the history
Update uploadImg.php
  • Loading branch information
Emilien52 authored Nov 29, 2020
2 parents a68f09e + 7b51b83 commit 5f64b44
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions admin/actions/uploadImg.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,37 @@
$dossier = './theme/upload/panel/';
$taille_maxi = 10000000;

$fichier = basename($_FILES['img']['name']);
$taille = filesize($_FILES['img']['tmp_name']);
$extensions = array('.ico', '.bmp', '.png', '.gif', '.jpg', '.jpeg');
$extension = strrchr($_FILES['img']['name'], '.');
if(!in_array($extension, $extensions))
header ("Refresh: ?page=upload&erreur=1");
$fichier = $_FILES['img']['name'];
$taille = $_FILES['img']['size'];
$extensions = array('ico', 'bmp', 'png', 'gif', 'jpg', 'jpeg');
$extension = pathinfo($_FILES['img']['name'], PATHINFO_EXTENSION);
if(!in_array(strtolower($extension), $extensions))
{
header ("location: admin.php?page=upload&erreur=0");
exit();
}
if($taille > $taille_maxi)
header ("Refresh: ?page=upload&erreur=1");
{
header ("location: admin.php?page=upload&erreur=1");
exit();
}
if (file_exists($dossier.$fichier))
header ("Refresh: ?page=upload&erreur=2");
{
header ("location: admin.php?page=upload&erreur=2");
exit();
}


$fichier = strtr($fichier,
'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ',
'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
$fichier = preg_replace('/([^.a-z0-9]+)/i', '-', $fichier);
if(!move_uploaded_file($_FILES['img']['tmp_name'], $dossier . $fichier))
header ("Refresh: ?page=upload&erreur=3");
{
header ("location: admin.php?page=upload&erreur=3");
exit();
}

header ("Refresh: ?page=upload");
header ("location: admin.php?page=upload&success");
exit();
}?>

0 comments on commit 5f64b44

Please sign in to comment.