|
Oltana.net
|
21 Mai 2012 à 10:56:26
|
Voir les messages - Flavien
|
|
Pages: 1 2 [3] 4 5 6 7 ... 29
|
|
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.phpharester.php : <!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($dir); while($dossier[0] = readdir($a)) { if ($dossier[0][0] != "." && $dossier[0][0] != ".." && !is_dir($dossier[0])) { if (strtolower(substr($dossier[0],-3,3)) == "jpg" || strtolower(substr($dossier[0],-3,3)) == "gif" || strtolower(substr($dossier[0],-4,4)) == "jpeg" || strtolower(substr($dossier[0],-3,3)) == "png") { echo "<option value=\"",$dossier[0],"\">",$dossier[0],"</option>"; } } } ?> </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($dir); while($dossier[0] = readdir($a)) { if ($dossier[0][0] != "." && $dossier[0][0] != ".." && !is_dir($dossier[0])) { if (strtolower(substr($dossier[0],-3,3)) == "jpg" || strtolower(substr($dossier[0],-3,3)) == "gif" || strtolower(substr($dossier[0],-4,4)) == "jpeg" || strtolower(substr($dossier[0],-3,3)) == "png") { echo "<option value=\"",$dossier[0],"\">",$dossier[0],"</option>"; } } } ?> </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 : <?php include("fonctions.php"); include("zip.lib.php"); $dir = "images/"; $crea = "mini/"; $lpolice = 6; $t = 1; $zip = new zipfile(); while(isset($_POST['img_'.$t]) && isset($_POST['chiffre_'.$t])){ if (isset($_POST['color'])){ if (strtolower(substr($_POST['img_'.$t], -3, 3)) == 'jpg' || strtolower(substr($_POST['img_'.$t], -4, 4)) == 'jpeg'){ $image = imagecreatefromjpeg($dir.$_POST['img_'.$t]); $nbrchif = nbre_chiffre($_POST['chiffre_'.$t]); // nbre de chiffre $lchif = $nbrchif*$lpolice+2; $limage = imagesx($image) + $lchif ; $himage = imagesy($image); $destination = imagecreatetruecolor($limage, $himage); $ldestination = imagesx($destination); $hdestination = imagesy($destination); imagecopy($destination, $image, 0, 0, 0, 0, imagesx($image), $himage); $i = imagecreate($lchif,$hdestination); // image de toute la largeur imagecolorate($_POST['color'],$i); $text = imagecolorate($_POST['text'],$i); imagestring($i, 2, 2, imagesy($image)/2, $_POST['chiffre_'.$t], $text); imagecopymerge($destination, $i, imagesx($image), 0, 0, 0, imagesx($image), $himage, 100); $a = enregistre($destination, $crea.$_POST['img_'.$t], "jpeg"); $f = fopen($a, "r"); $content = fread($f, filesize($a)); fclose($f); $zip->addfile($content, "image_".$t.".jpeg"); } else if (strtolower(substr($_POST['img_'.$t], -3, 3)) == 'png'){ $image = imagecreatefrompng($dir.$_POST['img_'.$t]); $nbrchif = nbre_chiffre($_POST['chiffre_'.$t]); // nbre de chiffre $lchif = $nbrchif*$lpolice+2; $limage = imagesx($image) + $lchif ; $himage = imagesy($image); $destination = imagecreatetruecolor($limage, $himage); $ldestination = imagesx($destination); $hdestination = imagesy($destination); imagecolorate($_POST['color'],$destination); imagecopy($destination, $image, 0, 0, 0, 0, imagesx($image), $himage); $i = imagecreate($lchif,$hdestination); // image de toute la largeur imagecolorate($_POST['color'], $i); $text = textcolorate($_POST['text'], $i); imagestring($i, 2, 2, imagesy($image)/2, $_POST['chiffre_'.$t], $text); imagecopymerge($destination, $i, imagesx($image), 0, 0, 0, imagesx($image), $himage, 100); $a = enregistre($destination,$crea.$_POST['img_'.$t], "png"); $f = fopen($a, "r"); $content = fread($f, filesize($a)); fclose($f); $zip->addfile($content, "image_".$t.".png"); } elseif (strtolower(substr($_POST['img_'.$t], -3, 3)) == 'gif'){ $image = imagecreatefromgif($dir.$_POST['img_'.$t]); $nbrchif = nbre_chiffre($_POST['chiffre_'.$t]); // nbre de chiffre $lchif = $nbrchif*$lpolice +2; $limage = imagesx($image) + $lchif ; $himage = imagesy($image); $destination = imagecreatetruecolor($limage, $himage); $ldestination = imagesx($destination); $hdestination = imagesy($destination); imagecolorate($_POST['color'],$destination); imagecopy($destination, $image, 0, 0, 0, 0, imagesx($image), $himage); $i = imagecreate($lchif,$hdestination); // image de toute la largeur imagecolorate($_POST['color'],$i); $text = textcolorate($_POST['text'], $i); imagestring($i, 2, 2, imagesy($image)/2, $_POST['chiffre_'.$t], $text); imagecopymerge($destination, $i, imagesx($image), 0, 0, 0, imagesx($image), $himage, 100); $a = enregistre($destination, $crea.$_POST['img_'.$t], "gif"); $zip->addfile($crea.$_POST['img_'.$t] , "image_".$t.".gif"); $f = fopen($a, "r"); $content = fread($f, filesize($a)); fclose($f); $zip->addfile($content, "image_".$t.".gif"); } } $t++; } $archive = $zip->file(); header('Content-Type: application/x-zip'); header('Content-Disposition: attachment; filename=archive.zip'); echo $archive; ?>
fonctions.php : <?php function imagecolorate ($color, $i){ if($color == "black"){ $black = imagecolorallocate($i, 0, 0, 0); imagefill($i, 0, 0, $black); } else if($color == "blue"){ $blue =imagecolorallocate($i, 0, 0, 255); imagefill($i, 0, 0, $blue); } else if($color == "yellow"){ $yellow = imagecolorallocate($i, 255, 255, 0); imagefill($i, 0, 0, $yellow); } else if($color == "red"){ $red = imagecolorallocate($i, 255, 0, 0); imagefill($i, 0, 0, $red); } else if($color == "green"){ $green = imagecolorallocate($i, 0, 255, 0); imagefill($i, 0, 0, $green); } else if($color == "white"){ $white = imagecolorallocate($i, 255, 255, 255); imagefill($i, 0, 0, $white); } else if($color == "trans"){ $trans = imagecolorallocate($i, 0, 1, 0); imagefill($i, 0, 0, $trans); imagecolortransparent($i,$trans); } return 0; } function textcolorate ($color, $i){ if($color == "black"){ $text = imagecolorallocate($i, 0, 0, 0); } else if($color == "blue"){ $text =imagecolorallocate($i, 0, 0, 255); } else if($color == "yellow"){ $text = imagecolorallocate($i, 255, 255, 0); } else if($color == "red"){ $text = imagecolorallocate($i, 255, 0, 0); } else if($color == "green"){ $text = imagecolorallocate($i, 0, 255, 0); } else if($color == "white"){ $text = imagecolorallocate($i, 255, 255, 255); } return $text; } function enregistre($image, $adress, $format){ if (file_exists($adress)){ $i = 1; do{ $e = "png"; $nom = substr($adress, 0, -4).'_'.$i.'.'.$e; $i++; }while(file_exists($nom)); if ($format == "jpeg"){ imagejpeg($image, $nom); } else if ($format == "png"){ imagepng($image, $nom); } else if ($format == "gif"){ imagegif($image, $nom); } } else{ $nom = $adress; imagepng($image, $nom); } return $nom; } function nbre_chiffre($var){ $chif = intval($var); $nbrchif = 1; for($i = 1;;){ if(($chif/$i) < 10){ break; } else{ $nbrchif++; $i *= 10; } } return $nbrchif; }
et la librarie pas de moi zip.lib.php : <?php /* $Id: zip.lib.php,v 1.6 2002/03/30 08:24:04 loic1 Exp $ */
/** * Zip file creation class. * Makes zip files. * * Based on : * * http://www.zend.com/codex.php?id=535&single=1 * By Eric Mueller <eric@themepark.com> * * http://www.zend.com/codex.php?id=470&single=1 * by Denis125 <webmaster@atlant.ru> * * a patch from Peter Listiak <mlady@users.sourceforge.net> for last modified * date and time of the compressed file * * Official ZIP file format: http://www.pkware.com/appnote.txt * * @access public */ class zipfile { /** * Array to store compressed data * * @var array $datasec */ var $datasec = array();
/** * Central directory * * @var array $ctrl_dir */ var $ctrl_dir = array();
/** * 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 (date * in high two bytes, time in low two bytes allowing magnitude comparison). * * @param integer the current Unix timestamp * * @return integer the current date in a four byte DOS format * * @access private */ function unix2DosTime($unixtime = 0) { $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) { $timearray['year'] = 1980; $timearray['mon'] = 1; $timearray['mday'] = 1; $timearray['hours'] = 0; $timearray['minutes'] = 0; $timearray['seconds'] = 0; } // end if
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); } // end of the 'unix2DosTime()' method
/** * Adds "file" to archive * * @param string file contents * @param string name of the file in the archive (may contains the path) * @param integer the current timestamp * * @access public */ function addFile($data, $name, $time = 0) { $name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix2DosTime($time)); $hexdtime = '\x' . $dtime[6] . $dtime[7] . '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[0] . $dtime[1]; eval('$hexdtime = "' . $hexdtime . '";');
$fr = "\x50\x4b\x03\x04"; $fr .= "\x14\x00"; // ver needed to extract $fr .= "\x00\x00"; // gen purpose bit flag $fr .= "\x08\x00"; // compression method $fr .= $hexdtime; // last mod time and date
// "local file header" segment $unc_len = strlen($data); $crc = crc32($data); $zdata = gzcompress($data); $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug $c_len = strlen($zdata); $fr .= pack('V', $crc); // crc32 $fr .= pack('V', $c_len); // compressed filesize $fr .= pack('V', $unc_len); // uncompressed filesize $fr .= pack('v', strlen($name)); // length of filename $fr .= pack('v', 0); // extra field length $fr .= $name;
// "file data" segment $fr .= $zdata;
// "data descriptor" segment (optional but necessary if archive is not // served as file) $fr .= pack('V', $crc); // crc32 $fr .= pack('V', $c_len); // compressed filesize $fr .= pack('V', $unc_len); // uncompressed filesize
// add this entry to array $this -> datasec[] = $fr; $new_offset = strlen(implode('', $this->datasec));
// now add to central directory record $cdrec = "\x50\x4b\x01\x02"; $cdrec .= "\x00\x00"; // version made by $cdrec .= "\x14\x00"; // version needed to extract $cdrec .= "\x00\x00"; // gen purpose bit flag $cdrec .= "\x08\x00"; // compression method $cdrec .= $hexdtime; // last mod time & date $cdrec .= pack('V', $crc); // crc32 $cdrec .= pack('V', $c_len); // compressed filesize $cdrec .= pack('V', $unc_len); // uncompressed filesize $cdrec .= pack('v', strlen($name) ); // length of filename $cdrec .= pack('v', 0 ); // extra field length $cdrec .= pack('v', 0 ); // file comment length $cdrec .= pack('v', 0 ); // disk number start $cdrec .= pack('v', 0 ); // internal file attributes $cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header $this -> old_offset = $new_offset;
$cdrec .= $name;
// optional extra field, file comment goes here // save to central directory $this -> ctrl_dir[] = $cdrec; } // end of the 'addFile()' method
/** * Dumps out file * * @return string the zipped file * * @access public */ function file() { $data = implode('', $this -> datasec); $ctrldir = implode('', $this -> ctrl_dir);
return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall pack('V', strlen($ctrldir)) . // size of central dir pack('V', strlen($data)) . // offset to start of central dir "\x00\x00"; // .zip file comment length } // end of the 'file()' method
} // 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
|
|
|
|
|
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 : <!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($dir); while($dossier[0] = readdir($a)) { if ($dossier[0][0] != "." && $dossier[0][0] != ".." && !is_dir($dossier[0])) { if (substr($dossier[0],-3,3) == JPG || substr($dossier[0],-3,3) == jpg || substr($dossier[0],-3,3) == gif || substr($dossier[0],-3,3) == GIF || substr($dossier[0],-4,4) == JPEG || substr($dossier[0],-4,4) == jpeg || substr($dossier[0],-3,3) == png || substr($dossier[0],-3,3) == PNG) { echo "<option value=\"",$dossier[0],"\">",$dossier[0],"</option>"; } } } ?> </select><br/>
<input type="submit" value="OK" /> </form> </body> </html>
newimage.php : <?php include("fonctions.php"); $dir = "images/"; $crea = "mini/"; $lpolice = 6; if (isset($_POST['img']) AND isset($_POST['chiffre']) AND isset($_POST['color'])){ if (strtolower(substr($_POST['img'], -3, 3)) == 'jpg' || strtolower(substr($_POST['img'], -4, 4)) == 'jpeg'){ header ("Content-type: image/jpeg"); header('Content-Disposition: attachment; filename="image.jpeg"'); $image = imagecreatefromjpeg($dir.$_POST['img']); $nbrchif = nbre_chiffre($_POST['chiffre']); // nbre de chiffre $lchif = $nbrchif*$lpolice+2; $limage = imagesx($image) + $lchif ; $himage = imagesy($image); $destination = imagecreatetruecolor($limage, $himage); $ldestination = imagesx($destination); $hdestination = imagesy($destination); imagecopy($destination, $image, 0, 0, 0, 0, imagesx($image), $himage); $i = imagecreate($lchif,$hdestination); // image de toute la largeur imagecolorate($_POST['color'],$i); $text = imagecolorate($_POST['text'],$i); imagestring($i, 2, 2, imagesy($image)/2, $_POST['chiffre'], $text); imagecopymerge($destination, $i, imagesx($image), 0, 0, 0, imagesx($image), $himage, 100); enregistre($destination, $crea.$_POST['img'], "jpeg"); imagejpeg($destination); } else if (strtolower(substr($_POST['img'], -3, 3)) == 'png'){ header ("Content-type: image/png "); header('Content-Disposition: attachment; filename="image.png"'); $image = imagecreatefrompng($dir.$_POST['img']); $nbrchif = nbre_chiffre($_POST['chiffre']); // nbre de chiffre $lchif = $nbrchif*$lpolice+2; $limage = imagesx($image) + $lchif ; $himage = imagesy($image); $destination = imagecreatetruecolor($limage, $himage); $ldestination = imagesx($destination); $hdestination = imagesy($destination); imagecolorate($_POST['color'],$destination); imagecopy($destination, $image, 0, 0, 0, 0, imagesx($image), $himage); $i = imagecreate($lchif,$hdestination); // image de toute la largeur imagecolorate($_POST['color'], $i); $text = textcolorate($_POST['text'], $i); imagestring($i, 2, 2, imagesy($image)/2, $_POST['chiffre'], $text); imagecopymerge($destination, $i, imagesx($image), 0, 0, 0, imagesx($image), $himage, 100); enregistre($destination,$crea.$_POST['img'], "png"); imagepng($destination); } elseif (strtolower(substr($_POST['img'], -3, 3)) == 'gif'){ header ("Content-type: image/gif"); header('Content-Disposition: attachment; filename="image.gif"'); $image = imagecreatefromgif($dir.$_POST['img']); $nbrchif = nbre_chiffre($_POST['chiffre']); // nbre de chiffre $lchif = $nbrchif*$lpolice +2; $limage = imagesx($image) + $lchif ; $himage = imagesy($image); $destination = imagecreatetruecolor($limage, $himage); $ldestination = imagesx($destination); $hdestination = imagesy($destination); imagecolorate($_POST['color'],$destination); imagecopy($destination, $image, 0, 0, 0, 0, imagesx($image), $himage); $i = imagecreate($lchif,$hdestination); // image de toute la largeur imagecolorate($_POST['color'],$i); $text = textcolorate($_POST['text'], $i); imagestring($i, 2, 2, imagesy($image)/2, $_POST['chiffre'], $text); imagecopymerge($destination, $i, imagesx($image), 0, 0, 0, imagesx($image), $himage, 100); enregistre($destination, $crea.$_POST['img'], "gif"); imagegif($destination); } } ?>
fonctions.php <?php function imagecolorate ($color, $i){ if($color == "black"){ $black = imagecolorallocate($i, 0, 0, 0); imagefill($i, 0, 0, $black); } else if($color == "blue"){ $blue =imagecolorallocate($i, 0, 0, 255); imagefill($i, 0, 0, $blue); } else if($color == "yellow"){ $yellow = imagecolorallocate($i, 255, 255, 0); imagefill($i, 0, 0, $yellow); } else if($color == "red"){ $red = imagecolorallocate($i, 255, 0, 0); imagefill($i, 0, 0, $red); } else if($color == "green"){ $green = imagecolorallocate($i, 0, 255, 0); imagefill($i, 0, 0, $green); } else if($color == "white"){ $white = imagecolorallocate($i, 255, 255, 255); imagefill($i, 0, 0, $white); } else if($color == "trans"){ $trans = imagecolorallocate($i, 0, 1, 0); imagefill($i, 0, 0, $trans); imagecolortransparent($i,$trans); } return 0; } function textcolorate ($color, $i){ if($color == "black"){ $text = imagecolorallocate($i, 0, 0, 0); } else if($color == "blue"){ $text =imagecolorallocate($i, 0, 0, 255); } else if($color == "yellow"){ $text = imagecolorallocate($i, 255, 255, 0); } else if($color == "red"){ $text = imagecolorallocate($i, 255, 0, 0); } else if($color == "green"){ $text = imagecolorallocate($i, 0, 255, 0); } else if($color == "white"){ $text = imagecolorallocate($i, 255, 255, 255); } return $text; } function enregistre($image, $adress, $format){ if (file_exists($adress)){ $i = 1; do{ $e = "png"; $nom = substr($adress, 0, -4).'_'.$i.'.'.$e; $i++; }while(file_exists($nom)); if ($format == "jpeg"){ imagejpeg($image, $nom); } else if ($format == "png"){ imagepng($image, $nom); } else if ($format == "gif"){ imagegif($image, $nom); } } else{ imagepng($image, $adress); } } function nbre_chiffre($var){ $chif = intval($var); $nbrchif = 1; for($i = 1;;){ if(($chif/$i) < 10){ break; } else{ $nbrchif++; $i *= 10; } } return $nbrchif; }
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
|
|
|
|
|
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 
|
|
|
|
|
Chargement...
|