<?php

erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.blockedusers', array());
$tpl = erLhcoreClassTemplate::getInstance('lhchat/blockedusers.tpl.php');
if (is_numeric($Params['user_parameters_unordered']['remove_block'])) {
    try {
        if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
            die('Invalid CSRF Token');
            exit;
        }
        $block = erLhcoreClassModelChatBlockedUser::fetch($Params['user_parameters_unordered']['remove_block']);
        $block->removeThis();
    } catch (Exception $e) {
    }
}
if (isset($_POST['AddBlock'])) {
    $definition = array('IPToBlock' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'));
    if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
        erLhcoreClassModule::redirect('chat/blockedusers');
        exit;
    }
    $form = new ezcInputForm(INPUT_POST, $definition);
    $Errors = array();
    if ($form->hasValidData('IPToBlock') && $form->IPToBlock != '') {
        $ipBlock = new erLhcoreClassModelChatBlockedUser();
        $ipBlock->ip = $form->IPToBlock;
        $ipBlock->user_id = erLhcoreClassUser::instance()->getUserID();
        $ipBlock->datets = time();
        $ipBlock->saveThis();
        $tpl->set('block_saved', true);
    } else {