diff --git a/.gitignore b/.gitignore index 7aba2e2..5e5cc8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /setting.josn /ip.csv -/login.txt \ No newline at end of file +/login.txt +/setting.json \ No newline at end of file diff --git a/commands.php b/commands.php index c8f9361..e739823 100644 --- a/commands.php +++ b/commands.php @@ -24,6 +24,7 @@ function loadSettings() { $json = json_decode($filedata, true); //var_dump($json); + //checking it see if function exist only in new versions of PHP if (function_exists("json_last_error")) { $error = json_last_error(); diff --git a/getips.php b/getips.php index 95e8be8..a1df54a 100644 --- a/getips.php +++ b/getips.php @@ -22,7 +22,7 @@ function getIPs($settings) foreach($xml->entry as $entry) { $title = base64_encode($entry->title); //getting ip from dig - $arip = preg_split("/((?title AAAA +short"))); + $arip = preg_split("/((?title)." AAAA +short"))); //may have multiply ips so adds them a different entries. foreach($arip as $ipraw) { diff --git a/he.php b/he.php index f223df9..da24a6d 100644 --- a/he.php +++ b/he.php @@ -3,13 +3,13 @@ require_once "getips.php"; require_once 'commands.php'; require_once 'setting.php'; + $settings = loadSettings(); +saveSettings($settings); $settings = he($settings); -//saveSettings($settings); -print "End\n"; //$settings->username = ""; ///$password = ""; @@ -30,7 +30,11 @@ function he($settings) { print("Current Dir: " . $settings->directory . "\n"); //making dir is doesn't exist if (!file_exists($settings->directory)) { - mkdir($settings->directory, 0700, TRUE); + if (!mkdir($settings->directory, 0700, TRUE)) + { + print "Failed to create place to store data"; + exit(1); + } } if ($settings->debug) { @@ -43,8 +47,7 @@ function he($settings) { getIPs($settings); $address = getAddress($settings); - if ($settings->debug) - echo "IP:" . $address['ip'] . " Host:" . $address['host'] . "\n"; + // $ch = curl_init(); @@ -109,13 +112,16 @@ function he($settings) { function performTest($test, $settings, $ch, $address) { $cmd = str_replace("{ip}", $address['ip'], $test['command']); $cmd = str_replace("{host}", $address['host'], $cmd); - + if ($settings->debug) + { echo "Performing Test..\n"; + echo $cmd."\n"; + } if ($settings->debug) $cmd . "\n"; - $command = shell_exec($test['command']); + $command = shell_exec($cmd); curl_setopt($ch, CURLOPT_URL, $test['url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -207,6 +213,8 @@ function getAddress($settings) { $host = escapeshellcmd(base64_decode($ipdata[0])); $ip = escapeshellcmd(base64_decode($ipdata[1])); $address = array('host' => escapeshellcmd(base64_decode($ipdata[0])), 'ip' => escapeshellcmd(base64_decode($ipdata[1]))); + if ($settings->debug) + echo "IP:" . $address['ip'] . " Host:" . $address['host'] . "\n"; return $address; } @@ -254,8 +262,8 @@ function performRepeat($test, $ch, $address, $settings) { recordSuccess($test, "Pass", $address, $settings); $time = new DateTime("now"); $date = $time->format("c"); - $test->lastdone = $date; - saveSettings($setting); + $test['lastdone'] = $date; + saveSettings($settings); return TRUE; break; } else { diff --git a/setting.php b/setting.php index 39a2c74..c648651 100644 --- a/setting.php +++ b/setting.php @@ -4,7 +4,7 @@ class Setting { public $username = ""; public $password = ""; -public $directory = "/HECT/"; +public $directory = "HECT/"; public $repeat = 50; public $number = 0; public $debug = true;