postcode-bij-straat
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
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Postcode</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
@import 'postcode.css';
</style>
</head>
<body>
<div id="content">
<div id="container">
<div class="wrapper">
<h1>Postcodes</h1>
<form method="post" action="postcode.php">
<p>
<label for="postcode">Postcode:</label>
<input type="text" id="postcode" name="postcode" />
</p>
<p>
<input type="submit" class="indent" value="Zoek" />
</p>
</form>
</div>
</div>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
$url = explode(' ',$_POST['postcode']);
if((isset($url[1])) && (strlen($url[0]) == 4) && (strlen($url[1]) == 2) && (is_numeric($url[0])) && (preg_match('/^[a-zA-Z]*$/' ,$url[1]))) {
$url = "http://www.zoekplaats.nl/index.cgi?actie=postcode&zoek=".$url[0]."+".$url[1];
if($data = @file_get_contents($url)) {
$data = explode('<DIV style="padding-left: 2px; margin-top:20px">',$data);
$data = explode('</DIV>',$data[1]);
$datawp = explode('<H1>',$data[0]);
$datawp = explode('</H1>',$datawp[1]);
$specs['woonplaats'] = $datawp[0];
$datast = explode('<B>Straat</B>: ',$data[0]);
$datast = explode('<BR>',$datast[1]);
$specs['straat'] = $datast[0];
if($specs['woonplaats'] == "Postcode niet gevonden...") {
echo "<pre>Deze postcode is niet gevonden.</pre>";
} else {
echo "<pre>";
echo "Woonplaats: ".$specs['woonplaats'];
echo "Straat: ".$specs['straat'];
echo "</pre>";
}
} else {
echo "<pre>Er kon geen connectie worden gemaakt met onze postcode bron.</pre>";
}
} else {
echo "<pre>ongeldige postcode</pre>";
}
}
?>
<div class="footer"><p>
<a href="postcode.phps" title="">Broncode</a>
<a href="http://validator.w3.org/check?uri=referer"><img
style="border:0;" src="http://www.w3.org/Icons/valid-html401"
alt="Valid HTML 4.01 Strict" height="31" width="88"></a>
<a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fpascal.signet.nl%2Fsignet%2Fstyle.css&warning=1&profile=css21&usermedium=all">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss"
alt="Valid CSS!" />
</a></p>
</div>
</div>
</body>
</html>
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Postcode</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
@import 'postcode.css';
</style>
</head>
<body>
<div id="content">
<div id="container">
<div class="wrapper">
<h1>Postcodes</h1>
<form method="post" action="postcode.php">
<p>
<label for="postcode">Postcode:</label>
<input type="text" id="postcode" name="postcode" />
</p>
<p>
<input type="submit" class="indent" value="Zoek" />
</p>
</form>
</div>
</div>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
$url = explode(' ',$_POST['postcode']);
if((isset($url[1])) && (strlen($url[0]) == 4) && (strlen($url[1]) == 2) && (is_numeric($url[0])) && (preg_match('/^[a-zA-Z]*$/' ,$url[1]))) {
$url = "http://www.zoekplaats.nl/index.cgi?actie=postcode&zoek=".$url[0]."+".$url[1];
if($data = @file_get_contents($url)) {
$data = explode('<DIV style="padding-left: 2px; margin-top:20px">',$data);
$data = explode('</DIV>',$data[1]);
$datawp = explode('<H1>',$data[0]);
$datawp = explode('</H1>',$datawp[1]);
$specs['woonplaats'] = $datawp[0];
$datast = explode('<B>Straat</B>: ',$data[0]);
$datast = explode('<BR>',$datast[1]);
$specs['straat'] = $datast[0];
if($specs['woonplaats'] == "Postcode niet gevonden...") {
echo "<pre>Deze postcode is niet gevonden.</pre>";
} else {
echo "<pre>";
echo "Woonplaats: ".$specs['woonplaats'];
echo "Straat: ".$specs['straat'];
echo "</pre>";
}
} else {
echo "<pre>Er kon geen connectie worden gemaakt met onze postcode bron.</pre>";
}
} else {
echo "<pre>ongeldige postcode</pre>";
}
}
?>
<div class="footer"><p>
<a href="postcode.phps" title="">Broncode</a>
<a href="http://validator.w3.org/check?uri=referer"><img
style="border:0;" src="http://www.w3.org/Icons/valid-html401"
alt="Valid HTML 4.01 Strict" height="31" width="88"></a>
<a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fpascal.signet.nl%2Fsignet%2Fstyle.css&warning=1&profile=css21&usermedium=all">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss"
alt="Valid CSS!" />
</a></p>
</div>
</div>
</body>
</html>