| @@ -24,9 +24,9 @@ | ||
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | function removeAdminNotices() { |
| 28 | - if (WPRHelper::getRawParam('REQUEST', 'page') === $this->bvinfo->plugname) { | |
| 28 | + if (array_key_exists('page', $_REQUEST) && $_REQUEST['page'] == $this->bvinfo->plugname) { | |
| 29 | 29 | remove_all_actions('admin_notices'); |
| 30 | 30 | remove_all_actions('all_admin_notices'); |
| 31 | 31 | } |
| 32 | 32 | } |
| @@ -33,47 +33,40 @@ | ||
| 33 | 33 | |
| 34 | 34 | public function initHandler() { |
| 35 | 35 | if (!current_user_can('activate_plugins')) |
| 36 | 36 | return; |
| 37 | - $bvnonce = WPRHelper::getRawParam('REQUEST', 'bvnonce'); | |
| 38 | - $blogvaultkey = WPRHelper::getRawParam('REQUEST', 'blogvaultkey'); | |
| 39 | - $blogvaultkey = $blogvaultkey ? WPRAccount::sanitizeKey($blogvaultkey) : ""; | |
| 40 | 37 | |
| 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); | |
| 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 | 45 | WPRAccount::addAccount($this->settings, $keys[0], $keys[1]); |
| 46 | - | |
| 47 | - $location = WPRHelper::getStringParamSanitized('REQUEST', 'redirect', 'url'); | |
| 48 | - if ($location) { | |
| 46 | + if (array_key_exists('redirect', $_REQUEST)) { | |
| 47 | + $location = $_REQUEST['redirect']; | |
| 49 | 48 | wp_redirect($this->bvinfo->appUrl()."/dash/redir?q=".urlencode($location)); |
| 50 | 49 | exit(); |
| 51 | 50 | } |
| 52 | 51 | } |
| 53 | - | |
| 54 | 52 | if ($this->bvinfo->isActivateRedirectSet()) { |
| 55 | 53 | $this->settings->updateOption($this->bvinfo->plug_redirect, 'no'); |
| 56 | 54 | ##ACTIVATEREDIRECTCODE## |
| 57 | - if (!wp_doing_ajax()) { | |
| 58 | - wp_redirect($this->mainUrl()); | |
| 59 | - } | |
| 55 | + wp_redirect($this->mainUrl()); | |
| 60 | 56 | } |
| 61 | 57 | } |
| 62 | 58 | |
| 63 | 59 | 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); | |
| 60 | + if ($hook === 'toplevel_page_wpremote' || preg_match("/wpr_add_account$/", $hook) || preg_match("/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__)); | |
| 68 | 63 | } |
| 69 | 64 | } |
| 70 | 65 | |
| 71 | 66 | 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) { | |
| 67 | + $brand = $this->bvinfo->getBrandInfo(); | |
| 68 | + if (!is_array($brand) || (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand))) { | |
| 76 | 69 | $bname = $this->bvinfo->getBrandName(); |
| 77 | 70 | $icon = $this->bvinfo->getBrandIcon(); |
| 78 | 71 | add_menu_page($bname, $bname, 'manage_options', $this->bvinfo->plugname, |
| 79 | 72 | array($this, 'adminPage'), plugins_url($icon, __FILE__ )); |
| @@ -79,32 +72,15 @@ | ||
| 79 | 72 | array($this, 'adminPage'), plugins_url($icon, __FILE__ )); |
| 80 | 73 | } |
| 81 | 74 | } |
| 82 | 75 | |
| 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 | - } | |
| 76 | + public function hidePluginDetails($plugin_metas, $slug) { | |
| 77 | + $brand = $this->bvinfo->getBrandInfo(); | |
| 78 | + $bvslug = $this->bvinfo->slug; | |
| 97 | 79 | |
| 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)) { | |
| 80 | + if ($slug === $bvslug && is_array($brand) && array_key_exists('hide_plugin_details', $brand)){ | |
| 104 | 81 | foreach ($plugin_metas as $pluginKey => $pluginValue) { |
| 105 | - // phpcs:ignore WordPress.WP.I18n.MissingArgDomain | |
| 106 | - if (strpos($pluginValue, sprintf('>%s<', __('View details')))) { | |
| 82 | + if (strpos($pluginValue, sprintf('>%s<', translate('View details')))) { | |
| 107 | 83 | unset($plugin_metas[$pluginKey]); |
| 108 | 84 | break; |
| 109 | 85 | } |
| 110 | 86 | } |
| @@ -111,46 +87,14 @@ | ||
| 111 | 87 | } |
| 112 | 88 | return $plugin_metas; |
| 113 | 89 | } |
| 114 | 90 | |
| 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 | 91 | public function settingsLink($links, $file) { |
| 147 | 92 | #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>'; | |
| 93 | + if ( $file == plugin_basename( dirname(__FILE__).'/blogvault.php' ) ) { | |
| 94 | + $brand = $this->bvinfo->getBrandInfo(); | |
| 95 | + if (!$brand || !array_key_exists('hide_plugin_details', $brand)) { | |
| 96 | + $links[] = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>'; | |
| 153 | 97 | } |
| 154 | 98 | } |
| 155 | 99 | return $links; |
| 156 | 100 | } |
| @@ -155,10 +99,10 @@ | ||
| 155 | 99 | return $links; |
| 156 | 100 | } |
| 157 | 101 | |
| 158 | 102 | public function getPluginLogo() { |
| 159 | - $brand = $this->bvinfo->getPluginWhitelabelInfo(); | |
| 160 | - if (array_key_exists('logo', $brand)) { | |
| 103 | + $brand = $this->bvinfo->getBrandInfo(); | |
| 104 | + if ($brand && array_key_exists('logo', $brand)) { | |
| 161 | 105 | return $brand['logo']; |
| 162 | 106 | } |
| 163 | 107 | return $this->bvinfo->logo; |
| 164 | 108 | } |
| @@ -163,10 +107,10 @@ | ||
| 163 | 107 | return $this->bvinfo->logo; |
| 164 | 108 | } |
| 165 | 109 | |
| 166 | 110 | public function getWebPage() { |
| 167 | - $brand = $this->bvinfo->getPluginWhitelabelInfo(); | |
| 168 | - if (array_key_exists('webpage', $brand)) { | |
| 111 | + $brand = $this->bvinfo->getBrandInfo(); | |
| 112 | + if ($brand && array_key_exists('webpage', $brand)) { | |
| 169 | 113 | return $brand['webpage']; |
| 170 | 114 | } |
| 171 | 115 | return $this->bvinfo->webpage; |
| 172 | 116 | } |
| @@ -175,9 +119,8 @@ | ||
| 175 | 119 | require_once dirname( __FILE__ ) . '/recover.php'; |
| 176 | 120 | $bvnonce = wp_create_nonce("bvnonce"); |
| 177 | 121 | $public = WPRAccount::getApiPublicKey($this->settings); |
| 178 | 122 | $secret = WPRRecover::defaultSecret($this->settings); |
| 179 | - $server_ip = WPRHelper::getStringParamEscaped('SERVER', 'SERVER_ADDR', 'attr'); | |
| 180 | 123 | $tags = "<input type='hidden' name='url' value='".esc_attr($this->siteinfo->wpurl())."'/>\n". |
| 181 | 124 | "<input type='hidden' name='homeurl' value='".esc_attr($this->siteinfo->homeurl())."'/>\n". |
| 182 | 125 | "<input type='hidden' name='siteurl' value='".esc_attr($this->siteinfo->siteurl())."'/>\n". |
| 183 | 126 | "<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n". |
| @@ -183,9 +126,9 @@ | ||
| 183 | 126 | "<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n". |
| 184 | 127 | "<input type='hidden' name='plug' value='".esc_attr($this->bvinfo->plugname)."'/>\n". |
| 185 | 128 | "<input type='hidden' name='adminurl' value='".esc_attr($this->mainUrl())."'/>\n". |
| 186 | 129 | "<input type='hidden' name='bvversion' value='".esc_attr($this->bvinfo->version)."'/>\n". |
| 187 | - "<input type='hidden' name='serverip' value='".$server_ip."'/>\n". | |
| 130 | + "<input type='hidden' name='serverip' value='".esc_attr($_SERVER["SERVER_ADDR"])."'/>\n". | |
| 188 | 131 | "<input type='hidden' name='abspath' value='".esc_attr(ABSPATH)."'/>\n". |
| 189 | 132 | "<input type='hidden' name='secret' value='".esc_attr($secret)."'/>\n". |
| 190 | 133 | "<input type='hidden' name='public' value='".esc_attr($public)."'/>\n". |
| 191 | 134 | "<input type='hidden' name='bvnonce' value='".esc_attr($bvnonce)."'/>\n"; |
| @@ -212,20 +155,13 @@ | ||
| 212 | 155 | require_once dirname( __FILE__ ) . "/admin/account_details.php"; |
| 213 | 156 | } |
| 214 | 157 | |
| 215 | 158 | public function adminPage() { |
| 216 | - $bvnonce = WPRHelper::getRawParam('REQUEST', 'bvnonce'); | |
| 217 | - if ($bvnonce && wp_verify_nonce($bvnonce, 'bvnonce')) { | |
| 159 | + if (isset($_REQUEST['bvnonce']) && wp_verify_nonce( $_REQUEST['bvnonce'], 'bvnonce' )) { | |
| 218 | 160 | $info = array(); |
| 219 | 161 | $this->siteinfo->basic($info); |
| 220 | - | |
| 221 | - $pubkey = WPRHelper::getRawParam('REQUEST', 'pubkey'); | |
| 222 | - | |
| 223 | - if (!empty($pubkey)) { | |
| 224 | - $pubkey = WPRAccount::sanitizeKey($pubkey); | |
| 225 | - $this->bvapi->pingbv('/bvapi/disconnect', $info, $pubkey); | |
| 226 | - WPRAccount::remove($this->settings, $pubkey); | |
| 227 | - } | |
| 162 | + $this->bvapi->pingbv('/bvapi/disconnect', $info, $_REQUEST['pubkey']); | |
| 163 | + WPRAccount::remove($this->settings, $_REQUEST['pubkey']); | |
| 228 | 164 | } |
| 229 | 165 | if (WPRAccount::isConfigured($this->settings)) { |
| 230 | 166 | if (!isset($_REQUEST['add_account'])) { |
| 231 | 167 | $this->showAccountDetailsPage(); |
| @@ -236,17 +172,17 @@ | ||
| 236 | 172 | $this->showAddAccountPage(); |
| 237 | 173 | } |
| 238 | 174 | } |
| 239 | 175 | |
| 240 | - public function initWhitelabel($plugins) { | |
| 241 | - if (!is_array($plugins) || !$this->bvinfo->canWhiteLabel()) { | |
| 176 | + public function initBranding($plugins) { | |
| 177 | + $slug = $this->bvinfo->slug; | |
| 178 | + | |
| 179 | + if (!is_array($plugins) || !isset($slug, $plugins)) { | |
| 242 | 180 | return $plugins; |
| 243 | 181 | } |
| 244 | - $whitelabel_infos = $this->bvinfo->getPluginsWhitelabelInfos(); | |
| 245 | - foreach ($whitelabel_infos as $slug => $brand) { | |
| 246 | - if (!isset($slug) || !$this->bvinfo->canWhiteLabel($slug) || !array_key_exists($slug, $plugins) || !is_array($brand)) { | |
| 247 | - continue; | |
| 248 | - } | |
| 182 | + | |
| 183 | + $brand = $this->bvinfo->getBrandInfo(); | |
| 184 | + if (is_array($brand)) { | |
| 249 | 185 | if (array_key_exists('hide', $brand)) { |
| 250 | 186 | unset($plugins[$slug]); |
| 251 | 187 | } else { |
| 252 | 188 | if (array_key_exists('name', $brand)) { |
| @@ -274,5 +210,5 @@ | ||
| 274 | 210 | } |
| 275 | 211 | return $plugins; |
| 276 | 212 | } |
| 277 | 213 | } |
| 278 | -endif; | |
| 214 | +endif; | |