Skip to content

Commit

Permalink
Fixing a few things in the new setting system
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:tactmaster/HECT

Conflicts:
	getips.php -- sec fix and merge with new settings system.

Signed-off-by: Edmund Watson <[email protected]>
  • Loading branch information
tactmaster committed Jun 20, 2011
2 parents 2680139 + a2b0ef6 commit 58451af
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/setting.josn
/ip.csv
/login.txt
/login.txt
/setting.json
1 change: 1 addition & 0 deletions commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion getips.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getIPs($settings)
foreach($xml->entry as $entry) {
$title = base64_encode($entry->title);
//getting ip from dig
$arip = preg_split("/((?<!\\\|\r)\n)|((?<!\\\)\r\n)/",trim(shell_exec("dig $entry->title AAAA +short")));
$arip = preg_split("/((?<!\\\|\r)\n)|((?<!\\\)\r\n)/",trim(shell_exec("dig ".escapeshellcmd($entry->title)." AAAA +short")));
//may have multiply ips so adds them a different entries.
foreach($arip as $ipraw)
{
Expand Down
26 changes: 17 additions & 9 deletions he.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -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) {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 58451af

Please sign in to comment.