home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / full / atlantic / Software / Teweb / data1.cab / Pages / scripts / password.asp < prev    next >
Encoding:
Text File  |  2000-02-14  |  4.6 KB  |  157 lines

  1. <%@ LANGUAGE="VBSCRIPT" %>
  2. <%    Set clsTes = Session("TES")
  3.     If clsTes.LoggedIn = False Then
  4.         Set clsTes = Nothing
  5.         Response.Redirect("../loggedout.htm")
  6.     End If
  7.     If Request.Form("txtEncrypted") = "TRUE" Then
  8.         bEncrypted = True
  9.     Else
  10.         bEncrypted = False
  11.     End If
  12.     tErrorList = "<B>Errors:</B>"
  13.     nErrors = 0
  14.     On Error Resume Next
  15.     bSave = False
  16.     If Request.Form("btnSubmit") = "Change Password" Then
  17.         bSave = clsTes.ChangePassword (CStr(Request.Form("txtCurrent")), CStr(Request.Form("txtNew")), CStr(Request.Form("txtConfirmed")), bEncrypted, CLng(Session.SessionID))
  18.         If clsTes.ErrorNumber <> 0 Then
  19.             nErrors = 1
  20.             tErrorList = tErrorList & "<BR>" & Server.HTMLEncode(clsTes.ErrorText)
  21.         End If
  22.     End If %>
  23. <!-- #INCLUDE FILE = "settings/colours.txt" -->
  24. <HTML>
  25. <HEAD>
  26. <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
  27. <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
  28. <TITLE>Change Timesheet Expert Web Password</TITLE>
  29. <%    If Session("JAVASCRIPT") > 1 Then    'Only for FULL Javascript %>
  30. <SCRIPT LANGUAGE="javascript">
  31. <!-- 
  32.  
  33. function Shuffle(tWord) {
  34.     
  35.     tShuffle = tWord;
  36.     if (tWord.length > 0) {
  37.         for (var nLoop = 1; nLoop <= ((<%= CStr(Session.SessionID) %> % tWord.length)+1) * tWord.length ; nLoop++) {
  38.             nChar1 = Math.floor(<%= CStr(Session.SessionID) %> / nLoop) % tWord.length;
  39.             nChar2 = nLoop % tWord.length;
  40.             if (nChar1 != nChar2) {
  41.                 if (Math.min(nChar1,nChar2) > 0) {
  42.                     tTemp = tShuffle.substring(0,Math.min(nChar1,nChar2));
  43.                 }
  44.                 else {
  45.                     tTemp = "";
  46.                 }
  47.                 tTemp = tTemp + tShuffle.charAt(Math.max(nChar1,nChar2));
  48.                 if (Math.max(nChar1,nChar2) - Math.min(nChar1,nChar2) > 1) {
  49.                     tTemp = tTemp + tShuffle.substring(Math.min(nChar1,nChar2) + 1, Math.max(nChar1,nChar2));
  50.                 }
  51.                 tTemp = tTemp + tShuffle.charAt(Math.min(nChar1,nChar2));
  52.                 if (Math.max(nChar1,nChar2) < tShuffle.length - 1) {
  53.                     tTemp = tTemp + tShuffle.substring(Math.max(nChar1,nChar2) + 1, tShuffle.length);
  54.                 }
  55.                 tShuffle = tTemp;
  56.             }
  57.         }
  58.     }
  59.     return tShuffle;
  60. }
  61.  
  62. function Encrypt(tWord) {
  63.  
  64.     tTemp = Shuffle(tWord.toUpperCase());
  65.     tJunk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!รบ$%^&*()-=_+[]{},./<>?\|;'#:@~`";
  66.  
  67.     tEncrypt = "";
  68.     for (var nCount = 1; nCount <= tWord.length; nCount++) {
  69.         nEndLoop = (Math.floor(<%= CStr(Session.SessionID) %> / (2 * nCount)) % 11) + 3
  70.         for (var nJunk = 1; nJunk <= nEndLoop; nJunk++) {
  71.             tEncrypt = tEncrypt + tJunk.charAt(Math.round(Math.random() * (tJunk.length - 1)));
  72.         }
  73.         tEncrypt = tEncrypt + tTemp.charAt(nCount-1);
  74.     }
  75.     nEndLoop = (Math.floor(<%= CStr(Session.SessionID) %> / (2 * (tWord.length + 1))) % 11) + 3
  76.     for (var nJunk = 1; nJunk <= nEndLoop; nJunk++) {
  77.         tEncrypt = tEncrypt + tJunk.charAt(Math.round(Math.random() * (tJunk.length - 1)));
  78.     }
  79.     return tEncrypt;
  80. }
  81.  
  82.  
  83. function Submit() {
  84.     
  85.     document.frmPassword.txtEncrypted.value = "TRUE";
  86.     document.frmPassword.txtCurrent.value = Encrypt(document.frmPassword.txtCurrent.value);
  87.     if (document.frmPassword.txtNew.value.toUpperCase() == document.frmPassword.txtConfirmed.value.toUpperCase()) {
  88.         document.frmPassword.txtNew.value = Encrypt(document.frmPassword.txtNew.value);
  89.         document.frmPassword.txtConfirmed.value = document.frmPassword.txtNew.value;
  90.     }
  91.     else {
  92.         document.frmPassword.txtNew.value = Encrypt(document.frmPassword.txtNew.value);
  93.         document.frmPassword.txtConfirmed.value = Encrypt(document.frmPassword.txtConfirmed.value);
  94.     }
  95.             
  96. }
  97.  
  98. // -->
  99. </SCRIPT>
  100. <%    End If %>
  101.  
  102. </HEAD>
  103. <BODY BGCOLOR="<%= BackColor %>" LINK="<%= LinkColor %>" VLINK="<%= VLinkColor %>" ALINK="<%= ALinkColor %>" TEXT="<%= TextColor %>">
  104. <BASEFONT SIZE=2 COLOR="<%= TextColor %>">
  105.  
  106. <CENTER>
  107. <%    If bSave Then %>
  108.     <FONT SIZE=+2><B>Password Changed Successfully</B></FONT>
  109. <%    Else %>
  110.     
  111. <FONT SIZE=+2><B>Change Password</B></FONT>
  112. <P>
  113. <%        If nErrors Then %>
  114.             <%= tErrorList %>
  115.             <BR><BR>
  116. <%        End If %>
  117.  
  118. <FORM NAME="frmPassword" ACTION="password.asp" METHOD=POST <% If Session("JAVASCRIPT") > 1 Then %>onSubmit="Submit()"<% End If %>>
  119. <INPUT TYPE=HIDDEN NAME="txtEncrypted" VALUE="FALSE">
  120. <TABLE BORDER=0 CELLSPACING=2 CELLPADDING=2>
  121. <TR>
  122.     <TD>
  123.         <B>Old Password:</B>
  124.     </TD>
  125.     <TD>
  126.         <INPUT TYPE=PASSWORD NAME="txtCurrent" SIZE=20 MAXLENGTH=20>
  127.     </TD>
  128. </TR>
  129.  
  130. <TR>
  131.     <TD>
  132.         <B>New Password:</B>
  133.     </TD>
  134.     <TD>
  135.         <INPUT TYPE=PASSWORD NAME="txtNew" SIZE=20 MAXLENGTH=20>
  136.     </TD>
  137. </TR>
  138.  
  139. <TR>
  140.     <TD>
  141.         <B>Confirm Password:</B>
  142.     </TD>
  143.     <TD>
  144.         <INPUT TYPE=PASSWORD NAME="txtConfirmed" SIZE=20 MAXLENGTH=20>
  145.     </TD>
  146. </TR>
  147.  
  148. </TABLE>
  149. <P>
  150. <INPUT TYPE=SUBMIT NAME="btnSubmit" VALUE="Change Password">
  151.  
  152. <% End If %>
  153. </CENTER>
  154. <% Set clsTes = Nothing %>
  155. </BODY>
  156. </HTML>
  157.