home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / image.js < prev    next >
Encoding:
JavaScript  |  2004-07-12  |  1.5 KB  |  58 lines

  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. *     http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16.  
  17. function main() {
  18.     
  19.     var secret = generateSecret();
  20.    
  21.     while (true) {
  22.         cocoon.sendPageAndWait("main.jxt", {secret:secret});
  23.  
  24.         if (cocoon.parameters.msg == "image") {
  25.             cocoon.sendPage("auth.jpg", {text:secret});
  26.             return;
  27.         } else {
  28.     
  29.             var input = cocoon.request.get("secret");
  30.  
  31.             if (input == secret) {
  32.                 break;
  33.             }
  34.         }
  35.     }
  36.     
  37.     cocoon.sendPage("success.jxt", {secret:secret});
  38.     
  39. }
  40.  
  41. function generateSecret() {
  42.     
  43.       var characters = "!@#$%^&*(){}[]<>.,ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  44.     
  45.       var passwordlength = 7;
  46.     
  47.       var password = "";
  48.       var randomnumber = 0;
  49.       
  50.       for (var n = 0; n < passwordlength; n++) {
  51.          randomnumber = Math.floor(characters.length*Math.random());
  52.          password += characters.substring(randomnumber,randomnumber + 1) 
  53.       }
  54.       
  55.       return password;
  56. }
  57.     
  58.