PluXml 5.10.xxx

2»

Réponses

  • bazooka07bazooka07 PluXml Lead Developer, Moderator

    @BKaernel ,
    Pour le capcha image chez AlwaysData, voici la fonction createImage() dans core/lib/class.plx.capcha.php qui marche
    Voir les variables $fontPath et $fontFamily

        public function createImage($encode=false) {
            $length = self::MAX_LENGTH;
            if($length < strlen($this->_word)) {
                $length = strlen($this->_word);
            }
    
            $imgWidth = (self::CHAR_WIDTH * $length) + 30;
            $img = imagecreate($imgWidth, self::CHAR_HEIGHT);
            # background-color of image
            $bg = imagecolorallocate($img, rand(230, 255), rand(230, 255), rand(230, 255));
    
            # draw the word
            $dx = intval($imgWidth / strlen($this->_word));
            $fontPath = realpath(PLX_CORE . 'lib/fonts') . DIRECTORY_SEPARATOR;
            for($i=0; $i<strlen($this->_word); $i++) {
                $color = imagecolorallocate($img, rand(0,200), rand(0,200), rand(0,200));
                $fontSize = rand(25, 30);
                $fontFamily = rand(1, 10) . '.ttf';
                $x = rand(10, 20) + ($dx * $i);
                $x = rand($x - 5, $x + 5);
                $y = rand(28, self::CHAR_HEIGHT - 8);
                $angle = rand(-25, 25);
                imagettftext($img, $fontSize, $angle, $x, $y , $color, $fontPath . $fontFamily, $this->_word[$i]);
            }
    
            # Add random lines
            $iMax = rand(10, 20);
            for($i=0; $i<$iMax; $i++) {
                $color = imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255));
                imageline($img, rand(0, $imgWidth), rand(0, self::CHAR_HEIGHT), rand(0, $imgWidth), rand(0, self::CHAR_HEIGHT), $color);
            }
            if(!$encode) {
                header('Content-Type: image/png');
                imagepng($img);
                imagedestroy($img);
                return '';
            }
    
            ob_start();
            imagepng($img);
            imagedestroy($img);
            $data = base64_encode(ob_get_clean());
            return '<img class="capcha-img" src="data:image/png;base64,' . $data . '" width="' . $imgWidth . '" height="' . self::CHAR_HEIGHT . '">';
        }
    

    J'ai testé sur ce site :
    https://www.ardechecs.fr

Connectez-vous ou Inscrivez-vous pour répondre.