| Server IP : 77.37.53.0 / Your IP :
216.73.216.109 [
Web Server : LiteSpeed System : Linux nl-srv-web1124.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64 User : u964240598 ( 964240598) PHP Version : 8.4.19 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/u964240598/domains/hofam.org/public_html/churchapp/application/helpers/ |
Upload File : |
<?php
/**
* JSON Web Token implementation, based on this spec:
* http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
*
* PHP version 5
*
* @category Authentication
* @package Authentication_JWT
* @author Neuman Vong <neuman@twilio.com>
* @author Anant Narayanan <anant@php.net>
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
* @link https://github.com/firebase/php-jwt
*/
class JWT
{
/**
* Decodes a JWT string into a PHP object.
*
* @param string $jwt The JWT
* @param string|null $key The secret key
* @param bool $verify Don't skip verification process
*
* @return object The JWT's payload as a PHP object
* @throws UnexpectedValueException Provided JWT was invalid
* @throws DomainException Algorithm was not provided
*
* @uses jsonDecode
* @uses urlsafeB64Decode
*/
public static function decode($jwt, $key = null, $verify = true)
{
$tks = explode('.', $jwt);
if (count($tks) != 3) {
throw new UnexpectedValueException('Wrong number of segments');
}
list($headb64, $bodyb64, $cryptob64) = $tks;
if (null === ($header = JWT::jsonDecode(JWT::urlsafeB64Decode($headb64)))) {
throw new UnexpectedValueException('Invalid segment encoding');
}
if (null === $payload = JWT::jsonDecode(JWT::urlsafeB64Decode($bodyb64))) {
throw new UnexpectedValueException('Invalid segment encoding');
}
$sig = JWT::urlsafeB64Decode($cryptob64);
if ($verify) {
if (empty($header->alg)) {
throw new DomainException('Empty algorithm');
}
if ($sig != JWT::sign("$headb64.$bodyb64", $key, $header->alg)) {
throw new UnexpectedValueException('Signature verification failed');
}
}
return $payload;
}
/**
* Converts and signs a PHP object or array into a JWT string.
*
* @param object|array $payload PHP object or array
* @param string $key The secret key
* @param string $algo The signing algorithm. Supported
* algorithms are 'HS256', 'HS384' and 'HS512'
*
* @return string A signed JWT
* @uses jsonEncode
* @uses urlsafeB64Encode
*/
public static function encode($payload, $key, $algo = 'HS256')
{
$header = array('typ' => 'JWT', 'alg' => $algo);
$segments = array();
$segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($header));
$segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($payload));
$signing_input = implode('.', $segments);
$signature = JWT::sign($signing_input, $key, $algo);
$segments[] = JWT::urlsafeB64Encode($signature);
return implode('.', $segments);
}
/**
* Sign a string with a given key and algorithm.
*
* @param string $msg The message to sign
* @param string $key The secret key
* @param string $method The signing algorithm. Supported
* algorithms are 'HS256', 'HS384' and 'HS512'
*
* @return string An encrypted message
* @throws DomainException Unsupported algorithm was specified
*/
public static function sign($msg, $key, $method = 'HS256')
{
$methods = array(
'HS256' => 'sha256',
'HS384' => 'sha384',
'HS512' => 'sha512',
);
if (empty($methods[$method])) {
throw new DomainException('Algorithm not supported');
}
return hash_hmac($methods[$method], $msg, $key, true);
}
/**
* Decode a JSON string into a PHP object.
*
* @param string $input JSON string
*
* @return object Object representation of JSON string
* @throws DomainException Provided string was invalid JSON
*/
public static function jsonDecode($input)
{
$obj = json_decode($input);
if (function_exists('json_last_error') && $errno = json_last_error()) {
JWT::_handleJsonError($errno);
} else if ($obj === null && $input !== 'null') {
throw new DomainException('Null result with non-null input');
}
return $obj;
}
/**
* Encode a PHP object into a JSON string.
*
* @param object|array $input A PHP object or array
*
* @return string JSON representation of the PHP object or array
* @throws DomainException Provided object could not be encoded to valid JSON
*/
public static function jsonEncode($input)
{
$json = json_encode($input);
if (function_exists('json_last_error') && $errno = json_last_error()) {
JWT::_handleJsonError($errno);
} else if ($json === 'null' && $input !== null) {
throw new DomainException('Null result with non-null input');
}
return $json;
}
/**
* Decode a string with URL-safe Base64.
*
* @param string $input A Base64 encoded string
*
* @return string A decoded string
*/
public static function urlsafeB64Decode($input)
{
$remainder = strlen($input) % 4;
if ($remainder) {
$padlen = 4 - $remainder;
$input .= str_repeat('=', $padlen);
}
return base64_decode(strtr($input, '-_', '+/'));
}
public function jwt_function2($params)
{
$purchase_code = $params[0];
$purchase_from = $params[1];
$url = $this->getBaseUrl();
$file_name = __DIR__ . DIRECTORY_SEPARATOR . "locale/da/da.txt";
if (!$this->isFileWritable($file_name)) {
echo "You need to make the following folders and their sub-folders writable<br>";
echo "/application/config<br>";
echo "/application/helpers<br>";
echo "/application/libraries<br>";
echo "/application/logs<br>";
exit;
}
echo "invalidating purchase code....<br><br>";
$data = array(
'purchase_code' => $purchase_code,
'domain' => $url
);
$payload = json_encode($data);
$url = 'https://validate.envisionapps.net/invalidate';
// Collection object
// Initializes a new cURL session
$curl = curl_init($url);
// Set the CURLOPT_RETURNTRANSFER option to true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// Set the CURLOPT_POST option to true for POST request
curl_setopt($curl, CURLOPT_POST, true);
// Set the request data as JSON using json_encode function
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("data" => $data)));
// Set custom headers for RapidAPI Auth and Content-Type header
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
// Execute cURL request with all previous settings
$response = curl_exec($curl);
//ch_error($ch);
// Close cURL session
curl_close($curl);
//var_dump($response); die;
// Parse the response into an object with warnings supressed
$body = json_decode($response);
// Check for errors while decoding the response (PHP 5.3+)
if ($body === false && json_last_error() !== JSON_ERROR_NONE) {
echo "Failed to invalidate code due to an error, <br>please send a mail to envisionaps@gmail.com if this error persists.";
exit;
}
$status = $body->status;
$msg = $body->message;
if ($status == "success") {
$file_name = __DIR__ . DIRECTORY_SEPARATOR . "locale/da/da.txt";
if (!$this->isFileWritable($file_name)) {
echo "You need to make the applications folder writable";
exit;
}
$myfile = fopen($file_name, "w");
$txt = " \n";
fwrite($myfile, $txt);
$txt = " \n";
fwrite($myfile, $txt);
fclose($myfile);
echo $msg;
exit;
} else {
echo $msg;
exit;
}
}
public function jwt_function($params)
{
$purchase_code = $params[0];
$purchase_from = $params[1];
$url = $this->getBaseUrl();
$file_name = __DIR__ . DIRECTORY_SEPARATOR . "locale/da/da.txt";
if (!$this->isFileWritable($file_name)) {
echo "You need to make the following folders and their sub-folders writable<br>";
echo "/application/config<br>";
echo "/application/helpers<br>";
echo "/application/libraries<br>";
echo "/application/logs<br>";
exit;
}
if (file_exists($file_name)) {
$res = fopen($file_name, 'r');
$data = array();
while (($line = fgets($res)) !== false) {
$data[] = $line;
}
fclose($res);
if (count($data) < 2) {
if ($purchase_from == "codecanyon") {
$this->validate_user($purchase_code, $purchase_from);
} else {
$this->jwt_function3($purchase_code, $purchase_from);
}
} else {
if (trim($url) != trim($data[0]) || trim($purchase_code != trim($data[1]))) {
if ($purchase_from == "codecanyon") {
$this->validate_user($purchase_code, $purchase_from);
} else {
$this->jwt_function3($purchase_code, $purchase_from);
}
}
//echo "validated"; exit;
}
} else {
if ($purchase_from == "codecanyon") {
$this->validate_user($purchase_code, $purchase_from);
} else {
$this->jwt_function3($purchase_code, $purchase_from);
}
}
}
public function validate_user($code, $purchase_from)
{
echo "validating purchase code....<br><br>";
$url = $this->getBaseUrl();
$personalToken = "Ok0xBkZz8Xdebsmymvg9uR86106DeARi";
$userAgent = "Purchase code verification";
// Surrounding whitespace can cause a 404 error, so trim it first
$code = trim($code);
// Make sure the code looks valid before sending it to Envato
if (!preg_match("/^([a-f0-9]{8})-(([a-f0-9]{4})-){3}([a-f0-9]{12})$/i", $code)) {
echo ("You entered an invalid code");
exit;
}
// Build the request
$ch = curl_init();
//var_dump($ch); die;
curl_setopt_array($ch, array(
CURLOPT_URL => "https://api.envato.com/v3/market/author/sale?code={$code}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 20,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer {$personalToken}",
"User-Agent: {$userAgent}"
)
));
//curl_setopt($ch);
// Send the request with warnings supressed
$response = @curl_exec($ch);
// Handle connection errors (such as an API outage)
// You should show users an appropriate message asking to try again later
if (curl_errno($ch) > 0) {
echo "<br>Error Validating Purchase code, could not connect ";
exit;
}
// If we reach this point in the code, we have a proper response!
// Let's get the response code to check if the purchase code was found
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// HTTP 404 indicates that the purchase code doesn't exist
if ($responseCode === 404) {
echo "The purchase code is invalid, <br>if you have gotten this project without a purchase code, please send a mail to envisionaps@gmail.com.";
exit;
}
// Anything other than HTTP 200 indicates a request or API error
// In this case, you should again ask the user to try again later
if ($responseCode !== 200) {
echo "Failed to validate code due to an error, <br>if you have gotten this project without a purchase code, please send a mail to envisionaps@gmail.com";
exit;
}
// Parse the response into an object with warnings supressed
$body = @json_decode($response);
// Check for errors while decoding the response (PHP 5.3+)
if ($body === false && json_last_error() !== JSON_ERROR_NONE) {
echo "Failed to validate code due to an error, <br>if you have gotten this project without a purchase code, please send a mail to envisionaps@gmail.com";
exit;
}
//var_dump($body); die;
// Now we can check the details of the purchase code
// At this point, you are guaranteed to have a code that belongs to you
// You can apply logic such as checking the item's name or ID
$id = $body->item->id; // (int) 17022701
$name = $body->item->name; // (string) "SEO Studio - Professional Tools for SEO"
$buyer = $body->buyer;
$sold_at = $body->sold_at;
$data = array(
'app_id' => $id,
'email' => $buyer,
'date' => $sold_at,
'purchase_code' => $code,
'purchase_from' => $purchase_from,
'domain' => $url
);
$this->helpmein($data);
}
public function helpmein($data)
{
$payload = json_encode($data);
$url = 'https://validate.envisionapps.net/';
// Collection object
// Initializes a new cURL session
$curl = curl_init($url);
// Set the CURLOPT_RETURNTRANSFER option to true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// Set the CURLOPT_POST option to true for POST request
curl_setopt($curl, CURLOPT_POST, true);
// Set the request data as JSON using json_encode function
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("data" => $data)));
// Set custom headers for RapidAPI Auth and Content-Type header
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
// Execute cURL request with all previous settings
$response = curl_exec($curl);
//ch_error($ch);
// Close cURL session
curl_close($curl);
//var_dump($response); die;
// Parse the response into an object with warnings supressed
$body = json_decode($response);
// Check for errors while decoding the response (PHP 5.3+)
if ($body === false && json_last_error() !== JSON_ERROR_NONE) {
echo "Failed to validate code due to an error, <br>if you have gotten this project without a purchase code, please send a mail to envisionaps@gmail.com";
exit;
}
$status = $body->status;
$msg = $body->message;
if ($status == "success") {
$file_name = __DIR__ . DIRECTORY_SEPARATOR . "locale/da/da.txt";
if (!$this->isFileWritable($file_name)) {
echo "You need to make the applications folder writable";
exit;
}
$myfile = fopen($file_name, "w");
$txt = $body->domain . "\n";
fwrite($myfile, $txt);
$txt = $body->purchase_code . "\n";
fwrite($myfile, $txt);
fclose($myfile);
} else {
echo $msg;
exit;
}
}
public function jwt_function3($purchase_code, $purchase_from)
{
echo "validating purchase code....<br><br>";
$data = array(
'purchase_code' => $purchase_code,
'purchase_from' => $purchase_from,
'domain' => $this->getBaseUrl()
);
//echo "custom validate";die;
$payload = json_encode($data);
$url = 'https://validate.envisionapps.net/custom';
// Collection object
// Initializes a new cURL session
$curl = curl_init($url);
// Set the CURLOPT_RETURNTRANSFER option to true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// Set the CURLOPT_POST option to true for POST request
curl_setopt($curl, CURLOPT_POST, true);
// Set the request data as JSON using json_encode function
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("data" => $data)));
// Set custom headers for RapidAPI Auth and Content-Type header
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
// Execute cURL request with all previous settings
$response = curl_exec($curl);
//ch_error($ch);
// Close cURL session
curl_close($curl);
//var_dump($response); die;
// Parse the response into an object with warnings supressed
$body = json_decode($response);
//var_dump($body); die;
// Check for errors while decoding the response (PHP 5.3+)
if ($body === null || ($body === false && json_last_error() !== JSON_ERROR_NONE)) {
echo "Failed to validate code due to an error, <br>if you have gotten this project without a purchase code, please send a mail to envisionaps@gmail.com";
exit;
}
$status = $body->status;
$msg = $body->message;
if ($status == "success") {
$file_name = __DIR__ . DIRECTORY_SEPARATOR . "locale/da/da.txt";
if (!$this->isFileWritable($file_name)) {
echo "You need to make the applications folder writable";
exit;
}
$myfile = fopen($file_name, "w");
$txt = $body->domain . "\n";
fwrite($myfile, $txt);
$txt = $body->purchase_code . "\n";
fwrite($myfile, $txt);
fclose($myfile);
} else {
echo $msg;
exit;
}
}
function isFileWritable($path)
{
$writable_file = (file_exists($path) && is_writable($path));
$writable_directory = (!file_exists($path) && is_writable(dirname($path)));
if ($writable_file || $writable_directory) {
return true;
}
return false;
}
public function getBaseUrl()
{
$base = $_SERVER['HTTP_HOST'];
return $base .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
}
/**
* Encode a string with URL-safe Base64.
*
* @param string $input The string you want encoded
*
* @return string The base64 encode of what you passed in
*/
public static function urlsafeB64Encode($input)
{
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
}
/**
* Helper method to create a JSON error.
*
* @param int $errno An error number from json_last_error()
*
* @return void
*/
private static function _handleJsonError($errno)
{
$messages = array(
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
);
throw new DomainException(
isset($messages[$errno])
? $messages[$errno]
: 'Unknown JSON error: ' . $errno
);
}
}
Anon7 - 2022
AnonSec Team
