コード例 #1
0
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;
        }
    }
}
コード例 #2
0
function sw_options_registration($sw_options)
{
    // Add the Registration Tab and Tab Name
    $sw_options['tabs']['links']['registration'] = 'Registration';
    // Add the Registration Options Arrays
    $sw_options['options']['registration'] = array('registrationTitle' => array('type' => 'title', 'content' => 'Premium Registration'));
    $homeURL = get_home_url();
    $regCode = md5($homeURL);
    if (is_sw_registered()) {
        $sw_options['options']['registration']['registrationNotice'] = array('type' => 'paragraph', 'content' => '<span style="color:green" class="sw_registration_span sw_registered"><b>This copy of Social Warfare IS registered.</b></span>');
    } else {
        $sw_options['options']['registration']['registrationNotice'] = array('type' => 'paragraph', 'content' => '<span style="color:#ed464f" class="sw_registration_span sw_not_registered"><b>This copy of Social Warfare IS NOT registered.</b></span>');
    }
    $sw_options['options']['registration']['registrationInstructions'] = array('type' => 'paragraph', 'content' => '
		1. Enter Your Email.<br />
		2. Click on the "ACTIVATE PLUGIN" button.<br />
		3. Watch the magic.<br /><br />');
    $sw_options['options']['registration']['registrationCode'] = array('type' => 'paragraph', 'content' => '
		<div class="at-label"><label for="regCode">Registration Code</label></div><input type="text" class="at-text" name="regCode" id="regCode" value="' . $regCode . '" size="30" readonly><input type="hidden" class="at-text" name="domain" id="domain" value="' . $homeURL . '" size="30" readonly data-premcode="' . md5(md5($homeURL)) . '"><div class="clearfix"></div>
		');
    $sw_options['options']['registration']['emailAddress'] = array('type' => 'textbox', 'content' => 'Email Address');
    $sw_options['options']['registration']['premiumCode'] = array('type' => 'textbox', 'content' => 'Premium Code');
    $sw_options['options']['registration']['registrationActivateButton'] = array('type' => 'paragraph', 'content' => '<input type="submit" class="activate btn-info" value="Activate Plugin" />');
    $sw_options['options']['registration']['unregisterInstructions'] = array('type' => 'paragraph', 'content' => 'To unregister the plugin from this site, simply click the "Deactivate Plugin" button below. This will disable it\'s functionality on this site, but will free up your license, allowing you to register this plugin to a different domain.');
    $sw_options['options']['registration']['unregisterButtons'] = array('type' => 'paragraph', 'content' => '<input type="submit" class="deactivate btn-info" value="Deactivate Plugin" />');
    return $sw_options;
}