Visualizzazione dei risultati da 1 a 10 su 10

Discussione: modulo CAPTCHA

  1. #1

    modulo CAPTCHA

    non riesco a vedere l'immagine

    Form

    ho scaricato questo script

    script

    e in locale lo vedo ma quando lo carico sul sito dentro htdocs (penso sia un path) nn vedo l'immagine.

    Un aiuto grazie

  2. #2
    guarda questa pillola è molto ben fatta :

    http://forum.html.it/forum/showthrea...hreadid=807514

    stai attento a non far stampare codice (anche spazi prima della classe) .

    Cmq in pochi secondi la metti su

  3. #3
    Grazie molto gentile

  4. #4
    Mi fa lo stesso difetto del precedente non vedo l'immagine....

    Dunque io ho messo i file dentro htdocs/prova.php

    e ho anche caricato il font ma nulla

    FORM

  5. #5
    il tuo serrver ha le gd installate ?

  6. #6
    si

    gd
    GD Support enabled
    GD Version 2.0 or higher
    FreeType Support enabled
    FreeType Linkage with freetype
    T1Lib Support enabled
    GIF Read Support enabled
    GIF Create Support enabled
    JPG Support enabled
    PNG Support enabled
    WBMP Support enabled

  7. #7
    l'ho riprovato ora :

    index.php

    Codice PHP:
    <?php
    error_reporting
    (E_ALL);
    require_once(
    'captcha.class.php');
    session_start();
    $captcha=new captcha();
    $act=isset($_GET['act']) ? $_GET['act'] : '';
    switch(
    $act):
        case(
    'img'):
            
    $captcha->offuscamento=3;
            
    $captcha->genera($_GET['stringa']);    
        break;
        case(
    'check'):
            if(
    $_SESSION['stringa'] == $_POST['codice']){
                echo 
    'nome: '.$_POST['nome'];
                echo 
    '
    '
    ;
                echo 
    'cognome: '.$_POST['cognome'];
            } else
                echo 
    'Il codice non corrisponde all'immagine';
        break;
        default:
            $stringa=$captcha->stringa_casuale();
            $_SESSION['
    stringa']=$stringa;
            echo '
    <form method="post" action="'.$_SERVER['PHP_SELF'].'?act=check">
            <
    ul style="list-style: none;">
            [*]
    nome: <input type="text" name="nome" />
            [*]
    cognome: <input type="text" name="cognome" />
            [*]
    codice: [img]'.$_SERVER['PHP_SELF'].'?act=img&stringa='.$stringa.'[/img]
            [*]
    inserisci il codice: <input type="text" name="codice" />
            [*]<
    input type="submit" name="invia" value="invia" />
            [/list]
            </
    form>';    
        break;
    endswitch;
    ?>
    e qui la classe captcha.class.php:

    Codice PHP:
    <?php
    // Marco Barcaro
    // 22/03/2005
    //
    // questa classe richiede le librerie grafiche GD
    //
    // Testato con Apache 1.3.33, PHP 4.3.10, GD 2.0.28 su winXP

    class captcha {

        var 
    $offuscamento '';

        function 
    captcha(){
            
    $this->x=110;
            
    $this->y=30;
            
    $this->font='arial.ttf';
            
    $this->dimensione=20;        
        }

        function 
    stringa_casuale(){
            return 
    chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90)) . chr(rand(65,90));
        }

        function 
    genera($stringa){
            
    $im=imagecreate($this->x,$this->y);
            
    $bianco=imagecolorallocate($im255255255);
            
    $nero=imagecolorallocate($im000);
            
    $box=imagettfbbox($this->dimensione0$this->font$stringa);
            
    imagettftext($im$this->dimensione055+abs($box[5]), $nero$this->font$stringa);
            
    $this->offuscamento=$this->offuscamento != NULL $this->offuscamento 0;
            
    $max=ceil(($this->$this->$this->offuscamento) / 30);
            for(
    $i=0;$i<$max;$i++){
                
    $temp_x=rand(1,$this->x);
                
    $temp_y=rand(1,$this->y);
                
    imageline ($im$temp_x$temp_y$temp_x$temp_y$nero);
            }
            for(
    $i=1;$i<$this->y;$i=$i+10){
                
    imageline ($im0$i$this->x$i+5$nero);        
            }
            for(
    $i=1;$i<$this->x;$i=$i+10){
                
    imageline ($im$i0$i+5$this->y$nero);        
            }        
            
    header("content-type: image/jpeg");
            
    imagejpeg($im,"",80);
            
    imagedestroy($im);    
        }
    }
    ?>
    controlla di non avere spazi alla fine dopo il ?>

    a me funziona ho riprovato ora

  8. #8
    Grazie per la tua pazienza...ho controllato e non ho spazi e il codice è essttamente uguale al tuo... mah nn so :master:

  9. #9
    ma ne sei sicuro ??

    guarda che a me funziona

  10. #10
    sicuro sì...il mio unico dubbio è che io sul server ho messo tutto dentro

    htdocs/

    e penso che sia corretto, ma nn vedo l'immagine come puoi vedere anche tu...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.