<?php
Error_Reporting(4);
include_once("../tools/inc.php");
$PATH=$config["path"];
$DOCUMENT_ROOT=$_SERVER['DOCUMENT_ROOT'];
$HTTP_HOST=$_SERVER['HTTP_HOST'];
chdir($DOCUMENT_ROOT.$PATH);

// Cron Start
$filename=$DOCUMENT_ROOT.$PATH.'tools/cron.txt';
$f=fopen($filename, 'w');
if ($f) {
	fwrite($f, "MAILTO=\"bh@inbox.ru\"\n");
	fwrite($f, '0 0 * * * '.$DOCUMENT_ROOT.$PATH.'tools/stat_daily_delete.php'."\n");
	fwrite($f, '* * * * * '.$DOCUMENT_ROOT.$PATH.'tools/auto_create.php'."\n");
	fwrite($f, '* * * * * '.$DOCUMENT_ROOT.$PATH.'tools/msg_autoresponder.php'."\n");
	fwrite($f, '* * * * * '.$DOCUMENT_ROOT.$PATH.'tools/msg_campaign_schedule.php'."\n");
	fwrite($f, '*/10 * * * * '.$DOCUMENT_ROOT.$PATH.'tools/msg_check.php'."\n");
	fclose($f);
	exec('crontab '.$filename);
	@unlink($filename);
} else {
	print "error";
}
// Cron End
print "DONE";			
exit;
?>