Sign in to follow this  
Followers 0
ttleser

PHP and AutoIT

13 posts in this topic

I've got a webcam at home what I'd like to control from work. The webcam I own is a Dlink DCS-5300, basically a LAN based webcam that you can control it to move around. Unfornuately I've got 2 things going wrong for me.

a. My home ISP doesn't allow you to host a webserver. (So I can't access the cam from work directly)

b. My work doesn't allow you to browse to any port other than 80 (http).

But I've got a few things going for me:

a. My wife's work (I'm the system administrator for) can host a webserver.

b. I've got a VPN connection from my home to my wife's work.

I've got the webcam setup to FTP images to my wife's webserver every 5 secs. I can view the images via a webpage from my work.

If I were home and I wanted to view the cam, I could browse to it's IP address. If I wanted to move it the camera, there are buttons on the page to move it up, down, right, left or "home" position. If I highlight the buttons, I figured out the URL to simply move the camera without going to it's homepage. The URL to move it down would look like: http://192.168.2.110/cgi-bin/camctrl.cgi?move=down

So, what I figured I could do it create a Autoit script that will create a IE window to move the cam a certain direction and then close the window out. I then created a PHP script that would use SHELL_EXEC to run the autoit script. Keep in mind this is just a test to see if I can make it work.

When I browse to the "down" webpage from work, it doesn't move the camera and in fact keeps IE running on the webserver. That IE process can't be closed, even under admin rights, unless I reboot the server.

Here's what I know.

1. I think the "down" php webpage is setup right, as I created a similiar one that simply pings the webserver. It works and sends the results back to my browser.

2. The autoitscript works not using it from the php script. I was at my wife's work and ran the autoitscript from the server directly and found that the cam had moved.

Here's the 2 scripts:

WebcamDown.exe

#include <IE.au3>
$oIE2 = _IECreate ("http://192.168.2.110/cgi-bin/camctrl.cgi?move=down", 1, 0, 1)
_IELoadWait ($oIE2)
_IEQuit ($oIE2)

Down.php

<?php
shell_exec('WebcamDown.exe');
?>

Sample Ping PHP script

<?php
$output = shell_exec('ping 127.0.0.1');
echo "<pre>$output</pre>";
//echo "$output";
?>

I'm at my work right now, so testing it limited. But I can ftp files to my wife's work's webserver, so I can upload files.

Share this post


Link to post
Share on other sites



I've got a webcam at home what I'd like to control from work. The webcam I own is a Dlink DCS-5300, basically a LAN based webcam that you can control it to move around. Unfornuately I've got 2 things going wrong for me.

a. My home ISP doesn't allow you to host a webserver. (So I can't access the cam from work directly)

b. My work doesn't allow you to browse to any port other than 80 (http).

But I've got a few things going for me:

a. My wife's work (I'm the system administrator for) can host a webserver.

b. I've got a VPN connection from my home to my wife's work.

I've got the webcam setup to FTP images to my wife's webserver every 5 secs. I can view the images via a webpage from my work.

If I were home and I wanted to view the cam, I could browse to it's IP address. If I wanted to move it the camera, there are buttons on the page to move it up, down, right, left or "home" position. If I highlight the buttons, I figured out the URL to simply move the camera without going to it's homepage. The URL to move it down would look like: http://192.168.2.110/cgi-bin/camctrl.cgi?move=down

I use a program called Proxifier. Also most home routers will let you do port forwarding/remapping.

When you say your company lets only port 80 keep in mind that it's probably not a open port but a proxy.

More details might help, hard to say, lots of variables here.

So, what I figured I could do it create a Autoit script that will create a IE window to move the cam a certain direction and then close the window out. I then created a PHP script that would use SHELL_EXEC to run the autoit script. Keep in mind this is just a test to see if I can make it work.

When I browse to the "down" webpage from work, it doesn't move the camera and in fact keeps IE running on the webserver. That IE process can't be closed, even under admin rights, unless I reboot the server.

Here's what I know.

1. I think the "down" php webpage is setup right, as I created a similiar one that simply pings the webserver. It works and sends the results back to my browser.

2. The autoitscript works not using it from the php script. I was at my wife's work and ran the autoitscript from the server directly and found that the cam had moved.

Here's the 2 scripts:

WebcamDown.exe

#include <IE.au3>
$oIE2 = _IECreate ("http://192.168.2.110/cgi-bin/camctrl.cgi?move=down", 1, 0, 1)
_IELoadWait ($oIE2)
_IEQuit ($oIE2)

Down.php

<?php
shell_exec('WebcamDown.exe');
?>

Sample Ping PHP script

<?php
$output = shell_exec('ping 127.0.0.1');
echo "<pre>$output</pre>";
//echo "$output";
?>

I'm at my work right now, so testing it limited. But I can ftp files to my wife's work's webserver, so I can upload files.


www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org

Share this post


Link to post
Share on other sites

Was there something you wanted to say Avery? I don't see anything in your post other than you quoting me.

Share this post


Link to post
Share on other sites

Was there something you wanted to say Avery? I don't see anything in your post other than you quoting me.

That is odd indeed. I had responded to your post and it similar to something I had done before. Somehow the post got ate :)

I will type it again once I get back from the store lol. Sorry about that.


www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org

Share this post


Link to post
Share on other sites

Bump.

Anyone?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

something with the ip... have you tried other ips?

198.162 is a private IP, so that may be the problem... I don't know though, the main point of this post is to say:

Avery did reply:

I use a program called Proxifier. Also most home routers will let you do port forwarding/remapping.

When you say your company lets only port 80 keep in mind that it's probably not a open port but a proxy.

More details might help, hard to say, lots of variables here.

its just hidden inside the quote.

MDiesel

Edit:

Microsoft Windows XP [Version 5.1.2600]

© Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Diesel Home\My Documents\My documents>ping 192.168.2.1

10

Pinging 192.168.2.110 with 32 bytes of data:

Request timed out.

Request timed out.

Request timed out.

Request timed out.

Ping statistics for 192.168.2.110:

Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Documents and Settings\Diesel Home\My Documents\My documents>

Edited by mdiesel

Share this post


Link to post
Share on other sites

Bump.

Anyone?

I'm interested to understand what you've done but so far I don't. From the first post I understand that the camera is on your home network and it's IP is 192.168.2.110. If you navigate to http://192.168.2.110/cgi-bin/camctrl.cgi?move=down then the camera moves down. I'm already lost at this point probably because I'm ignorant about VPNs.

Does having a VPN effectively mean you have a server on your PC which is why you can run camctrl.cgi and the Down.php script?

Once I understand that I'll try to get a bit further.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

mdiesel:

something with the ip... have you tried other ips?

198.162 is a private IP, so that may be the problem... I don't know though

It's not with the IP that I think. I had to use the 192.168.2.110 from the webserver when connecting to the webcam at my house.

martin:

I'm interested to understand what you've done but so far I don't. From the first post I understand that the camera is on your home network and it's IP is 192.168.2.110. If you navigate to http://192.168.2.110/cgi-bin/camctrl.cgi?move=down then the camera moves down. I'm already lost at this point probably because I'm ignorant about VPNs.

Does having a VPN effectively mean you have a server on your PC which is why you can run camctrl.cgi and the Down.php script?

Once I understand that I'll try to get a bit further.

Martin, VPN stands for Virtual Private Network. Basically I've got 2 VPN routers setup, one at my house and one at my wife's work. Through proper configuration and using a standard internet connection, can make both networks appear to be on the same network. My IP range at my wife's work is 192.168.1.xxx and my home network is 192.168.2.xxx . Thru VPN, I can ping any of my home PCs from my wife's work as if I were sitting at one of my computers at home and vise versa. My home network and my wife's work's network is one big happy family and able to communicate like they were all in the same room, even though they are hooked up using the Internet. VPN is a concept that MANY companies use to communicate with satelite offices spread too far apart for normal means. Many employees use their own home connection to connect to their work's network to do work from home.

Since both networks can talk and ping each other, I don't think it's a problem with that. I can run the WebCamDown.exe program from the server's desktop and watch the webcam move down. That part is working. I just don't know why I can't make it work from a PHP script using Shell_Exec or Exec.

I haven't tried making another autoitscript. Maybe the next thing for me to try it to make a simple autoit script that'll maybe write one line of text to a text document. I'll have the php script execute that when I browse to that page from the web and then FTP into the server and see if the text file got created. If not then I know it's with AutoIT and PHP. As I stated in my first post, I know that I can execute "ping" from php or even PSLIST from PSTOOLS and it'll echo back to the browser all the processes running on the server. Some things do work as expected...

Funny thing I did try last night though... After much changes to the PHP script and the AutoIT scripts.... I was home and remoted using VNC into the Webserver and ran the WebCamDown.exe to verify that it still moved the webcam and it did! But... When I browsed to the Down.php page, that's suppose to run WebCamDown.exe using Shell_Exec, I got a echo back to the browser of an error:

--> IE.au3 V2.4-0 Error from function _IELoadWait, $_IEStatus_InvalidObjectType

--> IE.au3 V2.4-0 Error from function _IELoadWait, $_IEStatus_InvalidObjectType

--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidObjectType

Hadn't gotten that when I ran the AutoIt script directly from the webserver.. Thoughts?

Share this post


Link to post
Share on other sites

Avery:

I use a program called Proxifier. Also most home routers will let you do port forwarding/remapping.

When you say your company lets only port 80 keep in mind that it's probably not a open port but a proxy.

More details might help, hard to say, lots of variables here.

You're right about the open port from work, it's a proxy server I have to go through... Port 80 at home IS a problem as my ISP won't allow any incoming Port 80 requests, they are allowed only if they were originated from the home. I can and have setup port forwarding of my router for the webcam, and it works great, if I'm not behind the proxy server at work. :) I don't need to use the port forwarding if I'm at my wife's work as I'm connected through VPN.

Nice try!

Share this post


Link to post
Share on other sites

Is this all that is being hosted on the web service on port 80 at your wife's work? If so, why not just forward incoming connections on port 80 at that site, through the VPN to the webcams web server at your home, instead of trying to build your own interface for the camera?

Even if it isn't the only thing being hosted, you could forward.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Hamachi is a UDP-based virtual private networking system., Try it. & you can host your webserver! FREE

You can also use tons of UDFs hire to control your computer. it will be a pain to find them tho. cuz the are not sorted or anything.

I personally use RealVNC.Enterprise to control my PC. but this is only good, if your connection is good.

Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

Is this all that is being hosted on the web service on port 80 at your wife's work? If so, why not just forward incoming connections on port 80 at that site, through the VPN to the webcams web server at your home, instead of trying to build your own interface for the camera?

Even if it isn't the only thing being hosted, you could forward.

Can't. The router at work won't let me put in a IP in port forwarding other than the subnet it's setup for... 192.168.1.xxx where the IP of the webcam is 192.168.2.110. I already tried it. :party:

Hamachi is a UDP-based virtual private networking system., Try it. & you can host your webserver! FREE

You can also use tons of UDFs hire to control your computer. it will be a pain to find them tho. cuz the are not sorted or anything.

I personally use RealVNC.Enterprise to control my PC. but this is only good, if your connection is good.

Hamachi - a.k.a. Logmein.com is bad here at work.. :) Per a nasty email from a IT Security admin about 4 months ago "During routine troubleshooting of Internet access, it was noticed that a workstation you were logged on to had an extremely high number of Internet access hits to one or more sites categorized as Anonymous Proxy....", there was more to it but it more or less said, do it again and you're fired. Can't use VNC as again it runs off of ports 5800-5900 and are blocked by the proxy server here at work.

Basically, what I'm looking to do is browse to a webpage from my work to the webserver at my wife's work and have IT browse to the appropriate movement webpages of the webcam. ie...

http://192.168.2.110/cgi-bin/camctrl.cgi?move=down = Move Down

http://192.168.2.110/cgi-bin/camctrl.cgi?move=up = Move Up

http://192.168.2.110/cgi-bin/camctrl.cgi?move=right = Move Right

http://192.168.2.110/cgi-bin/camctrl.cgi?move=left = Move Left

Since the webcam and the server is linked through VPN, port 80 blocking isn't an issue.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

yea im still little confused of what you can do & what you cant, but i have an idea. so i will just share it with you.

you create mywifeip/test.php+ create an inputbox where you can insert values into so they are remembered, so if you enter left/right/up or down, then anyone who will open mywifeip/test.txt will see the values you have entered.

so all you need is to modify the files from your work by simply browsing the mywifeip/test.php and the code in your home will react on the changes & move the camera depending what the source code contained, that was downloaded via inetget.

obviosely mywifeip/test.php will contain more info than just 1 value, so save your value into test.txt file in the webserver

or you can simply rename the 1 file to lets say down.html or left.html so if the code cant find a file called down.html it will look for left.html & if it cant find the file, it wont do anything.

#include <INet.au3>
#include <IE.au3>


$oIE2 = _IECreate ("about:blank")


while 1
    $source = _INetGetSource('mywifeip/test.txt')

    _ienavigate($oIE2,'http://localhost/cgi-bin/camctrl.cgi?move=' & $source) ; we imagine, the webpage source returned word left
    _IELoadWait ($oIE2)
    
    sleep(5000); sleep 5 sec
wend
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
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
Sign in to follow this  
Followers 0