<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();

require_once(__DIR__ . '/include/constants.php');
require_once(__DIR__ . '/include/helper.php');

if (file_exists(__DIR__ . '/include/redirects.php')) {
    require_once(__DIR__ . '/include/redirects.php');
}


AddEventHandler('main', 'OnEpilog', array('CMainHandlers', 'OnEpilogHandler'));

class CMainHandlers {

    public static function OnEpilogHandler()
    {
        global $APPLICATION;
        $CURRENT_PAGE = "https://";
        $CURRENT_PAGE .= $_SERVER["HTTP_HOST"];
        $CURRENT_PAGE .= parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
        $APPLICATION->SetPageProperty('canonical', $CURRENT_PAGE);
    }
}

if (!function_exists('custom_mail') && COption::GetOptionString("webprostor.smtp", "USE_MODULE") == "Y")
{
	function custom_mail($to, $subject, $message, $additional_headers='', $additional_parameters='')
	{
		if(CModule::IncludeModule("webprostor.smtp"))
		{
			$smtp = new CWebprostorSmtp(false, $additional_parameters);
			$result = $smtp->SendMail($to, $subject, $message, $additional_headers, $additional_parameters);

			if($result)
				return true;
			else
				return false;
		}
	}
}