Check-in [00b778bd58]
Not logged in
Overview

SHA1 Hash:00b778bd585d92646741bca9755cbe6fa7cf4567
Date: 2009-12-07 22:42:42
User: stephan
Comment:Added new config option with the rather unwieldy name 'anon-login-enable-captcha-filler'
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/db.c from [295793e5a5] to [a46411d47c].

@@ -1432,10 +1432,16 @@
 ** values.  With just a property name it shows the value of that property.
 ** With a value argument it changes the property for the current repository.
 **
 ** The "unset" command clears a property setting.
 **
+**
+**    anon-login-enable-captcha-filler
+**                     If enabled, the Login page will provide a button
+**                     which uses JavaScript to fill out the captcha for
+**                     the user. (Most bots cannot use JavaScript.)
+**
 **    autosync         If enabled, automatically pull prior to
 **                     commit or update and automatically push
 **                     after commit or tag or branch creation.
 **
 **    diff-command     External command to run when performing a diff.
@@ -1477,10 +1483,11 @@
 **                     Defaults to "start" on windows, "open" on Mac,
 **                     and "firefox" on Unix.
 */
 void setting_cmd(void){
   static const char *azName[] = {
+    "anon-login-enable-captcha-filler",
     "autosync",
     "diff-command",
     "dont-push",
     "editor",
     "gdiff-command",

Modified src/login.c from [3b52c138db] to [646f690c52].

@@ -225,11 +225,11 @@
     @   <td><input type="text" id="u" name="u" value="" size=30></td>
   }
   @ </tr>
   @ <tr>
   @  <td align="right">Password:</td>
-  @   <td><input type="password" name="p" value="" size=30></td>
+  @   <td><input type="password" id="p" name="p" value="" size=30></td>
   @ </tr>
   if( g.zLogin==0 ){
     zAnonPw = db_text(0, "SELECT pw FROM user"
                          " WHERE login='anonymous'"
                          "   AND cap!=''");
@@ -250,18 +250,24 @@
   @ "Login" button.  Your user name will be stored in a browser cookie.
   @ You must configure your web browser to accept cookies in order for
   @ the login to take.</p>
   if( zAnonPw ){
     unsigned int uSeed = captcha_seed();
-    char *zCaptcha = captcha_render(captcha_decode(uSeed));
-
-    @ <input type="hidden" name="cs" value="%u(uSeed)">
+    char const * zDecoded = captcha_decode(uSeed);
+    int iAllowPasswordFill = db_get_boolean( "anon-login-enable-captcha-filler", 0 );
+    char *zCaptcha = captcha_render(zDecoded);
+
+    @ <input type="hidden" name="cs" value="%u(uSeed)"/>
     @ <p>Visitors may enter <b>anonymous</b> as the user-ID with
     @ the 8-character hexadecimal password shown below:</p>
     @ <center><table border="1" cellpadding="10"><tr><td><pre>
     @ %s(zCaptcha)
-    @ </pre></td></tr></table></center>
+    @ </pre></td></tr></table>
+    if( iAllowPasswordFill ) {
+        @ <input type="button" value="Fill out captcha" onclick="document.getElementById('u').value='anonymous'; document.getElementById('p').value='%s(zDecoded)';"/>
+    }
+    @ </center>
     free(zCaptcha);
   }
   if( g.zLogin ){
     @ <br clear="both"><hr>
     @ <p>To log off the system (and delete your login cookie)

Modified src/setup.c from [56d1a9a08f] to [800f3104a6].

@@ -269,10 +269,11 @@
   ** modified user record.  After writing the user record, redirect
   ** to the page that displays a list of users.
   */
   doWrite = cgi_all("login","info","pw") && !higherUser;
   if( doWrite ){
+    char const * anonLoginCheckedbox = PD("anonymousEnableAutofill",0);
     char zCap[50];
     int i = 0;
     int aa = P("aa")!=0;
     int ad = P("ad")!=0;
     int ae = P("ae")!=0;
@@ -337,10 +338,16 @@
     db_multi_exec(
        "REPLACE INTO user(uid,login,info,pw,cap) "
        "VALUES(nullif(%d,0),%Q,%Q,%Q,'%s')",
       uid, P("login"), P("info"), zPw, zCap
     );
+    if( anonLoginCheckedbox && (*anonLoginCheckedbox) ){
+      db_set( "anon-login-enable-captcha-filler", "on", 0 );
+    }
+    else{
+      db_set( "anon-login-enable-captcha-filler", "off", 0 );
+    }
     cgi_redirect("setup_ulist");
     return;
   }
 
   /* Load the existing information about the user, if any
@@ -445,39 +452,43 @@
   @ <tr>
   @   <td align="right" valign="top">Capabilities:</td>
   @   <td>
 #define B(x) inherit[x]
   if( g.okSetup ){
-    @    <input type="checkbox" name="as"%s(oas)>%s(B('s'))Setup</input><br>
-  }
-  @    <input type="checkbox" name="aa"%s(oaa)>%s(B('a'))Admin</input><br>
-  @    <input type="checkbox" name="ad"%s(oad)>%s(B('d'))Delete</input><br>
-  @    <input type="checkbox" name="ae"%s(oae)>%s(B('e'))Email</input><br>
-  @    <input type="checkbox" name="ap"%s(oap)>%s(B('p'))Password</input><br>
-  @    <input type="checkbox" name="ai"%s(oai)>%s(B('i'))Check-In</input><br>
-  @    <input type="checkbox" name="ao"%s(oao)>%s(B('o'))Check-Out</input><br>
-  @    <input type="checkbox" name="ah"%s(oah)>%s(B('h'))History</input><br>
-  @    <input type="checkbox" name="au"%s(oau)>%s(B('u'))Reader</input><br>
-  @    <input type="checkbox" name="av"%s(oav)>%s(B('v'))Developer</input><br>
-  @    <input type="checkbox" name="ag"%s(oag)>%s(B('g'))Clone</input><br>
-  @    <input type="checkbox" name="aj"%s(oaj)>%s(B('j'))Read Wiki</input><br>
-  @    <input type="checkbox" name="af"%s(oaf)>%s(B('f'))New Wiki</input><br>
-  @    <input type="checkbox" name="am"%s(oam)>%s(B('m'))Append Wiki</input><br>
-  @    <input type="checkbox" name="ak"%s(oak)>%s(B('k'))Write Wiki</input><br>
-  @    <input type="checkbox" name="ar"%s(oar)>%s(B('r'))Read Tkt</input><br>
-  @    <input type="checkbox" name="an"%s(oan)>%s(B('n'))New Tkt</input><br>
-  @    <input type="checkbox" name="ac"%s(oac)>%s(B('c'))Append Tkt</input><br>
-  @    <input type="checkbox" name="aw"%s(oaw)>%s(B('w'))Write Tkt</input><br>
-  @    <input type="checkbox" name="at"%s(oat)>%s(B('t'))Tkt Report</input><br>
-  @    <input type="checkbox" name="az"%s(oaz)>%s(B('z'))Download Zip</input>
+    @    <input type="checkbox" name="as"%s(oas)/>%s(B('s'))Setup<br>
+  }
+  @    <input type="checkbox" name="aa"%s(oaa)/>%s(B('a'))Admin<br>
+  @    <input type="checkbox" name="ad"%s(oad)/>%s(B('d'))Delete<br>
+  @    <input type="checkbox" name="ae"%s(oae)/>%s(B('e'))Email<br>
+  @    <input type="checkbox" name="ap"%s(oap)/>%s(B('p'))Password<br>
+  @    <input type="checkbox" name="ai"%s(oai)/>%s(B('i'))Check-In<br>
+  @    <input type="checkbox" name="ao"%s(oao)/>%s(B('o'))Check-Out<br>
+  @    <input type="checkbox" name="ah"%s(oah)/>%s(B('h'))History<br>
+  @    <input type="checkbox" name="au"%s(oau)/>%s(B('u'))Reader<br>
+  @    <input type="checkbox" name="av"%s(oav)/>%s(B('v'))Developer<br>
+  @    <input type="checkbox" name="ag"%s(oag)/>%s(B('g'))Clone<br>
+  @    <input type="checkbox" name="aj"%s(oaj)/>%s(B('j'))Read Wiki<br>
+  @    <input type="checkbox" name="af"%s(oaf)/>%s(B('f'))New Wiki<br>
+  @    <input type="checkbox" name="am"%s(oam)/>%s(B('m'))Append Wiki<br>
+  @    <input type="checkbox" name="ak"%s(oak)/>%s(B('k'))Write Wiki<br>
+  @    <input type="checkbox" name="ar"%s(oar)/>%s(B('r'))Read Tkt<br>
+  @    <input type="checkbox" name="an"%s(oan)/>%s(B('n'))New Tkt<br>
+  @    <input type="checkbox" name="ac"%s(oac)/>%s(B('c'))Append Tkt<br>
+  @    <input type="checkbox" name="aw"%s(oaw)/>%s(B('w'))Write Tkt<br>
+  @    <input type="checkbox" name="at"%s(oat)/>%s(B('t'))Tkt Report<br>
+  @    <input type="checkbox" name="az"%s(oaz)/>%s(B('z'))Download Zip
   @   </td>
   @ </tr>
   @ <tr>
   @   <td align="right">Password:</td>
   if( strcmp(zLogin, "anonymous")==0 ){
+    int enabled = db_get_boolean( "anon-login-enable-captcha-filler", 0 );
+    char const * checked = enabled ? "checked=\"checked\"" : "";
     /* User the password for "anonymous" as cleartext */
-    @   <td><input type="text" name="pw" value="%h(zPw)"></td>
+    @   <td><input type="text" name="pw" value="%h(zPw)"/>
+    @   <br/>Enable password-filler button for anonymous login? <input type="checkbox" name="anonymousEnableAutofill" %s(checked)/><br/>
+    @   </td>
   }else if( zPw[0] ){
     /* Obscure the password for all other users */
     @   <td><input type="password" name="pw" value="**********"></td>
   }else{
     /* Show an empty password as an empty input field */
@@ -618,11 +629,11 @@
   @ with check-in privileges.  When adding new trusted users, simply
   @ select the <b>Developer</b> privilege to cause the new user to inherit
   @ all privileges of the "developer" user.  Similarly, the "<b>reader</b>"
   @ user is a template for users who are allowed more access than anonymous,
   @ but less than a developer.
-  @ </li></p>
+  @ </p></li>
   @ </ul>
   @ </form>
   style_footer();
 }