• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

How do you write a program to interact with a Cold Fusion page?

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
My employer just switched a new time logging system that uses Cold Fusion pages. It'd be cool if I could write a little script/program of some kind to automatically fill my time out for me. Writing a Visual Basic program that just sends keystrokes to the window is an option, but not a very good one. Can anyone point me to some web pages that explain how to do this the "right way"?

I'm running Windows 2000, btw.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
the fact that it is written in ColdFusion is not relevent you are still only able to communicate it through a web interface. All the coldfusion stuff is done server side out of your control. You best best for automating the process is to disect how the system works...ie does it user get or post variables and what are their names and what not...then you just have to send the right request to the right pages and automate the variables based on what you need.
 

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
Originally posted by: jonmullen
the fact that it is written in ColdFusion is not relevent you are still only able to communicate it through a web interface. All the coldfusion stuff is done server side out of your control. You best best for automating the process is to disect how the system works...ie does it user get or post variables and what are their names and what not...then you just have to send the right request to the right pages and automate the variables based on what you need.

How do I tell? I don't have access to the source code for the pages. And then how do I form a request to send to the right pages?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
such a program could be used for eeeevil so you might want to just keep doing it the hard way, if anyone else at work found out about your auto-timecard-puncher they might wonder if you've set it to run while you're not even in the building. Bosses can be paranoid about anything that looks like it could be used to cheat them :)
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
you dont have to have access to the coldfusion source code pages you just have to look at the HTML that your browser gets...to see that just right click and click view source. Each form should have a property of method that will either be set to post or get that will tell you what it is using. For a get variable it is as easy as requesting the page with the variable set as so:

page.cfm?variable=variablevalue

now if its a post variable you are going to have to read up on writting the HTML headers and learn about how to do it on your own specific for the language you are using to write you application. If you google it you shold find plenty of info.
 

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
Originally posted by: DaveSimmons
such a program could be used for eeeevil so you might want to just keep doing it the hard way, if anyone else at work found out about your auto-timecard-puncher they might wonder if you've set it to run while you're not even in the building. Bosses can be paranoid about anything that looks like it could be used to cheat them :)

Actually my boss is as annoyed with the new system as I am, so he said if I figured out how to do it to give him the program too. :D

What does "writing the HTML headers" mean? I'd just like to have a general framework in mind of what I need to do before I start googling.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
HTML headers are where the server and client talk to each other that is not visable when the web page is rendered in the browers. Some of the more important stuff that is passed in the headers are the User-Agent to tell what type of browser you are useing, the Referrer to tell from where the URI in the request was obtained. It is also where most authorization information is passed. It is also where POST variables are passed instead of in the URL as a query string like a GET variable.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Originally posted by: BingBongWongFooey
Actually, they're HTTP headers. :)

OMG I feel like an idiot...your right, and the sad thing is I knew that and ment that....its just like every time I typed it I meant HTTP but HTML came out...oh well, at least you knew what I ment.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: jonmullen
Originally posted by: BingBongWongFooey
Actually, they're HTTP headers. :)

OMG I feel like an idiot...your right, and the sad thing is I knew that and ment that....its just like every time I typed it I meant HTTP but HTML came out...oh well, at least you knew what I ment.

Suuuuuuuuuure.

;):p
 

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
Ok, so here's what I believe to be the relevant bits from the logon page:

<form action="login_process_ext.cfm?logon_check=0" name="login" method="post">

<input type="text" name="user_id" value="" maxlength=8 size=10 onFocus="select()" onBlur="trim_me(this)">
<input type="password" name="password" value="" maxlength=8 size=10 onFocus="select()" onBlur="trim_me(this)">
<input type="submit" name="action" value="Login">

So these are post variables, which means I need to read up on how to write HTTP headers, correct? Any good website suggestions? If I can do it with Visual Basic that would be ideal, but Sun Java is ok too.
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Take a look at Microsoft's XMLHTTP object for posting form variables over HTTP. In VB, it will look something like this:

Dim objXMLHTTP As New MSXML2.XMLHTTP

objXMLHTTP.async = False
objXMLHTTP.open "POST", "http://servername/login_process_ext.cfm?logon_check=0", False
objXMLHTTP.setRequestHeader "content-type", "application/x-www-form-urlencoded"
objXMLHTTP.send "user_id=myname&password=mypassword"

XMLHTTP is part of the MSXML Core Services package. The trick with interfacing with ColdFusion will be maintaining the session state. Sessions are tracked in ColdFusion using two variables: CFID and CFTOKEN. You will need to find the values for CFID and CFTOKEN in the response header of your login post and pass these in each subsequent post. You may also have to send cookie values in your HTTP header to remain "logged in."
 

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
OK, made a little progress. This code:

Dim x As New MSXML2.XMLHTTP
Open "C:\output.txt" for Output as #1

x.OPEN "POST", "https://website/login_process_ext.cfm?logon_check=0", False
x.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
x.send "user_id=user&password=password"

Print #1, x.getAllResponseHeaders
Print #1, "---------------------------------------"
Print #1, x.responseText

Set x = Nothing
Close #1

produces this output:

Server: Netscape-Enterprise/3.6 SP1
Date: Mon, 06 Oct 2003 19:24:46 GMT
Content-type: text/html
Page-completion-status: Normal
Page-completion-status: Normal
Set-cookie: SI=TSVIKCBVXToiTzFKLSYhTU5WLksjR1gyRjkkSUdMO1JdNigmUSRQTiJDOEE9QzhCPUI4PSJCUF43LiA%2BRQozVisrV0cuUzE%2BNFJKWThaJyNEU0BOWFcsNCAgIAo%3D; path=/; domain=domain.com; secure
Set-cookie: SNA=WUVT; path=/; domain=domain.com; secure
Set-cookie: SU=JzxKTVhZSkY8VkAgIAo%3D; path=/; domain=domain.com; secure

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

<html>
<head>
<title></title>
<meta http-equiv="REFRESH" content="0; url=menu.cfm?RequestTimeout=1000">
</head>
<body>
</body>
</html>

===================================

If I login normally, menu.cfm is the next page I'm taken to where I can navigate through the structure. I guess I need to set some cookies here, but I'm not sure how. getAllResponseHeaders doesn't seem to know about CFID and CFTOKEN, and setting SI, SNA, and SU with setRequestHeader doesn't produce the desired result.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
No your did it right...what that page does is just redirects you t menu.cfm after what looks like 1 second. Now you just need to find
the next form that you need to fill out for your process and do so...it looks like your getting the hang of it.