}
     if (!empty($session->_conf_all['flood_protection_max_messages']) && !empty($session->_conf_all['flood_protection_mute_time']) && $current_user->is_admin !== 'y' && $last_sent_message_repeats_count >= $session->_conf_all['flood_protection_max_messages']) {
         // Message was flooded. Mute author.
         $current_user->globalMuteUnmute($current_user->id, 1, $session->_conf_all['flood_protection_mute_time'] / 60, $l->g('flooding'));
         $msg->addMessage(10110, 'n', 0, $l->g('server'), $session->_s_room_id, 0, $current_user->id . '/0/' . $session->_conf_all['flood_protection_mute_time'] / 60 . '/' . $l->g('flooding'), date('Y-m-d H:i:s'), 0, '');
         $last_sent_message_repeats_count = 0;
         $last_sent_message_hash = '';
         break;
         // Ignore further messages
     } else {
         // Add message to database
         $last_sent_message_time = time();
         $msg->addMessage($type, $offline, $current_user->id, $current_nickname, $target_room_id, $target_user_id, $body, date('Y-m-d H:i:s'), $privacy, $css_properties);
         // Attachments?
         _pcpin_loadClass('attachment');
         $attachment = new PCPIN_Attachment($session);
         _pcpin_loadClass('message_log_attachment');
         $message_log_attachment = new PCPIN_Message_Log_Attachment($session);
         _pcpin_loadClass('binaryfile');
         $binaryfile = new PCPIN_BinaryFile($session);
         if (!empty($tmpdata_list)) {
             foreach ($tmpdata_list as $tmpdata_data) {
                 $attachment->addAttachment($msg->id, $tmpdata_data['binaryfile_id'], $tmpdata_data['filename']);
                 if (!empty($session->_conf_all['logging_period']) && $binaryfile->_db_getList('body,size,mime_type', 'id = ' . $tmpdata_data['binaryfile_id'], 1)) {
                     $message_log_attachment->addLogRecord($msg->id, $tmpdata_data['filename'], $binaryfile->_db_list[0]['body'], $binaryfile->_db_list[0]['size'], $binaryfile->_db_list[0]['mime_type']);
                     $binaryfile->_db_freeList();
                 }
             }
         }
     }
 }
 /**
  * Get last messages for user
  * @param   int   $user_id      User ID
  * @param   int   $count        Messages count to return
  * @return  array
  */
 function getLastMessages($user_id, $count = 0)
 {
     $messages = array();
     if (!empty($user_id) && !empty($count)) {
         $query = $this->_db_makeQuery(1300, $user_id, $count * 1, 3001);
         if ($result = $this->_db_query($query)) {
             _pcpin_loadClass('attachment');
             $attachment = new PCPIN_Attachment($this);
             while ($data = $this->_db_fetch($result, MYSQL_ASSOC)) {
                 if ($data['has_attachments'] == '1') {
                     // Get attachments
                     $data['attachment'] = $attachment->getAttachments($data['id']);
                 }
                 $messages[] = $data;
             }
             $this->_db_freeResult($result);
         }
     }
     return $messages;
 }