حظر دول معينة

بعد <body>

<div class="fNtf" id="cntryBlk" style="display:none;">
  <div>
    <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
      <circle cx="12" cy="12" r="10"></circle>
      <line x1="12" x2="12" y1="8" y2="12"></line>
      <line x1="12" x2="12.01" y1="16" y2="16"></line>
    </svg>
    <h5>الموقع غير متاح</h5>
    <p>عذرا لا يمكن الدخول الى هذا الموقع من بلدك حاليا</p>
  </div>
</div>
 

 

 قبل ]]></b:skin>

.fNtf{
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
background:rgba(0,0,0,0.85);
display:none;
align-items:center;
justify-content:center;
z-index:9999;
color:#fff;
text-align:center
}
.fNtf div{
background:#1b5a84;
padding:25px;
border-radius:10px;
max-width:420px;
width:90%;
box-shadow:0 0 15px rgba(27,90,132,0.6)
}
.fNtf svg{
width:55px;
height:55px;
stroke:#fff;
fill:none;
stroke-width:2;
margin-bottom:10px
}
.fNtf h5{
font-size:24px;
margin:5px 0
}
.fNtf p{
font-size:16px
}
 

 

قبل </body>

<script>
document.addEventListener("DOMContentLoaded", function () {

function checkBlock(){

const blockedTimeZones = ["Africa/Cairo","Asia/Manila","Asia/Jakarta"];
const blockedIPs = ["123.123.123.123","41.45.60.70"];

const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;

fetch("https://api.ipify.org?format=json")
.then(response => response.json())
.then(data => {

const userIP = data.ip;

if(blockedTimeZones.includes(userTimeZone) || blockedIPs.includes(userIP)){

const blocker = document.getElementById("cntryBlk");

if(blocker){
blocker.style.display="flex";
document.body.style.overflow="hidden";
}

}

});

}

checkBlock();

});
</script>
 

كاتب المقال محمد بلقاسم

محمد ذويب، مدون مهتم بالربح من الإنترنت، العملات الرقمية، والتسويق الإلكتروني. أشارك شروحات ودروسًا تساعد المبتدئين على تحقيق دخل عبر الإنترنت.

Previous Post Next Post

نموذج الاتصال