|
|
@@ -27,33 +27,27 @@ class cwp7_Admin {
|
|
|
protected $cwp7Token;
|
|
|
/**
|
|
|
* Constructor
|
|
|
- * @param string $cwp7URL cwp7 URL (example: https://cwp7.my.lan)
|
|
|
- * @param string $username admin/user account's name
|
|
|
+ * @param string $cwp7Host cwp7 hostname or IP (example: cwp7.my.lan)
|
|
|
* @param string $token api token
|
|
|
* @param string $secure optional false to force unsecure (default true)
|
|
|
*/
|
|
|
- function __construct($cwp7URL, $token, $secure=true) {
|
|
|
+ function __construct($cwp7Host, $token, $secure=true) {
|
|
|
if(!in_array('curl', get_loaded_extensions())) {
|
|
|
$this->constructorSuccess = false;
|
|
|
return array('error_msg' => 'Error: PHP curl extension not available');
|
|
|
}
|
|
|
- if (empty($cwp7URL) || empty($token)) {
|
|
|
+ if (empty($cwp7Host) || empty($token)) {
|
|
|
$this->constructorSuccess = false;
|
|
|
return array('error_msg' => 'Error: Server login info missing, check server configuration');
|
|
|
}
|
|
|
- if(preg_match('/^https/', $cwp7URL)) {
|
|
|
+ if($secure) {
|
|
|
$this->cwp7ConType = 'https://';
|
|
|
- if($secure) {
|
|
|
- $this->cwp7Secure = true;
|
|
|
- } else {
|
|
|
- $this->cwp7Secure = false;
|
|
|
- }
|
|
|
+ $this->cwp7Secure = true;
|
|
|
} else {
|
|
|
$this->cwp7ConType = 'http://';
|
|
|
$this->cwp7Secure = false;
|
|
|
}
|
|
|
- $cwp7Hostname = str_replace(array('http://', 'https://'), array('',''), $cwp7URL);
|
|
|
- $cwp7Hostname = explode(':', $cwp7Hostname);
|
|
|
+ $cwp7Hostname = explode(':', $cwp7Host);
|
|
|
if (gethostbyname($cwp7Hostname[0]) == $cwp7Hostname[0] && !filter_var($cwp7Hostname[0], FILTER_VALIDATE_IP)) {
|
|
|
$this->constructorSuccess = false;
|
|
|
return array('error_msg' => 'Error: Cannot resolve ' . $cwp7Hostname[0] . ', check server configuration');
|