global $USER;
$user_id=$USER->GetID();
$obGroups = CUser::GetUserGroupList($user_id);
$arAimGroups = [6,7,8,9,10];
$maxGroupId = 0;
while ($arGroup = $obGroups->Fetch()) {
if (in_array($arGroup['GROUP_ID'], $arAimGroups) && (empty($arGroup['DATE_ACTIVE_TO']) || strtotime($arGroup['DATE_ACTIVE_TO']) >= time())) {
if ($maxGroupId < $arGroup['GROUP_ID']) {
$maxGroupId = $arGroup['GROUP_ID'];
}
}
}
$obMaxGroup = CGroup::GetByID($maxGroupId);
if ($arMaxGroup = $obMaxGroup->Fetch()) {
$name_pex_without = str_replace(['[',']'],['',''],$arMaxGroup['NAME']);
$class1 = str_replace(['6','7','8','9','10'],['player1','vip1','premium','deluxe1','ultra1'],$maxGroupId);
$class2 = str_replace(['6','7','8','9','10'],['player2','vip2','premium','deluxe2','ultra2'],$maxGroupId);
$name_pex = str_replace(['[',']',$name_pex_without],['<pex class="'.$class1.'">[</pex>','<pex class="'.$class1.'">]</pex>','<pex class="'.$class2.'">'.$name_pex_without.'</pex>'],$arMaxGroup['NAME']);
echo $name_pex;
}
$pex = str_replace(['pex user [user] group add ',' * 2592000'],['',''],$cur_data["command"]);
$arGroups_db = CUser::GetUserGroupList($uid);
if($pex=="vip") {
$aimGroupId = 7; //id группы, куда добавляем
}
if($pex=="premium") {
$aimGroupId = 8; //id группы, куда добавляем
}
if($pex=="deluxe") {
$aimGroupId = 9; //id группы, куда добавляем
}
if($pex=="ultra") {
$aimGroupId = 10; //id группы, куда добавляем
}
$aimGroupUpdated = false;
while ($arGroup = $arGroups_db->Fetch()){
if ($arGroup['GROUP_ID'] == $aimGroupId) {
$arGroup['DATE_ACTIVE_FROM'] = $cur_date;
$arGroup['DATE_ACTIVE_TO'] = $to_date;
$aimGroupUpdated = true;
}
$arGroups[] = $arGroup;
}
if (!$aimGroupUpdated) {
$arGroups[] = [
'GROUP_ID' => $aimGroupId,
'DATE_ACTIVE_FROM' => $cur_date,
'DATE_ACTIVE_TO' => $to_date
];
}
$add = CUser::SetUserGroup($uid);