Hoe lees ik deze array correct uit...
Onderstaand whois script heb ik aangepast om bepaalde domeinnamen te blokkeren(zodat er geen whois info verschijnt).
tevens ben ik bezig een om indien een .nl domeinnaam wordt opgevraagd, dat dan alleen de juiste houder gegevens worden getoont.
de gegevens van de houder zoals adres telfoon etc. mag niet meer. vandaar dat ik de whois query in een array wil hebben en daar de owner, status, admin cont, registrar, tech cont, nameservers etc uit wil halen.
nu heb ik dit op een heel (slordige manier voor elkaar gekregen) terwijl ik niet veel kennis heb van php.
vraag me toch af wij mij kan uitleggen hoe ik dit beter kan doen ipv. onderstaande zodat het ook goed werkt.
ik begrijp dat ik een array nodig heb zoals:
Array
(
[Domain name] => waarde
[status] => waarde
[registrar] => waarde
[technical contact] => waarde
[nameservers] => waarde
)
en deze dan kan opvragen met bv.
print $array['domain name'];
maar het wil maar niet lukken, wat doe ik verkeerd?
heeft iemand een simpel voorbeeld, zodat ik de gegevens juist in de array zet..
Code (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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<?php
$domain = $_GET['domain'];
$verboden = array ( 'verboden-domein1.nl' , 'verboden-domein2.nl' , '#' );
if ( in_array ( $domain , $verboden ) )
{
print "<br><br><center><b>Gegevens op basis van: Wet bescherming van persoonsgegevens, <br>geblokkeerd op verzoek registrant.</b></center><br>";
}
else {
$whoisservers = array(
"ac" =>"whois.nic.ac",
"ae" =>"whois.nic.ae",
"aero"=>"whois.aero",
"af" =>"whois.nic.af",
"ag" =>"whois.nic.ag",
"al" =>"whois.ripe.net",
"am" =>"whois.amnic.net",
"arpa" =>"whois.iana.org",
"as" =>"whois.nic.as",
"asia" =>"whois.nic.asia",
"at" =>"whois.nic.at",
"au" =>"whois.aunic.net",
"az" =>"whois.ripe.net",
"ba" =>"whois.ripe.net",
"be" =>"whois.dns.be",
"bg" =>"whois.register.bg",
"bi" =>"whois.nic.bi",
"biz" =>"whois.biz",
"bj" =>"whois.nic.bj",
"br" =>"whois.registro.br",
"bt" =>"whois.netnames.net",
"by" =>"whois.ripe.net",
"bz" =>"whois.belizenic.bz",
"ca" =>"whois.cira.ca",
"cat" =>"whois.cat",
"cc" =>"whois.nic.cc",
"cd" =>"whois.nic.cd",
"ch" =>"whois.nic.ch",
"ci" =>"whois.nic.ci",
"ck" =>"whois.nic.ck",
"cl" =>"whois.nic.cl",
"cn" =>"whois.cnnic.net.cn",
"com" =>"whois.verisign-grs.com",
"coop" =>"whois.nic.coop",
"cx" =>"whois.nic.cx",
"cy" =>"whois.ripe.net",
"cz" =>"whois.nic.cz",
"de" =>"whois.denic.de",
"dk" =>"whois.dk-hostmaster.dk",
"dm" =>"whois.nic.cx",
"dz" =>"whois.ripe.net",
"edu" =>"whois.educause.edu",
"ee" =>"whois.eenet.ee",
"eg" =>"whois.ripe.net",
"es" =>"whois.ripe.net",
"eu" =>"whois.eu",
"fi" =>"whois.ficora.fi",
"fo" =>"whois.ripe.net",
"fr" =>"whois.nic.fr",
"gb" =>"whois.ripe.net",
"gd" =>"whois.adamsnames.com",
"ge" =>"whois.ripe.net",
"gg" =>"whois.channelisles.net",
"gi" =>"whois2.afilias-grs.net",
"gl" =>"whois.ripe.net",
"gm" =>"whois.ripe.net",
"gov" =>"whois.nic.gov",
"gr" =>"whois.ripe.net",
"gs" =>"whois.nic.gs",
"gw" =>"whois.nic.gw",
"gy" =>"whois.registry.gy",
"hk" =>"whois.hkirc.hk",
"hm" =>"whois.registry.hm",
"hn" =>"whois2.afilias-grs.net",
"hr" =>"whois.ripe.net",
"hu" =>"whois.nic.hu",
"ie" =>"whois.domainregistry.ie",
"il" =>"whois.isoc.org.il",
"in" =>"whois.inregistry.net",
"info" =>"whois.afilias.info",
"int" =>"whois.iana.org",
"io" =>"whois.nic.io",
"iq" =>"vrx.net",
"ir" =>"whois.nic.ir",
"is" =>"whois.isnic.is",
"it" =>"whois.nic.it",
"je" =>"whois.channelisles.net",
"jobs" =>"jobswhois.verisign-grs.com",
"jp" =>"whois.jprs.jp",
"ke" =>"whois.kenic.or.ke",
"kg" =>"www.domain.kg",
"ki" =>"whois.nic.ki",
"kr" =>"whois.nic.or.kr",
"kz" =>"whois.nic.kz",
"la" =>"whois.nic.la",
"li" =>"whois.nic.li",
"lt" =>"whois.domreg.lt",
"lu" =>"whois.dns.lu",
"lv" =>"whois.nic.lv",
"ly" =>"whois.nic.ly",
"ma" =>"whois.iam.net.ma",
"mc" =>"whois.ripe.net",
"md" =>"whois.ripe.net",
"me" =>"whois.meregistry.net",
"mg" =>"whois.nic.mg",
"mil" =>"whois.nic.mil",
"mn" =>"whois.nic.mn",
"mobi" =>"whois.dotmobiregistry.net",
"ms" =>"whois.adamsnames.tc",
"mt" =>"whois.ripe.net",
"mu" =>"whois.nic.mu",
"museum" =>"whois.museum",
"mx" =>"whois.nic.mx",
"my" =>"whois.mynic.net.my",
"na" =>"whois.na-nic.com.na",
"name" =>"whois.nic.name",
"net" =>"whois.verisign-grs.net",
"nf" =>"whois.nic.nf",
"nl" =>"rwhois.domain-registry.nl",
"no" =>"whois.norid.no",
"nu" =>"whois.nic.nu",
"nz" =>"whois.srs.net.nz",
"org" =>"whois.pir.org",
"pl" =>"whois.dns.pl",
"pm" =>"whois.nic.pm",
"pr" =>"whois.uprr.pr",
"pro" =>"whois.registrypro.pro",
"pt" =>"whois.dns.pt",
"re" =>"whois.nic.re",
"ro" =>"whois.rotld.ro",
"ru" =>"whois.ripn.net",
"sa" =>"whois.nic.net.sa",
"sb" =>"whois.nic.net.sb",
"sc" =>"whois2.afilias-grs.net",
"se" =>"whois.iis.se",
"sg" =>"whois.nic.net.sg",
"sh" =>"whois.nic.sh",
"si" =>"whois.arnes.si",
"sk" =>"whois.ripe.net",
"sm" =>"whois.ripe.net",
"st" =>"whois.nic.st",
"su" =>"whois.ripn.net",
"tc" =>"whois.adamsnames.tc",
"tel" =>"whois.nic.tel",
"tf" =>"whois.nic.tf",
"th" =>"whois.thnic.net",
"tj" =>"whois.nic.tj",
"tk" =>"whois.dot.tk",
"tl" =>"whois.nic.tl",
"tm" =>"whois.nic.tm",
"tn" =>"whois.ripe.net",
"to" =>"whois.tonic.to",
"tp" =>"whois.nic.tl",
"tr" =>"whois.nic.tr",
"travel" =>"whois.nic.travel",
"tv" => "tvwhois.verisign-grs.com",
"tw" =>"whois.twnic.net.tw",
"ua" =>"whois.net.ua",
"ug" =>"whois.co.ug",
"uk" =>"whois.nic.uk",
"us" =>"whois.nic.us",
"uy" =>"nic.uy",
"uz" =>"whois.cctld.uz",
"va" =>"whois.ripe.net",
"vc" =>"whois2.afilias-grs.net",
"ve" =>"whois.nic.ve",
"vg" =>"whois.adamsnames.tc",
"wf" =>"whois.nic.wf",
"ws" =>"whois.website.ws",
"yt" =>"whois.nic.yt",
"yu" =>"whois.ripe.net");
function LookupDomain($domain){
global $whoisservers;
$whoisserver = "";
foreach($whoisservers as $tld=>$server) {
if(substr($domain, -strlen($tld)) == $tld) {
$whoisserver = $server;
break;
}
}
if(!$whoisserver) {
return "Error: No appropriate Whois server found for $domain domain!";
}
$result = QueryWhoisServer($whoisserver, $domain);
if($whoisserver == "rwhois.domain-registry.nl") {
return " ";
}
else {
if(!$result) {
return "Error: No results retrieved from $whoisserver server for $domain domain!";
}
else {
while(strpos($result, "Whois Server:") !== FALSE){
preg_match("/Whois Server: (.*)/", $result, $matches);
$secondary = $matches[1];
if($secondary) {
$result = QueryWhoisServer($secondary, $domain);
$whoisserver = $secondary;
}
}
}
return "$domain domain lookup results from $whoisserver server:\n\n" . $result;
}
}
function LookupIP($ip) {
$whoisservers = array(
//"whois.afrinic.net", // Africa - returns timeout error :-(
"whois.lacnic.net", // Latin America and Caribbean - returns data for ALL locations worldwide :-)
"whois.apnic.net", // Asia/Pacific only
"whois.arin.net", // North America only
"whois.ripe.net" // Europe, Middle East and Central Asia only
);
$results = array();
foreach($whoisservers as $whoisserver) {
$result = QueryWhoisServer($whoisserver, $ip);
if($result && !in_array($result, $results)) {
$results[$whoisserver]= $result;
}
}
$res = "RESULTS FOUND: " . count($results);
foreach($results as $whoisserver=>$result) {
$res .= "\n\n-------------\nLookup results for $ip from $whoisserver server:\n\n$result";
}
return $res;
}
function ValidateIP($ip) {
$ipnums = explode(".", $ip);
if(count($ipnums) != 4) {
return false;
}
foreach($ipnums as $ipnum) {
if(!is_numeric($ipnum) || ($ipnum > 255)) {
return false;
}
}
return $ip;
}
function ValidateDomain($domain) {
if(!preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i", $domain)) {
return false;
}
return $domain;
}
function QueryWhoisServer($whoisserver, $domain) {
$port = 43;
$timeout = 10;
$fp = @fsockopen($whoisserver, $port, $errno, $errstr, $timeout) or die("Socket Error " . $errno . " - " . $errstr);
if($whoisserver == "whois.verisign-grs.com") $domain = "=".$domain; // whois.verisign-grs.com requires the equals sign ("=") or it returns any result containing the searched string.
fputs($fp, $domain . "\r\n");
$out = "";
while(!feof($fp)){
$out .= fgets($fp);
}
fclose($fp);
////// begin whois filter array
if($whoisserver == "rwhois.domain-registry.nl") {
print "<br><br><b>Gegevens op basis van: Wet bescherming van persoonsgegevens</b><br>";
$res = "";
if((strpos(strtolower($out), "error") === FALSE) && (strpos(strtolower($out), "not allocated") === FALSE)) {
$rows = explode("\n", $out);
//echo "<br>rows<br>";
//print_r($rows);
//om de array nummers te laten zien
//print_r (explode("\n", $out));
//echo "<br>out<br>";
//print_r($out);
$data = explode("\n", substr($out, 0, -1));
//echo "<br>data<br>";
//print_r($data);
$dataarray = array();
foreach($data as $key => $explode) {
$explode2 = explode("=>", $explode);
$explode2 = explode(":", $explode);
$dataarray[$explode2[0]] = $explode2[1];
}
//echo "<br>dataarray<br>";
//print_r($dataarray);
/*
##################################
echo "<br>";
echo "Domainname:";
echo $dataarray['Domain name'];
echo "<br>";
echo "Status:";
echo $dataarray['Status'];
echo "<br>";
echo "Registrant:";
echo $dataarray['Registrant'];
echo "<br>";
echo "Administrative contact:";
echo $dataarray['Administrative contact'];
echo "<br>";
echo "Registrar:";
echo $dataarray['Registrar'];
echo "<br>";
echo "Technical contact(s):";
echo $dataarray['Technical contact(s):'];
echo "<br>";
echo "Domain nameservers:";
echo $dataarray['Domain nameservers'];
##################################
*/
$textToMatch = $data[25];
if(strstr($out, $textToMatch) != '*+*'){
// hieronder de regelnummers die je wilt tonen toevoegen indien technisch contact GEEN adres heeft.
echo "<br><br>" . $rows['0'] . "<br><br>" . $rows['1'] . "<br><br>" . $rows['3'] . "<br>" . $rows['5'] . "<br><br>" . $rows['10'] . "<br>" . $rows['14'] . "<br><br>" . $rows['16'] . "<br>" . $rows['17'] . "<br>" . $rows['18'] . "<br>" . $rows['19'] . "<br>" . $rows['20'] . "<br><br>" . $rows['22'] . "<br>" . $rows['26'] . "<br><br>" . $rows['28'] . "<br>" . $rows['29'] . "<br>" . $rows['30'] . "<br>" . $rows['31'] ."<br><br>" . $rows['33'] ."<br><br>" . $rows['35'] . "<br><br><br>";
} else {
// hieronder de regelnummers die je wilt tonen toevoegen indien technisch contact WEL EEN adres geeft.
echo "<br><br>" . $rows['0'] . "<br><br>" . $rows['1'] . "<br><br>" . $rows['3'] . "<br>" . $rows['5'] . "<br><br>" . $rows['10'] . "<br>" . $rows['14'] . "<br><br>" . $rows['16'] . "<br>" . $rows['17'] . "<br>" . $rows['18'] . "<br>" . $rows['19'] . "<br>" . $rows['20'] . "<br><br>" . $rows['22'] . "<br>" . $rows['27'] . "<br><br>" . $rows['28'] . "<br>" . $rows['29'] . "<br>" . $rows['30'] . "<br>" . $rows['31'] ."<br><br>" . $rows['32'] ."<br><br>" . $rows['33'] ."<br><br>" . $rows['35'] . "<br><br><br>";
}
foreach($rows as $row) {
$row = trim($row);
if(($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
$res .= $row."\n";
}
}
}
//return $res;
}
else {
////// einde whois filter array
$res = "";
if((strpos(strtolower($out), "error") === FALSE) && (strpos(strtolower($out), "not allocated") === FALSE)) {
$rows = explode("\n", $out);
foreach($rows as $row) {
$row = trim($row);
if(($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
$res .= $row."\n";
}
}
}
return $res;
}
}
?>
$domain = $_GET['domain'];
$verboden = array ( 'verboden-domein1.nl' , 'verboden-domein2.nl' , '#' );
if ( in_array ( $domain , $verboden ) )
{
print "<br><br><center><b>Gegevens op basis van: Wet bescherming van persoonsgegevens, <br>geblokkeerd op verzoek registrant.</b></center><br>";
}
else {
$whoisservers = array(
"ac" =>"whois.nic.ac",
"ae" =>"whois.nic.ae",
"aero"=>"whois.aero",
"af" =>"whois.nic.af",
"ag" =>"whois.nic.ag",
"al" =>"whois.ripe.net",
"am" =>"whois.amnic.net",
"arpa" =>"whois.iana.org",
"as" =>"whois.nic.as",
"asia" =>"whois.nic.asia",
"at" =>"whois.nic.at",
"au" =>"whois.aunic.net",
"az" =>"whois.ripe.net",
"ba" =>"whois.ripe.net",
"be" =>"whois.dns.be",
"bg" =>"whois.register.bg",
"bi" =>"whois.nic.bi",
"biz" =>"whois.biz",
"bj" =>"whois.nic.bj",
"br" =>"whois.registro.br",
"bt" =>"whois.netnames.net",
"by" =>"whois.ripe.net",
"bz" =>"whois.belizenic.bz",
"ca" =>"whois.cira.ca",
"cat" =>"whois.cat",
"cc" =>"whois.nic.cc",
"cd" =>"whois.nic.cd",
"ch" =>"whois.nic.ch",
"ci" =>"whois.nic.ci",
"ck" =>"whois.nic.ck",
"cl" =>"whois.nic.cl",
"cn" =>"whois.cnnic.net.cn",
"com" =>"whois.verisign-grs.com",
"coop" =>"whois.nic.coop",
"cx" =>"whois.nic.cx",
"cy" =>"whois.ripe.net",
"cz" =>"whois.nic.cz",
"de" =>"whois.denic.de",
"dk" =>"whois.dk-hostmaster.dk",
"dm" =>"whois.nic.cx",
"dz" =>"whois.ripe.net",
"edu" =>"whois.educause.edu",
"ee" =>"whois.eenet.ee",
"eg" =>"whois.ripe.net",
"es" =>"whois.ripe.net",
"eu" =>"whois.eu",
"fi" =>"whois.ficora.fi",
"fo" =>"whois.ripe.net",
"fr" =>"whois.nic.fr",
"gb" =>"whois.ripe.net",
"gd" =>"whois.adamsnames.com",
"ge" =>"whois.ripe.net",
"gg" =>"whois.channelisles.net",
"gi" =>"whois2.afilias-grs.net",
"gl" =>"whois.ripe.net",
"gm" =>"whois.ripe.net",
"gov" =>"whois.nic.gov",
"gr" =>"whois.ripe.net",
"gs" =>"whois.nic.gs",
"gw" =>"whois.nic.gw",
"gy" =>"whois.registry.gy",
"hk" =>"whois.hkirc.hk",
"hm" =>"whois.registry.hm",
"hn" =>"whois2.afilias-grs.net",
"hr" =>"whois.ripe.net",
"hu" =>"whois.nic.hu",
"ie" =>"whois.domainregistry.ie",
"il" =>"whois.isoc.org.il",
"in" =>"whois.inregistry.net",
"info" =>"whois.afilias.info",
"int" =>"whois.iana.org",
"io" =>"whois.nic.io",
"iq" =>"vrx.net",
"ir" =>"whois.nic.ir",
"is" =>"whois.isnic.is",
"it" =>"whois.nic.it",
"je" =>"whois.channelisles.net",
"jobs" =>"jobswhois.verisign-grs.com",
"jp" =>"whois.jprs.jp",
"ke" =>"whois.kenic.or.ke",
"kg" =>"www.domain.kg",
"ki" =>"whois.nic.ki",
"kr" =>"whois.nic.or.kr",
"kz" =>"whois.nic.kz",
"la" =>"whois.nic.la",
"li" =>"whois.nic.li",
"lt" =>"whois.domreg.lt",
"lu" =>"whois.dns.lu",
"lv" =>"whois.nic.lv",
"ly" =>"whois.nic.ly",
"ma" =>"whois.iam.net.ma",
"mc" =>"whois.ripe.net",
"md" =>"whois.ripe.net",
"me" =>"whois.meregistry.net",
"mg" =>"whois.nic.mg",
"mil" =>"whois.nic.mil",
"mn" =>"whois.nic.mn",
"mobi" =>"whois.dotmobiregistry.net",
"ms" =>"whois.adamsnames.tc",
"mt" =>"whois.ripe.net",
"mu" =>"whois.nic.mu",
"museum" =>"whois.museum",
"mx" =>"whois.nic.mx",
"my" =>"whois.mynic.net.my",
"na" =>"whois.na-nic.com.na",
"name" =>"whois.nic.name",
"net" =>"whois.verisign-grs.net",
"nf" =>"whois.nic.nf",
"nl" =>"rwhois.domain-registry.nl",
"no" =>"whois.norid.no",
"nu" =>"whois.nic.nu",
"nz" =>"whois.srs.net.nz",
"org" =>"whois.pir.org",
"pl" =>"whois.dns.pl",
"pm" =>"whois.nic.pm",
"pr" =>"whois.uprr.pr",
"pro" =>"whois.registrypro.pro",
"pt" =>"whois.dns.pt",
"re" =>"whois.nic.re",
"ro" =>"whois.rotld.ro",
"ru" =>"whois.ripn.net",
"sa" =>"whois.nic.net.sa",
"sb" =>"whois.nic.net.sb",
"sc" =>"whois2.afilias-grs.net",
"se" =>"whois.iis.se",
"sg" =>"whois.nic.net.sg",
"sh" =>"whois.nic.sh",
"si" =>"whois.arnes.si",
"sk" =>"whois.ripe.net",
"sm" =>"whois.ripe.net",
"st" =>"whois.nic.st",
"su" =>"whois.ripn.net",
"tc" =>"whois.adamsnames.tc",
"tel" =>"whois.nic.tel",
"tf" =>"whois.nic.tf",
"th" =>"whois.thnic.net",
"tj" =>"whois.nic.tj",
"tk" =>"whois.dot.tk",
"tl" =>"whois.nic.tl",
"tm" =>"whois.nic.tm",
"tn" =>"whois.ripe.net",
"to" =>"whois.tonic.to",
"tp" =>"whois.nic.tl",
"tr" =>"whois.nic.tr",
"travel" =>"whois.nic.travel",
"tv" => "tvwhois.verisign-grs.com",
"tw" =>"whois.twnic.net.tw",
"ua" =>"whois.net.ua",
"ug" =>"whois.co.ug",
"uk" =>"whois.nic.uk",
"us" =>"whois.nic.us",
"uy" =>"nic.uy",
"uz" =>"whois.cctld.uz",
"va" =>"whois.ripe.net",
"vc" =>"whois2.afilias-grs.net",
"ve" =>"whois.nic.ve",
"vg" =>"whois.adamsnames.tc",
"wf" =>"whois.nic.wf",
"ws" =>"whois.website.ws",
"yt" =>"whois.nic.yt",
"yu" =>"whois.ripe.net");
function LookupDomain($domain){
global $whoisservers;
$whoisserver = "";
foreach($whoisservers as $tld=>$server) {
if(substr($domain, -strlen($tld)) == $tld) {
$whoisserver = $server;
break;
}
}
if(!$whoisserver) {
return "Error: No appropriate Whois server found for $domain domain!";
}
$result = QueryWhoisServer($whoisserver, $domain);
if($whoisserver == "rwhois.domain-registry.nl") {
return " ";
}
else {
if(!$result) {
return "Error: No results retrieved from $whoisserver server for $domain domain!";
}
else {
while(strpos($result, "Whois Server:") !== FALSE){
preg_match("/Whois Server: (.*)/", $result, $matches);
$secondary = $matches[1];
if($secondary) {
$result = QueryWhoisServer($secondary, $domain);
$whoisserver = $secondary;
}
}
}
return "$domain domain lookup results from $whoisserver server:\n\n" . $result;
}
}
function LookupIP($ip) {
$whoisservers = array(
//"whois.afrinic.net", // Africa - returns timeout error :-(
"whois.lacnic.net", // Latin America and Caribbean - returns data for ALL locations worldwide :-)
"whois.apnic.net", // Asia/Pacific only
"whois.arin.net", // North America only
"whois.ripe.net" // Europe, Middle East and Central Asia only
);
$results = array();
foreach($whoisservers as $whoisserver) {
$result = QueryWhoisServer($whoisserver, $ip);
if($result && !in_array($result, $results)) {
$results[$whoisserver]= $result;
}
}
$res = "RESULTS FOUND: " . count($results);
foreach($results as $whoisserver=>$result) {
$res .= "\n\n-------------\nLookup results for $ip from $whoisserver server:\n\n$result";
}
return $res;
}
function ValidateIP($ip) {
$ipnums = explode(".", $ip);
if(count($ipnums) != 4) {
return false;
}
foreach($ipnums as $ipnum) {
if(!is_numeric($ipnum) || ($ipnum > 255)) {
return false;
}
}
return $ip;
}
function ValidateDomain($domain) {
if(!preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i", $domain)) {
return false;
}
return $domain;
}
function QueryWhoisServer($whoisserver, $domain) {
$port = 43;
$timeout = 10;
$fp = @fsockopen($whoisserver, $port, $errno, $errstr, $timeout) or die("Socket Error " . $errno . " - " . $errstr);
if($whoisserver == "whois.verisign-grs.com") $domain = "=".$domain; // whois.verisign-grs.com requires the equals sign ("=") or it returns any result containing the searched string.
fputs($fp, $domain . "\r\n");
$out = "";
while(!feof($fp)){
$out .= fgets($fp);
}
fclose($fp);
////// begin whois filter array
if($whoisserver == "rwhois.domain-registry.nl") {
print "<br><br><b>Gegevens op basis van: Wet bescherming van persoonsgegevens</b><br>";
$res = "";
if((strpos(strtolower($out), "error") === FALSE) && (strpos(strtolower($out), "not allocated") === FALSE)) {
$rows = explode("\n", $out);
//echo "<br>rows<br>";
//print_r($rows);
//om de array nummers te laten zien
//print_r (explode("\n", $out));
//echo "<br>out<br>";
//print_r($out);
$data = explode("\n", substr($out, 0, -1));
//echo "<br>data<br>";
//print_r($data);
$dataarray = array();
foreach($data as $key => $explode) {
$explode2 = explode("=>", $explode);
$explode2 = explode(":", $explode);
$dataarray[$explode2[0]] = $explode2[1];
}
//echo "<br>dataarray<br>";
//print_r($dataarray);
/*
##################################
echo "<br>";
echo "Domainname:";
echo $dataarray['Domain name'];
echo "<br>";
echo "Status:";
echo $dataarray['Status'];
echo "<br>";
echo "Registrant:";
echo $dataarray['Registrant'];
echo "<br>";
echo "Administrative contact:";
echo $dataarray['Administrative contact'];
echo "<br>";
echo "Registrar:";
echo $dataarray['Registrar'];
echo "<br>";
echo "Technical contact(s):";
echo $dataarray['Technical contact(s):'];
echo "<br>";
echo "Domain nameservers:";
echo $dataarray['Domain nameservers'];
##################################
*/
$textToMatch = $data[25];
if(strstr($out, $textToMatch) != '*+*'){
// hieronder de regelnummers die je wilt tonen toevoegen indien technisch contact GEEN adres heeft.
echo "<br><br>" . $rows['0'] . "<br><br>" . $rows['1'] . "<br><br>" . $rows['3'] . "<br>" . $rows['5'] . "<br><br>" . $rows['10'] . "<br>" . $rows['14'] . "<br><br>" . $rows['16'] . "<br>" . $rows['17'] . "<br>" . $rows['18'] . "<br>" . $rows['19'] . "<br>" . $rows['20'] . "<br><br>" . $rows['22'] . "<br>" . $rows['26'] . "<br><br>" . $rows['28'] . "<br>" . $rows['29'] . "<br>" . $rows['30'] . "<br>" . $rows['31'] ."<br><br>" . $rows['33'] ."<br><br>" . $rows['35'] . "<br><br><br>";
} else {
// hieronder de regelnummers die je wilt tonen toevoegen indien technisch contact WEL EEN adres geeft.
echo "<br><br>" . $rows['0'] . "<br><br>" . $rows['1'] . "<br><br>" . $rows['3'] . "<br>" . $rows['5'] . "<br><br>" . $rows['10'] . "<br>" . $rows['14'] . "<br><br>" . $rows['16'] . "<br>" . $rows['17'] . "<br>" . $rows['18'] . "<br>" . $rows['19'] . "<br>" . $rows['20'] . "<br><br>" . $rows['22'] . "<br>" . $rows['27'] . "<br><br>" . $rows['28'] . "<br>" . $rows['29'] . "<br>" . $rows['30'] . "<br>" . $rows['31'] ."<br><br>" . $rows['32'] ."<br><br>" . $rows['33'] ."<br><br>" . $rows['35'] . "<br><br><br>";
}
foreach($rows as $row) {
$row = trim($row);
if(($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
$res .= $row."\n";
}
}
}
//return $res;
}
else {
////// einde whois filter array
$res = "";
if((strpos(strtolower($out), "error") === FALSE) && (strpos(strtolower($out), "not allocated") === FALSE)) {
$rows = explode("\n", $out);
foreach($rows as $row) {
$row = trim($row);
if(($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
$res .= $row."\n";
}
}
}
return $res;
}
}
?>
Quote:
ik begrijp dat ik een array nodig heb zoals:
Array
(
[Domain name] => waarde
[status] => waarde
[registrar] => waarde
[technical contact] => waarde
[nameservers] => waarde
)
en deze dan kan opvragen met bv.
print $array['domain name'];
maar het wil maar niet lukken, wat doe ik verkeerd?
heeft iemand een simpel voorbeeld, zodat ik de gegevens juist in de array zet..
Array
(
[Domain name] => waarde
[status] => waarde
[registrar] => waarde
[technical contact] => waarde
[nameservers] => waarde
)
en deze dan kan opvragen met bv.
print $array['domain name'];
maar het wil maar niet lukken, wat doe ik verkeerd?
heeft iemand een simpel voorbeeld, zodat ik de gegevens juist in de array zet..
Code (php)
Gewijzigd op 12/02/2011 15:52:22 door Michael -
Bedankt voor je reactie....
Dit stuk code is mij duidelijk.
Echter vraag ik me af hoe ik de domeinname of status waarde uit de output kan krijgen?
dit gaat volgens mij doormiddel van een explode van bv. /n
of heb ik het verkeerd?