PluginProbe
The WP Remote WordPress Plugin / 5.85
The WP Remote WordPress Plugin v5.85
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
wpremote / wp_admin.php

wp_admin.php in The WP Remote WordPress Plugin 5.85, at wp_admin.php

271 lines 9.8 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('WPRWPAdmin')) :
5
6 class WPRWPAdmin {
7 public $settings;
8 public $siteinfo;
9 public $bvinfo;
10 public $bvapi;
11
12 function __construct($settings, $siteinfo, $bvapi = null) {
13 $this->settings = $settings;
14 $this->siteinfo = $siteinfo;
15 $this->bvapi = new WPRWPAPI($settings);
16 $this->bvinfo = new WPRInfo($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 function removeAdminNotices() {
28 if (array_key_exists('page', $_REQUEST) && $_REQUEST['page'] == $this->bvinfo->plugname) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
29 remove_all_actions('admin_notices');
30 remove_all_actions('all_admin_notices');
31 }
32 }
33
34 public function initHandler() {
35 if (!current_user_can('activate_plugins'))
36 return;
37 $bvnonce = isset($_REQUEST['bvnonce']) ? sanitize_text_field(wp_unslash($_REQUEST['bvnonce'])) : '';
38 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- using custom sanitization
39 $blogvaultkey = isset($_REQUEST['blogvaultkey']) ? WPRAccount::sanitizeKey(wp_unslash($_REQUEST['blogvaultkey'])) : '';
40 $page = isset($_REQUEST['page']) ? sanitize_text_field(wp_unslash($_REQUEST['page'])) : '';
41
42 if ($bvnonce && wp_verify_nonce($bvnonce, "bvnonce") &&
43 $blogvaultkey && strlen($blogvaultkey) == 64 &&
44 ($page && $page === $this->bvinfo->plugname)) {
45 $keys = str_split($blogvaultkey, 32);
46 WPRAccount::addAccount($this->settings, $keys[0], $keys[1]);
47
48 if (array_key_exists('redirect', $_REQUEST)) {
49 $location = esc_url_raw(wp_unslash($_REQUEST['redirect']));
50 wp_redirect($this->bvinfo->appUrl()."/dash/redir?q=".urlencode($location));
51 exit();
52 }
53 }
54
55 if ($this->bvinfo->isActivateRedirectSet()) {
56 $this->settings->updateOption($this->bvinfo->plug_redirect, 'no');
57 ##ACTIVATEREDIRECTCODE##
58 if (!wp_doing_ajax()) {
59 wp_redirect($this->mainUrl());
60 }
61 }
62 }
63
64 public function wprsecAdminMenu($hook) {
65 if ($hook === 'toplevel_page_wpremote' || WPRHelper::safePregMatch("/wpr_add_account$/", $hook) || WPRHelper::safePregMatch("/wpr_account_details$/", $hook)) {
66 wp_enqueue_style( 'bootstrap', plugins_url('css/bootstrap.min.css', __FILE__));
67 wp_enqueue_style( 'bvplugin', plugins_url('css/bvplugin.min.css', __FILE__));
68 }
69 }
70
71 public function menu() {
72 $brand = $this->bvinfo->getPluginWhitelabelInfo();
73 if (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand)) {
74 $bname = $this->bvinfo->getBrandName();
75 $icon = $this->bvinfo->getBrandIcon();
76 add_menu_page($bname, $bname, 'manage_options', $this->bvinfo->plugname,
77 array($this, 'adminPage'), plugins_url($icon, __FILE__ ));
78 }
79 }
80
81 public function hidePluginUpdate($plugins) {
82 if (!$this->bvinfo->canWhiteLabel()) {
83 return $plugins;
84 }
85 $whitelabel_infos = $this->bvinfo->getPluginsWhitelabelInfos();
86 foreach ($whitelabel_infos as $slug => $brand) {
87 if ($this->bvinfo->canWhiteLabel($slug) && isset($plugins->response[$slug]) && is_array($brand)) {
88 if (array_key_exists('hide_from_menu', $brand) || array_key_exists('hide', $brand)) {
89 unset($plugins->response[$slug]);
90 }
91 }
92 }
93 return $plugins;
94 }
95
96 public function hidePluginDetails($plugin_metas, $slug) {
97 if (!is_array($plugin_metas) || !$this->bvinfo->canWhiteLabel($slug)) {
98 return $plugin_metas;
99 }
100 $whitelabel_info = $this->bvinfo->getPluginWhitelabelInfo($slug);
101 if (array_key_exists('hide_plugin_details', $whitelabel_info)) {
102 foreach ($plugin_metas as $pluginKey => $pluginValue) {
103 if (strpos($pluginValue, sprintf('>%s<', translate('View details')))) {
104 unset($plugin_metas[$pluginKey]);
105 break;
106 }
107 }
108 }
109 return $plugin_metas;
110 }
111
112 public function handlePluginHealthInfo($plugins) {
113 if (!isset($plugins["wp-plugins-active"]) ||
114 !isset($plugins["wp-plugins-active"]["fields"]) || !$this->bvinfo->canWhiteLabel()) {
115 return $plugins;
116 }
117
118 $whitelabel_infos_by_title = $this->bvinfo->getPluginsWhitelabelInfoByTitle();
119
120 foreach ($whitelabel_infos_by_title as $title => $brand) {
121 if (is_array($brand) && array_key_exists('slug', $brand) && $this->bvinfo->canWhiteLabel($brand["slug"])) {
122 if (array_key_exists('hide', $brand)) {
123 unset($plugins["wp-plugins-active"]["fields"][$title]);
124 } else {
125 $plugin = $plugins["wp-plugins-active"]["fields"][$title];
126 $author = $brand['default_author'];
127 if (array_key_exists('name', $brand)) {
128 $plugin["label"] = $brand['name'];
129 }
130 if (array_key_exists('author', $brand)) {
131 $plugin["value"] = str_replace($author, $brand['author'], $plugin["value"]);
132 }
133 if (array_key_exists('description', $brand)) {
134 $plugin["debug"] = str_replace($author, $brand['author'], $plugin["debug"]);
135 }
136 $plugins["wp-plugins-active"]["fields"][$title] = $plugin;
137 }
138 }
139 }
140 return $plugins;
141 }
142
143 public function settingsLink($links, $file) {
144 #XNOTE: Fix this
145 if ( $file == plugin_basename( dirname(__FILE__).'/plugin.php' ) ) {
146 $brand = $this->bvinfo->getPluginWhitelabelInfo();
147 if (!array_key_exists('hide_plugin_details', $brand)) {
148 $links[] = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>';
149 }
150 }
151 return $links;
152 }
153
154 public function getPluginLogo() {
155 $brand = $this->bvinfo->getPluginWhitelabelInfo();
156 if (array_key_exists('logo', $brand)) {
157 return $brand['logo'];
158 }
159 return $this->bvinfo->logo;
160 }
161
162 public function getWebPage() {
163 $brand = $this->bvinfo->getPluginWhitelabelInfo();
164 if (array_key_exists('webpage', $brand)) {
165 return $brand['webpage'];
166 }
167 return $this->bvinfo->webpage;
168 }
169
170 public function siteInfoTags() {
171 require_once dirname( __FILE__ ) . '/recover.php';
172 $bvnonce = wp_create_nonce("bvnonce");
173 $public = WPRAccount::getApiPublicKey($this->settings);
174 $secret = WPRRecover::defaultSecret($this->settings);
175 $server_ip = isset($_SERVER["SERVER_ADDR"]) ? sanitize_text_field(wp_unslash($_SERVER["SERVER_ADDR"])) : null;
176 $tags = "<input type='hidden' name='url' value='".esc_attr($this->siteinfo->wpurl())."'/>\n".
177 "<input type='hidden' name='homeurl' value='".esc_attr($this->siteinfo->homeurl())."'/>\n".
178 "<input type='hidden' name='siteurl' value='".esc_attr($this->siteinfo->siteurl())."'/>\n".
179 "<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n".
180 "<input type='hidden' name='plug' value='".esc_attr($this->bvinfo->plugname)."'/>\n".
181 "<input type='hidden' name='adminurl' value='".esc_attr($this->mainUrl())."'/>\n".
182 "<input type='hidden' name='bvversion' value='".esc_attr($this->bvinfo->version)."'/>\n".
183 "<input type='hidden' name='serverip' value='".esc_attr($server_ip)."'/>\n".
184 "<input type='hidden' name='abspath' value='".esc_attr(ABSPATH)."'/>\n".
185 "<input type='hidden' name='secret' value='".esc_attr($secret)."'/>\n".
186 "<input type='hidden' name='public' value='".esc_attr($public)."'/>\n".
187 "<input type='hidden' name='bvnonce' value='".esc_attr($bvnonce)."'/>\n";
188 return $tags;
189 }
190
191 public function activateWarning() {
192 global $hook_suffix;
193 if (!WPRAccount::isConfigured($this->settings) && $hook_suffix == 'index.php' ) {
194 ?>
195 <div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
196 <a class="button-primary" href="<?php echo esc_url($this->mainUrl()); ?>">Activate WPRemote</a>
197 &nbsp;&nbsp;&nbsp;<b>Almost Done:</b> Activate your WPRemote account to backup & secure your site.
198 </div>
199 <?php
200 }
201 }
202
203 public function showAddAccountPage() {
204 require_once dirname( __FILE__ ) . "/admin/add_new_account.php";
205 }
206
207 public function showAccountDetailsPage() {
208 require_once dirname( __FILE__ ) . "/admin/account_details.php";
209 }
210
211 public function adminPage() {
212 $bvnonce = isset($_REQUEST['bvnonce']) ? sanitize_text_field(wp_unslash($_REQUEST['bvnonce'])) : '';
213 if ($bvnonce && wp_verify_nonce($bvnonce, 'bvnonce')) {
214 $info = array();
215 $this->siteinfo->basic($info);
216 if (!empty($_REQUEST['pubkey'])) {
217 $pubkey = WPRAccount::sanitizeKey(wp_unslash($_REQUEST['pubkey'])); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
218 $this->bvapi->pingbv('/bvapi/disconnect', $info, $pubkey);
219 WPRAccount::remove($this->settings, $pubkey);
220 }
221 }
222 if (WPRAccount::isConfigured($this->settings)) {
223 if (!isset($_REQUEST['add_account'])) {
224 $this->showAccountDetailsPage();
225 } else {
226 $this->showAddAccountPage();
227 }
228 } else {
229 $this->showAddAccountPage();
230 }
231 }
232
233 public function initWhitelabel($plugins) {
234 if (!is_array($plugins) || !$this->bvinfo->canWhiteLabel()) {
235 return $plugins;
236 }
237 $whitelabel_infos = $this->bvinfo->getPluginsWhitelabelInfos();
238 foreach ($whitelabel_infos as $slug => $brand) {
239 if (!isset($slug) || !$this->bvinfo->canWhiteLabel($slug) || !array_key_exists($slug, $plugins) || !is_array($brand)) {
240 continue;
241 }
242 if (array_key_exists('hide', $brand)) {
243 unset($plugins[$slug]);
244 } else {
245 if (array_key_exists('name', $brand)) {
246 $plugins[$slug]['Name'] = $brand['name'];
247 }
248 if (array_key_exists('title', $brand)) {
249 $plugins[$slug]['Title'] = $brand['title'];
250 }
251 if (array_key_exists('description', $brand)) {
252 $plugins[$slug]['Description'] = $brand['description'];
253 }
254 if (array_key_exists('authoruri', $brand)) {
255 $plugins[$slug]['AuthorURI'] = $brand['authoruri'];
256 }
257 if (array_key_exists('author', $brand)) {
258 $plugins[$slug]['Author'] = $brand['author'];
259 }
260 if (array_key_exists('authorname', $brand)) {
261 $plugins[$slug]['AuthorName'] = $brand['authorname'];
262 }
263 if (array_key_exists('pluginuri', $brand)) {
264 $plugins[$slug]['PluginURI'] = $brand['pluginuri'];
265 }
266 }
267 }
268 return $plugins;
269 }
270 }
271 endif;