<?php

header('Content-Type: application/json');
header('Accept: */*');
header('Accept-Encoding: gzip,deflate,br');
header('Connection: keep-alive');
header('Access-Control-Allow-Origin: *');
function dbx_licence($endpoint = null)
{
    if ($endpoint != null) {
        $dataz = array('action' => 'licence_key_activate', 'store_code' => '3na80m79e2Q2FDR', 'license_key' => $_REQUEST['license_key']);
        $data = json_encode($dataz);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://dabex.eu/wp-json/woo-license-keys/v1/' . $endpoint);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLINFO_HEADER_OUT, true);
        $server_output = curl_exec($ch);
        $httpcode = curl_getinfo($ch);
        curl_close($ch);
        return $server_output;
    }
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_SERVER["CONTENT_TYPE"] == "application/json") {
    $data = trim(file_get_contents("php://input"));
    $json = json_decode($data, true);
    if (is_array($json)) {
        $_REQUEST = $json + $_REQUEST;
    }
    $run = dbx_licence('activate');
    echo $run;
}