PluginProbe
The WP Remote WordPress Plugin / 6.69
The WP Remote WordPress Plugin v6.69
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 6.69, at wp_admin.php

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