PluginProbe
MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall / 5.77
MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall v5.77
6.72 6.69 6.65 6.62 6.48 6.47 5.41 5.42 5.45 5.47 5.53 5.54 5.55 5.56 5.65 5.67 5.68 5.72 5.73 5.77 5.81 5.85 5.88 5.91 5.92 All 88 releases
malcare-security / wp_admin.php

wp_admin.php in MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall 5.77, at wp_admin.php

305 lines 10.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('MCWPAdmin')) :
5 class MCWPAdmin {
6 public $settings;
7 public $siteinfo;
8 public $account;
9 public $bvapi;
10 public $bvinfo;
11
12 function __construct($settings, $siteinfo, $bvapi = null) {
13 $this->settings = $settings;
14 $this->siteinfo = $siteinfo;
15 $this->bvapi = new MCWPAPI($settings);
16 $this->bvinfo = new MCInfo($this->settings);
17 }
18
19 public function mainUrl($_params = '') {
20 if (function_exists('network_admin_url')) {
21 return network_admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
22 } else {
23 return admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
24 }
25 }
26
27 public function removeAdminNotices() {
28 if (array_key_exists('page', $_REQUEST) && $_REQUEST['page'] == $this->bvinfo->plugname) {
29 remove_all_actions('admin_notices');
30 remove_all_actions('all_admin_notices');
31 }
32 }
33
34 public function cwBrandInfo() {
35 return array(
36 'name' => "Bot Protection",
37 'title' => "Wordpress Security",
38 'description' => "WordPress Security, Bot Protection",
39 'authoruri' => "https://www.malcare.com",
40 'author' => "MalCare Security",
41 'authorname' => "Malcare Security",
42 'pluginuri' => "https://www.malcare.com",
43 'menuname' => "Bot Protection",
44 'brand_icon' => "/img/cw_icon.png"
45 );
46 }
47
48 public function initHandler() {
49 if (!current_user_can('activate_plugins'))
50 return;
51
52 if (array_key_exists('bvnonce', $_REQUEST) &&
53 wp_verify_nonce($_REQUEST['bvnonce'], "bvnonce") &&
54 array_key_exists('blogvaultkey', $_REQUEST) &&
55 (strlen(MCAccount::sanitizeKey($_REQUEST['blogvaultkey'])) == 64) &&
56 (array_key_exists('page', $_REQUEST) &&
57 $_REQUEST['page'] == $this->bvinfo->plugname)) {
58 $keys = str_split($_REQUEST['blogvaultkey'], 32);
59 $pubkey = $keys[0];
60 MCAccount::addAccount($this->settings, $keys[0], $keys[1]);
61 if (array_key_exists('redirect', $_REQUEST)) {
62 $location = $_REQUEST['redirect'];
63 $this->account = MCAccount::find($this->settings, $pubkey);
64 wp_redirect($this->account->authenticatedUrl('/malcare/access/welcome'));
65 exit();
66 }
67 }
68 if ($this->bvinfo->isActivateRedirectSet()) {
69 $this->settings->updateOption($this->bvinfo->plug_redirect, 'no');
70 ##ACTIVATEREDIRECTCODE##
71 if (!wp_doing_ajax()) {
72 wp_redirect($this->mainUrl());
73 }
74 }
75 }
76
77 public function mcsecAdminMenu($hook) {
78 if ($hook === 'toplevel_page_malcare' || MCHelper::safePregMatch("/bv_add_account$/", $hook) ||
79 MCHelper::safePregMatch("/bv_account_details$/", $hook)) {
80 wp_enqueue_style( 'bootstrap', plugins_url('css/bootstrap.min.css', __FILE__));
81 wp_enqueue_style( 'bvplugin', plugins_url('css/bvplugin.min.css', __FILE__));
82 }
83 }
84
85 public function menu() {
86 add_submenu_page('', 'Malcare', 'Malcare', 'manage_options', 'bv_add_account',
87 array($this, 'showAddAccountPage'));
88 add_submenu_page('', 'Malcare', 'Malcare', 'manage_options', 'bv_account_details',
89 array($this, 'showAccountDetailsPage'));
90
91 $brand = $this->bvinfo->getPluginWhitelabelInfo();
92 if (!$this->bvinfo->canSetCWBranding() && (!is_array($brand) || (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand)))) {
93 $bname = $this->bvinfo->getBrandName();
94 $icon = $this->bvinfo->getBrandIcon();
95
96 $pub_key = MCAccount::getApiPublicKey($this->settings);
97 if ($pub_key && isset($pub_key)) {
98 $this->account = MCAccount::find($this->settings, $pub_key);
99 }
100
101 add_menu_page($bname, $bname, 'manage_options', $this->bvinfo->plugname,
102 array($this, 'adminPage'), plugins_url($icon, __FILE__ ));
103 }
104 }
105
106 public function hidePluginUpdate($plugins) {
107 if (!$this->bvinfo->canWhiteLabel()) {
108 return $plugins;
109 }
110 $whitelabel_infos = $this->bvinfo->getPluginsWhitelabelInfos();
111 foreach ($whitelabel_infos as $slug => $brand) {
112 if ($this->bvinfo->canWhiteLabel($slug) && isset($plugins->response[$slug]) && is_array($brand)) {
113 if (array_key_exists('hide_from_menu', $brand) || array_key_exists('hide', $brand)) {
114 unset($plugins->response[$slug]);
115 }
116 }
117 }
118 return $plugins;
119 }
120
121 public function hidePluginDetails($plugin_metas, $slug) {
122 if (!is_array($plugin_metas) || !$this->bvinfo->canWhiteLabel($slug)) {
123 return $plugin_metas;
124 }
125 $whitelabel_info = $this->bvinfo->getPluginWhitelabelInfo($slug);
126 if (array_key_exists('hide_plugin_details', $whitelabel_info)) {
127 foreach ($plugin_metas as $pluginKey => $pluginValue) {
128 if (strpos($pluginValue, sprintf('>%s<', translate('View details')))) {
129 unset($plugin_metas[$pluginKey]);
130 break;
131 }
132 }
133 }
134 return $plugin_metas;
135 }
136
137 public function handlePluginHealthInfo($plugins) {
138 if (!isset($plugins["wp-plugins-active"]) ||
139 !isset($plugins["wp-plugins-active"]["fields"]) || !$this->bvinfo->canWhiteLabel()) {
140 return $plugins;
141 }
142
143 $whitelabel_infos_by_title = $this->bvinfo->getPluginsWhitelabelInfoByTitle();
144
145 foreach ($whitelabel_infos_by_title as $title => $brand) {
146 if (is_array($brand) && array_key_exists('slug', $brand) && $this->bvinfo->canWhiteLabel($brand["slug"])) {
147 if (array_key_exists('hide', $brand)) {
148 unset($plugins["wp-plugins-active"]["fields"][$title]);
149 } else {
150 $plugin = $plugins["wp-plugins-active"]["fields"][$title];
151 $author = $brand['default_author'];
152 if (array_key_exists('name', $brand)) {
153 $plugin["label"] = $brand['name'];
154 }
155 if (array_key_exists('author', $brand)) {
156 $plugin["value"] = str_replace($author, $brand['author'], $plugin["value"]);
157 }
158 if (array_key_exists('description', $brand)) {
159 $plugin["debug"] = str_replace($author, $brand['author'], $plugin["debug"]);
160 }
161 $plugins["wp-plugins-active"]["fields"][$title] = $plugin;
162 }
163 }
164 }
165 return $plugins;
166 }
167
168 public function settingsLink($links, $file) {
169 #XNOTE: Fix this
170 if ( $file == plugin_basename( dirname(__FILE__).'/malcare.php' ) ) {
171 if (!$this->bvinfo->canSetCWBranding()) {
172 $brand = $this->bvinfo->getPluginWhitelabelInfo();
173 if (!is_array($brand) || !array_key_exists('hide_from_menu', $brand)) {
174 $settings_link = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>';
175 array_unshift($links, $settings_link);
176 $account_details = '<a href="'.$this->mainUrl('&account_details=true').'">'.__( 'Account Details' ).'</a>';
177 array_unshift($links, $account_details);
178 }
179 }
180 }
181 return $links;
182 }
183
184 public function getPluginLogo() {
185 $brand = $this->bvinfo->getPluginWhitelabelInfo();
186 if (array_key_exists('logo', $brand)) {
187 return $brand['logo'];
188 }
189 return $this->bvinfo->logo;
190 }
191
192 public function getWebPage() {
193 $brand = $this->bvinfo->getPluginWhitelabelInfo();
194 if (array_key_exists('webpage', $brand)) {
195 return $brand['webpage'];
196 }
197 return $this->bvinfo->webpage;
198 }
199
200 public function siteInfoTags() {
201 require_once dirname( __FILE__ ) . '/recover.php';
202 $bvnonce = wp_create_nonce("bvnonce");
203 $public = MCAccount::getApiPublicKey($this->settings);
204 $secret = MCRecover::defaultSecret($this->settings);
205 $tags = "<input type='hidden' name='url' value='".esc_attr($this->siteinfo->wpurl())."'/>\n".
206 "<input type='hidden' name='homeurl' value='".esc_attr($this->siteinfo->homeurl())."'/>\n".
207 "<input type='hidden' name='siteurl' value='".esc_attr($this->siteinfo->siteurl())."'/>\n".
208 "<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n".
209 "<input type='hidden' name='plug' value='".esc_attr($this->bvinfo->plugname)."'/>\n".
210 "<input type='hidden' name='adminurl' value='".esc_attr($this->mainUrl())."'/>\n".
211 "<input type='hidden' name='bvversion' value='".esc_attr($this->bvinfo->version)."'/>\n".
212 "<input type='hidden' name='serverip' value='".esc_attr($_SERVER["SERVER_ADDR"])."'/>\n".
213 "<input type='hidden' name='abspath' value='".esc_attr(ABSPATH)."'/>\n".
214 "<input type='hidden' name='secret' value='".esc_attr($secret)."'/>\n".
215 "<input type='hidden' name='public' value='".esc_attr($public)."'/>\n".
216 "<input type='hidden' name='bvnonce' value='".esc_attr($bvnonce)."'/>\n";
217 return $tags;
218 }
219
220 public function activateWarning() {
221 global $hook_suffix;
222 if (!MCAccount::isConfigured($this->settings) && $hook_suffix == 'index.php' ) {
223 ?>
224 <div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
225 <a class="button-primary" href="<?php echo esc_url($this->mainUrl()); ?>">Activate MalCare</a>
226 &nbsp;&nbsp;&nbsp;<b>Almost Done:</b> Activate your Malcare account to secure your site.
227 </div>
228 <?php
229 }
230 }
231
232 public function showAddAccountPage() {
233 require_once dirname( __FILE__ ) . "/admin/add_new_account.php";
234 }
235
236 public function showAccountDetailsPage() {
237 require_once dirname( __FILE__ ) . "/admin/account_details.php";
238 }
239
240 public function showDashboard() {
241 require_once dirname( __FILE__ ) . "/admin/dashboard.php";
242 }
243
244 public function adminPage() {
245 if (isset($_REQUEST['bvnonce']) && wp_verify_nonce( $_REQUEST['bvnonce'], 'bvnonce' )) {
246 $info = array();
247 $this->siteinfo->basic($info);
248 $this->bvapi->pingbv('/bvapi/disconnect', $info, MCAccount::sanitizeKey($_REQUEST['pubkey']));
249 MCAccount::remove($this->settings, MCAccount::sanitizeKey($_REQUEST['pubkey']));
250 }
251
252 if (isset($_REQUEST['account_details'])) {
253 $this->showAccountDetailsPage();
254 } else if (isset($_REQUEST['add_account'])) {
255 $this->showAddAccountPage();
256 } else if(MCAccount::isConfigured($this->settings)) {
257 $this->showDashboard();
258 } else {
259 $this->showAddAccountPage();
260 }
261 }
262
263 public function initWhitelabel($plugins) {
264 if (!is_array($plugins) || !$this->bvinfo->canWhiteLabel()) {
265 return $plugins;
266 }
267 $whitelabel_infos = $this->bvinfo->getPluginsWhitelabelInfos();
268 if ($this->bvinfo->canSetCWBranding()) {
269 $whitelabel_infos[$this->bvinfo->slug] = $this->cwBrandInfo();
270 }
271
272 foreach ($whitelabel_infos as $slug => $brand) {
273 if (!isset($slug) || !$this->bvinfo->canWhiteLabel($slug) || !array_key_exists($slug, $plugins) || !is_array($brand)) {
274 continue;
275 }
276 if (array_key_exists('hide', $brand)) {
277 unset($plugins[$slug]);
278 } else {
279 if (array_key_exists('name', $brand)) {
280 $plugins[$slug]['Name'] = $brand['name'];
281 }
282 if (array_key_exists('title', $brand)) {
283 $plugins[$slug]['Title'] = $brand['title'];
284 }
285 if (array_key_exists('description', $brand)) {
286 $plugins[$slug]['Description'] = $brand['description'];
287 }
288 if (array_key_exists('authoruri', $brand)) {
289 $plugins[$slug]['AuthorURI'] = $brand['authoruri'];
290 }
291 if (array_key_exists('author', $brand)) {
292 $plugins[$slug]['Author'] = $brand['author'];
293 }
294 if (array_key_exists('authorname', $brand)) {
295 $plugins[$slug]['AuthorName'] = $brand['authorname'];
296 }
297 if (array_key_exists('pluginuri', $brand)) {
298 $plugins[$slug]['PluginURI'] = $brand['pluginuri'];
299 }
300 }
301 }
302 return $plugins;
303 }
304 }
305 endif;