Visa ett inlägg
Oläst 2010-11-05, 06:25 #10
emilvs avatar
emilv emilv är inte uppkopplad
Bara ett inlägg till!
 
Reg.datum: Feb 2004
Inlägg: 1 564
emilv emilv är inte uppkopplad
Bara ett inlägg till!
emilvs avatar
 
Reg.datum: Feb 2004
Inlägg: 1 564
Loopia har annars DynDNS-stöd som du lätt kan skripta något emot. Så här ser mitt (halvhackiga) skript ut:

PHP-kod:
<?php

$ch 
curl_init();
curl_setopt($chCURLOPT_URL'http://dns.loopia.se/checkip/checkip.php');
curl_setopt($chCURLOPT_TIMEOUT60);
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);

$ip_site curl_exec($ch);
preg_match("/^.*: ([^<]*).*$/"$ip_site$matches);
$current_ip $matches[1];

@
$old_ip file_get_contents('last_ip');

if(
$current_ip == $old_ip) {
        die(
date('Y-m-d H:i:s') . ': IP not updated'."\n");
}

function 
updateip($host$ip) {
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL"http://dns.loopia.se/XDynDNSServer/XDynD\
NS.php?hostname=
{$host}&myip={$ip}&wildcard=NOCHG");
        
curl_setopt($chCURLOPT_TIMEOUT60);
        
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
        
curl_setopt($chCURLOPT_FOLLOWLOCATIONFALSE);
        
curl_setopt($chCURLOPT_HTTPAUTHCURLAUTH_ANY);
        
curl_setopt($chCURLOPT_USERPWD"blaha:password"); //user:pass here
//      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);                        
        
echo "{$host}: ".curl_exec($ch) ."\n";
}
echo 
"New ip: $current_ip\n";

$sites = array('sajt.com''sajt2.com''sajt3.se');

foreach(
$sites as $site) {
        
updateip($site$current_ip);
        
updateip("www.$site"$current_ip);
}
echo 
"\n";

file_put_contents('last_ip'$current_ip);
?>
Jag kör det i crontab var tionde minut. Ge dina domäner hos Loopia en låg TTL (5-10 minuter) så cachas de inte så lång tid och uppdateringarna slår igenom fort.
emilv är inte uppkopplad   Svara med citatSvara med citat