Changeset 3259127
- Timestamp:
- 03/20/2025 12:37:03 PM (9 months ago)
- Location:
- really-simple-ssl/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (1 diff)
-
rlrsssl-really-simple-ssl.php (modified) (2 diffs)
-
upgrade/upgrade-to-pro.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
really-simple-ssl/trunk/readme.txt
r3250908 r3259127 152 152 153 153 == Changelog == 154 = 9.3.2.1 = 155 * March 20th, 2025 156 * Fix: Properly handle unknown plugins in upgrade requests, preventing unintended behavior. 157 154 158 = 9.3.2 = 155 159 * March 5th, 2025 -
really-simple-ssl/trunk/rlrsssl-really-simple-ssl.php
r3249448 r3259127 4 4 * Plugin URI: https://really-simple-ssl.com 5 5 * Description: Easily improve site security with WordPress Hardening, Two-Factor Authentication (2FA), Login Protection, Vulnerability Detection and SSL certificate generation. 6 * Version: 9.3.2 6 * Version: 9.3.2.1 7 7 * Requires at least: 5.9 8 8 * Requires PHP: 7.4 … … 114 114 define('rsssl_file', __FILE__); 115 115 } 116 define('rsssl_version', '9.3.2 ');116 define('rsssl_version', '9.3.2.1'); 117 117 define('rsssl_le_cron_generation_renewal_check', 20); 118 118 define('rsssl_le_manual_generation_renewal_check', 15); -
really-simple-ssl/trunk/upgrade/upgrade-to-pro.php
r3249448 r3259127 9 9 */ 10 10 if ( !class_exists('rsp_upgrade_to_pro') ){ 11 class rsp_upgrade_to_pro { 12 private $version = 1; 13 private $api_url = ""; 14 private $license = ""; 15 private $item_id = ""; 16 private $slug = ""; 17 private $health_check_timeout = 5; 18 private $plugin_name = ""; 19 private $plugin_constant = ""; 20 private $steps; 21 private $prefix; 22 private $dashboard_url; 23 private $instructions; 24 private $account_url; 25 26 /** 27 * Class constructor. 28 * 29 */ 30 public function __construct() { 31 32 if ( isset($_GET['license']) ) { 33 $this->license = sanitize_title($_GET['license']); 34 } 35 36 if ( isset($_GET['item_id']) ) { 37 $this->item_id = sanitize_title($_GET['item_id']); 38 } 39 40 if ( isset($_GET['plugin']) ) { 41 $plugin = sanitize_title($_GET['plugin']); 42 switch ($plugin) { 43 case "rsssl_pro": 44 $rsssl_admin_url = is_multisite() ? network_admin_url('settings.php') : admin_url("options-general.php"); 45 $this->slug = is_multisite() ? "really-simple-ssl-pro-multisite/really-simple-ssl-pro-multisite.php" : "really-simple-ssl-pro/really-simple-ssl-pro.php"; 46 $this->plugin_name = "Really Simple Security Pro"; 47 $this->plugin_constant = "rsssl_pro"; 48 $this->prefix = "rsssl_"; 49 $this->api_url = "https://really-simple-ssl.com"; 50 $this->dashboard_url = add_query_arg(["page" => "really-simple-security"], $rsssl_admin_url ); 51 $this->account_url = 'https://really-simple-ssl.com/account'; 52 $this->instructions = 'https://really-simple-ssl.com/knowledge-base/install-really-simple-ssl-pro'; 53 break; 54 case "cmplz_pro": 55 default: 56 $this->slug = is_multisite() ? "complianz-gdpr-premium-multisite/complianz-gpdr-premium.php" : "complianz-gdpr-premium/complianz-gpdr-premium.php"; 57 $this->plugin_name = "Complianz"; 58 $this->plugin_constant = "cmplz_premium"; 59 $this->prefix = "cmplz_"; 60 $this->api_url = "https://complianz.io"; 61 $this->dashboard_url = add_query_arg(["page" => "complianz"], admin_url("admin.php") ); 62 $this->account_url = 'https://complianz.io/account'; 63 $this->instructions = 'https://complianz.io/how-to-install-complianz-gdpr-premium-plugin'; 64 break; 65 } 66 } 67 68 $this->steps = array( 69 array( 70 'action' => 'rsp_upgrade_destination_clear', 71 'doing' => __("Checking if plugin folder exists...", "really-simple-ssl"), 72 'success' => __("Able to create destination folder", "really-simple-ssl"), 73 'error' => __("Destination folder already exists", "really-simple-ssl"), 74 'type' => 'folder', 75 ), 76 array( 77 'action' => 'rsp_upgrade_activate_license', 78 'doing' => __("Validating license...", "really-simple-ssl"), 79 'success' => __("License valid", "really-simple-ssl"), 80 'error' => __("License invalid", "really-simple-ssl"), 81 'type' => 'license', 82 ), 83 array( 84 'action' => 'rsp_upgrade_package_information', 85 'doing' => __("Retrieving package information...", "really-simple-ssl"), 86 'success' => __("Package information retrieved", "really-simple-ssl"), 87 'error' => __("Failed to gather package information", "really-simple-ssl"), 88 'type' => 'package', 89 ), 90 array( 91 'action' => 'rsp_upgrade_install_plugin', 92 'doing' => __("Installing plugin...", "really-simple-ssl"), 93 'success' => __("Plugin installed", "really-simple-ssl"), 94 'error' => __("Failed to install plugin", "really-simple-ssl"), 95 'type' => 'install', 96 ), 97 array( 98 'action' => 'rsp_upgrade_activate_plugin', 99 'doing' => __("Activating plugin...", "really-simple-ssl"), 100 'success' => __("Plugin activated", "really-simple-ssl"), 101 'error' => __("Failed to activate plugin", "really-simple-ssl"), 102 'type' => 'activate', 103 ) 104 ); 105 106 // Set up hooks. 107 $this->init(); 108 } 109 110 private function get_suggested_plugin($attr){ 111 $plugin_to_be_installed = $current_plugin = false; 112 if (isset($_GET['plugin']) && $_GET['plugin']==='cmplz_pro' ) { 113 $plugin_to_be_installed = 'complianz-gdpr'; 114 } else if (isset($_GET['plugin']) && $_GET['plugin']==='rsssl_pro' ) { 115 $plugin_to_be_installed = 'really-simple-ssl'; 116 } 117 118 $path = __FILE__; 119 if (strpos($path, 'really-simple-ssl')!==false) { 120 $current_plugin = 'really-simple-ssl'; 121 } else if (strpos($path, 'complianz')!==false){ 122 $current_plugin = 'complianz-gdpr'; 123 } 124 $dir_url = plugin_dir_url(__FILE__).'img/'; 125 126 127 if ( $plugin_to_be_installed === 'really-simple-ssl' ){ 128 $suggestion = [ 129 'icon_url' => $dir_url.'complianz-gdpr.png', 130 'constant' => 'cmplz_version', 131 'title' => 'Complianz GDPR/CCPA', 132 'description_short' => __('GDPR/CCPA Privacy Suite', "really-simple-ssl"), 133 'disabled' => '', 134 'button_text' => __("Install", "really-simple-ssl"), 135 'slug' => 'complianz-gdpr', 136 'description' => __('Configure your Cookie Notice, Consent Management and Cookie Policy with our Wizard and Cookie Scan. Supports GDPR, DSGVO, TTDSG, LGPD, POPIA, RGPD, CCPA and PIPEDA.', "really-simple-ssl"), 137 'install_url' => 'complianz+gdpr+POPIA&tab=search&type=term', 138 ]; 139 } 140 141 if ( $plugin_to_be_installed === 'complianz-gdpr' ){ 142 $suggestion = [ 143 'icon_url' => $dir_url.'really-simple-ssl.png', 144 'constant' => 'rsssl_version', 145 'title' => 'Really Simple Security', 146 'description_short' => __('One click SSL optimization', "really-simple-ssl"), 147 'disabled' => '', 148 'button_text' => __("Install", "really-simple-ssl"), 149 'slug' => 'really-simple-ssl', 150 'description' => __('Easily improve site security with WordPress Hardening, Two-Factor Authentication (2FA), Login Protection, Vulnerability Detection and SSL certificate generation.', "really-simple-ssl"), 151 'install_url' => 'ssl%20really%20simple%20plugins%20complianz+HSTS&tab=search&type=term', 152 ]; 153 if ( $current_plugin==='really-simple-ssl' ) { 154 $suggestion = $fallback_suggestion; 155 } 156 } 157 158 $admin_url = is_multisite() ? network_admin_url('plugin-install.php?s=') : admin_url('plugin-install.php?s='); 159 $suggestion['install_url'] = $admin_url.$suggestion['install_url']; 160 if (defined($suggestion['constant'])){ 161 $suggestion['install_url'] = '#'; 162 $suggestion['button_text'] = __("Installed", "really-simple-ssl"); 163 $suggestion['disabled'] = 'disabled'; 164 } 165 166 return $suggestion[$attr]; 167 } 168 169 /** 170 * Set up WordPress filters to hook into WP's update process. 171 * 172 * @uses add_filter() 173 * 174 * @return void 175 */ 176 public function init() { 177 add_action( 'admin_footer', array( $this, 'print_install_modal' ) ); 178 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets') ); 179 add_action( 'wp_ajax_rsp_upgrade_destination_clear', array($this, 'process_ajax_destination_clear') ); 180 add_action( 'wp_ajax_rsp_upgrade_activate_license', array($this, 'process_ajax_activate_license') ); 181 add_action( 'wp_ajax_rsp_upgrade_package_information', array($this, 'process_ajax_package_information') ); 182 add_action( 'wp_ajax_rsp_upgrade_install_plugin', array($this, 'process_ajax_install_plugin') ); 183 add_action( 'wp_ajax_rsp_upgrade_activate_plugin', array($this, 'process_ajax_activate_plugin') ); 184 } 185 186 /** 187 * Enqueue javascript 188 * @todo minification 189 */ 190 public function enqueue_assets( $hook ) { 191 if ( $hook === "plugins.php" && isset($_GET['install_pro']) ) { 192 $minified = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 193 wp_register_style( 'rsp-upgrade-css', plugin_dir_url(__FILE__) . "upgrade-to-pro$minified.css", false, $this->version ); 194 wp_enqueue_style( 'rsp-upgrade-css' ); 195 wp_enqueue_script( 'rsp-ajax-js', plugin_dir_url(__FILE__) . "ajax$minified.js", array(), $this->version, true ); 196 wp_enqueue_script( 'rsp-upgrade-js', plugin_dir_url(__FILE__) . "upgrade-to-pro$minified.js", array(), $this->version, true ); 197 wp_localize_script( 198 'rsp-upgrade-js', 199 'rsp_upgrade', 200 array( 201 'steps' => $this->steps, 202 'admin_url' => admin_url( 'admin-ajax.php' ), 203 'token' => wp_create_nonce( 'upgrade_to_pro_nonce'), 204 'cmplz_nonce' => wp_create_nonce( 'complianz_save'), 205 'finished_title' => __("Installation finished", "really-simple-ssl"), 206 ) 207 ); 208 } 209 } 210 211 /** 212 * Calls the API and, if successfull, returns the object delivered by the API. 213 * 214 * @uses get_bloginfo() 215 * @uses wp_remote_post() 216 * @uses is_wp_error() 217 * 218 * @return false|object 219 */ 220 private function api_request() { 221 if ( !rsssl_user_can_manage() ) { 222 return false; 223 } 224 global $edd_plugin_url_available; 225 226 // Do a quick status check on this domain if we haven't already checked it. 227 $store_hash = md5( $this->api_url ); 228 if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) { 229 $test_url_parts = parse_url( $this->api_url ); 230 $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : ''; 231 $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; 232 $test_url = 'https://' . $host . $port; 233 $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => true ) ); 234 $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true; 235 } 236 237 if ( false === $edd_plugin_url_available[ $store_hash ] ) { 238 return false; 239 } 240 241 if( $this->api_url == trailingslashit ( home_url() ) ) { 242 return false; // Don't allow a plugin to ping itself 243 } 244 245 $api_params = array( 246 'edd_action' => 'get_version', 247 'license' => ! empty( $this->license ) ? $this->license : '', 248 'item_id' => isset( $this->item_id ) ? $this->item_id : false, 249 'url' => home_url(), 250 ); 251 $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => true, 'body' => $api_params ) ); 252 if ( ! is_wp_error( $request ) ) { 253 $request = json_decode( wp_remote_retrieve_body( $request ) ); 254 } 255 256 if ( $request && isset( $request->sections ) ) { 257 $request->sections = maybe_unserialize( $request->sections ); 258 } else { 259 $request = false; 260 } 261 262 if ( $request && isset( $request->banners ) ) { 263 $request->banners = maybe_unserialize( $request->banners ); 264 } 265 266 if ( $request && isset( $request->icons ) ) { 267 $request->icons = maybe_unserialize( $request->icons ); 268 } 269 270 if( ! empty( $request->sections ) ) { 271 foreach( $request->sections as $key => $section ) { 272 $request->$key = (array) $section; 273 } 274 } 275 276 return $request; 277 } 278 279 /** 280 * Prints a modal with bullets for each step of the install process 281 */ 282 public function print_install_modal() 283 { 284 if ( !rsssl_user_can_manage() ) { 285 return false; 286 } 287 288 if ( is_admin() && isset($_GET['install_pro']) && isset($_GET['license']) && isset($_GET['item_id']) && isset($_GET['plugin']) ) { 289 $dashboard_url = $this->dashboard_url; 290 $plugins_url = admin_url( "plugins.php" ); 291 ?> 11 class rsp_upgrade_to_pro { 12 private $version = 1; 13 private $api_url = ""; 14 private $license = ""; 15 private $item_id = ""; 16 private $slug = ""; 17 private $health_check_timeout = 5; 18 private $plugin_name = ""; 19 private $plugin_constant = ""; 20 private $steps; 21 private $prefix; 22 private $dashboard_url; 23 private $instructions; 24 private $account_url; 25 26 // The plugins we only support upgrading to PRO for. 27 private $knownPlugins = [ 28 'rsssl_pro', 29 'cmplz_pro', 30 ]; 31 32 /** 33 * Class constructor. 34 */ 35 public function __construct() 36 { 37 if (!isset($_GET['license'], $_GET['item_id'], $_GET['plugin']) || (isset($_GET['install_pro']) && $_GET['install_pro'] !== 'true')) { 38 return; 39 } 40 41 if (!in_array($_GET['plugin'], $this->knownPlugins)) { 42 return; 43 } 44 45 $this->license = sanitize_title($_GET['license']); 46 $this->item_id = sanitize_title($_GET['item_id']); 47 48 $plugin = sanitize_title($_GET['plugin']); 49 switch ($plugin) { 50 case "rsssl_pro": 51 $rsssl_admin_url = is_multisite() ? network_admin_url('settings.php') : admin_url("options-general.php"); 52 $this->slug = is_multisite() ? "really-simple-ssl-pro-multisite/really-simple-ssl-pro-multisite.php" : "really-simple-ssl-pro/really-simple-ssl-pro.php"; 53 $this->plugin_name = "Really Simple Security Pro"; 54 $this->plugin_constant = "rsssl_pro"; 55 $this->prefix = "rsssl_"; 56 $this->api_url = "https://really-simple-ssl.com"; 57 $this->dashboard_url = add_query_arg(["page" => "really-simple-security"], $rsssl_admin_url ); 58 $this->account_url = 'https://really-simple-ssl.com/account'; 59 $this->instructions = 'https://really-simple-ssl.com/knowledge-base/install-really-simple-ssl-pro'; 60 break; 61 case "cmplz_pro": 62 default: 63 $this->slug = is_multisite() ? "complianz-gdpr-premium-multisite/complianz-gpdr-premium.php" : "complianz-gdpr-premium/complianz-gpdr-premium.php"; 64 $this->plugin_name = "Complianz"; 65 $this->plugin_constant = "cmplz_premium"; 66 $this->prefix = "cmplz_"; 67 $this->api_url = "https://complianz.io"; 68 $this->dashboard_url = add_query_arg(["page" => "complianz"], admin_url("admin.php") ); 69 $this->account_url = 'https://complianz.io/account'; 70 $this->instructions = 'https://complianz.io/how-to-install-complianz-gdpr-premium-plugin'; 71 break; 72 } 73 74 $this->steps = array( 75 array( 76 'action' => 'rsp_upgrade_destination_clear', 77 'doing' => __("Checking if plugin folder exists...", "really-simple-ssl"), 78 'success' => __("Able to create destination folder", "really-simple-ssl"), 79 'error' => __("Destination folder already exists", "really-simple-ssl"), 80 'type' => 'folder', 81 ), 82 array( 83 'action' => 'rsp_upgrade_activate_license', 84 'doing' => __("Validating license...", "really-simple-ssl"), 85 'success' => __("License valid", "really-simple-ssl"), 86 'error' => __("License invalid", "really-simple-ssl"), 87 'type' => 'license', 88 ), 89 array( 90 'action' => 'rsp_upgrade_package_information', 91 'doing' => __("Retrieving package information...", "really-simple-ssl"), 92 'success' => __("Package information retrieved", "really-simple-ssl"), 93 'error' => __("Failed to gather package information", "really-simple-ssl"), 94 'type' => 'package', 95 ), 96 array( 97 'action' => 'rsp_upgrade_install_plugin', 98 'doing' => __("Installing plugin...", "really-simple-ssl"), 99 'success' => __("Plugin installed", "really-simple-ssl"), 100 'error' => __("Failed to install plugin", "really-simple-ssl"), 101 'type' => 'install', 102 ), 103 array( 104 'action' => 'rsp_upgrade_activate_plugin', 105 'doing' => __("Activating plugin...", "really-simple-ssl"), 106 'success' => __("Plugin activated", "really-simple-ssl"), 107 'error' => __("Failed to activate plugin", "really-simple-ssl"), 108 'type' => 'activate', 109 ) 110 ); 111 112 // Set up hooks. 113 $this->init(); 114 } 115 116 private function get_suggested_plugin($attr){ 117 $plugin_to_be_installed = ''; 118 if (isset($_GET['plugin']) && $_GET['plugin']==='cmplz_pro' ) { 119 $plugin_to_be_installed = 'complianz-gdpr'; 120 } else if (isset($_GET['plugin']) && $_GET['plugin']==='rsssl_pro' ) { 121 $plugin_to_be_installed = 'really-simple-ssl'; 122 } 123 124 $dir_url = plugin_dir_url(__FILE__).'img/'; 125 126 $suggestion = [ 127 'icon_url' => $dir_url.'complianz-gdpr.png', 128 'constant' => 'cmplz_version', 129 'title' => 'Complianz GDPR/CCPA', 130 'description_short' => __('GDPR/CCPA Privacy Suite', "really-simple-ssl"), 131 'disabled' => '', 132 'button_text' => __("Install", "really-simple-ssl"), 133 'slug' => 'complianz-gdpr', 134 'description' => __('Configure your Cookie Notice, Consent Management and Cookie Policy with our Wizard and Cookie Scan. Supports GDPR, DSGVO, TTDSG, LGPD, POPIA, RGPD, CCPA and PIPEDA.', "really-simple-ssl"), 135 'install_url' => 'complianz+gdpr+POPIA&tab=search&type=term', 136 ]; 137 138 if ( $plugin_to_be_installed === 'complianz-gdpr' ){ 139 $suggestion = [ 140 'icon_url' => $dir_url.'really-simple-ssl.png', 141 'constant' => 'rsssl_version', 142 'title' => 'Really Simple Security', 143 'description_short' => __('One click SSL optimization', "really-simple-ssl"), 144 'disabled' => '', 145 'button_text' => __("Install", "really-simple-ssl"), 146 'slug' => 'really-simple-ssl', 147 'description' => __('Easily improve site security with WordPress Hardening, Two-Factor Authentication (2FA), Login Protection, Vulnerability Detection and SSL certificate generation.', "really-simple-ssl"), 148 'install_url' => 'ssl%20really%20simple%20plugins%20complianz+HSTS&tab=search&type=term', 149 ]; 150 } 151 152 $admin_url = is_multisite() ? network_admin_url('plugin-install.php?s=') : admin_url('plugin-install.php?s='); 153 $suggestion['install_url'] = $admin_url.$suggestion['install_url']; 154 if (defined($suggestion['constant'])){ 155 $suggestion['install_url'] = '#'; 156 $suggestion['button_text'] = __("Installed", "really-simple-ssl"); 157 $suggestion['disabled'] = 'disabled'; 158 } 159 160 return $suggestion[$attr]; 161 } 162 163 /** 164 * Set up WordPress filters to hook into WP's update process. 165 * 166 * @uses add_filter() 167 * 168 * @return void 169 */ 170 public function init() { 171 add_action( 'admin_footer', array( $this, 'print_install_modal' ) ); 172 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets') ); 173 add_action( 'wp_ajax_rsp_upgrade_destination_clear', array($this, 'process_ajax_destination_clear') ); 174 add_action( 'wp_ajax_rsp_upgrade_activate_license', array($this, 'process_ajax_activate_license') ); 175 add_action( 'wp_ajax_rsp_upgrade_package_information', array($this, 'process_ajax_package_information') ); 176 add_action( 'wp_ajax_rsp_upgrade_install_plugin', array($this, 'process_ajax_install_plugin') ); 177 add_action( 'wp_ajax_rsp_upgrade_activate_plugin', array($this, 'process_ajax_activate_plugin') ); 178 } 179 180 /** 181 * Enqueue javascript 182 * @todo minification 183 */ 184 public function enqueue_assets( $hook ) { 185 if ( $hook === "plugins.php" && isset($_GET['install_pro']) ) { 186 $minified = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 187 wp_register_style( 'rsp-upgrade-css', plugin_dir_url(__FILE__) . "upgrade-to-pro$minified.css", false, $this->version ); 188 wp_enqueue_style( 'rsp-upgrade-css' ); 189 wp_enqueue_script( 'rsp-ajax-js', plugin_dir_url(__FILE__) . "ajax$minified.js", array(), $this->version, true ); 190 wp_enqueue_script( 'rsp-upgrade-js', plugin_dir_url(__FILE__) . "upgrade-to-pro$minified.js", array(), $this->version, true ); 191 wp_localize_script( 192 'rsp-upgrade-js', 193 'rsp_upgrade', 194 array( 195 'steps' => $this->steps, 196 'admin_url' => admin_url( 'admin-ajax.php' ), 197 'token' => wp_create_nonce( 'upgrade_to_pro_nonce'), 198 'cmplz_nonce' => wp_create_nonce( 'complianz_save'), 199 'finished_title' => __("Installation finished", "really-simple-ssl"), 200 ) 201 ); 202 } 203 } 204 205 /** 206 * Calls the API and, if successfull, returns the object delivered by the API. 207 * 208 * @uses get_bloginfo() 209 * @uses wp_remote_post() 210 * @uses is_wp_error() 211 * 212 * @return false|object 213 */ 214 private function api_request() { 215 if ( !rsssl_user_can_manage() ) { 216 return false; 217 } 218 global $edd_plugin_url_available; 219 220 // Do a quick status check on this domain if we haven't already checked it. 221 $store_hash = md5( $this->api_url ); 222 if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) { 223 $test_url_parts = parse_url( $this->api_url ); 224 $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : ''; 225 $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; 226 $test_url = 'https://' . $host . $port; 227 $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => true ) ); 228 $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true; 229 } 230 231 if ( false === $edd_plugin_url_available[ $store_hash ] ) { 232 return false; 233 } 234 235 if( $this->api_url == trailingslashit ( home_url() ) ) { 236 return false; // Don't allow a plugin to ping itself 237 } 238 239 $api_params = array( 240 'edd_action' => 'get_version', 241 'license' => ! empty( $this->license ) ? $this->license : '', 242 'item_id' => isset( $this->item_id ) ? $this->item_id : false, 243 'url' => home_url(), 244 ); 245 $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => true, 'body' => $api_params ) ); 246 if ( ! is_wp_error( $request ) ) { 247 $request = json_decode( wp_remote_retrieve_body( $request ) ); 248 } 249 250 if ( $request && isset( $request->sections ) ) { 251 $request->sections = maybe_unserialize( $request->sections ); 252 } else { 253 $request = false; 254 } 255 256 if ( $request && isset( $request->banners ) ) { 257 $request->banners = maybe_unserialize( $request->banners ); 258 } 259 260 if ( $request && isset( $request->icons ) ) { 261 $request->icons = maybe_unserialize( $request->icons ); 262 } 263 264 if( ! empty( $request->sections ) ) { 265 foreach( $request->sections as $key => $section ) { 266 $request->$key = (array) $section; 267 } 268 } 269 270 return $request; 271 } 272 273 /** 274 * Prints a modal with bullets for each step of the install process 275 */ 276 public function print_install_modal() 277 { 278 if ( !rsssl_user_can_manage() ) { 279 return false; 280 } 281 282 if ( is_admin() && isset($_GET['install_pro']) && isset($_GET['license']) && isset($_GET['item_id']) && isset($_GET['plugin']) ) { 283 $dashboard_url = $this->dashboard_url; 284 $plugins_url = admin_url( "plugins.php" ); 285 ?> 292 286 <div id="rsp-step-template"> 293 287 <div class="rsp-install-step {step}"> … … 308 302 <div class="rsp-description_short"><?=$this->get_suggested_plugin('description_short')?></div> 309 303 <div class="rsp-rating"><?php 310 $plugin_info = $this->get_plugin_info($this->get_suggested_plugin('slug'));311 312 if (!is_wp_error($plugin_info) && !empty($plugin_info->rating)) {313 wp_star_rating([314 'rating' => $plugin_info->rating,315 'type' => 'percent',316 'number' => $plugin_info->num_ratings317 ]318 );319 }320 ?></div>304 $plugin_info = $this->get_plugin_info($this->get_suggested_plugin('slug')); 305 306 if (!is_wp_error($plugin_info) && !empty($plugin_info->rating)) { 307 wp_star_rating([ 308 'rating' => $plugin_info->rating, 309 'type' => 'percent', 310 'number' => $plugin_info->num_ratings 311 ] 312 ); 313 } 314 ?></div> 321 315 </div> 322 316 <div class="rsp-description"><?=$this->get_suggested_plugin('description')?></div> … … 337 331 <div class="rsp-footer"> 338 332 <a href="<?php echo $dashboard_url ?>" role="button" class="button-primary rsp-yellow rsp-hidden rsp-btn rsp-visit-dashboard"> 339 <?php echo __("Visit Dashboard", "really-simple-ssl") ?>333 <?php echo __("Visit Dashboard", "really-simple-ssl") ?> 340 334 </a> 341 335 <a href="<?php echo $plugins_url ?>" role="button" class="button-primary rsp-red rsp-hidden rsp-btn rsp-cancel"> 342 <?php echo __("Cancel", "really-simple-ssl") ?>336 <?php echo __("Cancel", "really-simple-ssl") ?> 343 337 </a> 344 338 <div class="rsp-error-message rsp-folder rsp-package rsp-install rsp-activate rsp-hidden"><span><?php _e('An error occurred:',"really-simple-ssl")?></span> <?php printf(__('Install %sManually%s.',"really-simple-ssl").' ', '<a target="_blank" rel="noopener noreferrer" href="'.$this->account_url.'">','</a>')?></div> … … 347 341 </div> 348 342 </div> 349 <?php350 }351 }352 353 354 /**355 * Retrieve plugin info for rating use356 *357 * @uses plugins_api() Get the plugin data358 *359 * @param string $slug The WP.org directory repo slug of the plugin360 *361 * @version 1.0362 */363 private function get_plugin_info($slug = '')364 {365 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';366 $plugin_info = get_transient('rsp_'.$slug . '_plugin_info');367 if ( empty($plugin_info) ) {368 $plugin_info = plugins_api('plugin_information', array('slug' => $slug));369 if (!is_wp_error($plugin_info)) {370 set_transient('rsp_'.$slug . '_plugin_info', $plugin_info, WEEK_IN_SECONDS);371 }372 }373 return $plugin_info;374 }375 376 /**377 * Ajax GET request378 *379 * Checks if the destination folder already exists380 *381 * Requires from GET:382 * - 'token' => wp_nonce 'upgrade_to_pro_nonce'383 * - 'plugin' (This will set $this->slug (Ex. 'really-simple-ssl-pro/really-simple-ssl-pro.php'), based on which plugin)384 *385 * Echoes array [success]386 */387 public function process_ajax_destination_clear()388 {389 $error = false;390 $response = [391 'success' => false,392 ];393 394 if ( !rsssl_user_can_manage() ) {395 $error = true;396 }343 <?php 344 } 345 } 346 347 348 /** 349 * Retrieve plugin info for rating use 350 * 351 * @uses plugins_api() Get the plugin data 352 * 353 * @param string $slug The WP.org directory repo slug of the plugin 354 * 355 * @version 1.0 356 */ 357 private function get_plugin_info($slug = '') 358 { 359 require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; 360 $plugin_info = get_transient('rsp_'.$slug . '_plugin_info'); 361 if ( empty($plugin_info) ) { 362 $plugin_info = plugins_api('plugin_information', array('slug' => $slug)); 363 if (!is_wp_error($plugin_info)) { 364 set_transient('rsp_'.$slug . '_plugin_info', $plugin_info, WEEK_IN_SECONDS); 365 } 366 } 367 return $plugin_info; 368 } 369 370 /** 371 * Ajax GET request 372 * 373 * Checks if the destination folder already exists 374 * 375 * Requires from GET: 376 * - 'token' => wp_nonce 'upgrade_to_pro_nonce' 377 * - 'plugin' (This will set $this->slug (Ex. 'really-simple-ssl-pro/really-simple-ssl-pro.php'), based on which plugin) 378 * 379 * Echoes array [success] 380 */ 381 public function process_ajax_destination_clear() 382 { 383 $error = false; 384 $response = [ 385 'success' => false, 386 ]; 387 388 if ( !rsssl_user_can_manage() ) { 389 $error = true; 390 } 397 391 398 392 if ( !isset($_GET['token']) || !wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce')) { … … 400 394 } 401 395 396 if ( ! current_user_can( 'activate_plugins' ) ) { 397 $error = true; 398 } 399 400 if (empty($this->slug)) { 401 $error = true; 402 $response['message'] = esc_html__('Unknown plugin encountered.', 'really-simple-ssl'); 403 } 404 402 405 if (!$error) { 403 if ( defined( $this->plugin_constant ) ) {404 deactivate_plugins( $this->slug );405 }406 407 $file = trailingslashit( WP_CONTENT_DIR ) . 'plugins/' . $this->slug;408 if ( file_exists( $file ) ) {409 $dir = dirname( $file );410 $new_dir = $dir . '_' . time();411 set_transient( 'rsssl_upgrade_dir', $new_dir, WEEK_IN_SECONDS );412 rename( $dir, $new_dir );413 //prevent uninstalling code by previous plugin414 unlink( trailingslashit( $new_dir ) . 'uninstall.php' );415 }416 } 417 418 if ( !$error && file_exists($file ) ) {419 $error = true;420 $response = [421 'success' => false,422 'message' => __("Could not rename folder!", "really-simple-ssl"),423 ];424 }425 426 if ( !$error && isset($_GET['plugin']) ) {427 if ( !file_exists(WP_PLUGIN_DIR . '/' . $this->slug) ) {428 $response = [429 'success' => true,430 ];431 }432 }433 434 $response = json_encode($response);435 header("Content-Type: application/json");436 echo $response;437 exit;438 }439 440 441 /**442 * Ajax GET request443 *444 * Links the license on the website to this site445 *446 * Requires from GET:447 * - 'token' => wp_nonce 'upgrade_to_pro_nonce'448 * - 'license'449 * - 'item_id'450 *451 * (Without this link you cannot download the pro package from the website)452 *453 * Echoes array [license status, response message]454 */455 public function process_ajax_activate_license()456 {457 $error = false;458 $response = [459 'success' => false,460 'message' => '',461 ];462 463 if ( !rsssl_user_can_manage() ) {464 $error = true;465 }466 467 if (!$error && isset($_GET['token']) && wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce') && isset($_GET['license']) && isset($_GET['item_id']) ) {468 $license = sanitize_title($_GET['license']);469 $item_id = (int) $_GET['item_id'];470 $response = $this->validate($license, $item_id);471 update_site_option($this->prefix.'auto_installed_license', $license);472 }473 474 $response = json_encode($response);475 header("Content-Type: application/json");476 echo $response;477 exit;478 }479 480 481 /**482 * Activate the license on the websites url at EDD483 *484 * Stores values in database:485 * - {$this->pro_prefix}license_activations_left486 * - {$this->pro_prefix}license_expires487 * - {$this->pro_prefix}license_activation_limit488 *489 * @param $license490 * @param $item_id491 *492 * @return array [license status, response message]493 */494 495 private function validate( $license, $item_id ): array {496 $message = "";497 $success = false;498 499 if ( !rsssl_user_can_manage() ) {500 return [501 'success' => $success,502 'message' => $message,503 ];504 }505 506 // data to send in our API request507 $api_params = array(508 'edd_action' => 'activate_license',509 'license' => $license,510 'item_id' => $item_id,511 'url' => home_url()512 );513 514 // Call the custom API.515 $response = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );516 517 // make sure the response came back okay518 if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {519 if ( is_wp_error( $response ) ) {520 $message = $response->get_error_message();521 } else {522 $message = __( 'An error occurred, please try again.', "really-simple-ssl");523 }524 } else {525 $license_data = json_decode( wp_remote_retrieve_body( $response ) );526 if ( false === $license_data->success ) {527 switch( $license_data->error ) {528 case 'expired' :529 $message = sprintf(530 __( 'Your license key expired on %s.', "really-simple-ssl"),531 date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) )532 );533 break;534 case 'disabled' :535 case 'revoked' :536 $message = __( 'Your license key has been disabled.', "really-simple-ssl");537 break;538 case 'missing' :539 $message = __('Missing license.', "really-simple-ssl");540 break;541 case 'invalid' :542 $message = __( 'Invalid license.', "really-simple-ssl");543 break;544 case 'site_inactive' :545 $message = __( 'Your license is not active for this URL.', "really-simple-ssl" );546 break;547 case 'item_name_mismatch' :548 $message = __( 'This appears to be an invalid license key for this plugin.', "really-simple-ssl" );549 break;550 case 'no_activations_left':551 $message = __( 'Your license key has reached its activation limit.', "really-simple-ssl");552 break;553 default :554 $message = __( 'An error occurred, please try again.', "really-simple-ssl" );555 break;556 }406 if ( defined( $this->plugin_constant ) ) { 407 deactivate_plugins( $this->slug ); 408 } 409 410 $file = trailingslashit( WP_CONTENT_DIR ) . 'plugins/' . $this->slug; 411 if ( file_exists( $file ) ) { 412 $dir = dirname( $file ); 413 $new_dir = $dir . '_' . time(); 414 set_transient( 'rsssl_upgrade_dir', $new_dir, WEEK_IN_SECONDS ); 415 rename( $dir, $new_dir ); 416 //prevent uninstalling code by previous plugin 417 unlink( trailingslashit( $new_dir ) . 'uninstall.php' ); 418 } 419 } 420 421 if ( !$error && file_exists($file ) ) { 422 $error = true; 423 $response = [ 424 'success' => false, 425 'message' => __("Could not rename folder!", "really-simple-ssl"), 426 ]; 427 } 428 429 if ( !$error && isset($_GET['plugin']) ) { 430 if ( !file_exists(WP_PLUGIN_DIR . '/' . $this->slug) ) { 431 $response = [ 432 'success' => true, 433 ]; 434 } 435 } 436 437 $response = json_encode($response); 438 header("Content-Type: application/json"); 439 echo $response; 440 exit; 441 } 442 443 444 /** 445 * Ajax GET request 446 * 447 * Links the license on the website to this site 448 * 449 * Requires from GET: 450 * - 'token' => wp_nonce 'upgrade_to_pro_nonce' 451 * - 'license' 452 * - 'item_id' 453 * 454 * (Without this link you cannot download the pro package from the website) 455 * 456 * Echoes array [license status, response message] 457 */ 458 public function process_ajax_activate_license() 459 { 460 $error = false; 461 $response = [ 462 'success' => false, 463 'message' => '', 464 ]; 465 466 if ( !rsssl_user_can_manage() ) { 467 $error = true; 468 } 469 470 if (!$error && isset($_GET['token']) && wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce') && isset($_GET['license']) && isset($_GET['item_id']) ) { 471 $license = sanitize_title($_GET['license']); 472 $item_id = (int) $_GET['item_id']; 473 $response = $this->validate($license, $item_id); 474 update_site_option($this->prefix.'auto_installed_license', $license); 475 } 476 477 $response = json_encode($response); 478 header("Content-Type: application/json"); 479 echo $response; 480 exit; 481 } 482 483 484 /** 485 * Activate the license on the websites url at EDD 486 * 487 * Stores values in database: 488 * - {$this->pro_prefix}license_activations_left 489 * - {$this->pro_prefix}license_expires 490 * - {$this->pro_prefix}license_activation_limit 491 * 492 * @param $license 493 * @param $item_id 494 * 495 * @return array [license status, response message] 496 */ 497 498 private function validate( $license, $item_id ): array { 499 $message = ""; 500 $success = false; 501 502 if ( !rsssl_user_can_manage() ) { 503 return [ 504 'success' => $success, 505 'message' => $message, 506 ]; 507 } 508 509 // data to send in our API request 510 $api_params = array( 511 'edd_action' => 'activate_license', 512 'license' => $license, 513 'item_id' => $item_id, 514 'url' => home_url() 515 ); 516 517 // Call the custom API. 518 $response = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); 519 520 // make sure the response came back okay 521 if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { 522 if ( is_wp_error( $response ) ) { 523 $message = $response->get_error_message(); 524 } else { 525 $message = __( 'An error occurred, please try again.', "really-simple-ssl"); 526 } 527 } else { 528 $license_data = json_decode( wp_remote_retrieve_body( $response ) ); 529 if ( false === $license_data->success ) { 530 switch( $license_data->error ) { 531 case 'expired' : 532 $message = sprintf( 533 __( 'Your license key expired on %s.', "really-simple-ssl"), 534 date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) ) 535 ); 536 break; 537 case 'disabled' : 538 case 'revoked' : 539 $message = __( 'Your license key has been disabled.', "really-simple-ssl"); 540 break; 541 case 'missing' : 542 $message = __('Missing license.', "really-simple-ssl"); 543 break; 544 case 'invalid' : 545 $message = __( 'Invalid license.', "really-simple-ssl"); 546 break; 547 case 'site_inactive' : 548 $message = __( 'Your license is not active for this URL.', "really-simple-ssl" ); 549 break; 550 case 'item_name_mismatch' : 551 $message = __( 'This appears to be an invalid license key for this plugin.', "really-simple-ssl" ); 552 break; 553 case 'no_activations_left': 554 $message = __( 'Your license key has reached its activation limit.', "really-simple-ssl"); 555 break; 556 default : 557 $message = __( 'An error occurred, please try again.', "really-simple-ssl" ); 558 break; 559 } 557 560 //in case of failure, rename back to default 558 $new_dir = get_transient('rsssl_upgrade_dir');561 $new_dir = get_transient('rsssl_upgrade_dir'); 559 562 if ( $new_dir ) { 560 if ( file_exists($new_dir ) ) {561 $default_file = trailingslashit(WP_CONTENT_DIR).'plugins/'.$this->slug;562 $default_dir = dirname($default_file);563 rename($new_dir, $default_dir);564 }563 if ( file_exists($new_dir ) ) { 564 $default_file = trailingslashit(WP_CONTENT_DIR).'plugins/'.$this->slug; 565 $default_dir = dirname($default_file); 566 rename($new_dir, $default_dir); 567 } 565 568 } 566 569 567 570 568 } else {569 $success = $license_data->license === 'valid';570 }571 }572 573 return [574 'success' => $success,575 'message' => $message,576 ];577 } 578 579 580 /**581 * Ajax GET request582 *583 * Do an API request to get the download link where to download the pro package584 *585 * Requires from GET:586 * - 'token' => wp_nonce 'upgrade_to_pro_nonce'587 * - 'license'588 * - 'item_id'589 *590 * Echoes array [success, download_link]591 */592 public function process_ajax_package_information()593 {594 if ( !rsssl_user_can_manage() ) {595 return false;596 }597 598 if ( isset($_GET['token']) && wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce') && isset($_GET['license']) && isset($_GET['item_id']) ) {599 $api = $this->api_request();600 if ( $api && isset($api->download_link) ) {601 $response = [602 'success' => true,603 'download_link' => $api->download_link,604 ];605 } else {606 $response = [607 'success' => false,608 'download_link' => "",609 ];610 }611 $response = json_encode($response);612 header("Content-Type: application/json");613 echo $response;614 exit;615 616 }617 }618 619 620 /**621 * Ajax GET request622 *623 * Download and install the plugin624 *625 * Requires from GET:626 * - 'token' => wp_nonce 'upgrade_to_pro_nonce'627 * - 'download_link'628 * (Linked license on the website to this site)629 *630 * Echoes array [success]631 */632 public function process_ajax_install_plugin()633 {634 $message = '';635 636 if ( !rsssl_user_can_manage() ) {637 return [638 'success' => false,639 'message' => $message,640 ];641 }642 643 if ( isset($_GET['token']) && wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce') && isset($_GET['download_link']) ) {644 645 $download_link = esc_url_raw($_GET['download_link']);646 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';647 include_once ABSPATH . 'wp-admin/includes/plugin-install.php';648 649 $skin = new WP_Ajax_Upgrader_Skin();650 $upgrader = new Plugin_Upgrader( $skin );651 $result = $upgrader->install( $download_link );652 653 if ( $result ) {654 $response = [655 'success' => true,656 ];657 } else {658 if ( is_wp_error($result) ){659 $message = $result->get_error_message();660 }661 $response = [662 'success' => false,663 'message' => $message,664 ];665 }666 667 $response = json_encode($response);668 header("Content-Type: application/json");669 echo $response;670 exit;671 }672 }673 674 675 /**676 * Ajax GET request677 *678 * Do an API request to get the download link where to download the pro package679 *680 * Requires from GET:681 * - 'token' => wp_nonce 'upgrade_to_pro_nonce'682 * - 'plugin' (This will set $this->slug (Ex. 'really-simple-ssl-pro/really-simple-ssl-pro.php'), based on which plugin)683 *684 * Echoes array [success]685 */686 public function process_ajax_activate_plugin()687 {688 if ( !rsssl_user_can_manage() ) {689 return;690 }691 692 if ( isset($_GET['token']) && wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce') && isset($_GET['plugin']) ) {693 $networkwide = is_multisite() && rsssl_is_networkwide_active();694 $result = activate_plugin( $this->slug, '', $networkwide );695 if ( !is_wp_error($result) ) {696 $response = [697 'success' => true,698 ];699 } else {700 $response = [701 'success' => false,702 ];703 }704 $response = json_encode($response);705 header("Content-Type: application/json");706 echo $response;707 exit;708 }709 }710 }711 $rsp_upgrade_to_pro = new rsp_upgrade_to_pro();571 } else { 572 $success = $license_data->license === 'valid'; 573 } 574 } 575 576 return [ 577 'success' => $success, 578 'message' => $message, 579 ]; 580 } 581 582 583 /** 584 * Ajax GET request 585 * 586 * Do an API request to get the download link where to download the pro package 587 * 588 * Requires from GET: 589 * - 'token' => wp_nonce 'upgrade_to_pro_nonce' 590 * - 'license' 591 * - 'item_id' 592 * 593 * Echoes array [success, download_link] 594 */ 595 public function process_ajax_package_information() 596 { 597 if ( !rsssl_user_can_manage() ) { 598 return false; 599 } 600 601 if ( isset($_GET['token']) && wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce') && isset($_GET['license']) && isset($_GET['item_id']) ) { 602 $api = $this->api_request(); 603 if ( $api && isset($api->download_link) ) { 604 $response = [ 605 'success' => true, 606 'download_link' => $api->download_link, 607 ]; 608 } else { 609 $response = [ 610 'success' => false, 611 'download_link' => "", 612 ]; 613 } 614 $response = json_encode($response); 615 header("Content-Type: application/json"); 616 echo $response; 617 exit; 618 619 } 620 } 621 622 623 /** 624 * Ajax GET request 625 * 626 * Download and install the plugin 627 * 628 * Requires from GET: 629 * - 'token' => wp_nonce 'upgrade_to_pro_nonce' 630 * - 'download_link' 631 * (Linked license on the website to this site) 632 * 633 * Echoes array [success] 634 */ 635 public function process_ajax_install_plugin() 636 { 637 $message = ''; 638 639 if ( !rsssl_user_can_manage() ) { 640 return [ 641 'success' => false, 642 'message' => $message, 643 ]; 644 } 645 646 if ( isset($_GET['token']) && wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce') && isset($_GET['download_link']) ) { 647 648 $download_link = esc_url_raw($_GET['download_link']); 649 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 650 include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; 651 652 $skin = new WP_Ajax_Upgrader_Skin(); 653 $upgrader = new Plugin_Upgrader( $skin ); 654 $result = $upgrader->install( $download_link ); 655 656 if ( $result ) { 657 $response = [ 658 'success' => true, 659 ]; 660 } else { 661 if ( is_wp_error($result) ){ 662 $message = $result->get_error_message(); 663 } 664 $response = [ 665 'success' => false, 666 'message' => $message, 667 ]; 668 } 669 670 $response = json_encode($response); 671 header("Content-Type: application/json"); 672 echo $response; 673 exit; 674 } 675 } 676 677 678 /** 679 * Ajax GET request 680 * 681 * Do an API request to get the download link where to download the pro package 682 * 683 * Requires from GET: 684 * - 'token' => wp_nonce 'upgrade_to_pro_nonce' 685 * - 'plugin' (This will set $this->slug (Ex. 'really-simple-ssl-pro/really-simple-ssl-pro.php'), based on which plugin) 686 * 687 * Echoes array [success] 688 */ 689 public function process_ajax_activate_plugin() 690 { 691 if ( !rsssl_user_can_manage() ) { 692 return; 693 } 694 695 if ( isset($_GET['token']) && wp_verify_nonce($_GET['token'], 'upgrade_to_pro_nonce') && isset($_GET['plugin']) ) { 696 $networkwide = is_multisite() && rsssl_is_networkwide_active(); 697 $result = activate_plugin( $this->slug, '', $networkwide ); 698 if ( !is_wp_error($result) ) { 699 $response = [ 700 'success' => true, 701 ]; 702 } else { 703 $response = [ 704 'success' => false, 705 ]; 706 } 707 $response = json_encode($response); 708 header("Content-Type: application/json"); 709 echo $response; 710 exit; 711 } 712 } 713 } 714 $rsp_upgrade_to_pro = new rsp_upgrade_to_pro(); 712 715 }
Note: See TracChangeset
for help on using the changeset viewer.