Ticket #954: guestbookWithCaptcha.diff
| File guestbookWithCaptcha.diff, 3.1 kB (added by mstahv, 4 years ago) |
|---|
-
modules/guestbook/conf.ini
old new -
modules/guestbook/classes/GuestbookMgr.php
old new 76 76 $input->action = ($req->get('action')) ? $req->get('action') : 'list'; 77 77 $input->submitted = $req->get('submitted'); 78 78 $input->guestbook = (object)$req->get('guestbook'); 79 $input->captcha = $req->get('captcha'); 79 80 80 81 if ($input->submitted) { 81 82 require_once 'Validate.php'; … … 92 93 if (empty($input->guestbook->message)) { 93 94 $aErrors['message'] = 'Please, fill in the message text'; 94 95 } 96 if ($this->conf['GuestbookMgr']['useCaptcha']) { 97 require_once(SGL_MOD_DIR . '/captcha/classes/Captcha.php'); 98 if(!Captcha::validateKey($input->captcha)) { 99 $aErrors['captcha'] = 'Please, fill in the characters shown in image. 100 We require this to avoid spam. Sorry for your inconvience.'; 101 $input->useCaptcha = true; 102 } 103 } 95 104 } 96 105 // if errors have occured 97 106 if (isset($aErrors) && count($aErrors)) { … … 112 121 SGL::logMessage(null, PEAR_LOG_DEBUG); 113 122 $output->pageTitle = 'Guestbook Manager :: Add'; 114 123 $output->template = 'guestbookAdd.html'; 124 125 if($this->conf['GuestbookMgr']['useCaptcha']) { 126 $output->useCaptcha = true; 127 } 115 128 116 129 // build ordering select object 117 130 $output->guestbook = DB_DataObject::factory($this->conf['table']['guestbook']); -
modules/guestbook/templates/guestbookAdd.html
old new 27 27 <textarea cols="40" rows="7" name="guestbook[message]">{guestbook.message}</textarea> 28 28 </td> 29 29 </tr> 30 {if:useCaptcha} 30 31 <tr> 32 <th align="left">{translate(#Type characters shown in image#)}:</th> 33 <td> 34 <div class="error" flexy:if="error[captcha]">{translate(error[captcha])}</div> 35 <div><img src="{makeUrl(##,##,#captcha#)}" alt="captcha" /></div> 36 <input type="text" name="captcha" /> 37 </td> 38 </tr> 39 {end:} 40 <tr> 31 41 <td colspan="2" align="center"> 32 42 <input class="wideButton" type="submit" name="submitted" value="{translate(#Add#)}" /> 33 43 <input class="wideButton" type="button" name="cancel" value="{translate(#Cancel#)}"
