Help me stop DDoS

1. QuyCuong (07.05.2013 / 07:43)
Can you help me write a script that hits the limit
time for 3.x rotorcms. I want some smaller hits
500. If you exceed the 500 will notice the entrance: the site is overloaded, please visit a few minutes
    function server_busy($numer){
    if (PHP_OS == ‘Linux’ AND @file_exists(‘/proc/loadavg’) AND $filestuff =@file_get_contents(‘/proc/loadavg’)){
    $loadavg = explode(‘ ’, $filestuff);
    if (trim($loadavg[0]) > $numer) {
    print ‘the site is overloaded, please visit a few minutes….’;
    exit(0);
    }
    }
    } 

    $srv = server_busy(500);
?>
I'm using 3.3.2 Rotorcms
code above does not work, please help me edit it,

2. STR (07.05.2013 / 08:01)
Give the reference to a site

3. bad (07.05.2013 / 08:47)
Nicht fershctein

4. shilo (07.05.2013 / 09:52)
500 - is a very very lot.
$srv = server_busy('5.00');
if load average > 5 (5.00) or 10, it is time to take action...
when load average is 500 server will not work ;-)

5. QuyCuong (07.05.2013 / 10:14)
4. shilo,
I do not understand what you say

6. shilo (07.05.2013 / 10:54)
$srv = server_busy('5.00');

^ That's done, 500 is a lot.
Кто на инглише свободно говорит, объясните ему что 500 это очень очень много, сервер с такой нагрузкой со свистом вылетает из стойки

7. Вячеслав (07.05.2013 / 11:17)
asked to explain...
$srv = server_busy(500); // is a server with 500 processor cores, you really have such a server?

otherwise do not run on a server with four cores, because max "loadavg" for him <= 8

8. QuyCuong (07.05.2013 / 12:46)
7. Trionix,
Thanks! but it does not work

9. iProfes (07.05.2013 / 17:05)
shilo (7 Мая 2013 / 10:54)
$srv = server_busy('5.00');

^ That's done, 500 is a lot.
Кто на инглише свободно говорит, объясните ему что 500 это очень очень много, сервер с такой нагрузкой со свистом вылетает из стойки
Не ему, а ей.

10. QuyCuong (07.05.2013 / 18:12)
Please help me

11. shilo (08.05.2013 / 08:55)
Please write to function fully, I will correct it

12. QuyCuong (08.05.2013 / 09:16)
includes/function.php
    function server_busy($numer){
    if (PHP_OS == 'Linux' AND @file_exists('/proc/loadavg') AND $filestuff =@file_get_contents('/proc/loadavg')){
    $loadavg = explode(' ', $filestuff);
    if (trim($loadavg[0]) > $numer) {
    print 'server busy, Please wait….';
    exit(0);
    }
    }
    } 

    $srv = server_busy('5.00');
?>
Thanks

13. shilo (08.05.2013 / 09:44)
12. QuyCuong, Checked out your function, it works.
Maybe file /proc/loadavg is not readable?

14. shilo (08.05.2013 / 10:00)
<?php
function server_busy($numer){
    if (PHP_OS == 'Linux' AND @file_exists('/proc/loadavg') AND $filestuff =@file_get_contents('/proc/loadavg')){
        $loadavg = explode(' ', $filestuff);
        if (trim($loadavg[0]) > $numer) {
                echo 'server busy, Please wait.';
                exit(0);
        }
        # :D EBUG
        # else {
        #       echo "OK";
        #}
        return trim($loadavg[0];
    }
}

$srv = server_busy('1.00');
?>


15. QuyCuong (08.05.2013 / 10:41)
shilo (8 Мая 2013 / 10:00)
<?php
function server_busy($numer){
    if (PHP_OS == 'Linux' AND @file_exists('/proc/loadavg') AND $filestuff =@file_get_contents('/proc/loadavg')){
        $loadavg = explode(' ', $filestuff);
        if (trim($loadavg[0]) > $numer) {
                echo 'server busy, Please wait.';
                exit(0);
        }
        # :D EBUG
        # else {
        #       echo "OK";
        #}
        return trim($loadavg[0];
    }
}

$srv = server_busy('1.00');
?>
It does not work, 501 hits without notice : Server busy , Please wait...

16. shilo (08.05.2013 / 15:02)
You probably do not quite understand what the script does ...
His script displays an error if the server is overloaded. it does not function as antiddos.

17. QuyCuong (08.05.2013 / 17:39)
for example, I rather $ s r v = s e r v e r _ b u s y ( ' 1 . 0 0 ' ) ; In order to check, why? I
want test some hits in 10 people

18. юЮЮфюв (08.05.2013 / 17:59)
To eliminate such problems should the administration of your server.
P.S. I do not speak English. But I think what you understand me.

URL: https://visavi.net/topics/37763