aqua Posted October 29, 2008 Share Posted October 29, 2008 Hello,I have install Abyss Web server under Windows XP SP2, autoit V3 and AuCGI.exe like it was explain at the top of this discus..I have install an example script like colours.auw in htdocs.When i call my classic url : http://127.0.0.1/colours.auw there is an 500 http error !I don't known why !In my cgi.log, i have :CGI: [C:\AuCGI.exe colours.auw ] URI: /colours.auw Bad ExecutableIs there someone for any solution ?As you guess, i'm not speaking english/american very well.Thank. Link to comment Share on other sites More sharing options...
agenore Posted October 31, 2008 Share Posted October 31, 2008 your server is always down. how can I download AuCGI.exe ? thank Link to comment Share on other sites More sharing options...
NELyon Posted October 31, 2008 Share Posted October 31, 2008 Until TheGuy gets his server working again (If he ever does), you can use my mirror: http://kentonbomb.homelinux.net/AuCGI.exe Link to comment Share on other sites More sharing options...
hazed Posted December 8, 2008 Share Posted December 8, 2008 Can't find Web.au3...Can some one send me a link? Thx Link to comment Share on other sites More sharing options...
zaldwaik Posted December 8, 2008 Share Posted December 8, 2008 Could someone post a mirror for web.au3 please Link to comment Share on other sites More sharing options...
LastHopeLost Posted December 9, 2008 Share Posted December 9, 2008 I zipped up the web.au3, aucgi.au3, and aucgi.exe and posted them on my site. You can download them from:http://home.comcast.net/~gunbuster/AuCGI.zipBig thanks to TheGuy0000 for creating this and for getting a copy of the web.au3 to me last night.Enjoy! Link to comment Share on other sites More sharing options...
Chris86 Posted February 15, 2009 Share Posted February 15, 2009 U genius! I LOVE YAA! Link to comment Share on other sites More sharing options...
sheeva Posted February 23, 2009 Share Posted February 23, 2009 Hi,I have installed AUCgi using abyss web server. i have configured everything like descripted in the first post.but, absolutly nothing is working ! For me is a little bit confuse... i try a direct test like this : http://127.0.0.1/test.auw or test.au3 of even test.htm (where is a web page with <au3> script..when i look in my abyss log it's always the same message, BROKEN PIPE.So i have try to run aucgi from Dos console.he start to work but autoit.exe return me a message like "error line 0" "cant find c:\Document and setting\user\local setting\..blabla"so i think the autoit.exe can find the copy of script made bu aucgi.exe.I have already a web server running perfectly (abyss web server) and no problem to display web pages i made.So, can you explain me (step- by step) how i have to configure that. what kinf of script i have to made Thank's Link to comment Share on other sites More sharing options...
wraithdu Posted October 1, 2009 Share Posted October 1, 2009 (edited) Since I recently became interested in this, I've gathered info from the forum and updated Web.au3 and AuCGI.au3 to work with the current beta of AutoIt (3.3.1.1). I have it working with LightTPD based on ptrex's insturctions here:Webbased AU3 on LightTDThe biggest changes were to the ConsoleRead() and StdoutRead() functions, which work differently now. There are example scripts and instructions for setup in ptrex's post. The best part....I got POST working **snip** Edited October 2, 2009 by wraithdu Link to comment Share on other sites More sharing options...
wraithdu Posted October 1, 2009 Share Posted October 1, 2009 I updated the above post with a few small changes. I've added an inline() function to Web.au3 that operates like echo() but does not insert a newline. This is useful for inline dynamic variable replacements. I've also changed AuCGI so that it outputs prettier html source. It is now exactly like the original source, with clean replacements of the <?au3 ?> sections. No longer are there crazy long lines of html source. Might make it easier to debug if there are problems. Link to comment Share on other sites More sharing options...
wraithdu Posted October 2, 2009 Share Posted October 2, 2009 Another small performance tweak to AuCGI above. The StdoutRead($run) loops could peg the CPU at 100% if the webapp is in a blocked state, ie MsgBox(). Now, it sits at about 5-10%. It is definitely not adviseable to block the webapp with something like MsgBox(). Link to comment Share on other sites More sharing options...
wraithdu Posted October 2, 2009 Share Posted October 2, 2009 Updated AuCGI...again....fixing any Au3Check warnings, and tweaking the main loop to make sure we don't miss any script output on a really fast server. Before, there was a possibility the webapp could end before reaching the output loop on a really fast server. Now the loop is run at least once to read the buffer. This should also keep CPU usage to near 0% even if the script blocks with something like MsgBox(). Link to comment Share on other sites More sharing options...
JRowe Posted October 2, 2009 Share Posted October 2, 2009 Damn, wraithdu. The rate you're going, it better be making my coffee by tomorrow morning. Nice work! [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
wraithdu Posted October 2, 2009 Share Posted October 2, 2009 (edited) Hehe, thanks, I think it works really well now. It can even show incremental output in the browser and has practically 0 overhead. Try the current version with this test script: #!C:\LightTPD\au3\AuCGI.exe ##WebApp <html><body> <form action="<?au3 inline(@ScriptName) ?>" method="POST"><button name="go" value="go">GO!</button> <button>Reset</button> <br /><br /> <?au3 If _POST("go") Then For $i = 1 to 10 echol($i) sleep(500) Next echol("<br /><br />DONE!") EndIf ?> </body></html> Neat, huh? Edited October 2, 2009 by wraithdu Link to comment Share on other sites More sharing options...
wraithdu Posted October 2, 2009 Share Posted October 2, 2009 (edited) I think I've made my last tweak to AuCGI and fixed all Au3Check warnings in Web.au3, so I'm moving it all down here. It's tested and working with multipart form POST data as well.Follow directions for LightTPD by ptrex here: Webbased AU3 on LightTPDAuCGIexpandcollapse popup;-------------------------------------------------------------- ; AuCGI CGI Handler for AutoIt ; by Matt Roth (theguy0000) <theguy0000@gmail.com> ; updated by Erik Pilsits (wraithdu) ; ; Version 1.2.0.1 ; January 28, 2010 ;-------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Res_Fileversion=1.2.0.1 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #NoTrayIcon #Region start If $CmdLine[0] < 1 Then error("what are you trying to do???") Global $sourcescript = $CmdLine[1] If Not FileExists($sourcescript) Then error("something weird just happened...tell theguy0000 (Line 13 file " & $sourcescript & ")") Global $version = "1.2.0.1" Global $error = "" #EndRegion start #Region set environment variables EnvSet("AUCGI_VERS", $version) Global $ContentLength = Number(EnvGet("CONTENT_LENGTH")) EnvSet("CONTENT_LENGTH", String($ContentLength)) EnvSet("QUERY_STRING", EnvGet("QUERY_STRING")) EnvSet("HTTP_COOKIE", EnvGet("HTTP_COOKIE")) EnvSet("REMOTE_ADDR", EnvGet("REMOTE_ADDR")) EnvSet("HTTP_ACCEPT_LANGUAGE", EnvGet("HTTP_ACCEPT_LANGUAGE")) EnvSet("HTTP_HOST", EnvGet("HTTP_HOST")) EnvSet("HTTP_ACCEPT_CHARSET", EnvGet("HTTP_ACCEPT_CHARSET")) EnvSet("HTTP_USER_AGENT", EnvGet("HTTP_USER_AGENT")) EnvSet("SERVER_SOFTWARE", EnvGet("SERVER_SOFTWARE")) EnvSet("SERVER_NAME", EnvGet("SERVER_NAME")) EnvSet("SERVER_PROTOCOL", EnvGet("SERVER_PROTOCOL")) EnvSet("SERVER_PORT", EnvGet("SERVER_PORT")) EnvSet("SCRIPT_NAME", EnvGet("SCRIPT_NAME")) EnvSet("HTTPS", EnvGet("HTTPS")) EnvSet("DOCUMENT_ROOT", EnvGet("DOCUMENT_ROOT")) EnvSet("HTTP_REFERER", EnvGet("HTTP_REFERER")) EnvSet("PATH", EnvGet("PATH")) EnvSet("REMOTE_HOST", EnvGet("REMOTE_HOST")) EnvSet("REMOTE_PORT", EnvGet("REMOTE_PORT")) EnvSet("REMOTE_USER", EnvGet("REMOTE_USER")) EnvSet("REQUEST_METHOD", EnvGet("REQUEST_METHOD")) EnvSet("REQUEST_URI", EnvGet("REQUEST_URI")) EnvSet("SCRIPT_FILENAME", EnvGet("SCRIPT_FILENAME")) EnvSet("SERVER_ADMIN", EnvGet("SERVER_ADMIN")) #EndRegion set environment variables #Region parse html and ##WebApp and stuff Global $newscriptpath Do $newscriptpath = "" While StringLen($newscriptpath) < 7 $newscriptpath &= Chr(Random(97, 122, 1)) WEnd $newscriptpath = @TempDir & "\AUCGI\~" & $newscriptpath & ".tmp" Until Not FileExists($newscriptpath) Global $source = FileRead($sourcescript) If StringLeft($source, 2) = "#!" Then $source = StringTrimLeft($source, StringInStr($source, @CRLF) + 1) If StringLeft($source, 8) <> "##WebApp" Then error("no ##WebApp definition") Global $number = StringInStr($source, @CRLF) - 1 Global $webdef = StringLeft($source, $number) $source = StringTrimLeft($source, $number + 2) Global $title_pos = StringInStr($webdef, "title=") Global $title, $bleh_title, $title1, $title2 If Not $title_pos Then $title = "" Else $bleh_title = StringRight($webdef, StringLen($webdef) - $title_pos) $title1 = StringInStr($bleh_title, '"') $title2 = StringInStr($bleh_title, '"', 0, 2) $title = StringMid($bleh_title, $title1 + 1, ($title2 - $title1) - 1) EndIf Global $cookie, $bleh_cookie, $cookie1, $cookie2 Global $cookie_pos = StringInStr($webdef, "cookie=") If Not $cookie_pos Then $cookie = "" Else $bleh_cookie = StringRight($webdef, StringLen($webdef) - $cookie_pos) $cookie1 = StringInStr($bleh_cookie, '"') $cookie2 = StringInStr($bleh_cookie, '"', 0, 2) $cookie = StringMid($bleh_cookie, $cookie1 + 1, ($cookie2 - $cookie1) - 1) EndIf Global $content_type, $bleh_content_type, $content_type1, $content_type2 Global $content_type_pos = StringInStr($webdef, "content-type=") If Not $content_type_pos Then $content_type = "text/html" Else $bleh_content_type = StringRight($webdef, StringLen($webdef) - $content_type_pos) $content_type1 = StringInStr($bleh_content_type, '"') $content_type2 = StringInStr($bleh_content_type, '"', 0, 2) $content_type = StringMid($bleh_content_type, $content_type1 + 1, ($content_type2 - $content_type1) - 1) EndIf $source = "#include <Web.au3>" & @CRLF & "Global $AuCGI_version = '" & $version & "'?>" & $source & "<?au3" Global $html = _StringBetween($source, '?>', '<?au3') For $i = 0 To UBound($html) - 1 If $html[$i] = "" Then ContinueLoop $html[$i] = StringRegExpReplace($html[$i], "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)", "\\$1") $source = StringRegExpReplace($source, "\?>" & $html[$i] & "<\?au3", @CRLF & 'inline("' & StringRegExpReplace(StringRegExpReplace($html[$i], '"', '""'), @CRLF, '" & @CRLF & "') & '")' & @CRLF) Next $source = StringRegExpReplace($source, "\?><\?au3", "") ; if original source ended with au3 script, we need to remove this last segment $source = '_StartWebApp("' & $title & '", "' & $cookie & '", "' & $content_type & '")' & @CRLF & $source #EndRegion parse html and ##WebApp and stuff #Region do stuff ;in case you haven't noticed, i like to get in the habit of putting everything into regions. ;copy to the script that will be executed, echo's and all. Global $file = FileOpen($newscriptpath, 2 + 8) ; overwrite + create dir structure FileWrite($file, $source) FileClose($file) ;find and run AutoIt Global $RegKey = "HKLM\SOFTWARE\AutoIt v3\AutoIt" If @AutoItX64 Then $RegKey = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt" Global $AutoItDir = RegRead($RegKey, "InstallDir") Global $AutoItExe = "AutoIt3.exe" ; uncomment the next line if you want to run the webapp as native x64 ;~ If @OSArch <> "X86" Then $AutoItExe = "AutoIt3_x64.exe" $AutoItExe = $AutoItDir & "\" & $AutoItExe If @error Or Not FileExists($AutoItExe) Then error("Could not locate AutoIt executable.") Global $run = Run('"' & $AutoItExe & '" "' & $newscriptpath & '"', "", Default, 3) ; STDIN/OUT ProcessWait($run) ; give post data to AutoIt3.exe If $ContentLength Then Global $post = "", $timer = TimerInit() While StringLen($post) < $ContentLength $post &= ConsoleRead() If TimerDiff($timer) > 5000 Then ExitLoop ; 5 second timeout WEnd StdinWrite($run, $post) EndIf ; give auw script output to server ; run loop at least once, even if process has already exited ; seems to work better this way on very fast servers Global $out = "" Do While 1 $out = StdoutRead($run) If @extended Or @error Then ExitLoop Sleep(10) WEnd If $out Then ConsoleWrite($out) $out = "" Until (Not ProcessExists($run)) ; one final buffer check $out = StdoutRead($run) If @extended Then ConsoleWrite($out) StdioClose($run) ; delete temp script FileDelete($newscriptpath) #EndRegion do stuff #Region UDFs Func error($str) ConsoleWrite($str) ;~ MsgBox(0, "AuCGI error", $str) Exit EndFunc ;==>error Func _StringBetween($s_String, $s_Start, $s_End, $v_Case = -1) ; Set case type Local $s_case = "" If $v_Case = Default Or $v_Case = -1 Then $s_case = "(?i)" ; Escape characters Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)" $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1") $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1") ; If you want data from beginning then replace blank start with beginning of string If $s_Start = "" Then $s_Start = "\A" ; If you want data from a start to an end then replace blank with end of string If $s_End = "" Then $s_End = "\z" Local $a_ret = StringRegExp($s_String, "(?s)" & $s_case & $s_Start & "(.*?)" & $s_End, 3) If @error Then Return SetError(1, 0, 0) Return $a_ret EndFunc ;==>_StringBetween ;~ Func _StringBetween($sString, $sStart, $sEnd, $vCase = -1, $iSRE = -1) ;~ If $iSRE = -1 Or $iSRE = Default Then ;~ If $vCase = -1 Or $vCase = Default Then ;~ $vCase = 0 ;~ Else ;~ $vCase = 1 ;~ EndIf ;~ Local $sHold = '', $sSnSStart = '', $sSnSEnd = '' ;~ While StringLen($sString) > 0 ;~ $sSnSStart = StringInStr($sString, $sStart, $vCase) ;~ If Not $sSnSStart Then ExitLoop ;~ $sString = StringTrimLeft($sString, ($sSnSStart + StringLen($sStart)) - 1) ;~ $sSnSEnd = StringInStr($sString, $sEnd, $vCase) ;~ If Not $sSnSEnd Then ExitLoop ;~ $sHold &= StringLeft($sString, $sSnSEnd - 1) & Chr(1) ;~ $sString = StringTrimLeft($sString, $sSnSEnd) ;~ WEnd ;~ If Not $sHold Then Return SetError(1, 0, 0) ;~ $sHold = StringSplit(StringTrimRight($sHold, 1), Chr(1)) ;~ Local $avArray[UBound($sHold) - 1] ;~ For $iCC = 1 To UBound($sHold) - 1 ;~ $avArray[$iCC - 1] = $sHold[$iCC] ;~ Next ;~ Return $avArray ;~ Else ;~ If $vCase = Default Or $vCase = -1 Then ;~ $vCase = '(?i)' ;~ Else ;~ $vCase = '' ;~ EndIf ;~ Local $aArray = StringRegExp($sString, '(?s)' & $vCase & $sStart & '(.*?)' & $sEnd, 3) ;~ If IsArray($aArray) Then Return $aArray ;~ Return SetError(1, 0, 0) ;~ EndIf ;~ EndFunc ;==>_StringBetween #EndRegion UDFs ;--------------------------------------------------------------------------------Web.au3expandcollapse popup#region start #include-once #include <Array.au3> Global $AuCGI_version = EnvGet ("AUCGI_VERS") Global $session = 0 Global $is_rss = False Global $_MULTIPART = False Global $PostContentLength = Number(EnvGet ("CONTENT_LENGTH")) Global $_POST_raw = "" If $PostContentLength > 0 Then Global $timer = TimerInit() While StringLen($_POST_raw) < $PostContentLength $_POST_raw &= ConsoleRead() If TimerDiff($timer) > 5000 Then ExitLoop ; 5 second timeout WEnd EndIf Global $_GET_raw = EnvGet("QUERY_STRING") Global $_Cookie_Raw = EnvGet("HTTP_COOKIE") #endregion #region useful vars Global $_REMOTE_ADDR = EnvGet ('REMOTE_ADDR') Global $_ACCEPT_LANGUAGE = EnvGet ('HTTP_ACCEPT_LANGUAGE') Global $_HOST = EnvGet ('HTTP_HOST') Global $_ACCEPT_CHARSET = EnvGet ('HTTP_ACCEPT_CHARSET') Global $_USER_AGENT = EnvGet ('HTTP_USER_AGENT') Global $_SERVER_SOFTWARE = EnvGet ('SERVER_SOFTWARE') Global $_SERVER_NAME = EnvGet ('SERVER_NAME') Global $_SERVER_PROTOCOL = EnvGet ('SERVER_PROTOCOL') Global $_SERVER_PORT = EnvGet ('SERVER_PORT') Global $_SCRIPT_NAME = EnvGet ('SCRIPT_NAME') Global $_HTTPS = EnvGet ('HTTPS') Global $_DOCUMENT_ROOT = EnvGet('DOCUMENT_ROOT') ; The root directory of your server Global $_HTTP_REFERER = EnvGet('HTTP_REFERER') ; The URL of the page that called your program Global $_PATH = EnvGet('PATH') ; The system path your server is running under Global $_REMOTE_HOST = EnvGet('REMOTE_HOST') ; The hostname of the visitor (if your server has reverse-name-lookups on; otherwise this is the IP address again) Global $_REMOTE_PORT = EnvGet('REMOTE_PORT') ; The port the visitor is connected to on the web server Global $_REMOTE_USER = EnvGet('REMOTE_USER') ; The visitor's username (for .htaccess-protected pages) Global $_REQUEST_METHOD = EnvGet('REQUEST_METHOD') ; GET or POST Global $_REQUEST_URI = EnvGet('REQUEST_URI') ; The interpreted pathname of the requested document or CGI (relative to the document root) Global $_SCRIPT_FILENAME = EnvGet('SCRIPT_FILENAME') ; The full pathname of the current CGI Global $_SERVER_ADMIN = EnvGet('SERVER_ADMIN') ; The email address for your server's webmaster #endregion #region funcs ;=============================================================================== ; ; Description: Sends the http header to the browser for web-based applications. ; Parameter(s): $sTitle - The title of the web page to start. ; $sCookie - If you want to specify a cookie, do it here. ; Use the format name=value. "" by default. ; $sContent_type - lets you specify a different content type ; other than text/html. ; Requirement(s): None ; Return Value(s): On Success - 0 ; On Failure - 0 and Set @error to 1 if unable to ConsoleWrite ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): Must go at the top of all web-based applications. ; ;=============================================================================== Func _StartWebApp ($sTitle="", $sCookie = "", $sContent_type="text/html") Local $error = 0 if $sCookie <> "" then ConsoleWrite("Content-Type: "&$sContent_type & Chr(13) & Chr(10) & "Set-Cookie: " & $sCookie & Chr(13) & Chr(10) & Chr(13) & Chr(10)) If @error then $error = 1 else ConsoleWrite("Content-Type: "&$sContent_type & Chr(13) & Chr(10) & Chr(13) & Chr(10)) If @error then $error = 1 endif If $sTitle <> "" Then ConsoleWrite("<html><head><title>"&$sTitle&"</title></head><body bgcolor=#FAFAFA>") If @error then $error = 1 SetError ($error) Return 0 EndFunc ;=============================================================================== ; ; Description: Sends text to be displayed in the web browser. ; Parameter(s): $sText - The text to display. ; Requirement(s): None ; Return Value(s): On Success - 0 ; On Failure - 0 and Set @error to 1 if unable to ConsoleWrite ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): The text can include html. ; ;=============================================================================== Func echo($sText, $sTag="") Local $error Local $tagsplit = StringSplit ($sTag, " ") If $sTag <> "" Then ConsoleWrite("<"&$sTag&">"&$sText&"</"&$tagsplit[1]&">" & @crlf) Else ConsoleWrite ($sText & @crlf) EndIf If @error then $error = 1 SetError ($error) Return 0 EndFunc Func echol($sText, $sTag="") Local $error Local $tagsplit = StringSplit ($sTag, " ") If $sTag <> "" Then ConsoleWrite("<"&$sTag&">"&$sText&"</"&$tagsplit[1]&"><br />" & @crlf) Else ConsoleWrite ($sText&"<br />" & @crlf) EndIf If @error then $error = 1 SetError ($error) Return 0 EndFunc Func inline($sText, $sTag="") Local $error Local $tagsplit = StringSplit ($sTag, " ") If $sTag <> "" Then ConsoleWrite("<"&$sTag&">"&$sText&"</"&$tagsplit[1]&">") Else ConsoleWrite ($sText) EndIf If @error then $error = 1 SetError ($error) Return 0 EndFunc ;=============================================================================== ; ; Description: Gets the value of a POST variable sent to the page. ; Parameter(s): $sVar - The name of the variable to retrieve ; Requirement(s): None ; Return Value(s): On Success - The value of the requested variable. ; On Failure - "" if the requested variable doesn't exist. ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _Post($sVar) Local $varstring, $num, $vars, $var_array $varstring = $_POST_raw If Not StringInStr($varstring, $sVar&"=") Then Return "" $num = __StringFindOccurances($varstring, "=") Local $vars[$num+1] $vars = StringSplit ($varstring, "&") For $i=1 To $vars[0] $var_array = StringSplit ($vars[$i], "=") If $var_array[0] < 2 Then Return "error" If $var_array[1] = $sVar Then Return _URLDecode($var_array[2]) Next Return "" EndFunc ;=============================================================================== ; ; Description: Gets the value of a GET variable sent to the page. ; Parameter(s): $sVar - The name of the variable to retrieve ; Requirement(s): None ; Return Value(s): On Success - The value of the requested variable. (or returns True. see notes) ; On Failure - "" if the requested variable doesn't exist. ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): If $iVarType is 1, it uses variables without values, like script.auw?myvar ; then you could use _Get("myvar", 1) and it would return true. ; ;=============================================================================== Func _Get($sVar, $iVarType=0) Local $varstring, $num, $vars, $var_array $varstring = $_GET_raw If Not StringInStr($varstring, $sVar&"=") Then Return "" $num = __StringFindOccurances($varstring, "=") Local $vars[$num+1] $vars = StringSplit ($varstring, "&") For $i=1 To $vars[0] If $iVarType Then If $vars[$i] = $sVar Then Return True Else $var_array = StringSplit ($vars[$i], "=") If $var_array[0] < 2 Then Return "error" If $var_array[1] = $sVar Then Return _URLDecode($var_array[2]) EndIf Next If $iVarType Then Return False Return True EndFunc ;=============================================================================== ; ; Description: Gets the value of a cookie. ; Parameter(s): $sVar - The name of the variable to retrieve ; Requirement(s): None ; Return Value(s): On Success - The value of the requested cookie. ; On Failure - "" if the requested cookie doesn't exist. ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _Cookie($sVar) Local $varstring, $num, $vars, $var_array $varstring = $_Cookie_Raw If Not StringInStr($varstring, $sVar&"=") Then Return "" $num = __StringFindOccurances($varstring, "=") Local $vars[$num+1] $vars = StringSplit ($varstring, "&") For $i=1 To $vars[0] $var_array = StringSplit ($vars[$i], "=") If $var_array[0] < 2 Then Return "error" If $var_array[1] = $sVar Then Return $var_array[2] Next Return "" EndFunc ;=============================================================================== ; ; Description: Gets a file that was submitted form, or the value of an input ; in a multipart form. ; Parameter(s): $sVar - The name of the input where the file was ; submitted. ; Requirement(s): None ; Return Value(s): On Success - ; IF THE REQUESTED VARIABLE IS A FILE: ; An array: ; [0] - Name of the file - example: hello.txt ; [1] - Content type of the retrieved file - Example: text/plain ; [2] - Contents of the file. ; IF THE REQUESTED VARIABLE IS NOT A FILE: ; Value of the variable ; On Failure - 0 ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _PostMultipart ($sVar) Local $ret[3], $temp_split, $name_pos, $name, $quote_pos, $pos Local $split = StringSplit ($_POST_raw, "-----------------------------", 1) For $i = 1 To $split[0] $temp_split = StringSplit ($split[$i], @CRLF, 1) If $temp_split[0] < 4 Then ContinueLoop ;~ _ArrayDisplay ($temp_split, "") _ArrayDelete ($temp_split, 0) ;~ _ArrayDisplay ($temp_split, "") If StringInStr ($temp_split[1], '; filename="') Then $name_pos = StringInStr ($temp_split[1], '; name="') $name = StringRight ($temp_split[1], StringLen($temp_split[1])-($name_pos+7)) $quote_pos = StringInStr ($name, '"') $name = StringLeft ($name, (StringLen($name)-(StringLen($name)-$quote_pos))-1) ;~ MsgBox (0, "", $name) If $name <> $sVar Then ContinueLoop $pos = StringInStr ($temp_split[1], '; filename="') $ret[0] = StringRight ($temp_split[1], StringLen($temp_split[1])-($pos+11)) $ret[0] = StringTrimRight ($ret[0], 1) _ArrayDelete ($temp_split, 1) $ret[1] = StringRight($temp_split[1], StringLen($temp_split[1])-14) _ArrayDelete ($temp_split, 1) _ArrayDelete ($temp_split, 1) _ArrayDelete ($temp_split, 0) _ArrayDelete ($temp_split, UBound($temp_split)-1) $ret[2] = _ArrayToString($temp_split, @CRLF) ;~ _ArrayDisplay ($temp_split, "") Return $ret Else $name_pos = StringInStr ($temp_split[1], '; name="') $name = StringRight ($temp_split[1], StringLen($temp_split[1])-($name_pos+7)) $quote_pos = StringInStr ($name, '"') $name = StringLeft ($name, (StringLen($name)-(StringLen($name)-$quote_pos))-1) ;~ MsgBox (0, "", $name) If $name <> $sVar Then ContinueLoop Return $temp_split[3] EndIf Next Return 0 EndFunc ;=============================================================================== ; ; Description: echo's a string telling the user their visitor number. ; Parameter(s): $sCounterMsg - The text to be echo'd. % will be replaced ; with the visitor number. ; $sCounter - Optional path to the file where the visitor ; number will be stored/retrieved. ; Requirement(s): None ; Return Value(s): On Success - the visitor number ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _WebCounter($sCounterMsg='You are Visitor Number % to this page', $sCounter='') If $sCounter = '' Then $sCounter = "C:\count_"&$_SCRIPT_NAME&".txt" If Not FileExists ($sCounter) Then FileWriteLine ($sCounter, 0) Local $i Local $line = FileRead($sCounter) Local $ending $i = $line + $i If $i = 1 Then $ending = "st" ElseIf $i = 2 Then $ending = "nd" ElseIf $i = 3 Then $ending = "rd" Else $ending = "th" EndIf echo (StringReplace (StringReplace($sCounterMsg,"!",$ending), "%", $i)) FileDelete($sCounter) FileWriteLine($sCounter,$i) Return $i EndFunc Func __StringFindOccurances($sStr1, $sStr2) ; NOT BY ME For $i = 1 to StringLen($sStr1) If not StringInStr($sStr1, $sStr2, 1, $i) Then ExitLoop Next Return $i EndFunc ;=============================================================================== ; ; Description: Displays a message box on the user's computer. ; Parameter(s): $sCounterMsg - The text to be echo'd. % will be replaced ; with the visitor number. ; $sCounter - Optional path to the file where the visitor ; number will be stored/retrieved. ; Requirement(s): Javascript enabled on the user's browser ; Return Value(s): On Success - the visitor number ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _MsgBox($sText) echo('<script language="javascript" type="text/javascript">') echo('alert("'& $sText &'")') echo("</script>") EndFunc ;=============================================================================== ; ; Description: optionally echo's a string of text then exits the script. ; Parameter(s): $sText - The optional text to be echo'd before exiting. ; Requirement(s): None ; Return Value(s): 0 ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func die ($sText="") echo ($sText) Exit EndFunc ;=============================================================================== ; ; Description: Sends the http header to the browser with session variables enabled. ; Parameter(s): $sTitle - The title of the web page to start. ; $sContent_type - lets you specify a different content type ; other than text/html. ; Requirement(s): Javascript enabled on the user's browser ; Return Value(s): 0 ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): If you want to use session variables, you should use this instead ; of _StartWebApp ; ;=============================================================================== Func _StartWebApp_Session ($sTitle="", $sContent_type="text/html") $session = 1 If _GetSID()>11110 Then ConsoleWrite("Content-Type: " & $sContent_type & Chr(13) & Chr(10) & "Set-Cookie: sid="&_GenerateSID() & Chr(13) & Chr(10) & Chr(13) & Chr(10)) If $sTitle <> "" Then ConsoleWrite("<html><head><title>"&$sTitle&"</title></head><body>") $_Cookie_Raw = EnvGet ("HTTP_COOKIE") Else _StartWebApp ($sTitle) EndIf EndFunc Func _GenerateSID () Local $ret Do $ret = Random (11111, 99999, 1) Until IniRead ("sessions.ini", "list", $ret, "no") = "no" IniWrite ("sessions.ini", "list", $ret, "yes") Return $ret EndFunc ;=============================================================================== ; ; Description: gets the current user's Session ID. ; Parameter(s): None ; Requirement(s): None ; Return Value(s): On Success - The user's SID ; On Failure - "" ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _GetSID ( ) Return _Cookie ("sid") EndFunc ;=============================================================================== ; ; Description: Sets a session variable ; Parameter(s): $sName - The name of the variable to set ; $sValue - The value of the new variable. ; Requirement(s): _StartWebApp_Session at the beginning of the script ; Return Value(s): On Success - 1 ; On Failure - 0 If the ini file is read-only or sessions aren't enabled. ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _Session_set ($sName, $sValue) If Not $session Then Return 0 Return IniWrite ("sessions.ini", _GetSID (), $sName, $sValue) EndFunc ;=============================================================================== ; ; Description: gets the value of a session variable. ; Parameter(s): $sName - the name of the variable to retrieve. ; Requirement(s): _StartWebApp_Session at the beginning of the script ; Return Value(s): On Success - The value of ; On Failure - "" ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _Session ($sName) If Not $session Then Return 0 Return IniRead ("sessions.ini", _GetSID(), $sName, "") EndFunc ;=============================================================================== ; ; Description: Create an ActiveX Object for use later. ; Parameter(s): $sObj - the object to create, for example, SAPI.SpVoice ; $sObjName - could be anything to identify it to you, but must ; adhere to the following standards ; -they cannot be any of the words found here: http://www.javascriptkit.com/jsref/reserved.shtml ; -they are case sensitive ; -they can begin with a letter or underscore, NOT a numeral ; -no spaces... ; Requirement(s): _StartWebApp_Session at the beginning of the script ; Return Value(s): On Success - The value of ; On Failure - "" ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): Does not work if javascript is not enabled, and even if it is, ; security settings sometimes stop it. ; ;=============================================================================== Func WebObjCreate($sObj, $sObjName) Local $out='<script language="javascript" type="text/javascript">'&@CRLF $out &= 'var '&$sObjName&' = ActiveXObj ('&$sObj&');'&@crlf $out &= '</script>'&@CRLF echo ($out) return $out EndFunc ;=============================================================================== ; ; Description: starts a web page that will be used as an RSS Feed. ; Parameter(s): $sTitle - The name of the channel. It's how people refer to ; your service. If you have an HTML website that ; contains the same information as your RSS file, the ; title of your channel should be the same as the title ; of your website. ; $sLink - The URL to the HTML website corresponding to the channel. ; $sDescription - Phrase or sentence describing the channel. ; $sLanguage - [optional] the language your RSS feed is in. Default is en-us. Set as an empty string to omit. ; $sCopyright - [optional] Copyright notice for content in the channel. Default is a blank string ; $sEditor - [optional] Email address for person responsible for editorial content. Default is a blank string. ; $sMaster - [optional] Email address for person responsible for technical issues relating to channel. ; Requirement(s): None. ; Return Value(s): On Success - True ; On Failure - False ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): If you use this, do not use _StartWebApp () or _StartWebApp_Session () ; ;=============================================================================== Func _StartRssFeed ($sTitle, $sLink, $sDescription, $sLanguage="en-us", $sCopyright="", $sEditor="", $sMaster="") $is_rss = True _StartWebApp () If @error Then Return SetError (1, @error, False) echo ('<?xml version="1.0"?>') If @error Then Return SetError (2, @error, False) echo ('<rss version="2.0">') If @error Then Return SetError (3, @error, False) echo ('<channel>') If @error Then Return SetError (4, @error, False) echo ('<title>'&$sTitle&'</title>') If @error Then Return SetError (5, @error, False) echo ('<link>'&$sLink&'</link>') If @error Then Return SetError (6, @error, False) echo ('<description>'&$sDescription&'</description>') If @error Then Return SetError (7, @error, False) If $sLanguage <> "" Then echo ('<language>'&$sLanguage&'</language>') If @error Then Return SetError (8, @error, False) If $sCopyright <> "" Then echo ('<copyright>'&$sCopyright&'</copyright>') If @error Then Return SetError (9, @error, False) If $sEditor <> "" Then echo ('<managingEditor>'&$sEditor&'</managingEditor>') If @error Then Return SetError (10, @error, False) If $sMaster <> "" Then echo ('<webMaster>'&$sMaster&'</webMaster>') If @error Then Return SetError (11, @error, False) echo ('<generator>AutoIt '&@AutoItVersion&'</generator>') If @error Then Return SetError (12, @error, False) echo ('<docs>http://validator.w3.org/feed/docs/rss2.html</docs>') If @error Then Return SetError (13, @error, False) Return True EndFunc ;=============================================================================== ; ; Description: Adds an Item to the current RSS Feed ; Parameter(s): $sTitle - The title of the item. ; $sDescription - The item synopsis. ; $sLink - [optional] The URL of the item. Leave blank to omit. ; $sAuthor - [optional] Email address of the author of the item. ; Leave blank to omit. ; $sCategory - [optional] Includes the item in one or more ; categories. Leave blank to omit. ; $sGuid - [optional] A string that uniquely identifies the item. ; There are no syntax rules. Leave blank to omit. ; $sPubDate - [optional] Indicates when the item was published. ; Leave blank to omit. Must be in the format: ; WWW, DD MMM YYYY HH:MM:SS GMT ; Example: ; Sun, 19 Aug 2002 15:21:36 GMT ; Requirement(s): _StartRssFeed () ; Return Value(s): On Success - True ; On Failure - False ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): None. ; ;=============================================================================== Func _RssAddItem ($sTitle, $sDescription, $sLink="", $sAuthor="", $sCategory="", $sGuid="", $sPubDate="") If Not $is_rss Then Return SetError( -1, "", False) echo ('<item>') If @error Then Return SetError (1, @error, False) echo ('<title>'&$sTitle&'</title>') If @error Then Return SetError (2, @error, False) echo ('<description>'&$sDescription&'</description>') If @error Then Return SetError (3, @error, False) If $sLink <> "" then echo ('<link>'&$sLink&'</link>') If @error Then Return SetError (4, @error, False) If $sAuthor <> "" then echo ('<author>'&$sAuthor&'</author>') If @error Then Return SetError (5, @error, False) If $sCategory <> "" then echo ('<category>'&$sCategory&'</category>') If @error Then Return SetError (6, @error, False) If $sGuid <> "" then echo ('<guid>'&$sGuid&'</guid>') If @error Then Return SetError (7, @error, False) If $sPubDate <> "" then echo ('<pubDate>'&$sPubDate&'</pubDate>') If @error Then Return SetError (8, @error, False) echo ('</item>') If @error Then Return SetError (9, @error, False) Return True EndFunc ;=============================================================================== ; ; Description: ends the RSS Feed ; Parameter(s): None. ; Requirement(s): None. ; Return Value(s): On Success - True ; On Failure - False ; Author(s): Matt Roth (theguy0000) <theguy0000@gmail.com> ; Note(s): This will exit the script. You cannot do anything else after using this function. ; ;=============================================================================== Func _EndRssFeed () If Not $is_rss Then Return SetError( -1, "", False) echo ('</channel>') If @error Then Return SetError (1, @error, False) echo ('</rss>') If @error Then Return SetError (2, @error, False) Return True EndFunc #endregion #region helper funcs ;=============================================================================== ; _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): : - ; ;=============================================================================== Func _URLDecode($toDecode) 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 Return StringReplace($strChar, "+", " ") EndFunc #endregion Edited March 4, 2010 by wraithdu Link to comment Share on other sites More sharing options...
sheeva Posted October 4, 2009 Share Posted October 4, 2009 Hi, I try & try & try again to make AuCGI running on abyss web server without any success. Can somebody tell me how to activate that ? I have follow all explanation on first post and nothing. i certainly miss something but the first post concerning Abyss web server is very clear. Pleease help ! Thank's Link to comment Share on other sites More sharing options...
joseLB Posted October 7, 2009 Share Posted October 7, 2009 Hi, do you have a link where we can see AuCGI working? Thans Jose Link to comment Share on other sites More sharing options...
wraithdu Posted October 8, 2009 Share Posted October 8, 2009 Not public, no. Follow the directions for setting it up on LightTPD in my post above, ptrex's post has examples, and there's an example posted a few pages back as well. It works. Link to comment Share on other sites More sharing options...
wraithdu Posted October 8, 2009 Share Posted October 8, 2009 Updated AuCGI above. The main HTML formatting is done with StringRegExpReplace now. Should be faster. Link to comment Share on other sites More sharing options...
ptrex Posted October 8, 2009 Share Posted October 8, 2009 @wraithdu Thanks for the update. Good to see you could get use of the "LightTPD". Rgds ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now