home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / SetPrefs.asp < prev    next >
Text File  |  1997-11-01  |  4KB  |  119 lines

  1. <%@ LANGUAGE="VBSCRIPT" %>
  2. <% Option Explicit
  3.  
  4. Dim item
  5.  
  6. If Request.QueryString("Edit")="Yes" Then
  7.     EditVariables
  8. ElseIf Request.QueryString("Add")="Yes" Then
  9.   AddVariable
  10. End If
  11. %>
  12.  
  13. <HTML>
  14.  
  15. <BODY BGCOLOR=#FFFFFF TOPMARGIN=0 LEFTMARGIN=0 ALINK=#23238E VLINK=#228B22 LINK=#23238E>
  16. <BASEFONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=2>
  17.  
  18. <!--Change link color on mouseover
  19.     Only if running Internet Explorer 4.0 or later -->
  20. <!--#include file=../libHighlight.inc-->
  21.  
  22. These are the existing Application level variables. Their values are stored
  23. in a text file called prefs.txt. Edit or delete them as desired in the form
  24. below.<BR><BR>
  25.  
  26. <FORM METHOD=Post ACTION=SetPrefs.asp?Edit=Yes>
  27. <TABLE BORDER=1>
  28.   <TR>
  29.     <TD><B>Variable Name</B></TD>
  30.         <TD><B>Variable Value</B></TD>
  31.     <TR>
  32.  
  33. <% DisplayVariables %>
  34. </TABLE>
  35. <INPUT TYPE=SUBMIT>
  36. </FORM>
  37.  
  38. <P>
  39. To add, delete, or change a variable, type the name and value of the variable into the text 
  40. boxes below, then click Submit. If you type the name of an exiting variable and give a new value, then this
  41. variable's value will be altered in the running application and in the prefs.txt file. If
  42. you use a new variable name, an additional variable will be created for you. If you use an
  43. existing variable name and omit a value, then this variable will be deleted.
  44. <P>
  45.  
  46. <FORM METHOD=Post ACTION=SetPrefs.Asp?Update=Yes>
  47.   <TABLE BORDER=1>
  48.     <TR>
  49.         <TD>Variable Name</TD>
  50.           <TD>Variable Value</TD>
  51.       </TR>
  52.       <TR>
  53.         <TD><INPUT NAME=VarName SIZE=25></TD>
  54.         <TD><INPUT NAME=VarValue SIZE=50></TD>
  55.       </TR>
  56.   </TABLE>    
  57.   <INPUT TYPE=Submit>
  58. </FORM>
  59.  
  60.  
  61. <%
  62.   Sub DisplayVariables
  63.   Dim fso, txtSettings, stTextLine, intEqualPosition, stVarName, stVarValue, intCounter
  64.   
  65.   Set fso = Server.CreateObject("Scripting.FileSystemObject")
  66.   Set txtSettings = fso.OpenTextFile(Server.MapPath("..\Prefs.txt"))
  67.   Do Until txtSettings.AtEndOfStream
  68.     stTextLine = ConvertQuotes(txtSettings.ReadLine)
  69.     intEqualPosition = Instr(1, stTextLine, "=")
  70.     If intEqualPosition <> 0 Then
  71.       stVarName = Left(stTextLine, intEqualPosition - 1)
  72.       stVarValue = Right(stTextLine, len(stTextLine) - intEqualPosition)
  73.     End If
  74.     Response.Write "<TR><TD>" & stVarName & "</TD>"
  75.     Response.Write "<TD><INPUT SIZE=50 NAME=" & stVarName & " VALUE=" & Chr(34) & ConvertQuotes(stVarValue) & Chr(34) & "></TD></TR>"
  76.   Loop
  77. End Sub 
  78.     
  79.   ' in order to display the quotation mark character in a form's input box
  80.   ' it is necessary to convert the quotation mark to the " sequence
  81.   Function ConvertQuotes(st)
  82.     dim intQuotePosition
  83.     intQuotePosition = Instr(1, st, Chr(34))
  84.     Do Until intQuotePosition = 0 
  85.       st = Left(st, intQuotePosition - 1) & """ & Right(st, len(st) - intQuotePosition)
  86.       intQuotePosition = Instr(1, st, Chr(34))
  87.     Loop
  88.     ConvertQuotes = st
  89.   End Function
  90.     
  91. Sub ChangeVariables
  92.  
  93. End Sub
  94.     
  95. Sub EditVariables
  96.     Dim fso, txtSettings
  97.     Set fso = Server.CreateObject("Scripting.FileSystemObject")
  98.   Set txtSettings = fso.CreateTextFile(Server.MapPath("Prefs.txt"), True, False)
  99.     For Each item in Request.Form
  100.         response.write item
  101.       If Trim(item)<> "" And Trim (Request.Form(item))<>"" Then
  102.           txtSettings.WriteLine item & "=" & Request.Form(item)
  103.         End If
  104.     Next
  105. End Sub
  106.  
  107. Sub MakeNewTxtFile
  108.         Dim fso, txtSettings 
  109.         Set fso = Server.CreateObject("Scripting.FileSystemObject")
  110.       Set txtSettings = fso.CreateTextFile(Server.MapPath("Prefs.txt"), True, False)
  111.             'Create a new prefs.txt file to replace the old one
  112.       For Each item in Request.Form("VarName")
  113.                 If item <> "" And Request.Form("VarName") <> "" Then
  114.                 txtSettings.WriteLine item & "=" & request.form(item)
  115.                 End If
  116.       Next
  117.   End Sub
  118.     
  119. %>