cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/scratchpad/samples/image-auth/flow image.js
Date Fri, 31 Oct 2003 17:12:44 GMT
tony        2003/10/31 09:12:44

  Added:       src/blocks/scratchpad/samples/image-auth/flow image.js
  Log:
  flowscript for image-auth sample
  
  Revision  Changes    Path
  1.1                  cocoon-2.1/src/blocks/scratchpad/samples/image-auth/flow/image.js
  
  Index: image.js
  ===================================================================
  
  function main() {
      
      var secret = generateSecret();
     
      while (true) {
          cocoon.sendPageAndWait("main.jxt", {secret:secret});
  
          if (cocoon.parameters.msg == "image") {
              cocoon.sendPage("auth.jpg", {text:secret});
              return;
          } else {
      
              var input = cocoon.request.get("secret");
  
              if (input == secret) {
                  break;
              }
          }
      }
      
      cocoon.sendPage("success.jxt", {secret:secret});
      
  }
  
  function generateSecret() {
      
        var characters = "!@#$%^&*(){}[]<>.,ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
      
        var passwordlength = 7;
      
        var password = "";
        var randomnumber = 0;
        
        for (var n = 0; n < passwordlength; n++) {
           randomnumber = Math.floor(characters.length*Math.random());
           password += characters.substring(randomnumber,randomnumber + 1) 
        }
        
        return password;
  }
      
  
  
  

Mime
View raw message