-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate-settings.php
71 lines (66 loc) · 2.12 KB
/
validate-settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require(__DIR__."/lib/Settings.php");
use ascio\whmcs\tools\Settings;
use ascio\whmcs\tools\SettingsTest;
header('Content-Type: application/json');
class AccountValidation {
/**
* @var Settings $settings
*/
protected $settings;
/**
* @var SettingsTest $settingsTest
*/
protected $settingsTest;
/**
* @var bool $testMode
*/
private $testMode;
private $env;
public function __construct()
{
global $_GET;
$this->settings = new Settings("mod_asciossl_settings");
$this->settings->readDb();
$this->settingsTest = new SettingsTest($this->settings);
$this->testMode = $_GET["environment"] == "testing";
$this->env = $_GET["environment"];
}
public function testDomainAccount () {
$error = false;
$result = "";
try {
$sessionId = $this->settingsTest->login($this->testMode);
$this->settingsTest->availability($this->testMode,$sessionId);
$result .= "Availability Check ".$this->env." OK<br/>";
$this->settingsTest->logout($this->testMode,$sessionId);
} catch (\Exception $e) {
$result .= "Error: ".$e->getCode()." - ".$e->getMessage()."<br/>";
$error = true;
}
return json_encode(["message" => $result, "error" => $error]);
}
public function testDnsAccount () {
$error = false;
$result = "";
try {
$this->settingsTest->dns();
$result .= "DNS Live OK<br/>";
} catch (\Exception $e) {
$result .= "Error: ".$e->getCode()." - ".$e->getMessage()."<br/>";
$error = true;
}
return json_encode(["message" => $result, "error" => $error]);
}
}
if($_SESSION["adminid"] < 1) {
echo "Invalid Session";
die();
}
$result = "";
$accountValidation = new AccountValidation();
switch($_GET["type"]) {
case "domain" : echo $accountValidation->testDomainAccount(); break;
case "dns" : echo $accountValidation->testDnsAccount(); break;
default : echo "please specify a type";
}