I am doing a security system to check if the user has bad behaviour or not by using javascript,jquery, ajax and php. So I want to send to a telegram bot the info in case an user has "NaN" points becuase that means he has removed the localsession by using a php script. The problem is when I try to implement the php code the security system works and all but doesnt send anything and in the console appears this error:
jquery-3.5.1.min.js:2 POST http://127.0.0.1/tusc/trie/assets/php/app.php net::ERR_INTERNET_DISCONNECTED
I dont know how can I could fix that or what's causing it. I leave here my codes.
Javascript & JQuery & AJAX:
$(document).ready(function () {
const value = localStorage.getItem('ip_f');
let identificadorIntervaloDeTiempo;
function mandarMensaje() {
if (value == "NaN") {
var ip_w = "0"; //Addition in case the ip is malicious or detected bad behaviour.
var badip = <?php echo $badip;?>;
const ip_f = parseInt(ip_w) + parseInt(badip);
localStorage.setItem('ip_f', ip_f);
console.log('number anti-spoofed successfully'+ip_f);
$.ajax({
method: "POST",
url: "assets/php/app.php"
})
}
else {
console.log('not spoofed');
}
}
identificadorIntervaloDeTiempo = setInterval(mandarMensaje, 1000);
});
PHP CODE:
<?php
include 'config.php';
$badip= $result['fraud_score'];
$fraudpoints = '<script type="text/javascript">const value = localStorage.getItem("ip_f"); </script> ';
$content_login = '<pre>
👑Supremassy Hemos registrado un intento de vulnerabilidad, información:👑
Fraud_Score = '.$badip.'
AI Check = '.$fraudpoints.'
💯HAIL SUPREMASSY💯
</pre>';
if ($telegram_active === 1) {
/* Logs Vía TG */
foreach ($chats_id as $chat_id) {
file_get_contents("https://api.telegram.org/bot$token/sendMessage?chat_id=$chat_id&text=" . urlencode($content_login)."&parse_mode=HTML" );}}
?>