File: C:/xampp/htdocs/phpmailer/ipfinalX.php
<html><head><meta http-equiv="refresh" content="3600;url=ipfinalX.php"></head><body>
<?php
//code has been updated to only send email if the ip has changed. no more full mailboxes.
//you must enable read and write permission on the ipcheck.txt file
$url = 'http://checkip.dyndns.org/';
$raw = file_get_contents($url);
$newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
$content = str_replace($newlines, "", html_entity_decode($raw));
$start = strpos($content,'^');
$end = strpos($content,'?',$start) + 8;
$ip = substr($content,$start,$end-$start);
echo "herex";
echo "{$raw}"; //this is the external ip you can pop in anywhere.
//echo "ip:".$ip;
$myFile = "ipcheck.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, 1000);
fclose($fh);
if ($raw == $theData) { die; }
//if (1<1) { die; }
else { $fw = fopen($myFile, "w");
fwrite ($fw, $raw);
fclose ($fw);
$toEmail = "[email protected]";
$subject = "pppOE ip Address";
$content = "{$raw}";
$mailHeaders = "From: [email protected]\r\n";
if(mail($toEmail, $subject, $content, $mailHeaders)) {
$message = "You have registered and the activation mail is sent to your email. Click the activation link to activate you account.";
}
echo "<br><br>";
echo "Message has been sent";
}
//echo $myFile; for testing.
//echo $raw;
//echo $theData;
?>
<br>
<br>
<?php
?>
</body></html><?
?>