Cách chặn IP vào admincp thì alucar đã có TUT hướng dẫn rồi mà làm thế thì với IP động hơi bất tiện mà chấp nhận nguyên 1 dải IP thì không hay cho lắm, mà mỗi lần muốn thêm ip vào admincp lại phải sửa file .htaccess hới mất thời gian nên lọ mọ áp dụng cách này từ vbb sang và đã chạy good @@ giờ share cho anh em. - Bước 1: Tạo 1 file php đặt tên là baomat.php PHP: <?php$list_ip = array( "127.0.0.1", // Local "202.78.227.157" // IP Hosting );$file_listip = "themip.txt"; // Kiem tra xem trong file themip.txt co ip dang truy cap khong.$fopen_ip = fopen($file_listip, "r"); while ( !feof($fopen_ip) ) { $read_ip = fgets($fopen_ip,50); $ip = explode('<nbb>', $read_ip); $list_ip[] = $ip[1]; } fclose($fopen_ip); if ( !in_array($_SERVER['REMOTE_ADDR'], $list_ip) ){ echo "<center></center>"; exit(); }?> - Bước 2: Tạo tiếp 1 file php đặt tên là themip.php PHP: <?phpSESSION_start();$pass = 'm4u.vn'; // Mat khau de them ip vao file txt$file_listip = "themip.txt"; // file txt co nhiem vu them ip?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>Kiểm tra IP</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><?php$fopen_ip = fopen($file_listip, "r"); while ( !feof($fopen_ip) ) { $read_ip = fgets($fopen_ip,50); $ip = explode('<nbb>', $read_ip); $list_ip[] = $ip[1]; } fclose($fopen_ip); if ( in_array($_SERVER['REMOTE_ADDR'], $list_ip) ){ echo "<center>IP của bạn đã được cập nhập sẵn.</center>"; }else { if ($_POST[submit]) { if ($_POST[code] == "$pass") $_SESSION['code'] = "$pass"; } if (!$_SESSION['code'] || $_SESSION['code'] != "$pass") { echo "<center><form action='' method=post> Code: <input type=password name=code> <input type=submit name=submit value=Submit> </form></center> "; exit; } $new_ip = $_SERVER['REMOTE_ADDR']; $fp = fopen($file_listip, "a+"); fputs ($fp, "<nbb>$new_ip<nbb>\n"); fclose($fp); echo "<center>IP của bạn đã được cập nhập thành công.</center>";}?></body></html> Đoạn này: PHP: $pass = 'm4u.vn'; là pass nhé - Bước 3: Ttiếp tục mở Notepad lên rồi lưu lại với tên themip.txt - Bước 4: Mở file admin.php thêm đoạn code này HTML: include("baomat.php"); dưới HTML: <?php - Bước 5: up tất cả lên host ngang hàng index * tác dụng của các file: khi các bạn gõ đường dẫn: http://yoursitename/admin.php nó sẽ đọc lệnh: include("baomat.php"); trước và chạy file baomat.php, file baomat.php sẽ check trong file themip.txt xem có địa chỉ IP bạn trong đó không, nếu có thì nó sẽ chuyển bạn tới khung đăng nhập của admincp, nếu không có thì nó sẽ hiện trang trắng @@. Để thêm IP bạn chạy link: http://yoursite/themip.php và nhập pass vào ô code Have fun. nguồn: http://m4u.vn