Languages :: PHP :: sending email upon computer logon |
|||
| By: PHP newbee |
Date: 12/03/2003 00:00:00 |
Points: 50 | Status: Answered Quality : Excellent |
|
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, |
|||
| By: VGR | Date: 12/03/2003 11:11:00 | Type : Comment |
|
| 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 |
|||
| By: TheFalklands | Date: 12/03/2003 12:03:00 | Type : Comment |
|
| 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. |
|||
| By: carchitect | Date: 12/03/2003 18:29:00 | Type : Comment |
|
| 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 |
|||
| By: VGR | Date: 13/03/2003 07:23:00 | Type : Comment |
|
| carchitect, this will send a mail whenever someone refreshes that page 8-) The solution of TFL 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. |
|||
| By: carchitect | Date: 13/03/2003 07:45:00 | Type : Comment |
|
| hi you may session to prevent email sending again... if session is active then don't send again |
|||
| By: VGR | Date: 13/03/2003 07:52:00 | Type : Comment |
|
| 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 ;-)" |
|||
| By: carchitect | Date: 13/03/2003 20:01:00 | Type : Comment |
|
| all right |
|||
| By: PHP newbee | Date: 13/03/2003 20:11:00 | Type : Comment |
|
| VGR I am not skilled in vb and would not be able to port this program to a windows app, TheFalklands could you show me some code that would do this |
|||
| By: VGR | Date: 13/03/2003 21:06:00 | Type : Comment |
|
| 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 "; // ?> |
|||
| By: sumotimor | Date: 14/03/2003 09:36:00 | Type : Comment |
|
| 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. |
|||
| By: PHP newbee | Date: 14/03/2003 10:50:00 | Type : Comment |
|
| hey sumotimor what if i need to know when my pc turns off though |
|||
| By: VGR | Date: 14/03/2003 18:28:00 | Type : Answer |
|
| 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 |
|||
| By: sumotimor | Date: 15/03/2003 07:33:00 | Type : Comment |
|
| Simple, just use this program: <A HREF="http://users.pandora.be/jbosman/pwroff30.zip">http://users.pandora.be/jbosman/pwroff30.zip</a> It's free and has all source included |
|||
| By: PHP newbee | Date: 18/03/2003 04:28:00 | Type : Comment |
|
| 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 |
|||
| By: VGR | Date: 18/03/2003 05:16:00 | Type : Comment |
|
| ok, leave me some time |
|||
| By: VGR | Date: 18/03/2003 06:58:00 | Type : Comment |
|
| 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 ? |
|||
| By: PHP newbee | Date: 18/03/2003 19:22:00 | Type : Comment |
|
| i have the last choice: PC under windows i have an email address(globule@hotmail.com) to send the IP@ to |
|||
| By: VGR | Date: 18/03/2003 20:09:00 | Type : Comment |
|
| 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 |
|||
| By: VGR | Date: 18/03/2003 20:10:00 | Type : Comment |
|
| 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 ? |
|||
| By: VGR | Date: 18/03/2003 20:18:00 | Type : Comment |
|
| anyway, I'm 99% done |
|||
| By: VGR | Date: 18/03/2003 20:47:00 | Type : Comment |
|
| ok, done. You can find the GetIPsend program (383KB) at <A HREF="http://www.edainworks.com">http://www.edainworks.com</a> , 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 "; ?> In this mode, the GetIPsend program is called with parameter line "uri <A HREF="http://www.yourdomain.org/receiver.php">www.yourdomain.org/receiver.php</a>" (note that "<A HREF="http://">http://</a>" is not to be passed) Note that the GetIPsend program isn't configured to handle proxies (I simplified it) regards |
|||
| By: PHP newbee | Date: 18/03/2003 21:31:00 | Type : Comment |
|
| so in the properties the shortcut would be C:\WINDOWS\Desktop\GetIPsend.exe email globule@hotmail.com|192.168.0.101 |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








