1 | <?php |
||
2 | |||
3 | use Ffcms\Templex\Url\Url; |
||
0 ignored issues
–
show
|
|||
4 | |||
5 | /** @var \Ffcms\Templex\Template\Template $this */ |
||
6 | |||
7 | $this->layout('_layouts/default', [ |
||
8 | 'title' => __('Antivirus'), |
||
9 | 'breadcrumbs' => [ |
||
10 | Url::to('main/index') => __('Main'), |
||
11 | __('Antivirus') |
||
12 | ] |
||
13 | ]); |
||
14 | ?> |
||
15 | |||
16 | <?php $this->start('body') ?> |
||
17 | <h1><?= __('Antivirus scan'); ?></h1> |
||
18 | <p><?= __('FFCMS 3 provide a simple signature-based antivirus software') . '. ' . __('Remember! This is just an advisory algorithm!') ?></p> |
||
19 | |||
20 | <div class="row mb-2"> |
||
21 | <div class="col-md-8"> |
||
22 | <div class="progress d-none" id="pbar-main"> |
||
23 | <div id="pbar-item" class="progress-bar bg-info" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0"> |
||
24 | 0% |
||
25 | </div> |
||
26 | </div> |
||
27 | <a href="#scanlog" class="btn btn-success" id="runscan"><?= __('Scan') ?></a> |
||
28 | </div> |
||
29 | <div class="col-md-4"> |
||
30 | <div class="card d-none" id="scanlog"> |
||
31 | <div class="card-body"> |
||
32 | <?= __('Files left') ?>: <span class="badge badge-primary" id="scancount">0</span> <br /> |
||
33 | <?= __('Detected issues') ?>: <span class="badge badge-warning" id="detected">0</span> |
||
34 | </div> |
||
35 | </div> |
||
36 | </div> |
||
37 | </div> |
||
38 | |||
39 | <ul class="nav nav-tabs" id="tab-menu" role="tablist"> |
||
40 | <li class="nav-item"> |
||
41 | <a class="nav-link active" id="home-tab" data-toggle="tab" href="#critical" role="tab" aria-controls="home" aria-selected="true"><?= __('Critical') ?></a> |
||
42 | </li> |
||
43 | <li class="nav-item"> |
||
44 | <a class="nav-link" id="profile-tab" data-toggle="tab" href="#suspicious" role="tab" aria-controls="profile" aria-selected="false"><?= __('Suspicious') ?></a> |
||
45 | </li> |
||
46 | </ul> |
||
47 | <!-- Tab panes --> |
||
48 | <div class="tab-content"> |
||
49 | <div class="tab-pane active" id="critical" role="tabpanel" aria-labelledby="home-tab"> |
||
50 | <div class="table-responsive"> |
||
51 | <table id="criticalresult" class="table table-hover d-none"> |
||
52 | <thead> |
||
53 | <tr> |
||
54 | <th><?= __('File') ?></th> |
||
55 | <th><?= __('Issues') ?></th> |
||
56 | <th><?= __('Descriptions of issues') ?></th> |
||
57 | </tr> |
||
58 | </thead> |
||
59 | <tbody></tbody> |
||
60 | </table> |
||
61 | </div> |
||
62 | <p id="no-critical-msg"><?= __('No critical issues found') ?></p> |
||
63 | </div> |
||
64 | <div class="tab-pane" id="suspicious" role="tabpanel" aria-labelledby="profile-tab"> |
||
65 | <div class="table-responsive"> |
||
66 | <table id="scanresult" class="table table-hover"> |
||
67 | <thead> |
||
68 | <tr> |
||
69 | <th><?= __('File') ?></th> |
||
70 | <th><?= __('Issues') ?></th> |
||
71 | <th><?= __('Descriptions of issues') ?></th> |
||
72 | </tr> |
||
73 | </thead> |
||
74 | <tbody> |
||
75 | </tbody> |
||
76 | </table> |
||
77 | </div> |
||
78 | </div> |
||
79 | </div> |
||
80 | <a href="#scanresult" class="btn btn-primary" id="loadresults"><?= __('Update results') ?></a> |
||
81 | <?php $this->stop() ?> |
||
82 | |||
83 | <?php $this->push('javascript') ?> |
||
84 | <script> |
||
85 | $(document).ready(function() { |
||
86 | runscan = function (first) { |
||
87 | $.getJSON(script_url+'/api/main/antivirus?lang='+script_lang, function (data) { |
||
88 | if (first) { |
||
89 | totalScan = data.left; |
||
90 | progress = 0; |
||
91 | } else { |
||
92 | progress = ((totalScan - data.left) / totalScan) * 100; |
||
93 | } |
||
94 | $("#pbar-item").css("width", progress + "%"); |
||
95 | $("#pbar-item").text(parseInt(progress) + "%"); |
||
96 | $("#scancount").text(data.left); |
||
97 | $("#detected").text(parseInt($("#detected").text()) + data.detect); |
||
98 | }).done(function (data) { |
||
99 | if (data.left > 0) { |
||
100 | loadResults(); |
||
101 | runscan(false); |
||
102 | } else { |
||
103 | $("#runscan").text("Done!"); |
||
104 | } |
||
105 | }); |
||
106 | } |
||
107 | }); |
||
108 | // jquery init of scan |
||
109 | $(document).ready(function () { |
||
110 | $("#runscan").on("click", function () { |
||
111 | $.get(script_url + '/api/main/antivirusclear?lang=' + script_lang); |
||
112 | $(this).addClass("disabled"); |
||
113 | $(this).text("Working ..."); |
||
114 | $("#scanlog").removeClass("d-none"); |
||
115 | $("#pbar-main").removeClass("d-none"); |
||
116 | runscan(true); |
||
117 | }) |
||
118 | }); |
||
119 | // jquery load results via json |
||
120 | $(document).ready(function () { |
||
121 | loadResults = function () { |
||
122 | $.getJSON(script_url + '/api/main/antivirusresults?lang=' + script_lang, function(data) { |
||
123 | if (data.status != 1) { |
||
124 | $("#scanresult").addClass('d-none'); |
||
125 | $('#criticalresult').addClass('d-none'); |
||
126 | } else { |
||
127 | $("#scanresult").removeClass('d-none'); |
||
128 | $('#criticalresult').removeClass('d-none'); |
||
129 | } |
||
130 | // cleanup ;) |
||
131 | $("#scanresult tbody").empty(); |
||
132 | if (typeof data.data === 'undefined') { |
||
133 | return; |
||
134 | } |
||
135 | $.each(data.data, function(file, logs) { |
||
136 | var isCritical = false; |
||
137 | var content = "<td>" + file + "</td>" + |
||
138 | "<td>" + logs[0].length + "</td>" + |
||
139 | "<td>"; |
||
140 | $.each(logs[0], function (num, info) { |
||
141 | if (info.sever == "c") { // critical malware posibility |
||
142 | content += "<span class=\"text-danger\">"; |
||
143 | isCritical = true; |
||
144 | } else if (info.sever = "w") { // warning, low posibility |
||
145 | content += "<span class=\"text-warning\">"; |
||
146 | } else { |
||
147 | content += "<span>"; |
||
148 | } |
||
149 | content += info.title + ", pos: " + info.pos + ", malware_id: " + info.sigId + ", regExp: " + info.sigRule + "<br />"; |
||
150 | }); |
||
151 | content += "</td>"; |
||
152 | if (isCritical) { |
||
153 | $('#criticalresult tbody').append('<tr>' + content + '</tr>'); |
||
154 | if (!$('#no-critical-msg').hasClass('d-none')) { |
||
155 | $('#no-critical-msg').addClass('d-none'); |
||
156 | } |
||
157 | } else { |
||
158 | $("#scanresult tbody").append("<tr>" + content + "</tr>"); |
||
159 | } |
||
160 | }); |
||
161 | }); |
||
162 | } |
||
163 | }); |
||
164 | $(document).ready(function () { |
||
165 | $("#loadresults").on("click", function () { |
||
166 | loadResults(); |
||
167 | }); |
||
168 | loadResults(); |
||
169 | }); |
||
170 | var totalScan = 2000; |
||
171 | </script> |
||
172 | <?php $this->stop() ?> |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: