diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-content/plugins/portfolio/bws_menu/class-bws-settings.php --- a/wp/wp-content/plugins/portfolio/bws_menu/class-bws-settings.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-content/plugins/portfolio/bws_menu/class-bws-settings.php Tue Dec 15 13:49:49 2020 +0100 @@ -10,6 +10,7 @@ private $tabs; private $pro_plugin_is_activated = false; private $custom_code_args = array(); + private $bws_plugin_link = ''; public $plugin_basename; public $prefix; @@ -53,6 +54,8 @@ * @param array|string $args */ public function __construct( $args = array() ) { + global $wp_version; + $args = wp_parse_args( $args, array( 'plugin_basename' => '', 'prefix' => '', @@ -66,8 +69,6 @@ 'wp_slug' => '', 'demo_data' => false, /* if this is free version and pro exist */ - 'pro_page' => '', - 'bws_license_plugin' => '', 'link_key' => '', 'link_pn' => '', 'trial_days' => false, @@ -90,14 +91,27 @@ $this->doc_link = $args['doc_link']; $this->doc_video_link = $args['doc_video_link']; - $this->pro_page = $args['pro_page']; - $this->bws_license_plugin = $args['bws_license_plugin']; $this->link_key = $args['link_key']; $this->link_pn = $args['link_pn']; $this->trial_days = $args['trial_days']; $this->licenses = $args['licenses']; - $this->hide_pro_tabs = bws_hide_premium_options_check( $this->options ); + $this->pro_page = $this->bws_license_plugin = ''; + /* get $bws_plugins */ + require( dirname( __FILE__ ) . '/product_list.php' ); + if ( isset( $bws_plugins[ $this->plugin_basename ] ) ) { + if ( isset( $bws_plugins[ $this->plugin_basename ]['pro_settings'] ) ) { + $this->pro_page = $bws_plugins[ $this->plugin_basename ]['pro_settings']; + $this->bws_license_plugin = $bws_plugins[ $this->plugin_basename ]['pro_version']; + } + + $this->bws_plugin_link = substr( $bws_plugins[ $this->plugin_basename ]['link'],0 , strpos( $bws_plugins[ $this->plugin_basename ]['link'], '?' ) ); + + if ( ! empty( $this->link_key ) && ! empty( $this->link_pn ) ) + $this->bws_plugin_link .= '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version; + } + + $this->hide_pro_tabs = bws_hide_premium_options_check( $this->options ); $this->version = '1.0.0'; $this->is_multisite = is_multisite(); @@ -112,7 +126,7 @@ $this->licenses[ $this->plugins_info['TextDomain'] ] = array( 'name' => $this->plugins_info['Name'], 'slug' => $this->plugins_info['TextDomain'], - 'pro_slug' => stristr( $this->bws_license_plugin, '/', TRUE ), + 'pro_slug' => substr( $this->bws_license_plugin, 0, stripos( $this->bws_license_plugin, '/' ) ), 'basename' => $this->plugin_basename, 'pro_basename' => $this->bws_license_plugin ); @@ -156,7 +170,7 @@
is_pro ) { - if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) || isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $this->plugin_basename ] ) ) { + if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $this->plugin_basename ] ) || empty( $bstwbsftwppdtplgns_options['time_out'] ) || ! array_key_exists( $this->plugin_basename, $bstwbsftwppdtplgns_options['time_out'] ) ) { $license_type = 'Pro'; $license_status = __( 'Inactive', 'bestwebsoft' ) . ' ' . __( 'Learn More', 'bestwebsoft' ) . ''; } else { @@ -174,7 +188,7 @@ $license_status .= '. ' . __( 'Upgrade to Pro', 'bestwebsoft' ) . ''; } else { $license_type = isset( $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] ) ? 'Nonprofit Pro' : 'Pro'; - if ( $finish < $today ) { + if ( ! empty( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) && $finish < $today ) { $license_status = sprintf( __( 'Expired on %s', 'bestwebsoft' ), $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) . '. ' . __( 'Renew Now', 'bestwebsoft' ) . ''; } else { $license_status = __( 'Active', 'bestwebsoft' ); @@ -234,9 +248,8 @@ * @param void * @return void */ - public function display_tabs() { - global $wp_version; ?> -
> + public function display_tabs() { ?> +
    display_tabs_list(); ?>
@@ -452,7 +465,7 @@ 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started' ), 'php' => array( 'description' => sprintf( __( 'This PHP code will be hooked to the %s action and will be printed on front end only.', 'bestwebsoft' ), 'init' ), - 'learn_more_link' => 'http://php.net/' + 'learn_more_link' => 'https://php.net/' ), 'js' => array( 'description' => __( 'These code will be added to the header on all pages of your site.', 'bestwebsoft' ), 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript' @@ -631,6 +644,8 @@ */ private function save_options_misc() { global $bstwbsftwppdtplgns_options, $wp_version; + $notice = ''; + /* hide premium options */ if ( ! empty( $this->pro_page ) ) { if ( isset( $_POST['bws_hide_premium_options'] ) ) { @@ -692,7 +707,7 @@ ), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); - $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/products-statistics/track-usage/', $options ); + $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/products-statistics/track-usage/', $options ); if ( ! is_wp_error( $raw_response ) && 200 == wp_remote_retrieve_response_code( $raw_response ) ) { $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); @@ -722,43 +737,53 @@ help_phrase(); ?>
licenses as $single_license) { + foreach ( $this->licenses as $single_license ) { $pro_plugin_name = ( strpos( $single_license['name'], 'Pro' ) ) ? $single_license['name'] : $single_license['name'] . ' ' . 'Pro'; if ( ! empty( $this->pro_page ) || ! empty( $single_license['pro_basename'] ) ) { if ( $this->pro_plugin_is_activated && ( empty( $single_license['pro_basename'] ) || isset( $this->bws_license_plugin ) ) ) { - deactivate_plugins( $single_license['basename'] ); ?> - -

-

pro_page ) ) . '">' . __( 'Settings page', 'bestwebsoft' ) . '', '7' ); ?>

+ $url = 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $this->bws_license_plugin . '&bws_license_key=' . $bstwbsftwppdtplgns_options[ $this->bws_license_plugin ] . '&download_from=5'; ?> + + + + + +
+

+ +
+ +

+

+ +

+
+

+ +
+ +

+
+

+ +
+ +
+ +
+ +

+
bws_license_plugin ]['count'] ) && '5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] && $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) $attr = 'disabled="disabled"'; - - $license_key = ''; - if( ! empty( $single_license['pro_basename'] ) ) { + if ( ! empty( $single_license['pro_basename'] ) ) { $license_key = ! empty( $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] ) ? $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] : ''; - } - $current_plugin_link = ( ! empty( $this->link_key ) && ! empty( $this->link_pn ) ? esc_url( 'https://bestwebsoft.com/products/wordpress/plugins/' . $this->wp_slug . '/' . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ) : esc_url( 'https://bestwebsoft.com/products/wordpress/plugins/' . $this->wp_slug . '/' ) ); - ?> + } ?> @@ -767,7 +792,7 @@ type="hidden" name="bws_license_plugin_" value="" /> type="submit" class="button button-secondary" name="bws_license_submit" value="" />
- ' . $pro_plugin_name . '' ); ?> + bws_plugin_link . '" target="_blank" title="' . $pro_plugin_name . '">' . $pro_plugin_name . '' ); ?>

@@ -817,7 +842,9 @@ private function save_options_license_key() { global $wp_version, $bstwbsftwppdtplgns_options; /*$empty_field_error - added to avoid error when 1 field is empty while another field contains license key*/ - $empty_field_error = ''; + + $error = $message = $empty_field_error = ''; + foreach ( $this->licenses as $single_license) { $bws_license_key = ( isset( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) ? stripslashes( sanitize_text_field( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) : ''; if ( '' != $bws_license_key ) { @@ -838,15 +865,15 @@ if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { $to_send = array(); - $to_send["plugins"][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = $this->all_plugins[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]; - $to_send["plugins"][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]["bws_license_key"] = $bws_license_key; - $to_send["plugins"][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]["bws_illegal_client"] = true; + $to_send["plugins"][ $single_license['basename'] ] = $this->all_plugins[ $single_license['basename'] ]; + $to_send["plugins"][ $single_license['basename'] ]["bws_license_key"] = $bws_license_key; + $to_send["plugins"][ $single_license['basename'] ]["bws_illegal_client"] = true; $options = array( 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), 'body' => array( 'plugins' => serialize( $to_send ) ), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); - $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); + $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { $error = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ': BestWebSoft. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); @@ -875,6 +902,9 @@ if ( ! empty( $single_response->time_out ) ) { $message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.'; + } else { + /* lifetime */ + $single_response->time_out = NULL; } if ( isset( $single_response->trial ) && $this->is_trial ) { @@ -883,19 +913,19 @@ } if ( isset( $single_response->trial ) ) { - $bstwbsftwppdtplgns_options['trial'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = 1; + $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] = 1; } else { - unset( $bstwbsftwppdtplgns_options['trial'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ); + unset( $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] ); } if ( isset( $single_response->nonprofit ) ) { - $bstwbsftwppdtplgns_options['nonprofit'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = 1; + $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] = 1; } else { - unset( $bstwbsftwppdtplgns_options['nonprofit'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ); + unset( $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] ); } - if ( ! isset( $bstwbsftwppdtplgns_options[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] != $bws_license_key ) { - $bstwbsftwppdtplgns_options[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = $bws_license_key; + if ( ! isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options[ $single_license['basename'] ] != $bws_license_key ) { + $bstwbsftwppdtplgns_options[ $single_license['basename'] ] = $bws_license_key; $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt", "w+" ); if ( $file ) { @@ -905,9 +935,14 @@ $update_option = true; } - if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options['time_out'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] != $single_response->time_out ) { - $bstwbsftwppdtplgns_options['time_out'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = $single_response->time_out; - $update_option = true; + if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ) ) { + unset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ); + $update_option = true; + } + + if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] != $single_response->time_out ) { + $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] = $single_response->time_out; + $update_option = true; } if ( isset( $update_option ) ) { @@ -955,7 +990,7 @@ 'body' => array( 'plugins' => serialize( $to_send ) ), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); - $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); + $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { $error = __( "Something went wrong. Please try again later. If the error appears again, please contact us", 'bestwebsoft' ) . ': BestWebSoft. ' . __( "We are sorry for inconvenience.", 'bestwebsoft' ); @@ -979,72 +1014,7 @@ $bws_license_plugin = ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename']; $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; - - $url = 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $bws_license_plugin . '&bws_license_key=' . $bws_license_key . '&download_from=5'; - - if ( ! $this->upload_dir ) { - $this->upload_dir = wp_upload_dir(); - } - - $zip_name = explode( '/', $bws_license_plugin ); - - if ( ! function_exists( 'curl_init' ) ) { - $received_content = file_get_contents( $url ); - } else { - $ch = curl_init(); - curl_setopt( $ch, CURLOPT_URL, $url ); - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); - $received_content = curl_exec( $ch ); - curl_close( $ch ); - } - - if ( ! $received_content ) { - $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); - } else { - if ( is_writable( $this->upload_dir["path"] ) ) { - $file_put_contents = $this->upload_dir["path"] . "/" . $zip_name[0] . ".zip"; - if ( file_put_contents( $file_put_contents, $received_content ) ) { - @chmod( $file_put_contents, octdec( 755 ) ); - if ( class_exists( 'ZipArchive' ) ) { - $zip = new ZipArchive(); - if ( $zip->open( $file_put_contents ) === true ) { - $zip->extractTo( WP_PLUGIN_DIR ); - $zip->close(); - } else { - $error = __( "Failed to open the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); - } - } elseif ( class_exists( 'Phar' ) ) { - $phar = new PharData( $file_put_contents ); - $phar->extractTo( WP_PLUGIN_DIR ); - } else { - $error = __( "Your server does not support either ZipArchive or Phar. Please, upload the plugin manually.", 'bestwebsoft' ); - } - @unlink( $file_put_contents ); - } else { - $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); - } - } else { - $error = __( "UploadDir is not writable. Please, upload the plugin manually.", 'bestwebsoft' ); - } - } - - /* activate Pro */ - if ( file_exists( WP_PLUGIN_DIR . '/' . $zip_name[0] ) ) { - if ( $this->is_multisite && is_plugin_active_for_network( ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ) ) { - /* if multisite and free plugin is network activated */ - $active_plugins = get_site_option( 'active_sitewide_plugins' ); - $active_plugins[ $bws_license_plugin ] = time(); - update_site_option( 'active_sitewide_plugins', $active_plugins ); - } else { - /* activate on a single blog */ - $active_plugins = get_option( 'active_plugins' ); - array_push( $active_plugins, $bws_license_plugin ); - update_option( 'active_plugins', $active_plugins ); - } - $this->pro_plugin_is_activated = true; - } elseif ( empty( $error ) ) { - $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); - } + $this->pro_plugin_is_activated = true; } } else { $error = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft' ); @@ -1147,4 +1117,4 @@ } } } -} \ No newline at end of file +}