Пример #1
0
 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) {
                 $data = new StdClass();
                 $data->user = $user;
                 $data->id_room = $id_room;
                 $data->ip = $_SERVER['REMOTE_ADDR'];
                 $data->timestamp = date('Y-m-d H:i:s', time());
                 $fields = array_keys((array) $data);
                 $users_model = new UsersModel();
                 $users_model->setFields($fields);
                 $users_model->setData($data);
                 if ($users_model->insert()) {
Пример #2
0
     break;
 case 'block_user':
     $id = (int) $_GET['block_user'];
     if ($id) {
         $users = new UsersModel();
         $users->setData(array('active' => 0));
         $users->setFields(array('active'));
         $users->update($id);
         $message = 'User blocked';
     }
     break;
 case 'block_ip':
     $ip = $_GET['block_ip'];
     if ($ip) {
         $ip_block = new IpBlockModel();
         $ip_block->setCond('ip = "' . $ip . '"');
         $data = $ip_block->load_all();
         if (empty($data)) {
             $data = new StdClass();
             $data->ip = $ip;
             $data->permanent = 0;
             $data->timestamp = date('Y-m-d H:i:s');
             $data->end = date('Y-m-d H:i:s', strtotime('+1 day'));
             $fields = array_keys((array) $data);
             $ip_block = new IpBlockModel();
             $ip_block->setData($data);
             $ip_block->setFields($fields);
             $ip_block->insert();
             $message = 'Ip blocked';
         } else {
             $message = 'The ip has been blocked';