Sign in to follow this  
Followers 0
Joseroy

Your Own Ip Address? Server

9 posts in this topic

Folks who want to do TCP/IP aware scripts are interested in accessing the currently used dynamic ip address of a PC or router. To do so, most use 3rd party web sites to provide the information. If the server hosting your own web site supports PHP, you can have your own web site provide your Autoit script the same information, only better since (1) the data is clean and without html tags so no parcing is necessary and (2) your Autoit scripts are more stable since you have control of your own web site. Simply save this PHP code with a .php extension and upload it to your web site (Obviously, if the web server hosting your web site does not support PHP, this won't work so check it out first with your web hosting ISP.):

I also have this PHP script on line for trial (although I probably won't have it on line for public use too long...) at:

Get My Current IP Address

If you view the source code of the page in the web browser, there is nothing there but your IP address.

<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache");

// The headers above insure the data is not cached.
// The Old Expire date is to insure any previous downloads are outdated.
// Do not put any comments above the header codes as PHP wants headers to be
//   the first lines in a PHP script.
// These headers are mostly for web browsers and probably have little use in Autoit scripts.

//********
// The code below filters out unnecessary data which might be fed into
//   the PHP script (accidental or intentional) -- otherwise can be a security hole.

if (!empty($_POST))
{
Exit;
}
if (!empty($_GET))
{
Exit;
}
if (!empty($_COOKIE))
{
Exit;
}
// This last check is reduntant to the above 3, but here just in case... 
if (!empty($_REQUEST))
{
Exit;
}

// This is not part of $_REQUEST, so must be filtered separately.
if (!empty($_FILES))
{
Exit;
}

//******
// The echo below is what is returned; the global IP address -- clean of any 
//   html tags, so no parcing is necessary upon receipt.

echo $host = $_SERVER['REMOTE_ADDR'];
exit;

// If your web hosting ISP supports PHP, you can place this PHP script
// in your web site and access it to check out the current IP global (dynamic) 
// address your PC is using directly or via a router (i.e., the dynamic IP  
// address your router is using.)

// If routers are used, you can configure the local and remote routers to forward 
// particular port/s to the PC's local IP addresses. Once the relevant IP addresses 
// and ports are known (mutually advised via email?), the local and remote PC's  
// can be made to talk to each other via an Autoit script.
?>

This is obviously simple PHP, but it works.

I hope it helps...

Jose

Share this post


Link to post
Share on other sites



Thank you.

I found it useful, it was just what I wanted to do.

Now, I'll insert it in another php to save the Ip and to check if my home connection has changed IP.

Share this post


Link to post
Share on other sites

Thats nice - but you could skip all that and just use the only thing doing something in all that -

<?=$_SERVER['REMOTE_ADDR'];?>

and be done with it.

Share this post


Link to post
Share on other sites

<?=$_SERVER['REMOTE_ADDR'];?>
It works. Thank you for helping me create my first PHP site!! :D

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Looks like you're getting into the wonderful world of php too huh? Or are you a master?

Nice script!


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]

Share this post


Link to post
Share on other sites

im srry if im being stupid but what exactly does this do, allow you to run autoit scripts on your webhosts? b/c thats what ive been wanting to do for a while

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This is nice..

incase your wondering theres.. http://www.whatismyip.org/ , it displays nothing but your ip address..

Edited by WTS

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