<?php

include '../../config.php';

$aralik = time()-2592000;

$query = $db->query("SELECT * FROM kullanicilar WHERE user_songiris <= $aralik AND user_bot = 0", PDO::FETCH_ASSOC);

$mesajsayi = 0;

foreach ($query as $veri) {


	$user_id = $veri['user_id'];

	$query2 = $db->query("SELECT * FROM mesajlar WHERE (gonderen_id = $user_id OR alan_id = $user_id)", PDO::FETCH_ASSOC);

	$delete = $db->exec("DELETE FROM mesajlar WHERE (gonderen_id = $user_id OR alan_id = $user_id)");

	$mesajsayi = ($mesajsayi+$query2->rowCount());



}

echo $mesajsayi." Mesaj Temizlendi!";






echo "<br>";

$aralik2 = time()-345600;



	$delete = $db->exec("DELETE FROM ziyaretler WHERE time <= $aralik2");



echo "+++ Ziyaret Kaydı Temizlendi!";


echo "<br>";



$aralik3 = time()-2592000;




	$delete = $db->exec("DELETE FROM aramalar WHERE zaman <= $aralik3");

	//$mesajsayi = ($mesajsayi+$delete->rowCount());



echo "+++ Arama Kaydı Temizlendi!";


?>


