Your IP : 13.58.255.158


Current Path : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/components/bitrix/mobile.crm.location.list/
Upload File :
Current File : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/components/bitrix/mobile.crm.location.list/ajax.php

<?php
define('NO_KEEP_STATISTIC', true);
define('NO_AGENT_STATISTIC','Y');
define('NO_AGENT_CHECK', true);
define('NOT_CHECK_PERMISSIONS', true);
define('NO_LANG_FILES', true);
define('DisableEventsCheck', true);
define('BX_STATISTIC_BUFFER_USED', false);
define('BX_PUBLIC_TOOLS', true);
define('PUBLIC_AJAX_MODE', true);

if (isset($_REQUEST['site_id']) && is_string($_REQUEST['site_id']))
{
	$siteID = $_REQUEST['site_id'];
	//Prevent LFI in prolog_before.php
	if($siteID !== '' && preg_match('/^[a-z0-9_]{2}$/i', $siteID) === 1)
	{
		define('SITE_ID', $siteID);
	}
}

require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/bx_root.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php');

if (!defined('LANGUAGE_ID') )
{
	$dbSite = CSite::GetByID(SITE_ID);
	$arSite = $dbSite ? $dbSite->Fetch() : null;
	define('LANGUAGE_ID', $arSite ? $arSite['LANGUAGE_ID'] : 'en');
}

//session_write_close();

if (!CModule::IncludeModule('crm'))
{
	die();
}

if (CModule::IncludeModule('compression'))
{
	CCompress::Disable2048Spaces();
}

global $APPLICATION, $DB;
$curUser = CCrmSecurityHelper::GetCurrentUser();
if (!$curUser || !$curUser->IsAuthorized() || !check_bitrix_sessid() || $_SERVER['REQUEST_METHOD'] != 'POST')
{
	die();
}

CUtil::JSPostUnescape();

if(!function_exists('__CrmMobileLocationListEndResponse'))
{
	function __CrmMobileLocationListEndResponse($result)
	{
		$GLOBALS['APPLICATION']->RestartBuffer();
		Header('Content-Type: application/x-javascript; charset='.LANG_CHARSET);

		if(!empty($result))
		{
			echo CUtil::PhpToJSObject($result);
		}
		require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_after.php');
		die();
	}
}

$curUserPrems = CCrmPerms::GetCurrentUserPermissions();
$action = isset($_REQUEST['ACTION']) ? $_REQUEST['ACTION'] : '';
if($action === 'SAVE_RECENT_USED_LOCATION')
{
	//__IncludeLang(dirname(__FILE__).'/lang/'.LANGUAGE_ID.'/'.basename(__FILE__));

	if(!CCrmPerms::IsAccessEnabled())
	{
		__CrmMobileLocationListEndResponse(array('ERROR' => 'Access denied.'));
	}

	$ID = isset($_REQUEST['ID']) ? $_REQUEST['ID'] : '';
	if($ID === '')
	{
		__CrmMobileLocationListEndResponse(array('ERROR' => 'ID is not found.'));
	}

	if(CCrmMobileHelper::SaveRecentlyUsedLocation($ID))
	{
		__CrmMobileLocationListEndResponse(array('SAVED_ENTITY_ID' => $ID));
	}
	else
	{
		__CrmMobileLocationListEndResponse(array('ERROR' => 'Could not save location.'));
	}
}
else
{
	__CrmMobileLocationListEndResponse(array('ERROR' => 'Action is not supported in current context.'));
}