- Joined
- May 2, 2018
- Messages
- 3,404
Last month I created and shared a script that can protect your landing pages from direct access if you use BeMob as a tracker. Since landing page protection is a paid feature in BeMob, I’ve decided to create a script that works with Skro tracker, since they offer that feature in their free plan.
Skro also provides PHP and JS code, but I wanted to create a script that works with CloudFlare Pages.
Anyway, the PHP code looks like this:
You’ll need to create a Protection Token on this page.
Click on the Generate token button and save that token somewhere for later use.
When
Skro also provides PHP and JS code, but I wanted to create a script that works with CloudFlare Pages.
Anyway, the PHP code looks like this:
Code:
const PROTECTION_TOKEN = ''; // Your landing protection token
const KEY_TTL = '30 minutes'; // How long KEY should be valid. Valid formats are explained here: http://php.net/manual/en/datetime.formats.php
const KEY_GET_PARAM = 'key'; // GET parameter with Skro landing key.
$key = isset($_GET[KEY_GET_PARAM]) ? rawurldecode($_GET[KEY_GET_PARAM]) : exit('Access denied');
if (!$key = base64_decode($key)) {
exit('Access denied');
}
if (!$key = json_decode($key, true)) {
exit('Access denied');
}
if (!isset($key['timestamp']) || !isset($key['hash'])) {
exit('Access denied');
}
$signedHash = hash_hmac('sha1', $key['timestamp'], PROTECTION_TOKEN);
if ($signedHash !== $key['hash'] || strtotime(KEY_TTL, $key['timestamp']) < time()) {
exit('Access denied');
}
You’ll need to create a Protection Token on this page.
Click on the Generate token button and save that token somewhere for later use.
When
Attachments
Last edited: