Jump to content

AutoIt CGI Handler: AuCGI


wraithdu
 Share

Recommended Posts

I've updated the Server Control app to v1.0.1.2. It's a bit more user friendly now.

@JRowe

Please update your server's copy as well if you wish to continue to maintain it there. Thanks!

Edited by wraithdu
Link to comment
Share on other sites

  • Replies 76
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • 2 weeks later...

Almost, anyway. He's saying that the test.web demo is missing it's closing </form> tag, lol. I'll fix the upload tonight.

Link to comment
Share on other sites

The post isn't to the temp script, if you recall, but to the page, which is parsed by the handler, and then converted into a temp script. The reference to the script/page name from the existing POSTs still work.

Link to comment
Share on other sites

  • 2 months later...

The server needs to support calling a CGI handler. I don't think Manadar's has this functionality.

In the old thread, someone posted a method to make this work with IIS (source file path is passed to the handler via environment variable instead of command line param). I hope to have that integrated soon.

Link to comment
Share on other sites

Thanks wraithdu. I just got the LightTPD and I want to test AUCGI with a simple example. I want to create a simple login form but I can't figure out how this work.

How I can get values from input boxes? And how can I redirect to a specific html file after I verify the user and the password?

<?au3
ConsoleWrite("Content-Type: text/html")
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>AuCGI Test</title>
</head>
<body>
<form name = "login" action="test.web" method="POST">
<center><br><br><br>
<input id="user" name="user" value="Username"><br><br>
<input id="pwd" name="pwd" value="password" type="password"><br><br>
<button name="submit" value="submit">Submit</button>
<?au3
    If _POST("submit") Then
        $LOGGED = FALSE
        $INDEX = 1
        $FILE = FileOpen("credentials.txt",0)
        WHILE TRUE
            $LINE = FileReadLine($FILE,$INDEX)
            If @error then ExitLoop
            $SPLIT = StringSplit($LINE,@TAB)
            If IsArray($SPLIT) Then
                IF $SPLIT[1] == '[username_value]' and $SPLIT[2] = '[password_value]' then
                    $LOGGED = TRUE
                    EXITLOOP
                ENDIF
            ENDIF
            $INDEX += 1
        WEND
        FileClose($FILE)
        IF $LOGGED THEN
            ConsoleWrite('<meta HTTP-EQUIV="REFRESH" content="0; url=correct.html">') ;maybe exists something more good
        else
            ConsoleWrite('<meta HTTP-EQUIV="REFRESH" content="0; url=incorrect.html">')
        endif
    EndIf
?>
</form>
</body></html>
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

First off, _POST works like _POST(<name>) returns <value>. The id is your own internal value. So, _POST("user") = "Username". This should get you started. Please note the changes to the first few lines and the form's 'action='

<?au3
#NoTrayIcon
_standardHeader()
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>AuCGI Test</title>
</head>
<body>
<form name = "login" action="<?au3 inline($_SCRIPT_NAME) ?>" method="POST">
<center><br><br><br>
<input id="user" name="user" value="Username"><br><br>
<input id="pwd" name="pwd" value="password" type="password"><br><br>
<button name="submit" value="submit">Submit</button>
<button>Reset</button>
<?au3
    If _POST("submit") Then
        echol("")
        echol("")
        echol("user: " & _POST("user"))
        echol("pass: " & _POST("pwd"))
    EndIf
?>
</form>
</body></html>

EDIT:

You can always do a echol($_POST_raw) to see exactly what POST data you're getting.

Edited by wraithdu
Link to comment
Share on other sites

Regarding your post here:

The new thread for this project is HERE. Me and JRowe have picked up development and I've coded a much improved version of AuCGI. Your changes for IIS support would be trivial to implement in the new codebase.

However it would be best if there was a way for AuCGI to tell, internally, if it was running under IIS or not. Do you know if that is possible? Then it wouldn't be necessary to maintain a separate version of AuCGI for IIS based servers.

There may very well be a method for determining what server is calling AuCGI. You seem quite interested in being able to run this on IIS (as I am, too!) so I'll grab the latest AuCGI and web.au3 code and roll up some changes or patches if you like. In the meantime, I'll investigate the options. I'll post back either in a couple hours or by Monday and let ya know! In the meantime if I get a chance, I'll keep this thread subscribed if you've got anything to add :P

Oh one more thing: It seems that passing serverside info to a CGI application is supposed to be done through environment variables, so it's likely that adding support for IIS/Apache/Tomcat/whatever will all be extensions of the same code base, FWIW.

Thanks again guys :blink:

__________

Update:

Here's a snippet of what IIS is passing to the CGI module:

SERVER_SOFTWARE: Microsoft-IIS/7.0 
 SERVER_NAME: drew-dc.drew.local 
 GATEWAY_INTERFACE: CGI/1.1 
 SERVER_PROTOCOL: HTTP/1.1 
 SERVER_PORT: 80 
 REQUEST_METHOD: GET 
 PATH_INFO: /AutoIt/test.auw 
 PATH_TRANSLATED: C:\inetpub\wwwroot\AutoIt\test.auw 
 SCRIPT_NAME: /AutoIt/test.auw 
 REMOTE_HOST: 192.168.1.61 
 REMOTE_ADDR: 192.168.1.61

Ironically, all of these variables seem to be declared in web.au3, so I'm going to have to read them an additional time in AuCGI if it detects IIS. If anyone has another suggestion though, I'd be welcome to it ;)

Should have a code snippet ready soon.

Edited by RulerOf
Link to comment
Share on other sites

After looking at AuCGI's environment after being called by LightTPD, I don't see the PATH_ variables. But can you tell me if you have SCRIPT_FILENAME and what the value is? Do you also maybe have DOCUMENT_ROOT?

I see a few options:

1) Check whether either PATH_TRANSLATED or SCRIPT_FILENAME exist and is a valid path

2) Use DOCUMENT_ROOT and SCRIPT_NAME to create the full path

Option 2 is better if possible. The correct full path to the script can then be set in the _envInit() function to the $_SCRIPT_FILENAME variable.

Edited by wraithdu
Link to comment
Share on other sites

Not to go out of topic, but I would ask if you know something about any firefox pluging, where you open a plain file.au3 like www.oneweb.com/file.au3 and this pluging could redirect/remap all Autoit Windows commands into similar legal web outputs, as by example msgbox(0,...) into javascript msgbox("")?

Thanks if you got some link about this Autoit-Reader (Web).

Saludos

Autoit.es - Foro Autoit en EspaƱol Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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