-
Notifications
You must be signed in to change notification settings - Fork 0
/
no-class-example.php
222 lines (149 loc) · 6.01 KB
/
no-class-example.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?
/*
// HTTP method
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.zetascan.com/v2/check/http/baddomain.org?key=YOURAPIKEY');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Request headers only
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$response = curl_exec($ch);
// Lookup the HTTP status code
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check status codes for a match
if($status == 204) {
echo "No match in Zetascan blacklist or white-list";
} else if($status == 403) {
echo "Request forbidden, check API-key or IP registered";
} else if($status == 200) {
$headers = array();
$data = explode("\n",$response);
$headers['status'] = $data[0];
// Take the HTTP response out, first element
array_shift($data);
// Build an array for our headers
foreach($data as $part){
$middle=explode(":",$part);
$headers[trim($middle[0])] = trim($middle[1]);
}
// Display the score if blacklisted, otherwise if a whitelist
if( $headers[x-zetascan-score] > 0 || $headers[x-zetascan-webscore] > 0) {
echo "Item blacklisted, score " . $headers[x-zetascan-score] . " webscore " . $headers[x-zetascan-webscore];
} else {
echo "Item white-listed";
}
}
// Text method
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.zetascan.com/v2/check/text/baddomain.org?key=d9e7fccc96280b799df429b71c8c508e');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
// Lookup the HTTP status code
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check status codes for a match
if($status == 204) {
echo "No match in Zetascan blacklist or white-list";
} else if($status == 403) {
echo "Request forbidden, check API-key or IP registered";
} else if($status == 200) {
// Read the body and split from the specified API formatting
$head = explode(":", $response);
if($head[0] == "error") {
echo "An error occurred " . $head[1];
} else {
$str = explode(",", $head[1]);
// $str will contain each field as specified below
echo "Blacklist hit => " . $str[0] . "\n";
echo "Whitelist hit => " . $str[1] . "\n";
echo "Whitelist data => " . $str[2] . "\n";
echo "Score => " . $str[3] . "\n";
echo "WebScore => " . $str[4] . "\n";
echo "Sources => ";
// List all sources, comma seperated
for($i = 5; $i < count($str); $i++) {
echo $str[$i] . ",";
}
}
}
// JSON method
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.zetascan.com/v2/check/json/baddomain.org,okdomain.org,badquery?key=d9e7fccc96280b799df429b71c8c508e');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
// Lookup the HTTP status code
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check status codes for a match
if($status == 403) {
echo "Request forbidden, check API-key or IP registered";
} else if($status == 200) {
$json = json_decode($response, true);
// Check for any error messages, auth failure, API-key incorrect, etc.
if( !empty($json["error"]["message"])) {
echo "An error occurred " . $json["error"]["message"];
}
// Loop through each response ( multiple queries can be delimitated by a comma)
for($i = 0; $i < count($json["results"]); $i++) {
echo "Query => " . $json["results"][$i]["item"] . "\n";
// Check for an error message
if($json["results"][$i]["error"]) {
echo "An error occurred " . $json["results"][$i]["error"]["message"] . "\n";
continue;
}
// Print information on the record
if( empty( $json["results"][$i]["wl"] ) && !empty($json["results"][$i]["found"]) ) {
echo "Blacklist hit\n";
} else {
echo "Whitelist hit\n";
echo "Whitelist data => " . $json["results"][$i]["wldata"] . "\n";
}
echo "Score => " . $json["results"][$i]["score"] . "\n";
echo "WebScore => " . $json["results"][$i]["webscore"]. "\n";
echo "\n";
}
}
*/
// Simple JSON method
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.zetascan.com/v2/check/json/baddomain.org,okdomain.org,badquery?key=d9e7fccc96280b799df429b71c8c508e');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
// Lookup the HTTP status code
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check status codes for a match
if($status == 403) {
echo "Request forbidden, check API-key or IP registered";
} else if($status == 200) {
$json = json_decode($response, true);
// Check for any error messages, auth failure, API-key incorrect, etc.
if( !empty($json["error"]["message"])) {
echo "An error occurred " . $json["error"]["message"];
}
// Loop through each response ( multiple queries can be delimitated by a comma)
for($i = 0; $i < count($json["results"]); $i++) {
echo "Query => " . $json["results"][$i]["item"] . "\n";
// Check for an error message
if($json["results"][$i]["error"]) {
echo "An error occurred " . $json["results"][$i]["error"]["message"] . "\n";
continue;
}
print_r($json["results"][$i]);
}
}
// JSONx method
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.zetascan.com/v2/check/jsonx/127.9.9.1?key=d9e7fccc96280b799df429b71c8c508e');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
// Lookup the HTTP status code
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check status codes for a match
if($status == 403) {
echo "Request forbidden, check API-key or IP registered";
} else if($status == 200) {
$json = json_decode($response, true);
// Display the array
print_r($json);
// Display extended information
print_r($json["results"][0]["extended"]);
}
?>