function wpsc_activate_gold_module() { if (isset($_POST['activate_gold_module']) && $_POST['activate_gold_module'] == 'true') { if ($_POST['activation_name'] != null) { update_option('activation_name', $_POST['activation_name']); } if (isset($_POST['activation_key'])) { update_option('activation_key', $_POST['activation_key']); } $target = "http://instinct.co.nz/wp-goldcart-api/api_register.php?name=" . $_POST['activation_name'] . "&key=" . $_POST['activation_key'] . "&url=" . get_option('siteurl') . ""; $remote_access_fail = false; $useragent = 'WP e-Commerce plugin'; $activation_name = urlencode($_POST['activation_name']); $activation_key = urlencode($_POST['activation_key']); $siteurl = urlencode(get_option('siteurl')); $request = ''; $http_request = "GET /wp-goldcart-api/api_register.php?name={$activation_name}&key={$activation_key}&url={$siteurl} HTTP/1.0\r\n"; $http_request .= "Host: instinct.co.nz\r\n"; $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; $http_request .= "Content-Length: " . strlen($request) . "\r\n"; $http_request .= "User-Agent: {$useragent}\r\n"; $http_request .= "\r\n"; $http_request .= $request; $response = ''; if (false != ($fs = @fsockopen('instinct.co.nz', 80, $errno, $errstr, 10))) { fwrite($fs, $http_request); while (!feof($fs)) { $response .= fgets($fs, 1160); } // One TCP-IP packet fclose($fs); $response = explode("\r\n\r\n", $response, 2); $returned_value = (int) trim($response[1]); // $returned_value = 1; if ($returned_value == 1) { if (get_option('activation_state') != 'true') { update_option('activation_state', 'true'); gold_shpcrt_install(); } ?> <div class="updated" style="min-width:45%; max-width:463px;"> <p> <?php _e('Thanks! The Gold Cart upgrade has been activated.', 'wpsc'); ?> <br /> <?php printf(__('New options have been added to %s, and your payment gateway list has been extended.', 'wpsc'), sprintf('<a href="options-general.php?page=wpsc-settings&tab=presentation">%s</a>', __('Settings -> Presentation', 'wpsc'))); ?> </p> </div> <?php } else { update_option('activation_state', "false"); echo '<div class="error"><p>' . __("Sorry, the API key was incorrect.", "wpsc") . '</p></div>'; } } } }
/** * Activate Gold Cart plugin */ function wpsc_activate_gold_module() { if (isset($_POST['activate_gold_module']) && $_POST['activate_gold_module'] == 'true') { if ($_POST['activation_name'] != null) { update_option('activation_name', $_POST['activation_name']); } if (isset($_POST['activation_key'])) { update_option('activation_key', $_POST['activation_key']); } //Action to perform if (isset($_POST['submit_values'])) { //register api $action = 'register'; } if (isset($_POST['reset_values'])) { //reset api $action = 'reset'; update_option('activation_key', ''); } $url = "https://wpecommerce.org/wp-goldcart-api/api_register.php"; $params = array('api' => 'v2', 'name' => base64_encode($_POST['activation_name']), 'key' => base64_encode($_POST['activation_key']), 'url' => base64_encode(esc_url_raw(site_url())), 'action' => $action); $url = add_query_arg($params, $url); $args = array('httpversion' => '1.0', 'sslverify' => false, 'timeout' => 15, 'user-agent' => 'Gold Cart/' . WPSC_GOLD_VERSION . '; ' . get_bloginfo('url')); $returned_value = wp_remote_retrieve_body(wp_remote_get($url, $args)); if ($returned_value === 'MQ==') { if (get_option('activation_state') != 'true') { update_option('activation_state', 'true'); gold_shpcrt_install(); } ?> <div class="updated" style="min-width:45%; max-width:463px;"> <p> <?php _e('Thanks! The Gold Cart upgrade has been activated.', 'wpsc_gold_cart'); ?> <br /> <?php printf(__('New options have been added to %s, and your payment gateway list has been extended.', 'wpsc_gold_cart'), sprintf('<a href="options-general.php?page=wpsc-settings&tab=presentation">%s</a>', __('Settings -> Presentation', 'wpsc_gold_cart'))); ?> </p> </div> <?php } else { if ($returned_value === 'Mg==') { //Reset API update_option('activation_state', "false"); echo '<div class="error"><p>Gold Cart upgrade has been deactivated!</p></div>'; } else { echo '<div class="error"><p>' . $returned_value . '</p></div>'; } } } }