Jump to content

Warning: eregi() [function.eregi]: REG_EMPTY


tcollie

Recommended Posts

I'm trying prevent access to pages on my site unless they are called from another page on my server itself and I'm getting the following error:

[code]Warning: eregi() [function.eregi]: REG_EMPTY[/code]

Here is how I have this set up:

[code]
//This defines my root folder--In production this will be my domain
$root = 'localhost';

//This checks if the page referrer is a local page within my site
$webserver=apache_request_headers();
if( !eregi($root,$webserver[Referer])) {
//Okay to process here
}else{
//Stop Processing
}
[/code]

Can somebody help me out with this?
Link to comment
Share on other sites

Sorry, my bad.  I didn't understand what you were getting at.  I have put a link from a file called run.php to a page that echos $webserver[Referer] and here is what I get when I click the link and view my test.php page:

http://localhost/project/run.php

Link to comment
Share on other sites

Sorry, It left out some info on my post.

When I click a link to view my test.php page here is the info returned:

[code]http://localhost/project/run.php[/code]

And here is the code for my test.php page:
[code]$webserver=apache_request_headers();
//if( !eregi($root,$webserver[Referer])) {
echo $webserver[Referer];[/code]
Link to comment
Share on other sites

What is your PHP version?

This works for me:

[code]
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Load this page.</a>
<pre>
<?php
$root = 'localhost';
$webserver = apache_request_headers();
print_r($webserver);
if (!eregi($root, $webserver['Referer'])) {
echo "Not local";
} else {
echo "Local";
}
?>
</pre>
[/code]
Link to comment
Share on other sites

Guest
This topic is now 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.