// no direct access
defined('_JEXEC') or die('Restricted access');
ini_set('display_errors', '0');
include "config.php";
global $user, $user_name, $user_id, $dbase, $header_mask, $referafriend_present;
$user = &JFactory::getUser();
$user_date_create_dogovor = 0;
$user_street = "";
$user_house = "";
$user_box = "";
$refer_a_friend_count = 99;
/*
18 — 'Registered'
19 — 'Author'
20 — 'Editor'
21 — 'Publisher'
23 — 'Manager'
24 — 'Administrator'
25 — 'Super Administrator'
*/
$errmsg = '';
if (!($dbase = ibase_pconnect($ibase_host, $ibase_user, $ibase_password, 'UTF8')))
{$errmsg = ibase_errmsg();}
else
{
$header_mask = "
%s
\n";
switch ($user->gid)
{
// Unregistred
default:
$errmsg = "Для получения доступа к
Личному кабинету необходимо произвести вход!";
break;
// Registered
case 18:
$date = time();
$date = mktime(date("H", $date), date("i", $date) + 5, date("s", $date), date("n", $date), date("j", $date), date("Y", $date));
if ((date("d", $date) == "01") && ((date("H", $date) == "00") || (date("H", $date) == "01")))
{$errmsg = "Доступ в личный кабинет
закрыт до 02:00!";}
else
{
$dbquery = "select ID, LOGIN, CREATEDATE, STREET, HOUSE, BOX, REFERAFRIENDCOUNT ".
"from ABONENTS ".
"where upper(LOGIN)=upper('".$user->username."') ".
"and MARKDELETE is null ".
"and ENABLED = 1 ".
"and ((ARCHIVED = 0) or (ARCHIVED is null))";
if (!($dbdata = ibase_query($dbase, $dbquery)))
{$errmsg = ibase_errmsg();}
else
{
$dbrow = ibase_fetch_object($dbdata);
if ($dbrow->ID > 0)
{
$user_id = $dbrow->ID;
$user_date_create_dogovor = $dbrow->CREATEDATE;
$user_street = $dbrow->STREET;
$user_house = $dbrow->HOUSE;
$user_box = $dbrow->BOX;
$refer_a_friend_count = $dbrow->REFERAFRIENDCOUNT;
}
else
{$errmsg = "Для получения доступа к
Личному кабинету обратитесь в
службу поддержки";}
ibase_free_result($dbdata);
}
}
break;
// Manager, Administrator, Super Administrator
case 23:
case 24:
case 25:
$user_id = JArrayHelper::getValue($_REQUEST, 'userid', "");
if ($user_id > 0)
{
$filehandle = fopen("cache/".$user->username."-userid", "w");
fwrite($filehandle, $user_id."\n");
fclose($filehandle);
}
else
{
$filename = "cache/".$user->username."-userid";
if (file_exists($filename))
{
$filehandle = fopen($filename, "r");
$user_id = rtrim(fgets($filehandle));
fclose($filehandle);
}
}
if ($user_id > 0)
{
$dbquery = "select ID, DOGOVOR, ABONENTTYPE, LOGIN, ORGANIZATION, DEPARTMENT, FAMILY, ABONENTNAME, LASTNAME ".
"from ABONENTS ".
"where ID=".$user_id;
if (!($dbdata = ibase_query($dbase, $dbquery)))
{$errmsg = ibase_errmsg();}
else
{
$dbrow = ibase_fetch_object($dbdata);
if ($dbrow->ABONENTTYPE == 0)
{$user_name = $dbrow->FAMILY." ".$dbrow->ABONENTNAME." ".$dbrow->LASTNAME;}
else
{$user_name = $dbrow->ORGANIZATION." ".$dbrow->DEPARTMENT;}
printf($header_mask, "Текущий пользователь");
echo "
".$dbrow->DOGOVOR." - ".$user_name." (".$dbrow->LOGIN.") [".$user_id."]";
}
}
else
{
$filename = "cache/".$user->username."-userid";
if (file_exists($filename)) {unlink($filename);}
}
break;
}
ibase_close($dbase);
}
#if ($user->gid < 2)
#{$errmsg = "
Доступ в личный кабинет времмено не доступен!
Ведутся технические работы.";}
if ($errmsg != "")
{echo "
\n";}
else
{
$action = JArrayHelper::getValue($_REQUEST, 'action', '');
switch ($user->gid)
{
// Registered
case 18:
if (($action != "referafriendconfirm") && ($action != "referafriendrules") && ($refer_a_friend_count < 3))
{
// Это та самая выборка, которая дает нам знать, надо показывать окно активации "Приведи друга" или нет
$now = time();
$expire_date_status_0 = mktime(0, 0, 0, date("m", $now), date("j", $now) - $referafriend_activation_days, date("Y", $now));
$dbquery =
"select COUNT(*) from REFERAFRIEND ".
"where ((MARKDELETE = 0) or (MARKDELETE is null)) ".
"and (((STATUS is null) or (STATUS = 0)) and (CREATEDATE > '".date('d.m.Y', $expire_date_status_0)."') and (CREATEDATE < '$user_date_create_dogovor')) ".
"and (STREET = '$user_street') and (HOUSE = '$user_house') and (BOX = '$user_box')";
if (!($dbdata = ibase_query($dbase, $dbquery)))
{$errmsg = ibase_errmsg();}
else
{
$dbrow = ibase_fetch_object($dbdata);
if ($dbrow->COUNT > 0) {include "referafriend-activate.php";}
}
}
break;
// Manager, Administrator, Super Administrator
case 23:
case 24:
case 25:
echo
"
";
break;
}
if (($user_id) || ((! $user_id) && ($action == 'users')))
{
switch ($action)
{
case 'users':
if ($user->gid >= 23)
{
include "users.php";
echo "";
}
break;
case 'info':
include "info.php";
if ($user->gid >= 23)
{echo "";}
break;
case 'logs':
include "logs.php";
break;
case 'schet':
include "schet.php";
break;
case 'stats':
include "stats.php";
break;
case 'internet':
include "internet.php";
break;
case 'tarifchange':
include "tarifchange.php";
break;
case 'nightdrive':
include "nightdrive.php";
break;
case 'realip':
include "realip.php";
break;
case 'pbxphone':
include "pbxphone.php";
break;
case 'resources':
include "resources.php";
break;
case 'activatecard':
include "activatecard.php";
break;
case 'referafriend':
include "referafriend.php";
break;
case 'referafriendrules':
include "referafriend-rules.php";
break;
case 'referafriendconfirm':
if ($user->gid == 18) {include "referafriend-confirm.php";}
break;
case 'gotocabinet':
include "gotocabinet.php";
break;
default:
if ($user->gid >= 23)
{include "users.php";}
else
{include "info.php";}
break;
}
}
if ($dbase) {ibase_close($dbase);}
}
//if ( $_SERVER['REMOTE_ADDR'] == '10.230.51.11' )
?>