php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -
php newbie here, struggling crazy head around how go implementing http_referer-based security feature woefully inept downloads system.
basically, have file download pages have specific string appended end of url, specific string being:
?thanks
if visible in url, users able download file situated on it. works great, it's easy 'unlock' page adding '?thanks' part onto url themselves. allowing users bypass clumsy security , access premium files ease.
if possible, i'd add security measure whereby attempting access page containing string '?thanks' did not arrive page containing '?pending' redirected homepage. make perfect solution me.
just clarity, typical pre-download process goes this:
- user visits download page: [website]/download/page/123/
- user completes recaptcha, gets redirected here: [website]/download/page/123/?pending
- user fills in details, gets redirected here: [website]/download/page/123/?thanks
- user receives file
long-winded, yes, more ideal unusual requirements. know users can around first appending '?pending' url , appending '?thanks' afterwards, still really, no end.
so, stackoverflow, can of wizened , kindly coders fledgling web designer out? thank , help. cheers guys.
edit: oh, , here's 1 failed method last attempted bombed horribly, in case helps further illustrate goal:
if (('http://'.$_server['http_host'].$_server['request_uri'] == wp_get_shortlink().'?thanks') && (isset($_server['http_referer']) && preg_match("/".preg_quote('?pending',"/")."/i",$_server['http_referer']))) { echo 'hurrah!'; } else { echo 'oh dear.'; }
if depends on information in request itself, there's no way enforce you're trying do. referer arbitrary request header.
what need actual server side state. open session user, give process he's going through random unique id carried across each page in process , save progress , messages displayed next in session.
Comments
Post a Comment