summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Kristensen <ekristen@pfsense.org>2005-07-17 00:43:42 +0000
committerErik Kristensen <ekristen@pfsense.org>2005-07-17 00:43:42 +0000
commit4951476bcb22c2c1a46d885b1eb312713ff2eff6 (patch)
treeb1dbf47255bbf215f1eae81351e9450f60a75e4c
parent5d719ffa0192715163a6e0a1ac25c1b7c838e013 (diff)
downloadpfsense-4951476bcb22c2c1a46d885b1eb312713ff2eff6.zip
pfsense-4951476bcb22c2c1a46d885b1eb312713ff2eff6.tar.gz
Added code so that the cache file will be created if missing.
-rw-r--r--etc/inc/dyndns.class16
1 files changed, 11 insertions, 5 deletions
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class
index 34d0733..583d10b 100644
--- a/etc/inc/dyndns.class
+++ b/etc/inc/dyndns.class
@@ -39,7 +39,7 @@
*/
class updatedns {
- var $_changeFile = '/var/etc/dyndns.cache';
+ var $_cacheFile = '/var/etc/dyndns.cache';
var $_debugFile = '/var/etc/dyndns.debug';
var $_UserAgent = 'User-Agent: phpDynDNS/0.4';
var $_errorVerbosity = 0;
@@ -348,11 +348,17 @@
$wan_ip = find_interface_ip($wan_if);
$this->_dnsIP = $wan_ip;
- if (file_exists($this->_changeFile)) {
- $file = fopen($this->_changeFile, 'r');
- $contents = fread($file, filesize($this->_changeFile));
+ if (file_exists($this->_cacheFile)) {
+ $file = fopen($this->_cacheFile, 'r');
+ $contents = fread($file, filesize($this->_cacheFile));
fclose($file);
list($cacheIP,$cacheTime) = split(':', $contents);
+ } else {
+ $file = fopen($this->_cacheFile, 'w');
+ fwrite($file, '0.0.0.0:'.$currentTime);
+ fclose($file);
+ $cacheIP = '0.0.0.0';
+ $cacheTime = $currentTime;
}
switch ($this->_dnsService) {
@@ -382,7 +388,7 @@
/* If IP addresses are different or 28 days have passed update record */
if ( ($cacheIP != $wan_ip) || ( ($currentTime - $cacheTime) > $time ) ) {
/* Write WAN IP to cache file */
- $file = fopen($this->_changeFile, 'w');
+ $file = fopen($this->_cacheFile, 'w');
fwrite($file, $wan_ip.':'.$currentTime);
fclose($file);
OpenPOWER on IntegriCloud