Jump to content

Recommended Posts

  • 1 month later...
Posted

FYI

Any ip like this: 192.168.0.x, is a network ip. It's your ip on your network, do you really have 44 computers in your network? 127.0.0.1 is like a callback, or it's just localhost. Any other ip is an internet ip.

I like this, although I'll stick with apache! Maybe you should try and integrate php? MySQL? Perl? ASP? Cgi?

http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Posted

FYI

Any ip like this: 192.168.0.x, is a network ip. It's your ip on your network, do you really have 44 computers in your network? 127.0.0.1 is like a callback, or it's just localhost. Any other ip is an internet ip.

I like this, although I'll stick with apache! Maybe you should try and integrate php? MySQL? Perl? ASP? Cgi?

Thanks for the feedback!

I just wanted a webserver which I can easily customize to my needs and I know exactly what it does, inside out. (Helps for website debugging)

I'll do CGI first, it's simple!

Step 1: Rename <script>.cgi to temp.exe

Step 2: Run the exe and collect the data on the output stream

Step 3: Post the data to the client.

Step 4: Delete temp.exe

Maybe when I'm free?

#)

Posted

@nfwu

The issue with standard compliant browers is that the mime type in the header is being sent as text/plain instead of text/html. I did a quick hack on the script last week some time and the html pages now appears as they should. Most of the changes in the script are in the main while loop. I also added an internal 404 page as an experiment. My intentions were to use the script as a white list/ black list proxy server but I had to table the project temporarily as another project came up.

Please look at the code. pm me if you have any questions.

#include <Array.au3>
#include <INet.au3>
#include <File.au3>
;;#include "DSO.au3"
;#include "RSUDF.au3"
Global $mime = ""
Global $filetypes = _ArrayCreate("html","text/html","htm","text/html","gif", "image/gif", "bmp", "image/x-xbitmap", "jpg", "image/jpeg", "jpeg", "image/jpeg", "jpe", "image/jpeg", "ppt", "application/vnd.ms-powerpoint", "xls", "application/vnd.ms-excel", "doc", "application/msword", "swf", "application/x-shockwave-flash")
Global $newsession = 1
Global $listen
Global $sock
Global $serverName[100]
Global $serverPids[100]
Global $serverSPtr = 0
Global $recv
Global Const $IP = InputBox( "Wood's General Server", "Input IP address:", _GetIP() )
Global Const $PORT = 80
Global Const $a= "'"
Global Const $E404 = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80"><title>%IP%:%PORT% - Error 404 - File %REQUEST% not found.</title>'& _
                '</head><body bgcolor="#FFFFFF"><h1>Wood'&$a&'s Technologies General Purpose Server</h1><h2>Error 404: File %REQUEST% not found</h2>'& _
                '<p>The server which you are requesting the file&quot;%REQUEST%&quot; from cannot find the file.</p><hr><address>Wood'& _
                $a&'s Technologies General Server (1.2.0), IP: %IP%, PORT:%PORT% (%_MDAY%/%_MON%/%_YEAR% %_HOUR%:%_MIN%:%_SEC%)</address></body></html>'
TCPStartup()

$listen = TCPListen($IP, $PORT, 100)
If $listen = -1 Then
    $err = @error
    MsgBox(16, "Error", "Unable to connect." & @CRLF & @CRLF & "dec: " & $err & @CRLF & "hex: 0x" & Hex($err, 8))
EndIf


While 1
    $sock = TCPAccept($listen)                        ;;Poll the socket for commands
    If $sock >= 0 Then
        
        $recv = _SockRecv($sock)                        ;;Get Command from socket
        _DSO_Referer($recv)                          ;;Do some DSO related stuff
        $recv = StringSplit($recv, " ")              ;;Split up the Command
        $recvRequest = StringSplit($recv[2], "?")      ;;Split up the Request
        
        If StringInStr($recv[2], "woodserverexeoutput=") Then 
            $html = _VarsInterpret(_Server_Execute($recvRequest[2]))    ;;Server-Related Command
        ElseIf StringInStr($recv[2], "directserveroutput=") Then
            $html = _VarsInterpret(_DirectServerOutput($recvRequest[2], _URLDecode($recvRequest[1])));;'DSO'-Related Command
        Else
            $html = _Get(_URLDecode($recvRequest[1]))   ;;Normal file request
        EndIf
        consoleWrite(_URLDecode($recvRequest[1])&@lf)
        $mime = _GetFileType(_URLDecode($recvRequest[1]))
        consoleWrite("mime>"&$mime&@lf)
        $send = _SockSend($sock, _GetHeader($mime) & $html)  ;;Send the data
    EndIf
    TCPCloseSocket($sock)
Wend
Exit


;;;;Functions

Func _Server_Execute($aVar="")
    Return
EndFunc


;;Get Functions

;Gets the document header
FUNc _GetHeader($filetype="text/plain")
    Return 'HTTP/1.0 200 OK' & @CRLF & 'Content-Type: ' & $filetype & @CRLF & @CRLF
EndFunc
;Gets the filetype for the header using the extention
Func _GetFileType($ext)
    For $i = 0 to UBound($filetypes)-1 Step 2
        If StringInStr($ext, $filetypes[$i]) Then Return $filetypes[$i+1]
    Next
    Return "text/plain"
EndFunc
;Get a file normally
Func _GET($filename)
   ;;Default to index.html
    If $filename = "/" or $filename = "\" or $filename = "" Then $filename = "\index.html"
    $file = @ScriptDir & "\" & $filename
    
   ;;If file does not exist, send an error 404
    If Not FileExists($file) Then
        ConsoleWrite("File>"&$file&@crlf)
        if FileExists(@ScriptDir & "\" &"ERROR_404.html") then
            Return _GET("/ERROR_404.html")
        Else
            consoleWrite($E404)
            return _VarsInterpret($E404)
        EndIf
    EndIf
    
   ;;Check for Unauthorized access
    If StringInStr(FileGetAttrib($file), "D") And IniRead(@ScriptDir & "\variables.ini", "Permissions", "folders", 0) = 0 THen Return _GET("/ERROR_401.html")
    If StringInStr($file, "..") And IniRead(@ScriptDir & "\variables.ini", "Permissions", "prevdir", 0) = 0 THen Return _GET("/ERROR_401.html")
    
   ;;Read the data from the file
    $data = FileRead($file, FileGetSize($file))
    
   ;;If html file, transalte %% macros
    if StringInStr(FileGetExt($file), "htm") Then $data = _VarsInterpret($data)
    
    Return $data
EndFunc

;;Sock Functions

;Recieve Data on a socket
Func _SockRecv( $iSocket, $iBytes = 2048 )
    Local $sData = ""
   ;;Loop Until you recieve data on the socket
    While $sData = ""
        $sData = TCPRecv($iSocket, $iBytes)
    Wend
   ;;Flash a MsgBox
    MsgBox(0,"",$sData)
   ;;Log the Command
    _FileWriteLog( @ScriptDir&"\log.txt", $sData )
    Return $sData
EndFunc

;Send Data on a socket
Func _SockSend( $iSocket, $sData )
;   ConsoleWrite($sData&@crlf)
    Return TCPSend($iSocket, $sData)
EndFunc

;;OnExit Function
Func OnAutoItExit()
    TCPCloseSocket($sock)
    TCPCloseSocket($listen)
    TCPShutdown()
    Exit
EndFunc

#cs The old code dump:
$send = _SockSend($sock, _GetHeader(_GetFileType(FileGetExt(_URLDecode($recv[2])))) & $html)
#ce




Global $DSO_REFERER = ""
Global $DSO_REFERER_ALLOW = 0
Func _DirectServerOutput($input, $file)
    $str = StringTrimLeft($input, StringLen("directserveroutput="))
    Switch $str
    Case 'of0'
        If StringInStr(FileGetAttrib(@ScriptDir&'/'&$file), "D") THen Return _DSO_Dir($file&'/')
        Return _Get($file)
    EndSwitch
EndFunc
Func _DSO_Dir($s_Path)
   ;$data = ''
   ;#CS
    $s_Mask = '*'
    Local $html = '<table border=1><caption>Directory Listing of '&_URLEncode($s_Path)&'</caption>'
    $html &= '<TR><TH>Name<TH>Ext<TH>Attrib<TH>Size<TH>Created On<TH>Modified ON<TH>Accessed On<TH>Link'
    $h_Search = FileFindFirstFile(@ScriptDir & $s_Path & $s_Mask)
    $s_FileName = FileFindNextFile($h_Search)
    If Not @error Then
        While Not @error
            $s_FullName = $s_Path & $s_FileName
            $i_ExtMarker = StringInStr($s_FileName,'.',0,-1)
            If $i_ExtMarker Then
                $html &= '<TR>'&'<TH>'&StringLeft($s_FileName, $i_ExtMarker - 1)&'<TH>'&StringMid($s_FileName, $i_ExtMarker + 1)
            Else
                $html &= '<TR>'&'<TH>'&$s_FileName&'<TH>'&''
            EndIf
            $html &= '<TH>'&FileGetAttrib(@ScriptDir & $s_FullName)&'<TH>'&FileGetSize(@ScriptDir & $s_FullName)&'<TH>'& _
                    FileGetTime(@ScriptDir & $s_FullName,1,1)&'<TH>'&FileGetTime(@ScriptDir & $s_FullName,0,1)&'<TH>'& _
                    FileGetTime(@ScriptDir & $s_FullName,2,1)&'<TH>'&'<a href="http://%IP%'&$s_FullName&'?directserveroutput=of0">'& _
                    'Open</a>'
            $s_FileName = FileFindNextFile($h_Search)
        WEnd
    EndIf
    $html &= '</table>'
   ;#CE
   ;$PID = Run(@ComSpec & ' /c DIR "'&@ScriptDir&'\'&$s_Path&'"', '', @SW_HIDE, 2)
   ;Do
   ;    $data = $data & StdoutRead($PID)
   ;Until @error
   ;Return $data
    Return $html
EndFunc
Func _DSO_OpenFile($file)
    If Not FileExists($file) Then Return _GET("/ERROR_404.html")
    If StringInStr($file, "..") And IniRead(@ScriptDir & "\variables.ini", "Permissions", "prevdir", 0) = 0 THen Return _GET("/ERROR_401.html")
    If StringInStr(FileGetAttrib($file), "D") THen Return _DSO_Dir($file)
    $data = FileRead($file, FileGetSize($file))
    if StringInStr(FileGetExt($file), "htm") Then
        $data = _VarsInterpret($data)
    EndIf
    Return $data
EndFunc
Func _DSO_Referer($recv)
    $recvparams = StringSplit($recv, @CRLF)
    $DSO_REFERER = ''
    For $i = 1 to $recvparams[0]
        If StringLeft($recvparams[$i], StringLen("Referer: ")) == "Referer: " Then
            $DSO_REFERER = StringTrimLeft($recvparams[$i], StringLen("Referer: "))
        EndIf
    Next
EndFunc
Func _DSO_Login()
EndFunc

Func _QuickArraySearch($array, $val)
    For $i = 0 to UBound($array)-1
        If $array[$i] = $val Then Return $i
    Next
EndFunc

;;Var Functions
Func _VarsInterpret( $sData )
    Local $sFile = @ScriptDir & "\variables.ini", $aVars = IniReadSection($sFile, "Variables")
    If @error Then
        SetError(1)
        Return $sData
    EndIf
    For $i = 1 to $aVars[0][0]
        $sData = StringReplace($sData, $aVars[$i][0], Execute($aVars[$i][1]))
    Next
    Return $sData
EndFunc
Func _VarsGet($varlist="")
    Return StringSplit($varlist, "&")
EndFunc

;; By: MrSpacely
;; At: Dec 21 2005, 06:08 AM  (+8 GMT)
;; In: http://www.autoitscript.com/forum/index.php?showtopic=18448
Func FileGetExt($inputfilename)
    If StringInStr($inputfilename, "\") Then $inputfilename = StringRegExpReplace($inputfilename, ".*\\([^\\])", "\1")
    If StringInStr($inputfilename, "/") Then $inputfilename = StringRegExpReplace($inputfilename, ".*/([^/])", "\1")
    If StringInStr($inputfilename, ".") Then
        Return StringRegExpReplace($inputfilename, ".*\.([^.])", "\1")
    Else
        Return -1
    EndIf
EndFunc  ;==>FileGetExt

;;STACK UDFs by nfwu
Func _StackPop(ByRef $avArray)
    Local $sLastVal
    If (Not IsArray($avArray)) Then
        SetError(1)
        Return "";$_StackEmpty
    EndIf
    $sLastVal = $avArray[UBound($avArray) - 1]
    If UBound($avArray) = 1 Then
        $avArray = "";$_StackEmpty
    Else
        ReDim $avArray[UBound($avArray) - 1]
    EndIf
    
    Return $sLastVal
EndFunc  ;==>_StackPop
Func _StackPush(ByRef $avArray, $sValue)
    If IsArray($avArray) Then
        ReDim $avArray[UBound($avArray) + 1]
    Else
        Dim $avArray[1]
    EndIf
    $avArray[UBound($avArray) - 1] = $sValue
    SetError(0)
    Return 1
EndFunc  ;==>_StackPush

;===============================================================================
; _URLEncode()
; Description:      : Encodes a string to be URL-friendly
; Parameter(s):     : $toEncode    - The String to Encode
;                    $encodeType = 0 - Practical Encoding (Encode only what is necessary)
;                                = 1 - Encode everything
;                                = 2 - RFC 1738 Encoding - http://www.ietf.org/rfc/rfc1738.txt
; Return Value(s):  : The URL encoded string
; Author(s):        : nfwu
; Note(s):          : -
;
;===============================================================================
Func _URLEncode($toEncode, $encodeType = 0)
    Local $strHex = "", $iDec
    Local $aryChar = StringSplit($toEncode, "")
    If $encodeType = 1 Then;;Encode EVERYTHING
        For $i = 1 To $aryChar[0]
            $strHex = $strHex & "%" & Hex(Asc($aryChar[$i]), 2)
        Next
        Return $strHex
    ElseIf $encodeType = 0 Then;;Practical Encoding
        For $i = 1 To $aryChar[0]
            $iDec = Asc($aryChar[$i])
            if $iDec <= 32 Or $iDec = 37 Then
                $strHex = $strHex & "%" & Hex($iDec, 2)
            Else
                $strHex = $strHex & $aryChar[$i]
            EndIf
        Next
        Return $strHex
    ElseIf $encodeType = 2 Then;;RFC 1738 Encoding
        For $i = 1 To $aryChar[0]
            If Not StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", $aryChar[$i]) Then
                $strHex = $strHex & "%" & Hex(Asc($aryChar[$i]), 2)
            Else
                $strHex = $strHex & $aryChar[$i]
            EndIf
        Next
        Return $strHex
    EndIf
EndFunc
;===============================================================================
; _URLDecode()
; Description:      : Tranlates a URL-friendly string to a normal string
; Parameter(s):     : $toDecode - The URL-friendly string to decode
; Return Value(s):  : The URL decoded string
; Author(s):        : nfwu
; Note(s):          : Don't mess with the $mode parameter unless you know what 
;                    you are doing!!!
;
;===============================================================================
Func _URLDecode($toDecode, $mode=0)
    local $strChar = "", $iOne, $iTwo
    Local $aryHex = StringSplit($toDecode, "")
    For $i = 1 to $aryHex[0]
        If $aryHex[$i] = "%" Then
            $i = $i + 1
            $iOne = $aryHex[$i]
            $i = $i + 1
            $iTwo = $aryHex[$i]
            $strChar = $strChar & Chr(Dec($iOne & $iTwo))
        Else
            $strChar = $strChar & $aryHex[$i]
        EndIf
    Next
    if $mode = 0 Then
        Return StringReplace($strChar, "+", " ")
    Else
        Return $strChar
    EndIf
EndFunc

Oh, I added html and htm to the $filetypes array.

Ideally, the script should parse html file for a content type before make another determination of its type.

Hope it helps,

Steve

Posted

very nice script.... :)

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Posted

Update! v0.4

----------------

Tweeked 'Direct Server Output' functionality a little.

Added some of eltorro's code.

Added a tutorial for the DSO interface and added a very simple demo game server DSO. See under the /DSO/ directory.

#)

Posted

Update! v0.4

----------------

Tweeked 'Direct Server Output' functionality a little.

Added some of eltorro's code.

Added a tutorial for the DSO interface and added a very simple demo game server DSO. See under the /DSO/ directory.

#)

Thanks for the update... :)

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Posted

No problem! Any suggestions for improvement?

#)

I did some modification on your script :

#cs
GET /i.html HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR 2.0.50727)
Host: 127.0.0.1
Connection: Keep-Alive
#ce
#cs From: http://www.autoitscript.com/forum/index.php?s=&showtopic=19696&view=findpost&p=136138
    GET request format:
    http://<url>?<name_of_input>=<data>&<name_of_input2>=<data>
#ce
#include <Array.au3>
#include <INet.au3>
#include <File.au3>
;;#include "DSO.au3"
#include "RSUDF.au3"

Global $filetypes = _ArrayCreateVals("html","text/html","htm","text/html","gif", "image/gif", "bmp", "image/x-xbitmap", "jpg", "image/jpeg", "jpeg", "image/jpeg", "jpe", "image/jpeg", "ppt", "application/vnd.ms-powerpoint", "xls", "application/vnd.ms-excel", "doc", "application/msword", "swf", "application/x-shockwave-flash")
Global $newsession = 1
Global $listen
Global $sock
Global $serverName[100]
Global $serverPids[100]
Global $serverSPtr = 0
Global $recv
Global $DSO_FORCE_MIME = ""
Global Const $IP = InputBox( "Wood's General Server", "Input IP address:", _GetIP() )
Global Const $PORT = 80

Global Const $E404 = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80"><title>%IP%:%PORT% - Error 404 - File %REQUEST% not found.</title>'& _
                '</head><body bgcolor="#FFFFFF"><h1>Wood'&"'"&'s Technologies General Purpose Server</h1><h2>Error 404: File %REQUEST% not found</h2>'& _
                '<p>The server which you are requesting the file&quot;%REQUEST%&quot; from cannot find the file.</p><hr><address>Wood'& _
                "'"&'s Technologies General Server (0.4), IP: %IP%, PORT:%PORT% (%_MDAY%/%_MON%/%_YEAR% %_HOUR%:%_MIN%:%_SEC%)</address></body></html>'

TCPStartup()

$listen = TCPListen($IP, $PORT, 100)
If $listen = -1 Then
    $err = @error
    MsgBox(16, "Error", "Unable to connect." & @CRLF & @CRLF & "dec: " & $err & @CRLF & "hex: 0x" & Hex($err, 8))
EndIf


While 1
    $sock = TCPAccept($listen)                        ;;Poll the socket for commands
    If $sock >= 0 Then
        
        $recv = _SockRecv($sock)                        ;;Get Command from socket
        _DSO_Referer($recv)                          ;;Do some DSO related stuff
        $recv = StringSplit($recv, " ")              ;;Split up the Command
        $recvRequest = StringSplit($recv[2], "?")      ;;Split up the Request
        
        If StringInStr($recv[2], "woodserverexeoutput=") Then 
        ;$html = _VarsInterpret(_Server_Execute($recvRequest[2]))   ;;Server-Related Command (not yet implemented)
            $html = "Sorry, WSE not yet implemented. Please intergrate your application into the server. Refer to DSO.txt"
        ElseIf StringInStr($recv[2], "directserveroutput=") Then
            $html = _VarsInterpret(_DirectServerOutput($recvRequest[2], _URLDecode($recvRequest[1])));;'DSO'-Related Command
        Else
            $html = _Get(_URLDecode($recvRequest[1]))   ;;Normal file request
        EndIf
        $mime = _GetFileType(_URLDecode($recvRequest[1]))
        If $DSO_FORCE_MIME <> "" Then
            $mime = $DSO_FORCE_MIME
            $DSO_FORCE_MIME = ""
        EndIf
        $send = _SockSend($sock, _GetHeader($mime) & $html);;Send the data
    EndIf
    TCPCloseSocket($sock)
Wend
Exit


;;;;Functions

;;Get Functions

;Gets the document header
FUNc _GetHeader($filetype="text/plain")
    Return 'HTTP/1.0 200 OK' & @CRLF & 'Content-Type: ' & $filetype & @CRLF & @CRLF
EndFunc
;Gets the filetype for the header using the extention
Func _GetFileType($ext)
    For $i = 0 to UBound($filetypes)-1 Step 2
        If StringInStr($ext, $filetypes[$i]) Then Return $filetypes[$i+1]
    Next
    Return "text/plain"
EndFunc
;Get a file normally
Func _GET($filename)
;;Default to index.html
    If $filename = "/" or $filename = "\" or $filename = "" Then $filename = "\index.html"
    $file = @ScriptDir & "\" & $filename
    
;;If file does not exist, send an error 404
    If Not FileExists($file) Then 
        If FileExists("ERROR_404.html") Then
            Return _GET("/ERROR_404.html")
        Else
            Return _VarsInterpret($E404)
        EndIf
    EndIf
    
;;Check for Unauthorized access
    If StringInStr(FileGetAttrib($file), "D") And IniRead(@ScriptDir & "\variables.ini", "Permissions", "folders", 0) = 0 THen Return _GET("/ERROR_401.html")
    If StringInStr($file, "..") And IniRead(@ScriptDir & "\variables.ini", "Permissions", "prevdir", 0) = 0 THen Return _GET("/ERROR_401.html")
    
;;Read the data from the file
    $data = FileRead($file, FileGetSize($file))
    
;;If html file, transalte %% macros
    if StringInStr(FileGetExt($file), "htm") Then $data = _VarsInterpret($data)
    
    Return $data
EndFunc

;;Sock Functions

;Recieve Data on a socket
Func _SockRecv( $iSocket, $iBytes = 2048 )
    Local $sData = ""
;;Loop Until you recieve data on the socket
    While $sData = ""
        $sData = TCPRecv($iSocket, $iBytes)
    Wend
;;Flash a MsgBox
    MsgBox(0,"",$sData,1)
;;Log the Command
    _FileWriteLog( @ScriptDir&"\log.txt", $sData )
    Return $sData
EndFunc

;Send Data on a socket
Func _SockSend( $iSocket, $sData )
    Return TCPSend($iSocket, $sData)
EndFunc

;;OnExit Function
Func OnAutoItExit()
    TCPCloseSocket($sock)
    TCPCloseSocket($listen)
    TCPShutdown()
    Exit
EndFunc

#cs The old code dump:
$send = _SockSend($sock, _GetHeader(_GetFileType(FileGetExt(_URLDecode($recv[2])))) & $html)
#ce




Global $DSO_REFERER = ""
Global $DSO_REFERER_ALLOW = 0
Func _DirectServerOutput($input, $file)
    $str = StringTrimLeft($input, StringLen("directserveroutput="))
    Switch $str
    Case 'of0'
        If StringInStr(FileGetAttrib(@ScriptDir&'/'&$file), "D") THen Return _DSO_Dir($file&'/')
        Return _Get($file)
    EndSwitch
EndFunc
Func _DSO_Dir($s_Path)
;$data = ''
;#CS
    $s_Mask = '*'
    Local $html = '<table border=1><caption>Directory Listing of '&_URLEncode($s_Path)&'</caption>'
    $html &= '<TR><TH>Name<TH>Ext<TH>Attrib<TH>Size<TH>Created On<TH>Modified On<TH>Accessed On<TH>Link'
    $h_Search = FileFindFirstFile(@ScriptDir & $s_Path & $s_Mask)
    $s_FileName = FileFindNextFile($h_Search)
    If Not @error Then
        While Not @error
            $s_FullName = $s_Path & $s_FileName
            $t_Created = FileGetTime(@ScriptDir & $s_FullName,1)
            $t_Modified = FileGetTime(@ScriptDir & $s_FullName,0)
            $t_Accessed = FileGetTime(@ScriptDir & $s_FullName,2)
            $i_ExtMarker = StringInStr($s_FileName,'.',0,-1)
            If $i_ExtMarker Then
                $html &= '<TR>'&'<TH>'&StringLeft($s_FileName, $i_ExtMarker - 1)&'<TH>'&StringMid($s_FileName, $i_ExtMarker + 1)
            Else
                $html &= '<TR>'&'<TH>'&$s_FileName&'<TH>'&''
            EndIf
            $html &= '<TH>'&FileGetAttrib(@ScriptDir & $s_FullName)&'<TH>'&FileGetSize(@ScriptDir & $s_FullName)&'<TH>'& _
                    $t_Created[0]&'/'&$t_Created[1]&'/'&$t_Created[2]&'  '&$t_Created[3]&':'&$t_Created[4]&':'&$t_Created[5]&'<TH>'&$t_Modified[0]&'/'&$t_Modified[1]&'/'&$t_Modified[2]&'  '&$t_Modified[3]&':'&$t_Modified[4]&':'&$t_Modified[5]&'<TH>'& _
                    $t_Accessed[0]&'/'&$t_Accessed[1]&'/'&$t_Accessed[2]&'  '&$t_Accessed[3]&':'&$t_Accessed[4]&':'&$t_Accessed[5]&'<TH>'&'<a href="http://%IP%'&$s_FullName&'?directserveroutput=of0">'& _
                    'Open</a>'
            $s_FileName = FileFindNextFile($h_Search)
        WEnd
    EndIf
    $html &= '</table>'
;#CE
;$PID = Run(@ComSpec & ' /c DIR "'&@ScriptDir&'\'&$s_Path&'"', '', @SW_HIDE, 2)
;Do
;   $data = $data & StdoutRead($PID)
;Until @error
;Return $data
    Return $html
EndFunc
Func _DSO_OpenFile($file)
    If Not FileExists($file) Then Return _GET("/ERROR_404.html")
    If StringInStr($file, "..") And IniRead(@ScriptDir & "\variables.ini", "Permissions", "prevdir", 0) = 0 THen Return _GET("/ERROR_401.html")
    If StringInStr(FileGetAttrib($file), "D") THen Return _DSO_Dir($file)
    $data = FileRead($file, FileGetSize($file))
    if StringInStr(FileGetExt($file), "htm") Then
        $data = _VarsInterpret($data)
    EndIf
    Return $data
EndFunc
Func _DSO_Referer($recv)
    $recvparams = StringSplit($recv, @CRLF)
    $DSO_REFERER = ''
    For $i = 1 to $recvparams[0]
        If StringLeft($recvparams[$i], StringLen("Referer: ")) == "Referer: " Then
            $DSO_REFERER = StringTrimLeft($recvparams[$i], StringLen("Referer: "))
        EndIf
    Next
EndFunc
Func _DSO_Login()
EndFunc
Func _DSO_ProcessString($proc)
;;Get Rid of Starting and Ending slashes
    $c = StringLeft($proc, 1)
    If $c = "\" or $c = "/" then $proc = StringTrimLeft($proc, 1)
    $c = StringRight($proc, 1)
    If $c = "\" or $c = "/" then $proc = StringTrimRight($proc, 1)
;;Get Rid of Double Slashes
    while StringInStr($proc, "//")
        StringReplace($proc, "//", "/")
    wend
    while StringInStr($proc, "\\")
        StringReplace($proc, "\\", "\")
    wend
    Return StringSplit($proc, "\/")
EndFunc
Func _DSO_SetMIMEType($mime)
    $DSO_FORCE_MIME = $mime
EndFunc

Screenshot:

Posted Image

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Posted

I did some modification on your script :

[... code cut ...]

Screenshot:

Posted Image

Thanks for that suggestion. I'll modify the directory browsing DSO with your suggestions when I add in CGI support.

I'll try checking out PHP and maybe add that in too.

#)

  • 3 weeks later...
Posted (edited)

Gues what. I could not get the CGI function to work with linux-style CGI scripts.

I mean those which are basically scripts with a

!#/usr/perl

or something like that attached to the front.

Works with executables though.

Updating now. When new update is released, (v1.0), it will have CGI support for compiled scripts (i.e. renamed exes), 3 seperate documentations for the user (user-friendly) and the programmer (non-user-friendly) and the DSO portion (n00b-programmer-friendly).

Also, I'll add Dhilip's modification to the of0 (File Browser) DSO.

Gonna add a Computer Control DSO.

Also going to modify the DSO functionality from this:

http://127.0.0.1/?directserveroutput=of0

to this:

http://127.0.0.1/dso:of0/

If there are any more suggestions, disagreement, bugs, etc, or any more ways to make it user friendly, please post here!

Hoping to complete this soon,

nfwu

#)

Edit (at the next day): Screwed up my private copy of the Webserver, gonna redo from scrach via the public copy.

Edited by nfwu
Posted

Will this overcome the 10 user connection in xp pro and 2000 IIS? Also does it support user authentication?

The reason I'm asking is I am currently writting a blog,email,game etc web server in autoit, but I am using IIS in win 2000 for the webs server part. I was actually on here for a file upload server script example, so that i could add users pics to thier profiles and forum/blog posts.

If ya wanna check out what Ive done so far checkout www.garageaction.com let me know what ya think, and if you'd like to maybe work together to develope both our projects into one. just an idea.

`Mitch

Posted

Will this overcome the 10 user connection in xp pro and 2000 IIS? Also does it support user authentication?

The reason I'm asking is I am currently writting a blog,email,game etc web server in autoit, but I am using IIS in win 2000 for the webs server part. I was actually on here for a file upload server script example, so that i could add users pics to thier profiles and forum/blog posts.

If ya wanna check out what Ive done so far checkout www.garageaction.com let me know what ya think, and if you'd like to maybe work together to develope both our projects into one. just an idea.

`Mitch

You can easily extend this server using DSO.

Refer to the README.txt file in the download for the WebServer.

#)

Posted

unable to connect:

dec: 10048

hex: 0x000027440

its after i very first start and input my ip =S

i've disabled my firewall, would my router be a problem?

Posted

Repaired Basic WebServer (actually a modded version of 0.2) to work with FireFox.

Added link to first post.

Adding of features to the full version not yet complete... Still working on it.

#)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...