equal
deleted
inserted
replaced
563 }, to); |
563 }, to); |
564 } |
564 } |
565 |
565 |
566 disableJSONExts(); |
566 disableJSONExts(); |
567 |
567 |
568 // |
568 var auth_enabled = aes_self_test(); |
569 // Encryption test |
569 |
570 // |
|
571 |
|
572 var str = ''; |
|
573 for(i=0;i<keySizeInBits/4;i++) |
|
574 { |
|
575 str+='0'; |
|
576 } |
|
577 str = hexToByteArray(str); |
|
578 var ct = rijndaelEncrypt(str, str, 'ECB'); |
|
579 ct = byteArrayToHex(ct); |
|
580 var v; |
|
581 switch(keySizeInBits) |
|
582 { |
|
583 case 128: |
|
584 v = '66e94bd4ef8a2c3b884cfa59ca342b2e'; |
|
585 break; |
|
586 case 192: |
|
587 v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7'; |
|
588 break; |
|
589 case 256: |
|
590 v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087'; |
|
591 break; |
|
592 } |
|
593 auth_enabled = ( ct == v && md5_vm_test() ); |
|
594 if ( !auth_enabled ) |
570 if ( !auth_enabled ) |
595 { |
571 { |
596 alert('Login error: encryption sanity check failed\n'); |
572 alert('Login error: encryption sanity check failed\n'); |
597 return true; |
573 return true; |
598 } |
574 } |
794 { |
770 { |
795 return ( email.match(/^(?:[\w\d_-]+\.?)+@((?:(?:[\w\d_-]\-?)+\.)+\w{2,4}|localhost)$/) ) ? true : false; |
771 return ( email.match(/^(?:[\w\d_-]+\.?)+@((?:(?:[\w\d_-]\-?)+\.)+\w{2,4}|localhost)$/) ) ? true : false; |
796 } |
772 } |
797 |
773 |
798 /** |
774 /** |
|
775 * Validates a username. |
|
776 * @param string Username to test |
|
777 * @return bool |
|
778 */ |
|
779 |
|
780 function validateUsername(username) |
|
781 { |
|
782 var regex = new RegExp('^[^<>&\?\'"%\n\r/]+$', ''); |
|
783 return ( username.match(regex) ) ? true : false; |
|
784 } |
|
785 |
|
786 /** |
799 * Equivalent of PHP's time() |
787 * Equivalent of PHP's time() |
800 * @return int |
788 * @return int |
801 */ |
789 */ |
802 |
790 |
803 function unix_time() |
791 function unix_time() |