-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
105 lines (97 loc) · 5.29 KB
/
index.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
<?php include_once 'includes/header.php'; ?>
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Tags Search</h2>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?php $url = !empty($_GET['q']) ? $_GET['q'] : null; ?>
<br/>
<form method="get" action="">
<div class="form-group">
<div class="input-group">
<input type="search" name="q" class="form-control" value="<?php echo $url; ?>" placeholder="Enter Web Address (URL) to fetch..."/>
<div class="input-group-append">
<button type="submit" class="btn btn-dark" title="Search"> →</button>
</div>
</div>
</div>
</form>
<hr/>
</div>
<?php if (!empty($url)): ?>
<?php
#$context = stream_context_create(['http' => ['method' => 'GET', 'max_redirects' => '0', 'ignore_errors' => '1']]);
#$file_contents = @file_get_contents($url);
$file_contents = fileGetContentsByCurl($url);
$file_contents_f = htmlentities($file_contents);
# get the pre-selected tag name
$tag_name_pre = !empty($_GET['tag']) ? $_GET['tag'] : null;
if (!is_null($tag_name_pre)) {
$search = ['<' . $tag_name_pre, '</' . $tag_name_pre . '>'];
$replace = ['<span class="bg-warning"><' . $tag_name_pre . '</span>', '<span class="bg-warning"></' . $tag_name_pre . '></span>'];
$file_contents_f = str_replace($search, $replace, $file_contents_f);
}
$dm = new DOMDocument();
@$dm->loadHTML($file_contents);
$html_tags = getHtmlTagsWithCount($dm);
ksort($html_tags, SORT_STRING);
?>
<div class="col-md-12">
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="pill-vs-tab" data-toggle="pill" href="#view-source" aria-controls="pill-vs" role="tab">View Source</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pill-ds-tab" data-toggle="pill" href="#document-summary" aria-controls="pill-ds" role="tab">Document Summary</a>
</li>
</ul>
<div class="tab-content mb-4" id="pills-tabContent">
<div class="tab-pane fade show active" id="view-source" role="tabpanel" aria-labelledby="pill-vs-tab">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="pre-scrollable bg-white">
<pre><code><?= $file_contents_f; ?></code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade show" id="document-summary" role="tabpanel" aria-labelledby="pill-ds-tab">
<div class="table-responsive">
<table class="table text-left m-0 bg-white">
<thead class="font-weight-bold">
<tr class="bg-dark text-white">
<th>Tags/Count</th>
<th>Document Structure — Mini</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td width="40%" class="p-0">
<ul class="list-group">
<?php foreach ($html_tags as $tag_name => $tag_count) { ?>
<li class="list-group-item list-group-item-action<?= ($tag_name_pre == $tag_name ? ' active' : ''); ?>">
<a href="?q=<?= $url; ?>&tag=<?= $tag_name; ?>" class="text-dark justify-content-between align-items-center d-flex">
<<?= $tag_name; ?>>
<span class="badge badge-secondary badge-pill"><?= $tag_count; ?></span>
</a>
</li>
<?php } ?>
</ul>
</td>
<td><?php displayNodes($dm); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
<?php include_once 'includes/footer.php'; ?>