PluginProbe
The WP Remote WordPress Plugin / 5.47
The WP Remote WordPress Plugin v5.47
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.47, at wp_admin.php

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