/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('watch_chatroom', array('h', 'u'), array(true)), '', ''); } else { require_code('chat'); if (array_key_exists('u', $options) || array_key_exists('unwatch', $options)) { delete_value('occle_watched_chatroom'); $_chatroom = do_lang('SUCCESS'); } elseif (array_key_exists(0, $parameters)) { if (is_numeric($parameters[0])) { $chatroom = $parameters[0]; } else { $chatroom = get_chatroom_id($parameters[0]); } if (is_null($chatroom)) { return array('', '', '', do_lang('MISSING_RESOURCE')); } set_value('occle_watched_chatroom', $chatroom); $_chatroom = get_chatroom_name($chatroom); } else { $_chatroom = get_chatroom_name(intval(get_value('occle_watched_chatroom')), true); if (is_null($_chatroom)) { return array('', '', '', do_lang('MISSING_RESOURCE')); } } return array('', '', $_chatroom, ''); } }
/** * The UI for deleting all the messages in a room. * * @return tempcode The UI. */ function chat_delete_all_messages() { $title = get_page_title('DELETE_ALL_MESSAGES'); $id = get_param_integer('id'); check_chatroom_access($id); $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $room_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $row = $room_details[0]; $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms'); if (!$has_mod_access) { access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content'); } $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_tick(do_lang_tempcode('PROCEED'), do_lang_tempcode('Q_SURE'), 'continue_delete', false)); $text = paragraph(do_lang_tempcode('CONFIRM_DELETE_ALL_MESSAGES', escape_html(get_chatroom_name($id)))); $post_url = build_url(array('page' => '_SELF', 'type' => '_delete', 'id' => $id), '_SELF'); $submit_name = do_lang_tempcode('DELETE'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:room:id=' . strval($id), do_lang_tempcode('CHAT_MOD_PANEL')))); return do_template('FORM_SCREEN', array('_GUID' => '31b488e5d4ff52ffd5e097876c0b13c7', 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text)); }
/** * The UI for a chat room. * * @return tempcode The UI */ function chat_room() { require_javascript('javascript_yahoo_2'); require_javascript('javascript_colour_picker'); require_javascript('javascript_posting'); require_css('colour_picker'); $prefs = @$_COOKIE['ocp_chat_prefs']; $prefs = @explode(';', $prefs); //$mode=get_param('mode',''); $room_id = get_param_integer('id', 1); $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=chat&filter=' . strval($room_id); $room_check = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id', 'is_im', 'allow_list', 'allow_list_groups', 'disallow_list', 'disallow_list_groups', 'room_owner'), array('id' => $room_id), '', 1); if (!array_key_exists(0, $room_check)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } check_chatroom_access($room_check[0]); $posting_name = do_lang_tempcode('SEND_MESSAGE'); $keep = symbol_tempcode('KEEP'); $posting_url = find_script('messages') . '?mode=2&room_id=' . strval($room_id) . $keep->evaluate(); $messages_link = find_script('messages') . '?room_id=' . strval($room_id) . '&zone=' . get_zone_name() . $keep->evaluate(); $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode')); $chatcode_help = build_url(array('page' => 'userguide_chatcode'), get_comcode_zone('userguide_chatcode')); $buttons = new ocp_tempcode(); $_buttons = array('url', 'thumb', 'email', 'code', 'hide'); if (has_specific_permission(get_member(), 'comcode_dangerous')) { $_buttons[] = 'html'; } foreach ($_buttons as $button) { $buttons->attach(do_template('COMCODE_EDITOR_BUTTON', array('_GUID' => '4fd75edb2d091b1c78a71c653efb18f0', 'DIVIDER' => false, 'FIELD_NAME' => 'post', 'TITLE' => do_lang_tempcode('INPUT_COMCODE_' . $button), 'B' => $button))); } if (!is_guest()) { $_buttons = array('private_message', 'invite'); if (has_specific_permission(get_member(), 'create_private_room')) { $_buttons[] = 'new_room'; } foreach ($_buttons as $button) { $buttons->attach(do_template('CHATCODE_EDITOR_BUTTON', array('_GUID' => 'f1c3ccc2b6f0b68d71b7d256b3817cf3', 'TITLE' => do_lang_tempcode('INPUT_CHATCODE_' . $button), 'B' => $button))); } } $micro_buttons = new ocp_tempcode(); $_micro_buttons = array('b', 'i'); foreach ($_micro_buttons as $button) { $micro_buttons->attach(do_template('COMCODE_EDITOR_MICRO_BUTTON', array('_GUID' => '3ced1e569e0c6feaeadbc09f7f89e7ee', 'FIELD_NAME' => 'post', 'TITLE' => do_lang_tempcode('INPUT_COMCODE_' . $button), 'B' => $button))); } $user_colour = array_key_exists(0, $prefs) && $prefs[0] != '' ? $prefs[0] : get_option('chat_default_post_colour'); $line_contents = array_key_exists(1, $prefs) && $prefs[1] != '' ? $prefs[1] : get_option('chat_default_post_font'); $cs_post_url = build_url(array('page' => '_SELF', 'type' => 'options', 'id' => $room_id), '_SELF'); $yourname = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); if (is_guest()) { $yourname .= '-' . substr(md5(get_ip_address()), 0, 5); } $messages_php = find_script('messages'); $debug = get_param_integer('debug', 0) == 1 ? 'block' : 'none'; $title = get_page_title('ROOM'); if (has_actual_page_access(get_member(), 'cms_chat', NULL, array('chat', strval($room_id)), array('edit_lowrange_content', $room_check[0]['room_owner'] == get_member() ? 'moderate_my_private_rooms' : NULL))) { $link = build_url(array('page' => 'cms_chat', 'type' => 'room', 'id' => $room_id), get_module_zone('cms_chat')); $modlink = hyperlink($link, do_lang_tempcode('CHAT_MOD_PANEL'), true); } else { $modlink = new ocp_tempcode(); } if (has_actual_page_access(get_member(), 'admin_chat')) { // The user is staff, so let him have the admin link $link = build_url(array('page' => 'admin_chat', 'type' => '_ed', 'id' => $room_id), 'adminzone'); $adminlink = hyperlink($link, do_lang_tempcode('EDIT_CHATROOM'), true); } else { $adminlink = new ocp_tempcode(); } $link = build_url(array('page' => '_SELF', 'type' => 'room', 'id' => $room_id), '_SELF'); $refreshlink = hyperlink($link, do_lang_tempcode('CHAT_REFRESH')); $link = build_url(array('page' => '_SELF', 'type' => 'download_logs'), '_SELF'); $downloadlink = hyperlink(build_url(array('page' => '_SELF', 'type' => 'download_logs', 'id' => $room_id), '_SELF'), do_lang_tempcode('CHAT_DOWNLOAD_LOGS'), true); $seteffectslink = hyperlink(build_url(array('page' => '_SELF', 'type' => 'set_effects'), '_SELF'), do_lang_tempcode('CHAT_SET_EFFECTS'), true); $links = array($adminlink, $modlink, $refreshlink, $downloadlink, $seteffectslink); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY_END_CHAT')))); return do_template('CHAT_SCREEN', array('_GUID' => '867a0b050c050c81d33482d131783eb0', 'CHATTERS' => get_chatters_in_room_tpl(get_chatters_in_room($room_id)), 'CHAT_SOUND' => get_chat_sound_tpl(), 'ROOM_ID' => strval($room_id), 'DEBUG' => $debug, 'MESSAGES_PHP' => $messages_php, 'TEXT_COLOUR_DEFAULT' => $user_colour, 'FONT_NAME_DEFAULT' => $line_contents, 'OPTIONS_URL' => $cs_post_url, 'COMCODE_HELP' => $comcode_help, 'CHATCODE_HELP' => $chatcode_help, 'ROOM_NAME' => get_chatroom_name(get_param_integer('id', 1)), 'MICRO_BUTTONS' => $micro_buttons, 'BUTTONS' => $buttons, 'YOUR_NAME' => $yourname, 'MESSAGES_LINK' => $messages_link, 'POSTING_URL' => $posting_url, 'SUBMIT_VALUE' => $posting_name, 'INTRODUCTION' => '', 'TITLE' => $title, 'LINKS' => $links)); }
/** * 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); }