IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Utilisation d'un captcha


Sujet :

Langage PHP

  1. #1
    Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Points : 4
    Points
    4
    Par défaut Utilisation d'un captcha
    bonjour!
    c'est encore moi qui revient avec un nouveau problem tout neuf.
    en fait sur l'inscription le code captcha affiche 5 lettre a la place de 6 lettre et rend impossible les inscriptions en mettant ceci:{{{
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    The Security Answer field must be at least 6 characters in length.
    
    Security Code does not match
    }}}
    comment y remedié a ce probleme
    merci de votre aide.

  2. #2
    FoxLeRenard
    Invité(e)
    Par défaut
    aucun élément pour te répondre, car il faudrait voir
    1) le code qui te génére ton image
    2) le <form de la saisie
    3) et enfin le PHP qui ércupére tout et fait le contrôle

    merci d'avance

  3. #3
    Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Points : 4
    Points
    4
    Par défaut
    voici tout ce que j'ai trouvé enfin le code qui genere
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality
    ÿÛC		
    
     $.' ",#(7),01444'9=82<.342ÿÛC			
     
    2!!22222222222222222222222222222222222222222222222222ÿÀ–"ÿÄ	
    ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚	
    %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ	
    ÿĵw!1AQaq"2B‘¡±Á	#3RðbrÑ
    $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ?õm+JÓ‡´ùçÓ4ÔÝk4²À®ÎvñŽ§“ÔšžMKXÌãK±DLæKˆQ8ÿt.>„Ã¥;ðÌú›/•fŒ)v%†rxäq2ó©õØnÞÅ+,qʯ"$g,£¯çéYÛC¯šÒµÊ6v¾ž_"3JyŸž0}2˜üªÿö6“ÿBõ¯þÃþ5«ê6—:~ë{Ç–â6WEX°ä{q×¹*I§UIšA°ÌÒœäv\ûdoRàâÞ¿çÿ‚MG‘²Þ„cåŽ5þF«ÝhÚ}´H´[BÀ€‰<0>ÄõéžýªM-“Tº»G&ضüÐw
    Àžùã€@9ýkZ8¾ÊÙFÃßØ÷ÿÊ‹\N\®×¿õêròGi
    «Éqám8Æ/ \}Bž’}7L:\¯‰% fý嚶÷<7¯sŸÂ´nÕ5]Y-aÀŽ%¸lpÍü*ÃúÒ´®/–Ê%Ê0
    @Ê†ÉÇñÎ>¸Î(°Üí²×±ÊYXx^x Š[X"ºØ –ŒívÇ¿¿^žÆ¶Ž¢4`¶—§¦Ve¶Cý:{À÷ªº•å¶¡h-,[Í,êTì#ÈÁ$��Œý>55GKsu3vFv™ž:u?õ¡wk}FG¡èż¹4}<Hx¶L0õ~¿"[ƒ£FþSé6û¶6Èr1ÐœuëøzóTä“R±†.RÞ{g`0Œ~Bz{z8•«Ürâ	ÃXª³dƒíߎ£Ž	Å;¢ek§tS¸ðæŠ\ÒìÖ6IHlðF¿ò¨æдÛ`´›rw‹dèÀÔtÇN¹Ø_Z	¹$é¹}Çßð¥…ØîÎ]	õùî
    ;!)É-u±”4]XÒâ-"È€>dû*g±ÔuÿõÔ’øGxCäØeźa½ºwãS$‚â_³cåÏB§°=¹.™55¼ª@Få†
    ©¨öö—˜åu¬YBo
    è·P+ŦY.Få+®Aøÿ?¥G‹¥*6§Ç<oŒ}™NFFük^Ý»@z™?Ý=¿ùT7
    éx“D Èc+†8
    ‚ß©ŸÃÓ45ÔQ“øoèq^?Óôëo
    ÛOgamnítªZ8U_ àzŽžÔTŸ%Y<;F—%Ò¸Èû§cdLä~MÜ뤚Ž§M ›†ðî˜F‹öH°ÍóòÃάNѤrIvêÈHÛžÀôØžk‰Ó¼{¥Úé–·ÞÈð@‘”DUBU@äîɧµX´½ÊÂÞíJŽ‰H_`7Žƒ¿S“ÐqWsŸ‘Ý¿ëüÍæ¶Ôõ6„\[EoiòýütÿžÂ¶®ŠZHùJãðäq\gü,},òÃRÑ!ˆÕ‰ýi¯ñH’6F:¾•H”pA¡14ÞöüMÛ0‡]ÕYà•Fb'gUÊŸîœóíŸzÒó
    ÿ«ša%»0ðþf¼ò/éqÜĺÂ;_,¯æc 8e?çµj'Ä/•]:ì¿rcG?™lšI—8[ëï:Ha²I<ý²K$Œí)o.BOpô5p^/—ó0–"0K€§Ügî·àGNõʧĝ"6`¿hý°üwóô?ŸjSñ'FoŽÚü~pcL½×ÿÕé†KWèu±Mœyæ.7rCãÔÔ}:ÍÖ6¬6r£·‘äeЯÜN£¯CíŠÀ—â‚Ä2Y^†Ü	ýÒúž¯\¹üj¯è—1´Om~ñ¸ÚK"Ù·r=~sI°Œu¹Óx€cH™#ù–á“a›rôö<Ÿ®}kNHÐÊÑÈ¡¢œ`ƒýà?¨†ßzóØ|a¡$ˆgT¹E$…“nÑžàoë×××5¤ß4‰!hÞýÙù_ËN£HÝ×?Ëð¦˜8µdŽ¶ux”fQåg‰ïDzžã·>¼œfœdÞe’1–UçrŸO\à}±Ç5É?Ä*X7µ¿Ô«mDã#·ÍP7Äm,xí¯™†Å?ŏ›¡ôú£‘´(ÂOFµ;yH
    êA‚’9Ê·~;OáP_[s*ê679úgŽ2ør‹ñE	$Mk~aa€»€G#ïôÿj|4	-ïË…ˆ9=ÿŠ‹¦$¥5Ðê„Áâ[Ž7ÂJʧ¿¡õãsS\|¾TŸÜq럗ÿfÏá\<´XÕ´½-°G ؘudüÝqýG½IÿHkFà¿ÉR›¼´'??\u¡1¸ku°¿á	¡Ã"à+].G¡ÚÿÏôçÔÑX~/ñ…‡ˆtxmm ¹ŽTeo1Wn°À Ÿ_J*%¾‡EòêÿÙ
    et voici un exemple d'image en piece jointe
    Images attachées Images attachées  

  4. #4
    Invité
    Invité(e)
    Par défaut
    Euh, avec le code que tu donnes, il faudrait faire appel à Champollion !
    http://fr.wikipedia.org/wiki/Jean-Fr...is_Champollion

    Sinon, tu dois avoir un fichier de "config" du captcha, où tu peut définir le nombre de lettres affichées.
    Il faut aussi voir si la fonction qui vérifie ce nombre de lettres est elle aussi modifiée.

    Perso, j'utilise cryptographp :
    http://www.captcha.fr/
    Ca fonctionne bien, facile à installer et à paramétrer ...

  5. #5
    Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Points : 4
    Points
    4
    Par défaut
    un peu perdu dans les fichiers dans et dans le dossier captcha je n'ai que l'image a edite, a voir. rien d'autre peut etre que le fichier config se trouve autre part que je ne peux voir pour le moment

  6. #6
    Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Points : 4
    Points
    4
    Par défaut
    rebonjour je suis de retour pour apporté le code php dans l'espoir d'avoir une correction.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    <?php
     
    /**
     * Generates a new captcha image
     *
     *
     * @copyright Copyright (c) 2008 [x-MoBiLe] Nulled
     * @license
     * @since 2007-12-13
     */
    class Captcha extends Controller
    {
    		//Constructor
    		function Captcha()
    		{
    				parent::Controller();
    		}
    		function index()
    		{
    				//Load the captcha plugin
    				$this->load->plugin('captcha');
    				//Create the captcha image
    				$randKey = 123456;
    				$vals = array('word' => $this->_randomPassword(5, $randKey), 'img_path' => BASEPATH . '../application/images/captcha/', 'img_url' => base_url() . 'application/images/captcha/', 'font_path' => BASEPATH . '../application/fonts/verdana.ttf', 'font_size' => 25, 'img_width' => 150, 'img_height' => 30, 'expiration' => 7200);
    				$cap = create_captcha($vals);
    				echo $cap['word'] . '|' . $cap['time'] . '|' . $randKey;
    		}
    		function _randomPassword($length = 8, $seed = '')
    		{
    				$password = "";
    				$possible = "0123456789";
    				$i = 0;
    				mt_srand(($seed == '') ? rand() : $seed);
    				while ($i < $length)
    				{
    						$char = substr($possible, mt_rand(0, strlen($possible) - 1), 1);
    						if (!strstr($password, $char))
    						{
    								$password .= $char;
    								$i++;
    						}
    				}
    				return $password;
    		}
    }
    ?>
    J'attend avec impatience et Merçi d'avance.

  7. #7
    Invité
    Invité(e)
    Par défaut
    $this->_randomPassword(5, $randKey) ----> $this->_randomPassword(6, $randKey)
    Je ne vois que ca...

  8. #8
    Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Points : 4
    Points
    4
    Par défaut
    si j'ai rectifié le problem du 5 au 6 et il faut toujours regénérer pour avoir 6 chiffres.
    il revele un autre problem sur register.php on line 127
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    mt_srand(($seed == '') ? rand() : $seed);
    bon voici tout le code.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    <?php
     
    /**
    * Login Page
    *
    *
    * @copyright Copyright (c) 
    * @license
    * @since 2009-12-13
    */
    class Register extends Controller
    {
          //Constructor
          function Register()
          {
                parent::Controller();
                loggedInTakeIn();
                //Load the language file
                $this->lang->load('login', $this->config->item('language_code'));
                $this->lang->load('register', $this->config->item('language_code'));
          }
          function index()
          {
                //Load the required model, libraries, plugins.
                $this->load->model('registerModel');
                $this->load->model('usermodel');
                $this->load->library('validation');
                $this->load->plugin('captcha');
                //Set the form validation rules
                $this->_registerFrmRules();
                //Delete the old captcha images
                if (isset($_POST['time'])) @unlink(BASEPATH . '../application/images/captcha/' . $_POST['time'] . '.jpg');
                //Create the captcha image
                $randKey = rand();
                $vals = array('word' => $this->_randomPassword(5, $randKey), 'img_path' => BASEPATH . '../application/images/captcha/', 'img_url' => base_url() . 'application/images/captcha/', 'font_path' => BASEPATH . '../application/fonts/verdana.ttf', 'font_size' => 25, 'img_width' => 150, 'img_height' => 30, 'expiration' => 7200);
                $cap = create_captcha($vals);
                //set the output data
                $outputData['captcha'] = $cap;
                $outputData['randKey'] = $randKey;
                $outputData['lifeStage'] = $this->registerModel->getLifeStage();
                $outputData['schoolStatus'] = $this->registerModel->getSchoolStatus();
                $outputData['securityQuestions'] = $this->usermodel->getSecurityQuestions();
                //Do the validation
                if ($this->validation->run() == false || ($this->input->post('iam') == 3 && $this->input->post('high_school') == ''))
                {
                      if ($this->input->post('iam') == 3 && $this->input->post('high_school') == '') $this->validation->error_string = $this->validation->error_string . $this->validation->_error_prefix . $this->lang->line('register_high_school_required') . $this->validation->_error_suffix;
                      //Oops! validation Error.
                      $outputData['validationError'] = $this->validation->error_string;
                      $outputData['college_year'] = $this->input->post('college_Year') . '-' . date('m') . '-' . date('d');
                      $outputData['highschool_year'] = $this->input->post('high_school_Year') . '-' . date('m') . '-' . date('d');
                      $outputData['dateofbirth'] = $this->input->post('birthday_Year') . '-' . $this->input->post('birthday_Month') . '-' . $this->input->post('birthday_Day');
                      $this->smartyextended->view('register', $outputData);
                }
                else
                {
                      //Load the user model
                      $this->load->model('usermodel');
                      //Create the new user
                      $newUserStatus = $this->usermodel->newUser($_POST);
                      if ($newUserStatus != false)
                      {
                            //Registration completed succcess
                            //Send the confirmation email
                            $this->_sendConfirmEmail($this->input->post('register_name'), $this->input->post('register_email'));
                            /* Send the confirmation E-Mail */
                            $outputData['email'] = $this->input->post('register_email');
                            $this->smartyextended->view('registersuccess', $outputData);
                      }
                      else
                      {
                            $outputData['validationError'] = $this->lang->line('register_error_email_exists');
                            $this->smartyextended->view('register', $outputData);
                      }
                }
          }
          function _registerFrmRules()
          {
                $rules['register_name'] = 'trim|required|alpha_dash_space|min_length[6]';
                $rules['iam'] = 'required';
                $rules['register_email'] = 'trim|required|valid_email';
                $rules['register_password'] = 'required|min_length[6]';
                $rules['birthday_Month'] = 'required|callback__dateCheck';
                $rules['security_answer'] = 'trim|required|alpha_dash_space|min_length[6]';
                $rules['captcha_response'] = 'required|callback__captcha_check';
                $rules['terms'] = 'required';
                $this->validation->set_rules($rules);
                $fields['register_name'] = $this->lang->line('register_fullname');
                $fields['iam'] = $this->lang->line('register_iam');
                $fields['register_email'] = $this->lang->line('register_email');
                $fields['register_password'] = $this->lang->line('register_password');
                $fields['security_answer'] = $this->lang->line('register_security_answer');
                //$fields['captcha_response'] = $this->lang->line('register_captcha');
                $fields['terms'] = $this->lang->line('register_terms');
                $this->validation->set_fields($fields);
          }
          function _captcha_check($captcha)
          {
                $randomWord = $this->_randomPassword(6, $_POST['randKey']);
                if (trim($captcha) == '')
                {
                      $this->validation->set_message('_captcha_check', $this->lang->line('register_the') . '%s' . $this->lang->line('register_requireds'));
                      return false;
                } elseif ($randomWord != $this->input->post('captcha_response'))
                {
                      $this->validation->set_message('_captcha_check', $this->lang->line('register_code_mismatch'));
                      return false;
                }
                else
                {
                      return true;
                }
          }
          function _dateCheck()
          {
                if (checkdate($this->input->post('birthday_Month'), $this->input->post('birthday_Day'), $this->input->post('birthday_Year')) == false)
                {
                      $this->validation->set_message('_dateCheck', $this->lang->line('register_date_invalid'));
                      return false;
                }
                else  return true;
          }
          function _randomPassword($length = 8, $seed = '')
          {
                $password = "";
                $possible = "0123456789";
                $i = 0;
                mt_srand(($seed == '') ? rand() : $seed);
                while ($i < $length)
                {
                      $char = substr($possible, mt_rand(0, strlen($possible) - 1), 1);
                      if (!strstr($password, $char))
                      {
                            $password .= $char;
                            $i++;
                      }
                }
                return $password;
          }
          function _sendConfirmEmail($username, $email)
          {
                $this->load->model('emailTemplateModel');
                $this->load->library('email');
                $emailTemplate = $this->emailTemplateModel->readEmailTemplate('register_confirm');
                /* Send the Confirm E-Mail as the register is confirmed successfully */
                $settings = $this->settingsmodel->readSetting('admin_email, admin_name, site_name, site_title');
                $adminEmail = $settings['admin_email'];
                $adminName = $settings['admin_name'];
                $confirmKey = md5(time());
                $confirmText = base_url() . 'register/confirm/' . $confirmKey;
                //Set the user activation key
                $this->usermodel->setUserActivationKey($email, $confirmKey);
                $splVars = array("~~receiverName~~" => $username, "~~siteName~~" => $settings['site_name'], "~~siteTitle~~" => $settings['site_title'], "~~attachUrl~~" => $confirmText, "~~adminEmail~~" => $adminEmail, "~~adminName~~" => $adminName);
                $subject = strtr($emailTemplate['template_subject'], $splVars);
                $message = strtr($emailTemplate['template_content'], $splVars);
                $this->email->from($adminEmail, $adminName);
                $this->email->to($email);
                $this->email->subject($subject);
                $this->email->message(nl2br($message));
                $this->email->send();
          }
          function confirm($confirmKey)
          {
                //Load the user model
                $this->load->model('usermodel');
                //setUserActive
                $this->usermodel->setUserActive($confirmKey);
                //Set the flash data
                $this->session->set_flashdata('flash_msg', $this->lang->line('register_confirm_success'));
                //go the login page
                redirect('login');
          }
    }
    ?>

Discussions similaires

  1. Récupération de la valeur d'un captcha utilisant simplecatcha
    Par duelking75010 dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 03/03/2013, 16h18
  2. [WB11] Utiliser une captcha
    Par alaclef dans le forum WebDev
    Réponses: 9
    Dernier message: 16/12/2010, 11h19
  3. [JpGraph] Utiliser un captcha : récupérer le texte affiché
    Par 12monkeys dans le forum Bibliothèques et frameworks
    Réponses: 6
    Dernier message: 16/01/2008, 18h06
  4. utilisation du meta type ANY
    Par Anonymous dans le forum CORBA
    Réponses: 1
    Dernier message: 15/04/2002, 12h36
  5. Réponses: 2
    Dernier message: 20/03/2002, 23h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo