Skip to content

Commit 630e9e9

Browse files
Fix Webseer CI dependencies and formatting
1 parent 14d784e commit 630e9e9

16 files changed

Lines changed: 1196 additions & 1129 deletions

.github/workflows/plugin-ci-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
run: sudo apt-get update
8686

8787
- name: Install System Dependencies
88-
run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping libapache2-mod-php${{ matrix.php }}
88+
run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping
8989

9090
- name: Start SNMPD Agent and Test
9191
run: |

classes/cURL.php

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function __construct($cookies = true, $cookie = 'cookies.txt', $compression = WE
5757
$this->cookies = $cookies;
5858
$this->debug = $debug;
5959

60-
if ($this->cookies === true){
60+
if ($this->cookies === true) {
6161
$this->cookie($cookie);
6262
}
6363

@@ -67,7 +67,7 @@ function __construct($cookies = true, $cookie = 'cookies.txt', $compression = WE
6767
$this->compression = 0;
6868
}
6969

70-
$this->results = array('result' => 0, 'time' => time(), 'error' => '');
70+
$this->results = ['result' => 0, 'time' => time(), 'error' => ''];
7171
$this->bundle = $config['base_path'] . '/plugins/webseer/ca-bundle.crt';
7272
}
7373

@@ -78,36 +78,37 @@ function cookie($cookie_file) {
7878
$this->cookie_file = $cookie_file;
7979
} elseif (is_writable($cookie_file)) {
8080
$this->cookie_file = $cookie_file;
81-
}else{
81+
} else {
8282
$this->results['error'] = 'The cookie file could not be opened. Make sure this directory has the correct permissions';
8383
}
8484
}
8585

86-
function post($url, $data = array()) {
86+
function post($url, $data = []) {
8787
global $httpcompressions;
8888

8989
$this->debug('Executing Post Request');
9090

91-
$process = curl_init($url);
91+
$process = curl_init($url);
9292
$this->headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
9393

94-
$d = array();
94+
$d = [];
95+
9596
foreach ($data as $i => $j) {
9697
$d[] = "$i=$j";
9798
}
9899

99100
$data = implode('&', $d);
100101

101-
$options = array(
102-
CURLOPT_HTTPHEADER => $this->headers,
103-
CURLOPT_HEADER => true,
104-
CURLOPT_USERAGENT => $this->user_agent,
105-
CURLOPT_TIMEOUT => 4,
106-
CURLOPT_POSTFIELDS => $data,
102+
$options = [
103+
CURLOPT_HTTPHEADER => $this->headers,
104+
CURLOPT_HEADER => true,
105+
CURLOPT_USERAGENT => $this->user_agent,
106+
CURLOPT_TIMEOUT => 4,
107+
CURLOPT_POSTFIELDS => $data,
107108
CURLOPT_RETURNTRANSFER => true,
108109
CURLOPT_FOLLOWLOCATION => true,
109-
CURLOPT_POST => true,
110-
);
110+
CURLOPT_POST => true,
111+
];
111112

112113
if (!empty($this->compression)) {
113114
$options[CURLOPT_ENCODING] = $httpcompressions[$this->compression];
@@ -135,15 +136,15 @@ function get() {
135136

136137
$process = curl_init($url);
137138

138-
$options = array(
139+
$options = [
139140
CURLOPT_HEADER => true,
140141
CURLOPT_USERAGENT => $this->user_agent,
141142
CURLOPT_RETURNTRANSFER => true,
142143
CURLOPT_FOLLOWLOCATION => true,
143144
CURLOPT_MAXREDIRS => 4,
144145
CURLOPT_TIMEOUT => $this->host['timeout_trigger'],
145146
CURLOPT_FAILONERROR => ($this->host['requiresauth'] == '' ? true : false),
146-
);
147+
];
147148

148149
if (!empty($this->compression)) {
149150
$options[CURLOPT_ENCODING] = $httpcompressions[$this->compression];
@@ -152,50 +153,50 @@ function get() {
152153
// CURLOPT_ENCODING => $this->compression,
153154
// CURLOPT_VERBOSE => 1,
154155

155-
156156
// if ($this->cookies == TRUE) CURLOPT_COOKIEFILE => $this->cookie_file,
157157
// if ($this->cookies == TRUE) CURLOPT_COOKIEJAR => $this->cookie_file,
158158

159-
160159
// CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0,
161160
// CURLOPT_SSLVERSION => 3, // FORCE SSL v3
162161

163162
if ($this->proxy_hostname != '') {
164163
$port_http = intval($this->proxy_http_port);
164+
165165
if ($port_http < 0 || $port_http > 65535) {
166-
$port_http = 80;
166+
$port_http = 80;
167167
$this->proxy_http_port = $port_http;
168168
}
169169

170170
$port_https = intval($this->proxy_https_port);
171+
171172
if ($port_https < 0 || $port_https > 65535) {
172-
$port_https = 443;
173+
$port_https = 443;
173174
$this->proxy_https_port = $port_http;
174175
}
175176

176177
$is_https = (substr(strtolower($url), 0, 5) == 'https');
177178

178-
$proxy_opts = array(
179+
$proxy_opts = [
179180
CURLOPT_UNRESTRICTED_AUTH => true,
180181
CURLOPT_PROXY => $this->proxy_hostname,
181182
CURLOPT_PROXYPORT => $is_https ? $port_https : $port_http,
182-
);
183+
];
183184

184185
if ($this->proxy_username != '') {
185186
$proxy_opts[CURLOPT_PROXYUSERPWD] = $this->proxy_username . ':' . $this->proxy_password;
186187
}
187188
} else {
188-
$proxy_opts = array();
189+
$proxy_opts = [];
189190
}
190191

191192
// Disable Cert checking for now
192193
if ($this->host['checkcert'] == '') {
193-
$cert_opts = array(
194-
CURLOPT_SSL_VERIFYPEER => FALSE,
195-
CURLOPT_SSL_VERIFYHOST => FALSE,
196-
);
194+
$cert_opts = [
195+
CURLOPT_SSL_VERIFYPEER => false,
196+
CURLOPT_SSL_VERIFYHOST => false,
197+
];
197198
} else {
198-
$cert_opts = array();
199+
$cert_opts = [];
199200
}
200201

201202
$options += $proxy_opts;
@@ -206,14 +207,15 @@ function get() {
206207

207208
$data = curl_exec($process);
208209

209-
$this->data = str_replace(array("'", "\\"), array(''), $data);
210+
$this->data = str_replace(["'", '\\'], [''], $data);
210211

211-
$this->results['options'] = curl_getinfo($process);
212+
$this->results['options'] = curl_getinfo($process);
212213
$this->results['options']['compression'] = $this->compression;
213214

214215
$errnum = curl_errno($process);
215216

216217
$this->debug('cURL errno: ' . $errnum);
218+
217219
if ($errnum) {
218220
$this->debug('cURL error: ' . curl_error($process));
219221
}
@@ -222,7 +224,7 @@ function get() {
222224
case 0:
223225
break;
224226
default:
225-
$this->results['error'] = 'HTTP ERROR: ' . str_replace(array('"', "'"), '', (curl_error($process)));
227+
$this->results['error'] = 'HTTP ERROR: ' . str_replace(['"', "'"], '', (curl_error($process)));
226228

227229
break;
228230
}
@@ -236,10 +238,10 @@ function get() {
236238
if (strpos($data, $this->host['search_failed']) !== false) {
237239
$this->results['error'] = 'Failure Search string found!';
238240
} else {
239-
$this->results['error'] = '';
241+
$this->results['error'] = '';
240242
$this->results['result'] = 1;
241243
}
242-
}elseif ($errnum == 0) {
244+
} elseif ($errnum == 0) {
243245
$this->debug('Processing search');
244246

245247
if ($this->host['search'] != '') {

classes/index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@
2323
*/
2424

2525
header('Location: ../index.php');
26-

classes/mxlookup.php

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
*/
2424

2525
class mxlookup {
26-
var $dns_socket = NULL;
26+
var $dns_socket = null;
2727
var $QNAME = '';
28-
var $dns_packet = NULL;
28+
var $dns_packet = null;
2929
var $ANCOUNT = 0;
3030
var $cIx = 0;
31-
var $arrMX = array();
31+
var $arrMX = [];
3232
var $dns_repl_domain;
3333

3434
function __construct($domain, $dns = '4.2.2.1') {
@@ -55,20 +55,21 @@ function __construct($domain, $dns = '4.2.2.1') {
5555

5656
for ($ic = 1; $ic <= $this->ANCOUNT; $ic++) {
5757
$QTYPE = ord($this->gdi($this->cIx));
58+
5859
if ($QTYPE !== 1) {
5960
print('[Record not returned]');
6061
die();
6162
}
6263

6364
$this->cIx += 8;
6465

65-
$ip = ord($this->gdi($this->cIx)) . '.' . ord($this->gdi($this->cIx)) . '.' . ord($this->gdi($this->cIx)) . '.' . ord($this->gdi($this->cIx));
66+
$ip = ord($this->gdi($this->cIx)) . '.' . ord($this->gdi($this->cIx)) . '.' . ord($this->gdi($this->cIx)) . '.' . ord($this->gdi($this->cIx));
6667
$this->arrMX[] = $ip;
6768

68-
//$mxPref = ord($this->gdi($this->cIx));
69-
//$this->parse_data($curmx);
70-
//$this->arrMX[] = array('MX_Pref' => $mxPref, 'MX' => $curmx);
71-
//$this->cIx += 3;
69+
// $mxPref = ord($this->gdi($this->cIx));
70+
// $this->parse_data($curmx);
71+
// $this->arrMX[] = array('MX_Pref' => $mxPref, 'MX' => $curmx);
72+
// $this->cIx += 3;
7273
}
7374
}
7475

@@ -77,24 +78,25 @@ function __destruct() {
7778
}
7879

7980
function parse_data(&$retval) {
80-
$arName = array();
81+
$arName = [];
8182
$byte = ord($this->gdi($this->cIx));
8283

83-
while($byte !== 0) {
84-
if ($byte == 192) { //compressed
85-
$tmpIx = $this->cIx;
84+
while ($byte !== 0) {
85+
if ($byte == 192) { // compressed
86+
$tmpIx = $this->cIx;
8687
$this->cIx = ord($this->gdi($cIx));
87-
$tmpName = $retval;
88+
$tmpName = $retval;
8889
$this->parse_data($tmpName);
89-
$retval=$retval . '.' . $tmpName;
90-
$this->cIx = $tmpIx+1;
90+
$retval = $retval . '.' . $tmpName;
91+
$this->cIx = $tmpIx + 1;
92+
9193
return;
9294
}
9395

94-
$retval='';
96+
$retval = '';
9597
$bCount = $byte;
9698

97-
for($b=0;$b<$bCount;$b++) {
99+
for ($b = 0; $b < $bCount; $b++) {
98100
$retval .= $this->gdi($this->cIx);
99101
}
100102

@@ -105,29 +107,29 @@ function parse_data(&$retval) {
105107
$retval = join('.',$arName);
106108
}
107109

108-
function gdi(&$cIx,$bytes=1) {
110+
function gdi(&$cIx,$bytes = 1) {
109111
$this->cIx++;
110112

111-
return(substr($this->dns_reply, $this->cIx-1, $bytes));
113+
return (substr($this->dns_reply, $this->cIx - 1, $bytes));
112114
}
113115

114116
function QNAME($domain) {
115117
$dot_pos = 0;
116118
$temp = '';
117119

118-
while($dot_pos = strpos($domain, '.')) {
120+
while ($dot_pos = strpos($domain, '.')) {
119121
$temp = substr($domain, 0, $dot_pos);
120122
$domain = substr($domain, $dot_pos + 1);
121123
$this->QNAME .= chr(strlen($temp)) . $temp;
122124
}
123125

124-
$this->QNAME .= chr(strlen($domain)) . $domain.chr(0);
126+
$this->QNAME .= chr(strlen($domain)) . $domain . chr(0);
125127
}
126128

127129
function gord($ln = 1) {
128130
$reply = '';
129131

130-
for($i = 0; $i < $ln; $i++){
132+
for ($i = 0; $i < $ln; $i++) {
131133
$reply .= ord(substr($this->dns_reply, $this->cIx, 1));
132134
$this->cIx++;
133135
}
@@ -137,14 +139,14 @@ function gord($ln = 1) {
137139

138140
function pack_dns_packet() {
139141
$this->dns_packet =
140-
chr(0).chr(1).
141-
chr(1).chr(0).
142-
chr(0).chr(1).
143-
chr(0).chr(0).
144-
chr(0).chr(0).
145-
chr(0).chr(0).
142+
chr(0) . chr(1) .
143+
chr(1) . chr(0) .
144+
chr(0) . chr(1) .
145+
chr(0) . chr(0) .
146+
chr(0) . chr(0) .
147+
chr(0) . chr(0) .
146148
$this->QNAME .
147-
chr(0).chr(1).
148-
chr(0).chr(1);
149+
chr(0) . chr(1) .
150+
chr(0) . chr(1);
149151
}
150152
}

0 commit comments

Comments
 (0)