Bizzare fonctionne en locale mais pas sur mon serveur

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Bizzare fonctionne en locale mais pas sur mon serveur

par zeus » 03 févr. 2008, 11:01

Modération :
Puisque ta question est résolue, j'ajoute le tag [Résolu]
pour indiquer aux personnes qui voudront consulter ce sujet qu'il contient une solution.

Tu peux réaliser cette opération toi-même
en cliquant sur le bouton Image qui s'affiche en haut à gauche de ce sujet
si tu as posté le 1er message en tant que membre (inscrit et identifié).

Alors... inscris-toi !!! ;)

par keny » 03 févr. 2008, 04:09

Voila j'ai résolu mon probleme en utilisant la fonction : imageellipse

merci a tous !

par keny » 03 févr. 2008, 03:50

Je viens de trouver le probleme mais cela ets vraiment bizzare !
si je change la grosseur des point par 2 au lieu de 1 sa fonctionne (et c'est tres laid)
donc ne fonctionne pas :

Code : Tout sélectionner

imagefilledellipse($this->image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $this->noisecolor);
Et cela fonctionne :

Code : Tout sélectionner

imagefilledellipse($this->image, mt_rand(0,$width), mt_rand(0,$height), 2, 2, $this->noisecolor);
Pourquoi ?

par keny » 03 févr. 2008, 03:29

La version de Gd sur mon serveur selon phpinfo 2.0 ou plus haut

Je vient de tester sur les 2 serveur la fonction imagefilledellipse() avec ce code et sa fonctionne ...

Code : Tout sélectionner

<?php // Nouvelle image $image = imagecreatetruecolor(400, 300); // Couleur de fond $bg = imagecolorallocate($image, 0, 0, 0); // Couleur de remplissage de l'ellipse $col_ellipse = imagecolorallocate($image, 255, 255, 255); // On dessine l'ellipse blanche imagefilledellipse($image, 200, 150, 300, 200, $col_ellipse); // On affiche l'image header("Content-type: image/png"); imagepng($image); ?>

par Sékiltoyai » 03 févr. 2008, 03:18

Quelle est la version de GD sur le serveur sur lequel le script ne fonctionne pas ?
Peux tu tester la fonction imagefilledellipse() séparément de ta fonction addNoise() sur les deux serveurs ?

par keny » 03 févr. 2008, 02:53

J'avoue pas trop clair :oops:

La fonction noise affiche en temps normale plein de petit cercle noir sur l'image mais la sur mon serveur aucun point ne s'affiche.

par Sékiltoyai » 03 févr. 2008, 02:23

Et ca veut dire quoi le "ca ne fonctionne pas" ?

Bizzare fonctionne en locale mais pas sur mon serveur

par keny » 03 févr. 2008, 02:19

Bonjour, j'utilise ce petit script pour afficher une image de securité contre les vilain spammer. Bref le code fonctionne sauf pour la fonction noise qui n'affiche rien sur mon serveur (fonctionne chez moi et sur lycos gratuit).

Si il y a quelq'un qui a une idée du probleme.

Merci énormément d'avance.

Ma librairie gd sur mon serveur est installé en voici les composants :

Code : Tout sélectionner

GD Support enabled GD Version 2.0 or higher FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.2.1 T1Lib Support enabled GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled
Voici le bout de code qui ne fonctionne pas coté serveur :

Code : Tout sélectionner

function addNoise() { $width = imagesx($this->image); $height = imagesy($this->image); //random dots. for($i = 0; $i < $this->num_dots; $i++) { imagefilledellipse($this->image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $this->noisecolor); } }
Voici le code source complet

Code : Tout sélectionner

<?php session_start(); /** * SecurityImage.php * * Class to implement Captcha security Images * to combat Spam, using PHP/GD * * @author A.D.Surrey. (www.surneo.com) * @version 1.3 */ class SecurityImage { var $bg, $image, $font, // Located in fonts folder. $fontsize, $colour, // Colour of text $strLength, // Length of random Text $text = "", $num_dots, // Num of noise dots to add $chars = array("a","b","c","d","e","f","g","h","i","j", "k","l","m","n","o","p","q","r","s","t", "u","v","w","x","y","z","1","2","3","4","5","6","7","8","9"); /** * Constructor, setup initial values. * * @return SecurityImage */ function SecurityImage() { $this->num_dots = 300; // How much Noise to add. $this->strLength = 5; $this->fontsize = 18; $this->selectFont(); // Decide which Font to use. $bg = "images/" . mt_rand(1,8) . ".png"; // Set bg to use. $this->image = imagecreatefrompng($bg); $this->colour = ImageColorAllocate ($this->image, 0, 0, 0); // Black $this->noisecolor = ImageColorAllocate ($this->image, 0, 0, 0); // Black /** * Automatically show when object created. */ $this->show(); /** * Set session varible so our form can compare the text * to users input */ $_SESSION['SECURITY_CODE'] = $this->text; } /** * Display our Captcha image * */ function show() { Header ("Content-type: image/png"); $this->text = $this->genString(); /** * write each letter to image */ for($i = 0; $i < $this->strLength; $i++) { $this->writeLetter($this->text[$i],(20 + $i * 25)); } $this->addNoise(); imagepng($this->image); imagedestroy($this->image); } /** * Generate a random string for our image * using the caracters in our array. * */ function genString() { for ($i = 0; $i < $this->strLength; $i++) { $this->text .= $this->chars[mt_rand(0, count($this->chars) - 1)]; } return $this->text; } /** * writes a single letter to the image, using random angles/colours * */ function writeLetter($letter ,$xvalue) { $yvalue = 30 - mt_rand(0, 10); // Randomly adjust y position. $angle = mt_rand(-30,30);// Give text a slight random angle. imagettftext($this->image, $this->fontsize, $angle, $xvalue, $yvalue, $this->colour, $this->font, $letter); } /** * Compares the given text to the one in the Security * Image. * * @return true if the text matches. */ function isMatch($t) { if($t == $this->text) { return true; } else return false; } /** * function to add extra "noise" * or random dots to the image * */ function addNoise() { $width = imagesx($this->image); $height = imagesy($this->image); //random dots. for($i = 0; $i < $this->num_dots; $i++) { imagefilledellipse($this->image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $this->noisecolor); } } /** * Chose a random TTF Font to use for out Captcha Text. * */ function selectFont() { switch (mt_rand(1,7)) { case 1 : $this->font = "fonts/Acidic.TTF"; break; case 2 : $this->font = "fonts/arial.ttf"; break; case 3 : $this->font = "fonts/frizzed.ttf"; break; case 4 : $this->font = "fonts/STACKZ.TTF"; break; case 5 : $this->font = "fonts/luggerbu.ttf"; break; case 6 : $this->font = "fonts/SCRAWL.TTF"; break; case 7 : $this->font = "fonts/times_new_yorker.ttf"; break; } } } /** * Create a new object when we include this file. */ $secim = new SecurityImage(); ?>