// no direct access
defined('_JEXEC') or die('Restricted access');
// Detecting user
$user_id = null;
if ($user_obj = &JFactory::getUser())
{
if ($user_obj->gid == 18)
{
include "components/com_cabinet/config.php";
if ($dbase = ibase_pconnect($ibase_host, $ibase_user, $ibase_password, 'UTF8'))
{
$dbquery = "
select ID
from ABONENTS
where upper(LOGIN) = upper('$user_obj->username')
and ENABLED = 1
and (MARKDELETE = 0 or MARKDELETE is null)
and (ARCHIVED = 0 or ARCHIVED is null)";
if ($dbdata = ibase_query($dbase, $dbquery))
{
$dbrow = ibase_fetch_object($dbdata);
if ($dbrow->ID > 0) {$user_id = $dbrow->ID;}
}
}
}
}
// User detected
if ($user_id)
{
$context = stream_context_create(
array(
'http' => array (
'header' => "User-Agent: xcom.kz\r\nConnection: Close\r\n\r\n",
'method' => 'POST',
'content' => "subscriberid=$user_id"
)
)
);
// Make domain of cabinet.xcom.kz
$cookie_host = explode('.', $_SERVER['HTTP_HOST']);
if (sizeof($cookie_host) > 2) {$cookie_host = array_slice($cookie_host, -2);}
$cookie_host = '.'.implode('.', $cookie_host);
// Remove prior cookie
$cookie_params = session_get_cookie_params();
setcookie('cabinet_remember_me', '', time() - 3600, $cookie_params['path'], $cookie_host);
// Register subscriber on cabinet.xcom.kz
if ($key = file_get_contents('http://cabinet.xcom.kz/domainauthentification.php', false, $context))
{setcookie('cabinet_remember_me', $key, time() + 60 * 60 * 24, $cookie_params['path'], $cookie_host, $cookie_params['secure'], $cookie_params['httponly']);}
}
//https://xcom.kz/index.php?option=com_gotocabinet
header('Location: http://cabinet.xcom.kz/'.($_REQUEST['section'] ? '#'.$_REQUEST['section'] : ''));
die();
?>