Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- try{
- session_id($_GET[PHPSESSID]);
- session_start();
- $PATH = "./pics/";
- if (!empty($_FILES)) //check de sécurité
- {
- if ($_FILES[fichier][error] == 0 and is_uploaded_file($_FILES[fichier][tmp_name])) //check de sécurité
- {
- $OK = false;
- $test_image = getimagesize($_FILES[fichier][tmp_name]);print_r($test_image);
- if ($test_image[2] == 2 and strtoupper(substr($_FILES[fichier][name],-4)) == ".JPG") //check de sécurité
- {
- $_FILES[fichier][name] = substr_replace(str_replace(" ","_",str_replace(".","_",str_replace("'","",str_replace("\"","",utf8_decode($_FILES[fichier][name]))))),".jpg",-4);
- $OK = true;
- }
- elseif ($test_image[2] == 1 and strtoupper(substr($_FILES[fichier][name],-4)) == ".GIF") //check de sécurité
- {
- $_FILES[fichier][name] = substr_replace(str_replace(" ","_",str_replace(".","_",str_replace("'","",str_replace("\"","",utf8_decode($_FILES[fichier][name]))))),".gif",-4);
- $OK = true;
- }
- elseif ($test_image[2] == 3 and strtoupper(substr($_FILES[fichier][name],-4)) == ".PNG") //check de sécurité
- {
- $_FILES[fichier][name] = substr_replace(str_replace(" ","_",str_replace(".","_",str_replace("'","",str_replace("\"","",utf8_decode($_FILES[fichier][name]))))),".png",-4);
- $OK = true;
- }
- if ($OK)
- {
- $i=0;
- do{
- if (file_exists($PATH.$_FILES[fichier][name])){
- $_FILES[fichier][name] = rand(1,99).$_FILES[fichier][name];
- $c = true;
- $i++;}
- else
- $c = false;
- }while ($c and $i<10);
- if ($i<20) { //Finalement!
- copy($_FILES[fichier][tmp_name],$PATH.$_FILES[fichier][name]);
- $_SESSION[url][] = $_FILES[fichier][name];
- }
- }
- }
- unlink($_FILES[fichier][tmp_name]); //Supprimer le fichier temporaire
- }
- }catch (Exception $e)
- {
- //echo $e->getMessage();
- }
- die(true);
- ?>
Add Comment
Please, Sign In to add comment