This repository has been archived by the owner on Jun 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
task3.php
59 lines (53 loc) · 1.96 KB
/
task3.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
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include ('classes/Angel5a/autoload.php');
$url = isset($_GET['url']) ? $_GET['url'] : basename(__FILE__);
if(!empty($url)) {
$text = @file_get_contents($url);
//$text = '<div>Here is <a>a link</a> some <b>bold text</B> and <A>extra link</A>.</div>';
$tokenizer = new Angel5a\MoveRuTest\HtmlTokenizer($text);
//$tokenizer = new Angel5a\MoveRuTest\FakeHtmlTokenizer();
$counter = new Angel5a\MoveRuTest\TagCounter($tokenizer);
$tagCounts = $counter->getTagCounts();
}
?>
<html>
<head>
<title>Task 3</title>
<head>
<body>
<h1>Task 3</h1>
<p>Count html tags in file.</p>
<div class="form">
<form>
<div class="form-group">
<label for="url">Url</label>
<input type="text" class="form-control" id="url" name="url" value="<?= htmlspecialchars($url) ?>" aria-describedby="urlHelp" placeholder="Enter URL">
<small id="urlHelp" class="form-text text-muted">Enter URL to HTML file.</small>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<?php if(!empty($url)) : ?>
<div class="block">
<div class="header">File</div>
<div class="content"><?= htmlspecialchars($url); ?></div>
</div>
<div class="block">
<div class="header">Result</div>
<div class="content">
<table class="result_table">
<tr><th>Tag name</th><th>Count</th></tr>
<?php foreach ($tagCounts as $name=>$count) : ?>
<tr>
<td><?= htmlspecialchars($name); ?></td>
<td><?= htmlspecialchars($count); ?></td>
</tr>
<?php endforeach; /* $tagCounts */ ?>
</table>
</div>
</div>
<?php endif; /* $url */ ?>
<body>
</html>