// Dados enviados if (count($_POST)) { $user = substr($_POST['user'], 0, 20); $user = Filters::convert($user); $captcha = $_POST['captcha']; $id_room = (int) $_POST['id_room']; if ($_SESSION['captcha_code'] == $captcha) { // Rooms $rooms_model = new RoomsModel(); $room = $rooms_model->load($id_room); if (count($room)) { // Users online $users_model = new UsersModel(); $users_model->setFieldsSelect(array('user')); $users_model->setCond('id_room = ' . $id_room); $users_model->setOrderBy('chat_users.id'); $users = $users_model->load_all(); $total = $users_model->count(); if ($room['capacity'] > $total) { // Verifica se tem user com o mesmo nome $users_model = new UsersModel(); $users_model->setCond('user = "******"'); $users = $users_model->load_all(); // IP's bloqueados $ip_model = new IpBlockModel(); $ip_model->setCond('ip = "' . $_SERVER['REMOTE_ADDR'] . '"'); $ip = $ip_model->load_all(); if (count($ip)) { $message = 'You are blocked from accessing chat.'; } else { if (count($users) == 0) {
<?php require_once 'app/autoload.php'; if (isset($_SESSION['chat_login']['id_user'])) { // Return $return = ''; // Update dos users $users = new UsersModel(); $users->setFields(array('timestamp')); $users->setData(array('timestamp' => date('Y-m-d H:i:s'))); $users->update($_SESSION['chat_login']['id_user']); // Lendo as messages $users = new UsersModel(); $users->setCond('id_room = ' . $_SESSION['chat_login']['id_room']); $users->setCond('id != ' . $_SESSION['chat_login']['id_user']); $users->setCond('active = 1'); $users->setOrderBy('user asc'); $load = $users->load_all(); $json = array(); foreach ($load as $line) { // Retorno $user = Filters::convert(htmlentities($line['user'])); $return .= '<a href="#" id="user_' . $line['id'] . '" rel="' . $line['id'] . '">' . $user . '</a>'; $json[] = '["' . $line['id'] . '", "' . $user . '"]'; } echo '[' . implode(',', $json) . ']'; } else { echo 'error'; }
</h4> <a href="#" id="user_0" rel="0" class="active_user_talk"><?php echo Locale::setContent('All users'); ?> </a> <?php echo '<span class="user_me"><a href="#" id="user_' . $_SESSION['chat_login']['id_user'] . '" rel="' . $_SESSION['chat_login']['id_user'] . '">' . Filters::convert($_SESSION['chat_login']['user']) . '</a></span>'; ?> <div id="box_users"> <?php $filters = array('all' => 'convert'); $users_model = new UsersModel(); $users_model->setCond('id_room = ' . $id_room); $users_model->setCond('active = 1'); $users_model->setCond('id <> ' . $id_user); $users_model->setOrderBy('user asc'); $users = $users_model->addFilter($users_model->load_all(), $filters); foreach ($users as $load) { echo '<a href="#" id="user_' . $load['id'] . '" rel="' . $load['id'] . '">' . $load['user'] . '</a>'; } ?> </div> </div> <div id="content"></div> <div id="tools"> <div id="box_talk"></div> <div id="box_tools"> <form action="#" id="form_send" method="post"> <div id="box_user_tools">