From 6f2e9b4a0124e494d04d3f87f3b1efe9e6a8db97 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Wed, 29 Jul 2020 20:04:31 -0700 Subject: [PATCH] Fix linode ddns script - Use password rather than account as the API token so that it isn't visible in the API (and also to meet my expectation). Username is ignored. - Split hostname into "foo.bar.biff.blat" into "foo" and "bar.biff.blat" so that it copes with deeper than two domains. - use pwd rather than account as the API token - split hostname into "foo.bar.blat" into "foo" and "bar.blat" so that it copes with deeper than two domains --- linode.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/linode.php b/linode.php index c84f60a..9fc9eab 100644 --- a/linode.php +++ b/linode.php @@ -11,7 +11,7 @@ $hostname = (string)$argv[3]; $ip = (string)$argv[4]; -$API_TOKEN = $account; +$API_TOKEN = $pwd; // check the hostname contains '.' if (strpos($hostname, '.') === false) { @@ -27,14 +27,14 @@ $hostname = explode('.', $hostname); $arrayCount = count($hostname); -if ($arrayCount > 2) { - $subDomain = implode('.', array_slice($hostname, 0, $arrayCount-2)); - $domain = implode('.', array_slice($hostname, $arrayCount-2, 2)); -} else { - $subDomain = '@'; - $domain = implode('.', $hostname); +if ($arrayCount < 2) { + echo 'badparam'; + exit(); } +$subDomain = $hostname[0]; +$domain = implode('.', array_slice($hostname, 1, $arrayCount-1)); + $post = array( 'api_key'=>$account, 'api_action'=>'domain.list'