/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { if (!array_key_exists('param', $map)) { $map['param'] = 'main'; } if (!array_key_exists('page', $map)) { $map['page'] = str_replace('-', '_', get_page_name()); } if (array_key_exists('extra_param_from', $map)) { $extra = '_' . $map['extra_param_from']; } else { $extra = ''; } require_code('feedback'); $submitted = post_param_integer('_comment_form_post', 0) == 1; $self_url = build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, true); $self_title = $map['page']; $test_changed = post_param('title', NULL); if (!is_null($test_changed)) { decache('main_comments'); } $hidden = $submitted ? actualise_post_comment(true, 'block_main_comments', $map['page'] . '_' . $map['param'] . $extra, $self_url, $self_title, array_key_exists('forum', $map) ? $map['forum'] : NULL, false, NULL, get_page_name() == 'guestbook') : false; $out = new ocp_tempcode(); if (array_key_exists('title', $_POST) && $hidden && $submitted) { $out->attach(paragraph(do_lang_tempcode('MESSAGE_POSTED'), 'dsgdgdfl;gkd09')); if (get_forum_type() == 'ocf') { if (addon_installed('unvalidated')) { require_code('submit'); $validate_url = get_self_url(true, false, array('keep_session' => NULL)); $_validate_url = build_url(array('page' => 'topics', 'type' => 'validate_post', 'id' => $GLOBALS['LAST_POST_ID'], 'redirect' => $validate_url), get_module_zone('topics'), NULL, false, false, true); $validate_url = $_validate_url->evaluate(); send_validation_request('MAKE_POST', 'f_posts', false, $GLOBALS['LAST_POST_ID'], $validate_url); } } } $invisible_if_no_comments = array_key_exists('invisible_if_no_comments', $map) && $map['invisible_if_no_comments'] == '1'; $reverse = array_key_exists('reverse', $map) && $map['reverse'] == '1'; $allow_reviews = !array_key_exists('reviews', $map) || $map['reviews'] == '1'; $out->attach(get_comments('block_main_comments', true, $map['page'] . '_' . $map['param'] . $extra, $invisible_if_no_comments, array_key_exists('forum', $map) ? $map['forum'] : NULL, NULL, NULL, get_page_name() == 'guestbook', $reverse, NULL, $allow_reviews)); return $out; }
/** * A bug report for a test. * * @return tempcode The result of execution. */ function report() { $id = get_param_integer('id'); $test_row = $GLOBALS['SITE_DB']->query_select('tests t LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'test_sections s ON t.t_section=s.id', array('*'), array('t.id' => $id), '', 1); if (!array_key_exists(0, $test_row)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $section = $test_row[0]['s_section']; $test = $test_row[0]['t_test']; $self_title = $section . '/' . substr($test, 0, 20); $title = get_page_title('BUG_REPORT_FOR', true, array(escape_html($self_title))); require_code('feedback'); $self_url = get_self_url(); $forum = get_option('tester_forum_name'); actualise_post_comment(true, 'bug_report', strval($id), $self_url, $self_title, $forum); $comment_text = str_replace('{1}', $test, get_option('bug_report_text')); $comments = get_comments('bug_report', true, strval($id), false, $forum, $comment_text); return do_template('TESTER_REPORT', array('_GUID' => '0c223a0a29a2c5289d71fbb69b0fe40d', 'TITLE' => $title, 'TEST' => $test, 'COMMENTS' => $comments)); }
/** * Do an AJAX comment post */ function post_comment_script() { header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past // Read in context of what we're doing $options = post_param('options'); secure_serialized_data($options); list($page_name, $content_id, $allow_comments, $submitter, $content_url, $content_title, $forum) = unserialize($options); // Check security $hash = post_param('hash'); if (best_hash($options, get_site_salt()) != $hash) { header('Content-Type: text/plain; charset=' . get_charset()); exit; } // Post comment actualise_post_comment($allow_comments >= 1, $page_name, $content_id, $content_url, $content_title, $forum); // Get new comments state $comment_details = get_comments($page_name, $allow_comments == 1, $content_id, false, $forum, NULL, NULL, false, false, $submitter, $allow_comments == 2); // And output as text header('Content-Type: text/plain; charset=' . get_charset()); $comment_details->evaluate_echo(); }
/** * Send out a notification to members enabled. */ function dispatch() { if (running_script('stress_test_loader')) { return; } if (get_page_name() == 'admin_import') { return; } $subject = $this->subject; $message = $this->message; $no_cc = $this->no_cc; if ($GLOBALS['DEBUG_MODE']) { if (strpos($this->message, 'keep_devtest') !== false && $this->notification_code != 'hack_attack' && $this->notification_code != 'auto_ban' && strpos($this->message, running_script('index') ? static_evaluate_tempcode(build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, true)) : get_self_url_easy()) === false && (strpos(ocp_srv('HTTP_REFERER'), 'keep_devtest') === false || strpos($this->message, ocp_srv('HTTP_REFERER')) === false)) { // Bad URL - it has to be general, not session-specific fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } } $ob = _get_notification_ob_for_code($this->notification_code); if (is_null($ob)) { if (get_page_name() != 'admin_setupwizard') { // Setupwizard may have removed after register_shutdown_function was called fatal_exit('Missing notification code: ' . $this->notification_code); } return; } require_lang('notifications'); require_code('mail'); if (function_exists('set_time_limit')) { @set_time_limit(0); } if ($this->store_in_staff_messaging_system && addon_installed('staff_messaging')) { require_lang('messaging'); list($type, $id) = explode('_', $this->code_category, 2); $message_url = build_url(array('page' => 'admin_messaging', 'type' => 'view', 'id' => $id, 'message_type' => $type), get_module_zone('admin_messaging'), NULL, false, false, true); $message = do_lang('MESSAGING_NOTIFICATION_WRAPPER', $message, $message_url->evaluate()); require_code('feedback'); actualise_post_comment(true, $type, $id, $message_url, $subject, get_option('messaging_forum_name'), true, 1, true, true, true); } $testing = get_param_integer('keep_debug_notifications', 0) == 1; $start = 0; $max = 300; do { list($members, $possibly_has_more) = $ob->list_members_who_have_enabled($this->notification_code, $this->code_category, $this->to_member_ids, $start, $max); if (get_value('notification_safety_testing') === '1') { if (count($members) > 20) { $members = array(6 => A_INSTANT_EMAIL); // This is just for testing on ocportal.com, if lots of notifications going out it's probably a scary bug, so send just to Chris (#6) with a note $message = 'OVER-ADDRESSED?' . "\n\n" . $message; } } foreach ($members as $to_member_id => $setting) { if (!is_null($this->no_notify_for__notification_code)) { if (notifications_enabled($this->no_notify_for__notification_code, $this->no_notify_for__code_category, $to_member_id)) { continue; } // Signal they are getting some other notification for this } if ($to_member_id !== $this->from_member_id || $testing) { $no_cc = _dispatch_notification_to_member($to_member_id, $setting, $this->notification_code, $this->code_category, $subject, $message, $this->from_member_id, $this->priority, $no_cc); } } $start += $max; } while ($possibly_has_more); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('feedback'); require_javascript('javascript_validation'); $is_occle_talking = ocp_srv('HTTP_USER_AGENT') == 'ocPortal' && ocp_srv('HTTP_HOST') == 'ocportal.com'; $self_url = get_self_url(); $self_title = get_page_name(); $type = 'block_main_feedback'; $id = array_key_exists('param', $map) ? $map['param'] : ''; $out = new ocp_tempcode(); if (post_param_integer('_comment_form_post', 0) == 1) { if (!has_no_forum()) { $hidden = actualise_post_comment(true, $type, $id, $self_url, $self_title, array_key_exists('forum', $map) ? $map['forum'] : NULL, $is_occle_talking || get_option('captcha_on_feedback') == '0', 1, false, true, true); if (array_key_exists('title', $_POST)) { $redirect = get_param('redirect', NULL); if (!is_null($redirect)) { $redirect_screen = redirect_screen(get_page_title('_FEEDBACK'), $redirect, do_lang_tempcode('FEEDBACK_THANKYOU')); @ob_end_clean(); $echo = globalise($redirect_screen, NULL, '', true); $echo->evaluate_echo(); exit; } else { attach_message(do_lang_tempcode('SUCCESS'), 'inform'); } } } else { $post = post_param('post', ''); $title = post_param('title', ''); if ($post != '') { require_code('notifications'); dispatch_notification('new_feedback', $type, do_lang('NEW_FEEDBACK_SUBJECT', $title, NULL, NULL, get_site_default_lang()), do_lang('NEW_FEEDBACK_MESSAGE', $post, NULL, NULL, get_site_default_lang())); $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member()))); if ($email_from != '') { require_code('mail'); mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', $title), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member()); } } } } // Comment posts $forum = get_option('comments_forum_name'); $count = 0; $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $type . '_' . $id), $count); if ($_comments !== -1) { $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)); require_javascript('javascript_validation'); $comment_url = get_self_url(); if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = !$is_occle_talking && get_option('captcha_on_feedback') == '1' && use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $comment_details = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4ca32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'POST_WARNING' => get_param('post_warning', ''), 'COMMENT_TEXT' => '', 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => $comment_url, 'TITLE' => do_lang_tempcode('FEEDBACK'))); } else { $comment_details = new ocp_tempcode(); } $out->attach($comment_details); return $out; }
/** * View a message. * * @return tempcode The message view screen. */ function view_message() { $title = get_page_title('CONTACT_US_MESSAGING'); $id = get_param('id', false, true); $message_type = get_param('message_type'); require_css('messaging'); require_javascript('javascript_validation'); $take_responsibility_url = build_url(array('page' => '_SELF', 'type' => 'take', 'id' => $id, 'message_type' => $message_type), '_SELF'); $responsible = NULL; $forum = get_option('messaging_forum_name'); // Filter/read comments require_code('feedback'); actualise_post_comment(true, $message_type, $id, build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF', NULL, false, false, true), NULL, $forum); $count = 0; $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $message_type . '_' . $id), $count); if (is_array($_comments) && array_key_exists(0, $_comments)) { $message_title = $_comments[0]['title']; $message = $_comments[0]['message']; if (isset($_comments[0]['message_comcode'])) { $GLOBALS['LAX_COMCODE'] = true; $message = comcode_to_tempcode(str_replace('[/staff_note]', '', str_replace('[staff_note]', '', $_comments[0]['message_comcode'])), $GLOBALS['FORUM_DRIVER']->get_guest_id()); } $by = $_comments[0]['username']; foreach ($_comments as $i => $comment) { if (is_object($comment['message'])) { $comment['message'] = $comment['message']->evaluate(); } if (substr($comment['message'], 0, strlen(do_lang('AUTO_SPACER_STUB'))) == do_lang('AUTO_SPACER_STUB')) { $matches = array(); if (preg_match('#' . str_replace('\\{1\\}', '(.+)', preg_quote(do_lang('AUTO_SPACER_TAKE_RESPONSIBILITY'))) . '#', $comment['message'], $matches) != 0) { $responsible = $matches[1]; } $_comments[$i] = NULL; } } $_comments[0] = NULL; } else { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $comment_details = get_comments($message_type, true, $id, false, $forum, NULL, $_comments, true); // Find who's read this $whos_read = array(); if (get_forum_type() == 'ocf') { // Read - who has, and when $topic_id = $GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $message_type . '_' . $id); $rows = $GLOBALS['FORUM_DB']->query_select('f_read_logs', array('l_member_id', 'l_time'), array('l_topic_id' => $topic_id)); foreach ($rows as $row) { $username = $GLOBALS['FORUM_DRIVER']->get_username($row['l_member_id']); $member_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($row['l_member_id'], false, true); $date = get_timezoned_date($row['l_time']); $whos_read[] = array('USERNAME' => $username, 'MEMBER_LINK' => $member_link, 'DATE' => $date); } } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')))); breadcrumb_set_self(do_lang_tempcode('VIEW')); return do_template('MESSAGING_MESSAGE_SCREEN', array('_GUID' => '61561f1a333b88370ceb66dbbcc0ea4c', 'TITLE' => $title, 'MESSAGE_TITLE' => $message_title, 'MESSAGE' => $message, 'BY' => $by, 'WHOS_READ' => $whos_read, 'COMMENT_DETAILS' => $comment_details, 'TAKE_RESPONSIBILITY_URL' => $take_responsibility_url, 'RESPONSIBLE' => $responsible)); }