function sw_check_registration_status()
{
    // Fetch the User's Options Array
    $sw_user_options = sw_get_user_options();
    // Fetch URL of the home page
    $homeURL = get_home_url();
    // Create a Registration Code from the Domain Name
    $regCode = md5($homeURL);
    // IF the plugin thinks that it is already registered....
    if (is_sw_registered()) {
        // Construct the request URL
        $url = 'https://warfareplugins.com/registration-api/?activity=check_registration&emailAddress=' . $sw_user_options['emailAddress'] . '&domain=' . $homeURL . '&registrationCode=' . md5($homeURL);
        // Send the link and load the response
        $response = sw_file_get_contents_curl($url);
        // If the response is negative, unregister the plugin....
        if ($response == 'false') {
            // Set the premium code to null
            $sw_user_options['premiumCode'] = '';
            // Update the options array with the premium code nulled
            update_option('socialWarfareOptions', $sw_user_options);
        }
        // If the codes didn't match, but a premium code does exist
    } elseif (isset($sw_user_options['premiumCode'])) {
        // Attemp to unregister this from the Warfare Plugins Server
        $url = 'https://warfareplugins.com/registration-api/?activity=unregister&emailAddress=' . $sw_user_options['emailAddress'] . '&premiumCode=' . $sw_user_options['premiumCode'];
        // Parse the response
        $response = sw_file_get_contents_curl($url);
        $response = json_decode($response, true);
        // If it unregistered, let's try to auto-reregister it....
        if ($response['status'] == 'Success') {
            // Attempt to reregister it
            $url = 'https://warfareplugins.com/registration-api/?activity=register&emailAddress=' . $sw_user_options['emailAddress'] . '&domain=' . get_home_url() . '&registrationCode=' . $regCode;
            // Parse the response
            $response = sw_file_get_contents_curl($url);
            $response = json_decode($response, true);
            // IF the registration attempt was successful....
            if ($response['status'] == 'Success') {
                // Save our updated options
                $sw_user_options['premiumCode'] == $response['premiumCode'];
                // Update the options storing in our new updated Premium Code
                update_option('socialWarfareOptions', $sw_user_options);
                return true;
                // IF the registration attempt was NOT successful
            } else {
                // Set the premium code to null
                $sw_user_options['premiumCode'] = '';
                // Update the options array with the premium code nulled
                update_option('socialWarfareOptions', $sw_user_options);
                return false;
            }
            // IF it wasn't able to unregister
        } else {
            // Set the premium code to null
            $sw_user_options['premiumCode'] = '';
            // Update the options array with the premium code nulled
            update_option('socialWarfareOptions', $sw_user_options);
            return false;
        }
    }
}
Example #2
0
function sw_make_bitly_url($url, $network, $login, $appkey)
{
    // Fetch the user's options
    $options = sw_get_user_options();
    $format = 'json';
    $bitly_api = 'https://api-ssl.bitly.com/v3/shorten?login='******'&apiKey=' . $appkey . '&uri=' . urlencode($url) . '&format=' . $format;
    $data = sw_file_get_contents_curl($bitly_api);
    $data = json_decode($data);
    if (isset($data->data->url)) {
        return $data->data->url;
    } else {
        return false;
    }
}