Exemplo n.º 1
0
 /**
  * The UI to show a results table of moderation actions for a moderator.
  *
  * @return tempcode		The UI
  */
 function choose_action()
 {
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('VIEW_ACTION_LOGS'))));
     breadcrumb_set_self(do_lang_tempcode('RESULTS'));
     $title = get_page_title('VIEW_ACTION_LOGS');
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     $id = get_param_integer('id', -1);
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'the_type' => do_lang_tempcode('ACTION'));
     $test = explode(' ', get_param('sort', 'date_and_time DESC'), 2);
     if (count($test) == 1) {
         $test[1] = 'DESC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sort';
     require_code('templates_results_table');
     $field_titles = array(do_lang_tempcode('USERNAME'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTION'), do_lang_tempcode('PARAMETER_A'), do_lang_tempcode('PARAMETER_B'));
     if (addon_installed('securitylogging')) {
         $field_titles[] = do_lang_tempcode('_BANNED');
     }
     $fields_title = results_field_title($field_titles, $sortables, 'sort', $sortable . ' ' . $sort_order);
     $filter_to_type = get_param('to_type', '');
     $filter_param_a = get_param('param_a', '');
     $filter_param_b = get_param('param_b', '');
     $max_rows = 0;
     // Pull up our rows: forum
     if (get_forum_type() == 'ocf') {
         // Possible filter (called up by URL)
         $where = '1=1';
         if ($filter_to_type != '') {
             $where .= ' AND ' . db_string_equal_to('l_the_type', $filter_to_type);
         }
         if ($filter_param_a != '') {
             $where .= ' AND l_param_a LIKE \'' . db_encode_like('%' . $filter_param_a . '%') . '\'';
         }
         if ($filter_param_b != '') {
             $where .= ' AND l_param_b LIKE \'' . db_encode_like('%' . $filter_param_b . '%') . '\'';
         }
         if ($id != -1) {
             $where .= ' AND l_by=' . strval($id);
         }
         // Fetch
         $rows1 = $GLOBALS['FORUM_DB']->query('SELECT l_reason,id,l_by AS the_user,l_date_and_time AS date_and_time,l_the_type AS the_type,l_param_a AS param_a,l_param_b AS param_b FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_moderator_logs WHERE ' . $where . ' ORDER BY ' . $sortable . ' ' . $sort_order, $max + $start);
         $max_rows += $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_moderator_logs WHERE ' . $where);
     } else {
         $rows1 = array();
     }
     // Possible filter (called up by URL)
     $where = '1=1';
     if ($filter_to_type != '') {
         $where .= ' AND ' . db_string_equal_to('the_type', $filter_to_type);
     }
     if ($filter_param_a != '') {
         $where .= ' AND param_a LIKE \'' . db_encode_like('%' . $filter_param_a . '%') . '\'';
     }
     if ($filter_param_b != '') {
         $where .= ' AND param_b LIKE \'' . db_encode_like('%' . $filter_param_b . '%') . '\'';
     }
     if ($id != -1) {
         $where .= ' AND the_user='******'SITE_DB']->query('SELECT id,the_user,date_and_time,the_type,param_a,param_b,ip FROM ' . get_table_prefix() . 'adminlogs WHERE ' . $where . ' ORDER BY ' . $sortable . ' ' . $sort_order, $max + $start);
     $max_rows += $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'adminlogs WHERE ' . $where);
     $rows = array_merge($rows1, $rows2);
     require_code('actionlog');
     $fields = new ocp_tempcode();
     $pos = 0;
     while (count($rows) != 0 && $pos - $start < $max) {
         $best = 0;
         // Initialise type to integer
         $_best = 0;
         // Initialise type to integer
         $best = NULL;
         $_best = NULL;
         foreach ($rows as $x => $row) {
             if (is_null($best) || $row['date_and_time'] < $_best && $sortable == 'date_and_time' && $sort_order == 'ASC' || $row['date_and_time'] > $_best && $sortable == 'date_and_time' && $sort_order == 'DESC' || intval($row['the_type']) < $_best && $sortable == 'the_type' && $sort_order == 'ASC' || intval($row['the_type']) > $_best && $sortable == 'the_type' && $sort_order == 'DESC') {
                 $best = $x;
                 if ($sortable == 'date_and_time') {
                     $_best = $row['date_and_time'];
                 }
                 if ($sortable == 'the_type') {
                     $_best = $row['the_type'];
                 }
             }
         }
         if ($pos >= $start) {
             $myrow = $rows[$best];
             $username = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['the_user']);
             $mode = array_key_exists('l_reason', $myrow) ? 'ocf' : 'ocp';
             $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $myrow['id'], 'mode' => $mode), '_SELF');
             $mode_nice = $mode == 'ocp' ? 'ocPortal' : 'OCF';
             $date = hyperlink($url, get_timezoned_date($myrow['date_and_time']), false, true, $mode_nice . '/' . $row['the_type'] . '/' . strval($myrow['id']), NULL, NULL, NULL, '_top');
             if (!is_null($myrow['param_a'])) {
                 $a = $myrow['param_a'];
             } else {
                 $a = '';
             }
             if (!is_null($myrow['param_b'])) {
                 $b = $myrow['param_b'];
             } else {
                 $b = '';
             }
             require_code('templates_interfaces');
             $_a = tpl_crop_text_mouse_over($a, 8);
             $_b = tpl_crop_text_mouse_over($b, 15);
             $type_str = do_lang($myrow['the_type'], $_a, $_b, NULL, NULL, false);
             if (is_null($type_str)) {
                 $type_str = $myrow['the_type'];
             }
             $test = actionlog_linkage($myrow['the_type'], $a, $b, $_a, $_b);
             if (!is_null($test)) {
                 list($_a, $_b) = $test;
             }
             $result_entry = array($username, $date, $type_str, $_a, $_b);
             if (addon_installed('securitylogging')) {
                 $banned_test_1 = array_key_exists('ip', $myrow) ? $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_ip', 'ip', array('ip' => $myrow['ip'])) : NULL;
                 $banned_test_2 = $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_member', 'the_member', array('the_member' => $myrow['the_user']));
                 $banned_test_3 = $GLOBALS['FORUM_DRIVER']->is_banned($myrow['the_user']);
                 $banned = is_null($banned_test_1) && is_null($banned_test_2) && !$banned_test_3 ? do_lang_tempcode('NO') : do_lang_tempcode('YES');
                 $result_entry[] = $banned;
             }
             $fields->attach(results_entry($result_entry, true));
         }
         unset($rows[$best]);
         $pos++;
     }
     $table = results_table(do_lang_tempcode('ACTIONS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort');
     return do_template('ACTION_LOGS_SCREEN', array('_GUID' => 'd75c813e372c3ca8d1204609e54c9d65', 'TABLE' => $table, 'TITLE' => $title));
 }
Exemplo n.º 2
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/errorlog';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_disaster';
     require_lang('errorlog');
     $title = get_page_title('ERROR_LOG');
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     // Read in errors
     if (is_readable(get_custom_file_base() . '/data_custom/errorlog.php')) {
         if (filesize(get_custom_file_base() . '/data_custom/errorlog.php') > 1024 * 1024) {
             $myfile = fopen(get_custom_file_base() . '/data_custom/errorlog.php', 'rt');
             fseek($myfile, -1024 * 500, SEEK_END);
             $lines = explode(chr(10), fread($myfile, 1024 * 500));
             fclose($myfile);
             unset($lines[0]);
             $lines[] = '...';
         } else {
             $lines = file(get_custom_file_base() . '/data_custom/errorlog.php');
         }
     } else {
         $lines = array();
     }
     $stuff = array();
     foreach ($lines as $line) {
         $_line = trim($line);
         if ($_line != '' && strpos($_line, '<?php') === false) {
             $matches = array();
             if (preg_match('#\\[(.+?) (.+?)\\] (.+?):  ?(.*)#', $_line, $matches) != 0) {
                 $stuff[] = $matches;
             }
         }
     }
     // Put errors into table
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'));
     $test = explode(' ', get_param('sort', 'date_and_time DESC'), 2);
     if (count($test) == 1) {
         $test[1] = 'DESC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sort';
     if ($sort_order == 'DESC') {
         $stuff = array_reverse($stuff);
     }
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode('DATE_TIME'), do_lang_tempcode('TYPE'), do_lang_tempcode('MESSAGE')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     for ($i = $start; $i < $start + $max; $i++) {
         if (!array_key_exists($i, $stuff)) {
             break;
         }
         $message = str_replace(get_file_base(), '', $stuff[$i][4]);
         $fields->attach(results_entry(array(escape_html($stuff[$i][1] . ' ' . $stuff[$i][2]), escape_html($stuff[$i][3]), escape_html($message))));
     }
     $error = results_table(do_lang_tempcode('ERROR_LOG'), $start, 'start', $max, 'max', $i, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort', new ocp_tempcode());
     // Read in end of permissions file
     require_all_lang();
     if (is_readable(get_custom_file_base() . '/data_custom/permissioncheckslog.php')) {
         $myfile = @fopen(get_custom_file_base() . '/data_custom/permissioncheckslog.php', 'rt');
         if ($myfile !== false) {
             fseek($myfile, -40000, SEEK_END);
             $data = '';
             while (!feof($myfile)) {
                 $data .= fread($myfile, 8192);
             }
             fclose($myfile);
             $lines = explode(chr(10), $data);
             if (count($lines) != 0) {
                 if (strpos($lines[0], '<' . '?php') !== false) {
                     array_shift($lines);
                 } else {
                     if (strlen($data) == 40000) {
                         $lines[0] = '...';
                     }
                 }
             }
             foreach ($lines as $i => $line) {
                 $matches = array();
                 if (preg_match('#^\\s+has\\_specific\\_permission: (\\w+)#', $line, $matches) != 0) {
                     $looked_up = do_lang('PT_' . $matches[1], NULL, NULL, NULL, NULL, false);
                     if (!is_null($looked_up)) {
                         $line = str_replace($matches[1], $looked_up, $line);
                         $lines[$i] = $line;
                     }
                 }
             }
         }
     }
     // Put permssions into table
     $permission = implode(chr(10), $lines);
     return do_template('ERRORLOG_SCREEN', array('_GUID' => '9186c7beb6b722a52f39e2cbe16aded6', 'TITLE' => $title, 'ERROR' => $error, 'PERMISSION' => $permission));
 }
Exemplo n.º 3
0
 /**
  * The UI to either show an existing ticket and allow a reply, or to start a new ticket.
  *
  * @return tempcode		The UI
  */
 function do_ticket()
 {
     require_lang('comcode');
     $id = get_param('id', NULL);
     if ($id == '') {
         $id = NULL;
     }
     if (!is_null($id)) {
         $_temp = explode('_', $id);
         if (!isset($_temp[1])) {
             warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
         }
         // Normal topic, not a ticket!
         $ticket_owner = intval($_temp[0]);
         $ticket_id = $_temp[1];
         if (is_guest()) {
             access_denied('NOT_AS_GUEST');
         }
         $this->check_id($id);
     } else {
         $ticket_owner = get_member();
         $ticket_id = uniqid('', true);
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SUPPORT_TICKETS'))));
     $poster = '';
     $new = true;
     $serialized_options = mixed();
     $hash = mixed();
     if (!is_guest() || is_null($id)) {
         $member = get_member();
         $new = is_null($id);
         $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread')));
         $start = get_param_integer('start_comments', 0);
         if ($new) {
             $id = strval($member) . '_' . $ticket_id;
             $title = get_page_title('ADD_TICKET');
         } else {
             $ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $id));
             $ticket_type_text = get_translated_text($ticket_type);
             $ticket_type_details = get_ticket_type($ticket_type);
             $forum = 1;
             $topic_id = 1;
             $_ticket_type = 1;
             // These will be returned by reference
             $_comments = get_ticket_posts($id, $forum, $topic_id, $_ticket_type, $start, $num_to_show_limit);
             $_comments_all = get_ticket_posts($id, $forum, $topic_id, $_ticket_type);
             if (!is_array($_comments) || !array_key_exists(0, $_comments)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $ticket_title = $_comments[0]['title'];
             if ($ticket_title == '') {
                 $ticket_title = do_lang('UNKNOWN');
             }
             $title = get_page_title('_VIEW_SUPPORT_TICKET', true, array(escape_html($ticket_title), escape_html($ticket_type_text)));
             breadcrumb_set_self($ticket_title);
         }
         $ticket_page_text = comcode_to_tempcode(get_option('ticket_text'), NULL, true);
         $staff_details = new ocp_tempcode();
         $types = $this->build_types_list(get_param('default', ''));
         $results_browser = NULL;
         if (!$new) {
             require_code('templates_internalise_screen');
             $test_tpl = internalise_own_screen($title, 30, $_comments_all);
             if (is_object($test_tpl)) {
                 return $test_tpl;
             }
             if (is_null($_comments)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             if (has_specific_permission(get_member(), 'support_operator')) {
                 $staff_details = make_string_tempcode($GLOBALS['FORUM_DRIVER']->topic_url($topic_id, escape_html(get_option('ticket_forum_name'))));
             } else {
                 $staff_details = new ocp_tempcode();
             }
             require_code('topics');
             $renderer = new OCP_Topic();
             $renderer->_inject_posts_for_scoring_algorithm($_comments);
             $renderer->topic_id = $topic_id;
             // Posts
             $max_thread_depth = get_param_integer('max_thread_depth', intval(get_option('max_thread_depth')));
             list($comments, $serialized_options, $hash) = $renderer->render_posts($num_to_show_limit, $max_thread_depth, true, $ticket_owner, array(), $forum);
             // Pagination
             if (!$renderer->is_threaded) {
                 if (count($_comments_all) > $num_to_show_limit) {
                     require_code('templates_results_browser');
                     $results_browser = results_browser(do_lang_tempcode('COMMENTS'), NULL, $start, 'start_comments', $num_to_show_limit, 'max_comments', count($_comments_all), NULL, NULL, true);
                 }
             }
             $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $_comments[0]['date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($_comments[0]['user']), 'publisher' => '', 'modified' => '', 'type' => 'Support ticket', 'title' => $_comments[0]['title'], 'identifier' => '_SEARCH:tickets:ticket:' . $id, 'description' => '', 'image' => find_theme_image('bigicons/tickets'));
             // "Staff only reply" tickbox
             if (get_forum_type() == 'ocf' && $GLOBALS['FORUM_DRIVER']->is_staff(get_member())) {
                 require_code('form_templates');
                 $staff_only = form_input_tick(do_lang('TICKET_STAFF_ONLY'), do_lang('TICKET_STAFF_ONLY_DESCRIPTION'), 'staff_only', false);
             } else {
                 $staff_only = new ocp_tempcode();
             }
         } else {
             $comments = new ocp_tempcode();
             $staff_only = new ocp_tempcode();
             $ticket_type_details = get_ticket_type(NULL);
         }
         if ($poster == '' || $GLOBALS['FORUM_DRIVER']->get_guest_id() != intval($poster)) {
             $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
             require_javascript('javascript_editing');
             require_javascript('javascript_validation');
             require_javascript('javascript_posting');
             require_javascript('javascript_swfupload');
             require_css('swfupload');
             require_code('form_templates');
             list($attachments, $attach_size_field) = get_forum_type() == 'ocf' ? get_attachments('post') : array(NULL, NULL);
             if (addon_installed('captcha')) {
                 require_code('captcha');
                 $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha();
                 if ($use_captcha) {
                     generate_captcha();
                 }
             } else {
                 $use_captcha = false;
             }
             $comment_form = do_template('COMMENTS_POSTING_FORM', array('_GUID' => 'aaa32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'ATTACHMENTS' => $attachments, 'ATTACH_SIZE_FIELD' => $attach_size_field, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => is_guest(), 'EMAIL_OPTIONAL' => is_guest() && $ticket_type_details['guest_emails_mandatory'], 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => '', 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'), 'TITLE' => do_lang_tempcode($new ? 'CREATE_TICKET_MAKE_POST' : 'MAKE_POST')));
         } else {
             $comment_form = new ocp_tempcode();
         }
         $post_url = build_url(array('page' => '_SELF', 'id' => $id, 'type' => 'post', 'redirect' => get_param('redirect', NULL)), '_SELF');
         require_code('form_templates');
         require_code('feedback');
         list($warning_details, $ping_url) = handle_conflict_resolution(NULL, true);
         $other_tickets = new ocp_tempcode();
         $our_topic = NULL;
         if (!is_guest($ticket_owner)) {
             $tickets_of_member = get_tickets($ticket_owner, NULL, true);
             if (!is_null($tickets_of_member)) {
                 foreach ($tickets_of_member as $topic) {
                     $ticket_id = extract_topic_identifier($topic['description']);
                     if ($id != $ticket_id) {
                         $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $ticket_id), '_SELF');
                         $_title = $topic['firsttitle'];
                         $date = get_timezoned_date($topic['lasttime']);
                         $ticket_owner_name = $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner);
                         if (is_null($ticket_owner_name)) {
                             $profile_link = '';
                         } else {
                             $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($ticket_owner, false, true);
                         }
                         $last_poster = $topic['lastusername'];
                         $unclosed = !$GLOBALS['FORUM_DRIVER']->is_staff($topic['lastmemberid']);
                         $params = array('NUM_POSTS' => integer_format($topic['num'] - 1), 'CLOSED' => strval($topic['closed']), 'URL' => $url, 'TITLE' => $_title, 'DATE' => $date, 'DATE_RAW' => strval($topic['lasttime']), 'PROFILE_LINK' => $profile_link, 'LAST_POSTER' => $last_poster, 'UNCLOSED' => $unclosed);
                         $other_tickets->attach(do_template('SUPPORT_TICKET_LINK', $params));
                     } else {
                         $our_topic = $topic;
                     }
                 }
             }
         }
         $toggle_ticket_closed_url = NULL;
         if (get_forum_type() == 'ocf' && !$new) {
             $toggle_ticket_closed_url = build_url(array('page' => '_SELF', 'type' => 'toggle_ticket_closed', 'id' => $id), '_SELF');
         }
         $map = array('page' => '_SELF', 'type' => 'ticket');
         if (get_param('default', '') != '') {
             $map['default'] = get_param('default');
         }
         $add_ticket_url = build_url($map, '_SELF');
         return do_template('SUPPORT_TICKET_SCREEN', array('_GUID' => 'd21a9d161008c6c44fe7309a14be2c5b', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'TOGGLE_TICKET_CLOSED_URL' => $toggle_ticket_closed_url, 'CLOSED' => is_null($our_topic) ? '0' : strval($our_topic['closed']), 'OTHER_TICKETS' => $other_tickets, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner), 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'NEW' => $new, 'TICKET_PAGE_TEXT' => $ticket_page_text, 'TYPES' => $types, 'STAFF_ONLY' => $staff_only, 'POSTER' => $poster, 'TITLE' => $title, 'COMMENTS' => $comments, 'COMMENT_FORM' => $comment_form, 'STAFF_DETAILS' => $staff_details, 'URL' => $post_url, 'ADD_TICKET_URL' => $add_ticket_url, 'RESULTS_BROWSER' => $results_browser));
     } else {
         return inform_screen(get_page_title('ADD_TICKET'), do_lang_tempcode('SUCCESS'));
     }
 }
Exemplo n.º 4
0
 /**
  * The UI to show a results table of banner details/statistics.
  *
  * @return tempcode		The UI
  */
 function banner_statistics()
 {
     $title = get_page_title('BANNER_STATISTICS');
     check_specific_permission('view_anyones_banner_stats');
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         $also_url = build_url(array('page' => 'cms_banners'), get_module_zone('cms_banners'));
         attach_message(do_lang_tempcode('menus:ALSO_SEE_ADMIN', escape_html($also_url->evaluate())), 'inform');
         return $test_tpl;
     }
     $id = get_param_integer('id', -1);
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('name' => do_lang_tempcode('NAME'), 'add_date' => do_lang_tempcode('DATE_TIME'));
     $test = explode(' ', get_param('sort', 'name ASC'), 2);
     if (count($test) == 1) {
         $test[1] = 'DESC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sort';
     $_sum = $GLOBALS['SITE_DB']->query_value('banners', 'SUM(views_from)');
     $has_banner_network = $_sum != 0.0;
     require_code('templates_results_table');
     $field_titles_arr = array(do_lang_tempcode('NAME'), do_lang_tempcode('TYPE'), do_lang_tempcode('_BANNER_TYPE'));
     if ($has_banner_network) {
         $field_titles_arr = array_merge($field_titles_arr, array(do_lang_tempcode('BANNER_HITSFROM'), do_lang_tempcode('BANNER_VIEWSFROM')));
     }
     $field_titles_arr = array_merge($field_titles_arr, array(do_lang_tempcode('BANNER_HITSTO'), do_lang_tempcode('BANNER_VIEWSTO'), do_lang_tempcode('BANNER_CLICKTHROUGH'), do_lang_tempcode('IMPORTANCE_MODULUS'), do_lang_tempcode('SUBMITTER'), do_lang_tempcode('_ADDED')));
     if (addon_installed('unvalidated')) {
         $field_titles_arr[] = do_lang_tempcode('VALIDATED');
     }
     $fields_title = results_field_title($field_titles_arr, $sortables, 'sort', $sortable . ' ' . $sort_order);
     $rows = $GLOBALS['SITE_DB']->query_select('banners', array('*'), NULL, '', $max, $start);
     $max_rows = $GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)');
     $fields = new ocp_tempcode();
     foreach ($rows as $myrow) {
         $name = hyperlink(build_url(array('page' => 'banners', 'type' => 'view', 'source' => $myrow['name']), get_module_zone('banners')), $myrow['name'], false, true);
         switch ($myrow['the_type']) {
             case 0:
                 $type = do_lang_tempcode('BANNER_PERMANENT');
                 break;
             case 1:
                 $type = do_lang_tempcode('_BANNER_HITS_LEFT', do_lang_tempcode('BANNER_CAMPAIGN'), make_string_tempcode(integer_format($myrow['campaign_remaining'])));
                 break;
             case 2:
                 $type = do_lang_tempcode('BANNER_DEFAULT');
                 break;
         }
         $banner_type = $myrow['b_type'];
         if ($banner_type == '') {
             $banner_type = do_lang('GENERAL');
         }
         $date_and_time = get_timezoned_date($myrow['add_date']);
         $hits_from = integer_format($myrow['hits_from']);
         $views_from = integer_format($myrow['views_from']);
         $hits_to = $myrow['site_url'] == '' ? do_lang_tempcode('CANT_TRACK') : protect_from_escaping(escape_html(integer_format($myrow['hits_to'])));
         $views_to = $myrow['site_url'] == '' ? do_lang_tempcode('CANT_TRACK') : protect_from_escaping(escape_html(integer_format($myrow['views_to'])));
         if ($myrow['views_to'] != 0) {
             $click_through = protect_from_escaping(escape_html(integer_format(intval(round(100.0 * ($myrow['hits_to'] / $myrow['views_to']))))));
         } else {
             $click_through = do_lang_tempcode('NA_EM');
         }
         $username = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['submitter']);
         $importance_modulus = $myrow['importance_modulus'];
         $validated = $myrow['validated'] == 1 ? do_lang('YES') : do_lang('NO');
         if (!is_null($myrow['expiry_date']) && $myrow['expiry_date'] < time()) {
             $validated .= do_lang('BUT_EXPIRED');
         }
         $result = array(escape_html($name), escape_html($type), escape_html($banner_type));
         if ($has_banner_network) {
             $result = array_merge($result, array(escape_html($hits_from), escape_html($views_from)));
         }
         $result = array_merge($result, array(escape_html($hits_to), escape_html($views_to), escape_html($click_through), escape_html(strval($importance_modulus)), $username, escape_html($date_and_time)));
         if (addon_installed('unvalidated')) {
             $result[] = escape_html($validated);
         }
         $fields->attach(results_entry($result, true));
     }
     $table = results_table(do_lang_tempcode('BANNERS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort');
     return do_template('RESULTS_TABLE_SCREEN', array('_GUID' => 'c9270fd515e76918a37edf3f573c6da2', 'RESULTS_TABLE' => $table, 'TITLE' => $title));
 }
Exemplo n.º 5
0
 /**
  * The UI to show the member directory.
  *
  * @return tempcode		The UI
  */
 function directory()
 {
     require_javascript('javascript_ajax');
     require_javascript('javascript_ajax_people_lists');
     $title = get_page_title('MEMBERS');
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     if (running_script('iframe')) {
         $get_url = find_script('iframe');
     } else {
         $get_url = find_script('index');
     }
     $hidden = new ocp_tempcode();
     $hidden->attach(build_keep_form_fields('_SELF', true, array('filter')));
     $hidden->attach(form_input_hidden('zone', get_zone_name()));
     $start = get_param_integer('md_start', 0);
     $max = get_param_integer('md_max', 50);
     $sortables = array('m_username' => do_lang_tempcode('USERNAME'), 'm_primary_group' => do_lang_tempcode('PRIMARY_GROUP'), 'm_cache_num_posts' => do_lang_tempcode('COUNT_POSTS'), 'm_join_time' => do_lang_tempcode('JOIN_DATE'));
     $default_sort_order = get_value('md_default_sort_order');
     if (is_null($default_sort_order)) {
         $default_sort_order = 'm_join_time DESC';
     }
     $test = explode(' ', get_param('md_sort', $default_sort_order), 2);
     if (count($test) == 1) {
         $test[] = 'ASC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'md_sort';
     $group_filter = get_param('group_filter', '');
     $_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, $group_filter == '' ? NULL : array(intval($group_filter)));
     $usergroups = array();
     require_code('ocf_groups2');
     foreach ($_usergroups as $group_id => $group) {
         $num = ocf_get_group_members_raw_count($group_id, true);
         $usergroups[$group_id] = array('USERGROUP' => $group, 'NUM' => strval($num));
     }
     $query = 'FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id());
     if (!has_specific_permission(get_member(), 'see_unvalidated')) {
         $query .= ' AND m_validated=1';
     }
     if ($group_filter != '') {
         if (is_numeric($group_filter)) {
             $title = get_page_title('USERGROUP', true, array(escape_html($usergroups[intval($group_filter)]['USERGROUP'])));
         }
         require_code('ocfiltering');
         $filter = ocfilter_to_sqlfragment($group_filter, 'm_primary_group', 'f_groups', NULL, 'm_primary_group', 'id');
         $query .= ' AND ' . $filter;
     }
     $search = get_param('filter', '');
     $sup = $search != '' ? ' AND m_username LIKE \'' . db_encode_like(str_replace('*', '%', $search)) . '\'' : '';
     if ($sortable == 'm_join_time') {
         $query .= $sup . ' ORDER BY m_join_time ' . $sort_order . ',' . 'id ' . $sort_order;
     } else {
         $query .= $sup . ' ORDER BY ' . $sortable . ' ' . $sort_order;
     }
     $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query);
     $rows = $GLOBALS['FORUM_DB']->query('SELECT * ' . $query, $max, $start);
     if (count($rows) == 0) {
         return inform_screen($title, do_lang_tempcode('NO_RESULTS'));
     }
     $members = new ocp_tempcode();
     $member_boxes = array();
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('PRIMARY_GROUP'), do_lang_tempcode('COUNT_POSTS'), do_lang_tempcode('JOIN_DATE')), $sortables, 'md_sort', $sortable . ' ' . $sort_order);
     require_code('ocf_members2');
     foreach ($rows as $row) {
         $link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['id'], true, $row['m_username']);
         if ($row['m_validated'] == 0) {
             $link->attach(do_lang_tempcode('MEMBER_IS_UNVALIDATED'));
         }
         if ($row['m_validated_email_confirm_code'] != '') {
             $link->attach(do_lang_tempcode('MEMBER_IS_UNCONFIRMED'));
         }
         $member_primary_group = ocf_get_member_primary_group($row['id']);
         $primary_group = ocf_get_group_link($member_primary_group);
         $members->attach(results_entry(array($link, $primary_group, escape_html(integer_format($row['m_cache_num_posts'])), escape_html(get_timezoned_date($row['m_join_time'])))));
         $member_boxes[] = ocf_show_member_box($row['id'], true);
     }
     $results_table = results_table(do_lang_tempcode('MEMBERS'), $start, 'md_start', $max, 'md_max', $max_rows, $fields_title, $members, $sortables, $sortable, $sort_order, 'md_sort');
     $results_browser = results_browser(do_lang_tempcode('MEMBERS'), NULL, $start, 'md_start', $max, 'md_max', $max_rows, NULL, NULL, true, true);
     $symbols = NULL;
     if (get_option('allow_alpha_search') == '1') {
         $alpha_query = $GLOBALS['FORUM_DB']->query('SELECT m_username FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id()) . ' ORDER BY m_username ASC');
         $symbols = array(array('START' => '0', 'SYMBOL' => do_lang('ALL')), array('START' => '0', 'SYMBOL' => '#'));
         foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z') as $s) {
             foreach ($alpha_query as $i => $q) {
                 if (strtolower(substr($q['m_username'], 0, 1)) == $s) {
                     break;
                 }
             }
             if (substr(strtolower($q['m_username']), 0, 1) != $s) {
                 $i = intval($symbols[count($symbols) - 1]['START']);
             }
             $symbols[] = array('START' => strval(intval($max * floor(floatval($i) / floatval($max)))), 'SYMBOL' => $s);
         }
     }
     return do_template('OCF_MEMBER_DIRECTORY_SCREEN', array('_GUID' => '096767e9aaabce9cb3e6591b7bcf95b8', 'MAX' => strval($max), 'RESULTS_BROWSER' => $results_browser, 'MEMBER_BOXES' => $member_boxes, 'USERGROUPS' => $usergroups, 'HIDDEN' => $hidden, 'SYMBOLS' => $symbols, 'SEARCH' => $search, 'GET_URL' => $get_url, 'TITLE' => $title, 'RESULTS_TABLE' => $results_table));
 }
Exemplo n.º 6
0
 /**
  * The UI to show the edit/delete history of posts (exact history shown depending on GET parameters).
  *
  * @return tempcode		The UI
  */
 function gui()
 {
     check_specific_permission('view_content_history');
     $member_id = get_param_integer('member_id', -1);
     $post_id = get_param_integer('post_id', -1);
     $topic_id = get_param_integer('topic_id', -1);
     $where = array();
     if ($member_id != -1) {
         $where['h_owner_member_id'] = $member_id;
         $title = get_page_title('POST_HISTORY_MEMBER');
     }
     if ($post_id != -1) {
         $where['h_post_id'] = $post_id;
         $title = get_page_title('POST_HISTORY_POST');
     }
     if ($topic_id != -1) {
         $where['h_topic_id'] = $topic_id;
         $title = get_page_title('POST_HISTORY_TOPIC');
     }
     if (count($where) == 0) {
         $where = NULL;
         $title = get_page_title('POST_HISTORY');
     }
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 40);
     $max_rows = $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', $where);
     $posts = $GLOBALS['FORUM_DB']->query_select('f_post_history', array('*'), $where, 'ORDER BY h_action_date_and_time DESC', $max, $start);
     $content = new ocp_tempcode();
     foreach ($posts as $post) {
         $create_date_and_time = get_timezoned_date($post['h_create_date_and_time']);
         $action_date_and_time = get_timezoned_date($post['h_action_date_and_time']);
         $owner_member = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($post['h_owner_member_id']);
         $alterer_member = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($post['h_alterer_member_id']);
         // Action/Link
         $topic_exists = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 'id', array('id' => $post['h_topic_id']));
         if (!is_null($topic_exists)) {
             if ($post['h_action'] == 'EDIT_POST') {
                 $relates_to = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $post['h_post_id']), get_module_zone('topicview'));
                 $relates_to->attach('#post_' . strval($post['h_post_id']));
                 $relates_text = do_lang_tempcode('VIEW_POST');
                 $relates_tooltip = 'post#' . strval($post['h_post_id']);
             } elseif ($post['h_action'] == 'DELETE_POST') {
                 $relates_to = build_url(array('page' => 'topicview', 'id' => $post['h_topic_id']), get_module_zone('topicview'));
                 $relates_text = do_lang_tempcode('VIEW_TOPIC');
                 $relates_tooltip = 'topic#' . strval($post['h_topic_id']);
             }
             $link = hyperlink($relates_to, $relates_text, false, true, $relates_tooltip);
         } else {
             $link = new ocp_tempcode();
         }
         $action = do_lang($post['h_action']);
         // Buttons
         $buttons = new ocp_tempcode();
         if (has_specific_permission(get_member(), 'delete_content_history')) {
             $url = build_url(array('page' => '_SELF', 'type' => 'delete', 'h_id' => $post['id']), '_SELF', NULL, true);
             $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '11c9f9ef4a646493544cb29778134960', 'IMMEDIATE' => true, 'URL' => $url, 'IMG' => 'delete', 'TITLE' => do_lang_tempcode('DELETE_HISTORY_POST'))));
         }
         if (has_specific_permission(get_member(), 'restore_content_history') && !is_null($topic_exists) && $post['h_action'] == 'DELETE_POST') {
             $url = build_url(array('page' => '_SELF', 'type' => 'restore', 'h_id' => $post['id']), '_SELF', NULL, true);
             $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '49623e00065f488bb27097bb722232dc', 'IMMEDIATE' => true, 'URL' => $url, 'IMG' => 'restore', 'TITLE' => do_lang_tempcode('RESTORE_HISTORY_POST'))));
         }
         if (has_specific_permission(get_member(), 'restore_content_history') && !is_null($topic_exists) && $post['h_action'] == 'EDIT_POST') {
             $url = build_url(array('page' => '_SELF', 'type' => 'revert', 'h_id' => $post['id']), '_SELF', NULL, true);
             $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '3f41d4d399676972c01ebb14f6ee56db', 'IMMEDIATE' => true, 'URL' => $url, 'IMG' => 'choose', 'TITLE' => do_lang_tempcode('REVERT_HISTORY_POST'))));
         }
         $content->attach(do_template('OCF_HISTORY_POST', array('_GUID' => 'f3512689a8b3fcf4215f63f9f340cdac', 'LABEL' => do_lang_tempcode('BEFORE_ACTION'), 'RAND' => uniqid(''), 'LINK' => $link, 'BUTTONS' => $buttons, 'ACTION' => $action, 'ACTION_DATE_AND_TIME' => $action_date_and_time, 'ACTION_DATE_AND_TIME_RAW' => strval($post['h_action_date_and_time']), 'CREATE_DATE_AND_TIME_RAW' => strval($post['h_create_date_and_time']), 'CREATE_DATE_AND_TIME' => $create_date_and_time, 'OWNER_MEMBER' => $owner_member, 'ALTERER_MEMBER' => $alterer_member, 'BEFORE' => $post['h_before'])));
     }
     if (count($posts) != 0 && $post_id != -1) {
         $original_post = $GLOBALS['FORUM_DB']->query_select('f_posts', array('*'), array('id' => $post_id), '', 1);
         if (array_key_exists(0, $original_post)) {
             $action = do_lang('CURRENT');
             $link = hyperlink(build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $post_id), get_module_zone('topicview')), do_lang_tempcode('VIEW_POST'), false, true);
             $buttons = new ocp_tempcode();
             $action_date_and_time = '';
             $action_date_and_time_raw = '';
             $owner_member = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($original_post[0]['p_poster']);
             $alterer_member = new ocp_tempcode();
             $before = get_translated_text($original_post[0]['p_post'], $GLOBALS['FORUM_DB']);
             $create_date_and_time = get_timezoned_date($original_post[0]['p_time']);
             $create_date_and_time_raw = strval($original_post[0]['p_time']);
             $content2 = do_template('OCF_HISTORY_POST', array('_GUID' => 'a3512689a8b3fcf4215f63f9f340cdac', 'LABEL' => do_lang_tempcode('CURRENT_STATUS'), 'RAND' => uniqid(''), 'LINK' => $link, 'BUTTONS' => $buttons, 'ACTION' => $action, 'ACTION_DATE_AND_TIME' => $action_date_and_time, 'ACTION_DATE_AND_TIME_RAW' => $action_date_and_time_raw, 'CREATE_DATE_AND_TIME_RAW' => $create_date_and_time_raw, 'CREATE_DATE_AND_TIME' => $create_date_and_time, 'OWNER_MEMBER' => $owner_member, 'ALTERER_MEMBER' => $alterer_member, 'BEFORE' => $before));
             $content2->attach($content);
             $content = $content2;
         }
     }
     require_code('templates_results_browser');
     $results_browser = results_browser(do_lang_tempcode('POST_HISTORY'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true);
     return do_template('OCF_HISTORY_SCREEN', array('_GUID' => '7dd45ce985fc7222771368336c3f19e4', 'RESULTS_BROWSER' => $results_browser, 'TITLE' => $title, 'CONTENT' => $content));
 }
Exemplo n.º 7
0
 /**
  * The UI to do a search.
  *
  * @return tempcode		The UI
  */
 function form()
 {
     global $NON_CANONICAL_PARAMS;
     $id = get_param('id', '');
     $title = get_page_title('SEARCH_TITLE');
     require_code('templates_internalise_screen');
     if ($id != '') {
         require_code('hooks/modules/search/' . filter_naughty_harsh($id), true);
         $object = object_factory('Hook_search_' . filter_naughty_harsh($id));
         $info = $object->info();
         if (!is_null($info)) {
             $title = get_page_title('_SEARCH_TITLE', true, array($info['lang']));
         }
         breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('SEARCH_FOR'))));
         breadcrumb_set_self($info['lang']);
         $under = get_param('search_under', '!', true);
         if (!is_null($info) && method_exists($object, 'get_tree')) {
             $object->get_tree($under);
         }
         if (!is_null($info)) {
             $test_tpl = internalise_own_screen($title);
         } else {
             $test_tpl = NULL;
         }
     } else {
         $test_tpl = internalise_own_screen($title);
     }
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     require_javascript('javascript_ajax');
     require_javascript('javascript_ajax_people_lists');
     $content = get_param('content', NULL, true);
     $user_label = do_lang_tempcode('SEARCH_USER');
     $days_label = do_lang_tempcode('SUBMITTED_WITHIN');
     $extra_sort_fields = array();
     if ($id != '') {
         $url_map = array('page' => '_SELF', 'type' => 'results', 'id' => $id, 'specific' => 1);
         $catalogue_name = get_param('catalogue_name', '');
         if ($catalogue_name != '') {
             $url_map['catalogue_name'] = $catalogue_name;
         }
         $force_non_tabular = get_param_integer('force_non_tabular', 0);
         if ($force_non_tabular == 1) {
             $url_map['force_non_tabular'] = 1;
         }
         $url = build_url($url_map, '_SELF', NULL, false, true);
         require_code('hooks/modules/search/' . filter_naughty_harsh($id), true);
         $object = object_factory('Hook_search_' . filter_naughty_harsh($id));
         $info = $object->info();
         if (is_null($info)) {
             warn_exit(do_lang_tempcode('SEARCH_HOOK_NOT_AVAILABLE'));
         }
         if (array_key_exists('user_label', $info)) {
             $user_label = $info['user_label'];
         }
         if (array_key_exists('days_label', $info)) {
             $days_label = $info['days_label'];
         }
         $extra_sort_fields = array_key_exists('extra_sort_fields', $info) ? $info['extra_sort_fields'] : array();
         $under = NULL;
         if (method_exists($object, 'ajax_tree')) {
             require_javascript('javascript_tree_list');
             require_javascript('javascript_more');
             $ajax = true;
             $under = get_param('search_under', '', true);
             list($ajax_hook, $ajax_options) = $object->ajax_tree();
             require_code('hooks/systems/ajax_tree/' . $ajax_hook);
             $tree_hook_object = object_factory('Hook_' . $ajax_hook);
             $simple_content = $tree_hook_object->simple(NULL, $ajax_options, preg_replace('#,.*$#', '', $under));
             $nice_label = $under;
             if (!is_null($under)) {
                 $simple_content_evaluated = $simple_content->evaluate();
                 $matches = array();
                 if (preg_match('#<option [^>]*value="' . str_replace('#', '\\#', preg_quote($under)) . '(' . (strpos($under, ',') === false ? ',' : '') . '[^"]*)?"[^>]*>([^>]* &gt; )?([^>]*)</option>#', $simple_content_evaluated, $matches) != 0) {
                     if (strpos($under, ',') === false) {
                         $under = $under . $matches[1];
                     }
                     $nice_label = trim($matches[3]);
                 }
             }
             require_code('form_templates');
             $tree = do_template('FORM_SCREEN_INPUT_TREE_LIST', array('_GUID' => '25368e562be3b4b9c6163aa008b47c91', 'TABINDEX' => strval(get_form_field_tabindex()), 'NICE_LABEL' => is_null($nice_label) || $nice_label == '-1' ? '' : $nice_label, 'END_OF_FORM' => true, 'REQUIRED' => '', 'USE_SERVER_ID' => false, 'NAME' => 'search_under', 'DEFAULT' => $under, 'HOOK' => $ajax_hook, 'ROOT_ID' => '', 'OPTIONS' => serialize($ajax_options)));
         } else {
             $ajax = false;
             $tree = form_input_list_entry('!', false, do_lang_tempcode('NA_EM'));
             if (method_exists($object, 'get_tree')) {
                 $under = get_param('search_under', '!', true);
                 $tree->attach($object->get_tree($under));
             }
         }
         $options = new ocp_tempcode();
         if (array_key_exists('special_on', $info)) {
             foreach ($info['special_on'] as $name => $display) {
                 $options->attach(do_template('SEARCH_FOR_SEARCH_DOMAIN_OPTION', array('_GUID' => 'c1853f42d0a110026453f8b94c9f623c', 'CHECKED' => is_null($content) || get_param_integer('option_' . $id . '_' . $name, 0) == 1, 'NAME' => 'option_' . $id . '_' . $name, 'DISPLAY' => $display)));
             }
         }
         if (array_key_exists('special_off', $info)) {
             foreach ($info['special_off'] as $name => $display) {
                 $options->attach(do_template('SEARCH_FOR_SEARCH_DOMAIN_OPTION', array('_GUID' => '2223ada7636c85e6879feb9a6f6885d2', 'CHECKED' => get_param_integer('option_' . $id . '_' . $name, 0) == 1, 'NAME' => 'option_' . $id . '_' . $name, 'DISPLAY' => $display)));
             }
         }
         if (method_exists($object, 'get_fields')) {
             $fields = $object->get_fields();
             foreach ($fields as $field) {
                 $options->attach(do_template('SEARCH_FOR_SEARCH_DOMAIN_OPTION' . $field['TYPE'], array('_GUID' => 'a223ada7636c85e6879feb9a6f6885d2', 'NAME' => 'option_' . $field['NAME'], 'DISPLAY' => $field['DISPLAY'], 'SPECIAL' => $field['SPECIAL'], 'CHECKED' => array_key_exists('checked', $field) ? $field['CHECKED'] : false)));
             }
         }
         $specialisation = do_template('SEARCH_ADVANCED', array('_GUID' => 'fad0c147b8291ba972f105c65715f1ac', 'AJAX' => $ajax, 'OPTIONS' => $options, 'TREE' => $tree, 'UNDERNEATH' => !is_null($under)));
     } else {
         $map = array('page' => '_SELF', 'type' => 'results');
         $under = get_param('search_under', '-1', true);
         if ($under != '-1') {
             $map['search_under'] = $under;
         }
         $url = build_url($map, '_SELF', NULL, false, true);
         $search_domains = new ocp_tempcode();
         $_search_domains = array();
         $_hooks = find_all_hooks('modules', 'search');
         foreach (array_keys($_hooks) as $hook) {
             require_code('hooks/modules/search/' . filter_naughty_harsh($hook));
             $object = object_factory('Hook_search_' . filter_naughty_harsh($hook), true);
             if (is_null($object)) {
                 continue;
             }
             $info = $object->info();
             if (is_null($info)) {
                 continue;
             }
             $NON_CANONICAL_PARAMS[] = 'search_' . $hook;
             $is_default_or_advanced = $info['default'] && $id == '' || $hook == $id;
             $checked = get_param_integer('search_' . $hook, is_null($content) || get_param_integer('all_defaults', 0) == 1 ? $is_default_or_advanced ? 1 : 0 : 0) == 1;
             $options = array_key_exists('special_on', $info) || array_key_exists('special_off', $info) || array_key_exists('extra_sort_fields', $info) || method_exists($object, 'get_fields') || method_exists($object, 'get_tree') || method_exists($object, 'get_ajax_tree') ? build_url(array('page' => '_SELF', 'id' => $hook), '_SELF', NULL, false, true) : new ocp_tempcode();
             $_search_domains[] = array('_GUID' => '3d3099872184923aec0f49388f52c750', 'ADVANCED_ONLY' => array_key_exists('advanced_only', $info) && $info['advanced_only'], 'CHECKED' => $checked, 'OPTIONS' => $options, 'LANG' => $info['lang'], 'NAME' => $hook);
         }
         global $M_SORT_KEY;
         $M_SORT_KEY = 'LANG';
         usort($_search_domains, 'multi_sort');
         foreach ($_search_domains as $sd) {
             $search_domains->attach(do_template('SEARCH_FOR_SEARCH_DOMAIN', $sd));
         }
         $specialisation = do_template('SEARCH_DOMAINS', array('_GUID' => '1fd8718b540ec475988070ee7a444dc1', 'SEARCH_DOMAINS' => $search_domains));
     }
     $author = get_param('author', '');
     $author_id = $author != '' ? $GLOBALS['FORUM_DRIVER']->get_member_from_username($author) : NULL;
     $days = get_param_integer('days', 60);
     $sort = get_param('sort', 'relevance');
     $direction = get_param('direction', 'DESC');
     if (!in_array(strtoupper($direction), array('ASC', 'DESC'))) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     $NON_CANONICAL_PARAMS[] = 'sort';
     $NON_CANONICAL_PARAMS[] = 'direction';
     $only_titles = get_param_integer('only_titles', 0) == 1;
     $search_under = get_param('search_under', '!', true);
     if ($search_under == '') {
         $search_under = '!';
     }
     $boolean_operator = get_param('conjunctive_operator', 'OR');
     $NON_CANONICAL_PARAMS[] = 'search_under';
     $NON_CANONICAL_PARAMS[] = 'all_defaults';
     $NON_CANONICAL_PARAMS[] = 'days';
     $NON_CANONICAL_PARAMS[] = 'only_titles';
     $NON_CANONICAL_PARAMS[] = 'conjunctive_operator';
     $NON_CANONICAL_PARAMS[] = 'boolean_search';
     $NON_CANONICAL_PARAMS[] = 'only_search_meta';
     $NON_CANONICAL_PARAMS[] = 'content';
     $NON_CANONICAL_PARAMS[] = 'author';
     $test = db_has_full_text($GLOBALS['SITE_DB']->connection_read);
     $old_mysql = !$test;
     $can_order_by_rating = db_has_subqueries($GLOBALS['SITE_DB']->connection_read);
     // Perform search, if we did one
     $out = NULL;
     $results_browser = '';
     $num_results = 0;
     if (!is_null($content)) {
         list($out, $results_browser, $num_results) = $this->results($id, $author, $author_id, $days, $sort, $direction, $only_titles, $search_under);
         if (has_zone_access(get_member(), 'adminzone')) {
             $admin_search_url = build_url(array('page' => 'admin', 'type' => 'search', 'search_content' => $content), 'adminzone');
             attach_message(do_lang_tempcode('ALSO_ADMIN_ZONE_SEARCH', escape_html($admin_search_url->evaluate())), 'inform');
         }
     }
     return do_template('SEARCH_FORM_SCREEN', array('_GUID' => '8bb208185740183323a6fe6e89d55de5', 'SEARCH_TERM' => is_null($content) ? '' : $content, 'NUM_RESULTS' => integer_format($num_results), 'CAN_ORDER_BY_RATING' => $can_order_by_rating, 'EXTRA_SORT_FIELDS' => $extra_sort_fields, 'USER_LABEL' => $user_label, 'DAYS_LABEL' => $days_label, 'BOOLEAN_SEARCH' => $this->_is_boolean_search(), 'AND' => $boolean_operator == 'AND', 'ONLY_TITLES' => $only_titles, 'DAYS' => is_null($days) ? '' : strval($days), 'SORT' => $sort, 'DIRECTION' => $direction, 'CONTENT' => $content, 'RESULTS' => $out, 'RESULTS_BROWSER' => $results_browser, 'OLD_MYSQL' => $old_mysql, 'TITLE' => $title, 'AUTHOR' => $author, 'SPECIALISATION' => $specialisation, 'URL' => $url));
 }