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

275 lines 9.6 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 }
68 }
69
70 public function menu() {
71 $brand = $this->bvinfo->getPluginWhitelabelInfo();
72 if (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand)) {
73 $bname = $this->bvinfo->getBrandName();
74 $icon = $this->bvinfo->getBrandIcon();
75 add_menu_page($bname, $bname, 'manage_options', $this->bvinfo->plugname,
76 array($this, 'adminPage'), plugins_url($icon, __FILE__ ));
77 }
78 }
79
80 public function hidePluginUpdate($plugins) {
81 if (!$this->bvinfo->canWhiteLabel()) {
82 return $plugins;
83 }
84 $whitelabel_infos = $this->bvinfo->getPluginsWhitelabelInfos();
85 foreach ($whitelabel_infos as $slug => $brand) {
86 if ($this->bvinfo->canWhiteLabel($slug) && isset($plugins->response[$slug]) && is_array($brand)) {
87 if (array_key_exists('hide_from_menu', $brand) || array_key_exists('hide', $brand)) {
88 unset($plugins->response[$slug]);
89 }
90 }
91 }
92 return $plugins;
93 }
94
95 public function hidePluginDetails($plugin_metas, $slug) {
96 if (!is_array($plugin_metas) || !$this->bvinfo->canWhiteLabel($slug)) {
97 return $plugin_metas;
98 }
99 $whitelabel_info = $this->bvinfo->getPluginWhitelabelInfo($slug);
100 if (array_key_exists('hide_plugin_details', $whitelabel_info)) {
101 foreach ($plugin_metas as $pluginKey => $pluginValue) {
102 // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
103 if (strpos($pluginValue, sprintf('>%s<', __('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 // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
149 $links[] = '<a href="'.$this->mainUrl().'">'.__('Settings').'</a>';
150 }
151 }
152 return $links;
153 }
154
155 public function getPluginLogo() {
156 $brand = $this->bvinfo->getPluginWhitelabelInfo();
157 if (array_key_exists('logo', $brand)) {
158 return $brand['logo'];
159 }
160 return $this->bvinfo->logo;
161 }
162
163 public function getWebPage() {
164 $brand = $this->bvinfo->getPluginWhitelabelInfo();
165 if (array_key_exists('webpage', $brand)) {
166 return $brand['webpage'];
167 }
168 return $this->bvinfo->webpage;
169 }
170
171 public function siteInfoTags() {
172 require_once dirname( __FILE__ ) . '/recover.php';
173 $bvnonce = wp_create_nonce("bvnonce");
174 $public = WPRAccount::getApiPublicKey($this->settings);
175 $secret = WPRRecover::defaultSecret($this->settings);
176 $server_ip = WPRHelper::getStringParamEscaped('SERVER', 'SERVER_ADDR', 'attr');
177 $tags = "<input type='hidden' name='url' value='".esc_attr($this->siteinfo->wpurl())."'/>\n".
178 "<input type='hidden' name='homeurl' value='".esc_attr($this->siteinfo->homeurl())."'/>\n".
179 "<input type='hidden' name='siteurl' value='".esc_attr($this->siteinfo->siteurl())."'/>\n".
180 "<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n".
181 "<input type='hidden' name='plug' value='".esc_attr($this->bvinfo->plugname)."'/>\n".
182 "<input type='hidden' name='adminurl' value='".esc_attr($this->mainUrl())."'/>\n".
183 "<input type='hidden' name='bvversion' value='".esc_attr($this->bvinfo->version)."'/>\n".
184 "<input type='hidden' name='serverip' value='".$server_ip."'/>\n".
185 "<input type='hidden' name='abspath' value='".esc_attr(ABSPATH)."'/>\n".
186 "<input type='hidden' name='secret' value='".esc_attr($secret)."'/>\n".
187 "<input type='hidden' name='public' value='".esc_attr($public)."'/>\n".
188 "<input type='hidden' name='bvnonce' value='".esc_attr($bvnonce)."'/>\n";
189 return $tags;
190 }
191
192 public function activateWarning() {
193 global $hook_suffix;
194 if (!WPRAccount::isConfigured($this->settings) && $hook_suffix == 'index.php' ) {
195 ?>
196 <div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
197 <a class="button-primary" href="<?php echo esc_url($this->mainUrl()); ?>">Activate WPRemote</a>
198 &nbsp;&nbsp;&nbsp;<b>Almost Done:</b> Activate your WPRemote account to backup & secure your site.
199 </div>
200 <?php
201 }
202 }
203
204 public function showAddAccountPage() {
205 require_once dirname( __FILE__ ) . "/admin/add_new_account.php";
206 }
207
208 public function showAccountDetailsPage() {
209 require_once dirname( __FILE__ ) . "/admin/account_details.php";
210 }
211
212 public function adminPage() {
213 $bvnonce = WPRHelper::getRawParam('REQUEST', 'bvnonce');
214 if ($bvnonce && wp_verify_nonce($bvnonce, 'bvnonce')) {
215 $info = array();
216 $this->siteinfo->basic($info);
217
218 $pubkey = WPRHelper::getRawParam('REQUEST', 'pubkey');
219
220 if (!empty($pubkey)) {
221 $pubkey = WPRAccount::sanitizeKey($pubkey);
222 $this->bvapi->pingbv('/bvapi/disconnect', $info, $pubkey);
223 WPRAccount::remove($this->settings, $pubkey);
224 }
225 }
226 if (WPRAccount::isConfigured($this->settings)) {
227 if (!isset($_REQUEST['add_account'])) {
228 $this->showAccountDetailsPage();
229 } else {
230 $this->showAddAccountPage();
231 }
232 } else {
233 $this->showAddAccountPage();
234 }
235 }
236
237 public function initWhitelabel($plugins) {
238 if (!is_array($plugins) || !$this->bvinfo->canWhiteLabel()) {
239 return $plugins;
240 }
241 $whitelabel_infos = $this->bvinfo->getPluginsWhitelabelInfos();
242 foreach ($whitelabel_infos as $slug => $brand) {
243 if (!isset($slug) || !$this->bvinfo->canWhiteLabel($slug) || !array_key_exists($slug, $plugins) || !is_array($brand)) {
244 continue;
245 }
246 if (array_key_exists('hide', $brand)) {
247 unset($plugins[$slug]);
248 } else {
249 if (array_key_exists('name', $brand)) {
250 $plugins[$slug]['Name'] = $brand['name'];
251 }
252 if (array_key_exists('title', $brand)) {
253 $plugins[$slug]['Title'] = $brand['title'];
254 }
255 if (array_key_exists('description', $brand)) {
256 $plugins[$slug]['Description'] = $brand['description'];
257 }
258 if (array_key_exists('authoruri', $brand)) {
259 $plugins[$slug]['AuthorURI'] = $brand['authoruri'];
260 }
261 if (array_key_exists('author', $brand)) {
262 $plugins[$slug]['Author'] = $brand['author'];
263 }
264 if (array_key_exists('authorname', $brand)) {
265 $plugins[$slug]['AuthorName'] = $brand['authorname'];
266 }
267 if (array_key_exists('pluginuri', $brand)) {
268 $plugins[$slug]['PluginURI'] = $brand['pluginuri'];
269 }
270 }
271 }
272 return $plugins;
273 }
274 }
275 endif;