<?php if ($_GET["ne"]<>"lform"){?>
	<script type="text/JavaScript" language="JavaScript">
		jQuery(document).ready(function(){
			<?php if($s10<>0){?>
			if(jQuery("#updater") != 'undefined'){
				jQuery("#updater").load("fonksiyon.php?islem=updater");
			}
			<?php }?>
		});
	</script>
<?php }?>
<?php
	$ucrm = $_SERVER['REQUEST_URI'];
	$pcrm = explode('/',$ucrm);
	$pathcrm=$pcrm[count($pcrm)-2];
	if($optimize<>"" and $_SESSION["V3Server"]==""){
		echo "<i class=\"fa fa-exchange\" aria-hidden=\"true\"></i> ";
		if($uurl==1){
			//$Sqlca = mysqli_query($conn, "update ".$_SESSION['lang']." set n9='".$wurl."' where ne='ayarlar'");
		}
		$sqld=mysqli_query($conn, "select * from genel where ne='tanim' and t2='domain' and n1='".v3e(str_replace("www.","",$_SERVER['SERVER_NAME']))."'"); $rsd=mysqli_fetch_assoc($sqld);
		if(mysqli_num_rows($sqld)==0){
			$sql = $conn->query("insert into genel(t2,ne,n1,n2,n3,n4,n5,s10) VALUES ('domain', 'tanim', '".v3e(str_replace("www.","",$_SERVER['SERVER_NAME']))."', '', '', '', '', '0')");
		}
	}
	if($module["authenticator"]<>"1"){
		$iarr = array();
		foreach($module as $key=>$value){
			if($key=="authenticator"){
				$iarr = $iarr + array($key => "1");
			}else{
				$iarr = $iarr + array($key => $value);
			}
		}
		if (in_array('authenticator', $module)) {
			$iarr = $iarr + array('authenticator' => '1');
		}
		$jsiarr = json_encode($iarr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
		$Sqlca = mysqli_query($conn, "update ".$_SESSION['lang']." set n18='".addslashes(stripslashes($jsiarr))."' where ne='ayarlar'");
	}
/*
	$ht1="".trim($sdil[200])." ".trim($t22s[0])."";
	$st1="".trim($sdil[200])." ".trim($t21s[0])."";
	$kt1="".trim($sdil[200])." ".trim($t24s[0])."";
	$mt1="".trim($sdil[200])." ".trim($n8s[0])."";
	$sqll = mysqli_query($conn, "select * from ".$_SESSION['lang']." where t1='".$ht1."' or t1='".$st1."' or t1='".$kt1."' or t1='".$mt1."' or  t1='İlan Başlık' "); while($rs=mysqli_fetch_assoc($sqll)){
		for ($l = 1; $l <= $lx; $l++) {
			$sql = mysqli_query($conn, "delete from lang".$l." where id=".$rs["id"]);
		}
		$sqli=mysqli_query($conn, "select * from medya where ne='resim' and s1=".$rs["id"].""); while($rsi=mysqli_fetch_assoc($sqli)){
			$dosya1="../deppo/image/".$rsi["t1"]."";
			unlink($dosya1);
			$dosya2="../deppo/image/k_".$rsi["t1"]."";
			unlink($dosya2);
			$sqld = mysqli_query($conn, "delete from medya where s1=".$_GET["id"]);
		}
	}
*/
//#Optimize
//peryodik ödeme için açıklama başına "@" eklenir.
$sqlc=mysqli_query($conn, "select * from t4 where ne='cari' order by id desc"); while($hcari=mysqli_fetch_assoc($sqlc)){
	if($hcari["n1"][0]=="@"){
		if(dtarih($hcari["t4"],"gg")==date("d") and $hcari["n1"][0]=="@"){
			$sql = $conn->query("insert into t4(t1,t2,t4,ne,t6,t11,pb1,pb2,pb3,pb4,ts1,n1,s1,s5) values ('".$hcari["t1"]."', 'cari', '".date("Y-m-d")."', 'cari', '".$hcari["t6"]."', '".$hcari["t11"]."', '".$hcari["pb1"]."', '".$hcari["pb2"]."', '".$hcari["pb3"]."', '".$hcari["pb4"]."', now(), '".$hcari["n1"]."', '".$hcari["s1"]."', '".$hcari["s5"]."')");
			$Rs = mysqli_query($conn, "update t4 set n1='".ltrim($hcari["n1"],'@')."' Where id=".$hcari["id"]."");
		}
	}
}
$sqlh=mysqli_query($conn, "select * from t4 where ne='hizmet'"); while($rsh=mysqli_fetch_assoc($sqlh)){
	$itarih = explode('.',$rsh["t3"]);
	$starih = explode('.',$rsh["t4"]);
	if(count($itarih)<>"1" or count($starih)<>"1"){
		$fd1="".$itarih[2]."-".i2a($itarih[1],2)."-".i2a($itarih[0],2).""; $fd2="".$starih[2]."-".i2a($starih[1],2)."-".i2a($starih[0],2)."";
		$Rs = mysqli_query($conn, "update t4 set t3='".$fd1."', t4='".$fd2."', t11='', t12='' Where id=".$rsh["id"]."");
	}
}
$sqlb=mysqli_query($conn, "select * from eticaret where t5='sepet'"); while($rsb=mysqli_fetch_assoc($sqlb)){
	if($rsb["ts1"] < date('Y-m-d', strtotime(date("Y-m-d"). ' -7 days'))){
		$Rs = mysqli_query($conn, "delete from eticaret where id=".$rsb["id"]."");
	}
}
//#Optimize
//Takvim Sil
$sql=mysqli_query($conn, "select * from genel where ne='not' and t3<>'keep' and t5='' order by t2 asc"); while($rs=mysqli_fetch_assoc($sql)){
	if($rs["t9"]==""){
		if($rs["t4"] < date("Y-m-d") and $rs["s3"]==0){ $Rs = mysqli_query($conn, "delete from genel where id=".$rs["id"].""); } //Geçmiş Notları Sil
	}else{
		if($rs["t9"] < date("Y-m-d") and $rs["s3"]==0){ $Rs = mysqli_query($conn, "delete from genel where id=".$rs["id"].""); } //Geçmiş Notları Sil
	}
}
if($e2==1){
	$Sqlca = mysqli_query($conn, "update genel set t1='on' where ne='ayar'");
}
//#Log Clear
$directory = './deppo/datas';
$currentDate = new DateTime();
$files = glob($directory . '/*.json');
foreach ($files as $file) {
    $filename = basename($file);
    if (preg_match('/^\d{8}_log\.json$/', $filename)) {
        $fileDateString = substr($filename, 0, 8); // İlk 8 karakter
        $fileDate = DateTime::createFromFormat('Ymd', $fileDateString);
        if ($fileDate) {
            $interval = $fileDate->diff($currentDate);
            if ($interval->days > 15) {
                if (unlink($file)) {
                    echo "Silindi: $file\n";
                } else {
                    echo "Silinemedi: $file\n";
                }
            }
        }
    }
}
?>