I've made a CSS template which I can sell. The css is hosted on my server. I only want site's who paid to have access to this file, so I thought of a php file which echo's the css, only if the url exists in an array.
<?php
header("Content-type: text/css");
$allowedUrls = ['google.com', 'facebook.com'];
$thisURL = "http://urlfromrequester.com"; //???
$thisURL = str_ireplace('www.', '', $thisURL);
$thisURL = (parse_url($thisURL, PHP_URL_HOST));
foreach ($allowedUrls as $url) {
if ($url == $thisURL) {
$css = file_get_contents('theCSSFile.css');
} else {
$css = file_get_contents('FileWithLinkToBuyPage.css');
}
}
echo($css);
This is a safe way to only print the css when the host bought the css file. But how can I get the URL of the requester?
People who buy this file will use it like this:
<link rel="stylesheet" type="text/css" href="http://domain.com/checkLicence.php">
Thanks