-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
80 lines (60 loc) · 1.61 KB
/
index.php
File metadata and controls
80 lines (60 loc) · 1.61 KB
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
<?php
use Core\Controller;
error_reporting(E_ERROR | E_PARSE);
spl_autoload_register(function (string $sClassName) {
$sClassFile = __DIR__ . '/classes';
if (file_exists($sClassFile . '/' . str_replace('\\', '/', $sClassName) . '.php')) {
require_once($sClassFile . '/' . str_replace('\\', '/', $sClassName) . '.php');
}
});
$url = $_REQUEST['url'];
?>
<h4>Для подстчета кол-ва html тегов введите url страницы</h4>
<form action="" method="get">
<input type="text" name="url" value="<?= $url ?>">
<input type="submit" value="Посчитать">
</form>
<?php
if (empty($url)) {
die();
}
echo "<h1>Результат:</h1>";
$controller = Controller::getInstance();
$result = $controller->getHtmlTags('url', $_REQUEST['url']);
if ($result['status'] == 'error') {
echo "<h2 style='color: red;'>{$result['errors']}</h2>";
die();
}
foreach ($result['data'] as $tag) {
$tags[$tag] = (isset($tags[$tag])) ? ++$tags[$tag] : 1;
}
?>
<style>
table {
border-collapse: collapse;
border: 1px solid black;
text-align: center;
}
th, td {
border: 1px solid grey;
}
</style>
<table style="border: 1px solid black; border-collapse: collapse;">
<thead>
<tr>
<th>
Тег
</th>
<th>
Кол-во
</th>
</tr>
</thead>
<tbody>
<?php
foreach ($tags as $tag => $count) {
echo "<tr><td>{$tag}</td><td>{$count}</td></tr>";
}
?>
</tbody>
</table>