/** * The UI to download chat logs. * * @return tempcode The UI */ function chat_download_logs() { $title = get_page_title('CHAT_DOWNLOAD_LOGS'); $chatrooms = chat_get_all_rooms(); $select = new ocp_tempcode(); $select_by_default = get_param_integer('id', NULL); foreach ($chatrooms as $value) { $select->attach(form_input_list_entry(strval($value['id']), $value['id'] == $select_by_default, $value['room_name'], false)); } $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_list(do_lang_tempcode('ROOM_NAME'), do_lang_tempcode('CHAT_DOWNLOAD_LOGS_ROOM_NAME'), 'room_name', $select)); $fields->attach(form_input_date(do_lang_tempcode('CHAT_DOWNLOAD_LOGS_START_DATE'), do_lang_tempcode('CHAT_DOWNLOAD_LOGS_START_DATE_DESCRIPTION'), 'start', false, false, true, time() - 4 * 60 * 60, 26)); $fields->attach(form_input_date(do_lang_tempcode('CHAT_DOWNLOAD_LOGS_FINISH_DATE'), do_lang_tempcode('CHAT_DOWNLOAD_LOGS_FINISH_DATE_DESCRIPTION'), 'finish', false, false, true, time(), 26)); $posting_name = do_lang_tempcode('CHAT_DOWNLOAD_LOGS'); $posting_url = build_url(array('page' => '_SELF', 'type' => '_download_logs'), '_SELF', NULL, false, true); if (count($chatrooms) == 0) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY')))); return do_template('FORM_SCREEN', array('_GUID' => '6741ef01d1c6dd8d2de9be3290666db7', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'SUBMIT_NAME' => $posting_name, 'URL' => $posting_url, 'TEXT' => '')); }
/** * Parse room creation chat code tag. * * @param string The room name * @param string Comma-separated list of members to allow in * @param SHORT_TEXT The username of who made this chatcode * @param string The text we are using * @param ?integer The maximum number of messages to be returned (NULL: no maximum) * @return array A pair: whether the message was deleted, and the new text of the message */ function _deal_with_chatcode_newroom($pm_user, $pm_message, $username, $text, $cutoff) { $pm_message_deleted = false; if (!has_specific_permission(get_member(), 'create_private_room')) { return array('pm_message_deleted' => $pm_message_deleted, 'text' => $text); } // This deals with the [newroom="roomname"]allowlist[/newroom] tag // We need to send invitations to all the people on the allow list // Create the room if it hasn't already been created $_row = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('room_name' => $pm_user), '', $cutoff); if (!array_key_exists(0, $_row)) { $new_room_id = $GLOBALS['SITE_DB']->query_insert('chat_rooms', array('is_im' => 0, 'room_name' => $pm_user, 'room_owner' => $GLOBALS['FORUM_DRIVER']->get_member_from_username($username), 'allow_list' => parse_allow_list_input($pm_message), 'disallow_list' => '', 'allow_list_groups' => '', 'disallow_list_groups' => '', 'c_welcome' => insert_lang('', 3), 'room_language' => user_lang()), true); $rooms = chat_get_all_rooms(); // For each person in the allow list, insert a private message into every room (except the new one) asking them to join the new room $_pm_message = explode(',', $pm_message); foreach ($_pm_message as $person) { if ($person != $GLOBALS['FORUM_DRIVER']->get_username(get_member()) && $person != do_lang('GUEST')) { foreach ($rooms as $room) { if ($room['id'] != $new_room_id) { $_message_parsed = insert_lang_comcode('[invite="' . $person . '"]' . get_chatroom_name($new_room_id) . '[/invite]', 4); $message_id = $GLOBALS['SITE_DB']->query_insert('chat_messages', array('ip_address' => get_ip_address(), 'room_id' => $room['id'], 'user_id' => get_member(), 'date_and_time' => time(), 'the_message' => $_message_parsed, 'text_colour' => get_option('chat_default_post_colour'), 'font_name' => get_option('chat_default_post_font')), true); $myfile = @fopen(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat', 'wb') or intelligent_write_error(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat'); fwrite($myfile, strval($message_id)); fclose($myfile); sync_file(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat'); } } } } } $text = preg_replace('#\\[newroom="([^&]*)"\\]([^\\[]*)\\[/newroom\\]#', '', $text, 1); if (is_null($text) || $text == '') { $pm_message_deleted = true; } return array('pm_message_deleted' => $pm_message_deleted, 'text' => $text); }