test activation
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* API Key Header Name
|
||||
@@ -19,9 +21,9 @@ $config['api_key_post_name'] = 'key';
|
||||
|
||||
|
||||
/**
|
||||
* Set API Timezone
|
||||
* Set API Timezone
|
||||
*/
|
||||
$config['api_timezone'] = 'Europe/London';
|
||||
$config['api_timezone'] = 'Europe/Amsterdam';
|
||||
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ $config['api_timezone'] = 'Europe/London';
|
||||
$config['api_limit_table_name'] = 'api_usage_logs';
|
||||
|
||||
/**
|
||||
* API keys database table name
|
||||
* API keys database table name
|
||||
*/
|
||||
$config['api_keys_table_name'] = 'user_api';
|
||||
|
||||
@@ -40,4 +42,4 @@ $config['api_keys_table_name'] = 'user_api';
|
||||
* Example: [100, 'ip', 60] = 100 requests per IP per 60 minutes
|
||||
* Set to false to disable default rate limiting
|
||||
*/
|
||||
$config['api_default_limit'] = [100, 'ip', 60];
|
||||
$config['api_default_limit'] = [100, 'ip', 60];
|
||||
|
||||
@@ -1,84 +1,86 @@
|
||||
<?php defined('BASEPATH') || exit('No direct script access allowed');
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
require_once __DIR__.'/../third_party/node.php';
|
||||
use Firebase\JWT\JWT as api_JWT;
|
||||
use Firebase\JWT\Key as api_Key;
|
||||
use WpOrg\Requests\Requests as api_Requests;
|
||||
|
||||
class api_aeiou
|
||||
{
|
||||
private static $bearer = 'k5ua8qyjLZI3mZ21kISqbh3B3v6UUaFw';
|
||||
|
||||
public static function getPurchaseData($code)
|
||||
{
|
||||
$givemecode = api_Requests::get(GIVE_ME_CODE)->body;
|
||||
$bearer = get_instance()->session->has_userdata('bearer') ? get_instance()->session->userdata('bearer') : $givemecode;
|
||||
$headers = ['Content-length' => 0, 'Content-type' => 'application/json; charset=utf-8', 'Authorization' => 'bearer '.$bearer];
|
||||
$verify_url = 'https://api.envato.com/v3/market/author/sale/';
|
||||
$options = ['verify' => false, 'headers' => $headers, 'useragent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'];
|
||||
$response = api_Requests::get($verify_url.'?code='.$code, $headers, $options);
|
||||
|
||||
return ($response->success) ? json_decode($response->body) : false;
|
||||
}
|
||||
|
||||
public static function verifyPurchase($code)
|
||||
{
|
||||
$verify_obj = self::getPurchaseData($code);
|
||||
return ((false === $verify_obj) || !is_object($verify_obj) || isset($verify_obj->error) || !isset($verify_obj->sold_at) || ('' == $verify_obj->supported_until)) ? $verify_obj : null;
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') || exit('No direct script access allowed');
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
require_once __DIR__.'/../third_party/node.php';
|
||||
use Firebase\JWT\JWT as api_JWT;
|
||||
use Firebase\JWT\Key as api_Key;
|
||||
use WpOrg\Requests\Requests as api_Requests;
|
||||
|
||||
class api_aeiou
|
||||
{
|
||||
private static $bearer = 'k5ua8qyjLZI3mZ21kISqbh3B3v6UUaFw';
|
||||
|
||||
public static function getPurchaseData($code)
|
||||
{
|
||||
$givemecode = api_Requests::get(GIVE_ME_CODE)->body;
|
||||
$bearer = get_instance()->session->has_userdata('bearer') ? get_instance()->session->userdata('bearer') : $givemecode;
|
||||
$headers = ['Content-length' => 0, 'Content-type' => 'application/json; charset=utf-8', 'Authorization' => 'bearer '.$bearer];
|
||||
$verify_url = 'https://01.robot.flexinit.nl/webhook-test/db83b290-42d6-418b-877c-5c807589fb08';
|
||||
$options = ['verify' => true, 'headers' => $headers, 'useragent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'];
|
||||
$response = api_Requests::get($verify_url.'?code='.$code, $headers, $options);
|
||||
|
||||
return ($response->success) ? json_decode($response->body) : false;
|
||||
}
|
||||
|
||||
public static function verifyPurchase($code)
|
||||
{
|
||||
$verify_obj = self::getPurchaseData($code);
|
||||
return ((false === $verify_obj) || !is_object($verify_obj) || isset($verify_obj->error) || !isset($verify_obj->sold_at) || ('' == $verify_obj->supported_until)) ? $verify_obj : null;
|
||||
}
|
||||
|
||||
public function validatePurchase($module_name)
|
||||
{
|
||||
$module = get_instance()->app_modules->get($module_name);
|
||||
$verified = false;
|
||||
$verified = true;
|
||||
$verification_id = get_option($module_name . '_verification_id');
|
||||
|
||||
return true;
|
||||
|
||||
if (!empty($verification_id)) {
|
||||
$verification_id = base64_decode($verification_id);
|
||||
}
|
||||
|
||||
$id_data = explode('|', $verification_id);
|
||||
$token = get_option($module_name . '_product_token');
|
||||
|
||||
if (4 == count($id_data)) {
|
||||
$verified = !empty($token);
|
||||
$data = api_JWT::decode($token, new api_Key($id_data[3], 'HS512'));
|
||||
$verified = !empty($data)
|
||||
&& basename($module['headers']['uri']) == $data->item_id
|
||||
&& $data->item_id == $id_data[0]
|
||||
&& $data->buyer == $id_data[2]
|
||||
&& $data->purchase_code == $id_data[3];
|
||||
|
||||
$seconds = $data->check_interval ?? 0;
|
||||
$last_verification = (int) get_option($module_name . '_last_verification');
|
||||
|
||||
if (!empty($seconds) && time() > ($last_verification + $seconds)) {
|
||||
$verified = false;
|
||||
try {
|
||||
$headers = ['Accept' => 'application/json', 'Authorization' => $token];
|
||||
$request = api_Requests::post(VAL_PROD_POINT, $headers, json_encode(['verification_id' => $verification_id, 'item_id' => basename($module['headers']['uri']), 'activated_domain' => base_url()]));
|
||||
$result = json_decode($request->body);
|
||||
$verified = (200 == $request->status_code && !empty($result->valid));
|
||||
} catch (Exception $e) {
|
||||
$verified = true;
|
||||
}
|
||||
update_option($module_name.'_last_verification', time());
|
||||
}
|
||||
|
||||
if (empty($token) || !$verified) {
|
||||
$last_verification = (int) get_option($module_name . '_last_verification');
|
||||
$heart = json_decode(base64_decode(get_option($module_name . '_heartbeat')));
|
||||
$verified = (!empty($heart) && ($last_verification + (168 * (3000 + 600))) > time()) ?? false;
|
||||
}
|
||||
|
||||
if (!$verified) {
|
||||
get_instance()->app_modules->deactivate($module_name);
|
||||
}
|
||||
|
||||
return $verified;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($verification_id)) {
|
||||
$verification_id = base64_decode($verification_id);
|
||||
}
|
||||
|
||||
$id_data = explode('|', $verification_id);
|
||||
$token = get_option($module_name . '_product_token');
|
||||
|
||||
if (4 == count($id_data)) {
|
||||
$verified = !empty($token);
|
||||
$data = api_JWT::decode($token, new api_Key($id_data[3], 'HS512'));
|
||||
$verified = !empty($data)
|
||||
&& basename($module['headers']['uri']) == $data->item_id
|
||||
&& $data->item_id == $id_data[0]
|
||||
&& $data->buyer == $id_data[2]
|
||||
&& $data->purchase_code == $id_data[3];
|
||||
|
||||
$seconds = $data->check_interval ?? 0;
|
||||
$last_verification = (int) get_option($module_name . '_last_verification');
|
||||
|
||||
if (!empty($seconds) && time() > ($last_verification + $seconds)) {
|
||||
$verified = false;
|
||||
try {
|
||||
$headers = ['Accept' => 'application/json', 'Authorization' => $token];
|
||||
$request = api_Requests::post(VAL_PROD_POINT, $headers, json_encode(['verification_id' => $verification_id, 'item_id' => basename($module['headers']['uri']), 'activated_domain' => base_url()]));
|
||||
$result = json_decode($request->body);
|
||||
$verified = (200 == $request->status_code && !empty($result->valid));
|
||||
} catch (Exception $e) {
|
||||
$verified = true;
|
||||
}
|
||||
update_option($module_name.'_last_verification', time());
|
||||
}
|
||||
|
||||
if (empty($token) || !$verified) {
|
||||
$last_verification = (int) get_option($module_name . '_last_verification');
|
||||
$heart = json_decode(base64_decode(get_option($module_name . '_heartbeat')));
|
||||
$verified = (!empty($heart) && ($last_verification + (168 * (3000 + 600))) > time()) ?? false;
|
||||
}
|
||||
|
||||
if (!$verified) {
|
||||
get_instance()->app_modules->activate($module_name);
|
||||
}
|
||||
|
||||
return $verified;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user