<?php
if(!isset($CRON_GUVENLIK)){
    echo "cron dosyasını manuel çalıştıramazsınız";
    exit;
}


require_once "mp-content/init.php";

$loglar = $db->query("select * from crons_report")->fetchAll(PDO::FETCH_ASSOC);

if (!is_dir('mp-content/log')) {
	mkdir('mp-content/log');
}
if (!is_dir('mp-content/log/crons_report')) {
	mkdir('mp-content/log/crons_report');
}
$dosya_adi = date("m-Y") . '.txt';
$myfile = fopen("mp-content/log/crons_report/" . $dosya_adi, "a") or die("Unable to open file!");

$txt = "";
foreach ($loglar as $log) {
	$log = (object)$log;

	$txt .= $log->report_date . ' | ' . $log->report_service_id . ' | ' . $log->report_detail . "\n";
}

if (count($loglar) > 0)
	fwrite($myfile, $txt);

fclose($myfile);

$sil = $db->query("TRUNCATE TABLE crons_report");
?>