Skip to content
Licenses

Check license

Systems and plugins developed by RIIS-DATA have a license number. Here you can check if a license is valid for a website.

How to check the license from the website

The website sends three things to RIIS-DATA and gets an answer back (valid or not):

licenseLicense numberRIIS-XXXX-XXXX-XXXX-XXXX
siteWebpage nameMy webpage
urlComing fromthe address of the website, e.g. https://www.example.no

Address: https://riis-data.no/api/license.php · POST (JSON) or GET

  1. Copy the file below and save it as riis-license.php on your website.
  2. Put it on the website and add these lines where the system starts (in WordPress: in the plugin or theme):
<?php
require __DIR__ . '/riis-license.php';

if (!riis_license_ok()) {
    echo riis_license_notice();   // or stop the system
}

The answer is saved for 12 hours, so RIIS-DATA is asked at most twice a day. If RIIS-DATA cannot be reached, the website keeps working. The answer is signed with the license number, so it cannot be faked.

Show the whole file
<?php
/**
 * RIIS-DATA license check for your website (PHP 7.4+, works in WordPress and any PHP site).
 *
 * 1. Save this file on your website, e.g. as riis-license.php
 * 2. Include it and check the license:
 *
 *        require __DIR__ . '/riis-license.php';
 *        if (!riis_license_ok()) {
 *            echo riis_license_notice();   // or stop the system / show a message to the admin
 *        }
 *
 * The answer is cached for 12 hours, so RIIS-DATA is contacted at most twice a day.
 * If RIIS-DATA cannot be reached, the website keeps working (it tries again within an hour).
 * The answer is signed with your license number, so it cannot be faked by a third party.
 */

const RIIS_LICENSE_KEY  = 'RIIS-XXXX-XXXX-XXXX-XXXX';     // license number
const RIIS_LICENSE_SITE = 'My webpage';    // webpage name
const RIIS_LICENSE_API  = 'https://riis-data.no/api/license.php';

/** Full check result: valid, status, message, product, expires_at … */
function riis_license_check(bool $force = false): array
{
    $cache = rtrim(sys_get_temp_dir(), '/\\') . '/riis_license_' . md5(RIIS_LICENSE_KEY . '|' . riis_license_url()) . '.json';
    if (!$force && is_file($cache)) {
        $c = json_decode((string)file_get_contents($cache), true);
        if (is_array($c) && ($c['_until'] ?? 0) > time()) {
            return $c;
        }
    }
    $nonce = bin2hex(random_bytes(8));
    $body = json_encode([
        'license' => RIIS_LICENSE_KEY,          // license number
        'site'    => RIIS_LICENSE_SITE,         // webpage name
        'url'     => riis_license_url(),        // coming from
        'nonce'   => $nonce,
    ]);
    $raw = false;
    if (function_exists('curl_init')) {
        $ch = curl_init(RIIS_LICENSE_API);
        curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body, CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 6, CURLOPT_HTTPHEADER => ['Content-Type: application/json']]);
        $raw = curl_exec($ch);
        curl_close($ch);
    } else {
        $raw = @file_get_contents(RIIS_LICENSE_API, false, stream_context_create(['http' => [
            'method' => 'POST', 'timeout' => 6, 'ignore_errors' => true, 'header' => "Content-Type: application/json\r\n", 'content' => $body]]));
    }
    $d = is_string($raw) ? json_decode($raw, true) : null;
    if (!is_array($d) || !isset($d['status'])) {
        // RIIS-DATA not reachable: do not block the website, try again within an hour
        $d = ['valid' => true, 'status' => 'offline', 'message' => 'License server not reachable', '_until' => time() + 3600];
    } elseif (isset($d['signature'])) {
        $expected = hash_hmac('sha256', implode('|', [!empty($d['valid']) ? '1' : '0', $d['status'], RIIS_LICENSE_KEY,
            $d['domain'] ?? '', $d['expires_at'] ?? '', $d['checked_at'] ?? '', $nonce]), RIIS_LICENSE_KEY);
        if (!hash_equals($expected, (string)$d['signature'])) {
            $d = ['valid' => false, 'status' => 'bad_signature', 'message' => 'The answer could not be verified'];
        }
        $d['_until'] = time() + 12 * 3600;
    } else {
        $d['_until'] = time() + 12 * 3600;      // unknown license number
    }
    @file_put_contents($cache, json_encode($d));
    return $d;
}

function riis_license_ok(): bool
{
    return !empty(riis_license_check()['valid']);
}

/** Message to show when the license is not valid. */
function riis_license_notice(): string
{
    $d = riis_license_check();
    return '<div style="padding:12px 16px;background:#fff0f2;border:1px solid #FF0027;border-radius:8px;font-family:sans-serif">'
        . '<strong>License:</strong> ' . htmlspecialchars((string)($d['message'] ?? 'Not valid')) . ' – RIIS-DATA</div>';
}

/** This website's address ("coming from"). */
function riis_license_url(): string
{
    if (function_exists('home_url')) {          // WordPress
        return home_url('/');
    }
    $https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || ($_SERVER['SERVER_PORT'] ?? '') == 443;
    return ($https ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost') . '/';
}

For websites without PHP: put this before </body>. It shows a red bar if the license is not valid.

<script>
fetch('https://riis-data.no/api/license.php', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    license: "RIIS-XXXX-XXXX-XXXX-XXXX",          // license number
    site: "My webpage",         // webpage name
    url: location.origin          // coming from
  })
})
  .then(r => r.json())
  .then(d => {
    if (!d.valid) {
      document.body.insertAdjacentHTML('afterbegin',
        '<div style="background:#FF0027;color:#fff;padding:10px;text-align:center">License: ' + d.message + '</div>');
    }
  });
</script>

To test from the command line, any programming language or directly in the browser:

curl -X POST https://riis-data.no/api/license.php \
  -H 'Content-Type: application/json' \
  -d '{"license":"RIIS-XXXX-XXXX-XXXX-XXXX","site":"My webpage","url":"https://www.example.no"}'

# or simply in the browser:
https://riis-data.no/api/license.php?license=RIIS-XXXX-XXXX-XXXX-XXXX&site=My+webpage&url=https%3A%2F%2Fwww.example.no
{
    "valid": true,
    "status": "valid",
    "message": "The license is valid.",
    "product": "RIIS Booking Plugin",
    "site_name": "My webpage",
    "domain": "example.no",
    "expires_at": "2027-12-31",
    "checked_at": "2026-10-19T19:14:51Z",
    "nonce": "a1b2c3",
    "signature": "9f2c…"
}
statusvalidMeaning
validtrueThe license is valid.
activatedtrueThe license is valid and is now registered to this website.
developmenttrueDevelopment address (localhost) – accepted, not registered.
invalidfalseThe license number does not exist.
domain_mismatchfalseThe license is not registered to this website.
expiredfalseThe license has expired.
suspendedfalseThe license is suspended. Contact RIIS-DATA.
revokedfalseThe license has been revoked.
missing_keyfalseNo license number was sent.
missing_urlfalseThe address of the website (url) is missing.

signature = HMAC-SHA256 of "valid|status|license|domain|expires_at|checked_at|nonce" with the license number as key (valid = 1 or 0). The PHP file checks it for you.

Customers find their license numbers in the customer portal under My licenses. Log in