<?php

ob_start();

if(!(is_readable(realpath(dirname(__FILE__).'/../').'/include/includesroutinesservice.inc'))) {
	die('Error - Could not open or read file '.realpath(dirname(__FILE__).'/../').'/include/includesroutinesservice.inc');
} else {
	include_once(realpath(dirname(__FILE__).'/../').'/include/includesroutinesservice.inc');
}

if(!(is_readable(realpath(dirname(__FILE__).'/../').'/include/mail.inc'))) {
	die('Error - Could not open or read file '.realpath(dirname(__FILE__).'/../').'/include/mail.inc');
} else {
	include_once(realpath(dirname(__FILE__).'/../').'/include/mail.inc');
}

/*
проверка на валидный ip передающий данные
*/
checkValidAgentIP();
/*
проверка на валидный ip передающий данные
*/
startPortal();

if (getSetting('portal','useRights',0) == 1 ) {
	$cn = db_connect();
	$emarr = db_getAdmin($cn);
	$size = sizeof($emarr);
	echo ' send mails to '.$size.' admins ';
		if ($size > 0) {
			$portal_url = GetSetting('portal','url',getCurPageURLWO());
			for($i=0; $i<$size; $i++){
				$userlang = $emarr[$i]['lang_short'];
				$lngid = $emarr[$i]['user_idlanguagecontent'];
				$url = $portal_url."/personal.php?lang=".$userlang;
				sendPortalStartMessage($emarr[$i]['user_email'],
					getResourceByLang('email.posrtalstarted.subject', $userlang),
					$url,
					$userlang) ;
			}
		}
		db_disconnect($cn);
		echo ' done ';
}

echo "finished ".date("H:i:s");
ob_end_flush();
?>