php - Allow requests from certain URL's only -
i've made css template can sell. css hosted on server. want site's paid have access file, thought of php file echo's css, if url exists in 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 $url) { if ($url == $thisurl) { $css = file_get_contents('thecssfile.css'); } else { $css = file_get_contents('filewithlinktobuypage.css'); } } echo($css);
this safe way print css when host bought css file. how can url of requester?
people buy file use this: <link rel="stylesheet" type="text/css" href="http://domain.com/checklicence.php">
thanks
you can use:
$_server['http_referer'];
take consider though, referral address set user agent. not user agents set this, , provide ability modify http_referer feature. in short, cannot trusted.
Comments
Post a Comment