I am trying to understand the below code how exactly it was verifying the license key and can it be bypassed in php file its self to put self license key and get verified
<?php
session_start();
if (!function_exists('curl_init')) {
die('cURL is not available on your server! Please enable cURL to continue the installation. You can read the documentation for more information.');
}
function currentUrl($server)
{
$http = 'http';
if (isset($server['HTTPS'])) {
$http = 'https';
}
$host = $server['HTTP_HOST'];
$requestUri = $server['REQUEST_URI'];
return $http . '://' . htmlentities($host) . '/' . htmlentities($requestUri);
}
$current_url = currentUrl($_SERVER);
if (isset($_POST["btn_purchase_code"])) {
$_SESSION["purchase_code"] = $_POST['purchase_code'];
$response = "";
$url = "http://jobsearchers.in/api/license?purchase_code=" . $_POST['purchase_code'] . "&domain=" . $current_url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
if (empty($response)) {
$url = "http://jobsearchers/api/license?purchase_code=" . $_POST['purchase_code'] . "&domain=" . $current_url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
}
$data = json_decode($response);
if (!empty($data)) {
if ($data->status == "300" || $data->status == "400") {
$_SESSION["error"] = "Invalid purchase code!";
} else {
$_SESSION["status"] = $data->status;
$_SESSION["license_code"] = $data->license_code;
header("Location: folder-permissions.php");
exit();
}
} else {
$_SESSION["error"] = "Invalid purchase code!";
}
}
?>
I tried removing the curl and place my own key in $data
place like $data = 123456789
and tried to validate it doesn't work.