Project

General

Profile

Download (56.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
	/*
3
	 * PHP.updateDNS (pfSense version)
4
	 *
5
	 * +====================================================+
6
	 *  Services Supported:
7
	 *    - DynDns (dyndns.org) [dynamic, static, custom]
8
	 *    - DHSDns (dhs.org)
9
	 *    - No-IP (no-ip.com)
10
	 *    - EasyDNS (easydns.com)
11
	 *    - DHS (www.dhs.org)
12
	 *    - HN (hn.org) -- incomplete checking!
13
	 *    - DynS (dyns.org)
14
	 *    - ZoneEdit (zoneedit.com)
15
	 *    - FreeDNS (freedns.afraid.org)
16
	 *    - Loopia (loopia.se)
17
	 *    - StaticCling (staticcling.org)
18
	 *    - DNSexit (dnsexit.com)
19
	 *    - OpenDNS (opendns.com)
20
	 *    - Namecheap (namecheap.com)
21
	 *    - HE.net (dns.he.net)
22
	 *    - HE.net IPv6 (dns.he.net)
23
	 *    - HE.net Tunnelbroker IP update (ipv4.tunnelbroker.net)
24
	 *    - SelfHost (selfhost.de)
25
	 *    - Amazon Route 53 (aws.amazon.com)
26
	 *    - DNS-O-Matic (dnsomatic.com)
27
	 *    - Custom DDNS (any URL)
28
	 *    - Custom DDNS IPv6 (any URL)
29
	 *    - CloudFlare (www.cloudflare.com)
30
 	 *    - Eurodns (eurodns.com)
31
 	 *    - GratisDNS (gratisdns.dk)
32
	 *    - City Network (citynetwork.se)
33
	 * +----------------------------------------------------+
34
	 *  Requirements:
35
	 *    - PHP version 4.0.2 or higher with the CURL Library and the PCRE Library
36
	 * +----------------------------------------------------+
37
	 *  Public Functions
38
	 *    - updatedns()
39
	 *
40
	 *  Private Functions
41
	 *    - _update()
42
	 *    - _checkStatus()
43
	 *    - _error()
44
	 *    - _detectChange()
45
	 *    - _debug()
46
	 *    - _checkIP()
47
	 * +----------------------------------------------------+
48
	 *  DynDNS Dynamic - Last Tested: 12 July 2005
49
	 *  DynDNS Static  - Last Tested: NEVER
50
	 *  DynDNS Custom  - Last Tested: NEVER
51
	 *  No-IP          - Last Tested: 20 July 2008
52
	 *  HN.org         - Last Tested: 12 July 2005
53
	 *  EasyDNS        - Last Tested: 20 July 2008
54
	 *  DHS            - Last Tested: 12 July 2005
55
	 *  ZoneEdit       - Last Tested: NEVER
56
	 *  Dyns           - Last Tested: NEVER
57
	 *  ODS            - Last Tested: 02 August 2005
58
	 *  FreeDNS        - Last Tested: 23 Feb 2011
59
	 *  Loopia         - Last Tested: NEVER
60
	 *  StaticCling    - Last Tested: 27 April 2006
61
	 *  DNSexit	   - Last Tested: 20 July 2008
62
	 *  OpenDNS	   - Last Tested: 4 August 2008
63
	 *  Namecheap	   - Last Tested: 31 August 2010
64
	 *  HE.net         - Last Tested: 7 July 2013
65
	 *  HE.net IPv6    - Last Tested: 7 July 2013
66
	 *  HE.net Tunnel  - Last Tested: 28 June 2011
67
	 *  SelfHost       - Last Tested: 26 December 2011
68
	 *  Amazon Route 53 - Last tested: 01 April 2012
69
	 *  DNS-O-Matic	   - Last Tested: 9 September 2010
70
	 *  CloudFlare     - Last Tested: 30 May 2013
71
  	 *  Eurodns	   - Last Tested: 27 June 2013
72
  	 *  GratisDNS      - Last Tested: 15 August 2012
73
	 *  OVH DynHOST	   - Last Tested: NEVER
74
	 *  City Network   - Last Tested: 13 November 2013
75
	 * +====================================================+
76
	 *
77
	 * @author 	E.Kristensen
78
	 * @link    	http://www.idylldesigns.com/projects/phpdns/
79
	 * @version 	0.8
80
	 * @updated	13 October 05 at 21:02:42 GMT
81
	 *
82
	 * DNSexit/OpenDNS support and multiwan extension for pfSense by Ermal Luci
83
	 * Custom DNS support by Matt Corallo
84
	 *
85
	 */
86

    
87
	class updatedns {
88
		var $_cacheFile;
89
		var $_cacheFile_v6;
90
		var $_debugFile;
91
		var $_UserAgent = 'User-Agent: phpDynDNS/0.7';
92
		var $_errorVerbosity = 0;
93
		var $_dnsService;
94
		var $_dnsUser;
95
		var $_dnsPass;
96
		var $_dnsHost;
97
		var $_dnsIP;
98
		var $_dnsWildcard;
99
		var $_dnsMX;
100
		var $_dnsBackMX;
101
		var $_dnsServer;
102
		var $_dnsPort;
103
		var $_dnsUpdateURL;
104
		var $_dnsZoneID;
105
		var $_dnsTTL;
106
		var $status;
107
		var $_debugID;
108
		var $_if;
109
		var $_dnsResultMatch;
110
		var $_dnsRequestIf;
111
		var $_dnsRequestIfIP;
112
		var $_dnsVerboseLog;
113
		var $_curlIpresolveV4;
114
		var $_curlSslVerifypeer;
115
		var $_dnsMaxCacheAgeDays;
116
		var $_dnsDummyUpdateDone;
117
		var $_forceUpdateNeeded;
118
		var $_useIPv6;
119
		
120
		/* 
121
		 * Public Constructor Function (added 12 July 05) [beta]
122
		 *   - Gets the dice rolling for the update. 
123
		 *   - $dnsResultMatch should only be used with $dnsService = 'custom'
124
		 *   -  $dnsResultMatch is parsed for '%IP%', which is the IP the provider was updated to, 
125
		 *   -  it is otherwise expected to be exactly identical to what is returned by the Provider.
126
		 *   - $dnsUser, and $dnsPass indicate HTTP Auth for custom DNS, if they are needed in the URL (GET Variables), include them in $dnsUpdateURL.
127
		 *   - $For custom requests, $dnsUpdateURL is parsed for '%IP%', which is replaced with the new IP.
128
		 */
129
		function updatedns ($dnsService = '', $dnsHost = '', $dnsUser = '', $dnsPass = '',
130
				    $dnsWildcard = 'OFF', $dnsMX = '', $dnsIf = '', $dnsBackMX = '',
131
				    $dnsServer = '', $dnsPort = '', $dnsUpdateURL = '', $forceUpdate = false,
132
				    $dnsZoneID ='', $dnsTTL='', $dnsResultMatch = '', $dnsRequestIf = '',
133
				    $dnsID = '', $dnsVerboseLog = false, $curlIpresolveV4 = false, $curlSslVerifypeer = true) {
134
			
135
			global $config, $g;
136
			
137
			$this->_cacheFile = "{$g['conf_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}.cache";
138
			$this->_cacheFile_v6 = "{$g['conf_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}_v6.cache";
139
			$this->_debugFile = "{$g['varetc_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . "{$dnsID}.debug";
140

    
141
			$this->_curlIpresolveV4 = $curlIpresolveV4;
142
			$this->_curlSslVerifypeer = $curlSslVerifypeer;
143
			$this->_dnsVerboseLog = $dnsVerboseLog;
144
			if ($this->_dnsVerboseLog)
145
				log_error("DynDns: updatedns() starting");
146

    
147
			$dyndnslck = lock("DDNS".$dnsID, LOCK_EX);
148

    
149
			if (!$dnsService) $this->_error(2);
150
			switch ($dnsService) {
151
			case 'freedns':
152
				if (!$dnsHost) $this->_error(5);
153
				break;
154
			case 'namecheap':
155
				if (!$dnsPass) $this->_error(4);
156
				if (!$dnsHost) $this->_error(5);
157
				break;
158
			case 'route53':
159
				if (!$dnsZoneID) $this->_error(8);
160
				if (!$dnsTTL) $this->_error(9);
161
				break;
162
			case 'custom':
163
				if (!$dnsUpdateURL) $this->_error(7);
164
				break;
165
			default:
166
				if (!$dnsUser) $this->_error(3);
167
				if (!$dnsPass) $this->_error(4);
168
				if (!$dnsHost) $this->_error(5);
169
			}
170
			
171
			switch ($dnsService) {
172
			case 'he-net-v6':
173
			case 'custom-v6':
174
				$this->_useIPv6 = true;
175
				break;
176
			default:
177
				$this->_useIPv6 = false;
178
			}
179
			$this->_dnsService = strtolower($dnsService);
180
			$this->_dnsUser = $dnsUser;
181
			$this->_dnsPass = $dnsPass;
182
			$this->_dnsHost = $dnsHost;
183
			$this->_dnsServer = $dnsServer;
184
			$this->_dnsPort = $dnsPort;
185
			$this->_dnsWildcard = $dnsWildcard;
186
			$this->_dnsMX = $dnsMX;
187
			$this->_dnsZoneID = $dnsZoneID;
188
			$this->_dnsTTL = $dnsTTL;
189
			$this->_if = get_failover_interface($dnsIf);
190
			$this->_checkIP();
191
			$this->_dnsUpdateURL = $dnsUpdateURL;
192
			$this->_dnsResultMatch = $dnsResultMatch;
193
			$this->_dnsRequestIf = get_failover_interface($dnsRequestIf);
194
			if ($this->_dnsVerboseLog)
195
				log_error("DynDNS ({$this->_dnsHost}): running get_failover_interface for {$dnsRequestIf}. found {$this->_dnsRequestIf}");
196
			$this->_dnsRequestIfIP = get_interface_ip($dnsRequestIf);
197
			$this->_dnsMaxCacheAgeDays = 25;
198
			$this->_dnsDummyUpdateDone = false;
199
			$this->_forceUpdateNeeded = $forceUpdate;
200
			
201
			// Ensure that we were able to lookup the IP
202
			if(!is_ipaddr($this->_dnsIP)) {
203
				log_error("DynDNS ({$this->_dnsHost}) There was an error trying to determine the public IP for interface - {$dnsIf}({$this->_if}). Probably interface is not a WAN interface.");
204
				unlock($dyndnslck);
205
				return;
206
			}
207

    
208
			$this->_debugID = rand(1000000, 9999999);
209
			
210
			if ($forceUpdate == false && $this->_detectChange() == false) {
211
				$this->_error(10);
212
			} else {
213
				switch ($this->_dnsService) {
214
				case 'dnsomatic':
215
				case 'dyndns':
216
				case 'dyndns-static':
217
				case 'dyndns-custom':
218
				case 'dhs':
219
				case 'noip':
220
				case 'noip-free':
221
				case 'easydns':
222
				case 'hn':
223
				case 'zoneedit':
224
				case 'dyns':
225
				case 'ods':
226
				case 'freedns':
227
				case 'loopia':
228
				case 'staticcling':
229
				case 'dnsexit':
230
				case 'custom':
231
				case 'custom-v6':
232
				case 'opendns':
233
				case 'namecheap':
234
				case 'he-net':
235
				case 'he-net-v6':
236
				case 'selfhost':
237
				case 'he-net-tunnelbroker':
238
				case 'route53':
239
				case 'cloudflare':
240
				case 'eurodns':
241
				case 'gratisdns':
242
				case 'ovh-dynhost':
243
                case 'citynetwork':
244
					$this->_update();
245
					if($this->_dnsDummyUpdateDone == true) {
246
						// If a dummy update was needed, then sleep a while and do the update again to put the proper address back.
247
						// Some providers (e.g. No-IP free accounts) need to have at least 1 address change every month.
248
						// If the address has not changed recently, or the user did "Force Update", then the code does
249
						// a dummy address change for providers like this.
250
						sleep(10);
251
						$this->_update();
252
					}
253
					break;
254
				default:
255
					$this->_error(6);
256
					break;
257
				}
258
			}
259

    
260
			unlock($dyndnslck);
261
		}
262
			
263
		/*
264
		 * Private Function (added 12 July 05) [beta]
265
		 *   Send Update To Selected Service.
266
		 */
267
		function _update() {
268
		
269
			if ($this->_dnsVerboseLog)
270
				log_error("DynDNS ({$this->_dnsHost}): DynDns _update() starting.");
271
		
272
			if ($this->_dnsService != 'ods' and $this->_dnsService != 'route53 ') {
273
				$ch = curl_init();
274
				curl_setopt($ch, CURLOPT_HEADER, 0);
275
				curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent);
276
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
277
				curl_setopt($ch, CURLOPT_INTERFACE, $this->_dnsRequestIfIP);
278
				curl_setopt($ch, CURLOPT_TIMEOUT, 120); // Completely empirical
279
			}
280

    
281
			switch ($this->_dnsService) {
282
				case 'dyndns':
283
				case 'dyndns-static':
284
				case 'dyndns-custom':
285
					$needsIP = FALSE;
286
					if ($this->_dnsVerboseLog)
287
						log_error("DynDNS: ({$this->_dnsHost}) DNS update() starting.");
288
					if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON";
289
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
290
					$server = "https://members.dyndns.org/nic/update";
291
					$port = "";
292
					if($this->_dnsServer)
293
						$server = $this->_dnsServer;
294
					if($this->_dnsPort)
295
						$port = ":" . $this->_dnsPort;
296
					curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO');
297
					break;
298
				case 'dhs':
299
					$needsIP = TRUE;
300
					$post_data['hostscmd'] = 'edit';
301
					$post_data['hostscmdstage'] = '2';
302
					$post_data['type'] = '4';
303
					$post_data['updatetype'] = 'Online';
304
					$post_data['mx'] = $this->_dnsMX;
305
					$post_data['mx2'] = '';
306
					$post_data['txt'] = '';
307
					$post_data['offline_url'] = '';
308
					$post_data['cloak'] = 'Y';
309
					$post_data['cloak_title'] = '';
310
					$post_data['ip'] = $this->_dnsIP;
311
					$post_data['domain'] = 'dyn.dhs.org';
312
					$post_data['hostname'] = $this->_dnsHost;
313
					$post_data['submit'] = 'Update';
314
					$server = "https://members.dhs.org/nic/hosts";
315
					$port = "";
316
					if($this->_dnsServer)
317
						$server = $this->_dnsServer;
318
					if($this->_dnsPort)
319
						$port = ":" . $this->_dnsPort;					
320
					curl_setopt($ch, CURLOPT_URL, '{$server}{$port}');
321
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
322
					curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
323
					break;
324
				case 'noip':
325
				case 'noip-free':
326
					$needsIP = TRUE;
327
					$server = "https://dynupdate.no-ip.com/ducupdate.php";
328
					$port = "";
329
					if($this->_dnsServer)
330
						$server = $this->_dnsServer;
331
					if($this->_dnsPort)
332
						$port = ":" . $this->_dnsPort;
333
					if(($this->_dnsService == "noip-free") && 
334
					   ($this->_forceUpdateNeeded == true) && 
335
					   ($this->_dnsDummyUpdateDone == false)) {
336
						// Update the IP to a dummy value to force No-IP free accounts to see a change.
337
						$iptoset = "192.168.1.1";
338
						$this->_dnsDummyUpdateDone = true;
339
						log_error("DynDNS ({$this->_dnsHost}): Processing dummy update on No-IP free account. IP temporarily set to " . $iptoset);
340
					} else {
341
						$iptoset = $this->_dnsIP;
342
					}
343
					curl_setopt($ch, CURLOPT_URL, $server . $port . '?username=' . urlencode($this->_dnsUser) . '&pass=' . urlencode($this->_dnsPass) . '&hostname=' . $this->_dnsHost.'&ip=' . $iptoset);
344
					break;
345
				case 'easydns':
346
					$needsIP = TRUE;
347
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
348
					$server = "https://members.easydns.com/dyn/dyndns.php";
349
					$port = "";
350
					if($this->_dnsServer)
351
						$server = $this->_dnsServer;
352
					if($this->_dnsPort)
353
						$port = ":" . $this->_dnsPort;
354
					curl_setopt($ch, CURLOPT_URL, $server . $port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard=' . $this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=' . $this->_dnsBackMX);
355
					break;
356
				case 'hn':
357
					$needsIP = TRUE;
358
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
359
					$server = "http://dup.hn.org/vanity/update";
360
					$port = "";
361
					if($this->_dnsServer)
362
						$server = $this->_dnsServer;
363
					if($this->_dnsPort)
364
						$port = ":" . $this->_dnsPort;
365
					curl_setopt($ch, CURLOPT_URL, $server . $port . '?ver=1&IP=' . $this->_dnsIP);
366
					break;
367
				case 'zoneedit':
368
					$needsIP = FALSE;
369
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
370

    
371
					$server = "https://dynamic.zoneedit.com/auth/dynamic.html";
372
					$port = "";
373
					if($this->_dnsServer)
374
						$server = $this->_dnsServer;
375
					if($this->_dnsPort)
376
						$port = ":" . $this->_dnsPort;
377
					curl_setopt($ch, CURLOPT_URL, "{$server}{$port}?host=" .$this->_dnsHost);
378
					break;
379
				case 'dyns':
380
					$needsIP = FALSE;
381
					$server = "https://www.dyns.cx/postscript011.php";
382
					$port = "";
383
					if($this->_dnsServer)
384
						$server = $this->_dnsServer;
385
					if($this->_dnsPort)
386
						$port = ":" . $this->_dnsPort;					
387
					curl_setopt($ch, CURLOPT_URL, $server . $port . '?username=' . urlencode($this->_dnsUser) . '&password=' . $this->_dnsPass . '&host=' . $this->_dnsHost);
388
					break;
389
				case 'ods':
390
					$needsIP = FALSE;
391
					$misc_errno = 0;
392
					$misc_error = "";
393
					$server = "ods.org";
394
					$port = "";
395
					if($this->_dnsServer)
396
						$server = $this->_dnsServer;
397
					if($this->_dnsPort)
398
						$port = ":" . $this->_dnsPort;						
399
					$this->con['socket'] = fsockopen("{$server}{$port}", "7070", $misc_errno, $misc_error, 30);
400
					/* Check that we have connected */
401
					if (!$this->con['socket']) {
402
						print "error! could not connect.";
403
						break;
404
					}
405
					/* Here is the loop. Read the incoming data (from the socket connection) */
406
					while (!feof($this->con['socket'])) {
407
						$this->con['buffer']['all'] = trim(fgets($this->con['socket'], 4096));
408
						$code = substr($this->con['buffer']['all'], 0, 3);
409
						sleep(1);
410
						switch($code) {
411
							case 100:
412
								fputs($this->con['socket'], "LOGIN ".$this->_dnsUser." ".$this->_dnsPass."\n");
413
								break;
414
							case 225:
415
								fputs($this->con['socket'], "DELRR ".$this->_dnsHost." A\n");
416
								break;
417
							case 901:
418
								fputs($this->con['socket'], "ADDRR ".$this->_dnsHost." A ".$this->_dnsIP."\n");
419
								break;
420
							case 795:
421
								fputs($this->con['socket'], "QUIT\n");
422
								break;
423
						}
424
					}
425
					$this->_checkStatus(0, $code);
426
					break;
427
				case 'freedns':
428
					$needIP = FALSE;
429
					curl_setopt($ch, CURLOPT_URL, 'https://freedns.afraid.org/dynamic/update.php?' . $this->_dnsPass);
430
					break;
431
				case 'dnsexit':
432
					$needsIP = TRUE;
433
					curl_setopt($ch, CURLOPT_URL, 'https://www.dnsexit.com/RemoteUpdate.sv?login='.$this->_dnsUser. '&password='.$this->_dnsPass.'&host='.$this->_dnsHost.'&myip='.$this->_dnsIP);
434
					break;
435
				case 'loopia':
436
					$needsIP = TRUE;
437
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
438
					curl_setopt($ch, CURLOPT_URL, 'https://dns.loopia.se/XDynDNSServer/XDynDNS.php?hostname='.$this->_dnsHost.'&myip='.$this->_dnsIP);
439
					break;
440
				case 'opendns':
441
					$needsIP = FALSE;
442
					if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON";
443
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
444
					$server = "https://updates.opendns.com/nic/update?hostname=". $this->_dnsHost;
445
					$port = "";
446
					if($this->_dnsServer)
447
						$server = $this->_dnsServer;
448
					if($this->_dnsPort)
449
						$port = ":" . $this->_dnsPort;
450
					curl_setopt($ch, CURLOPT_URL, $server .$port);
451
					break;
452

    
453
				case 'staticcling':
454
					$needsIP = FALSE;
455
					curl_setopt($ch, CURLOPT_URL, 'https://www.staticcling.org/update.html?login='.$this->_dnsUser.'&pass='.$this->_dnsPass);
456
					break;	                    
457
				case 'dnsomatic':
458
					/* Example syntax 
459
						https://username:password@updates.dnsomatic.com/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
460
					*/
461
					$needsIP = FALSE;
462
					if ($this->_dnsVerboseLog)
463
						log_error("DNS-O-Matic: DNS update() starting.");
464
					if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON";
465
					/*
466
					Reference: https://www.dnsomatic.com/wiki/api
467
						DNS-O-Matic usernames are 3-25 characters.
468
						DNS-O-Matic passwords are 6-20 characters.
469
						All ASCII letters and numbers accepted.
470
						Dots, dashes, and underscores allowed, but not at the beginning or end of the string.
471
					Required: "rawurlencode" http://www.php.net/manual/en/function.rawurlencode.php
472
						Encodes the given string according to RFC 3986.
473
					*/
474
					$server = "https://" . rawurlencode($this->_dnsUser) . ":" . rawurlencode($this->_dnsPass) . "@updates.dnsomatic.com/nic/update?hostname=";
475
					if($this->_dnsServer)
476
						$server = $this->_dnsServer;
477
					if($this->_dnsPort)
478
						$port = ":" . $this->_dnsPort;
479
					curl_setopt($ch, CURLOPT_URL, $server . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NOCHG');
480
					break;
481
				case 'namecheap':
482
					/* Example:
483
						https://dynamicdns.park-your-domain.com/update?host=[host_name]&domain=[domain.com]&password=[domain_password]&ip=[your_ip]
484
					*/
485
					$needsIP = FALSE;
486
					if ($this->_dnsVerboseLog)
487
						log_error("Namecheap ({$this->_dnsHost}): DNS update() starting.");
488
					$dparts = explode(".", trim($this->_dnsHost));
489
					$domain_part_count = ($dparts[count($dparts)-1] == "uk") ? 3 : 2;
490
					$domain_offset = count($dparts) - $domain_part_count;
491
					$hostname = implode(".", array_slice($dparts, 0, $domain_offset));
492
					$domain = implode(".", array_slice($dparts, $domain_offset));
493
					$dnspass = trim($this->_dnsPass);
494
					$server = "https://dynamicdns.park-your-domain.com/update?host={$hostname}&domain={$domain}&password={$dnspass}&ip={$this->_dnsIP}";
495
					curl_setopt($ch, CURLOPT_URL, $server);
496
					break;
497
				case 'he-net':
498
				case 'he-net-v6':
499
					$needsIP = FALSE;
500
					if ($this->_dnsVerboseLog)
501
						log_error("HE.net ({$this->_dnsHost}): DNS update() starting.");
502
					$server = "https://dyn.dns.he.net/nic/update?";
503
					curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
504
					curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
505
					curl_setopt($ch, CURLOPT_URL, $server . 'hostname=' . $this->_dnsHost . '&password=' . $this->_dnsPass . '&myip=' . $this->_dnsIP);
506
					break;
507
				case 'he-net-tunnelbroker':
508
					$needsIP = FALSE;
509
					if ($this->_dnsVerboseLog)
510
						log_error("HE.net Tunnelbroker: DNS update() starting.");
511
					$server = "https://ipv4.tunnelbroker.net/ipv4_end.php?";
512
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser . ':' . $this->_dnsPass);
513
					curl_setopt($ch, CURLOPT_URL, $server . 'tid=' . $this->_dnsHost);
514
					break;
515
				case 'selfhost':
516
					$needsIP = FALSE;
517
					if ($this->_dnsVerboseLog)
518
						log_error("SelfHost: DNS update() starting.");
519
					if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON";
520
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
521
					$server = "https://carol.selfhost.de/nic/update";
522
					$port = "";
523
					if($this->_dnsServer)
524
						$server = $this->_dnsServer;
525
					if($this->_dnsPort)
526
						$port = ":" . $this->_dnsPort;
527
					curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO');
528
					break;
529
				case 'route53':
530
					if ($this->_dnsVerboseLog)
531
						log_error("Route53 ({$this->_dnsHost}): DNS update() starting.");
532
					
533
					/* Setting Variables */
534
					$hostname = "{$this->_dnsHost}.";
535
					$ZoneID = $this->_dnsZoneID;
536
					$AccessKeyId=$this->_dnsUser;
537
					$SecretAccessKey=$this->_dnsPass;
538
					$NewIP=$this->_dnsIP;
539
					$NewTTL=$this->_dnsTTL;
540

    
541
					/* Include Route 53 Library Class */
542
					require_once('/etc/inc/r53.class');
543

    
544
					/* Set Amazon AWS Credentials for this record */
545
					$r53 = new Route53($AccessKeyId, $SecretAccessKey);
546

    
547
					/* Function to find old values of records in Route 53 */
548
					if(!function_exists('Searchrecords')) {
549
						function SearchRecords($records, $name) {
550
							$result = array();
551
							foreach($records as $record) {
552
								if(strtolower($record['Name']) == strtolower($name)) {
553
									$result [] = $record;
554
								}
555
							}
556
							return ($result) ? $result : false;
557
						}
558
					}
559

    
560
					$records = $r53->listResourceRecordSets("/hostedzone/$ZoneID");
561

    
562
					/* Get IP for your hostname in Route 53 */
563
					if(false !== ($a_result = SearchRecords($records['ResourceRecordSets'], "$hostname"))) {
564
						$OldTTL=$a_result[0][TTL];
565
						$OldIP=$a_result[0][ResourceRecords][0];
566
					} else {
567
						$OldIP="";
568
					}
569

    
570
					/* Check if we need to update DNS Record */
571
					if ($OldIP !== $NewIP) {
572
						if(!empty($OldIP)) {
573
							/* Your Hostname already exists, deleting and creating it again */
574
							$changes = array();
575
							$changes[] = $r53->prepareChange(DELETE, $hostname, A, $OldTTL, $OldIP);
576
							$changes[] = $r53->prepareChange(CREATE, $hostname, A, $NewTTL, $NewIP);
577
							$result = $r53->changeResourceRecordSets("/hostedzone/$ZoneID", $changes);
578
						} else {
579
							/* Your Hostname does not exist yet, creating it */
580
							$changes = $r53->prepareChange(CREATE, $hostname, A, $NewTTL, $NewIP);
581
							$result = $r53->changeResourceRecordSets("/hostedzone/$ZoneID", $changes);
582
						}
583
					}
584
					$this->_checkStatus(0, $result);
585
					break;
586
				case 'custom':
587
				case 'custom-v6':
588
					if ($this->_dnsVerboseLog)
589
						log_error("Custom DDNS ({$this->_dnsHost}): DNS update() starting.");
590
					if (strstr($this->dnsUpdateURL, "%IP%")) {$needsIP = TRUE;} else {$needsIP = FALSE;}
591
					if ($this->_dnsUser != '') {
592
						if ($this->_curlIpresolveV4)
593
							curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
594
						if ($this->_curlSslVerifypeer)
595
							curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
596
						else
597
							curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
598
						curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
599
						curl_setopt($ch, CURLOPT_USERPWD, "{$this->_dnsUser}:{$this->_dnsPass}");
600
					}
601
					$server = str_replace("%IP%", $this->_dnsIP, $this->_dnsUpdateURL);
602
					if ($this->_dnsVerboseLog)
603
						log_error("Sending request to: ".$server);
604
					curl_setopt($ch, CURLOPT_URL, $server);
605
					break;
606
				case 'cloudflare':
607
					$needsIP = TRUE;
608
					$dnsServer ='www.cloudflare.com';
609
					$dnsHost = str_replace(' ','', $this->_dnsHost);
610
					$URL = "https://{$dnsServer}/api.html?a=DIUP&email={$this->_dnsUser}&tkn={$this->_dnsPass}&ip={$this->_dnsIP}&hosts={$dnsHost}";
611
					curl_setopt($ch, CURLOPT_URL, $URL);
612
					break;
613
				case 'eurodns':		
614
					$needsIP = TRUE;
615
					if ($this->_dnsVerboseLog)
616
						log_error("EuroDynDns ({$this->_dnsHost}) DNS update() starting.");
617
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
618
					$server = "https://update.eurodyndns.org/update/";
619
					$port = "";
620
					if($this->_dnsPort)
621
						$port = ":" . $this->_dnsPort;
622
					curl_setopt($ch, CURLOPT_URL, $server .$port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP);
623
					break;
624
				case 'gratisdns':
625
					$needsIP = FALSE;
626
					if ($this->_dnsVerboseLog)
627
						log_error("GratisDNS.dk ({$this->_dnsHost}): DNS update() starting.");
628
					$server = "https://ssl.gratisdns.dk/ddns.phtml";
629
					list($hostname, $domain) = explode(".", $this->_dnsHost, 2);
630
					curl_setopt($ch, CURLOPT_URL, $server . '?u=' . $this->_dnsUser . '&p=' . $this->_dnsPass . '&h=' . $this->_dnsHost . '&d=' . $domain);
631
					break;
632
				case 'ovh-dynhost':
633
					$needsIP = FALSE;
634
					if ($this->_dnsVerboseLog)
635
						log_error("OVH DynHOST: ({$this->_dnsHost}) DNS update() starting.");
636
					if (isset($this->_dnsWildcard) && $this->_dnsWildcard != "OFF") $this->_dnsWildcard = "ON";
637
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
638
					$server = "https://www.ovh.com/nic/update";
639
					$port = "";
640
					if($this->_dnsServer)
641
						$server = $this->_dnsServer;
642
					if($this->_dnsPort)
643
						$port = ":" . $this->_dnsPort;
644
					curl_setopt($ch, CURLOPT_URL, $server .$port . '?system=dyndns&hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP . '&wildcard='.$this->_dnsWildcard . '&mx=' . $this->_dnsMX . '&backmx=NO');
645
					break;
646
				case 'citynetwork':
647
					$needsIP = TRUE;
648
					if ($this->_dnsVerboseLog)
649
						log_error("City Network: ({$this->_dnsHost}) DNS update() starting.");
650
					curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
651
					$server = 'https://dyndns.citynetwork.se/nic/update';
652
					$port = "";
653
					if($this->_dnsServer)
654
						$server = $this->_dnsServer;
655
					if($this->_dnsPort)
656
						$port = ":" . $this->_dnsPort;
657
					curl_setopt($ch, CURLOPT_URL, $server .$port . '?hostname=' . $this->_dnsHost . '&myip=' . $this->_dnsIP);
658
					break;
659
				default:
660
					break;
661
			}
662
			if ($this->_dnsService != 'ods' and $this->_dnsService != 'route53') {
663
				$data = curl_exec($ch);
664
				$this->_checkStatus($ch, $data);
665
				@curl_close($ch);
666
			}
667
		}
668

    
669
		/*
670
		 * Private Function (added 12 July 2005) [beta]
671
		 *   Retrieve Update Status
672
		 */
673
		function _checkStatus($ch, $data) {
674
			if ($this->_dnsVerboseLog) {
675
				log_error("DynDNS ({$this->_dnsHost}): DynDns _checkStatus() starting.");
676
				log_error("DynDNS ({$this->_dnsHost}): Current Service: {$this->_dnsService}");
677
			}
678
			$successful_update = false;
679
			if ($this->_dnsService != 'ods' and $this->_dnsService != 'route53' && @curl_error($ch)) {
680
				$status = "Curl error occurred: " . curl_error($ch);
681
				log_error($status);
682
				$this->status = $status;
683
				return;
684
			}
685
			switch ($this->_dnsService) {
686
				case 'dnsomatic':
687
					if (preg_match('/badauth/i', $data)) {
688
						$status = "DNS-O-Matic ({$this->_dnsHost}): The DNS-O-Matic username or password specified are incorrect. No updates will be distributed to services until this is resolved.";
689
					} else if (preg_match('/notfqdn /i', $data)) {
690
						$status = "DNS-O-Matic ({$this->_dnsHost}): The hostname specified is not a fully-qualified domain name. If no hostnames included, notfqdn will be returned once.";
691
					} else if (preg_match('/nohost/i', $data)) {
692
						$status = "DNS-O-Matic ({$this->_dnsHost}): The hostname passed could not be matched to any services configured. The service field will be blank in the return code.";
693
					} else if (preg_match('/numhost/i', $data)) {
694
						$status = "DNS-O-Matic ({$this->_dnsHost}): You may update up to 20 hosts. numhost is returned if you try to update more than 20 or update a round-robin.";	
695
					} else if (preg_match('/abuse/i', $data)) {
696
						$status = "DNS-O-Matic ({$this->_dnsHost}): The hostname is blocked for update abuse.";
697
					} else if (preg_match('/good/i', $data)) {
698
						$status = "DNS-O-Matic ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")";
699
						$successful_update = true;
700
					} else if (preg_match('/dnserr/i', $data)) {
701
						$status = "DNS-O-Matic ({$this->_dnsHost}): DNS error encountered. Stop updating for 30 minutes.";
702
					} else {
703
						$status = "DNS-O-Matic ({$this->_dnsHost}): (Unknown Response)";
704
						log_error("DNS-O-Matic ({$this->_dnsHost}): PAYLOAD: {$data}");
705
						$this->_debug($data);
706
					}
707
					break;
708
				case 'citynetwork':
709
					if (preg_match('/notfqdn/i', $data)) {
710
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
711
					} else if (preg_match('/nohost/i', $data)) {
712
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) No such host";
713
					} else if (preg_match('/nochg/i', $data)) {
714
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
715
						$successful_update = true;
716
					} else if (preg_match('/good/i', $data)) {
717
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")";
718
						$successful_update = true;
719
					} else if (preg_match('/badauth/i', $data)) {
720
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
721
					} else {
722
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
723
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
724
						$this->_debug($data);
725
					}
726
					break;
727
				case 'ovh-dynhost':
728
				case 'dyndns':
729
					if (preg_match('/notfqdn/i', $data)) {
730
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
731
					} else if (preg_match('/nochg/i', $data)) {
732
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
733
						$successful_update = true;
734
					} else if (preg_match('/good/i', $data)) {
735
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")";
736
						$successful_update = true;
737
					} else if (preg_match('/noauth/i', $data)) {
738
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
739
					} else {
740
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
741
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
742
						$this->_debug($data);
743
					}
744
					break;
745
				case 'dyndns-static':
746
					if (preg_match('/notfqdn/i', $data)) {
747
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
748
					} else if (preg_match('/nochg/i', $data)) {
749
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
750
						$successful_update = true;
751
					} else if (preg_match('/good/i', $data)) {
752
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
753
						$successful_update = true;
754
					} else if (preg_match('/noauth/i', $data)) {
755
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
756
					} else {
757
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
758
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
759
						$this->_debug($data);
760
					}
761
					break;
762
				case 'dyndns-custom':
763
					if (preg_match('/notfqdn/i', $data)) {
764
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Not A FQDN!";
765
					} else if (preg_match('/nochg/i', $data)) {
766
						$status = "phpDynDNS: (Success) No Change In IP Address";
767
						$successful_update = true;
768
					} else if (preg_match('/good/i', $data)) {
769
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
770
						$successful_update = true;
771
					} else if (preg_match('/noauth/i', $data)) {
772
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
773
					} else {
774
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
775
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
776
						$this->_debug($data);
777
					}
778
					break;
779
				case 'dhs':
780
					break;
781
				case 'noip':
782
				case 'noip-free':
783
					list($ip,$code) = explode(":",$data);
784
					switch ($code) {
785
						case 0:
786
							$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP address is current, no update performed.";
787
							$successful_update = true;
788
							break;
789
						case 1:
790
							$status = "phpDynDNS ({$this->_dnsHost}): (Success) DNS hostname update successful.";
791
							$successful_update = true;
792
							break;
793
						case 2:
794
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname supplied does not exist.";
795
							break;
796
						case 3:
797
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid Username.";
798
							break;
799
						case 4:
800
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid Password.";
801
							break;
802
						case 5:
803
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) To many updates sent.";
804
							break;
805
						case 6:
806
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Account disabled due to violation of No-IP terms of service.";
807
							break;
808
						case 7:
809
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid IP. IP Address submitted is improperly formatted or is a private IP address or is on a blacklist.";
810
							break;
811
						case 8:
812
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Disabled / Locked Hostname.";
813
							break;
814
						case 9:
815
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Host updated is configured as a web redirect and no update was performed.";
816
							break;
817
						case 10:
818
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Group supplied does not exist.";
819
							break;
820
						case 11:
821
							$status = "phpDynDNS ({$this->_dnsHost}): (Success) DNS group update is successful.";
822
							$successful_update = true;
823
							break;
824
						case 12:
825
							$status = "phpDynDNS ({$this->_dnsHost}): (Success) DNS group is current, no update performed.";
826
							$successful_update = true;
827
							break;
828
						case 13:
829
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Update client support not available for supplied hostname or group.";
830
							break;
831
						case 14:
832
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname supplied does not have offline settings configured.";
833
							break;
834
						case 99:
835
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Client disabled. Client should exit and not perform any more updates without user intervention.";
836
							break;
837
						case 100:
838
							$status = "phpDynDNS ({$this->_dnsHost}): (Error) Client disabled. Client should exit and not perform any more updates without user intervention.";
839
							break;
840
						default:
841
							$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
842
							$this->_debug("Unknown Response: ".$data);
843
							break;
844
					}
845
					break;
846
				case 'easydns':
847
					if (preg_match('/NOACCESS/i', $data)) {
848
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Authentication Failed: Username and/or Password was Incorrect.";
849
					} else if (preg_match('/NOSERVICE/i', $data)) {
850
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) No Service: Dynamic DNS Service has been disabled for this domain.";
851
					} else if (preg_match('/ILLEGAL INPUT/i', $data)) {
852
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Illegal Input: Self-Explanatory";
853
					} else if (preg_match('/TOOSOON/i', $data)) {
854
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Too Soon: Not Enough Time Has Elapsed Since Last Update";
855
					} else if (preg_match('/NOERROR/i', $data)) {
856
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Updated Successfully!";
857
						$successful_update = true;
858
					} else {
859
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
860
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
861
						$this->_debug($data);
862
					}
863
					break;
864
				case 'hn':
865
					/* FIXME: add checks */
866
					break;
867
				case 'zoneedit':
868
					if (preg_match('/799/i', $data)) {
869
						$status = "phpDynDNS ({$this->_dnsHost}): (Error 799) Update Failed!";				
870
					} else if (preg_match('/700/i', $data)) {
871
						$status = "phpDynDNS ({$this->_dnsHost}): (Error 700) Update Failed!";
872
					} else if (preg_match('/200/i', $data)) {
873
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
874
						$successful_update = true;
875
					} else if (preg_match('/201/i', $data)) {
876
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
877
						$successful_update = true;						
878
					} else {
879
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
880
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
881
						$this->_debug($data);
882
					}
883
					break;
884
				case 'dyns':
885
					if (preg_match("/400/i", $data)) {
886
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad Request - The URL was malformed. Required parameters were not provided.";
887
					} else if (preg_match('/402/i', $data)) {
888
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Update Too Soon - You have tried updating to quickly since last change.";
889
					} else if (preg_match('/403/i', $data)) {
890
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Database Error - There was a server-sided database error.";
891
					} else if (preg_match('/405/i', $data)) {
892
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname Error - The hostname (".$this->_dnsHost.") doesn't belong to you.";
893
					} else if (preg_match('/200/i', $data)) {
894
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
895
						$successful_update = true;
896
					} else {
897
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
898
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
899
						$this->_debug($data);
900
					}
901
					break;
902
				case 'ods':
903
					if (preg_match("/299/i", $data)) {
904
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
905
						$successful_update = true;
906
					} else {
907
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
908
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
909
						$this->_debug($data);
910
					}
911
					break;
912
				case 'freedns':
913
					if (preg_match("/has not changed./i", $data)) {
914
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
915
						$successful_update = true;
916
					} else if (preg_match("/Updated/i", $data)) {
917
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
918
						$successful_update = true;
919
					} else {
920
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
921
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
922
						$this->_debug($data);
923
					} 
924
					break;
925
				case 'dnsexit':
926
					if (preg_match("/is the same/i", $data)) {
927
						$status = "phpDynDns ({$this->_dnsHost}): (Success) No Change In IP Address";
928
						$successful_update = true;
929
					} else if (preg_match("/Success/i", $data)) {
930
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
931
						$successful_update = true;
932
					} else {
933
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
934
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
935
						$this->_debug($data);
936
					}
937
					break;
938
				case 'loopia':
939
					if (preg_match("/nochg/i", $data)) {
940
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address";
941
						$successful_update = true;
942
					} else if (preg_match("/good/i", $data)) {
943
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
944
						$successful_update = true;
945
					} else if (preg_match('/badauth/i', $data)) {
946
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed";
947
					} else {
948
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
949
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
950
						$this->_debug($data);
951
					}
952
					break;
953
				case 'opendns':
954
					if (preg_match('/badauth/i', $data)) {
955
						$status = "phpDynDNS({$this->_dnsHost}): (Error) Not a valid username or password!";
956
					} else if (preg_match('/nohost/i', $data)) {
957
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname you are trying to update does not exist.";
958
						$successful_update = true;
959
					} else if (preg_match('/good/i', $data)) {
960
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")";
961
						$successful_update = true;
962
					} else if (preg_match('/yours/i', $data)) {
963
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) hostname specified exists, but not under the username specified.";
964
					} else if (preg_match('/abuse/i', $data)) {
965
						$status = "phpDynDns ({$this->_dnsHost}): (Error) Updating too frequently, considered abuse.";
966
					} else {
967
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
968
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
969
						$this->_debug($data);
970
					}
971
					break;
972
				case 'staticcling':
973
					if (preg_match("/invalid ip/i", $data)) {
974
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad Request - The IP provided was invalid.";
975
					} else if (preg_match('/required info missing/i', $data)) {
976
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad Request - Required parameters were not provided.";
977
					} else if (preg_match('/invalid characters/i', $data)) {
978
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Bad Request - Illegal characters in either the username or the password.";
979
					} else if (preg_match('/bad password/i', $data)) {
980
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Invalid password.";
981
					} else if (preg_match('/account locked/i', $data)) {
982
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) This account has been administratively locked.";
983
					} else if (preg_match('/update too frequent/i', $data)) {
984
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Updating too frequently.";
985
					} else if (preg_match('/DB error/i', $data)) {
986
						$status = "phpDynDNS ({$this->_dnsHost}): (Error) Server side error.";
987
					} else if (preg_match('/success/i', $data)) {
988
						$status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Updated Successfully!";
989
						$successful_update = true;
990
					} else {
991
						$status = "phpDynDNS ({$this->_dnsHost}): (Unknown Response)";
992
						log_error("phpDynDNS ({$this->_dnsHost}): PAYLOAD: {$data}");
993
						$this->_debug($data);
994
					}
995
					break;
996
				case 'namecheap':
997
					$tmp = str_replace("^M", "", $data);
998
					$ncresponse = @xml2array($tmp);
999
					if (preg_match("/internal server error/i", $data)) {
1000
						$status = "phpDynDNS: (Error) Server side error.";
1001
					} else if (preg_match("/request is badly formed/i", $data)) {
1002
						$status = "phpDynDNS: (Error) Badly Formed Request (check your settings).";
1003
					} else if ($ncresponse['interface-response']['ErrCount'] === "0") {
1004
						$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
1005
						$successful_update = true;
1006
					} else if (is_numeric($ncresponse['interface-response']['ErrCount']) && ($ncresponse['interface-response']['ErrCount'] > 0)) {
1007
						$status = "phpDynDNS: (Error) " . implode(", ", $ncresponse["interface-response"]["errors"]);
1008
						$successful_update = true;
1009
					} else {
1010
						$status = "phpDynDNS: (Unknown Response)";
1011
						log_error("phpDynDNS: PAYLOAD: {$data}");
1012
						$this->_debug($data);
1013
					}
1014
					break;
1015
					
1016
				case 'he-net':
1017
				case 'he-net-v6':
1018
					if (preg_match("/badip/i", $data)) {
1019
						$status = "phpDynDNS: (Error) Bad Request - The IP provided was invalid.";
1020
					} else if (preg_match('/nohost/i', $data)) {
1021
						$status = "phpDynDNS: (Error) Bad Request - A hostname was not provided.";
1022
					} else if (preg_match('/badauth/i', $data)) {
1023
						$status = "phpDynDNS: (Error) Invalid username or password.";
1024
					} else if (preg_match('/good/i', $data)) {
1025
						$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
1026
						$successful_update = true;
1027
					} else if (preg_match('/nochg/i', $data)) {
1028
						$status = "phpDynDNS: (Success) No Change In IP Address.";
1029
						$successful_update = true;
1030
					} else {
1031
						$status = "phpDynDNS: (Unknown Response)";
1032
						log_error("phpDynDNS: PAYLOAD: {$data}");
1033
						$this->_debug($data);
1034
					}
1035
					break;
1036
				case 'he-net-tunnelbroker':
1037
					/*
1038
					-ERROR: Missing parameter(s).
1039
					-ERROR: Invalid API key or password
1040
					-ERROR: Tunnel not found
1041
					-ERROR: Another tunnel exists for this IP.
1042
					-ERROR: This tunnel is already associated with this IP address
1043
					+OK: Tunnel endpoint updated to: x.x.x.x
1044
					*/
1045
					if (preg_match("/Missing parameter/i", $data)) {
1046
						$status = "phpDynDNS: (Error) Bad Request - Missing/Invalid Parameters.";
1047
					} else if (preg_match('/Tunnel not found/i', $data)) {
1048
						$status = "phpDynDNS: (Error) Bad Request - Invalid Tunnel ID.";
1049
					} else if (preg_match('/Invalid API key or password/i', $data)) {
1050
						$status = "phpDynDNS: (Error) Invalid username or password.";
1051
					} else if (preg_match('/OK:/i', $data)) {
1052
						$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
1053
						$successful_update = true;
1054
					} else if (preg_match('/This tunnel is already associated with this IP address/i', $data)) {
1055
						$status = "phpDynDNS: (Success) No Change In IP Address.";
1056
						$successful_update = true;
1057
					} else {
1058
						$status = "phpDynDNS: (Unknown Response)";
1059
						log_error("phpDynDNS: PAYLOAD: {$data}");
1060
						$this->_debug($data);
1061
					}
1062
					break;
1063
				case 'selfhost':
1064
					if (preg_match('/notfqdn/i', $data)) {
1065
						$status = "phpDynDNS: (Error) Not A FQDN!";
1066
					} else if (preg_match('/nochg/i', $data)) {
1067
						$status = "phpDynDNS: (Success) No Change In IP Address";
1068
						$successful_update = true;
1069
					} else if (preg_match('/good/i', $data)) {
1070
						$status = "phpDynDNS: (Success) IP Address Changed Successfully! (".$this->_dnsIP.")";
1071
						$successful_update = true;
1072
					} else if (preg_match('/noauth/i', $data)) {
1073
						$status = "phpDynDNS: (Error) User Authorization Failed";
1074
					} else {
1075
						$status = "phpDynDNS: (Unknown Response)";
1076
						log_error("phpDynDNS: PAYLOAD: {$data}");
1077
						$this->_debug($data);
1078
					}
1079
					break;
1080
				case 'route53':
1081
					$successful_update = true;
1082
					break;
1083
				case 'custom':
1084
				case 'custom-v6':
1085
					$successful_update = false;
1086
					if ($this->_dnsResultMatch == "") {
1087
						$successful_update = true;
1088
					}else {
1089
						$this->_dnsResultMatch = str_replace("%IP%", $this->_dnsIP, $this->_dnsResultMatch);
1090
						$matches = preg_split("/(?<!\\\\)\\|/", $this->_dnsResultMatch);
1091
						foreach($matches as $match) {
1092
							$match= str_replace("\\|", "|", $match);
1093
							if(strcmp($match, trim($data, "\t\n\r")) == 0)
1094
								$successful_update = true;
1095
						}
1096
						unset ($matches);
1097
					}
1098
					if ($successful_update == true)
1099
						$status = "phpDynDNS: (Success) IP Address Updated Successfully!";
1100
					else
1101
						$status = "phpDynDNS: (Error) Result did not match.";
1102
					break;
1103
				case 'cloudflare':
1104
					// recieve multipe results
1105
					$data = explode("\n",$data);
1106
					$lines = count($data)-1;
1107

    
1108
					// loop over the lines
1109
					for ($pos=0; ($successful_update || $pos == 0) && $pos < $lines; $pos++){
1110
						$resp = $data[$pos];
1111
						if (preg_match('/UAUTH/i', $resp)) {
1112
							$status = "DynDNS: The username specified is not authorized to update this hostname and domain.";
1113
						} else if (preg_match('/NOHOST/i', $resp)) {
1114
							$status = "DynDNS: No valid FQDN (fully qualified domain name) was specified";
1115
						} else if (preg_match('/INVLDHST/i', $resp)) {
1116
							$status = "DynDNS: An invalid hostname was specified. This may be due to the fact the hostname has not been created in the system. Creating new host names via clients is not supported.";
1117
						} else if (preg_match('/INVLDIP/i', $resp)) {
1118
							$status = "DynDNS: The IP address given is not valid.";
1119
						} else if (preg_match('/DUPHST/i', $resp)) {
1120
							$status = "DynDNS: Duplicate values exist for a record. Only single values for records are supported currently.";
1121
						} else if (preg_match('/NOUPDATE/i', $resp)) {
1122
							$status = "DynDNS: No changes made to the hostname (".strtok($resp,' ')."). Continual updates with no changes lead to blocked clients.";
1123
							$successful_update = true; //success if it is the same so that it saves
1124
						} else if (preg_match('/OK/i', $resp)) {
1125
							$status = "DynDNS: (Success) (".strtok($resp,' ').") IP Address for Changed Successfully!";
1126
							$successful_update = true;
1127
						} else {
1128
							$status = "DynDNS: (Unknown Response)";
1129
							log_error("DynDNS: PAYLOAD: {$resp}");
1130
							$this->_debug($resp);
1131
						}
1132
						log_error($status);
1133
					}
1134
					break;
1135
				case 'eurodns':
1136
					if (preg_match('/notfqdn/i', $data)) {
1137
						$status = "phpDynDNS: (Error) Not A FQDN!";
1138
					} else if (preg_match('/nochg/i', $data)) {
1139
						$status = "phpDynDNS: (Success) No Change In IP Address";
1140
						$successful_update = true;
1141
					} else if (preg_match('/good/i', $data)) {
1142
						$status = "phpDynDNS: (Success) IP Address Changed Successfully! (".$this->_dnsIP.")";
1143
						$successful_update = true;
1144
					} else if (preg_match('/badauth/i', $data)) {
1145
						$status = "phpDynDNS: (Error) User Authorization Failed";
1146
					} else {
1147
						$status = "phpDynDNS: (Unknown Response)";
1148
						log_error("phpDynDNS: PAYLOAD: {$data}");
1149
						$this->_debug($data);
1150
					}
1151
					break;
1152
				case 'gratisdns':
1153
					if (preg_match('/Forkerte værdier/i', $data)) {
1154
					        $status = "phpDynDNS: (Error) Wrong values - Update could not be completed.";
1155
					} else if (preg_match('/Bruger login: Bruger eksistere ikke/i', $data)) {
1156
					        $status = "phpDynDNS: (Error) Unknown username - User does not exist.";
1157
					} else if (preg_match('/Bruger login: 1Fejl i kodeord/i', $data)) {
1158
					        $status = "phpDynDNS: (Error) Wrong password - Remember password is case sensitive.";
1159
					} else if (preg_match('/Domæne kan IKKE administreres af bruger/i', $data)) {
1160
					        $status = "phpDynDNS: (Error) User unable to administer the selected domain.";
1161
					} else if (preg_match('/OK/i', $data)) {
1162
					        $status = "phpDynDNS: (Success) IP Address Updated Successfully!";
1163
					        $successful_update = true;
1164
					} else {
1165
					        $status = "phpDynDNS: (Unknown Response)";
1166
					        log_error("phpDynDNS: PAYLOAD: {$data}");
1167
					        $this->_debug($data);
1168
					}
1169
					break;
1170
			}
1171
			
1172
			if($successful_update == true) {
1173
				/* Write WAN IP to cache file */
1174
				$wan_ip = $this->_checkIP();
1175
				conf_mount_rw();
1176
				if ($this->_useIPv6 == false && $wan_ip > 0) {
1177
					$currentTime = time();
1178
					notify_all_remote(sprintf(gettext("DynDNS updated IP Address on %s (%s) to %s"), convert_real_interface_to_friendly_descr($this->_if), $this->_if, $wan_ip));
1179
					log_error("phpDynDNS: updating cache file {$this->_cacheFile}: {$wan_ip}");
1180
					@file_put_contents($this->_cacheFile, "{$wan_ip}:{$currentTime}");
1181
				} else
1182
					@unlink($this->_cacheFile);
1183
				if ($this->_useIPv6 == true && $wan_ip > 0) {
1184
					$currentTime = time();
1185
					notify_all_remote(sprintf(gettext("DynDNS updated IPv6 Address on %s (%s) to %s"), convert_real_interface_to_friendly_descr($this->_if), $this->_if, $wan_ip));
1186
					log_error("phpDynDNS: updating cache file {$this->_cacheFile_v6}: {$wan_ip}");
1187
					@file_put_contents($this->_cacheFile_v6, "{$wan_ip}|{$currentTime}");
1188
				} else
1189
					@unlink($this->_cacheFile_v6);
1190
				conf_mount_ro();
1191
			}
1192
			$this->status = $status;
1193
			log_error($status);
1194
		}
1195

    
1196
		/*
1197
		 * Private Function (added 12 July 05) [beta]
1198
		 *   Return Error, Set Last Error, and Die.
1199
		 */
1200
		function _error($errorNumber = '1') {
1201
			switch ($errorNumber) {
1202
				case 0:
1203
					break;
1204
				case 2:
1205
					$error = 'phpDynDNS: (ERROR!) No Dynamic DNS Service provider was selected.';
1206
					break;
1207
				case 3:
1208
					$error = 'phpDynDNS: (ERROR!) No Username Provided.';
1209
					break;
1210
				case 4:
1211
					$error = 'phpDynDNS: (ERROR!) No Password Provided.';
1212
					break;
1213
				case 5:
1214
					$error = 'phpDynDNS: (ERROR!) No Hostname Provided.';
1215
					break;
1216
				case 6:
1217
					$error = 'phpDynDNS: (ERROR!) The Dynamic DNS Service provided is not yet supported.';
1218
					break;
1219
				case 7:
1220
					$error = 'phpDynDNS: (ERROR!) No Update URL Provided.';
1221
					break;
1222
				case 8:
1223
					$status = "Route 53: (Error) Invalid ZoneID";
1224
					break;
1225
				case 9:
1226
					$status = "Route 53: (Error) Invalid TTL";
1227
					break;  
1228
				case 10:
1229
					$error = "phpDynDNS ({$this->_dnsHost}): No change in my IP address and/or " . $this->_dnsMaxCacheAgeDays . " days has not passed. Not updating dynamic DNS entry.";
1230
					break;
1231
				default:
1232
					$error = "phpDynDNS: (ERROR!) Unknown Response.";
1233
					/* FIXME: $data isn't in scope here */
1234
					/* $this->_debug($data); */
1235
					break;
1236
			}
1237
			$this->lastError = $error;
1238
			log_error($error);
1239
		}
1240

    
1241
		/*
1242
		 * Private Function (added 12 July 05) [beta]
1243
		 *   - Detect whether or not IP needs to be updated.
1244
		 *      | Written Specifically for pfSense (https://www.pfsense.org) may
1245
		 *      | work with other systems. pfSense base is FreeBSD.
1246
		 */
1247
		function _detectChange() {
1248
			global $debug;
1249

    
1250
			if ($debug)
1251
				log_error("DynDns ({$this->_dnsHost}): _detectChange() starting.");
1252
		
1253
			$currentTime = time();
1254

    
1255
			$wan_ip = $this->_checkIP();
1256
			if ($wan_ip == 0) {
1257
				log_error("DynDns ({$this->_dnsHost}): Current WAN IP could not be determined, skipping update process.");
1258
				return false;
1259
			}
1260
			$log_error = "DynDns ({$this->_dnsHost}): Current WAN IP: {$wan_ip} ";
1261

    
1262
			if ($this->_useIPv6 == true) {
1263
				if (file_exists($this->_cacheFile_v6)) {
1264
					$contents = file_get_contents($this->_cacheFile_v6);
1265
					list($cacheIP,$cacheTime) = explode('|', $contents);
1266
					$this->_debug($cacheIP.'/'.$cacheTime);
1267
					$initial = false;
1268
					$log_error .= "Cached IPv6: {$cacheIP} ";
1269
				} else {
1270
					conf_mount_rw();
1271
					$cacheIP = '::';
1272
					@file_put_contents($this->_cacheFile, "::|{$currentTime}");
1273
					conf_mount_ro();
1274
					$cacheTime = $currentTime;
1275
					$initial = true;
1276
					$log_error .= "No Cached IPv6 found.";
1277
				}
1278
			} else {
1279
				if (file_exists($this->_cacheFile)) {
1280
					$contents = file_get_contents($this->_cacheFile);
1281
					list($cacheIP,$cacheTime) = explode(':', $contents);
1282
					$this->_debug($cacheIP.'/'.$cacheTime);
1283
					$initial = false;
1284
					$log_error .= "Cached IP: {$cacheIP} ";
1285
				} else {
1286
					conf_mount_rw();
1287
					$cacheIP = '0.0.0.0';
1288
					@file_put_contents($this->_cacheFile, "0.0.0.0:{$currentTime}");
1289
					conf_mount_ro();
1290
					$cacheTime = $currentTime;
1291
					$initial = true;
1292
					$log_error .= "No Cached IP found.";
1293
				}
1294
			}
1295
			if ($this->_dnsVerboseLog)
1296
				log_error($log_error);
1297

    
1298
			// Convert seconds = days * hr/day * min/hr * sec/min
1299
			$maxCacheAgeSecs = $this->_dnsMaxCacheAgeDays * 24 * 60 * 60;
1300

    
1301
			$needs_updating = FALSE;
1302
			/* lets determine if the item needs updating */
1303
			if ($cacheIP != $wan_ip) {
1304
				$needs_updating = true;
1305
				$update_reason = "DynDns: cacheIP != wan_ip.  Updating. ";
1306
				$update_reason .= "Cached IP: {$cacheIP} WAN IP: {$wan_ip} ";
1307
			}
1308
			if (($currentTime - $cacheTime) > $maxCacheAgeSecs) {
1309
				$needs_updating = true;
1310
				$this->_forceUpdateNeeded = true;
1311
				$update_reason = "DynDns: More than " . $this->_dnsMaxCacheAgeDays . " days.  Updating. ";
1312
				$update_reason .= "{$currentTime} - {$cacheTime} > {$maxCacheAgeSecs} ";
1313
			}
1314
			if ($initial == true) {
1315
				$needs_updating = true;
1316
				$update_reason .= "Initial update. ";
1317
			}
1318

    
1319
			/*   finally if we need updating then store the
1320
			 *   new cache value and return true
1321
			 */
1322
			if ($needs_updating == true) {
1323
				if ($this->_dnsVerboseLog)
1324
					log_error("DynDns ({$this->_dnsHost}): {$update_reason}");
1325
				return true;
1326
			}
1327

    
1328
			return false;			
1329
		}
1330

    
1331
		/*
1332
		 * Private Function (added 16 July 05) [beta]
1333
		 *   - Writes debug information to a file.
1334
		 *   - This function is only called when a unknown response
1335
		 *   - status is returned from a DynDNS service provider.
1336
		 */
1337
		function _debug($data) {
1338
			global $g;
1339

    
1340
			if (!$g['debug'])
1341
				return;
1342
			$string = date('m-d-y h:i:s').' - ('.$this->_debugID.') - ['.$this->_dnsService.'] - '.$data."\n";
1343
			conf_mount_rw();
1344
			$file = fopen($this->_debugFile, 'a');
1345
			fwrite($file, $string);
1346
			fclose($file);
1347
			conf_mount_ro();
1348
		}
1349
		function _checkIP() {
1350
			global $debug;
1351

    
1352
			if ($debug)
1353
				log_error("DynDns ({$this->_dnsHost}): _checkIP() starting.");
1354

    
1355
			if ($this->_useIPv6 == true) {
1356
				$ip_address = find_interface_ipv6($this->_if);
1357
				if (!is_ipaddrv6($ip_address))
1358
					return 0;
1359
			} else {
1360
				$ip_address = find_interface_ip($this->_if);
1361
				if (!is_ipaddr($ip_address))
1362
					return 0;
1363
			}
1364
			if ($this->_useIPv6 == false && is_private_ip($ip_address)) {
1365
				$hosttocheck = "checkip.dyndns.org";
1366
				$try = 0;
1367
				while ($try < 3) {
1368
					$checkip = gethostbyname($hosttocheck);
1369
					if (is_ipaddr($checkip))
1370
						break;
1371
					$try++;
1372
				}
1373
				if ($try >= 3) {
1374
					log_error("Dyndns debug information ({$this->_dnsHost}): Could not resolve {$hosttocheck} to IP using interface IP {$ip_address}.");
1375
					return 0;
1376
				}
1377
				$ip_ch = curl_init("http://{$checkip}");
1378
				curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
1379
				curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
1380
				curl_setopt($ip_ch, CURLOPT_INTERFACE, $ip_address);
1381
				curl_setopt($ip_ch, CURLOPT_CONNECTTIMEOUT, '30');
1382
				curl_setopt($ip_ch, CURLOPT_TIMEOUT, 120);
1383
				if ($this->_useIPv6 == false) {
1384
					curl_setopt($ip_ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
1385
				}
1386
				$ip_result_page = curl_exec($ip_ch);
1387
				curl_close($ip_ch);
1388
				$ip_result_decoded = urldecode($ip_result_page);
1389
				preg_match('/Current IP Address: (.*)<\/body>/', $ip_result_decoded, $matches);
1390
				$ip_address = trim($matches[1]);
1391
				if (is_ipaddr($ip_address)) {
1392
					if ($this->_dnsVerboseLog)
1393
						log_error("DynDns ({$this->_dnsHost}): {$ip_address} extracted from {$hosttocheck}");
1394
				} else {
1395
					log_error("DynDns ({$this->_dnsHost}): IP address could not be extracted from {$hosttocheck}");
1396
					return 0;
1397
				}
1398
			} else {
1399
				if ($this->_dnsVerboseLog)
1400
					log_error("DynDns ({$this->_dnsHost}): {$ip_address} extracted from local system.");
1401
			}
1402
			$this->_dnsIP = $ip_address;
1403

    
1404
			return $ip_address;
1405
		}
1406

    
1407
	}
1408

    
1409
?>
(17-17/68)