Fossil SCM

Improvements to comments on recently added CAPTCHA code.

drh 2012-11-21 01:08 trunk
Commit 64231a679d0e1da770004c36a47f78fca4f2ac78
1 file changed +16 -4
+16 -4
--- src/captcha.c
+++ src/captcha.c
@@ -440,23 +440,32 @@
440440
zRes[8] = 0;
441441
return zRes;
442442
}
443443
444444
/*
445
-** Return true if a CAPTCHA is required.
445
+** Return true if a CAPTCHA is required for editing wiki or tickets or for
446
+** adding attachments.
447
+**
448
+** A CAPTCHA is required in those cases if the user is not logged in (if they
449
+** are user "nobody") and if the "require-captcha" setting is true. The
450
+** "require-captcha" setting is controlled on the Admin/Access page. It
451
+** defaults to true.
446452
*/
447453
int captcha_needed(void){
448454
if( g.zLogin!=0 ) return 0;
449455
return db_get_boolean("require-captcha", 1);
450456
}
451457
452458
/*
453459
** If a captcha is required but the correct captcha code is not supplied
454
-** in the query parameters, then return false (0).
460
+** in the query parameters, then return false (0).
455461
**
456462
** If no captcha is required or if the correct captcha is supplied, return
457463
** true (non-zero).
464
+**
465
+** The query parameters examined are "captchaseed" for the seed value and
466
+** "captcha" for text that the user types in response to the captcha prompt.
458467
*/
459468
int captcha_is_correct(void){
460469
const char *zSeed;
461470
const char *zEntered;
462471
const char *zDecode;
@@ -471,12 +480,15 @@
471480
if( strcmp(zDecode,zEntered)!=0 ) return 0;
472481
return 1;
473482
}
474483
475484
/*
476
-** Generate a new CAPTCHA seed. Write it as a hidden variable named
477
-** "captchaseed". Then return the rendered captcha text.
485
+** Generate a captcha display together with the necessary hidden parameter
486
+** for the seed and the entry box into which the user will type the text of
487
+** the captcha. This is typically done at the very bottom of a form.
488
+**
489
+** This routine is a no-op if no captcha is required.
478490
*/
479491
void captcha_generate(void){
480492
unsigned int uSeed;
481493
const char *zDecoded;
482494
char *zCaptcha;
483495
--- src/captcha.c
+++ src/captcha.c
@@ -440,23 +440,32 @@
440 zRes[8] = 0;
441 return zRes;
442 }
443
444 /*
445 ** Return true if a CAPTCHA is required.
 
 
 
 
 
 
446 */
447 int captcha_needed(void){
448 if( g.zLogin!=0 ) return 0;
449 return db_get_boolean("require-captcha", 1);
450 }
451
452 /*
453 ** If a captcha is required but the correct captcha code is not supplied
454 ** in the query parameters, then return false (0).
455 **
456 ** If no captcha is required or if the correct captcha is supplied, return
457 ** true (non-zero).
 
 
 
458 */
459 int captcha_is_correct(void){
460 const char *zSeed;
461 const char *zEntered;
462 const char *zDecode;
@@ -471,12 +480,15 @@
471 if( strcmp(zDecode,zEntered)!=0 ) return 0;
472 return 1;
473 }
474
475 /*
476 ** Generate a new CAPTCHA seed. Write it as a hidden variable named
477 ** "captchaseed". Then return the rendered captcha text.
 
 
 
478 */
479 void captcha_generate(void){
480 unsigned int uSeed;
481 const char *zDecoded;
482 char *zCaptcha;
483
--- src/captcha.c
+++ src/captcha.c
@@ -440,23 +440,32 @@
440 zRes[8] = 0;
441 return zRes;
442 }
443
444 /*
445 ** Return true if a CAPTCHA is required for editing wiki or tickets or for
446 ** adding attachments.
447 **
448 ** A CAPTCHA is required in those cases if the user is not logged in (if they
449 ** are user "nobody") and if the "require-captcha" setting is true. The
450 ** "require-captcha" setting is controlled on the Admin/Access page. It
451 ** defaults to true.
452 */
453 int captcha_needed(void){
454 if( g.zLogin!=0 ) return 0;
455 return db_get_boolean("require-captcha", 1);
456 }
457
458 /*
459 ** If a captcha is required but the correct captcha code is not supplied
460 ** in the query parameters, then return false (0).
461 **
462 ** If no captcha is required or if the correct captcha is supplied, return
463 ** true (non-zero).
464 **
465 ** The query parameters examined are "captchaseed" for the seed value and
466 ** "captcha" for text that the user types in response to the captcha prompt.
467 */
468 int captcha_is_correct(void){
469 const char *zSeed;
470 const char *zEntered;
471 const char *zDecode;
@@ -471,12 +480,15 @@
480 if( strcmp(zDecode,zEntered)!=0 ) return 0;
481 return 1;
482 }
483
484 /*
485 ** Generate a captcha display together with the necessary hidden parameter
486 ** for the seed and the entry box into which the user will type the text of
487 ** the captcha. This is typically done at the very bottom of a form.
488 **
489 ** This routine is a no-op if no captcha is required.
490 */
491 void captcha_generate(void){
492 unsigned int uSeed;
493 const char *zDecoded;
494 char *zCaptcha;
495

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button