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

277 lines 9.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('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 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 // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
104 if (strpos($pluginValue, sprintf('>%s<', __('View details')))) {
105 unset($plugin_metas[$pluginKey]);
106 break;
107 }
108 }
109 }
110 return $plugin_metas;
111 }
112
113 public function handlePluginHealthInfo($plugins) {
114 if (!isset($plugins["wp-plugins-active"]) ||
115 !isset($plugins["wp-plugins-active"]["fields"]) || !$this->bvinfo->canWhiteLabel()) {
116 return $plugins;
117 }
118
119 $whitelabel_infos_by_title = $this->bvinfo->getPluginsWhitelabelInfoByTitle();
120
121 foreach ($whitelabel_infos_by_title as $title => $brand) {
122 if (is_array($brand) && array_key_exists('slug', $brand) && $this->bvinfo->canWhiteLabel($brand["slug"])) {
123 if (array_key_exists('hide', $brand)) {
124 unset($plugins["wp-plugins-active"]["fields"][$title]);
125 } else {
126 $plugin = $plugins["wp-plugins-active"]["fields"][$title];
127 $author = $brand['default_author'];
128 if (array_key_exists('name', $brand)) {
129 $plugin["label"] = $brand['name'];
130 }
131 if (array_key_exists('author', $brand)) {
132 $plugin["value"] = str_replace($author, $brand['author'], $plugin["value"]);
133 }
134 if (array_key_exists('description', $brand)) {
135 $plugin["debug"] = str_replace($author, $brand['author'], $plugin["debug"]);
136 }
137 $plugins["wp-plugins-active"]["fields"][$title] = $plugin;
138 }
139 }
140 }
141 return $plugins;
142 }
143
144 public function settingsLink($links, $file) {
145 #XNOTE: Fix this
146 if ( $file == plugin_basename( dirname(__FILE__).'/plugin.php' ) ) {
147 $brand = $this->bvinfo->getPluginWhitelabelInfo();
148 if (!array_key_exists('hide_plugin_details', $brand)) {
149 // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
150 $links[] = '<a href="'.$this->mainUrl().'">'.__('Settings').'</a>';
151 }
152 }
153 return $links;
154 }
155
156 public function getPluginLogo() {
157 $brand = $this->bvinfo->getPluginWhitelabelInfo();
158 if (array_key_exists('logo', $brand)) {
159 return $brand['logo'];
160 }
161 return $this->bvinfo->logo;
162 }
163
164 public function getWebPage() {
165 $brand = $this->bvinfo->getPluginWhitelabelInfo();
166 if (array_key_exists('webpage', $brand)) {
167 return $brand['webpage'];
168 }
169 return $this->bvinfo->webpage;
170 }
171
172 public function siteInfoTags() {
173 require_once dirname( __FILE__ ) . '/recover.php';
174 $bvnonce = wp_create_nonce("bvnonce");
175 $public = WPRAccount::getApiPublicKey($this->settings);
176 $secret = WPRRecover::defaultSecret($this->settings);
177 $server_ip = WPRHelper::getStringParamEscaped('SERVER', 'SERVER_ADDR', 'attr');
178 $tags = "<input type='hidden' name='url' value='".esc_attr($this->siteinfo->wpurl())."'/>\n".
179 "<input type='hidden' name='homeurl' value='".esc_attr($this->siteinfo->homeurl())."'/>\n".
180 "<input type='hidden' name='siteurl' value='".esc_attr($this->siteinfo->siteurl())."'/>\n".
181 "<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n".
182 "<input type='hidden' name='plug' value='".esc_attr($this->bvinfo->plugname)."'/>\n".
183 "<input type='hidden' name='adminurl' value='".esc_attr($this->mainUrl())."'/>\n".
184 "<input type='hidden' name='bvversion' value='".esc_attr($this->bvinfo->version)."'/>\n".
185 "<input type='hidden' name='serverip' value='".$server_ip."'/>\n".
186 "<input type='hidden' name='abspath' value='".esc_attr(ABSPATH)."'/>\n".
187 "<input type='hidden' name='secret' value='".esc_attr($secret)."'/>\n".
188 "<input type='hidden' name='public' value='".esc_attr($public)."'/>\n".
189 "<input type='hidden' name='bvnonce' value='".esc_attr($bvnonce)."'/>\n";
190 return $tags;
191 }
192
193 public function activateWarning() {
194 global $hook_suffix;
195 if (!WPRAccount::isConfigured($this->settings) && $hook_suffix == 'index.php' ) {
196 ?>
197 <div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
198 <a class="button-primary" href="<?php echo esc_url($this->mainUrl()); ?>">Activate WPRemote</a>
199 &nbsp;&nbsp;&nbsp;<b>Almost Done:</b> Activate your WPRemote account to backup & secure your site.
200 </div>
201 <?php
202 }
203 }
204
205 public function showAddAccountPage() {
206 require_once dirname( __FILE__ ) . "/admin/add_new_account.php";
207 }
208
209 public function showAccountDetailsPage() {
210 require_once dirname( __FILE__ ) . "/admin/account_details.php";
211 }
212
213 public function adminPage() {
214 $bvnonce = WPRHelper::getRawParam('REQUEST', 'bvnonce');
215 if ($bvnonce && wp_verify_nonce($bvnonce, 'bvnonce')) {
216 $info = array();
217 $this->siteinfo->basic($info);
218
219 $pubkey = WPRHelper::getRawParam('REQUEST', 'pubkey');
220
221 if (!empty($pubkey)) {
222 $pubkey = WPRAccount::sanitizeKey($pubkey);
223 $this->bvapi->pingbv('/bvapi/disconnect', $info, $pubkey);
224 WPRAccount::remove($this->settings, $pubkey);
225 }
226 }
227 if (WPRAccount::isConfigured($this->settings)) {
228 if (!isset($_REQUEST['add_account'])) {
229 $this->showAccountDetailsPage();
230 } else {
231 $this->showAddAccountPage();
232 }
233 } else {
234 $this->showAddAccountPage();
235 }
236 }
237
238 public function initWhitelabel($plugins) {
239 if (!is_array($plugins) || !$this->bvinfo->canWhiteLabel()) {
240 return $plugins;
241 }
242 $whitelabel_infos = $this->bvinfo->getPluginsWhitelabelInfos();
243 foreach ($whitelabel_infos as $slug => $brand) {
244 if (!isset($slug) || !$this->bvinfo->canWhiteLabel($slug) || !array_key_exists($slug, $plugins) || !is_array($brand)) {
245 continue;
246 }
247 if (array_key_exists('hide', $brand)) {
248 unset($plugins[$slug]);
249 } else {
250 if (array_key_exists('name', $brand)) {
251 $plugins[$slug]['Name'] = $brand['name'];
252 }
253 if (array_key_exists('title', $brand)) {
254 $plugins[$slug]['Title'] = $brand['title'];
255 }
256 if (array_key_exists('description', $brand)) {
257 $plugins[$slug]['Description'] = $brand['description'];
258 }
259 if (array_key_exists('authoruri', $brand)) {
260 $plugins[$slug]['AuthorURI'] = $brand['authoruri'];
261 }
262 if (array_key_exists('author', $brand)) {
263 $plugins[$slug]['Author'] = $brand['author'];
264 }
265 if (array_key_exists('authorname', $brand)) {
266 $plugins[$slug]['AuthorName'] = $brand['authorname'];
267 }
268 if (array_key_exists('pluginuri', $brand)) {
269 $plugins[$slug]['PluginURI'] = $brand['pluginuri'];
270 }
271 }
272 }
273 return $plugins;
274 }
275 }
276 endif;
277