Jump to content

instantdie()?


Azu

Recommended Posts

the "page not found" you speak of is an apache (or other) server thing, not a PHP thing. die/exit both terminate the script at once. if you wish to replicate the not found page, you'll need to send a 404 header, which makes absolutely no difference to what is displayed but sends the correct header to the users browser/search engine bots, etc:

 

<?php
function die_404() {
   header("HTTP/1.1 404 Not Found");
   echo '<h1>Page not Found</h1>';
   die;
}

die_404();
?>

Link to comment
Share on other sites

Since the browser's response to trying a link to a non-existent URL is different depending on the browser you use, it seems resonable to assume that the 'server not found' message is a browser feature and not a server feature.

 

I guess that concludes this thread.

Link to comment
Share on other sites

Yes exactly that is what happens when it gets no response and it differs from browser to browser it's not something in the HTML.

 

So please tell me how to make PHP die instantly without sending anything to the browser so that the browser reacts that way.

Link to comment
Share on other sites

It can't. The instant your .php file is found by the server, check that... the instant the website ITSELF is found, your browser is aware of that. Then when your .php file is found, the server is going to generate green lights.

 

The party is kind of exposed at this point, and just instructing your script to halt any further execution is not going to hide the fact that the server AND the script do in fact exist.

 

PhREEEk

Link to comment
Share on other sites

From my experience it's impossible to send a header with the 404 status code from within a PHP script (at least on an Apache server), because when a file is found, it's found. Likewise, you can't trick the server into not knowing about the script it's running.

 

as i put earlier. works fine on any server that supports php.

 

 

<?php
function die_404() {
   header("HTTP/1.1 404 Not Found");
   echo '<h1>Page not Found</h1>';
   die;
}

die_404();
?>

 

Status codes like 404's are mainly useful for search engines, as they'll stop attempting to crawl the page in future.

 

In terms of the original question - Azu, it's not possible.

Link to comment
Share on other sites

Okay thanks.. well if it's not possible to do it this way, is there another way to make a client think my server is offline?

 

This is mainly for something I am making to try to automatically detect XSS attacks from E.G. automated tools and block them A.S.A.P.

 

And the most secure response is no response so ya.. I thought that this was how I should do it..

Link to comment
Share on other sites

Okay thanks.. well if it's not possible to do it this way, is there another way to make a client think my server is offline?

 

Block the request via your firewall. In iptables, a simple rule such as....

 

iptables -A INPUT -i eth0 -p tcp -s 203.0.178.211 --dport 80 -j DROP

 

would suffice. This sends absolutely nothing back to the client and the browser will eventualy time out.

Link to comment
Share on other sites

Thanks.. the whole point of this though is to instantly block it as soon as it happens though.. and all I really want to do is just tell my website not to respond to the request. Not my whole computer just my PHP website. So I'm not sure why a firewall would be needed. Also this needs to be something OS independent (isn't that the whole point of PHP? ^_^)

Link to comment
Share on other sites

Thanks.. the whole point of this though is to instantly block it as soon as it happens though..

 

That rule will work as soon as its executed.

 

and all I really want to do is just tell my website not to respond to the request. Not my whole computer just my PHP website.

 

No, you actually want your server to not respond. The easiest (and maybe only) way to do so is to not let the request actually get to the server.

 

Either way, if there is another solution to this problem, php isn't it. It happens far to far into the request to be able to do anything about it. Have a look through your servers documentation for another solution.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.