function guest($roomId, $userName) { $result = $this->db->selectRow('rooms', 'guest', array('id' => $roomId)); $time = mktime(); $message = new MessageSpeak($roomId, $time); if ($result['guest'] != '0') { $this->kickGuests($roomId, $time); $status = '0'; } else { $status = substr(md5(uniqid(rand(), TRUE)), 0, 6); } // update the guests status $this->db->update('rooms', array('guest' => $status), array('id' => $roomId)); // our guest on message $message->guest($roomId, $userName, $status, $time); return $status; }