Oltana.net 21 Mai 2012 à 10:56:26 *
Bienvenue, Invité. Veuillez vous connecter ou vous inscrire.


Connexion avec identifiant et mot de passe
Nouvelles:
Bascule sur SMF faite!
 
 
Accueil Aide Rechercher
  Voir les messages - Flavien
Pages: 1 2 [3] 4 5 6 7 ... 29
31  Discussion / Taverne / le: 17 Septembre 2006 à 11:19:53
bonne anniversaire a lui
32  Informatique Pratique / Linux / le: 16 Septembre 2006 à 20:02:30
Perso ma hp PSC 1410 fonctionne sans probleme!
33  Informatique Créatrice / Programmation / le: 16 Septembre 2006 à 20:01:40
Pas vu ca en 2nd
34  Informatique Créatrice / Programmation / le: 16 Septembre 2006 à 20:00:06
Et voila tadam : http://oltana.free.fr/oltana-script/source.zip   !
35  Informatique Créatrice / Programmation / le: 16 Septembre 2006 à 19:47:33
C'est quoi un polynome?
je suis que en premiere desolé je peux rien pour toi!
36  Informatique Créatrice / Programmation / le: 16 Septembre 2006 à 18:52:33
Voila c'est fait : http://oltana.free.fr/oltana-script/harvester.php
tu me dis si ca te convient?

Merci
37  Informatique Créatrice / Programmation / le: 16 Septembre 2006 à 17:00:58
J'ai pas dis le contraire j'ai juste dis que jpEg n'etais (quasi) pas utiliser voir pas du tout si tu fais attention j'avais modifié!
Pour ce que demandais harvester j'avais apparament compris a coté!
J'ai deja fais le plus dure jpense que ca va pas me prendre longtemps de reprendre le code!
38  Informatique Créatrice / Programmation / le: 16 Septembre 2006 à 16:29:20
Voila fini tout à changé alors je reposte tout :
Test ici : http://oltana.free.fr/oltana-script/harvester.php
harester.php :
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
   <head>
       <title>Bienvenue Harvester!</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
       <script>
function create_champ(i) {

var i2 = i + 1;

document.getElementById('leschamps_'+i).innerHTML = '<label>Image : <select name="img_'+i+'"><?php
$dir 
"images";
$a opendir&#40;$dir&#41;;
while&#40;$dossier[0&#93; = readdir&#40;$a&#41;&#41;
  
&#123;
if &#40;$dossier[0&#93;[0&#93; != "&#46;" && $dossier[0&#93;[0&#93; != "&#46;&#46;" && !is_dir&#40;$dossier[0&#93;&#41;&#41;
&#123;
if &#40;strtolower&#40;substr&#40;$dossier[0&#93;,-3,3&#41;&#41; == "jpg" || strtolower&#40;substr&#40;$dossier[0&#93;,-3,3&#41;&#41; == "gif" || strtolower&#40;substr&#40;$dossier[0&#93;,-4,4&#41;&#41; == "jpeg" || strtolower&#40;substr&#40;$dossier[0&#93;,-3,3&#41;&#41; == "png"&#41; &#123;
echo "<option value=\"",$dossier[0&#93;,"\">",$dossier[0&#93;,"</option>";
&#125;
&#125;
&#125;
?>

</select><label>Chiffre : <input type="text" name="chiffre_'+i+'"/></label>';

document.getElementById('leschamps_'+i).innerHTML += (i <= 10) ? '<br /><span id="leschamps_'+i2+'"><a href="javascript:create_champ('+i2+')">Ajouter un champ</a><br/></span>' : '';


}
   </script>
   </head>
   <body>




<form method="post" action="newimage.php">
<label>Couleur arriere plan :<select name="color">
<option value="black">Noir</option>
<option value="red">Rouge</option>
<option value="blue">Bleu</option>
<option value="yellow">Jaune</option>
<option value="white">Blanc</option>
<option value="green">vert</option>
<option value="trans">Transparent</option>
</select></label>(L'option Transparent ne fonctionne que pour les pngs)<br/>
<label>Couleur texte :<select name="text">
<option value="white">Blanc</option>
<option value="black">Noir</option>
<option value="red">Rouge</option>
<option value="blue">Bleu</option>
<option value="yellow">Jaune</option>
<option value="green">Vert</option>
</select></label><br/>

<label>Image : <select name="img_1">



<?php
$dir 
"images";
$a opendir&#40;$dir&#41;;
while&#40;$dossier[0&#93; = readdir&#40;$a&#41;&#41;
  
&#123;
if &#40;$dossier[0&#93;[0&#93; != "&#46;" && $dossier[0&#93;[0&#93; != "&#46;&#46;" && !is_dir&#40;$dossier[0&#93;&#41;&#41;
&#123;
if &#40;strtolower&#40;substr&#40;$dossier[0&#93;,-3,3&#41;&#41; == "jpg" || strtolower&#40;substr&#40;$dossier[0&#93;,-3,3&#41;&#41; == "gif" || strtolower&#40;substr&#40;$dossier[0&#93;,-4,4&#41;&#41; == "jpeg" || strtolower&#40;substr&#40;$dossier[0&#93;,-3,3&#41;&#41; == "png"&#41;
    
&#123;
echo "<option value=\"",$dossier[0&#93;,"\">",$dossier[0&#93;,"</option>";
&#125;
&#125;
&#125;
?>

</select><label>Chiffre : <input type="text" name="chiffre_1" /></label><br/>
<span id="leschamps_2"><a href="javascript:create_champ(2)">Ajouter un champ</a><br/></span>
 
  <input type="submit" value="OK" />
</form>
 
   </body>
</html>

newimage.php :
Code:
<?php
include&#40;"fonctions&#46;php"&#41;;
include&#40;"zip&#46;lib&#46;php"&#41;;
$dir "images/";
$crea "mini/";
$lpolice 6;
$t 1;
$zip = new zipfile&#40;&#41;;
while&#40;isset&#40;$_POST['img_'&#46;$t&#93;&#41; && isset&#40;$_POST['chiffre_'&#46;$t&#93;&#41;&#41;&#123;
if &#40;isset&#40;$_POST['color'&#93;&#41;&#41;&#123;
if &#40;strtolower&#40;substr&#40;$_POST['img_'&#46;$t&#93;, -3, 3&#41;&#41; == 'jpg' || strtolower&#40;substr&#40;$_POST['img_'&#46;$t&#93;, -4, 4&#41;&#41; == 'jpeg'&#41;&#123;
$image imagecreatefromjpeg&#40;$dir&#46;$_POST['img_'&#46;$t&#93;&#41;; 
$nbrchif nbre_chiffre&#40;$_POST['chiffre_'&#46;$t&#93;&#41;; // nbre de chiffre
$lchif $nbrchif*$lpolice+2;
$limage imagesx&#40;$image&#41; + $lchif ;
$himage imagesy&#40;$image&#41;;
$destination imagecreatetruecolor&#40;$limage, $himage&#41;;
$ldestination imagesx&#40;$destination&#41;;
$hdestination imagesy&#40;$destination&#41;;
imagecopy&#40;$destination, $image, 0, 0, 0, 0, imagesx&#40;$image&#41;, $himage&#41;; 
$i imagecreate&#40;$lchif,$hdestination&#41;; // image de toute la largeur 
imagecolorate&#40;$_POST['color'&#93;,$i&#41;;
$text imagecolorate&#40;$_POST['text'&#93;,$i&#41;;
imagestring&#40;$i, 2, 2, imagesy&#40;$image&#41;/2, $_POST['chiffre_'&#46;$t&#93;, $text&#41;;
imagecopymerge&#40;$destination, $i, imagesx&#40;$image&#41;, 0, 0, 0, imagesx&#40;$image&#41;, $himage, 100&#41;;
$a enregistre&#40;$destination, $crea&#46;$_POST['img_'&#46;$t&#93;, "jpeg"&#41;;
$f fopen&#40;$a, "r"&#41;;
$content fread&#40;$f, filesize&#40;$a&#41;&#41;;
fclose&#40;$f&#41;;
$zip->addfile&#40;$content, "image_"&#46;$t&#46;"&#46;jpeg"&#41;;
&#125;
else if &#40;strtolower&#40;substr&#40;$_POST['img_'&#46;$t&#93;, -3, 3&#41;&#41; == 'png'&#41;&#123;
$image imagecreatefrompng&#40;$dir&#46;$_POST['img_'&#46;$t&#93;&#41;; 
$nbrchif nbre_chiffre&#40;$_POST['chiffre_'&#46;$t&#93;&#41;; // nbre de chiffre
$lchif $nbrchif*$lpolice+2;
$limage imagesx&#40;$image&#41; + $lchif ;
$himage imagesy&#40;$image&#41;;
$destination imagecreatetruecolor&#40;$limage, $himage&#41;;
$ldestination imagesx&#40;$destination&#41;;
$hdestination imagesy&#40;$destination&#41;;
imagecolorate&#40;$_POST['color'&#93;,$destination&#41;;
imagecopy&#40;$destination, $image, 0, 0, 0, 0, imagesx&#40;$image&#41;, $himage&#41;; 
$i imagecreate&#40;$lchif,$hdestination&#41;; // image de toute la largeur 
imagecolorate&#40;$_POST['color'&#93;, $i&#41;;
$text textcolorate&#40;$_POST['text'&#93;, $i&#41;;
imagestring&#40;$i, 2, 2, imagesy&#40;$image&#41;/2, $_POST['chiffre_'&#46;$t&#93;, $text&#41;;
imagecopymerge&#40;$destination, $i, imagesx&#40;$image&#41;, 0, 0, 0, imagesx&#40;$image&#41;, $himage, 100&#41;;
$a enregistre&#40;$destination,$crea&#46;$_POST['img_'&#46;$t&#93;, "png"&#41;;
$f fopen&#40;$a, "r"&#41;;
$content fread&#40;$f, filesize&#40;$a&#41;&#41;;
fclose&#40;$f&#41;;
$zip->addfile&#40;$content, "image_"&#46;$t&#46;"&#46;png"&#41;;
&#125;
elseif &#40;strtolower&#40;substr&#40;$_POST['img_'&#46;$t&#93;, -3, 3&#41;&#41; == 'gif'&#41;&#123;
$image imagecreatefromgif&#40;$dir&#46;$_POST['img_'&#46;$t&#93;&#41;; 
$nbrchif nbre_chiffre&#40;$_POST['chiffre_'&#46;$t&#93;&#41;; // nbre de chiffre
$lchif $nbrchif*$lpolice +2;
$limage imagesx&#40;$image&#41; + $lchif ;
$himage imagesy&#40;$image&#41;;
$destination imagecreatetruecolor&#40;$limage, $himage&#41;;
$ldestination imagesx&#40;$destination&#41;;
$hdestination imagesy&#40;$destination&#41;;
imagecolorate&#40;$_POST['color'&#93;,$destination&#41;;
imagecopy&#40;$destination, $image, 0, 0, 0, 0, imagesx&#40;$image&#41;, $himage&#41;; 
$i imagecreate&#40;$lchif,$hdestination&#41;; // image de toute la largeur 
imagecolorate&#40;$_POST['color'&#93;,$i&#41;;
$text textcolorate&#40;$_POST['text'&#93;, $i&#41;;
imagestring&#40;$i, 2, 2, imagesy&#40;$image&#41;/2, $_POST['chiffre_'&#46;$t&#93;, $text&#41;;
imagecopymerge&#40;$destination, $i, imagesx&#40;$image&#41;, 0, 0, 0, imagesx&#40;$image&#41;, $himage, 100&#41;;
$a enregistre&#40;$destination, $crea&#46;$_POST['img_'&#46;$t&#93;, "gif"&#41;;
$zip->addfile&#40;$crea&#46;$_POST['img_'&#46;$t&#93; , "image_"&#46;$t&#46;"&#46;gif"&#41;;
$f fopen&#40;$a, "r"&#41;;
$content fread&#40;$f, filesize&#40;$a&#41;&#41;;
fclose&#40;$f&#41;;
$zip->addfile&#40;$content, "image_"&#46;$t&#46;"&#46;gif"&#41;;
&#125;
&#125;
$t++;
&
#125;
$archive $zip->file&#40;&#41;;
header&#40;'Content-Type&#58; application/x-zip'&#41;;
header&#40;'Content-Disposition&#58; attachment; filename=archive&#46;zip'&#41;;
echo $archive;
?>


fonctions.php :
Code:
<?php
function imagecolorate &#40;$color, $i&#41;&#123;
if&#40;$color == "black"&#41;&#123;
$black imagecolorallocate&#40;$i, 0, 0, 0&#41;; 
imagefill&#40;$i, 0, 0, $black&#41;;
&#125;
else if&#40;$color == "blue"&#41;&#123;
$blue =imagecolorallocate&#40;$i, 0, 0, 255&#41;; 
imagefill&#40;$i, 0, 0, $blue&#41;;
&#125;
else if&#40;$color == "yellow"&#41;&#123;
$yellow imagecolorallocate&#40;$i, 255, 255, 0&#41;; 
imagefill&#40;$i, 0, 0, $yellow&#41;;
&#125;
else if&#40;$color == "red"&#41;&#123;
$red imagecolorallocate&#40;$i, 255, 0, 0&#41;; 
imagefill&#40;$i, 0, 0, $red&#41;;
&#125;
else if&#40;$color == "green"&#41;&#123;
$green imagecolorallocate&#40;$i, 0, 255, 0&#41;; 
imagefill&#40;$i, 0, 0, $green&#41;;
&#125;
else if&#40;$color == "white"&#41;&#123;
$white imagecolorallocate&#40;$i, 255, 255, 255&#41;; 
imagefill&#40;$i, 0, 0, $white&#41;;
&#125;
else if&#40;$color == "trans"&#41;&#123;
$trans imagecolorallocate&#40;$i, 0, 1, 0&#41;; 
imagefill&#40;$i, 0, 0, $trans&#41;;
imagecolortransparent&#40;$i,$trans&#41;;
&#125;
return 0;
&
#125;
function textcolorate &#40;$color, $i&#41;&#123;
if&#40;$color == "black"&#41;&#123;
$text imagecolorallocate&#40;$i, 0, 0, 0&#41;; 
&#125;
else if&#40;$color == "blue"&#41;&#123;
$text =imagecolorallocate&#40;$i, 0, 0, 255&#41;; 
&#125;
else if&#40;$color == "yellow"&#41;&#123;
$text imagecolorallocate&#40;$i, 255, 255, 0&#41;; 
&#125;
else if&#40;$color == "red"&#41;&#123;
$text imagecolorallocate&#40;$i, 255, 0, 0&#41;; 
&#125;
else if&#40;$color == "green"&#41;&#123;
$text imagecolorallocate&#40;$i, 0, 255, 0&#41;; 
&#125;
else if&#40;$color == "white"&#41;&#123;
$text imagecolorallocate&#40;$i, 255, 255, 255&#41;; 
&#125;
return $text;
&
#125;
function enregistre&#40;$image, $adress, $format&#41;&#123;
if &#40;file_exists&#40;$adress&#41;&#41;&#123;
$i 1;
do&
#123;
$e "png";
$nom   substr&#40;$adress, 0, -4&#41;&#46;'_'&#46;$i&#46;'&#46;'&#46;$e;
$i++;
&
#125;while&#40;file_exists&#40;$nom&#41;&#41;;
if &#40;$format == "jpeg"&#41;&#123;
imagejpeg&#40;$image, $nom&#41;; 
&#125;
else if &#40;$format == "png"&#41;&#123;
imagepng&#40;$image, $nom&#41;; 
&#125;
else if &#40;$format == "gif"&#41;&#123;
imagegif&#40;$image, $nom&#41;; 
&#125;
&#125;
else&#123;
$nom $adress;
imagepng&#40;$image, $nom&#41;;
&#125;
return $nom;
&
#125;
function nbre_chiffre&#40;$var&#41;&#123;
$chif intval&#40;$var&#41;; 
$nbrchif 1;
for&
#40;$i = 1;;&#41;&#123;
if&#40;&#40;$chif/$i&#41; < 10&#41;&#123;
break;
&
#125;
else&#123;
$nbrchif++;
$i *= 10;
&
#125;
&#125;
return $nbrchif;
&
#125;

et la librarie pas de moi zip.lib.php :
Code:
<?php
/* $Id&#58; zip&#46;lib&#46;php,v 1&#46;6 2002/03/30 08&#58;24&#58;04 loic1 Exp $ */


/**
 * Zip file creation class&#46;
 * Makes zip files&#46;
 *
 * Based on &#58;
 *
 *  http&#58;//www&#46;zend&#46;com/codex&#46;php?id=535&single=1
 *  By Eric Mueller <eric@themepark&#46;com>
 *
 *  http&#58;//www&#46;zend&#46;com/codex&#46;php?id=470&single=1
 *  by Denis125 <webmaster@atlant&#46;ru>
 *
 *  a patch from Peter Listiak <mlady@users&#46;sourceforge&#46;net> for last modified
 *  date and time of the compressed file
 *
 * Official ZIP file format&#58; http&#58;//www&#46;pkware&#46;com/appnote&#46;txt
 *
 * @access  public
 */
class zipfile
&#123;
    /**
     * Array to store compressed data
     *
     * @var  array    $datasec
     */
    
var $datasec      = array&#40;&#41;;

    /**
     * Central directory
     *
     * @var  array    $ctrl_dir
     */
    
var $ctrl_dir     = array&#40;&#41;;

    /**
     * End of central directory record
     *
     * @var  string   $eof_ctrl_dir
     */
    
var $eof_ctrl_dir "\x50\x4b\x05\x06\x00\x00\x00\x00";

    
/**
     * Last offset position
     *
     * @var  integer  $old_offset
     */
    
var $old_offset   0;


    
/**
     * Converts an Unix timestamp to a four byte DOS date and time format &#40;date
     * in high two bytes, time in low two bytes allowing magnitude comparison&#41;&#46;
     *
     * @param  integer  the current Unix timestamp
     *
     * @return integer  the current date in a four byte DOS format
     *
     * @access private
     */
    
function unix2DosTime&#40;$unixtime = 0&#41; &#123;
        
$timearray = &#40;$unixtime == 0&#41; ? getdate&#40;&#41; &#58; getdate&#40;$unixtime&#41;;

        
if &#40;$timearray['year'&#93; < 1980&#41; &#123;
        
$timearray['year'&#93;    = 1980;
        
$timearray['mon'&#93;     = 1;
        
$timearray['mday'&#93;    = 1;
        
$timearray['hours'&#93;   = 0;
        
$timearray['minutes'&#93; = 0;
        
$timearray['seconds'&#93; = 0;
        
&#125; // end if

        
return &#40;&#40;$timearray['year'&#93; - 1980&#41; << 25&#41; | &#40;$timearray['mon'&#93; << 21&#41; | &#40;$timearray['mday'&#93; << 16&#41; |
                
&#40;$timearray['hours'&#93; << 11&#41; | &#40;$timearray['minutes'&#93; << 5&#41; | &#40;$timearray['seconds'&#93; >> 1&#41;;
    
&#125; // end of the 'unix2DosTime&#40;&#41;' method


    /**
     * Adds "file" to archive
     *
     * @param  string   file contents
     * @param  string   name of the file in the archive &#40;may contains the path&#41;
     * @param  integer  the current timestamp
     *
     * @access public
     */
    
function addFile&#40;$data, $name, $time = 0&#41;
    
&#123;
        
$name     str_replace&#40;'\\', '/', $name&#41;;

        
$dtime    dechex&#40;$this->unix2DosTime&#40;$time&#41;&#41;;
        
$hexdtime '\x' &#46; $dtime[6&#93; &#46; $dtime[7&#93;
                  
&#46; '\x' &#46; $dtime[4&#93; &#46; $dtime[5&#93;
                  
&#46; '\x' &#46; $dtime[2&#93; &#46; $dtime[3&#93;
                  
&#46; '\x' &#46; $dtime[0&#93; &#46; $dtime[1&#93;;
        
eval&#40;'$hexdtime = "' &#46; $hexdtime &#46; '";'&#41;;

        
$fr   "\x50\x4b\x03\x04";
        
$fr   &#46;= "\x14\x00";            // ver needed to extract
        
$fr   &#46;= "\x00\x00";            // gen purpose bit flag
        
$fr   &#46;= "\x08\x00";            // compression method
        
$fr   &#46;= $hexdtime;             // last mod time and date

        // "local file header" segment
        
$unc_len strlen&#40;$data&#41;;
        
$crc     crc32&#40;$data&#41;;
        
$zdata   gzcompress&#40;$data&#41;;
        
$zdata   substr&#40;substr&#40;$zdata, 0, strlen&#40;$zdata&#41; - 4&#41;, 2&#41;; // fix crc bug
        
$c_len   strlen&#40;$zdata&#41;;
        
$fr      &#46;= pack&#40;'V', $crc&#41;;             // crc32
        
$fr      &#46;= pack&#40;'V', $c_len&#41;;           // compressed filesize
        
$fr      &#46;= pack&#40;'V', $unc_len&#41;;         // uncompressed filesize
        
$fr      &#46;= pack&#40;'v', strlen&#40;$name&#41;&#41;;    // length of filename
        
$fr      &#46;= pack&#40;'v', 0&#41;;                // extra field length
        
$fr      &#46;= $name;

        // "file data" segment
        
$fr &#46;= $zdata;

        // "data descriptor" segment &#40;optional but necessary if archive is not
        // served as file&#41;
        
$fr &#46;= pack&#40;'V', $crc&#41;;                 // crc32
        
$fr &#46;= pack&#40;'V', $c_len&#41;;               // compressed filesize
        
$fr &#46;= pack&#40;'V', $unc_len&#41;;             // uncompressed filesize

        // add this entry to array
        
$this -> datasec[&#93; = $fr;
        
$new_offset        strlen&#40;implode&#40;'', $this->datasec&#41;&#41;;

        // now add to central directory record
        
$cdrec "\x50\x4b\x01\x02";
        
$cdrec &#46;= "\x00\x00";                // version made by
        
$cdrec &#46;= "\x14\x00";                // version needed to extract
        
$cdrec &#46;= "\x00\x00";                // gen purpose bit flag
        
$cdrec &#46;= "\x08\x00";                // compression method
        
$cdrec &#46;= $hexdtime;                 // last mod time & date
        
$cdrec &#46;= pack&#40;'V', $crc&#41;;           // crc32
        
$cdrec &#46;= pack&#40;'V', $c_len&#41;;         // compressed filesize
        
$cdrec &#46;= pack&#40;'V', $unc_len&#41;;       // uncompressed filesize
        
$cdrec &#46;= pack&#40;'v', strlen&#40;$name&#41; &#41;; // length of filename
        
$cdrec &#46;= pack&#40;'v', 0 &#41;;             // extra field length
        
$cdrec &#46;= pack&#40;'v', 0 &#41;;             // file comment length
        
$cdrec &#46;= pack&#40;'v', 0 &#41;;             // disk number start
        
$cdrec &#46;= pack&#40;'v', 0 &#41;;             // internal file attributes
        
$cdrec &#46;= pack&#40;'V', 32 &#41;;            // external file attributes - 'archive' bit set

        
$cdrec &#46;= pack&#40;'V', $this -> old_offset &#41;; // relative offset of local header
        
$this -> old_offset $new_offset;

        
$cdrec &#46;= $name;

        // optional extra field, file comment goes here
        // save to central directory
        
$this -> ctrl_dir[&#93; = $cdrec;
    
&#125; // end of the 'addFile&#40;&#41;' method


    /**
     * Dumps out file
     *
     * @return  string  the zipped file
     *
     * @access public
     */
    
function file&#40;&#41;
    
&#123;
        
$data    implode&#40;'', $this -> datasec&#41;;
        
$ctrldir implode&#40;'', $this -> ctrl_dir&#41;;

        
return
            
$data &#46;
            
$ctrldir &#46;
            
$this -> eof_ctrl_dir &#46;
            
pack&#40;'v', sizeof&#40;$this -> ctrl_dir&#41;&#41; &#46;  // total # of entries "on this disk"
            
pack&#40;'v', sizeof&#40;$this -> ctrl_dir&#41;&#41; &#46;  // total # of entries overall
            
pack&#40;'V', strlen&#40;$ctrldir&#41;&#41; &#46;           // size of central dir
            
pack&#40;'V', strlen&#40;$data&#41;&#41; &#46;              // offset to start of central dir
            
"\x00\x00";                             // &#46;zip file comment length
    
&#125; // end of the 'file&#40;&#41;' method

&#125; // end of the 'zipfile' class
?>

39  Informatique Créatrice / Programmation / le: 16 Septembre 2006 à 13:49:23
ben justement je cherche une fonction en javascript que je ne trouve plus je te fais signe quand je la retrouve

Edit : fonction trouvée
40  Informatique Créatrice / Programmation / le: 16 Septembre 2006 à 13:00:43
J'y avait pas penser c'est pas bete mais bon les .jpEg j'ai jamais vu  Clin d'oeil
41  Informatique Pratique / Linux / le: 15 Septembre 2006 à 23:46:21
Il me semble que ca a deja été abordé mais que ca été supprimé parce que ca ne rentrait plus dans les règles avec DAVDSI  :x
42  Informatique Créatrice / Programmation / le: 15 Septembre 2006 à 23:00:09
voila!

le code sources :
harvester.php :
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
   <head>
       <title>Bienvenue Harvester!</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
   </head>
   <body>




<form method="post" action="newimage.php">
<label>Chiffre :<input type="text" name="chiffre" /></label><br/>
<label>Couleur arriere plan :<select name="color">
<option value="black">Noir</option>
<option value="red">Rouge</option>
<option value="blue">Bleu</option>
<option value="yellow">Jaune</option>
<option value="white">Blanc</option>
<option value="green">vert</option>
<option value="trans">Transparent</option>
</select></label>(L'option Transparent ne fonctionne que pour les pngs)<br/>
<label>Couleur texte :<select name="text">
<option value="white">Blanc</option>
<option value="black">Noir</option>
<option value="red">Rouge</option>
<option value="blue">Bleu</option>
<option value="yellow">Jaune</option>
<option value="green">Vert</option>
</select></label><br/>

<label>images :<select name="img">



<?php
$dir 
"images";
$a opendir&#40;$dir&#41;;
while&#40;$dossier[0&#93; = readdir&#40;$a&#41;&#41;
  
&#123;
if &#40;$dossier[0&#93;[0&#93; != "&#46;" && $dossier[0&#93;[0&#93; != "&#46;&#46;" && !is_dir&#40;$dossier[0&#93;&#41;&#41;
&#123;
if &#40;substr&#40;$dossier[0&#93;,-3,3&#41; == JPG ||  substr&#40;$dossier[0&#93;,-3,3&#41; == jpg || substr&#40;$dossier[0&#93;,-3,3&#41; == gif || substr&#40;$dossier[0&#93;,-3,3&#41; == GIF || substr&#40;$dossier[0&#93;,-4,4&#41; == JPEG || substr&#40;$dossier[0&#93;,-4,4&#41; == jpeg || substr&#40;$dossier[0&#93;,-3,3&#41; == png || substr&#40;$dossier[0&#93;,-3,3&#41; == PNG&#41;
    
&#123;
echo "<option value=\"",$dossier[0&#93;,"\">",$dossier[0&#93;,"</option>";
&#125;
&#125;
&#125;
?>

</select><br/>

 
  <input type="submit" value="OK" />
</form>
 
   </body>
</html>

newimage.php :
Code:
<?php
include&#40;"fonctions&#46;php"&#41;;
$dir "images/";
$crea "mini/";
$lpolice 6;
if &
#40;isset&#40;$_POST['img'&#93;&#41; AND isset&#40;$_POST['chiffre'&#93;&#41; AND isset&#40;$_POST['color'&#93;&#41;&#41;&#123;
if &#40;strtolower&#40;substr&#40;$_POST['img'&#93;, -3, 3&#41;&#41; == 'jpg' || strtolower&#40;substr&#40;$_POST['img'&#93;, -4, 4&#41;&#41; == 'jpeg'&#41;&#123;
header &#40;"Content-type&#58; image/jpeg"&#41;; 
header&#40;'Content-Disposition&#58; attachment; filename="image&#46;jpeg"'&#41;; 
$image imagecreatefromjpeg&#40;$dir&#46;$_POST['img'&#93;&#41;; 
$nbrchif nbre_chiffre&#40;$_POST['chiffre'&#93;&#41;; // nbre de chiffre
$lchif $nbrchif*$lpolice+2;
$limage imagesx&#40;$image&#41; + $lchif ;
$himage imagesy&#40;$image&#41;;
$destination imagecreatetruecolor&#40;$limage, $himage&#41;;
$ldestination imagesx&#40;$destination&#41;;
$hdestination imagesy&#40;$destination&#41;;
imagecopy&#40;$destination, $image, 0, 0, 0, 0, imagesx&#40;$image&#41;, $himage&#41;; 
$i imagecreate&#40;$lchif,$hdestination&#41;; // image de toute la largeur 
imagecolorate&#40;$_POST['color'&#93;,$i&#41;;
$text imagecolorate&#40;$_POST['text'&#93;,$i&#41;;
imagestring&#40;$i, 2, 2, imagesy&#40;$image&#41;/2, $_POST['chiffre'&#93;, $text&#41;;
imagecopymerge&#40;$destination, $i, imagesx&#40;$image&#41;, 0, 0, 0, imagesx&#40;$image&#41;, $himage, 100&#41;;
enregistre&#40;$destination, $crea&#46;$_POST['img'&#93;, "jpeg"&#41;;
imagejpeg&#40;$destination&#41;;
&#125;
else if &#40;strtolower&#40;substr&#40;$_POST['img'&#93;, -3, 3&#41;&#41; == 'png'&#41;&#123;
header &#40;"Content-type&#58; image/png "&#41;; 
header&#40;'Content-Disposition&#58; attachment; filename="image&#46;png"'&#41;; 
$image imagecreatefrompng&#40;$dir&#46;$_POST['img'&#93;&#41;; 
$nbrchif nbre_chiffre&#40;$_POST['chiffre'&#93;&#41;; // nbre de chiffre
$lchif $nbrchif*$lpolice+2;
$limage imagesx&#40;$image&#41; + $lchif ;
$himage imagesy&#40;$image&#41;;
$destination imagecreatetruecolor&#40;$limage, $himage&#41;;
$ldestination imagesx&#40;$destination&#41;;
$hdestination imagesy&#40;$destination&#41;;
imagecolorate&#40;$_POST['color'&#93;,$destination&#41;;
imagecopy&#40;$destination, $image, 0, 0, 0, 0, imagesx&#40;$image&#41;, $himage&#41;; 
$i imagecreate&#40;$lchif,$hdestination&#41;; // image de toute la largeur 
imagecolorate&#40;$_POST['color'&#93;, $i&#41;;
$text textcolorate&#40;$_POST['text'&#93;, $i&#41;;
imagestring&#40;$i, 2, 2, imagesy&#40;$image&#41;/2, $_POST['chiffre'&#93;, $text&#41;;
imagecopymerge&#40;$destination, $i, imagesx&#40;$image&#41;, 0, 0, 0, imagesx&#40;$image&#41;, $himage, 100&#41;;
enregistre&#40;$destination,$crea&#46;$_POST['img'&#93;, "png"&#41;;
imagepng&#40;$destination&#41;;
&#125;
elseif &#40;strtolower&#40;substr&#40;$_POST['img'&#93;, -3, 3&#41;&#41; == 'gif'&#41;&#123;
header &#40;"Content-type&#58; image/gif"&#41;; 
header&#40;'Content-Disposition&#58; attachment; filename="image&#46;gif"'&#41;; 
$image imagecreatefromgif&#40;$dir&#46;$_POST['img'&#93;&#41;; 
$nbrchif nbre_chiffre&#40;$_POST['chiffre'&#93;&#41;; // nbre de chiffre
$lchif $nbrchif*$lpolice +2;
$limage imagesx&#40;$image&#41; + $lchif ;
$himage imagesy&#40;$image&#41;;
$destination imagecreatetruecolor&#40;$limage, $himage&#41;;
$ldestination imagesx&#40;$destination&#41;;
$hdestination imagesy&#40;$destination&#41;;
imagecolorate&#40;$_POST['color'&#93;,$destination&#41;;
imagecopy&#40;$destination, $image, 0, 0, 0, 0, imagesx&#40;$image&#41;, $himage&#41;; 
$i imagecreate&#40;$lchif,$hdestination&#41;; // image de toute la largeur 
imagecolorate&#40;$_POST['color'&#93;,$i&#41;;
$text textcolorate&#40;$_POST['text'&#93;, $i&#41;;
imagestring&#40;$i, 2, 2, imagesy&#40;$image&#41;/2, $_POST['chiffre'&#93;, $text&#41;;
imagecopymerge&#40;$destination, $i, imagesx&#40;$image&#41;, 0, 0, 0, imagesx&#40;$image&#41;, $himage, 100&#41;;
enregistre&#40;$destination, $crea&#46;$_POST['img'&#93;, "gif"&#41;;
imagegif&#40;$destination&#41;;
&#125;
&#125;
?>



fonctions.php
Code:
<?php
function imagecolorate &#40;$color, $i&#41;&#123;
if&#40;$color == "black"&#41;&#123;
$black imagecolorallocate&#40;$i, 0, 0, 0&#41;; 
imagefill&#40;$i, 0, 0, $black&#41;;
&#125;
else if&#40;$color == "blue"&#41;&#123;
$blue =imagecolorallocate&#40;$i, 0, 0, 255&#41;; 
imagefill&#40;$i, 0, 0, $blue&#41;;
&#125;
else if&#40;$color == "yellow"&#41;&#123;
$yellow imagecolorallocate&#40;$i, 255, 255, 0&#41;; 
imagefill&#40;$i, 0, 0, $yellow&#41;;
&#125;
else if&#40;$color == "red"&#41;&#123;
$red imagecolorallocate&#40;$i, 255, 0, 0&#41;; 
imagefill&#40;$i, 0, 0, $red&#41;;
&#125;
else if&#40;$color == "green"&#41;&#123;
$green imagecolorallocate&#40;$i, 0, 255, 0&#41;; 
imagefill&#40;$i, 0, 0, $green&#41;;
&#125;
else if&#40;$color == "white"&#41;&#123;
$white imagecolorallocate&#40;$i, 255, 255, 255&#41;; 
imagefill&#40;$i, 0, 0, $white&#41;;
&#125;
else if&#40;$color == "trans"&#41;&#123;
$trans imagecolorallocate&#40;$i, 0, 1, 0&#41;; 
imagefill&#40;$i, 0, 0, $trans&#41;;
imagecolortransparent&#40;$i,$trans&#41;;
&#125;
return 0;
&
#125;
function textcolorate &#40;$color, $i&#41;&#123;
if&#40;$color == "black"&#41;&#123;
$text imagecolorallocate&#40;$i, 0, 0, 0&#41;; 
&#125;
else if&#40;$color == "blue"&#41;&#123;
$text =imagecolorallocate&#40;$i, 0, 0, 255&#41;; 
&#125;
else if&#40;$color == "yellow"&#41;&#123;
$text imagecolorallocate&#40;$i, 255, 255, 0&#41;; 
&#125;
else if&#40;$color == "red"&#41;&#123;
$text imagecolorallocate&#40;$i, 255, 0, 0&#41;; 
&#125;
else if&#40;$color == "green"&#41;&#123;
$text imagecolorallocate&#40;$i, 0, 255, 0&#41;; 
&#125;
else if&#40;$color == "white"&#41;&#123;
$text imagecolorallocate&#40;$i, 255, 255, 255&#41;; 
&#125;
return $text;
&
#125;
function enregistre&#40;$image, $adress, $format&#41;&#123;
if &#40;file_exists&#40;$adress&#41;&#41;&#123;
$i 1;
do&
#123;
$e "png";
$nom   substr&#40;$adress, 0, -4&#41;&#46;'_'&#46;$i&#46;'&#46;'&#46;$e;
$i++;
&
#125;while&#40;file_exists&#40;$nom&#41;&#41;;
if &#40;$format == "jpeg"&#41;&#123;
imagejpeg&#40;$image, $nom&#41;; 
&#125;
else if &#40;$format == "png"&#41;&#123;
imagepng&#40;$image, $nom&#41;; 
&#125;
else if &#40;$format == "gif"&#41;&#123;
imagegif&#40;$image, $nom&#41;; 
&#125;
&#125;
else&#123;
imagepng&#40;$image, $adress&#41;;
&#125;
&#125;
function nbre_chiffre&#40;$var&#41;&#123;
$chif intval&#40;$var&#41;; 
$nbrchif 1;
for&
#40;$i = 1;;&#41;&#123;
if&#40;&#40;$chif/$i&#41; < 10&#41;&#123;
break;
&
#125;
else&#123;
$nbrchif++;
$i *= 10;
&
#125;
&#125;
return $nbrchif;
&
#125;



Le tout a mettre dans un meme dossier!
Creer dans le meme dossier un sous-dossier "mini"
Ainsi que un sous-dossier "images" ou vous mettrez les images lister dans le formulaire!

PS à Harvester : les png de ton premier post son mort faire leur faire un tour dans GIMP avant de les utiliser!

Le script fonctionne avec les formats suivant : JPEG, PNG, GIF

PPS : La flemme de tout commenter

Je vais essayer de voir pour la transparence des gifs mais je ne te garantis rien
43  Informatique Créatrice / Programmation / le: 15 Septembre 2006 à 22:36:26
Voila j'ai plus qu'a regler ce probleme!
44  Informatique Créatrice / Programmation / le: 15 Septembre 2006 à 19:27:30
L'image s'enregistre deja dans le dossier /mini au format .png
sinon tu fais enregistrer sous il te propose newimage.php tu renommes en .png Clin d'oeil
45  Informatique Créatrice / Programmation / le: 14 Septembre 2006 à 21:09:44
Pour le moment j'ai fais ca : http://oltana.free.fr/oltana-script/harvester.php
J'ai eu quelques problemes pour la gestion de la transparence en png Triste
  mais ca devrait etre reglé!
C'est bien ce que tu voulais?
Me reste a ajouter la possibilité de faire plusieur images d'un coup!
Pages: 1 2 [3] 4 5 6 7 ... 29
Powered by SMF 1.1.15 | SMF © 2006-2009, Simple Machines