%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/devcapijob/public_html/liberary/
Upload File :
Create Path :
Current File : /home/devcapijob/public_html/liberary/uploadify-annonceur.php

<?php

/*

Uploadify

Copyright (c) 2012 Reactive Apps, Ronnie Garcia

Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 

*/



// Define a destination

$date=date('Ymd_His').'_';

$targetFolder = $_POST['folder']; // Relative to the root

//$targetFolder       = $_POST['folder'];

if (!empty($_FILES)) {

  $tempFile = $_FILES['Filedata']['tmp_name'];

  $targetPath = $_SERVER['DOCUMENT_ROOT'] .'/'. $targetFolder;
  
  $name_part   = explode('.',$_FILES['Filedata']['name']);

  if($name_part!=0){ $ext = $name_part[count($name_part)-1];}
  
  $nom_fichier=genere_alias(substr($_FILES['Filedata']['name'], 0, -strlen($ext)));
  
  $nom_fichier       = $nom_fichier.'.'.$ext;
  
  $targetFile = rtrim($targetPath,'/') . '/' . $date . $nom_fichier;
  
  $name=$date . $nom_fichier;

  

  // Validate the file type

  $fileParts = pathinfo($_FILES['Filedata']['name']);

    if(move_uploaded_file($tempFile,$targetFile)){
    //  echo 'dsfdsf'; exit;
      //redimensionner_image($targetFile, 400);
      fctredimimage('400', '', $targetFile, $tempFile, $targetFile, $tempFile);
      fctredimimage('90', '90', '/home/capijobnew/public_html/files_perso/annonceur/logo/thumbnails/', $name, '/home/capijobnew/public_html/files_perso/annonceur/logo/', $name);
      echo $name;
    }else{

      echo 'error';

    }

    //echo $name;

}



function randomname($lenth =5) {



    $aZ09 = range(0, 9);

    $out ='';

    for($c=0;$c < $lenth;$c++) {

       $out .= $aZ09[mt_rand(0,count($aZ09)-1)];

    }

    return $out;

  } 

function genere_alias($string){

  //remove any '-' from the string they will be used as concatonater

  $str = str_replace('-', ' ', $string);



  $str = htmlentities(utf8_decode($str));

  $str = preg_replace(array('/&szlig;/','/&(..)lig;/', '/&([aouAOU])uml;/','/&(.)[^;]*;/'),array('ss',"$1","$1".'e',"$1"),$str);

  



  // remove any duplicate whitespace, and ensure all characters are alphanumeric

  $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str);



  // lowercase and trim

  $str= str_replace('--','-',$str);

  $str = trim(strtolower($str));

  return $str;

}

function redimensionner_image($fichier, $nouvelle_taille) {

    //VARIABLE D'ERREUR
    global $error;

    //TAILLE EN PIXELS DE L'IMAGE REDIMENSIONNEE
    $longueur = $nouvelle_taille;
    $largeur = $nouvelle_taille;

    //TAILLE DE L'IMAGE ACTUELLE
    $taille = getimagesize($fichier);
  
  //SI LE FICHIER EXISTE
    if ($taille) {
    
        //SI JPG
        if ($taille['mime']=='image/jpeg' ) {
            //OUVERTURE DE L'IMAGE ORIGINALE
            $img_big = imagecreatefromjpeg($fichier); 
            $img_new = imagecreate($longueur, $largeur);
            
            //CREATION DE LA MINIATURE
            $img_petite = imagecreatetruecolor($longueur, $largeur) or $img_petite = imagecreate($longueur, $largeur);

      //COPIE DE L'IMAGE REDIMENSIONNEE
            imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]);
            imagejpeg($img_petite,$fichier);

        }
        
        //SI PNG
        else if ($taille['mime']=='image/png' ) {
            //OUVERTURE DE L'IMAGE ORIGINALE
            $img_big = imagecreatefrompng($fichier); // On ouvre l'image d'origine
            $img_new = imagecreate($longueur, $largeur);
            
            //CREATION DE LA MINIATURE
            $img_petite = imagecreatetruecolor($longueur, $largeur);

            //COPIE DE L'IMAGE REDIMENSIONNEE
      imagecolortransparent($img_petite, imagecolorallocatealpha($img_petite, 0, 0, 0, 127));
      imagealphablending($img_petite, false);
      imagesavealpha($img_petite, true);
            imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]);
            imagepng($img_petite,$fichier);

        }
        // GIF
        else if ($taille['mime']=='image/gif' ) {
            //OUVERTURE DE L'IMAGE ORIGINALE
            $img_big = imagecreatefromgif($fichier); 
            $img_new = imagecreate($longueur, $largeur);
      
            //CREATION DE LA MINIATURE
            $img_petite = imagecreatetruecolor($longueur, $largeur) or $img_petite = imagecreate($longueur, $largeur);

            //COPIE DE L'IMAGE REDIMENSIONNEE
            imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]);
            imagegif($img_petite,$fichier);

        }
    }}
  function fctredimimage($W_max, $H_max, $rep_Dst, $img_Dst, $rep_Src, $img_Src) {

  
 // ------------------------------------------------------------------

 $condition = 0;

 // Si certains parametres ont pour valeur '' :

   if ($rep_Dst == '') { $rep_Dst = $rep_Src; } // (meme repertoire)

   if ($img_Dst == '') { $img_Dst = $img_Src; } // (meme nom)

 // ------------------------------------------------------------------

 // si le fichier existe dans le répertoire, on continue...

 if (file_exists($rep_Src.$img_Src) && ($W_max!=0 || $H_max!=0)) { 

   // ----------------------------------------------------------------

   // extensions acceptees : 

   $ExtfichierOK = '" jpg jpeg png"'; // (l espace avant jpg est important)

   // extension fichier Source

   $tabimage = explode('.',$img_Src);

   $extension = $tabimage[sizeof($tabimage)-1]; // dernier element

   $extension = strtolower($extension); // on met en minuscule

   // ----------------------------------------------------------------

   // extension OK ? on continue ...

   if (strpos($ExtfichierOK,$extension) != '') {

      // -------------------------------------------------------------

      // recuperation des dimensions de l image Src

      $img_size = getimagesize($rep_Src.$img_Src);

      $W_Src = $img_size[0]; // largeur

      $H_Src = $img_size[1]; // hauteur

      // -------------------------------------------------------------

      // condition de redimensionnement et dimensions de l image finale

      // -------------------------------------------------------------

      // A- LARGEUR ET HAUTEUR maxi fixes

      if ($W_max != 0 && $H_max != 0) {

         $ratiox = $W_Src / $W_max; // ratio en largeur

         $ratioy = $H_Src / $H_max; // ratio en hauteur

         $ratio = max($ratiox,$ratioy); // le plus grand

         $W = $W_Src/$ratio;

         $H = $H_Src/$ratio;   

         $condition = ($W_Src>$W) || ($W_Src>$H); // 1 si vrai (true)

      }      // -------------------------------------------------------------

      // B- HAUTEUR maxi fixe

      if ($W_max == 0 && $H_max != 0) {

         $H = $H_max;

         $W = $H * ($W_Src / $H_Src);

         $condition = $H_Src > $H_max; // 1 si vrai (true)

      }

      // -------------------------------------------------------------

      // C- LARGEUR maxi fixe

      if ($W_max != 0 && $H_max == 0) {

         $W = $W_max;

         $H = $W * ($H_Src / $W_Src);         

         $condition = $W_Src > $W_max; // 1 si vrai (true)

      }

      // -------------------------------------------------------------

      // on REDIMENSIONNE si la condition est vraie

      // -------------------------------------------------------------

      // Par defaut : 

    // Si l'image Source est plus petite que les dimensions indiquees :

    // PAS de redimensionnement.

    // Mais on peut "forcer" le redimensionnement en ajoutant ici :

    // $condition = 1;

      if ($condition == 1) {

         // ----------------------------------------------------------

         // creation de la ressource-image "Src" en fonction de l extension

         switch($extension) {

         case 'jpg':

         case 'jpeg':

           $Ress_Src = imagecreatefromjpeg($rep_Src.$img_Src);

           break;

         case 'png':

           $Ress_Src = imagecreatefrompng($rep_Src.$img_Src);

           break;

         }

         // ----------------------------------------------------------

         // creation d une ressource-image "Dst" aux dimensions finales

         // fond noir (par defaut)

         switch($extension) {

         case 'jpg':

         case 'jpeg':

           $Ress_Dst = imagecreatetruecolor($W,$H);

           break;

         case 'png':

           $Ress_Dst = imagecreatetruecolor($W,$H);

           // fond transparent (pour les png avec transparence)

           imagesavealpha($Ress_Dst, true);

           $trans_color = imagecolorallocatealpha($Ress_Dst, 0, 0, 0, 127);

           imagefill($Ress_Dst, 0, 0, $trans_color);

           break;

         }

         // ----------------------------------------------------------

         // REDIMENSIONNEMENT (copie, redimensionne, re-echantillonne)

         imagecopyresampled($Ress_Dst, $Ress_Src, 0, 0, 0, 0, $W, $H, $W_Src, $H_Src); 

         // ----------------------------------------------------------

         // ENREGISTREMENT dans le repertoire (avec la fonction appropriee)

         switch ($extension) { 

         case 'jpg':

         case 'jpeg':

           imagejpeg ($Ress_Dst, $rep_Dst.$img_Dst);

           break;

         case 'png':

           imagepng ($Ress_Dst, $rep_Dst.$img_Dst);

           break;

         }

         // ----------------------------------------------------------

         // liberation des ressources-image

         imagedestroy ($Ress_Src);

         imagedestroy ($Ress_Dst);

      }

      // -------------------------------------------------------------

   }

 }

//  ---------------------------------------------------------------

 // si le fichier a bien ete cree

 if ($condition == 1 && file_exists($rep_Dst.$img_Dst)) { return true; }

 else { return false; }}
?>

Zerion Mini Shell 1.0