<?php
Returns a list of available endpoints
function get_endpoints()
{
$endpoints = './licenses/endpoints.txt';
if (file_exists($endpoints))
{
http_response_code(200);
header("Content-type: text/plain");
readfile($endpoints);
}
else
{
http_response_code(503);
header("Content-type: text/plain");
echo("ERROR - Endpoint list not found! Contact the site administrator if the problem persists.");
}
}
Returns a list of available license IDs. Limited to 5 licenses per row for readability.
function get_list()
{
$database = './licenses/licenses.txt';
if (file_exists($database))
{
http_response_code(200);
header("Content-type: text/plain");
$contents = file($database);
$displayed_text = "";
$max_per_line = 5;
$current_item = 0;
foreach ($contents as $line_num => $line)
{
$id = strtok($line, ' ');
$displayed_text .= $id . ', ';
++$current_item;
if ($current_item == $max_per_line)
{
$displayed_text .= "\n";
$current_item = 0;
}
}
$displayed_text = rtrim($displayed_text, ", ");
$displayed_text .= "\n";
echo $displayed_text;
}
else
{
http_response_code(503);
header("Content-type: text/plain");
echo("ERROR - License database not found! Contact the site administrator if the problem persists.");
}
}
Returns a detailed list of available licenses
function get_list_full()
{
$database = './licenses/licenses.txt';
if (file_exists($database))
{
http_response_code(200);
header('Content-Type: text/plain');
readfile($database);
}
else
{
http_response_code(503);
header("Content-type: text/plain");
echo("ERROR - License database not found! Contact the site administrator if the problem persists.");
}
}
Returns a single license using its ID
function get_license($license)
{
if (file_exists($license))
{
http_response_code(200);
header("Content-type: text/plain");
readfile($license);
echo ("\n");
}
else
{
http_response_code(404);
header("Content-type: text/plain");
echo("ERROR - " . strtolower($license) . " is undefined. Use list command to see defined license types.");
}
}
?>