Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

sending email upon computer logon

is there a way to detect when a computer comes online by detecting the ip address and then sending a notification to an email address(9535632@bellsouth.net.pe) saying that computer 192.168.0.101 (or whatever the pc's ip address is) has been turned on? when it is turned off

Thanks,
bartonjo2
0
bartonjo2
Asked:
bartonjo2
  • 11
  • 6
  • 3
  • +2
1 Solution
 
VGRCommented:
yes, of course, but only if the computer having that address goes to your server and encounters a PHP script ;-)

else build a windows/kylix application with a timer and a PING on the address
0
 
beachbum_boyCommented:
This would be a pretty crazy way to do things but if you wanted to use PHP you could do the following:

1)Make a page that does a header refresh say every minute
2)The page then does a fsockopen on the ICMP (ping,echo request) port, OR does an exec("ping xxx.xxx.xxx.xxx");
3)Then based on the results of 2) sends an email using the mail(); command.

You would then have to open the page on a machine and leave it open OR else run the PHP as a cron job.

The above would probably work ok but it would be a pretty wacky use of PHP.
0
 
carchitectCommented:
i hope do simple thing
in your site main page....like index.php
write this code on top of your file....

whenever anybody will open your site
mail will be sent....


$ip=getenv("REMOTE_ADDR");
mail('9535632@bellsouth.net.pe','new user','$ip has been turned on','From: youraddress@mail.com');
regards
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
VGRCommented:
carchitect, this will send a mail whenever someone refreshes that page 8-)

The solution of beachbum_boy is 100% correct, and it has happened that I did this 8-)
I prefer a Delphi app with timer to check the PING stuff, 'cause PHP is not meant for this, althought the (infamous ? :D ) trick of the refreshing IFRAME inside/hidden in a "normal" page is useful too.
0
 
carchitectCommented:
hi you may session to prevent email sending again...
if session is active then don't send again
0
 
VGRCommented:
exactly. But that's what I wrote above :D :D
"yes, of course, but only if the computer having that address goes to your server and encounters a PHP script ;-)"
0
 
carchitectCommented:
all right
0
 
bartonjo2Author Commented:
VGR I am not skilled in vb and would not be able to port this program to a windows app,

beachbum_boy  could you show me some code that would do this
0
 
VGRCommented:
how to ping a specified IP address and get teh max trip time in ms

Replace $sess_ip with your hardcoded IP@

<?
    // calcul vitesse ligne et mise à jour table utilisateurs (GetListeStatus reprend ces données)
    $lastline="";
    $lignes=array();
    $lastline=exec("ping -c2 -n -q $sess_ip",$lignes); // le mieux possible en non-root (-f)
    $tok = strtok ($lastline,"/");
    $tok = strtok ("/"); // saute le premier
    $tok = strtok ("/"); // saute le deuxième
    $tok = strtok ("/"); // saute le troisième
    //ne nous intéresse pas sauf si on était en -f (flood) : $moy=$tok;
    $tok = strtok ("/"); // au suivant
    $max=(double)substr($tok,0,strpos($tok,' ')); // on élimine " ms" de la chaîne
//debug
//echo "max $max<BR>";
//
?>
0
 
AmeristCommented:
Build a php page that sends an email including all necessary info.

Put a batch file in the system's startup folder that calls the php page from the internet.

Then, whenever the computer starts up, the batch file will be called and the page will be accessed, sending the email.

Simple as that.
0
 
bartonjo2Author Commented:
hey amerist what if i need to know when my pc turns off though
0
 
VGRCommented:
one freidn of mine had the same problem. He wanted to overlook his DSL connection and retrieve the new IP@ after a line crash/recovery

The best solution is to implement a small program on the CLIENT (your PC) that sends out the IP@ periodically to some outside server, where you'll always be able to recover it.

Very easy, 30 lines of Delphi code and 10 lines of PHP are enough
0
 
AmeristCommented:
Simple, just use this program:

http://users.pandora.be/jbosman/pwroff30.zip

It's free and has all source included
0
 
bartonjo2Author Commented:
VGR i am giving you the points but please show me how to use this suggestion :

one freidn of mine had the same problem. He wanted to overlook his DSL connection and retrieve the new IP@ after a line crash/recovery

The best solution is to implement a small program on the CLIENT (your PC) that sends out the IP@ periodically to some outside server, where you'll always be able to recover it.

Very easy, 30 lines of Delphi code and 10 lines of PHP are enough
0
 
bartonjo2Author Commented:
A (excellent) if you show me how to use your last comment
0
 
VGRCommented:
ok, leave me some time
0
 
VGRCommented:
ok, I offer you some solutions depending on what is running on the "monitored" machine :

-if it's a PC under Windows and it runs a webserver, I've a pretty good solution involving dynamic DNS (you'll have to pay for it, I dont provide this)

-if it's a PC under windows but you're not hosting anything, BUT you have a receiving machine able to host a simple PHP4 page, I can build a small program and the PHP page and it'll be nice : you'll see the current IP on the web page on the "receiving" server.

-if it's a PC under windows but you've only an email address to send the IP@ to, I also have a solution

which one do you want ?
0
 
bartonjo2Author Commented:
i have the last choice:
PC under windows i have an email address(bartonjo2@hotmail.com) to send the IP@ to
0
 
VGRCommented:
ok, but for (2) any free hosting facility nowadays offers 100 MB free disk&web space, a MySql DB and PHP4 ;-))

I'll go now doing (3) for you.

No, don't thank me :D
0
 
VGRCommented:
just tell me how you intend to receive the IP address ? On boot ? Then the program I'll send you will have to be in the start folder of windows. On a line crash/lease renewal ?  Both ?
0
 
VGRCommented:
anyway, I'm 99% done
0
 
VGRCommented:
ok, done.

You can find the GetIPsend program (383KB) at http://www.edainworks.com , choose "third party tools" , switch to French for the yime being, and then it's at the top of section "developpement" ; check for "GetIPsend" (193KB ZIP)

The program will send the new IP@ at startup time (if in the Start folder of windows), and whenever the IP@ changes (polling time is configurable). The program minimizes itself to the SysTray. Usually I also provide more options like a "configure" form, an "help/about", but I simplified.

The program is able to use "email" and "uri" options from the command line.
To pass command line parameters, alter the "properties" of the Windows desktop link (LNK) to the program.
"email" option has this format :
email yourname@provider.com

and the received email is like this :
// IP address changed for host "athlon800"
// "athlon800"'s IP addresses are 169.254.217.36|213.193.168.186

(yes, you'll have all NICs IP@, the program can't decide which one is the "external" one ;-)

Note that in that mode you need a MAPI-enabled email client (like OE? or Eudora without security settings)

--------------
This is the result of the "uri" option :
your ( athlon800 ) host's last known external IP address is 213.193.168.186

(note that in this case only the "external world readable" IP@ is shown, of course.

That's displayed at the specified URI using that "receiver.php" file :
<?
if (substr($PATH_INFO,1)=='itsme') { // good, a request for update
  // let's take also the host name
  $host="( $par_host )";
  $ip=$REMOTE_ADDR;
  // now write in a database or a flat file and exit (no output)
  $fd=fopen("distantip.txt","w");
  fputs($fd,$host);
  fputs($fd,'&|&');
  fputs($fd,$ip);
  fclose($fd);
  exit;
} // request received (if not : simple surveillance)
// else display
header("Refresh: 5");
// read DB or flat file
$fd=@fopen("distantip.txt","r");
if ($fd) { // read
  $poubStr=trim(fgets($fd,1024));
  $zarbi=explode('&|&',$poubStr);
  $host=$zarbi[0];
  $ip=$zarbi[1];
  fclose($fd);
} else { // has not yet run
  $host='';
  $ip='still unknown';
}
echo "your $host host's last known external IP address is $ip<BR>";
?>

In this mode, the GetIPsend program is called with parameter line "uri www.yourdomain.org/receiver.php" (note that "http://" is not to be passed)

Note that the GetIPsend program isn't configured to handle proxies (I simplified it)

regards
0
 
bartonjo2Author Commented:
so in the properties the shortcut would be C:\WINDOWS\Desktop\GetIPsend.exe email bartonjo2@hotmail.com|192.168.0.101
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 11
  • 6
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now