Professional Documents
Culture Documents
Gii php: ch ng gii hn s kt ni truy vn tin (lt truy cp) cng mt thi im.
Thm dng on m sau vo trang ch ca website.
function server_busy($numer) {
if (THIS_IS == 'WEBSITE' && PHP_OS == 'Linux' and @file_exists ( '/proc/loadavg' ) and $filestuff =
@file_get_contents ( '/proc/loadavg' )) {
$loadavg = explode ( ' ', $filestuff );
if (trim ( $loadavg [0] ) > $numer) {
print '<meta http-equiv="content-type" content="text/html; charset=UTF-8" />';
print 'Lng truy cp ang qu ti, mi bn quay li sau vi pht.';
exit ( 0 );
}
}
}
$srv = server_busy ( 100 ); // 100 l s ngi truy cp ti 1 thi im
on m trn c ngha cho php 100 ngi online trn website ti mt thi im. Nu vt qua
s 1000 th khch truy cp s nhn c thng bo: Lng truy cp ang qu ti. Mi bn quay li
sau vi pht.