Skip to content

Commit

Permalink
- add dp_ prefix to the shared functions
Browse files Browse the repository at this point in the history
  • Loading branch information
r-brown committed Aug 16, 2014
1 parent 95af302 commit 35a1b9e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 43 deletions.
4 changes: 2 additions & 2 deletions digipass-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ private static function get_blog_ids()
*/
private static function single_activate()
{
// TODO: Define activation functionality here
// Activation functionality
}

/**
* Fired for each blog when the plugin is deactivated.
*/
private static function single_deactivate()
{
// TODO: Define deactivation functionality here
// Deactivation functionality
}

/**
Expand Down
6 changes: 3 additions & 3 deletions options.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


define('DP_OPTIONS', 'DP_OPTIONS');
define('API_KEY', '31c7bc4e-90ff-44fb-9f07-b88eb06ed9dc');
define('DP_API_KEY', '31c7bc4e-90ff-44fb-9f07-b88eb06ed9dc');


if (is_admin()) {
Expand Down Expand Up @@ -186,7 +186,7 @@ function dp_page_init()
register_setting(
'DP_OPTIONS_GROUP', // Option group
DP_OPTIONS, // Option name
'dp_sanitize' // dp_sanitize
'dp_sanitize' // Sanitize
);

add_settings_section(
Expand Down Expand Up @@ -216,7 +216,7 @@ function dp_page_init()
*/
function dp_sanitize($input)
{
$input['dp_netlicensing_apikey'] = dp_sanitize_text_field($input['dp_netlicensing_apikey']);
$input['dp_netlicensing_apikey'] = sanitize_text_field($input['dp_netlicensing_apikey']);

return $input;
}
Expand Down
6 changes: 5 additions & 1 deletion php/curl/curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @package curl
* @author Sean Huber <[email protected]>
**/
if (!class_exists('Curl')) {

class Curl {

/**
Expand Down Expand Up @@ -253,4 +255,6 @@ protected function set_request_options($url, $vars) {
}
}

}
}

}
6 changes: 5 additions & 1 deletion php/curl/curl_response.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package curl
* @author Sean Huber <[email protected]>
**/
if (!class_exists('CurlResponse')) {

class CurlResponse {

/**
Expand Down Expand Up @@ -75,4 +77,6 @@ function __toString() {
return $this->body;
}

}
}

}
76 changes: 40 additions & 36 deletions php/netlicensing/netlicensing.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,54 @@
* @package netlicensing
* @author Labs64 <[email protected]>
**/
class NetLicensing
{
if (!class_exists('NetLicensing')) {

const NLIC_BASE_URL = 'https://netlicensing.labs64.com/core/v2/rest';
class NetLicensing
{

private $curl = null;
const NLIC_BASE_URL = 'https://netlicensing.labs64.com/core/v2/rest';

/**
* Initializes a NetLicensing object
**/
function __construct($apiKey)
{
$user_agent = 'NetLicensing/PHP ' . PHP_VERSION . ' (http://netlicensing.labs64.com)' . '; ' . $_SERVER['HTTP_USER_AGENT'];
private $curl = null;

$this->curl = new Curl();
$this->curl->headers['Authorization'] = 'Basic ' . base64_encode("apiKey:" . $apiKey);
$this->curl->headers['Accept'] = 'application/json';
$this->curl->user_agent = $user_agent;
}
/**
* Initializes a NetLicensing object
**/
function __construct($apiKey)
{
$user_agent = 'NetLicensing/PHP ' . PHP_VERSION . ' (http://netlicensing.labs64.com)' . '; ' . $_SERVER['HTTP_USER_AGENT'];

/**
* Validates active licenses of the licensee
*
* Returns a object containing licensee validation result
*
* @param string $productNumber
* @param string $licenseeNumber
* @param string $licenseeName
* @return licensee validation result
**/
function validate($productNumber, $licenseeNumber, $licenseeName = '')
{
if (empty($licenseeName)) {
$licenseeName = $licenseeNumber;
$this->curl = new Curl();
$this->curl->headers['Authorization'] = 'Basic ' . base64_encode("apiKey:" . $apiKey);
$this->curl->headers['Accept'] = 'application/json';
$this->curl->user_agent = $user_agent;
}
$params = array(
'productNumber' => $productNumber,
'name' => $licenseeName,
);
$url = self::NLIC_BASE_URL . '/licensee/' . $licenseeNumber . '/validate';

$response = $this->curl->get($url, $params);
/**
* Validates active licenses of the licensee
*
* Returns a object containing licensee validation result
*
* @param string $productNumber
* @param string $licenseeNumber
* @param string $licenseeName
* @return licensee validation result
**/
function validate($productNumber, $licenseeNumber, $licenseeName = '')
{
if (empty($licenseeName)) {
$licenseeName = $licenseeNumber;
}
$params = array(
'productNumber' => $productNumber,
'name' => $licenseeName,
);
$url = self::NLIC_BASE_URL . '/licensee/' . $licenseeNumber . '/validate';

$response = $this->curl->get($url, $params);

return $response->body;
}

return $response->body;
}

}

0 comments on commit 35a1b9e

Please sign in to comment.