Jump to content

[SOLVED] Can You Check A Query String Variable For A Specific Path?


phpQuestioner

Recommended Posts

Is there anyway to look for a specific path in a variable sent by a query string?

 

Example:

 

 

http://www.domain.com/page1.php?pid=http://www.domain.com/pic1.jpg

 

Is the any way to make sure that "domain.com" is somewhere in the "pid" query string variable? Otherwise if it is not; use a header too go somewhere else.

 

Can this be done........?

 

PS: I am not trying to prevent hot linking of pics; I am trying to prevent hot linking of a page.

 

I created a script a while back that kind of does this. What it does is create a session if a page is accessed from with inside my domain and the session displays the page; otherwise the page will not display. The thing is that I cannot delete this session until after the browser closes. I used "session_destroy();" - but it did not delete the session. So now I want to be able to find a way to prevent access from outside of my domain; without sessions or cookies; this is my goal.

SemiApocalyptic,

 

Thank You - That will work great, but I modified it a little bit.

 

<?php
$gurl = $_SERVER['QUERY_STRING'];
$str="$gurl";
echo (eregi("pid=.*domain.com.*",$str)) ? "FOUND" : "NOT FOUND";
?>

 

 

And I Also Did This......

 

<?php
$gurl = $_SERVER['QUERY_STRING'];
$str="$gurl";
$valid = (eregi("pid=.*domain.com.*",$str)) ? "Yes" : "No";

if ($valid == Yes) {
echo "Welcome";
}
else {
echo "You Do Not Belong Here";
}
?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.