function format_messages($messages) { global $PHP_SELF; $out .= "<table class='messages'>"; if (count($messages) == 0 or !is_array($messages)) { $out .= '<tr><td>No posts on this page</td></tr>'; } else { foreach ($messages as $row) { extract($row); $shaded = !$shaded; $out .= '<tr class="' . ($shaded ? 'shaded' : 'unshaded') . '">'; $out .= "<td rowspan='2' valign='top' class='poster'>{$poster}<br />{$date}</td>"; $out .= "<td class='subject'>{$subject}</td>"; $out .= "</tr>"; $out .= '<tr class="' . ($shaded ? 'shaded' : 'unshaded') . '">'; $out .= "<td class='body'>" . wiki_render($body) . "</td>"; $out .= '</tr>'; } } $out .= '</table>'; if (authorized($USERNAME, 'postcomment')) { $out .= hyperlink("{$PHP_SELF}/Comment", 'Post Comment'); } return "<center>" . $out . "</center>"; }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev) { if (is_object($ev)) { $ev = $ev->evaluate(); } return hyperlink('http://isbndb.com/search-all.html?kw=' . $ev, $ev, true, true); }
/** * URL'ise specially encoded text-acceptance language strings. * * @param string The language string * @param mixed The URL (either tempcode or string) * @param string The title of the hyperlink * @param boolean Whether to use a new window * @return tempcode The encoded version */ function _urlise_lang($string, $url, $title, $new_window) { $a = strpos($string, '<{'); $b = strpos($string, '}>'); if ($a === false || $b === false || $b < $a) { return make_string_tempcode($string); } $section = substr($string, $a + 2, $b - $a - 2); $prior = substr($string, 0, $a); $after = substr($string, $b + 2); if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($section); ocp_mark_as_escaped($prior); ocp_mark_as_escaped($after); } if (is_string($url)) { if ($url == '') { return protect_from_escaping($section); } } else { if ($url->is_empty()) { return protect_from_escaping($section); } } $out = new ocp_tempcode(); $out->attach(protect_from_escaping($prior)); $out->attach(hyperlink($url, protect_from_escaping($section), $new_window, false, $title)); $out->attach(protect_from_escaping($after)); return $out; }
/** * A page is not validated, so show a warning. * * @param ID_TEXT The zone the page is being loaded from * @param ID_TEXT The codename of the page * @param tempcode The edit URL (blank if no edit access) * @return tempcode The warning */ function get_page_warning_details($zone, $codename, $edit_url) { $warning_details = new ocp_tempcode(); if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $uv_warning = do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'); // Wear sun cream if (!$edit_url->is_empty()) { $menu_links = $GLOBALS['SITE_DB']->query('SELECT DISTINCT i_menu FROM ' . get_table_prefix() . 'menu_items WHERE ' . db_string_equal_to('i_url', $zone . ':' . $codename) . ' OR ' . db_string_equal_to('i_url', '_SEARCH:' . $codename)); if (count($menu_links) != 0) { $menu_items_linking = new ocp_tempcode(); foreach ($menu_links as $menu_link) { if (!$menu_items_linking->is_empty()) { $menu_items_linking->attach(do_lang_tempcode('LIST_SEP')); } $menu_edit_url = build_url(array('page' => 'admin_menus', 'type' => 'edit', 'id' => $menu_link['i_menu']), get_module_zone('admin_menus')); $menu_items_linking->attach(hyperlink($menu_edit_url, $menu_link['i_menu'], false, true)); } $uv_warning = do_lang_tempcode('UNVALIDATED_TEXT_STAFF', $menu_items_linking); } } $warning_details->attach(do_template('WARNING_TABLE', array('WARNING' => $uv_warning))); return $warning_details; }
/** * Standard modular render function for profile tab hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return array A triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('MODULE_TRANS_NAME_warnings'); $order = 80; if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } require_lang('ocf'); require_css('ocf'); $warnings = new ocp_tempcode(); $rows = $GLOBALS['FORUM_DB']->query_select('f_warnings', array('*'), array('w_member_id' => $member_id_of, 'w_is_warning' => 1)); foreach ($rows as $row) { $warning_by = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['w_by']); $date = get_timezoned_date($row['w_time']); if ($row['w_explanation'] == '') { $row['w_explanation'] = '?'; } else { $row['w_explanation'] = str_replace(chr(10), ' ', $row['w_explanation']); } $row['w_explanation_orig'] = $row['w_explanation']; if (strlen($row['w_explanation']) > 30) { $row['w_explanation'] = substr($row['w_explanation'], 0, 27) . '...'; } $explanation = hyperlink(build_url(array('page' => 'warnings', 'type' => '_ed', 'id' => $row['id'], 'redirect' => get_self_url(true)), get_module_zone('warnings')), $row['w_explanation'], false, true, $row['w_explanation_orig']); $warnings->attach(paragraph(do_lang_tempcode('MEMBER_WARNING', $explanation, $warning_by, array(make_string_tempcode(escape_html($date)))), 'treyerhy34y')); } $content = do_template('OCF_MEMBER_PROFILE_WARNINGS', array('MEMBER_ID' => strval($member_id_of), 'WARNINGS' => $warnings)); return array($title, $content, $order); }
function initializeMembers($tnum) { //var_dump($tnum['tweetID']); echo "<br>"; //var_dump($tnum['userID']); echo "<br>"; $this->tweetID = (string) $tnum['tweetID']; $this->userID = (string) $tnum['userID']; $this->tweetTokens = (string) $tnum['tweetTokens']; $this->longitude = (string) $tnum['longitude']; $this->latitude = (string) $tnum['latitude']; $this->text = (string) $tnum['text']; $this->date = (string) $tnum['date']; $this->text = hyperlink($this->text); $this->datatype = (string) $tnum['datatype']; $this->screenname = (string) $tnum['screenname']; $this->sentiment = (string) $tnum['sentiment']; }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev) { if (is_object($ev)) { return $ev; } if ($ev == '') { return ''; } $_ev = explode(' ', $ev, 2); if (!array_key_exists(1, $_ev)) { $_ev[1] = $_ev[0]; } list($zone, $attributes, ) = page_link_decode($_ev[0]); $url = build_url($attributes, $zone); return hyperlink($url, escape_html($_ev[1])); }
/** * Try and make an action log entry into a proper link. * * @param ID_TEXT Action type * @param string First parameter * @param string Second parameter * @param tempcode First parameter (cropped) * @param tempcode Second parameter (cropped) * @return ?array Pair: first parameter as possible link, second parameter as possible link (NULL: could not construct a nice link) */ function actionlog_linkage($type, $a, $b, $_a, $_b) { $type_str = do_lang($type, $a, $b, NULL, NULL, false); if (is_null($type_str)) { $type_str = $type; } // TODO: This will be replaced later with a more thorough system if ($type == 'EDIT_TEMPLATES' && strpos($a, ',') === false) { if ($b == '') { $b = 'default'; } $tmp_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $b, 'f0file' => $a), get_module_zone('admin_themes')); $a = basename($a, '.tpl'); $_a = tpl_crop_text_mouse_over($a, 14); $_a = hyperlink($tmp_url, $_a, false, false, $type_str); return array($_a, $_b); } if ($type == 'EDIT_CSS') { if ($b == '') { $b = 'global.css'; } $tmp_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $a, 'file' => $b), get_module_zone('admin_themes')); $b = basename($b, '.css'); $_b = hyperlink($tmp_url, $_b, false, false, $type_str); return array($_a, $_b); } if ($type == 'COMCODE_PAGE_EDIT') { $tmp_url = build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $b . ':' . $a), get_module_zone('cms_comcode_pages')); $_a = hyperlink($tmp_url, $_a, false, false, $type_str); return array($_a, $_b); } if ($type == 'ADD_CATALOGUE_ENTRY' || $type == 'EDIT_CATALOGUE_ENTRY') { $tmp_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $a), get_module_zone('catalogues')); $_b = hyperlink($tmp_url, $b == '' ? $_a : $_b, false, false, $type_str); return array($_a, $_b); } if (($type == 'ADD_CATALOGUE_CATEGORY' || $type == 'EDIT_CATALOGUE_CATEGORY') && $b != '') { $tmp_url = build_url(array('page' => 'catalogues', 'type' => 'misc', 'id' => !is_numeric($a) ? $b : $a), get_module_zone('catalogues')); $_b = hyperlink($tmp_url, $_b, false, false, $type_str); return array($_a, $_b); } return NULL; // Could not get a match }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $cat = post_param('cat'); $urls = get_url('url', 'file', 'uploads/galleries' . (get_value('use_gallery_subdirs') == '1' ? '/' . $cat : ''), 0, OCP_UPLOAD_IMAGE, true, '', 'file2'); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = $urls['url']; $thumb_url = $urls['thumb_url']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; $thumb_url = $urls[1]; } require_code('images'); $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, post_param('comments'), true); $preview = hyperlink(url_is_local($url) ? get_custom_base_url() . '/' . $url : $url, $thumb); return array($preview, NULL); }
function render_table($objects, $link_url, $id_col, $link_col, $table_header = '', $show_headers = true, $skip_col_names = array()) { if (empty($objects)) { return ''; } $html = '<table border="1">'; $display_col_names = array_diff_key($objects[0], $skip_col_names); unset($display_col_names[$id_col]); $display_col_names = array_keys($display_col_names); if (!empty($table_header)) { $html .= '<tr><th colspan="' . sizeof($display_col_names) . '">' . $table_header . '</th></tr>'; } if ($show_headers) { $html .= '<tr>'; foreach ($display_col_names as $col) { $html .= "<td><strong>{$col}</strong></td>"; } $html .= '</tr>'; } foreach ($objects as $o) { $html .= '<tr>'; $id = $o[$id_col]; foreach ($display_col_names as $col) { $html .= '<td>'; if ($id && $link_url && $col === $link_col) { $html .= hyperlink($link_url, $id, $o[$col]); } else { $html .= $o[$col]; } $html .= '</td>'; } $html .= '</tr>'; } $html .= '</table>'; return $html; }
/** * Standard aed_module table function. * * @param array Details to go to build_url for link to the next screen. * @return array A pair: The choose table, Whether re-ordering is supported from this screen. */ function nice_get_choose_table($url_map) { require_code('templates_results_table'); $current_ordering = get_param('sort', 'cf_order ASC'); if (strpos($current_ordering, ' ') === false) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } list($sortable, $sort_order) = explode(' ', $current_ordering, 2); $sortables = array('cf_name' => do_lang_tempcode('NAME'), 'cf_owner_view' => do_lang_tempcode('OWNER_VIEW'), 'cf_owner_set' => do_lang_tempcode('OWNER_SET'), 'cf_public_view' => do_lang_tempcode('PUBLIC_VIEW'), 'cf_required' => do_lang_tempcode('REQUIRED'), 'cf_order' => do_lang_tempcode('ORDER')); 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'; $fh = array(do_lang_tempcode('NAME'), do_lang_tempcode('OWNER_VIEW'), do_lang_tempcode('OWNER_SET'), do_lang_tempcode('PUBLIC_VIEW'), do_lang_tempcode('REQUIRED')); $fh[] = do_lang_tempcode('SHOW_ON_JOIN_FORM'); //$fh[]=do_lang_tempcode('SHOW_IN_POSTS'); //$fh[]=do_lang_tempcode('SHOW_IN_POST_PREVIEWS'); $fh[] = do_lang_tempcode('ORDER'); $fh[] = do_lang_tempcode('ACTIONS'); $header_row = results_field_title($fh, $sortables, 'sort', $sortable . ' ' . $sort_order); // Load up filters $hooks = find_all_hooks('systems', 'ocf_cpf_filter'); $to_keep = array(); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/ocf_cpf_filter/' . $hook); $_hook = object_factory('Hook_ocf_cpf_filter_' . $hook, true); if (is_null($_hook)) { continue; } $to_keep += $_hook->to_enable(); } $fields = new ocp_tempcode(); list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering, NULL); $changed = false; foreach ($rows as $row) { $order = post_param_integer('order_' . strval($row['id']), NULL); if (!is_null($order)) { $GLOBALS['FORUM_DB']->query_update('f_custom_fields', array('cf_order' => $order), array('id' => $row['id']), '', 1); $changed = true; } } if ($changed) { list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering); } require_code('form_templates'); foreach ($rows as $row) { $trans = get_translated_text($row['cf_name'], $GLOBALS['FORUM_DB']); $used = true; if (substr($trans, 0, 4) == 'ocp_') { // See if it gets filtered if (!array_key_exists(substr($trans, 4), $to_keep)) { $used = false; } $test = do_lang('SPECIAL_CPF__' . $trans, NULL, NULL, NULL, NULL, false); if (!is_null($test)) { $trans = $test; } } $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF'); $orderlist = new ocp_tempcode(); $num_cpfs = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'COUNT(*)'); $selected_one = false; $order = $row['cf_order']; for ($i = 0; $i < max($num_cpfs, $order); $i++) { $selected = $i === $order; if ($selected) { $selected_one = true; } $orderlist->attach(form_input_list_entry(strval($i), $selected, integer_format($i + 1))); } if (!$selected_one) { $orderlist->attach(form_input_list_entry(strval($order), true, integer_format($order + 1))); } $orderer = do_template('TABLE_TABLE_ROW_CELL_SELECT', array('LABEL' => do_lang_tempcode('ORDER'), 'NAME' => 'order_' . strval($row['id']), 'LIST' => $orderlist)); $fr = array(); $fr[] = $trans; $fr[] = $row['cf_owner_view'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $fr[] = $row['cf_owner_set'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $fr[] = $row['cf_public_view'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $fr[] = $row['cf_required'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $fr[] = $row['cf_show_on_join_form'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); //$fr[]=($row['cf_show_in_posts']==1)?do_lang_tempcode('YES'):do_lang_tempcode('NO'); //$fr[]=($row['cf_show_in_post_previews']==1)?do_lang_tempcode('YES'):do_lang_tempcode('NO'); $fr[] = protect_from_escaping($orderer); if ($used) { $edit_link = hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])); } else { $edit_link = do_lang_tempcode('UNUSED_CPF'); } $fr[] = protect_from_escaping($edit_link); $fields->attach(results_entry($fr, true)); } return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, NULL, 8, 'gdfg43tfdgdfgdrfgd', true), true); }
/** * View survey results. * * @return tempcode The result of execution. */ function _survey_results() { $title = get_page_title('SURVEY_RESULTS'); breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('MANAGE_QUIZZES')))); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/survey_results'; $id = get_param_integer('id'); // quiz ID $fields = new ocp_tempcode(); require_code('templates_results_table'); require_code('templates_view_space'); // Show summary $question_rows = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id), 'ORDER BY id'); foreach ($question_rows as $q) { $question = get_translated_text($q['q_question_text']); $answers = new ocp_tempcode(); $answer_rows = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $q['id']), 'ORDER BY id'); $all_answers = array(); foreach ($answer_rows as $i => $a) { $answer = get_translated_text($a['q_answer_text']); $count = $GLOBALS['SITE_DB']->query_value('quiz_entry_answer', 'COUNT(*)', array('q_answer' => strval($a['id']))); $all_answers[serialize(array($answer, $i))] = $count; } arsort($all_answers); foreach ($all_answers as $bits => $count) { list($answer, $i) = unserialize($bits); $answers->attach(paragraph(do_lang_tempcode('SURVEY_ANSWER_RESULT', escape_html($answer), integer_format($count), integer_format($i + 1)))); } if ($answers->is_empty()) { $answers = do_lang_tempcode('FREE_ENTRY_ANSWER'); } $fields->attach(view_space_field($question, $answers, true)); } $summary = do_template('VIEW_SPACE', array('_GUID' => '2b0c2ba0070ba810c5e4b5b4aedcb15f', 'WIDTH' => '300', 'FIELDS' => $fields)); // Show results table $start = get_param_integer('start', 0); $max = get_param_integer('max', 50); $sortables = array('q_time' => do_lang_tempcode('DATE')); $test = explode(' ', get_param('sort', 'q_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'; $max_rows = $GLOBALS['SITE_DB']->query_value('quiz_entries', 'COUNT(*)', array('q_quiz' => $id)); $rows = $GLOBALS['SITE_DB']->query_select('quiz_entries', array('id', 'q_time', 'q_member'), array('q_quiz' => $id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start); if (count($rows) == 0) { return inform_screen($title, do_lang_tempcode('NO_ENTRIES')); } $fields = new ocp_tempcode(); $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('USERNAME')), $sortables, 'sort', $sortable . ' ' . $sort_order); foreach ($rows as $myrow) { $date_link = hyperlink(build_url(array('page' => '_SELF', 'type' => '__survey_results', 'id' => $myrow['id']), '_SELF'), escape_html(get_timezoned_date($myrow['q_time']))); $member_link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['q_member']); $fields->attach(results_entry(array($date_link, $member_link), false)); } if ($fields->is_empty()) { warn_exit(do_lang_tempcode('NO_ENTRIES')); } $results = results_table(do_lang_tempcode('SURVEY_RESULTS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort'); return do_template('SURVEY_RESULTS_SCREEN', array('_GUID' => '3f38ac1b94fb4de8219b8f7108c7b0a3', 'TITLE' => $title, 'SUMMARY' => $summary, 'RESULTS' => $results)); }
/** * Get tempcode for a Comcode rich-media attachment. * * @param ID_TEXT The attachment tag * @set attachment attachment_safe attachment2 * @param array A map of the attributes (name=>val) for the tag * @param array A map of the attachment properties (name=>val) for the attachment * @param string A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post) * @param MEMBER The member who is responsible for this Comcode * @param boolean Whether to check as arbitrary admin * @param object The database connection to use * @param ?array A list of words to highlight (NULL: none) * @param ?MEMBER The member we are running on behalf of, with respect to how attachments are handled; we may use this members attachments that are already within this post, and our new attachments will be handed to this member (NULL: member evaluating) * @param boolean Whether to parse so as to create something that would fit inside a semihtml tag. It means we generate HTML, with Comcode written into it where the tag could never be reverse-converted (e.g. a block). * @return tempcode The tempcode for the attachment */ function render_attachment($tag, $attributes, $attachment, $pass_id, $source_member, $as_admin, $connection, $highlight_bits = NULL, $on_behalf_of_member = NULL, $semiparse_mode = false) { require_code('comcode_renderer'); $extension = get_file_extension($attachment['a_original_filename']); require_code('mime_types'); $mime_type = get_mime_type($extension); $attachment['CLEAN_SIZE'] = clean_file_size($attachment['a_file_size']); $attachment['MIME_TYPE'] = $mime_type; $attachment['PASS_ID'] = intval($pass_id) < 0 ? strval(mt_rand(0, 10000)) : $pass_id; $attachment['SCRIPT'] = find_script('attachment'); $attachment['RAND'] = strval(mt_rand(0, 32000)); if ($connection->connection_write != $GLOBALS['SITE_DB']->connection_write) { $attachment['SUP_PARAMS'] = '&forum_db=1'; $attachment['FORUM_DB_BIN'] = '1'; } else { $attachment['SUP_PARAMS'] = ''; $attachment['FORUM_DB_BIN'] = ''; } $type = trim(array_key_exists('type', $attributes) ? $attributes['type'] : 'auto'); $attachment['id'] = strval($attachment['id']); $attachment['a_member_id'] = strval($attachment['a_member_id']); $attachment['a_file_size'] = strval($attachment['a_file_size']); $attachment['a_last_downloaded_time'] = is_null($attachment['a_last_downloaded_time']) ? '' : strval($attachment['a_last_downloaded_time']); $attachment['a_add_time'] = strval($attachment['a_add_time']); $attachment['a_num_downloads'] = integer_format($attachment['a_num_downloads']); require_code('images'); $attachment['a_width'] = array_key_exists('width', $attributes) ? strval(intval($attributes['width'])) : ''; $attachment['a_height'] = array_key_exists('height', $attributes) ? strval(intval($attributes['height'])) : ''; if ($attachment['a_width'] == '' || $attachment['a_height'] == '') { if (addon_installed('galleries') && is_video($attachment['a_original_filename']) && url_is_local($attachment['a_url'])) { require_code('galleries2'); $vid_details = get_video_details(get_custom_file_base() . '/' . rawurldecode($attachment['a_url']), $attachment['a_original_filename'], true); if ($vid_details !== false) { list($_width, $_height, ) = $vid_details; if ($attachment['a_width'] == '') { $attachment['a_width'] = strval($_width); } if ($attachment['a_height'] == '') { $attachment['a_height'] = strval($_height); } } } if ($attachment['a_width'] == '' || $attachment['a_height'] == '') { if ($attachment['a_width'] == '') { $attachment['a_width'] = '240'; } if ($attachment['a_height'] == '') { $attachment['a_height'] = '216'; } } } $attachment['a_align'] = array_key_exists('align', $attributes) ? $attributes['align'] : 'left'; if (!array_key_exists('a_description', $attachment)) { if (array_key_exists('description', $attributes)) { $attachment['description'] = $attributes['description']; } if (!array_key_exists('description', $attachment)) { $attachment['description'] = ''; } $attachment['a_description'] = is_object($attachment['description']) ? $attachment['description'] : comcode_to_tempcode($attachment['description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member); } else { $attachment['a_description'] = comcode_to_tempcode($attachment['a_description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member); } $attachment['a_type'] = $type; $attachment['a_thumb'] = array_key_exists('thumb', $attributes) ? $attributes['thumb'] : '1'; if ($attachment['a_thumb'] != '0') { $attachment['a_thumb'] = '1'; } $attachment['a_thumb_url'] = array_key_exists('thumb_url', $attributes) ? $attributes['thumb_url'] : $attachment['a_thumb_url']; switch ($type) { case 'email': require_code('mail'); global $EMAIL_ATTACHMENTS; if (url_is_local($attachment['a_url'])) { $attachment['a_url'] = get_custom_base_url() . '/' . $attachment['a_url']; } $EMAIL_ATTACHMENTS[$attachment['a_url']] = $attachment['a_original_filename']; $temp_tpl = new ocp_tempcode(); break; case 'code': $url = $attachment['a_url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $file_contents = http_download_file($url, 1024 * 1024 * 20); list($_embed, $title) = do_code_box($extension, make_string_tempcode($file_contents)); if ($attachment['a_original_filename'] != '') { $title = escape_html($attachment['a_original_filename']); } $temp_tpl = do_template('COMCODE_CODE', array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'STYLE' => '', 'TYPE' => $extension, 'CONTENT' => $_embed, 'TITLE' => $title)); break; case 'hyperlink': if ($tag == 'attachment') { $keep = symbol_tempcode('KEEP'); $_url = new ocp_tempcode(); $_url->attach(find_script('attachment') . '?id=' . urlencode($attachment['id']) . $keep->evaluate()); if (get_option('anti_leech') == '1') { $_url->attach('&for_session='); $_url->attach(symbol_tempcode('SESSION_HASHED')); } } else { $url = $attachment['a_url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $_url = make_string_tempcode($url); } $temp_tpl = hyperlink($_url, is_object($attachment['a_description']) ? $attachment['a_description']->evaluate() : $attachment['a_description'] != '' ? $attachment['a_description'] : $attachment['a_original_filename'], true); break; default: if (is_image($attachment['a_original_filename'])) { if ($type == 'inline' || $type == 'left_inline' || $type == 'right_inline') { $attachment['mini'] = '1'; } require_code('images'); ensure_thumbnail($attachment['a_url'], $attachment['a_thumb_url'], 'attachments', 'attachments', intval($attachment['id']), 'a_thumb_url'); $temp_tpl = do_template('ATTACHMENT_IMG' . (array_key_exists('mini', $attachment) && $attachment['mini'] == '1' ? '_MINI' : ''), map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); if ($type == 'left' || $type == 'left_inline') { $temp_tpl = do_template('ATTACHMENT_LEFT', array('_GUID' => 'aee2a6842d369c8dae212c3478a3a3e9', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl)); } if ($type == 'right' || $type == 'right_inline') { $temp_tpl = do_template('ATTACHMENT_RIGHT', array('_GUID' => '1a7209d67d91db740c86e7a331720195', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl)); } break; } elseif ($extension == 'swf') { $temp_tpl = do_template('ATTACHMENT_SWF', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif (addon_installed('jwplayer') && ($mime_type == 'video/x-flv' || $mime_type == 'video/mp4' || $mime_type == 'video/webm')) { $temp_tpl = do_template('ATTACHMENT_FLV', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif ($mime_type == 'video/quicktime') { $temp_tpl = do_template('ATTACHMENT_QT', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif ($mime_type == 'audio/x-pn-realaudio') { $temp_tpl = do_template('ATTACHMENT_RM', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif (substr($mime_type, 0, 5) == 'video' || substr($mime_type, 0, 5) == 'audio') { $temp_tpl = do_template('ATTACHMENT_MEDIA', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } // Continues on, as it's not a media type... // Continues on, as it's not a media type... case 'download': if (is_null($attachment['a_file_size'])) { $temp_tpl = do_template('ATTACHMENT_DOWNLOAD_REMOTE', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); } else { $temp_tpl = do_template('ATTACHMENT_DOWNLOAD', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); } break; } return $temp_tpl; }
/** * Convert a CEDI chain to a nice formatted XHTML tree. * * @param string The chain to convert (which should include the current page ID) * @param ?string The title of the current CEDI page (if not given, it is looked up) (NULL: work it out) * @param boolean Whether to show the final tree element with a link to it (all others will always have links if $links is true) * @param boolean Whether to show links to pages in the tree * @param boolean Whether to make the link as a virtual-root link (only applies if $final_link is true) * @return tempcode Tempcode of the breadcrumb XHTML */ function cedi_breadcrumbs($chain, $current_title = NULL, $final_link = false, $links = true, $this_link_virtual_root = false) { $instree = new ocp_tempcode(); $token = strtok($chain, '/'); $rebuild_chain = ''; while ($token !== false) { $next_token = strtok('/'); if ($rebuild_chain != '') { $rebuild_chain .= '/'; } $rebuild_chain .= $token; $id = $this_link_virtual_root && $next_token === false ? $token : $rebuild_chain; $url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $id == strval(db_get_first_id()) ? NULL : $id) + ($this_link_virtual_root && $next_token === false ? array('keep_cedi_root' => $id) : array()), get_module_zone('cedi')); if ($next_token !== false) { $title = $GLOBALS['SITE_DB']->query_value_null_ok('seedy_pages', 'title', array('id' => intval($token))); if (is_null($title)) { continue; } $token_title = get_translated_text($title); $content = $links ? hyperlink($url, escape_html($token_title), false, false, do_lang_tempcode('GO_BACKWARDS_TO', $token_title), NULL, NULL, 'up') : make_string_tempcode(escape_html($token_title)); if ($instree->is_empty()) { $instree->attach($content); } else { $instree->attach(do_template('BREADCRUMB_ESCAPED')); $instree->attach($content); } } else { if (!$instree->is_empty()) { $instree->attach(do_template('BREADCRUMB_ESCAPED')); } if (is_null($current_title)) { $_current_title = $GLOBALS['SITE_DB']->query_value_null_ok('seedy_pages', 'title', array('id' => intval($token))); $current_title = is_null($_current_title) ? do_lang('MISSING_RESOURCE') : get_translated_text($_current_title); } if ($final_link) { $instree->attach(hyperlink($url, escape_html($current_title), false, false, $this_link_virtual_root ? do_lang_tempcode('VIRTUAL_ROOT') : do_lang_tempcode('GO_BACKWARDS_TO', $current_title), NULL, NULL, 'up')); } else { $instree->attach($current_title); } } $token = $next_token; } return $instree; }
/** * Standard aed_module table function. * * @param array Details to go to build_url for link to the next screen. * @return array A pair: The choose table, Whether re-ordering is supported from this screen. */ function nice_get_choose_table($url_map) { require_code('templates_results_table'); $current_ordering = get_param('sort', 'title ASC', true); list($sortable, $sort_order) = array(substr($current_ordering, 0, strrpos($current_ordering, ' ')), substr($current_ordering, strrpos($current_ordering, ' ') + 1)); $sortables = array('title' => do_lang_tempcode('TITLE')); if (db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) { $sortables['(SELECT COUNT(*) FROM ' . get_table_prefix() . 'newsletter n JOIN ' . get_table_prefix() . 'newsletter_subscribe s ON n.id=s.newsletter_id WHERE code_confirm=0)'] = do_lang_tempcode('COUNT_MEMBERS'); } 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'; $header_row = results_field_title(array(do_lang_tempcode('TITLE'), do_lang_tempcode('COUNT_MEMBERS'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); require_code('form_templates'); list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering); foreach ($rows as $row) { $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF'); $num_readers = $GLOBALS['SITE_DB']->query_value('newsletter n JOIN ' . get_table_prefix() . 'newsletter_subscribe s ON n.id=s.newsletter_id', 'COUNT(*)', array('code_confirm' => 0)); $fields->attach(results_entry(array(get_translated_text($row['title']), integer_format($num_readers), protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])))), true)); } return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false); }
/** * Makes a post in the specified forum, in the specified topic according to the given specifications. If the topic doesn't exist, it is created along with a spacer-post. * Spacer posts exist in order to allow staff to delete the first true post in a topic. Without spacers, this would not be possible with most forum systems. They also serve to provide meta information on the topic that cannot be encoded in the title (such as a link to the content being commented upon). * * @param SHORT_TEXT The forum name * @param SHORT_TEXT The topic identifier (usually <content-type>_<content-id>) * @param MEMBER The member ID * @param LONG_TEXT The post title * @param LONG_TEXT The post content in Comcode format * @param string The topic title; must be same as content title if this is for a comment topic * @param string This is put together with the topic identifier to make a more-human-readable topic title or topic description (hopefully the latter and a $content_title title, but only if the forum supports descriptions) * @param ?URLPATH URL to the content (NULL: do not make spacer post) * @param ?TIME The post time (NULL: use current time) * @param ?IP The post IP address (NULL: use current members IP address) * @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param ?BINARY Whether the topic is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param boolean Whether to skip post checks * @param SHORT_TEXT The name of the poster * @param ?AUTO_LINK ID of post being replied to (NULL: N/A) * @param boolean Whether the reply is only visible to staff * @return array Topic ID (may be NULL), and whether a hidden post has been made */ function make_post_forum_topic($forum_name, $topic_identifier, $member, $post_title, $post, $content_title, $topic_identifier_encapsulation_prefix, $content_url = NULL, $time = NULL, $ip = NULL, $validated = NULL, $topic_validated = 1, $skip_post_checks = false, $poster_name_if_guest = '', $parent_id = NULL, $staff_only = false) { if (is_null($time)) { $time = time(); } if (is_null($ip)) { $ip = get_ip_address(); } $forum_id = $this->forum_id_from_name($forum_name); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('MISSING_FORUM', escape_html($forum_name))); } $username = $this->get_username($member); $topic_id = $this->find_topic_id_for_topic_identifier($forum_name, $topic_identifier); $is_new = is_null($topic_id); if ($is_new) { $topic_id = $this->connection->query_insert('threads', array('topic' => $content_title . ', ' . $topic_identifier_encapsulation_prefix . ': #' . $topic_identifier, 'starttime' => $time, 'boardid' => $forum_id, 'closed' => 0, 'starter' => $username, 'starterid' => $member, 'lastposter' => $username, 'lastposttime' => $time, 'visible' => 1), true); $home_link = hyperlink($content_url, escape_html($content_title)); $this->connection->query_insert('posts', array('threadid' => $topic_id, 'username' => do_lang('SYSTEM', '', '', '', get_site_default_lang()), 'userid' => 0, 'posttopic' => '', 'posttime' => $time, 'message' => do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()), 'allowsmilies' => 1, 'ipaddress' => '127.0.0.1', 'visible' => 1)); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'boards SET threadcount=(threadcount+1), postcount=(postcount+1) WHERE boardid=' . strval((int) $forum_id), 1); } $GLOBALS['LAST_TOPIC_ID'] = $topic_id; $GLOBALS['LAST_TOPIC_IS_NEW'] = $is_new; if ($post == '') { return array($topic_id, false); } $this->connection->query_insert('posts', array('threadid' => $topic_id, 'username' => $username, 'userid' => $member, 'posttopic' => $post_title, 'posttime' => $time, 'message' => $post, 'allowsmilies' => 1, 'ipaddress' => $ip, 'visible' => 1)); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'boards SET lastthreadid=' . strval((int) $topic_id) . ', postcount=(postcount+1), lastposttime=' . strval($time) . ', lastposterid=' . strval((int) $member) . ', lastposter=\'' . db_escape_string($username) . '\' WHERE boardid=\'' . strval((int) $forum_id) . '\'', 1); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'threads SET replycount=(replycount+1), lastposttime=' . strval($time) . ', lastposterid=' . strval((int) $member) . ', lastposter=\'' . db_escape_string($username) . '\' WHERE threadid=' . strval((int) $topic_id), 1); return array($topic_id, false); }
/** * The UI to show a usergroup. * * @return tempcode The UI */ function usergroup() { $id = get_param_integer('id'); if ($id == db_get_first_id()) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } $map = has_specific_permission(get_member(), 'see_hidden_groups') ? array('id' => $id) : array('id' => $id, 'g_hidden' => 0); $groups = $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $map, '', 1); if (!array_key_exists(0, $groups)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $group = $groups[0]; $club = $group['g_is_private_club'] == 1; $name = get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']); $title = get_page_title($club ? 'CLUB' : 'USERGROUP', true, array(escape_html($name))); // Leadership if (!is_null($group['g_group_leader']) && !is_null($GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']))) { $leader_name = $GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']); if (is_null($leader_name)) { $leader_name = do_lang('UNKNOWN'); } $leader_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $group['g_group_leader']), get_module_zone('members')); $leader_link = hyperlink($leader_url, $leader_name, false, true); $leader = paragraph(do_lang_tempcode('GROUP_LED_BY', $leader_link), 'gfgdfggdf'); } else { $leader = new ocp_tempcode(); } // Promotion if (addon_installed('points') && !is_null($group['g_promotion_threshold']) && !is_null($group['g_promotion_target'])) { $promote_link = ocf_get_group_link($group['g_promotion_target']); $promotion_info = do_lang_tempcode('OCF_PROMOTION_INFO', integer_format($group['g_promotion_threshold']), $promote_link->evaluate()); } else { $promotion_info = new ocp_tempcode(); } // To add if (ocf_may_control_group($id, get_member())) { $add_url = build_url(array('page' => '_SELF', 'type' => 'add_to', 'id' => $id), '_SELF'); } else { $add_url = new ocp_tempcode(); } // To apply $my_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(get_member(), false, false); if (is_guest()) { $apply_url = new ocp_tempcode(); $apply_text = new ocp_tempcode(); } else { if (!in_array($id, $my_groups)) { $apply_url = build_url(array('page' => '_SELF', 'type' => 'apply', 'id' => $id), '_SELF'); $apply_text = do_lang_tempcode('APPLY_TO_GROUP'); } elseif (ocf_get_member_primary_group(get_member()) != $id) { $apply_url = build_url(array('page' => '_SELF', 'type' => 'resign', 'id' => $id), '_SELF'); $apply_text = do_lang_tempcode('RESIGN_FROM_GROUP'); } else { $apply_url = new ocp_tempcode(); $apply_text = new ocp_tempcode(); } } require_code('templates_results_table'); $sortables = array(); list($sortable, $sort_order) = explode(' ', get_param('p_sort', 'date_and_time DESC')); // Primary members $start = get_param_integer('p_start', 0); $max = get_param_integer('p_max', 50); $_primary_members = ocf_get_group_members_raw($id, true, true, false, false, $max, $start); if (count($_primary_members) > 0) { $max_rows = ocf_get_group_members_raw_count($id, true, true, false, false); $primary_members = new ocp_tempcode(); foreach ($_primary_members as $i => $primary_member) { $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($primary_member['gm_member_id'], false, true); $temp = do_template('OCF_VIEW_GROUP_MEMBER', array('_GUID' => 'b96b674ac713e9790ecb78c15af1baab', 'NAME' => $primary_member['m_username'], 'URL' => $url)); $primary_members->attach(results_entry(array($temp))); } $fields_title = results_field_title(array(do_lang_tempcode('PRIMARY_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order); $primary_members = results_table(do_lang_tempcode('PRIMARY_MEMBERS'), $start, 'p_start', $max, 'p_max', $max_rows, $fields_title, $primary_members, $sortables, $sortable, $sort_order, 'p_sort', NULL, NULL, NULL, 6); } else { $primary_members = new ocp_tempcode(); } $edit_url = new ocp_tempcode(); $s_start = get_param_integer('s_start', 0); $s_max = get_param_integer('s_max', 50); $_secondary_members = ocf_get_group_members_raw($id, false, true, true, ocf_may_control_group($id, get_member()), $s_max, $s_start); $secondary_members = new ocp_tempcode(); $prospective_members = new ocp_tempcode(); $s_max_rows = ocf_get_group_members_raw_count($id, false, false, true, ocf_may_control_group($id, get_member())); $d_max_rows = ocf_get_group_members_raw_count($id, false, true, true, ocf_may_control_group($id, get_member())); foreach ($_secondary_members as $secondary_member) { $m_username = $GLOBALS['FORUM_DRIVER']->get_member_row_field($secondary_member['gm_member_id'], 'm_username'); if (is_null($m_username)) { continue; } if ($secondary_member['gm_validated'] == 1) { $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($secondary_member['gm_member_id'], false, true); $remove_url = build_url(array('page' => '_SELF', 'type' => 'remove_from', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF'); $temp = do_template('OCF_VIEW_GROUP_MEMBER' . (ocf_may_control_group($id, get_member()) ? '_SECONDARY' : ''), array('REMOVE_URL' => $remove_url, 'NAME' => $m_username, 'URL' => $url)); $secondary_members->attach(results_entry(array($temp))); } elseif (!$add_url->is_empty()) { $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($secondary_member['gm_member_id'], false, true); $accept_url = build_url(array('page' => '_SELF', 'type' => 'accept', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF'); $decline_url = build_url(array('page' => '_SELF', 'type' => 'decline', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF'); $temp = do_template('OCF_VIEW_GROUP_MEMBER_PROSPECTIVE', array('_GUID' => '16e93cf50a14e3b6a3bdf31525fd5e7f', 'ACCEPT_URL' => $accept_url, 'DECLINE_URL' => $decline_url, 'NAME' => $m_username, 'URL' => $url)); $prospective_members->attach(results_entry(array($temp))); } } if (!$secondary_members->is_empty()) { $fields_title = results_field_title(array(do_lang_tempcode('SECONDARY_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order); $secondary_members = results_table(do_lang_tempcode('SECONDARY_MEMBERS'), $s_start, 's_start', $s_max, 's_max', $s_max_rows, $fields_title, $secondary_members, $sortables, $sortable, $sort_order, 's_sort', NULL, NULL, NULL, 6); } if (!$prospective_members->is_empty()) { $fields_title = results_field_title(array(do_lang_tempcode('PROSPECTIVE_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order); $prospective_members = results_table(do_lang_tempcode('PROSPECTIVE_MEMBERS'), $s_start, 's_start', $s_max, 's_max', $d_max_rows, $fields_title, $prospective_members, $sortables, $sortable, $sort_order, 'd_sort', NULL, NULL, NULL, 6); } elseif (has_actual_page_access(get_member(), 'cms_ocf_groups', get_module_zone('cms_ocf_groups'))) { $is_super_admin = $group['g_is_super_admin']; if (!has_specific_permission(get_member(), 'control_usergroups') || $is_super_admin == 1) { $leader_tmp = $group['g_group_leader']; if ($leader_tmp == get_member()) { $edit_url = build_url(array('page' => 'cms_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('cms_ocf_groups')); } } else { $edit_url = build_url(array('page' => 'cms_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('cms_ocf_groups')); } } breadcrumb_set_self(make_string_tempcode(escape_html($name))); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USERGROUPS')))); if (has_actual_page_access(get_member(), 'admin_ocf_groups', get_module_zone('admin_ocf_groups'))) { $edit_url = build_url(array('page' => 'admin_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('admin_ocf_groups')); } $club_forum = NULL; if ($group['g_is_private_club'] == 1) { $club_forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.f_description', 'f.id', array('text_original' => do_lang('FORUM_FOR_CLUB', $name))); } $group_name = get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']); $GLOBALS['META_DATA'] += array('created' => '', 'creator' => is_null($group['g_group_leader']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']), 'publisher' => '', 'modified' => '', 'type' => 'Usergroup', 'title' => $group_name, 'identifier' => '_SEARCH:groups:view:' . strval($id), 'description' => '', 'image' => find_theme_image('bigicons/usergroups')); require_javascript('javascript_ajax'); require_javascript('javascript_ajax_people_lists'); $forum_id = NULL; if ($club) { $forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $group_name, 'f_category_id' => intval(get_option('club_forum_parent_category')), 'f_parent_forum' => intval(get_option('club_forum_parent_forum')))); } return do_template('OCF_VIEW_GROUP_SCREEN', array('_GUID' => 'fc6cac5c73f92ab4410b492d58976dbe', 'GROUP_NAME' => $group_name, 'ID' => strval($id), 'FORUM' => is_null($forum_id) ? '' : strval($forum_id), 'CLUB' => $club, 'EDIT_URL' => $edit_url, 'TITLE' => $title, 'LEADER' => $leader, 'PROMOTION_INFO' => $promotion_info, 'ADD_URL' => $add_url, 'APPLY_URL' => $apply_url, 'APPLY_TEXT' => $apply_text, 'PRIMARY_MEMBERS' => $primary_members, 'SECONDARY_MEMBERS' => $secondary_members, 'PROSPECTIVE_MEMBERS' => $prospective_members)); }
/** * Makes a post in the specified forum, in the specified topic according to the given specifications. If the topic doesn't exist, it is created along with a spacer-post. * Spacer posts exist in order to allow staff to delete the first true post in a topic. Without spacers, this would not be possible with most forum systems. They also serve to provide meta information on the topic that cannot be encoded in the title (such as a link to the content being commented upon). * * @param SHORT_TEXT The forum name * @param SHORT_TEXT The topic identifier (usually <content-type>_<content-id>) * @param MEMBER The member ID * @param LONG_TEXT The post title * @param LONG_TEXT The post content in Comcode format * @param string The topic title; must be same as content title if this is for a comment topic * @param string This is put together with the topic identifier to make a more-human-readable topic title or topic description (hopefully the latter and a $content_title title, but only if the forum supports descriptions) * @param ?URLPATH URL to the content (NULL: do not make spacer post) * @param ?TIME The post time (NULL: use current time) * @param ?IP The post IP address (NULL: use current members IP address) * @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param ?BINARY Whether the topic is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param boolean Whether to skip post checks * @param SHORT_TEXT The name of the poster * @param ?AUTO_LINK ID of post being replied to (NULL: N/A) * @param boolean Whether the reply is only visible to staff * @return array Topic ID (may be NULL), and whether a hidden post has been made */ function make_post_forum_topic($forum_name, $topic_identifier, $member, $post_title, $_post, $content_title, $topic_identifier_encapsulation_prefix, $content_url = NULL, $time = NULL, $ip = NULL, $validated = NULL, $topic_validated = 1, $skip_post_checks = false, $poster_name_if_guest = '', $parent_id = NULL, $staff_only = false) { $__post = comcode_to_tempcode($_post); $post = $__post->evaluate(); if (is_null($time)) { $time = time(); } if (is_null($ip)) { $ip = get_ip_address(); } $forum_id = $this->forum_id_from_name($forum_name); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('MISSING_FORUM', escape_html($forum_name))); } $username = $this->get_username($member); $topic_id = $this->find_topic_id_for_topic_identifier($forum_name, $topic_identifier); $is_new = is_null($topic_id); if ($is_new) { $topic_id = $this->connection->query_insert('topics', array('title' => $this->ipb_escape($content_title . ', ' . $topic_identifier_encapsulation_prefix . ': #' . $topic_identifier), 'state' => 'open', 'posts' => 1, 'starter_id' => $member, 'start_date' => $time, 'icon_id' => 0, 'starter_name' => $username, 'poll_state' => 0, 'last_vote' => 0, 'forum_id' => $forum_id, 'approved' => 1, 'author_mode' => 1), true); $home_link = hyperlink($content_url, escape_html($content_title)); $this->connection->query_insert('posts', array('author_id' => 0, 'author_name' => do_lang('SYSTEM', '', '', '', get_site_default_lang()), 'ip_address' => '127.0.0.1', 'post_date' => $time, 'icon_id' => 0, 'post' => do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()), 'queued' => 0, 'topic_id' => $topic_id, 'forum_id' => $forum_id, 'attach_id' => '', 'attach_hits' => 0, 'attach_type' => '', 'attach_file' => '', 'post_title' => '', 'new_topic' => 1)); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'forums SET topics=(topics+1) WHERE id=' . strval((int) $forum_id), 1); } $GLOBALS['LAST_TOPIC_ID'] = $topic_id; $GLOBALS['LAST_TOPIC_IS_NEW'] = $is_new; if ($post == '') { return array($topic_id, false); } $this->connection->query_insert('posts', array('author_id' => $member, 'author_name' => $this->ipb_escape($username), 'ip_address' => $ip, 'post_date' => $time, 'icon_id' => 0, 'post' => $post, 'queued' => 0, 'topic_id' => $topic_id, 'forum_id' => $forum_id, 'attach_id' => '', 'attach_hits' => 0, 'attach_type' => '', 'attach_file' => '', 'post_title' => $this->ipb_escape($post_title), 'new_topic' => 0)); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'forums SET posts=(posts+1), last_post=' . strval($time) . ', last_poster_id=' . strval((int) $member) . ', last_poster_name=\'' . db_escape_string($this->ipb_escape($username)) . '\', last_id=' . strval((int) $topic_id) . ', last_title=\'' . db_escape_string($this->ipb_escape($post_title)) . '\' WHERE id=' . strval((int) $forum_id), 1); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'topics SET posts=(posts+1), last_post=' . strval($time) . ', last_poster_id=' . strval((int) $member) . ', last_poster_name=\'' . db_escape_string($this->ipb_escape($username)) . '\' WHERE tid=' . strval((int) $topic_id), 1); return array($topic_id, false); }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev) { if (is_object($ev)) { return $ev; } if ($ev == '') { return new ocp_tempcode(); } $type = preg_replace('#^choose\\_#', '', substr($field['cf_type'], 3)); // HACKHACK: imperfect content type naming schemes if ($type == 'forum_topic') { $type = 'topic'; } require_code('content'); list($title, , $info) = content_get_details($type, $ev); $page_link = str_replace('_WILD', $ev, $info['view_pagelink_pattern']); list($zone, $map) = page_link_decode($page_link); return hyperlink(build_url($map, $zone), $title, false, true); }
/** * Standard aed_module table function. * * @param array Details to go to build_url for link to the next screen. * @return array A quartet: The choose table, Whether re-ordering is supported from this screen, Search URL, Archive URL. */ function nice_get_choose_table($url_map) { require_code('templates_results_table'); $current_ordering = get_param('sort', 'c_title ASC', true); if (strpos($current_ordering, ' ') === false) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } list($sortable, $sort_order) = explode(' ', $current_ordering, 2); $sortables = array('c_title' => do_lang_tempcode('TITLE')); 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'; $header_row = results_field_title(array(do_lang_tempcode('TITLE'), do_lang_tempcode('EXPANDED_BY_DEFAULT'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); require_code('form_templates'); list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering); foreach ($rows as $row) { $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF'); $fields->attach(results_entry(array($row['c_title'], $row['c_expanded_by_default'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])))), true)); } $search_url = NULL; $archive_url = NULL; return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false, $search_url, $archive_url); }
/** * UI to show details of an order * * @return tempcode The interface. */ function order_details() { $id = get_param_integer('id'); $title = get_page_title('MY_ORDER_DETAILS'); $order_title = do_lang('CART_ORDER', $id); //pagination $start = get_param_integer('start', 0); $max = get_param_integer('max', 10); require_code('templates_results_browser'); require_code('templates_results_table'); $sortables = array(); $query_sort = explode(' ', get_param('sort', 'p_name ASC'), 2); if (count($query_sort) == 1) { $query_sort[] = 'ASC'; } list($sortable, $sort_order) = $query_sort; $fields_title = results_field_title(array(do_lang_tempcode('SLNO'), do_lang_tempcode('PRODUCT_NAME'), do_lang_tempcode('THE_PRICE'), do_lang_tempcode('QUANTITY'), do_lang_tempcode('STATUS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok('shopping_order_details', 'COUNT(*)', array('order_id' => $id)); $results_browser = results_browser(do_lang_tempcode('ORDERS'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'show_orders', true, true); $rows = $GLOBALS['SITE_DB']->query_select('shopping_order_details', array('*'), array('order_id' => $id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start); $product_entries = new ocp_tempcode(); breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('ORDERS')), array('_SELF:_SELF:show_orders', do_lang_tempcode('ORDER_LIST')))); foreach ($rows as $row) { $product_info_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $row['p_id']), get_module_zone('catalogues')); $product_name = $row['p_name']; $product = hyperlink($product_info_url, $product_name, false, true, do_lang('VIEW')); $product_entries->attach(results_entry(array(escape_html(strval($row['p_id'])), $product, ecommerce_get_currency_symbol() . escape_html(float_format($row['p_price'], 2)), escape_html(strval($row['p_quantity'])), do_lang($row['dispatch_status'])), false, NULL)); } $text = do_lang_tempcode('ORDER_DETAILS_TEXT'); //Collecting order details $rows = $GLOBALS['SITE_DB']->query_select('shopping_order', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $data = $rows[0]; $results_table = results_table(do_lang_tempcode('PRODUCTS'), 0, 'start', $max_rows, 'max', $max_rows, $fields_title, $product_entries, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, 'cart'); $ordered_by_member_id = $data['c_member']; $ordered_by_username = $GLOBALS['FORUM_DRIVER']->get_username($data['c_member']); $self_url = get_self_url(true, true); $ordr_act_submit = build_url(array('page' => '_SELF', 'type' => 'order_act', 'id' => $id, 'redirect' => $self_url), '_SELF'); $order_actions = do_template('ADMIN_ORDER_ACTIONS', array('ORDER_TITLE' => $order_title, 'ORDR_ACT_URL' => $ordr_act_submit, 'ORDER_STATUS' => do_lang($data['order_status']))); //Shipping address display $row = $GLOBALS['SITE_DB']->query_select('shopping_order_addresses', array('*'), array('order_id' => $id), '', 1); if (array_key_exists(0, $row)) { $address = $row[0]; $shipping_address = do_template('SHIPPING_ADDRESS', array('ADDRESS_NAME' => $address['address_name'], 'ADDRESS_STREET' => $address['address_street'], 'ADDRESS_CITY' => $address['address_city'], 'ADDRESS_ZIP' => $address['address_zip'], 'ADDRESS_COUNTRY' => $address['address_country'], 'RECEIVER_EMAIL' => $address['receiver_email'])); } else { $shipping_address = new ocp_tempcode(); } return do_template('ECOM_ADMIN_ORDERS_DETAILS_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'CURRENCY' => get_option('currency'), 'RESULT_TABLE' => $results_table, 'RESULTS_BROWSER' => $results_browser, 'ORDER_NUMBER' => strval($id), 'ADD_DATE' => get_timezoned_date($data['add_date'], true, false, true, true), 'TOTAL_PRICE' => float_format($data['tot_price'], 2), 'ORDERED_BY_MEMBER_ID' => strval($ordered_by_member_id), 'ORDERED_BY_USERNAME' => $ordered_by_username, 'ORDER_STATUS' => do_lang($data['order_status']), 'NOTES' => $data['notes'], 'PURCHASED_VIA' => $data['purchase_through'], 'ORDER_ACTIONS' => $order_actions, 'SHIPPING_ADDRESS' => $shipping_address)); }
/** * Update the spacer post of a comment topic, after an edit. * * @param boolean Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function) * @param ID_TEXT The type (download, etc) that this commenting is for * @param ID_TEXT The ID of the type that this commenting is for * @param mixed The URL to where the commenting will pass back to (to put into the comment topic header) (URLPATH or Tempcode) * @param ?string The title to where the commenting will pass back to (to put into the comment topic header) (NULL: don't know, but not first post so not important) * @param ?string The name of the forum to use (NULL: default comment forum) * @param ?AUTO_LINK ID of spacer post (NULL: unknown) */ function update_spacer_post($allow_comments, $content_type, $content_id, $content_url, $content_title, $forum = NULL, $post_id = NULL) { if (get_option('is_on_comments') == '0' || !$allow_comments) { return; } if (get_forum_type() != 'ocf') { return; } $home_link = is_null($content_title) ? new ocp_tempcode() : hyperlink($content_url, escape_html($content_title)); if (is_null($forum)) { $forum = get_option('comments_forum_name'); } if (!is_integer($forum)) { $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum); if (is_null($forum_id)) { return; } } else { $forum_id = (int) $forum; } $content_title = strip_comcode($content_title); if (is_null($post_id)) { $topic_id = $GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum_id, $content_type . '_' . $content_id); if (is_null($topic_id)) { return; } $post_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'MIN(id)', array('p_topic_id' => $topic_id)); if (is_null($post_id)) { return; } } else { $topic_id = $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_topic_id', array('id' => $post_id)); } $spacer_title = is_null($content_title) ? $content_type . '_' . $content_id : $content_title . ' (#' . $content_type . '_' . $content_id . ')'; $spacer_post = '[semihtml]' . do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()) . '[/semihtml]'; if (get_forum_type() == 'ocf') { require_code('ocf_posts_action3'); ocf_edit_post($post_id, 1, is_null($content_title) ? $spacer_title : $content_title, $spacer_post, 0, 0, NULL, false, false, '', false); require_code('ocf_topics_action2'); ocf_edit_topic($topic_id, do_lang('COMMENT') . ': #' . $content_type . '_' . $content_id, NULL, NULL, NULL, NULL, NULL, NULL, '', NULL, $home_link->evaluate(), false); } }
/** * Show my invoices. * * @return tempcode The interface. */ function my() { $title = get_page_title('MY_INVOICES'); $member_id = get_member(); if (has_specific_permission(get_member(), 'assume_any_member')) { $member_id = get_param_integer('id', $member_id); } $invoices = array(); $rows = $GLOBALS['SITE_DB']->query_select('invoices', array('*'), array('i_member_id' => $member_id)); foreach ($rows as $row) { $product = $row['i_type_code']; $object = find_product($product); if (is_null($object)) { continue; } $products = $object->get_products(false, $product); $invoice_title = $products[$product][4]; $time = get_timezoned_date($row['i_time'], true, false, false, true); $payable = $row['i_state'] == 'new'; $deliverable = $row['i_state'] == 'paid'; $state = do_lang('PAYMENT_STATE_' . $row['i_state']); if (perform_local_payment()) { $transaction_button = hyperlink(build_url(array('page' => '_SELF', 'type' => 'pay', 'id' => $row['id']), '_SELF'), do_lang_tempcode('MAKE_PAYMENT')); } else { $transaction_button = make_transaction_button(substr(get_class($object), 5), $invoice_title, strval($row['id']), floatval($row['i_amount']), get_option('currency')); } $invoices[] = array('TRANSACTION_BUTTON' => $transaction_button, 'INVOICE_TITLE' => $invoice_title, 'ID' => strval($row['id']), 'AMOUNT' => $row['i_amount'], 'TIME' => $time, 'STATE' => $state, 'DELIVERABLE' => $deliverable, 'PAYABLE' => $payable, 'NOTE' => $row['i_note'], 'TYPE_CODE' => $row['i_type_code']); } if (count($invoices) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } return do_template('ECOM_INVOICES_SCREEN', array('_GUID' => '144a893d93090c105eecc48fa58921a7', 'TITLE' => $title, 'CURRENCY' => get_option('currency'), 'INVOICES' => $invoices)); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } else { ocf_require_all_forum_stuff(); } require_code('ocf_topicview'); require_css('ocf'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $NON_CANONICAL_PARAMS[] = 'start'; $NON_CANONICAL_PARAMS[] = 'threaded'; $start = get_param_integer('start', 0); $default_max = intval(get_option('forum_posts_per_page')); $max = get_param_integer('max', $default_max); if ($max == 0) { $max = $default_max; } if ($max == 0) { $max = 1; } if ($max > 30 && !has_specific_permission(get_member(), 'remove_page_split')) { $max = $default_max; } $first_unread_id = -1; global $NON_CANONICAL_PARAMS; foreach (array_keys($_GET) as $key) { if (substr($key, 0, 3) == 'kfs') { $NON_CANONICAL_PARAMS[] = $key; } } $type = get_param('type', 'misc'); $id = get_param_integer('id', NULL); if (is_guest() && is_null($id)) { access_denied('NOT_AS_GUEST'); } if ($type == 'findpost') { $post_id = get_param_integer('id'); $redirect = find_post_id_url($post_id); require_code('site2'); assign_refresh($redirect, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '76e6d34c20a4f5284119827e41c7752f', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING'))); } else { if ($type == 'first_unread') { $redirect = find_first_unread_url($id); require_code('site2'); assign_refresh($redirect, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '12c5d16f60e8c4df03536d9a7a932528', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING'))); } } if (!is_null($id)) { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_topicview&filter=' . strval($id); } $view_poll_results = get_param_integer('view_poll_results', 0); // Mark as read if (!is_null($id)) { if (!is_guest()) { $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id), '', 1); $GLOBALS['FORUM_DB']->query_insert('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id, 'l_time' => time()), false, true); // race condition } $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics SET t_num_views=(t_num_views+1) WHERE id=' . strval((int) $id), 1, NULL, true); } // Load up topic info $topic_info = ocf_read_in_topic($id, $start, $max, $view_poll_results == 1); $GLOBALS['META_DATA'] += $topic_info['meta_data']; global $SEO_TITLE; $SEO_TITLE = do_lang('_VIEW_TOPIC', $topic_info['title']); // Render posts according to whether threaded or not $threaded = $topic_info['is_threaded'] == 1; $may_reply = array_key_exists('may_reply', $topic_info) && ($topic_info['is_open'] || array_key_exists('may_post_closed', $topic_info)); if (!$threaded) { $GLOBALS['META_DATA']['description'] = $topic_info['description']; // Poster detail hooks $hooks = find_all_hooks('modules', 'topicview'); $hook_objects = array(); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $hook_objects[$hook] = $object; } // Render non-threaded $posts = new ocp_tempcode(); $replied = false; if (is_null($topic_info['forum_id'])) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } $second_poster = $topic_info['first_poster']; foreach ($topic_info['posts'] as $array_id => $_postdetails) { if ($array_id == 0) { $description = $topic_info['description']; } else { $description = NULL; } if ($_postdetails['poster'] == get_member()) { $replied = true; } if ($array_id == 1 && $start == 0 || $array_id == 0 && $start != 0) { $second_poster = $_postdetails['poster']; } if (array_key_exists('last_edit_time', $_postdetails)) { $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('_GUID' => '77a28e8bc3cf2ec2211aafdb5ba192bf', 'LAST_EDIT_DATE_RAW' => is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']), 'LAST_EDIT_DATE' => $_postdetails['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $_postdetails['last_edit_by_username'])); } else { $last_edited = new ocp_tempcode(); } $last_edited_raw = array_key_exists('last_edit_time', $_postdetails) ? is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']) : '0'; $is_spacer_post = $_postdetails['is_spacer_post']; // Post buttons $buttons = new ocp_tempcode(); if (!$is_spacer_post) { $buttons = ocf_render_post_buttons($topic_info, $_postdetails, $may_reply); } // Avatar if (array_key_exists('poster_avatar', $_postdetails) && $_postdetails['poster_avatar'] != '') { $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => 'd647ada9c11d56eedc0ff7894d33e83c', 'AVATAR' => $_postdetails['poster_avatar'])); } else { $post_avatar = new ocp_tempcode(); } // Rank images $rank_images = new ocp_tempcode(); if (!$is_spacer_post) { $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($_postdetails['poster'], true); foreach ($posters_groups as $group) { $rank_image = ocf_get_group_property($group, 'rank_image'); $group_leader = ocf_get_group_property($group, 'group_leader'); $group_name = ocf_get_group_name($group); $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only'); if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_primary_group'))) { $rank_images->attach(do_template('OCF_RANK_IMAGE', array('_GUID' => '0ff7855482b901be95591964d4212c44', 'GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($_postdetails['poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $_postdetails['poster']))); } } } // Poster details if (!$is_spacer_post) { if (!is_guest($_postdetails['poster'])) { require_code('ocf_members2'); $poster_details = ocf_show_member_box($_postdetails, false, $hooks, $hook_objects, false); } else { $custom_fields = new ocp_tempcode(); if (array_key_exists('ip_address', $_postdetails)) { $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => 'd85be094dff0d039a64120d6f8f381bb', 'NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $_postdetails['ip_address']))); $poster_details = do_template('OCF_GUEST_DETAILS', array('_GUID' => 'e43534acaf598008602e8da8f9725f38', 'CUSTOM_FIELDS' => $custom_fields)); } else { $poster_details = new ocp_tempcode(); } } } else { $poster_details = new ocp_tempcode(); } if (!is_guest($_postdetails['poster'])) { $poster = do_template('OCF_POSTER_MEMBER', array('_GUID' => 'dbbed1850b6c01a6c9601d85c6aee43f', 'ONLINE' => member_is_online($_postdetails['poster']), 'ID' => strval($_postdetails['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['poster'], false, true), 'POSTER_USERNAME' => $_postdetails['poster_username'], 'HIGHLIGHT_NAME' => array_key_exists('poster_highlighted_name', $_postdetails) ? strval($_postdetails['poster_highlighted_name']) : NULL)); } else { $ip_link = array_key_exists('ip_address', $_postdetails) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $_postdetails['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode(); $poster = do_template('OCF_POSTER_GUEST', array('_GUID' => '36a8e550222cdac5165ef8f722be3def', 'IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $_postdetails['poster_username'])); } // Signature $signature = new ocp_tempcode(); if (array_key_exists('signature', $_postdetails) && !$_postdetails['signature']->is_empty()) { $signature = $_postdetails['signature']; } $post_title = $_postdetails['title']; $first_unread = $_postdetails['id'] == $first_unread_id || $first_unread_id < 0 && $array_id == count($topic_info['posts']) - 1 ? do_template('OCF_TOPIC_FIRST_UNREAD') : new ocp_tempcode(); $unvalidated = $_postdetails['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode(); $post_url = $GLOBALS['FORUM_DRIVER']->post_url($_postdetails['id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true); if (array_key_exists('intended_solely_for', $_postdetails) && $_postdetails['intended_solely_for'] == get_member()) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } $emphasis = ocf_get_post_emphasis($_postdetails); require_code('feedback'); if (!array_key_exists('intended_solely_for', $_postdetails)) { actualise_rating(true, 'post', strval($_postdetails['id']), get_self_url(), $_postdetails['title']); $rating = display_rating(get_self_url(), $_postdetails['title'], 'post', strval($_postdetails['id']), 'RATING_INLINE_DYNAMIC', $_postdetails['poster']); } else { $rating = new ocp_tempcode(); } $rendered_post = do_template('OCF_TOPIC_POST', array('_GUID' => 'sacd09wekfofpw2f', 'ID' => $is_spacer_post ? '' : strval($_postdetails['id']), 'TOPIC_FIRST_POST_ID' => is_null($topic_info['first_post_id']) ? '' : strval($topic_info['first_post_id']), 'TOPIC_FIRST_POSTER' => is_null($topic_info['first_poster']) ? '' : strval($topic_info['first_poster']), 'POST_ID' => $is_spacer_post ? '' : (get_value('seq_post_ids') === '1' ? strval($start + $array_id + 1) : strval($_postdetails['id'])), 'URL' => $post_url, 'CLASS' => $_postdetails['is_emphasised'] ? 'ocf_post_emphasis' : (array_key_exists('intended_solely_for', $_postdetails) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => $first_unread, 'POSTER_TITLE' => $is_spacer_post ? '' : $_postdetails['poster_title'], 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($_postdetails['time']), 'POST_DATE' => $_postdetails['time_string'], 'POST' => $_postdetails['post'], 'TOPIC_ID' => is_null($id) ? '' : strval($id), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($_postdetails['poster']), 'POSTER' => $is_spacer_post ? '' : $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => $buttons, 'SIGNATURE' => $signature, 'UNVALIDATED' => $unvalidated, 'DESCRIPTION' => $description, 'RATING' => $rating)); $posts->attach($rendered_post); } $serialized_options = mixed(); $hash = mixed(); } else { require_code('topics'); $threaded_topic_ob = new OCP_Topic(); // Load some settings into the renderer $threaded_topic_ob->first_post_id = $topic_info['first_post_id']; $threaded_topic_ob->topic_description = $topic_info['description']; $threaded_topic_ob->topic_description_link = $topic_info['description_link']; $threaded_topic_ob->topic_title = $topic_info['title']; $threaded_topic_ob->topic_info = $topic_info; // Other settings we need $max_thread_depth = intval(get_option('max_thread_depth')); $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread'))); // Load posts $threaded_topic_ob->load_from_topic($id, $num_to_show_limit, $start, false, NULL, true); $threaded_topic_ob->is_threaded = true; // Render posts list($posts, $serialized_options, $hash) = $threaded_topic_ob->render_posts($num_to_show_limit, $max_thread_depth, $may_reply, $topic_info['first_poster'], array(), $topic_info['forum_id'], NULL, false); $GLOBALS['META_DATA']['description'] = $threaded_topic_ob->topic_description; // Get other gathered details $replied = $threaded_topic_ob->replied; if (!is_null($threaded_topic_ob->topic_title)) { // Updated topic title $topic_info['title'] = $threaded_topic_ob->topic_title; } $topic_info['max_rows'] = $threaded_topic_ob->total_posts; $second_poster = $GLOBALS['FORUM_DRIVER']->get_guest_id(); // No definitive post orders } // Buttons for topic as whole $button_array = array(); if (!is_null($id)) { if (get_value('no_threaded_buttons') !== '1') { if ($threaded) { $view_as_linear_url = get_self_url(false, false, array('threaded' => 0)); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_LINEAR'), 'url' => $view_as_linear_url, 'img' => 'linear'); } else { $view_as_threaded_url = get_self_url(false, false, array('threaded' => 1)); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_THREADED'), 'url' => $view_as_threaded_url, 'img' => 'threaded'); } } if (!is_guest()) { $too_old = $topic_info['last_time'] < time() - 60 * 60 * 24 * intval(get_option('post_history_days')); if (get_value('disable_mark_topic_unread') !== '1' && !$too_old) { $map = array('page' => 'topics', 'type' => 'mark_unread_topic', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $mark_unread_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_UNREAD'), 'url' => $mark_unread_url, 'img' => 'mark_unread'); } } if ($may_reply && is_null(get_bot_type())) { $reply_prevented = false; // "Staff-only" reply for support tickets if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && addon_installed('tickets')) { require_code('tickets'); if (is_ticket_forum($topic_info['forum_id'])) { if (is_guest($second_poster)) { $reply_prevented = true; } require_lang('tickets'); $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id, 'intended_solely_for' => $GLOBALS['FORUM_DRIVER']->get_guest_id()); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('TICKET_STAFF_ONLY_REPLY'), 'url' => $new_post_url, 'img' => 'staff_only_reply'); } } if (!$reply_prevented) { if ($topic_info['is_threaded'] == 0) { $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode($topic_info['is_open'] ? 'REPLY' : 'CLOSED'), 'url' => $new_post_url, 'img' => $topic_info['is_open'] ? 'reply' : 'closed'); } } else { unset($topic_info['may_use_quick_reply']); } } elseif ((is_null($topic_info['forum_id']) || has_specific_permission(get_member(), 'submit_lowrange_content', 'topics', array('forums', $topic_info['forum_id']))) && $topic_info['last_poster'] == get_member() && !is_guest() && ocf_may_edit_post_by(get_member(), $topic_info['forum_id'])) { $map = array('page' => 'topics', 'type' => 'edit_post', 'id' => $topic_info['last_post_id']); $test = get_param_integer('kfs' . strval($topic_info['forum_id']), -1); if ($test != -1 && $test != 0) { $map['kfs' . strval($topic_info['forum_id'])] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'edit', 'title' => do_lang_tempcode('LAST_POST'), 'url' => $new_post_url, 'img' => 'amend'); } if (!is_null($topic_info['forum_id'])) { if (get_value('disable_add_topic_btn_in_topic') !== '1') { if (ocf_may_post_topic($topic_info['forum_id'], get_member())) { $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $topic_info['forum_id']), get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic'); } } } else { $invite_url = build_url(array('page' => 'topics', 'type' => 'invite_member', 'id' => $id), get_module_zone('topics')); $button_array[] = array('immediate' => false, 'title' => do_lang_tempcode('INVITE_MEMBER_TO_PT'), 'url' => $invite_url, 'img' => 'invite_member'); } } $buttons = ocf_screen_button_wrap($button_array); // Poll if (array_key_exists('poll', $topic_info)) { $_poll = $topic_info['poll']; $voted_already = $_poll['voted_already']; $poll_results = array_key_exists(0, $_poll['answers']) && array_key_exists('num_votes', $_poll['answers'][0]); $answers = new ocp_tempcode(); $real_button = false; if ($_poll['is_open']) { if ($poll_results) { $button = new ocp_tempcode(); } elseif ($_poll['requires_reply'] && !$replied) { $button = do_lang_tempcode('POLL_REQUIRES_REPLY'); } else { if (!has_specific_permission(get_member(), 'vote_in_polls') || is_guest()) { $button = do_lang_tempcode('VOTE_DENIED'); } else { if (!is_null($voted_already)) { $button = do_lang_tempcode('NOVOTE'); } else { require_lang('polls'); $map = array('page' => 'topicview', 'id' => $id, 'view_poll_results' => 1, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $results_url = build_url($map, get_module_zone('topics')); $button = do_template('OCF_TOPIC_POLL_BUTTON', array('_GUID' => '94b932fd01028df8f67bb5864d9235f9', 'RESULTS_URL' => $results_url)); $real_button = true; } } } } else { $button = do_lang_tempcode('TOPIC_POLL_CLOSED'); } foreach ($_poll['answers'] as $answer) { if ($poll_results && ($_poll['requires_reply'] == 0 || $replied)) { $num_votes = $answer['num_votes']; $total_votes = $_poll['total_votes']; if ($total_votes != 0) { $width = intval(round(70.0 * floatval($num_votes) / floatval($total_votes))); } else { $width = 0; } $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER_RESULTS', array('_GUID' => 'b32f4c526e147abf20ca0d668e40d515', 'ID' => strval($_poll['id']), 'NUM_VOTES' => integer_format($num_votes), 'WIDTH' => strval($width), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id']))); } else { $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER' . ($_poll['maximum_selections'] == 1 ? '_RADIO' : ''), array('REAL_BUTTON' => $real_button, 'ID' => strval($_poll['id']), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id']))); } $answers->attach($answer_tpl); } $map = array('page' => 'topics', 'type' => 'vote_poll', 'id' => $id, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $vote_url = build_url($map, get_module_zone('topics')); if ($_poll['is_private']) { $private = paragraph(do_lang_tempcode('TOPIC_POLL_IS_PRIVATE'), 'dfgsdgdsgs'); } else { $private = new ocp_tempcode(); } if ($_poll['maximum_selections'] > 1) { $num_choices = paragraph($_poll['minimum_selections'] == $_poll['maximum_selections'] ? do_lang_tempcode('POLL_NOT_ENOUGH_ERROR_2', integer_format($_poll['minimum_selections'])) : do_lang_tempcode('POLL_NOT_ENOUGH_ERROR', integer_format($_poll['minimum_selections']), integer_format($_poll['maximum_selections'])), 'dsfsdfsdfs'); } else { $num_choices = new ocp_tempcode(); } $poll = do_template('OCF_TOPIC_POLL' . ($poll_results ? '_VIEW_RESULTS' : ''), array('ID' => strval($_poll['id']), 'NUM_CHOICES' => $num_choices, 'PRIVATE' => $private, 'QUESTION' => $_poll['question'], 'ANSWERS' => $answers, 'REAL_BUTTON' => $real_button, 'BUTTON' => $button, 'VOTE_URL' => $vote_url, 'MINIMUM_SELECTIONS' => integer_format($_poll['minimum_selections']), 'MAXIMUM_SELECTIONS' => integer_format($_poll['maximum_selections']))); } else { $poll = new ocp_tempcode(); } // Forum nav tree if (!is_null($topic_info['forum_id'])) { $tree = ocf_forum_breadcrumbs($topic_info['forum_id'], NULL, NULL, false); } else { $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'members'), get_module_zone('members')), do_lang_tempcode('MEMBERS'), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up')); $tree->attach(do_template('BREADCRUMB_ESCAPED')); if (has_specific_permission(get_member(), 'view_other_pt')) { $of_member = $topic_info['pt_from'] == get_member() ? $topic_info['pt_from'] : $topic_info['pt_to']; } else { $of_member = get_member(); } $of_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member); if (is_null($of_username)) { $of_username = do_lang('UNKNOWN'); } $personal_topic_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $of_member), get_module_zone('members'), NULL, true, false, false, 'tab__pts'); $tree->attach(hyperlink($personal_topic_url, do_lang_tempcode('MEMBER_PROFILE', escape_html($of_username)), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up')); } // Quick reply if (array_key_exists('may_use_quick_reply', $topic_info) && $may_reply && !is_null($id)) { $map = array('page' => 'topics', 'type' => '_add_reply', 'topic_id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_post_url = build_url($map, get_module_zone('topics')); $post_url = $_post_url->evaluate(); $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $more_url = build_url($map, get_module_zone('topics')); $_postdetails = array_key_exists('first_post', $topic_info) ? get_translated_tempcode($topic_info['first_post'], $GLOBALS['FORUM_DB']) : new ocp_tempcode(); $first_post = $_postdetails; $first_post_url = $GLOBALS['FORUM_DRIVER']->post_url($topic_info['first_post_id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true); $display = 'block'; $expand_type = 'contract'; if ($topic_info['max_rows'] > $start + $max) { $display = 'none'; $expand_type = 'expand'; } $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); require_javascript('javascript_validation'); if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $post_warning = ''; if ($topic_info['is_really_threaded'] == 1) { $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning); } $quick_reply = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4c532620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => false, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => '', 'EM' => $em, 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'FIRST_POST_URL' => $first_post_url, 'FIRST_POST' => $first_post, 'MORE_URL' => $more_url, 'COMMENT_URL' => $post_url, 'TITLE' => do_lang_tempcode('QUICK_REPLY'), 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'))); } else { $quick_reply = new ocp_tempcode(); } $action_url = build_url(array('page' => 'topics', 'id' => $id), get_module_zone('topics')); if (!is_null($id)) { // Moderation options $moderator_actions = ''; if (is_null($topic_info['forum_id'])) { $moderator_actions .= '<option value="categorise_pts">' . do_lang('_CATEGORISE_PTS') . '</option>'; } if (array_key_exists('may_multi_moderate', $topic_info) && array_key_exists('forum_id', $topic_info)) { $multi_moderations = ocf_list_multi_moderations($topic_info['forum_id']); if (count($multi_moderations) != 0) { $moderator_actions .= '<optgroup label="' . do_lang('MULTI_MODERATIONS') . '">'; foreach ($multi_moderations as $mm_id => $mm_name) { $moderator_actions .= '<option value="mm_' . strval($mm_id) . '">' . $mm_name . '</option>'; } $moderator_actions .= '</optgroup>'; } } if (array_key_exists('may_move_topic', $topic_info)) { $moderator_actions .= '<option value="move_topic">' . do_lang('MOVE_TOPIC') . '</option>'; } if (array_key_exists('may_edit_topic', $topic_info)) { $moderator_actions .= '<option value="edit_topic">' . do_lang('EDIT_TOPIC') . '</option>'; } if (array_key_exists('may_delete_topic', $topic_info)) { $moderator_actions .= '<option value="delete_topic">' . do_lang('DELETE_TOPIC') . '</option>'; } if (array_key_exists('may_pin_topic', $topic_info)) { $moderator_actions .= '<option value="pin_topic">' . do_lang('PIN_TOPIC') . '</option>'; } if (array_key_exists('may_unpin_topic', $topic_info)) { $moderator_actions .= '<option value="unpin_topic">' . do_lang('UNPIN_TOPIC') . '</option>'; } if (array_key_exists('may_sink_topic', $topic_info)) { $moderator_actions .= '<option value="sink_topic">' . do_lang('SINK_TOPIC') . '</option>'; } if (array_key_exists('may_unsink_topic', $topic_info)) { $moderator_actions .= '<option value="unsink_topic">' . do_lang('UNSINK_TOPIC') . '</option>'; } if (array_key_exists('may_cascade_topic', $topic_info)) { $moderator_actions .= '<option value="cascade_topic">' . do_lang('CASCADE_TOPIC') . '</option>'; } if (array_key_exists('may_uncascade_topic', $topic_info)) { $moderator_actions .= '<option value="uncascade_topic">' . do_lang('UNCASCADE_TOPIC') . '</option>'; } if (array_key_exists('may_open_topic', $topic_info)) { $moderator_actions .= '<option value="open_topic">' . do_lang('OPEN_TOPIC') . '</option>'; } if (array_key_exists('may_close_topic', $topic_info)) { $moderator_actions .= '<option value="close_topic">' . do_lang('CLOSE_TOPIC') . '</option>'; } if (array_key_exists('may_edit_poll', $topic_info)) { $moderator_actions .= '<option value="edit_poll">' . do_lang('EDIT_TOPIC_POLL') . '</option>'; } if (array_key_exists('may_delete_poll', $topic_info)) { $moderator_actions .= '<option value="delete_poll">' . do_lang('DELETE_TOPIC_POLL') . '</option>'; } if (array_key_exists('may_attach_poll', $topic_info)) { $moderator_actions .= '<option value="add_poll">' . do_lang('ADD_TOPIC_POLL') . '</option>'; } if (has_specific_permission(get_member(), 'view_content_history') && $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', array('h_topic_id' => $id)) != 0) { $moderator_actions .= '<option value="topic_history">' . do_lang('POST_HISTORY') . '</option>'; } if (array_key_exists('may_make_personal', $topic_info) && !is_null($topic_info['forum_id'])) { $moderator_actions .= '<option value="make_personal">' . do_lang('MAKE_PERSONAL') . '</option>'; } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($moderator_actions); } // Marked post actions $map = array('page' => 'topics', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $action_url = build_url($map, get_module_zone('topics'), NULL, false, true); $marked_post_actions = ''; if (array_key_exists('may_move_posts', $topic_info)) { $marked_post_actions .= '<option value="move_posts_a">' . do_lang('MERGE_POSTS') . '</option>'; $marked_post_actions .= '<option value="move_posts_b">' . do_lang('SPLIT_POSTS') . '</option>'; } if (array_key_exists('may_delete_posts', $topic_info)) { $marked_post_actions .= '<option value="delete_posts">' . do_lang('DELETE_POSTS') . '</option>'; } if (array_key_exists('may_validate_posts', $topic_info)) { $marked_post_actions .= '<option value="validate_posts">' . do_lang('VALIDATE_POSTS') . '</option>'; } if (get_value('disable_multi_quote') !== '1') { if ($may_reply) { $marked_post_actions .= '<option value="new_post">' . do_lang('QUOTE_POSTS') . '</option>'; } } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($marked_post_actions); } } else { $moderator_actions = ''; $marked_post_actions = ''; } $max_rows = $topic_info['max_rows']; if ($max_rows > $max && !$threaded) { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('FORUM_POSTS'), $id, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true, false, 7, array(10, 20, 30)); } else { $results_browser = new ocp_tempcode(); } // Members viewing this topic $members = is_null($id) ? array() : get_members_viewing('topicview', '', strval($id), true); $num_guests = 0; $num_members = 0; if (is_null($members)) { $members_viewing = new ocp_tempcode(); } else { $members_viewing = new ocp_tempcode(); foreach ($members as $member_id => $at_details) { $username = $at_details['mt_cache_username']; if (is_guest($member_id)) { $num_guests++; } else { $num_members++; $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true); $map = array('PROFILE_URL' => $profile_url, 'USERNAME' => $username); if (has_specific_permission(get_member(), 'show_user_browsing') || in_array($at_details['the_page'], array('topics', 'topicview')) && $at_details['the_id'] == strval($id)) { $map['AT'] = escape_html($at_details['the_title']); } $map['COLOUR'] = get_group_colour(ocf_get_member_primary_group($member_id)); $members_viewing->attach(do_template('OCF_USER_MEMBER', $map)); } } if ($members_viewing->is_empty()) { $members_viewing = do_lang_tempcode('NONE_EM'); } } if (!is_null($id)) { breadcrumb_add_segment($tree, do_lang_tempcode(is_null($topic_info['forum_id']) ? 'VIEW_PERSONAL_TOPIC' : 'VIEW_TOPIC')); } if (is_null($id)) { $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => db_get_first_id())); $tree = hyperlink(build_url(array('page' => 'forumview', 'id' => db_get_first_id()), get_module_zone('forumview')), escape_html($root_forum_name), false, false, do_lang('GO_BACKWARDS_TO')); breadcrumb_add_segment($tree, do_lang('INLINE_PERSONAL_POSTS')); } if ($topic_info['validated'] == 0) { $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } $topic_tpl = do_template('OCF_TOPIC_WRAP', array('_GUID' => 'bb201d5d59559e5e2bd60e7cf2e6f7e9', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'ID' => strval($id), 'TITLE' => $topic_info['title'], 'MAY_DOUBLE_POST' => has_specific_permission(get_member(), 'double_post'), 'LAST_POSTER' => array_key_exists('last_poster', $topic_info) ? is_null($topic_info['last_poster']) ? '' : strval($topic_info['last_poster']) : '', 'WARNING_DETAILS' => $warning_details, 'MAX' => strval($max), 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $topic_info), 'ACTION_URL' => $action_url, 'NUM_GUESTS' => integer_format($num_guests), 'NUM_MEMBERS' => integer_format($num_members), 'MEMBERS_VIEWING' => $members_viewing, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'MARKED_POST_ACTIONS' => $marked_post_actions, 'QUICK_REPLY' => $quick_reply, 'TREE' => $tree, 'POLL' => $poll, 'SCREEN_BUTTONS' => $buttons, 'POSTS' => $posts, 'THREADED' => $threaded)); if (is_null($id)) { $title = get_page_title('INLINE_PERSONAL_POSTS'); } else { if (is_null($topic_info['forum_id'])) { $title = get_page_title(do_lang_tempcode('NAMED_PERSONAL_TOPIC', escape_html($topic_info['title'])), false, NULL, do_lang_tempcode('READING_PERSONAL_TOPIC')); } else { if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('topic', strval($id)); } else { $awards = array(); } $title = get_page_title(do_lang_tempcode('NAMED_TOPIC', escape_html($topic_info['title'])), false, NULL, NULL, $awards); } } return ocf_wrapper($title, $topic_tpl, true, false, $topic_info['forum_id']); }
/** * Show the point transactions a member has had. * * @param ID_TEXT The type of transactions we are looking for * @set from to * @param MEMBER Who we are looking at transactions for * @param MEMBER Who we are looking at transactions using the account of * @return tempcode The UI */ function points_get_transactions($type, $member_id_of, $member_id_viewing) { $where = array('gift_' . $type => $member_id_of); if ($type == 'from') { $where['anonymous'] = 0; } $start = get_param_integer('gift_start_' . $type, 0); $max = get_param_integer('gift_max_' . $type, 10); $sortables = array('date_and_time' => do_lang_tempcode('DATE'), 'amount' => do_lang_tempcode('AMOUNT')); $test = explode(' ', get_param('gift_sort_' . $type, 'date_and_time DESC')); 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[] = 'gift_sort_' . $type; $NON_CANONICAL_PARAMS[] = 'gift_start_' . $type; $max_rows = $GLOBALS['SITE_DB']->query_value('gifts', 'COUNT(*)', $where); $rows = $GLOBALS['SITE_DB']->query_select('gifts g LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=g.reason', array('*'), $where, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start); $out = new ocp_tempcode(); $viewing_name = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); if (is_null($viewing_name)) { $viewing_name = do_lang('UNKNOWN'); } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('AMOUNT'), do_lang_tempcode('FROM'), do_lang_tempcode('TO'), do_lang_tempcode('REASON')), $sortables, 'gift_sort_' . $type, $sortable . ' ' . $sort_order); foreach ($rows as $myrow) { if ($myrow['anonymous'] == 1 && $type == 'from') { continue; } // Their name $fromname = is_guest($myrow['gift_from']) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($myrow['gift_from']); $toname = $GLOBALS['FORUM_DRIVER']->get_username($myrow['gift_to']); if (is_null($fromname)) { $fromname = do_lang('UNKNOWN'); } if ($myrow['anonymous'] == 1 && !is_guest($myrow['gift_from'])) { if (!has_specific_permission($member_id_viewing, 'trace_anonymous_gifts')) { $_fromname = do_lang_tempcode('ANON'); } else { $_fromname = hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_from']), get_module_zone('points')), do_lang_tempcode('ANON'), false, false, escape_html($fromname)); } } else { $_fromname = is_guest($myrow['gift_from']) ? make_string_tempcode(escape_html($fromname)) : hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_from']), get_module_zone('points')), escape_html($fromname), false, false, do_lang_tempcode('VIEW_POINTS')); } $_toname = hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_to']), get_module_zone('points')), escape_html($toname), false, false, do_lang_tempcode('VIEW_POINTS')); $date = get_timezoned_date($myrow['date_and_time']); $amount = $myrow['amount']; if (get_page_name() != 'search' && array_key_exists('text_parsed', $myrow) && !is_null($myrow['text_parsed']) && $myrow['text_parsed'] != '' && $myrow['reason'] != 0) { $reason = new ocp_tempcode(); if (!$reason->from_assembly($myrow['text_parsed'], true)) { $reason = get_translated_tempcode($myrow['reason']); } } else { $reason = get_translated_tempcode($myrow['reason']); } $out->attach(results_entry(array(escape_html($date), escape_html(integer_format($amount)), $_fromname, $_toname, $reason))); } $out = results_table(do_lang_tempcode('_POINTS', escape_html($viewing_name)), $start, 'gift_start_' . $type, $max, 'gift_max_' . $type, $max_rows, $fields_title, $out, $sortables, $sortable, $sort_order, 'gift_sort_' . $type, NULL, NULL, NULL, 8, 'gfhfghtrhhjghgfhfgf', false, 'tab__points'); if ($type == 'to') { $title = do_lang_tempcode('POINTS_TO'); } else { $title = do_lang_tempcode('POINTS_FROM'); } return do_template('POINTS_TRANSACTIONS_WRAP', array('_GUID' => 'f19e3eedeb0b8bf398251b24e8389723', 'CONTENT' => $out, 'TITLE' => $title)); }
/** * Makes a post in the specified forum, in the specified topic according to the given specifications. If the topic doesn't exist, it is created along with a spacer-post. * Spacer posts exist in order to allow staff to delete the first true post in a topic. Without spacers, this would not be possible with most forum systems. They also serve to provide meta information on the topic that cannot be encoded in the title (such as a link to the content being commented upon). * * @param SHORT_TEXT The forum name * @param SHORT_TEXT The topic identifier (usually <content-type>_<content-id>) * @param MEMBER The member ID * @param LONG_TEXT The post title * @param LONG_TEXT The post content in Comcode format * @param string The topic title; must be same as content title if this is for a comment topic * @param string This is put together with the topic identifier to make a more-human-readable topic title or topic description (hopefully the latter and a $content_title title, but only if the forum supports descriptions) * @param ?URLPATH URL to the content (NULL: do not make spacer post) * @param ?TIME The post time (NULL: use current time) * @param ?IP The post IP address (NULL: use current members IP address) * @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param ?BINARY Whether the topic is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param boolean Whether to skip post checks * @param SHORT_TEXT The name of the poster * @param ?AUTO_LINK ID of post being replied to (NULL: N/A) * @param boolean Whether the reply is only visible to staff * @return array Topic ID (may be NULL), and whether a hidden post has been made */ function make_post_forum_topic($forum_name, $topic_identifier, $member, $post_title, $_post, $content_title, $topic_identifier_encapsulation_prefix, $content_url = NULL, $time = NULL, $ip = NULL, $validated = NULL, $topic_validated = 1, $skip_post_checks = false, $poster_name_if_guest = '', $parent_id = NULL, $staff_only = false) { $__post = comcode_to_tempcode($_post); $post = $__post->evaluate(); if (is_null($time)) { $time = time(); } if (is_null($ip)) { $ip = get_ip_address(); } $forum_id = $this->forum_id_from_name($forum_name); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('MISSING_FORUM', escape_html($forum_name))); } $test = $this->connection->query_select('forums', array('*'), NULL, '', 1); $fm = array_key_exists('hide_forum_in_cat', $test[0]); $topic_id = $this->find_topic_id_for_topic_identifier($forum_name, $topic_identifier); $ip_address = $this->_phpbb_ip($ip); $local_ip_address = $this->_phpbb_ip('127.0.0.1'); $is_new = is_null($topic_id); if ($is_new) { $map = array('forum_id' => $forum_id, 'topic_title' => $content_title . ', ' . $topic_identifier_encapsulation_prefix . ': #' . $topic_identifier, 'topic_poster' => $member, 'topic_time' => $time, 'topic_views' => 0, 'topic_replies' => 0, 'topic_replies_real' => 0, 'topic_status' => 0, 'topic_type' => 0, 'topic_first_post_id' => 0, 'topic_last_post_id' => 0, 'topic_moved_id' => 0); if ($fm) { $map = array_merge($map, array('answer_status' => 0, 'topic_attachment' => 0, 'topic_icon' => 0, 'rating_rank_id' => 0, 'title_compl_infos' => NULL, 'topic_priority' => 0)); } $topic_id = $this->connection->query_insert('topics', $map, true); $home_link = hyperlink($content_url, escape_html($content_title)); $map = array('topic_id' => $topic_id, 'forum_id' => $forum_id, 'poster_id' => -1, 'post_text' => do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()), 'post_time' => $time, 'poster_ip' => $local_ip_address, 'post_username' => $this->get_username($member), 'enable_bbcode' => 1, 'enable_smilies' => 1, 'enable_sig' => 1, 'post_edit_time' => 0, 'post_edit_count' => 0); if ($fm) { $map = array_merge($map, array('post_attachment' => 0, 'post_edit_user' => NULL, 'post_icon' => 0, 'post_bluecard' => NULL, 'rating_rank_id' => 0, 'user_avatar' => NULL, 'user_avatar_type' => 0, 'urgent_post' => 0)); } $post_id = $this->connection->query_insert('posts', $map, true); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'topics SET topic_first_post_id=' . strval((int) $post_id) . ' WHERE topic_id=' . strval((int) $topic_id), 1); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'forums SET forum_topics_real=(forum_topics_real+1),forum_topics=(forum_topics+1),forum_posts=(forum_posts+1) WHERE forum_id=' . strval((int) $forum_id), 1); } $GLOBALS['LAST_TOPIC_ID'] = $topic_id; $GLOBALS['LAST_TOPIC_IS_NEW'] = $is_new; if ($post == '') { return array($topic_id, false); } $map = array('topic_id' => $topic_id, 'forum_id' => $forum_id, 'poster_id' => $member, 'post_text' => $post, 'post_time' => $time, 'poster_ip' => $ip_address, 'post_username' => $this->get_username($member), 'enable_bbcode' => 1, 'enable_smilies' => 1, 'enable_sig' => 1, 'post_edit_time' => 0, 'post_edit_count' => 0); if ($fm) { $map = array_merge($map, array('post_attachment' => 0, 'post_edit_user' => NULL, 'post_icon' => 0, 'post_bluecard' => NULL, 'rating_rank_id' => 0, 'user_avatar' => NULL, 'user_avatar_type' => 0, 'urgent_post' => 0)); } $post_id = $this->connection->query_insert('posts', $map, true); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'forums SET forum_posts=(forum_posts+1), forum_last_post_id=' . strval((int) $post_id) . ' WHERE forum_id=' . strval((int) $forum_id), 1); $this->connection->query('UPDATE ' . $this->connection->get_table_prefix() . 'topics SET topic_replies=(topic_replies+1), topic_replies_real=(topic_replies_real+1), topic_last_post_id=' . strval((int) $post_id) . ' WHERE topic_id=' . strval((int) $topic_id), 1); return array($topic_id, false); }
function result_id($eventid) { global $userinfo, $user_sites, $dbconn; $dbconn->SetFetchMode(ADODB_FETCH_BOTH); $query = "SELECT hostip, hostname, service, risk, msg \n FROM vuln_nessus_results\n WHERE result_id='{$eventid}' LIMIT 1"; $result = $dbconn->execute($query); $numrows = $result->NumRows(); echo "sql={$query}<br>"; if ($numrows < 1) { die("<h3><font color=red>No Results</font></h3>"); } echo "<table summary=\"Plugin Matches [ <font color=red>{$pid}</a> ]\" border=\"1\" width=\"100%\">"; if ($details == "1") { echo <<<EOT <tr><td colspan=4><h4>Vulnerabilities found:</h4></tr> <tr> <td><font face="Verdana" color="#666666" size="4"><b>Host </b></font></td> <td><font face="Verdana" color="#666666" size="4"><b>Severity </b></font></td> <td><font face="Verdana" color="#666666" size="4"><b>Description </b></font></td> </tr> EOT; } else { echo "<tr><td colspan=4><h4>Vulnerabilities found:</h4></tr>"; } $htmldetails = ""; $i = 0; while (!$result->EOF) { list($hostIP, $hostname, $service, $risk, $msg) = $result->fields; $i = $i += 1; $msg = preg_replace("/^[ \t]*/", "", $msg); $msg = wordwrap(preg_replace("/\n/", "<br>", $msg), 100, "<br>", 1); $msg = hyperlink($msg); if ($details == "1") { $htmldetails .= "<tr>\n <td>{$hostIP}<br>{$hostname}</td>\n <td>{$service}<br>" . getrisk($risk) . "</td>\n <td>{$msg}</td>\n</tr>"; } else { $htmldetails .= "<tr><td>RISK</td><td colspan=4>" . getrisk($risk) . "</td></tr>\n<tr><td>SERVICE</td><td colspan=4>{$service}</td></tr>\n<tr><td>MSG</td><td colspan=4>{$msg}</td></tr>\n<tr><td colspan=4> </td></tr>\n<tr><td colspan=4><h4>VULNERABLE HOSTS</h4></td></tr>\n<tr><td colspan=4> </td></tr>\n<tr><td>HOSTIP</td><td>HOSTNAME</td><td>SITE</td><td>Location</td></tr>\n<tr><td>[{$i}] {$hostIP}</td><td>{$hostname}</td>\n <td> {$sCODE}</td><td>{$sORG}</td></tr>"; } } echo $htmldetails; echo "</table>"; }
/** * The main user interface for the file dump. * * @return tempcode The UI. */ function module_do_gui() { $title = get_page_title('FILE_DUMP'); $place = filter_naughty(get_param('place', '/')); if (substr($place, -1, 1) != '/') { $place .= '/'; } $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=filedump&filter=' . $place; // Show tree $dirs = explode('/', substr($place, 0, strlen($place) - 1)); $i = 0; $pre = ''; $file_tree = new ocp_tempcode(); while (array_key_exists($i, $dirs)) { if ($i > 0) { $d = $dirs[$i]; } else { $d = do_lang('FILE_DUMP'); } if (array_key_exists($i + 1, $dirs)) { $tree_url = build_url(array('page' => '_SELF', 'place' => $pre . $dirs[$i] . '/'), '_SELF'); if (!$file_tree->is_empty()) { $file_tree->attach(do_template('BREADCRUMB', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c6'))); } $file_tree->attach(hyperlink($tree_url, $d)); } $pre .= $dirs[$i] . '/'; $i++; } if (!$file_tree->is_empty()) { breadcrumb_add_segment($file_tree, $d); } else { breadcrumb_set_self($i == 1 ? do_lang_tempcode('FILE_DUMP') : make_string_tempcode(escape_html($d))); } // Check directory exists $fullpath = get_custom_file_base() . '/uploads/filedump' . $place; if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place)) { if (has_specific_permission(get_member(), 'upload_filedump')) { @mkdir($fullpath, 0777) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($fullpath), escape_html(dirname($fullpath)))); fix_permissions($fullpath, 0777); sync_file($fullpath); } } // Find all files in the incoming directory $handle = opendir(get_custom_file_base() . '/uploads/filedump' . $place); $i = 0; $filename = array(); $description = array(); $filesize = array(); $filetime = array(); $directory = array(); $deletable = array(); while (false !== ($file = readdir($handle))) { if (!should_ignore_file('uploads/filedump' . $place . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_HIDDEN_FILES)) { $directory[$i] = !is_file(get_custom_file_base() . '/uploads/filedump' . $place . $file); $filename[$i] = $directory[$i] ? $file . '/' : $file; if ($directory[$i]) { $filesize[$i] = do_lang_tempcode('NA_EM'); } $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => $place)); if (!array_key_exists(0, $dbrows)) { $description[$i] = $directory[$i] ? do_lang_tempcode('NA_EM') : do_lang_tempcode('NONE_EM'); } else { $description[$i] = make_string_tempcode(escape_html(get_translated_text($dbrows[0]['description']))); } if ($description[$i]->is_empty()) { $description[$i] = do_lang_tempcode('NONE_EM'); } $deletable[$i] = array_key_exists(0, $dbrows) && $dbrows[0]['the_member'] == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump'); if ($directory[$i]) { $size = get_directory_size(get_custom_file_base() . '/uploads/filedump' . $place . $file); $timestamp = NULL; } else { $size = filesize(get_custom_file_base() . '/uploads/filedump' . $place . $file); $timestamp = filemtime(get_custom_file_base() . '/uploads/filedump' . $place . $file); } $filesize[$i] = clean_file_size($size); $filetime[$i] = is_null($timestamp) ? NULL : get_timezoned_date($timestamp); $i++; } } closedir($handle); if ($i != 0) { require_code('templates_table_table'); $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS'))); $rows = new ocp_tempcode(); for ($a = 0; $a < $i; $a++) { if ($directory[$a]) { $link = build_url(array('page' => '_SELF', 'place' => $place . $filename[$a]), '_SELF'); } else { $link = make_string_tempcode(get_custom_base_url() . '/uploads/filedump' . str_replace('%2F', '/', rawurlencode($place . $filename[$a]))); } if (!$directory[$a]) { if ($deletable[$a]) { $delete_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'file' => $filename[$a], 'place' => $place), '_SELF'); $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '9b91e485d80417b1664145f9bca5a2f5', 'NAME' => $filename[$a], 'URL' => $delete_url)); } else { $actions = new ocp_tempcode(); } } else { $delete_url = build_url(array('page' => '_SELF', 'type' => 'ec', 'file' => $filename[$a], 'place' => $place), '_SELF'); $actions = do_template('TABLE_TABLE_ACTION_DELETE_CATEGORY', array('_GUID' => '0fa7d4090c6195328191399a14799169', 'NAME' => $filename[$a], 'URL' => $delete_url)); } $rows->attach(table_table_row(array(hyperlink($link, escape_html($filename[$a]), !$directory[$a]), escape_html($description[$a]), escape_html($filesize[$a]), is_null($filetime[$a]) ? do_lang_tempcode('NA') : make_string_tempcode(escape_html($filetime[$a])), $actions))); } $files = do_template('TABLE_TABLE', array('_GUID' => '1c0a91d47c5fc8a7c2b35c7d9b36132f', 'HEADER_ROW' => $header_row, 'ROWS' => $rows)); } else { $files = new ocp_tempcode(); } // Do a form so people can upload their own stuff if (has_specific_permission(get_member(), 'upload_filedump')) { $post_url = build_url(array('page' => '_SELF', 'type' => 'ad', 'uploading' => 1), '_SELF'); $submit_name = do_lang_tempcode('FILEDUMP_UPLOAD'); $max = floatval(get_max_file_size()); $text = new ocp_tempcode(); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $text->attach(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max / 1024.0 / 1024.0)), escape_html(is_null($config_url) ? '' : $config_url))); } require_code('form_templates'); $fields = form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('_DESCRIPTION_UPLOAD'), 'file', true); $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', '', false)); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('place', $place)); handle_max_file_size($hidden); $upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'HIDDEN' => $hidden, 'TEXT' => $text, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); } else { $upload_form = new ocp_tempcode(); } // Do a form so people can make folders if (get_option('is_on_folder_create') == '1') { $post_url = build_url(array('page' => '_SELF', 'type' => 'ac'), '_SELF'); require_code('form_templates'); $fields = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', '', true); $hidden = form_input_hidden('place', $place); $submit_name = do_lang_tempcode('FILEDUMP_CREATE_FOLDER'); $create_folder_form = do_template('FORM', array('_GUID' => '043f9b595d3699b7d8cd7f2284cdaf98', 'TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'SECONDARY_FORM' => true, 'HIDDEN' => $hidden, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); } else { $create_folder_form = new ocp_tempcode(); } return do_template('FILE_DUMP_SCREEN', array('_GUID' => '3f49a8277a11f543eff6488622949c84', 'TITLE' => $title, 'PLACE' => $place, 'FILES' => $files, 'UPLOAD_FORM' => $upload_form, 'CREATE_FOLDER_FORM' => $create_folder_form)); }
<?php $r = mysql_fetch_all(mysql_query("SELECT * FROM friends WHERE username = '******'")); print "<div class='controls'>"; if (is_array($r)) { print "<ul class='friends'><h2>Friends:</h2>"; foreach ($r as $row) { extract($row); print "<li class='friend'><span class='name'>{$friend}</span>\n\t\t\t<span class='uri'><a href='{$uri}'>{$uri}</a></span></li>"; } print '</ul>'; } print "<div class='toolbar'>"; print "<a href='{$PHP_SELF}/Friends/Add'>Add Friend</a>"; print "</div>"; $r = mysql_fetch_all(mysql_query("SELECT * FROM sidebars WHERE username = '******' ORDER BY title")); if (is_array($r)) { print "<ul class='sidebars'><h2>Sidebars:</h2>"; foreach ($r as $row) { extract($row); print "<li class='sidebar'><span class='title'>{$title}</span><span class='controls'>" . hyperlink("{$SCRIPT_URI}/Manage/Sidebar/Edit/" . $title, 'Edit') . "</span></li>"; } print '</ul>'; } print "</div>"; print "<div class='toolbar'>"; print "<a href='{$PHP_SELF}/Sidebar/Add'>Add Sidebar</a>"; print "</div>";
/** * The UI to show a gallery. * * @return tempcode The UI */ function do_gallery() { require_code('images'); $cat = get_param('id', 'root'); $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=galleries&filter=' . $cat; $root = get_param('root', 'root'); if (!has_category_access(get_member(), 'galleries', $cat)) { access_denied('CATEGORY_ACCESS'); } // Info on our gallery $gallery_rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $cat), '', 1); $implied_existence = false; if (!array_key_exists(0, $gallery_rows)) { // Possibly we will 'imply' it's existence if this is a member gallery; allows normal rendering to finish, with add links $matches = array(); if (preg_match('#^member\\_(\\d+)\\_(.*)$#', $cat, $matches) != 0) { $username = $GLOBALS['FORUM_DRIVER']->get_username(intval($matches[1])); if (!is_null($username)) { $gallery_rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $matches[2]), '', 1); } } if (!array_key_exists(0, $gallery_rows)) { return warn_screen(get_page_title('ERROR_OCCURRED'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $gallery_rows[0]; $myrow['is_member_synched'] = 0; $fullname = do_lang('PERSONAL_GALLERY_OF', $username, get_translated_text($myrow['fullname'])); $myrow['parent_id'] = $matches[2]; $implied_existence = true; } else { $myrow = $gallery_rows[0]; $fullname = get_translated_text($myrow['fullname']); } if ($fullname == '') { $fullname = $cat; } $description = get_translated_tempcode($myrow['description']); if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_galleries', array('galleries', $cat))) { $submit_cat = $myrow['is_member_synched'] == 1 ? 'member_' . strval(get_member()) . '_' . $cat : $cat; $submit_image_url = $myrow['accept_images'] == 0 ? new ocp_tempcode() : build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => $submit_cat), get_module_zone('cms_galleries')); $submit_video_url = $myrow['accept_videos'] == 0 ? new ocp_tempcode() : build_url(array('page' => 'cms_galleries', 'type' => 'av', 'cat' => $submit_cat), get_module_zone('cms_galleries')); } else { $submit_image_url = new ocp_tempcode(); $submit_video_url = new ocp_tempcode(); } if (!$implied_existence && has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('cat_mid', get_member(), get_member_id_from_gallery_name($cat), 'cms_galleries', array('galleries', $cat))) { $edit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ec', 'id' => $cat), get_module_zone('cms_galleries')); } else { $edit_url = new ocp_tempcode(); } if (!$implied_existence && has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_submit_permission('cat_mid', get_member(), get_ip_address(), 'cms_galleries')) { $add_gallery_url = build_url(array('page' => 'cms_galleries', 'type' => 'ac', 'cat' => $cat), get_module_zone('cms_galleries')); } else { $add_gallery_url = new ocp_tempcode(); } $may_download_gallery = has_specific_permission(get_member(), 'may_download_gallery', 'galleries', array('galleries', $cat)); $tree = gallery_breadcrumbs($cat, $root, true, get_module_zone('galleries')); if (!$tree->is_empty()) { $tree->attach(do_template('BREADCRUMB_ESCAPED')); } if (has_specific_permission(get_member(), 'open_virtual_roots')) { $url = get_self_url(false, false, array('root' => $cat)); $tree->attach(hyperlink($url, escape_html($fullname), false, false, do_lang_tempcode('VIRTUAL_ROOT'))); } else { $tree->attach('<span>' . escape_html($fullname) . '</span>'); } $myrow['flow_mode_interface'] = get_param_integer('flow_mode_interface', $myrow['flow_mode_interface']); // Allow override via URL // Flow mode puts emphasis on subgalleries, rather than entries; it is subgalleries that there are a lot of, rather than entries if ($myrow['flow_mode_interface'] == 1) { $max = get_param_integer('max', get_default_gallery_max()); if ($max < 1) { $max = 1; } $start = get_param_integer('start', 0); } else { $max = NULL; $start = NULL; } // Subgalleries $order = 'add_date DESC'; if (get_option('gallery_name_order') == '1') { $order = 'name ASC'; } $rows_children = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('parent_id' => $cat), 'ORDER BY ' . $order, 200); $children = new ocp_tempcode(); $num_galleries = 0; if (count($rows_children) == 200) { $rows_children = array(); } // Lots of personal galleries. Will need to be reached via member profiles foreach ($rows_children as $child) { if (substr($child['name'], 0, 9) == 'download_') { continue; } if (!has_category_access(get_member(), 'galleries', $child['name'])) { continue; } if (get_option('show_empty_galleries') == '1' || gallery_has_content($child['name'])) { if (is_null($max) || $num_galleries >= $start && $num_galleries < $start + $max) { $content = show_gallery_box($child, $root, true, get_zone_name(), get_option('show_empty_galleries') != '1'); if (!$content->is_empty()) { $children->attach(do_template('GALLERY_SUBGALLERY_WRAP', array('CONTENT' => $content))); } } $num_galleries++; } } // Views if (get_db_type() != 'xml') { $myrow['gallery_views']++; $GLOBALS['SITE_DB']->query_update('galleries', array('gallery_views' => $myrow['gallery_views']), array('name' => $cat), '', 1, NULL, false, true); } // Page title if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('gallery', $cat); } else { $awards = array(); } $title_to_use = do_lang_tempcode('_GALLERY', escape_html($fullname)); $title_to_use_2 = do_lang('_GALLERY', $fullname); $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('gallery', $cat, $title_to_use_2); $rep_image = $myrow['rep_image']; if (post_param_integer('rating_' . $cat, -1) != -1) { decache('main_top_galleries'); } list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), $cat, $myrow['allow_rating'], $myrow['allow_comments'], 0, 1, NULL, build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, true), $title_to_use_2, get_value('comment_forum__galleries')); breadcrumb_add_segment($tree); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => is_null($myrow['g_owner']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($myrow['g_owner']), 'publisher' => '', 'modified' => '', 'type' => 'Gallery', 'title' => $fullname, 'identifier' => '_SEARCH:galleries:misc:' . $cat, 'description' => get_translated_text($myrow['description'])); if ($rep_image != '') { $GLOBALS['META_DATA'] += array('image' => (url_is_local($rep_image) ? get_custom_base_url() . '/' : '') . $rep_image); } // Sorting list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order(); if (get_option('is_on_rating') == '1') { $_selectors['compound_rating DESC'] = 'POPULARITY'; } $_selectors = array_merge($_selectors, array('url ASC' => 'FILENAME', 'add_date ASC' => 'OLDEST_FIRST', 'add_date DESC' => 'NEWEST_FIRST', 'title ASC' => 'TITLE')); $selectors = new ocp_tempcode(); foreach ($_selectors as $selector_value => $selector_name) { $selected = $sort == $selector_value; $selectors->attach(do_template('RESULTS_BROWSER_SORTER', array('SELECTED' => $selected, 'NAME' => do_lang_tempcode($selector_name), 'VALUE' => $selector_value))); } $sort_url = get_self_url(false, false, array('sort' => NULL), false, true); $sorting = do_template('RESULTS_BROWSER_SORT', array('SORT' => 'sort', 'RAND' => uniqid(''), 'URL' => $sort_url, 'SELECTORS' => $selectors)); if ($myrow['flow_mode_interface'] == 1) { return $this->do_gallery_flow_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download_gallery, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $rep_image, $start, $max, $num_galleries, $fullname, $sorting); } else { return $this->do_gallery_regular_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download_gallery, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $fullname, $sorting); } }