home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / windowsxp / ftgateoffice / ftgateoffice.exe / Main / password.fts < prev    next >
Encoding:
Text File  |  2001-11-29  |  9.6 KB  |  431 lines

  1. <%
  2. #include </utility/global.fts>
  3. #include </utility/theme.fts>
  4. #include </utility/ftgate.fts>
  5.  
  6. const ERR_SUCCESS                = 0
  7. const ERR_BADMAILBOX        = 1
  8. const ERR_BADPASSWORD        = 2
  9. const ERR_BADDOMAIN            = 3
  10. const ERR_NOACCESS            = 4
  11. const ERR_BADTYPE                = 5
  12. const ERR_DISABLED            = 6
  13.  
  14. const STR_BADLOGON    = "Invalid User name/Password combination. Please re-enter."
  15. const STR_NOACCESS    = "You do not have the privileges to use Web Mail.\n\nPlease contact your System Administrator."
  16. const STR_BADTYPE        = "You cannot access this mailbox type with Web Mail.\n\nPlease contact your System Administrator."
  17. const STR_DISABLED    = "This mailbox has been disabled.\n\nPlease contact your System Administrator."
  18.  
  19. var err=0
  20.  
  21. function setDefaults()
  22. {
  23.     session.addressbook.individuals = 0
  24.     session.addressbook.groups = 0
  25.  
  26.     session.webmail.elements=10
  27.     session.webmail.width=72
  28.     session.webmail.indent=0
  29.     session.webmail.indentchar=">"
  30.     session.webmail.replyto=""
  31.     session.webmail.addsignature=0
  32.     session.webmail.signature=""
  33.  
  34. }
  35.  
  36. function readAddrBook()
  37. {
  38.     var d = new server.domain
  39.     d.domainname=session.webmail.domain
  40.  
  41.     if (d.domainname==session.webmail.domain)
  42.     {
  43.         var m = new d.mailbox
  44.         m.name=session.webmail.mailbox
  45.  
  46.         if (m.name==session.webmail.mailbox)
  47.         {
  48.             var filename = m.path+"\\WebMail\\addrbook.txt"
  49.             var file = new server.file
  50.  
  51.             if (file.open(filename))
  52.             {
  53.                 var i
  54.                 file.first()
  55.                 var line = file.text
  56.                 line=line.slice(0, line.length()-1)
  57.  
  58.                 if (line=="ab1")
  59.                 {
  60.                     file.next()
  61.                     session.addressbook.individuals = number(file.text)
  62.                     file.next()
  63.                     session.addressbook.groups = number(file.text)
  64.                     var total = number(session.addressbook.individuals+session.addressbook.groups)
  65.  
  66.                     for (i=0;i<total;i=i+1)
  67.                     {
  68.                         file.next()
  69.                         line = file.text
  70.                         session.addressbook.type[i]=number(line.slice(0, line.length()-1))
  71.                         file.next()
  72.                         line = file.text
  73.                         session.addressbook.nickname[i]=line.slice(0, line.length()-1)
  74.                         file.next()
  75.                         line = file.text
  76.                         session.addressbook.email[i]=line.slice(0, line.length()-1)
  77.                     }
  78.                 }
  79.  
  80.                 file.close()
  81.             }
  82.         }
  83.     }
  84. }
  85.  
  86. function readSettings()
  87. {
  88.     var d = new server.domain
  89.     d.domainname=session.webmail.domain
  90.  
  91.     if (d.domainname==session.webmail.domain)
  92.     {
  93.         var m = new d.mailbox
  94.         m.name=session.webmail.mailbox
  95.  
  96.         if (m.name==session.webmail.mailbox)
  97.         {
  98.             var filename = m.path+"\\WebMail\\settings.txt"
  99.             var file = new server.file
  100.  
  101.             if (file.open(filename))
  102.             {
  103.                 var i
  104.                 file.first()
  105.                 var line = file.text
  106.                 line=line.slice(0, line.length()-1)
  107.  
  108.                 if (line=="p1")
  109.                 {
  110.                     file.next()
  111.                     session.webmail.elements=number(file.text)
  112.                     file.next()
  113.                     session.webmail.width=number(file.text)
  114.                     file.next()
  115.                     session.webmail.indent=number(file.text)
  116.                     file.next()
  117.                     line = file.text
  118.                     session.webmail.indentchar=line.slice(0, line.length()-1)
  119.                     file.next()
  120.                     line = file.text
  121.                     session.webmail.replyto=line.slice(0, line.length()-1)
  122.                     file.next()
  123.                     session.webmail.addsignature=number(file.text)
  124.                     session.webmail.signature=""
  125.                     while (file.next())
  126.                     {
  127.                         session.webmail.signature=session.webmail.signature+file.text
  128.                     }
  129.                 }
  130.  
  131.                 file.close()
  132.             }
  133.         }
  134.     }
  135. }
  136.  
  137. if (form.config=="1")
  138. {
  139.   var s=string(form.mailbox)
  140.   var index=s.indexOf("@",0)
  141.   var domain
  142.  
  143.     session.webmail.user=form.mailbox
  144.  
  145.   if (index>=0)
  146.   {
  147.     session.webmail.mailbox=s.slice(0,index)
  148.     domain=s.slice(index+1,s.length)
  149.   }
  150.   else
  151.   {
  152.         session.webmail.mailbox=form.mailbox
  153.     var d = new server.domain
  154.     var count=0
  155.  
  156.     d.findfirst("*")
  157.     while (d.domainname)
  158.     {
  159.       if (d.description=="Local")
  160.       {
  161.         count=count+1
  162.         domain=d.domainname
  163.       }
  164.  
  165.       d.findnext()
  166.     }
  167.  
  168.     if (count!=1)
  169.       domain=""
  170.   }
  171.  
  172.   var d = new server.domain
  173.   d.domainname=domain
  174.   if (d.domainname)
  175.   {
  176.     var m = new d.mailbox
  177.     m.name=session.webmail.mailbox
  178.         m.name = m.name // dereference possible alias
  179.  
  180.     if (m.name)
  181.     {
  182.       if (m.verifypassword(form.password))
  183.             {
  184.                 if (m.status)
  185.                 {
  186.                     if ((m.type==MBX_LIST)||(m.type==MBX_GROUP))
  187.                     {
  188.                         session.webmail.mailbox=m.name
  189.                         session.webmail.domain=domain
  190.                         session.webmail.password=form.password
  191.                         %>
  192.                         <HTML>
  193.                         <HEAD>
  194.                         <SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
  195.                         <!--
  196.                         parent.location.href="/mailboxes/index.fts";
  197.                         //-->
  198.                         </SCRIPT>
  199.                         </HEAD>
  200.                         <BODY>
  201.                         </BODY>
  202.                         </HTML>
  203.                         <%
  204.                         output.end()
  205.                     }
  206.  
  207.                     var ok=false
  208.                     if (m.type==MBX_USER)
  209.                     {
  210.                         if (m.priv.domaindefaults)
  211.                         {
  212.                             if (d.priv.webaccess)
  213.                                 ok=true
  214.                         }
  215.                         else
  216.                         {
  217.                             if (m.priv.webaccess)
  218.                                 ok=true
  219.                         }
  220.                     }
  221.                     
  222.                     if (ok)
  223.                     {
  224.                         session.webmail.mailbox=m.name
  225.                         session.webmail.domain=domain
  226.                         session.webmail.password=form.password
  227.                         setDefaults()
  228.                         readAddrBook()
  229.                         readSettings()
  230.                         %>
  231.                         <HTML>
  232.                         <HEAD>
  233.                         <SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
  234.                         <!--
  235.                         parent.location.href="/main.fts";
  236.                         //-->
  237.                         </SCRIPT>
  238.                         </HEAD>
  239.                         <BODY>
  240.                         </BODY>
  241.                         </HTML>
  242.                         <%
  243.                         output.end()
  244.                     }
  245.                     else if (m.type==MBX_USER)
  246.                         err=ERR_NOACCESS
  247.                     else
  248.                         err=ERR_BADTYPE
  249.                 }
  250.                 else
  251.                     err=ERR_DISABLED
  252.             }
  253.       else
  254.         err=ERR_BADPASSWORD
  255.     }
  256.     else
  257.       err=ERR_BADMAILBOX
  258.   }
  259.   else
  260.     err=ERR_BADDOMAIN
  261. }
  262. else
  263. {
  264.   session.webmail.mailbox=""
  265.   session.webmail.domain=""
  266.   session.webmail.password=""
  267. }
  268. %>
  269. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  270. <HTML>
  271. <HEAD>
  272. <LINK REL=STYLESHEET HREF="/utility/main<%=nn4%>.css" TYPE="text/css">
  273. <META NAME="GENERATOR" Content="Microsoft Developer Studio">
  274. <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
  275. <TITLE>FTGate Web Mail -- Welcome</TITLE>
  276. </HEAD>
  277.  
  278. <SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
  279. <!--
  280. var dir="<%=buttons%>"
  281.  
  282. if (!document.images) {}
  283. else {
  284.   logon0 = new Image();
  285.   logon0.src  = dir+"logon.gif";
  286.   logon1 = new Image();
  287.   logon1.src = dir+"logonon.gif";
  288. }
  289.  
  290. function change(Name,Image,No)
  291. {
  292.   if (!document.images) {}
  293.   else document [Name].src = eval(Image + No + ".src");
  294. }
  295.  
  296. <%
  297. if (netscape)
  298. {
  299.   %>
  300.   document.captureEvents(Event.KEYPRESS);
  301.   document.onkeypress = keypress;
  302.  
  303.   function keypress(event)
  304.   {
  305.     if (event.which==13)
  306.     {
  307.       onLogon();
  308.       return false;
  309.     }
  310.  
  311.     return true;
  312.   }
  313.   <%
  314. }
  315. else
  316. {
  317.   %>
  318.   function keypress()
  319.   {
  320.     if (event.keyCode==13)
  321.     {
  322.       event.returnValue=null;
  323.       onLogon();
  324.     }
  325.   }
  326.   <%
  327. }
  328. %>
  329.  
  330. function onLoad()
  331. {
  332.   <%
  333.   if (err==ERR_NOACCESS)
  334.         output.writeln("alert(\""+STR_NOACCESS+"\");")
  335.     else if (err==ERR_BADTYPE)
  336.         output.writeln("alert(\""+STR_BADTYPE+"\");")
  337.     else if (err==ERR_DISABLED)
  338.         output.writeln("alert(\""+STR_DISABLED+"\");")
  339.     else if (err)
  340.     output.writeln("alert(\""+STR_BADLOGON+"\");")
  341.   %>
  342.     document.ftgate.mailbox.focus();
  343. }
  344.  
  345. function isOK(form)
  346. {
  347.   if (form.mailbox.value=="")
  348.   {
  349.     alert("Enter your Sign in name and password.");
  350.     form.mailbox.focus();
  351.     return false;
  352.   }
  353.  
  354.   return true;
  355. }
  356.  
  357. function onLogon()
  358. {
  359.   if (!isOK(document.ftgate))
  360.     return;
  361.  
  362.   document.ftgate.submit();
  363. }
  364. //-->
  365. </SCRIPT>
  366. <SCRIPT LANGUAGE="JavaScript1.2" SRC="/utility/cookies.js" TYPE="text/javascript"></SCRIPT>
  367. <SCRIPT LANGUAGE="JavaScript1.2" SRC="/utility/core.js" TYPE="text/javascript"></SCRIPT>
  368.  
  369. <BODY BGCOLOR="white" onLoad="onLoad()" MARGINHEIGHT="0" MARGINWIDTH="0" onKeypress="keypress()">
  370.  
  371. <TABLE BORDER="0" BGCOLOR="<%=border%>" WIDTH="100%" HEIGHT="<%=bodyheight%>" CELLPADDING="0" CELLSPACING="0"><TR><TD> </TD><TD VALIGN="TOP">
  372.  
  373. <FORM NAME="ftgate" METHOD="POST" onSubmit="return isOK(this)" ACTION="password.fts">
  374. <INPUT TYPE="HIDDEN" NAME="config" VALUE="1">
  375.  
  376. <TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0">
  377.   <TR>
  378.         <TD WIDTH="5" HEIGHT="18"> </TD>
  379.   </TR>
  380. </TABLE>
  381. <!--- end of the tabs ----->
  382.  
  383. <!--- start of the tab body --->
  384. <TABLE BORDER="0" BGCOLOR="<%=border%>" WIDTH="100%" CELLPADDING="0" CELLSPACING="0"><TR><TD>
  385. <TABLE <%=table%> CELLPADDING="0" CELLSPACING="0">
  386. <!----- start of block --->
  387. <TR>
  388. <TD VALIGN="TOP">
  389.     <!----- sub table goes here --->
  390.     <TABLE BORDER="0" WIDTH="100%">
  391.         <TR>
  392.             <TD>
  393.                 <TABLE BORDER="0">
  394.                     <TR>
  395.                         <TH COLSPAN="2"><%
  396.                         if (build()==FTGATE_PRO)
  397.                             output.write("You may need to enter the full email address for your mailbox, e.g. user@domain.com")
  398.                         else
  399.                             output.write(" ")
  400.                         %></TH>
  401.                     </TR>
  402.                     <TR>
  403.                         <TD>User name</TD>
  404.                         <TD COLSPAN="2"><INPUT TYPE="EDIT" NAME="mailbox" SIZE="<%=size40%>" VALUE="<%=session.webmail.user%>"></TD>
  405.           </TR>
  406.                     <TR>
  407.                         <TD>Password</TD>
  408.                         <TD><INPUT TYPE="PASSWORD" NAME="password" SIZE="<%=size15%>"></TD>
  409.                         <TD ALIGN="RIGHT">
  410.                             <A HREF="javascript:onLogon()"
  411.                             onMouseDown="change('logonA', 'logon', 1)"
  412.                             onMouseOut="change('logonA', 'logon', 0)"><IMG SRC="<%=buttons%>logon.gif" NAME="logonA" BORDER="0" WIDTH="49" HEIGHT="20" ALT="Sign In"></A>
  413.                         </TD>
  414.                     </TR>
  415.                 </TABLE>
  416.             </TD>
  417.         </TR>
  418.     </TABLE>
  419.     <!----- sub table ends here --->
  420. </TD>
  421. </TR>
  422. <!------ end of block ----->
  423. </TABLE>
  424. </TD></TR></TABLE>
  425.  
  426. </FORM>
  427.  
  428. </TD><TD WIDTH="10"> </TD></TD></TR></TABLE>
  429. </BODY>
  430. </HTML>
  431.