signOn())||!$backend->login($user,$backend)){http_response_code(503);exit('Support sign-in unavailable. Contact the operator.');} if(!empty($_SESSION['dune_staff_requested'])&&in_array('web.tickets.staff',$identity['permissions'],true)){ unset($_SESSION['dune_staff_requested']);$name=str_replace('-','',$identity['id']); $role=Role::lookup(['name'=>'DuneRealms support']); if(!$role){http_response_code(503);exit('Support staff role is unavailable.');} $staff=Staff::lookup(['username'=>$name]); if(!$staff){$staff=Staff::create(['username'=>$name,'firstname'=>substr($identity['username'],0,32),'lastname'=>'','email'=>$identity['id'].'@accounts.dunerealms.invalid','dept_id'=>1,'role_id'=>$role->getId(),'backend'=>'dunerealms-staff','passwd'=>null,'signature'=>'','phone'=>'','mobile'=>'','isactive'=>1,'isadmin'=>0,'created'=>SqlFunction::NOW(),'updated'=>SqlFunction::NOW()]);if(!$staff->save()){http_response_code(503);exit('Could not provision support staff.');}} $staff->isadmin=in_array('web.tickets.admin',$identity['permissions'],true)?1:0;$staff->save(); require_once __DIR__.'/department-access.php'; require_once __DIR__.'/staff-scope.php'; dune_sync_ticket_departments($staff,$identity,$role); $_SESSION['dune_staff_scope']=dune_ticket_staff_scope($identity); $staffBackend=StaffAuthenticationBackend::getBackend('dunerealms-staff'); $session=StaffSession::lookup($name); if(!$staffBackend||!$session||!$staffBackend->login($session,$staffBackend)){http_response_code(503);exit('Support staff sign-in unavailable.');} header('Location: /scp/');exit; } if(isset($_SESSION['dune_appeal_requested'])){$id=$_SESSION['dune_appeal_requested'];unset($_SESSION['dune_appeal_requested']);header('Location: /appeal.php?banId='.rawurlencode($id));exit;} if(!empty($_SESSION['dune_dev_requested'])){unset($_SESSION['dune_dev_requested']);header('Location: /dev-tasks.php');exit;} header('Location: /tickets.php');exit;