html-tags-checken
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
error_reporting(E_ALL);
$host = "";//host - Meestal localhost
$user = "";//User van db
$pass = "";//Pass van db
$db = "";//Database van db
mysql_connect($host,$user,$pass);
mysql_select_db($db);
if(isset($_GET['restore'])){
mysql_query("truncate table html_check");
mysql_query("INSERT INTO `html_check` VALUES (1, '<body>', '</body>');");
mysql_query("INSERT INTO `html_check` VALUES (1, '<body>', '</body>');");
mysql_query("INSERT INTO `html_check` VALUES (2, '<table>', '</table>');");
mysql_query("INSERT INTO `html_check` VALUES (3, '<tr>', '</tr>');");
mysql_query("INSERT INTO `html_check` VALUES (4, '<td>', '</td>');");
mysql_query("INSERT INTO `html_check` VALUES (5, '<head>', '</head>');");
mysql_query("INSERT INTO `html_check` VALUES (6, '<html>', '</html>');");
mysql_query("INSERT INTO `html_check` VALUES (7, '<br>', '');");
mysql_query("INSERT INTO `html_check` VALUES (8, '<a>', '</a>');");
}
?>
error_reporting(E_ALL);
$host = "";//host - Meestal localhost
$user = "";//User van db
$pass = "";//Pass van db
$db = "";//Database van db
mysql_connect($host,$user,$pass);
mysql_select_db($db);
if(isset($_GET['restore'])){
mysql_query("truncate table html_check");
mysql_query("INSERT INTO `html_check` VALUES (1, '<body>', '</body>');");
mysql_query("INSERT INTO `html_check` VALUES (1, '<body>', '</body>');");
mysql_query("INSERT INTO `html_check` VALUES (2, '<table>', '</table>');");
mysql_query("INSERT INTO `html_check` VALUES (3, '<tr>', '</tr>');");
mysql_query("INSERT INTO `html_check` VALUES (4, '<td>', '</td>');");
mysql_query("INSERT INTO `html_check` VALUES (5, '<head>', '</head>');");
mysql_query("INSERT INTO `html_check` VALUES (6, '<html>', '</html>');");
mysql_query("INSERT INTO `html_check` VALUES (7, '<br>', '');");
mysql_query("INSERT INTO `html_check` VALUES (8, '<a>', '</a>');");
}
?>
<html>
<body text="black" bgcolor="white">
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
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
<?php
//Als de tag list word upgedate
if(isset($_POST['submit'])){
mysql_query("truncate table html_check");
for($i=0;$i<$_POST['fields']+1;$i++){
$tag_begin=$_POST['tag_begin'.$i];
$tag_end=$_POST['tag_end'.$i];
$sql="insert into html_check set tag_begin='".$tag_begin."', tag_end='".$tag_end."'";
if($tag_begin!=""){
mysql_query($sql);
}
}
}
//Functie voor pagina inhoud te lezen
function read($page){
$contents="";
$handle = @fopen ($page, "r");
if($handle){
while (!feof ($handle)) {
$buffer = fgets($handle, 4096);
$contents=$contents.$buffer;
}
fclose ($handle);
return $contents;
}
else{
return "Cannot load";
}
}
//formuliet verwerken
if(empty($_GET['url'])){
$url='http://www.che-lives-clan.com/index.php';
}
else{
$url=$_GET['url'];
}
echo '<center><form action="check_html.php" method="GET">';
echo 'Url - <input type="text" name="url" value="'.$url.'" size="50"><br>';
echo '<input type="submit" name="submit" value="Submit">';
echo '</form></center>';
//Pagina openen en controleren
if(isset($_GET['submit'])){
if(empty($_GET['url'])){
echo '<center><hr width="30%">Gelieve een url op te geven</center>';
}
else{
echo '<hr width="30%">';
$page=$_GET['url'];
echo '<table width="30%" border="1" align="center">';
echo '<tr><td colspan="2" align="center"><b>Resultaten van pagina: </b><a href="'.$page.'" target="_new">'.$page.'</a></td></tr>';
$inhoud=read($page);
if($inhoud=='Cannot load'){
$count=0;
echo '<tr><td colspan="2" align="center">De pagina kon niet gevonden worden</td></tr>';
}
else{
$inhoud = strtolower($inhoud);
$pagina = $inhoud;
$pagina = str_replace ('<', '<', $pagina);
$pagina = str_replace ('>', '>', $pagina);
$pagina = str_replace ('/', '/', $pagina);
$sql="select * from html_check";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
}
for($i=0;$i<$count;$i++){
$row=mysql_fetch_array($res);
$tag_begin=$row['tag_begin'];
$tag_end=$row['tag_end'];
$tag_check_begin = str_replace ('>', '', $tag_begin);
$tago=substr_count($inhoud, $tag_check_begin);
if($tag_end!=""){
$tagg=substr_count($inhoud, $tag_end);
if($tago!=$tagg){
$tago='<font color="red">'.$tago.'</font>';
$tagg='<font color="red">'.$tagg.'</font>';
}
else{
$tago='<font color="green">'.$tago.'</font>';
$tagg='<font color="green">'.$tagg.'</font>';
}
}
else{
$tago='<font color="green">'.$tago.'</font>';
}
$tag_begin = str_replace ('<', '<', $tag_begin);
$tag_begin = str_replace ('>', '>', $tag_begin);
$tag_begin = str_replace ('/', '/', $tag_begin);
$tag_end = str_replace ('<', '<', $tag_end);
$tag_end = str_replace ('>', '>', $tag_end);
$tag_end = str_replace ('/', '/', $tag_end);
if($tag_end!=""){
echo '<tr><td width="50%"><b>'.$tag_begin.' tags geopent:</b></td><td width="50%"><b>'.$tago.'</b></td></tr>';
echo '<tr><td width="50%"><b>'.$tag_end.' tags gesloten:</b></td><td width="50%"><b>'.$tagg.'</b></td></tr>';
}
else{
echo '<tr><td width="50%"><b>'.$tag_begin.' tags:</b></td><td width="50%"><b>'.$tago.'</b></td></tr>';
}
}
echo '</table>';
}
}
echo '<hr width="30%">';
$php_self=$_SERVER['REQUEST_URI'];
echo '<form action="'.$php_self.'" method="POST">';
echo '<table width="30%" border="1" align="center">';
echo '<tr><td colspan="2" align="center"><b>Welke tags controleren</b></td></tr>';
$sql="select * from html_check";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++){
$row=mysql_fetch_array($res);
echo '<tr><td align="center" width="50%"><input type="text" name="tag_begin'.$i.'" value="'.$row['tag_begin'].'"></td>';
echo '<td align="center" width="50%"><input type="text" name="tag_end'.$i.'" value="'.$row['tag_end'].'"></td></tr>';
}
echo '<tr><td align="center" colspan="2"><b>Toevoegen:</b></td></tr>';
echo '<tr><td align="center"><input type="text" name="tag_begin'.$i.'"></td><td align="center"><input type="text" name="tag_end'.$i.'"></td></tr>';
echo '<tr><td align="center" colspan="2"><b>Update:</b></td></tr>';
echo '<tr><td align="center" colspan="2"><input type="submit" name="submit" value="Update"><input type="reset" name="reset" value="Reset"></td></tr>';
echo '<tr><td align="center" colspan="2"><a href="check_html.php?restore=1">Herstellen naar standaard tags</a></td></tr>';
echo '</table>';
echo '<input type="hidden" name="fields" value="'.$i.'"></form>';
?>
//Als de tag list word upgedate
if(isset($_POST['submit'])){
mysql_query("truncate table html_check");
for($i=0;$i<$_POST['fields']+1;$i++){
$tag_begin=$_POST['tag_begin'.$i];
$tag_end=$_POST['tag_end'.$i];
$sql="insert into html_check set tag_begin='".$tag_begin."', tag_end='".$tag_end."'";
if($tag_begin!=""){
mysql_query($sql);
}
}
}
//Functie voor pagina inhoud te lezen
function read($page){
$contents="";
$handle = @fopen ($page, "r");
if($handle){
while (!feof ($handle)) {
$buffer = fgets($handle, 4096);
$contents=$contents.$buffer;
}
fclose ($handle);
return $contents;
}
else{
return "Cannot load";
}
}
//formuliet verwerken
if(empty($_GET['url'])){
$url='http://www.che-lives-clan.com/index.php';
}
else{
$url=$_GET['url'];
}
echo '<center><form action="check_html.php" method="GET">';
echo 'Url - <input type="text" name="url" value="'.$url.'" size="50"><br>';
echo '<input type="submit" name="submit" value="Submit">';
echo '</form></center>';
//Pagina openen en controleren
if(isset($_GET['submit'])){
if(empty($_GET['url'])){
echo '<center><hr width="30%">Gelieve een url op te geven</center>';
}
else{
echo '<hr width="30%">';
$page=$_GET['url'];
echo '<table width="30%" border="1" align="center">';
echo '<tr><td colspan="2" align="center"><b>Resultaten van pagina: </b><a href="'.$page.'" target="_new">'.$page.'</a></td></tr>';
$inhoud=read($page);
if($inhoud=='Cannot load'){
$count=0;
echo '<tr><td colspan="2" align="center">De pagina kon niet gevonden worden</td></tr>';
}
else{
$inhoud = strtolower($inhoud);
$pagina = $inhoud;
$pagina = str_replace ('<', '<', $pagina);
$pagina = str_replace ('>', '>', $pagina);
$pagina = str_replace ('/', '/', $pagina);
$sql="select * from html_check";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
}
for($i=0;$i<$count;$i++){
$row=mysql_fetch_array($res);
$tag_begin=$row['tag_begin'];
$tag_end=$row['tag_end'];
$tag_check_begin = str_replace ('>', '', $tag_begin);
$tago=substr_count($inhoud, $tag_check_begin);
if($tag_end!=""){
$tagg=substr_count($inhoud, $tag_end);
if($tago!=$tagg){
$tago='<font color="red">'.$tago.'</font>';
$tagg='<font color="red">'.$tagg.'</font>';
}
else{
$tago='<font color="green">'.$tago.'</font>';
$tagg='<font color="green">'.$tagg.'</font>';
}
}
else{
$tago='<font color="green">'.$tago.'</font>';
}
$tag_begin = str_replace ('<', '<', $tag_begin);
$tag_begin = str_replace ('>', '>', $tag_begin);
$tag_begin = str_replace ('/', '/', $tag_begin);
$tag_end = str_replace ('<', '<', $tag_end);
$tag_end = str_replace ('>', '>', $tag_end);
$tag_end = str_replace ('/', '/', $tag_end);
if($tag_end!=""){
echo '<tr><td width="50%"><b>'.$tag_begin.' tags geopent:</b></td><td width="50%"><b>'.$tago.'</b></td></tr>';
echo '<tr><td width="50%"><b>'.$tag_end.' tags gesloten:</b></td><td width="50%"><b>'.$tagg.'</b></td></tr>';
}
else{
echo '<tr><td width="50%"><b>'.$tag_begin.' tags:</b></td><td width="50%"><b>'.$tago.'</b></td></tr>';
}
}
echo '</table>';
}
}
echo '<hr width="30%">';
$php_self=$_SERVER['REQUEST_URI'];
echo '<form action="'.$php_self.'" method="POST">';
echo '<table width="30%" border="1" align="center">';
echo '<tr><td colspan="2" align="center"><b>Welke tags controleren</b></td></tr>';
$sql="select * from html_check";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++){
$row=mysql_fetch_array($res);
echo '<tr><td align="center" width="50%"><input type="text" name="tag_begin'.$i.'" value="'.$row['tag_begin'].'"></td>';
echo '<td align="center" width="50%"><input type="text" name="tag_end'.$i.'" value="'.$row['tag_end'].'"></td></tr>';
}
echo '<tr><td align="center" colspan="2"><b>Toevoegen:</b></td></tr>';
echo '<tr><td align="center"><input type="text" name="tag_begin'.$i.'"></td><td align="center"><input type="text" name="tag_end'.$i.'"></td></tr>';
echo '<tr><td align="center" colspan="2"><b>Update:</b></td></tr>';
echo '<tr><td align="center" colspan="2"><input type="submit" name="submit" value="Update"><input type="reset" name="reset" value="Reset"></td></tr>';
echo '<tr><td align="center" colspan="2"><a href="check_html.php?restore=1">Herstellen naar standaard tags</a></td></tr>';
echo '</table>';
echo '<input type="hidden" name="fields" value="'.$i.'"></form>';
?>
</body>
</html>