<?php

require_once str_replace( 'applications/core/interface/vkontakte/auth.php', '', str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ) ) . 'init.php';
$state = explode( '-', \IPS\Request::i()->state );

if ( $state[0] == 'ucp' )
{
	\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=system&controller=settings&area=profilesync&service=VK&loginProcess=vkontakte&state={$state[1]}&code=" . urlencode( \IPS\Request::i()->code ), 'front', 'settings_Vkontakte' ) );
}
else
{

\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=system&controller=login&loginProcess=vkontakte&code=" . urlencode( \IPS\Request::i()->code ), $state[0] ) );

}