PDA

View Full Version : Web based minilogin update system


bpogue99
04-21-2003, 10:40 AM
Well, this is my first attempt at solving a problem I've had... and that's maintaining those IP addresses in the miniloginaccounts.ini. This lets the users add their own <g>. Since my server is small this works out very well.

Basically, this web page does the following:

1) Copies the miniloginaccounts.ini from the eqemu server to the web directory. This way we're not working on the live version.
2) Users can enter their information and then hit the Add It button. There's no syntax checks or anything in this right now.
3) It adds the info to the current copy of the file.
4) It copies the updated file back to the eqemu server.
5) It then kills the minilogin server on the eqemu server. The minilogin server auto-restarts itself.

Things you need:
ASPEXEC - www.softwareartisans.com
PSTOOLS - www.sysinternals.com
A webserver of course

Some things that might help read this code:

1) My EQEMU server is named EQEMU
2) It has a share created on it called EQEMU$ which points to the root of the game files (typically the Everquest directory)
3) My local webserver is at c:\webserver and I have a directory off of it specific for this stuff called eqemu (c:\webserver\eqemu)
4) The EQEMU server runs under the user EQEMU with matching password. When the command to execute the kill is done I pass it this information so we can remotely kill the minilogin server.

How do I make minilogin restart itself?
I have a batch file called mini1.bat that has these commands:
@echo off
cd \everquest
start /wait /min minilogin.exe
mini1

The eqemu.bat that I use to start the server has this line in it:
start "minibat" /min cmd /c mini1.bat

This starts the mini1.bat in it's own window named "minibat". Why?
I do it this way so I can do kill "minibat" and kill ONLY the command window associated with the minilogin system. Using this method you'll see 2 windows when it runs. One is the minibat the other is the minilogin. This allows us to auto-restart the minilogin by just killing that process as the minibat process will run it again.

I'll help where I can... and post any updates I make. Feel free to modify, enhance, etc. this code, just be sure to share it. Things I know I'd like to do but might not be able to quickly is:

1) Add ability to remove old entries (maybe some sort of checkbox/delete button thing)
2) Syntax checking on the IP address

Good luck!


<center>
<h1>EQEMU Minilogin Account Update System</h1>
<h4>Version 0.6c</h4>
</center>

<%
Dim strFile
strFile = "c:\webserver\eqemu\miniloginaccounts.ini"

' If the script doesn't have anything posted to it we display the form
' otherwise we process the input
If Request.Form.Count = 0 Then
' Display the entry form.
%>
Grabbing a copy of the miniloginaccounts.ini:
<%
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /c copy \\eqemu\eqemu$\miniloginaccounts.ini c:\webserver\eqemu\miniloginaccounts.ini"
Executor.Parameters = ""
strResult = Executor.ExecuteDosApp
Response.Write strResult
%>

<h3>Login Account Information to Add:</h3>
<form action="eqemu.asp" method="post">
<table>
<tr>
<th align="right">IP Address:</td>
<td><input type="text" name="name" size="15"></input></td>
</tr>
<tr>
<th align="right">Login ID:</td>
<td><input type="text" name="comment" size="35"></input></td>
</tr>
</table>
<input type="submit" value="Add It!"></input>
</form>

<br>

<h3>Current Login Account Information:</h3>
<%
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInFile = objFSO.OpenTextFile(strFile)

' Loop Through Real File and Output Results to Browser
Do While Not objInFile.AtEndOfStream
strIn = objInFile.ReadLine
Response.Write strIn & "<br>"
Loop

' Close file and free variables
objInFile.Close
Set objInFile = Nothing
Set objFSO = Nothing
%>

<%
Else
Dim objFSO 'FileSystemObject Variable
Dim objFile 'File Object Variable

' Create an instance of the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' Open the TextFile (FileName, ForAppending, AllowCreation)
Set objFile = objFSO.OpenTextFile(strFile, 8, True)

objFile.Write Request.Form("name")
objFile.Write " "
objFile.Write Request.Form("comment")
objFile.Write " "
objFile.Write Request.Form("comment")
objFile.WriteLine ""

' Close the file and dispose of our objects
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
%>
Storing a copy of the miniloginaccounts.ini:
<%
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /c copy c:\webserver\eqemu\miniloginaccounts.ini \\eqemu\eqemu$\miniloginaccounts.ini"
Executor.Parameters = ""
strResult = Executor.ExecuteDosApp
Response.Write strResult
%>
<br>
Attempting service restart:
<%
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /c pskill \\eqemu -u eqemu -p eqemu minilogin"
Executor.Parameters = ""
strResult = Executor.ExecuteDosApp
Response.Write "<pre>" & strResult & "</pre>"

' Tell people we've written their info
%>

<H3>Update should now be complete.</H3>
<H3>Please report any errors.</H3>
<A HREF="eqemu.asp">Back</A>
<%
End If
%>

Garrfish
04-21-2003, 02:57 PM
What is ASPEXEC from the link you provided? I went to that site and didn't find any file for download named ASPEXEC! Did I miss something?

Hardy
04-21-2003, 04:52 PM
www.serverobjects.com/comp/Aspexec.zip

google.com is a handy tool :D