/** * Get the tempcode for a results table. * * @param mixed Some text/word describing what is being browsed (Tempcode or string) * @param integer The result number our table starts at (x of n) * @param ID_TEXT The parameter name used to store our position in the results (usually, 'start') * @param integer The total number of results to show per-page * @param ID_TEXT The parameter name used to store the total number of results to show per-page (usually, 'max') * @param integer The maximum number of rows in the entire dataset * @param tempcode The titles of the fields we are showing in our table, presented in preprepared tempcode * @param tempcode The values of the fields we are showing in our table * @param ?array A map of sortable code (usually, db field names), to strings giving the human name for the sort order (NULL: no sortables) * @param ?ID_TEXT The current sortable (NULL: none) * @param ?ID_TEXT The order we are sorting in (NULL: none) * @set ASC DESC * @param ?ID_TEXT The parameter name used to store our sortable (usually 'sort') (NULL: none) * @param ?tempcode Message to show (NULL: auto) * @param ?array Widths to specify to the table (NULL: none sent) * @param ?string The template set to use (NULL: default) * @param integer The maximum number of quick-jump page links to show * @param string GUID to pass to template * @param boolean Whether to skip showing a sort form (useful if there is another form wrapped around this) * @param ?ID_TEXT URL hash component (NULL: none) * @return tempcode The results table */ function results_table($text_id, $start, $start_name, $max, $max_name, $max_rows, $fields_title, $fields, $sortables = NULL, $sortable = NULL, $sort_order = NULL, $sort_name = 'sort', $message = NULL, $widths = NULL, $tplset = NULL, $max_page_links = 8, $guid = '1c8645bc2a3ff5bec2e003142185561f', $skip_sortables_form = false, $hash = NULL) { require_code('templates_results_browser'); if (!is_null($sort_name)) { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = $sort_name; } if (is_null($widths)) { $widths = array(); } if (is_null($message)) { $message = new ocp_tempcode(); if (!is_null($sortables)) { foreach ($sortables as $_sortable => $text) { if (is_object($text)) { $text = $text->evaluate(); } if ($text == do_lang('DATE_TIME')) { $message = paragraph(do_lang_tempcode('CLICK_DATE_FOR_MORE')); } } } } // Sorting if (!is_null($sortables)) { $selectors = new ocp_tempcode(); foreach ($sortables as $_sortable => $text) { $text_ascending = new ocp_tempcode(); $text_ascending->attach($text); $text_ascending->attach(do_lang_tempcode('_ASCENDING')); $text_descending = new ocp_tempcode(); $text_descending->attach($text); $text_descending->attach(do_lang_tempcode('_DESCENDING')); $selector_value = $_sortable . ' ASC'; $selected = $sortable . ' ' . $sort_order == $selector_value; $selectors->attach(do_template('RESULTS_BROWSER_SORTER', array('_GUID' => $guid, 'SELECTED' => $selected, 'NAME' => $text_ascending, 'VALUE' => $selector_value))); $selector_value = $_sortable . ' DESC'; $selected = $sortable . ' ' . $sort_order == $selector_value; $selectors->attach(do_template('RESULTS_BROWSER_SORTER', array('_GUID' => $guid, 'SELECTED' => $selected, 'NAME' => $text_descending, 'VALUE' => $selector_value))); } if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) { $sort_url = find_script('iframe') . '?zone=' . get_zone_name(); $url_array = $_GET; foreach ($url_array as $key => $param) { if (is_array($param)) { continue; } if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) { continue; } if ($key == 'wide_high') { continue; } if ($param === '_SELF') { $param = get_page_name(); } if (get_magic_quotes_gpc()) { $param = stripslashes($param); } $sort_url .= '&' . $key . '=' . urlencode($param); } } else { $sort_url = get_self_url(); } $hidden = build_keep_form_fields('_SELF', true); if ($selectors->is_empty()) { $sort = new ocp_tempcode(); } else { $sort = do_template('RESULTS_BROWSER_SORT', array('_GUID' => $guid, 'HASH' => $hash, 'HIDDEN' => $hidden, 'SORT' => $sort_name, 'RAND' => strval($GLOBALS['INCREMENTAL_ID_GENERATOR']), 'URL' => $sort_url, 'SELECTORS' => $selectors)); } $GLOBALS['INCREMENTAL_ID_GENERATOR']++; } else { $sort = new ocp_tempcode(); } // Results browser $browser = results_browser(is_object($text_id) ? $text_id : make_string_tempcode($text_id), NULL, $start, $start_name, $max, $max_name, $max_rows, NULL, get_param('type', 'misc'), true, true, $max_page_links, NULL, is_null($hash) ? '' : $hash); return do_template(is_null($tplset) ? 'RESULTS_TABLE' : 'RESULTS_' . $tplset . '_TABLE', array('_GUID' => $guid, 'TEXT_ID' => $text_id, 'FIELDS_TITLE' => $fields_title, 'FIELDS' => $fields, 'MESSAGE' => $message, 'SORT' => $skip_sortables_form ? new ocp_tempcode() : $sort, 'BROWSER' => $browser, 'WIDTHS' => $widths), NULL, false, 'RESULTS_TABLE'); }
/** * UI to show all orders * * @return tempcode The interface. */ function show_orders() { require_code('shopping'); $title = get_page_title('ORDER_LIST'); $filter = get_param('filter', NULL); $search = get_param('search', '', true); $cond = "WHERE 1=1"; if ($filter == 'undispatched') { $cond .= " AND t1.order_status='ORDER_STATUS_payment_received'"; $title = get_page_title('UNDISPATCHED_ORDER_LIST'); } $extra_join = ''; if (!is_null($search) && $search != '') { $GLOBALS['NO_DB_SCOPE_CHECK'] = true; $cond .= " AND (t1.id LIKE '" . db_encode_like(str_replace('#', '', $search) . '%') . "' OR t2.m_username LIKE '" . db_encode_like(str_replace('#', '', $search) . '%') . "')"; $extra_join = ' JOIN ' . get_table_prefix() . 'f_members t2 ON t2.id=t1.c_member'; } breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('ORDERS')))); $orders = array(); //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('t1.id' => do_lang_tempcode('ECOM_ORDER'), 't1.add_date' => do_lang_tempcode('ORDERED_DATE'), 't1.c_member' => do_lang_tempcode('ORDERED_BY'), 't1.tot_price' => do_lang_tempcode('ORDER_PRICE_AMT'), 't3.included_tax' => do_lang_tempcode('TAX_PAID'), 't1.order_status' => do_lang_tempcode('STATUS'), 't1.transaction_id' => do_lang_tempcode('TRANSACTION_ID')); $query_sort = explode(' ', get_param('sort', 't1.add_date ASC'), 2); if (count($query_sort) == 1) { $query_sort[] = 'ASC'; } list($sortable, $sort_order) = $query_sort; 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'; $fields_title = results_field_title(array(do_lang_tempcode('ECOM_ORDER'), do_lang_tempcode('THE_PRICE'), do_lang_tempcode('TAX_PAID'), do_lang_tempcode('ORDERED_DATE'), do_lang_tempcode('ORDERED_BY'), do_lang_tempcode('TRANSACTION_ID'), do_lang_tempcode('STATUS'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order); global $NO_DB_SCOPE_CHECK; $NO_DB_SCOPE_CHECK = true; $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'shopping_order t1' . $extra_join . ' LEFT JOIN ' . get_table_prefix() . 'shopping_order_details t3 ON t1.id=t3.order_id ' . $cond); $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 t1.*,(t3.p_quantity*t3.included_tax) as tax FROM ' . get_table_prefix() . 'shopping_order t1' . $extra_join . ' LEFT JOIN ' . get_table_prefix() . 'shopping_order_details t3 ON t1.id=t3.order_id ' . $cond . ' GROUP BY t1.id ORDER BY ' . db_string_equal_to('t1.order_status', 'ORDER_STATUS_cancelled') . ',' . $sortable . ' ' . $sort_order, $max, $start); $order_entries = new ocp_tempcode(); foreach ($rows as $row) { if ($row['purchase_through'] == 'cart') { $order_det_url = build_url(array('page' => '_SELF', 'type' => 'order_det', 'id' => $row['id']), '_SELF'); $order_title = do_lang('CART_ORDER', strval($row['id'])); } else { $res = $GLOBALS['SITE_DB']->query_select('shopping_order_details', array('p_id', 'p_name'), array('order_id' => $row['id'])); if (!array_key_exists(0, $res)) { continue; } // DB corruption $product_det = $res[0]; $order_title = do_lang('PURCHASE_ORDER', strval($row['id'])); $order_det_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $product_det['p_id']), get_module_zone('catalogues')); } $submitted_by = $GLOBALS['FORUM_DRIVER']->get_username($row['c_member']); $order_status = do_lang($row['order_status']); $ordr_act_submit = build_url(array('page' => '_SELF', 'type' => 'order_act', 'id' => $row['id']), '_SELF'); $actions = do_template('ADMIN_ORDER_ACTIONS', array('ORDER_TITLE' => $order_title, 'ORDR_ACT_URL' => $ordr_act_submit, 'ORDER_STATUS' => $order_status)); $url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $row['c_member']), get_module_zone('members')); $member = hyperlink($url, $submitted_by, false, true, do_lang('CUSTOMER')); $view_url = build_url(array('page' => '_SELF', 'type' => 'order_det', 'id' => $row['id']), '_SELF'); $order_date = hyperlink($view_url, get_timezoned_date($row['add_date'], true, false, true, true)); $transaction_details_link = build_url(array('page' => '_SELF', 'type' => 'order_det', 'id' => $row['id']), '_SELF'); if ($row['transaction_id'] != '') { $transaction_details_link = build_url(array('page' => 'admin_ecommerce', 'type' => 'logs', 'product' => $order_title, 'id' => $row['id']), get_module_zone('admin_ecommerce')); $transaction_id = hyperlink($transaction_details_link, strval($row['transaction_id'])); } else { $transaction_id = do_lang_tempcode('INCOMPLETED_TRANCACTION'); } $order_entries->attach(results_entry(array(escape_html($order_title), ecommerce_get_currency_symbol() . escape_html(float_format($row['tot_price'], 2)), escape_html(float_format($row['tax'], 2)), $order_date, $member, $transaction_id, $order_status, $actions), false, NULL)); } $width = array('110', '70', '80', '200', '120', '180', '180', '200'); $results_table = results_table(do_lang_tempcode('ORDERS'), 0, 'start', $max_rows, 'max', $max_rows, $fields_title, $order_entries, $sortables, $sortable, $sort_order, 'sort', NULL, $width, 'cart'); if (is_null($order_entries)) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $hidden = build_keep_form_fields('_SELF', true, array('filter')); $search_url = get_self_url(true); return do_template('ECOM_ADMIN_ORDERS_SCREEN', array('TITLE' => $title, 'CURRENCY' => get_option('currency'), 'ORDERS' => $orders, 'RESULTS_BROWSER' => $results_browser, 'RESULT_TABLE' => $results_table, 'SEARCH_URL' => $search_url, 'HIDDEN' => $hidden, 'SEARCH_VAL' => $search)); }
/** * The UI to run a multi-moderation. * * @return tempcode The UI */ function multimod() { $mm_id = intval(substr(get_param('type', 'misc'), 3)); $topic_id = get_param_integer('id'); $this->check_has_mod_access($topic_id); $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $topic_title = $topic_info[0]['t_cache_first_title']; $this->handle_topic_breadcrumbs($topic_info[0]['t_forum_id'], $topic_id, $topic_info[0]['t_cache_first_title'], do_lang_tempcode('_PERFORM_MULTI_MODERATION', escape_html($topic_title))); $title = get_page_title('_PERFORM_MULTI_MODERATION', true, array(escape_html($topic_title))); $mm = $GLOBALS['FORUM_DB']->query_select('f_multi_moderations', array('*'), array('id' => $mm_id), '', 1); if (!array_key_exists(0, $mm)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $_mm = $mm[0]; $post_text = $_mm['mm_post_text']; $submit_name = do_lang_tempcode('PERFORM_MULTI_MODERATION'); $post_url = build_url(array('page' => '_SELF', 'type' => '_multimod', 'id' => $topic_id, 'mm_id' => $mm_id), '_SELF', NULL, true); $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); $hidden->attach(build_keep_post_fields()); $hidden->attach(build_keep_form_fields()); $fields->attach(form_input_text(do_lang_tempcode('MM_POST_TEXT'), do_lang_tempcode('DESCRIPTION_MM_POST_TEXT'), 'post_text', $post_text, false)); $options = array(); if (get_value('disable_skip_sig') !== '1') { if (addon_installed('ocf_signatures')) { $options[] = array(do_lang_tempcode('SKIP_SIGNATURE'), 'skip_sig', false, do_lang_tempcode('DESCRIPTION_SKIP_SIGNATURE')); } } if (get_value('disable_post_emphasis') !== '1') { $options[] = array(do_lang_tempcode('EMPHASISED'), 'is_emphasised', true, do_lang_tempcode('DESCRIPTION_EMPHASISED')); } $fields->attach(form_input_various_ticks($options, '')); $fields->attach(form_input_line(do_lang_tempcode('REASON'), do_lang_tempcode('OPTIONAL_REASON'), 'reason', '', false)); $mm_title = get_translated_text($_mm['mm_name'], $GLOBALS['FORUM_DB']); $action_list = new ocp_tempcode(); if ($_mm['mm_open_state'] == 1) { $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_OPEN')); } if ($_mm['mm_open_state'] == 0) { $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_CLOSE')); } if ($_mm['mm_pin_state'] == 1) { $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_PIN')); } if ($_mm['mm_pin_state'] == 0) { $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_UNPIN')); } if ($_mm['mm_sink_state'] == 1) { $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_SINK')); } if ($_mm['mm_sink_state'] == 0) { $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_UNSINK')); } if ($_mm['mm_title_suffix'] != '') { $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_TITLE_SUFFIX', escape_html($_mm['mm_title_suffix']))); } if (!is_null($_mm['mm_move_to'])) { $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_MOVE', ocf_forum_breadcrumbs($_mm['mm_move_to']))); } $action_list->attach(do_lang_tempcode('MULTI_MODERATION_WILL_POST')); $text = do_lang_tempcode('MULTI_MODERATION_WILL', make_string_tempcode($mm_title), $action_list); return do_template('FORM_SCREEN', array('_GUID' => '2eef0c445d207bb10ff3fd28ea32ef8c', 'STAFF_HELP_URL' => brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_forum_helpdesk', 'PREVIEW' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); }
/** * Get the tempcode for a results browser. * * @param tempcode The title/name of the resource we are browsing through * @param ?mixed The category ID we are browsing in (NULL: not applicable) * @param integer The current position in the browser * @param ID_TEXT The parameter name used to store our position in the results (usually, 'start') * @param integer The maximum number of rows to show per browser page * @param ID_TEXT The parameter name used to store the total number of results to show per-page (usually, 'max') * @param integer The maximum number of rows in the entire dataset * @param ?mixed The virtual root category this browser uses (NULL: no such concept for our results browser) * @param ?ID_TEXT The page type this browser is browsing through (e.g. 'category') (NULL: none) * @param boolean Whether to keep get data when browsing through * @param boolean Whether to keep post data when browsing through * @param integer The maximum number of quick-jump page links to show * @param ?array List of per-page selectors to show (NULL: show hard-coded ones) * @param ID_TEXT Hash component to URL * @return tempcode The results browser */ function results_browser($title, $category_id, $start, $start_name, $max, $max_name, $max_rows, $root = NULL, $type = NULL, $keep_all = false, $keep_post = false, $max_page_links = 7, $_selectors = NULL, $hash = '') { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = $max_name; $post_array = array(); if ($keep_post) { foreach ($_POST as $key => $val) { if (is_array($val)) { continue; } if (get_magic_quotes_gpc()) { $val = stripslashes($val); } $post_array[$key] = $val; } } if ($max < $max_rows) { $part = new ocp_tempcode(); if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) { $get_url = find_script('iframe'); } else { $get_url = get_base_url() . (get_zone_name() == '' ? '' : '/') . get_zone_name() . '/index.php'; } $num_pages = $max == 0 ? 1 : intval(ceil(floatval($max_rows) / floatval($max))); // How many to show per page if (is_null($_selectors)) { $_selectors = array(10, 25, 50, 80); } if (has_specific_permission(get_member(), 'remove_page_split')) { $_selectors[] = $max_rows; } $_selectors[] = $max; sort($_selectors); $_selectors = array_unique($_selectors); $selectors = new ocp_tempcode(); foreach ($_selectors as $selector_value) { if ($selector_value > $max_rows) { $selector_value = $max_rows; } $selected = $max == $selector_value; $selectors->attach(do_template('RESULTS_BROWSER_PER_PAGE_OPTION', array('_GUID' => '1a0583bab42257c60289459ce1ac1e05', 'SELECTED' => $selected, 'VALUE' => strval($selector_value), 'NAME' => integer_format($selector_value)))); if ($selector_value == $max_rows) { break; } } $hidden = build_keep_form_fields('_SELF', true, array($max_name, 'wide_high', $start_name)); $per_page = do_template('RESULTS_BROWSER_PER_SCREEN', array('_GUID' => '1993243727e58347d1544279c5eba496', 'HASH' => $hash == '' ? NULL : $hash, 'HIDDEN' => $hidden, 'URL' => $get_url, 'MAX_NAME' => $max_name, 'SELECTORS' => $selectors, 'RAND' => strval($GLOBALS['INCREMENTAL_ID_GENERATOR']))); $GLOBALS['INCREMENTAL_ID_GENERATOR']++; // Link to first if ($start > 0) { $url_array = array('page' => '_SELF', $start_name => NULL); $cat_url = _build_results_browser_cat_url($url_array, $post_array, $type, $root, $category_id, $keep_all, $hash); $part->attach(do_template('RESULTS_BROWSER_CONTINUE_FIRST', array('TITLE' => $title, 'P' => strval(1), 'FIRST_URL' => $cat_url))); } // Link to previous if ($start > 0) { $url_array = array('page' => '_SELF', $start_name => strval(max($start - $max, 0))); $cat_url = _build_results_browser_cat_url($url_array, $post_array, $type, $root, $category_id, $keep_all, $hash); $part->attach(do_template('RESULTS_BROWSER_PREVIOUS_LINK', array('_GUID' => 'ec4d4da9677b5b9c8cea08676337c6eb', 'TITLE' => $title, 'P' => integer_format(intval($start / $max)), 'URL' => $cat_url))); } else { $part->attach(do_template('RESULTS_BROWSER_PREVIOUS')); } // CALCULATIONS FOR CROPPING OF SEQUENCE // $from is the index number (one less than written page number) we start showing page links from // $to is the index number (one less than written page number) we stop showing page links from if ($max != 0) { $max_dispersal = $max_page_links / 2; $from = max(0, intval(floatval($start) / floatval($max) - $max_dispersal)); $to = intval(ceil(min(floatval($max_rows) / floatval($max), floatval($start) / floatval($max) + $max_dispersal))); $dif = floatval($start) / floatval($max) - $max_dispersal; if ($dif < 0.0) { $to = intval(ceil(min(floatval($max_rows) / floatval($max), floatval($start) / floatval($max) + $max_dispersal - $dif))); } } else { $from = 0; $to = 0; } // Indicate that the sequence is incomplete with an ellipsis if ($from > 0) { $part->attach(do_template('RESULTS_BROWSER_CONTINUE')); } // Show the page number jump links for ($x = $from; $x < $to; $x++) { $url_array = array('page' => '_SELF', $start_name => $x == 0 ? NULL : strval($x * $max)); $cat_url = _build_results_browser_cat_url($url_array, $post_array, $type, $root, $category_id, $keep_all, $hash); if ($x * $max == $start) { $part->attach(do_template('RESULTS_BROWSER_PAGE_NUMBER', array('_GUID' => '13cdaf548d5486fb8d8ae0d23b6a08ec', 'P' => strval($x + 1)))); } else { $rel = NULL; if ($x == 0) { $rel = 'first'; } $part->attach(do_template('RESULTS_BROWSER_PAGE_NUMBER_LINK', array('_GUID' => 'a6d1a0ba93e3b7deb6fe6f8f1c117c0f', 'REL' => $rel, 'TITLE' => $title, 'URL' => $cat_url, 'P' => strval($x + 1)))); } } // Indicate that the sequence is incomplete with an ellipsis if ($to < $num_pages) { $part->attach(do_template('RESULTS_BROWSER_CONTINUE')); } // Link to next if ($start + $max < $max_rows) { $url_array = array('page' => '_SELF', $start_name => strval($start + $max)); $cat_url = _build_results_browser_cat_url($url_array, $post_array, $type, $root, $category_id, $keep_all, $hash); $p = $max == 0 ? 1.0 : $start / $max + 2; $rel = NULL; if ($start + $max * 2 > $max_rows) { $rel = 'last'; } $part->attach(do_template('RESULTS_BROWSER_NEXT_LINK', array('_GUID' => '6da9b396bdd46b7ee18c05b5a7eb4d10', 'REL' => $rel, 'TITLE' => $title, 'NUM_PAGES' => integer_format($num_pages), 'P' => integer_format(intval($p)), 'URL' => $cat_url))); } else { $part->attach(do_template('RESULTS_BROWSER_NEXT')); } // Link to last if ($start + $max < $max_rows) { $url_array = array('page' => '_SELF', $num_pages - 1 == 0 ? NULL : $start_name => strval(($num_pages - 1) * $max)); $cat_url = _build_results_browser_cat_url($url_array, $post_array, $type, $root, $category_id, $keep_all, $hash); $part->attach(do_template('RESULTS_BROWSER_CONTINUE_LAST', array('_GUID' => '2934936df4ba90989e949a8ebe905522', 'TITLE' => $title, 'P' => strval($num_pages), 'LAST_URL' => $cat_url))); } // Page jump dropdown, if we had to crop if ($num_pages > $max_page_links) { $list = new ocp_tempcode(); $pg_start = 0; $pg_to = $num_pages; $pg_at = intval(floatval($start) / floatval($max)); if ($pg_to > 100) { $pg_start = max($pg_at - 50, 0); $pg_to = $pg_start + 100; } if ($pg_start != 0) { $list->attach(form_input_list_entry('', false, '...', false, true)); } for ($i = $pg_start; $i < $pg_to; $i++) { $list->attach(form_input_list_entry(strval($i * $max), $i * $max == $start, strval($i + 1))); } if ($pg_to != $num_pages) { $list->attach(form_input_list_entry('', false, '...', false, true)); } if ($keep_all) { $dont_auto_keep = array($start_name, 'type', 'wide_high'); if (!is_null($category_id)) { $dont_auto_keep[] = 'id'; } $hidden = build_keep_form_fields('_SELF', true, $dont_auto_keep); if (!is_null($category_id)) { $hidden->attach(form_input_hidden('id', is_integer($category_id) ? strval($category_id) : $category_id)); } if (!is_null($type)) { $hidden->attach(form_input_hidden('type', $type)); } } else { $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden($max_name, strval($max))); $hidden->attach(form_input_hidden('page', get_page_name())); $hidden->attach(form_input_hidden('type', $type)); } $part->attach(do_template('RESULTS_BROWSER_LIST_PAGES', array('_GUID' => '9e1b394763619433f23b8ed95f5ac134', 'RAND' => strval($GLOBALS['INCREMENTAL_ID_GENERATOR']), 'URL' => $get_url, 'HIDDEN' => $hidden, 'START_NAME' => $start_name, 'LIST' => $list))); } // Put it all together return do_template('RESULTS_BROWSER_WRAP', array('_GUID' => '2c3fc957d4d8ab9103ef26458e18aed1', 'TEXT_ID' => $title, 'PER_PAGE' => $per_page, 'PART' => $part)); } return new ocp_tempcode(); }
/** * The UI to choose what to import. * * @param mixed Output to show from last action (blank: none) * @return tempcode The UI */ function choose_actions($extra = '') { $title = get_page_title('IMPORT'); $session = either_param_integer('session', get_session_id()); $importer = filter_naughty(get_param('importer')); require_code('hooks/modules/admin_import/' . filter_naughty_harsh($importer)); $object = object_factory('Hook_' . filter_naughty_harsh($importer)); // Test import source is good if (method_exists($object, 'probe_db_access')) { list($db_name, $db_user, $db_password, $db_table_prefix) = $object->probe_db_access(either_param('old_base_dir')); } else { $db_name = either_param('db_name'); $db_user = either_param('db_user'); $db_password = either_param('db_password'); $db_table_prefix = either_param('db_table_prefix'); } if ($db_name == get_db_site() && $importer == 'ocp_merge' && $db_table_prefix == $GLOBALS['SITE_DB']->get_table_prefix()) { warn_exit(do_lang_tempcode('IMPORT_SELF_NO')); } $import_source = is_null($db_name) ? NULL : new database_driver($db_name, get_db_site_host(), $db_user, $db_password, $db_table_prefix); unset($import_source); $lang_array = array(); $hooks = find_all_hooks('modules', 'admin_import_types'); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/admin_import_types/' . filter_naughty_harsh($hook)); $_hook = object_factory('Hook_admin_import_types_' . filter_naughty_harsh($hook)); $lang_array += $_hook->run(); } $info = $object->info(); $session_row = $GLOBALS['SITE_DB']->query_select('import_session', array('*'), array('imp_session' => get_session_id()), '', 1); if (array_key_exists(0, $session_row)) { $old_base_dir = $session_row[0]['imp_old_base_dir']; $db_name = $session_row[0]['imp_db_name']; $db_user = $session_row[0]['imp_db_user']; $db_table_prefix = $session_row[0]['imp_db_table_prefix']; $refresh_time = $session_row[0]['imp_refresh_time']; } else { $old_base_dir = get_file_base() . '/old'; $db_name = get_db_site(); $db_user = get_db_site_user(); $db_table_prefix = array_key_exists('prefix', $info) ? $info['prefix'] : $GLOBALS['SITE_DB']->get_table_prefix(); $refresh_time = 15; } $_import_list = $info['import']; $_import_list_2 = array(); foreach ($_import_list as $import) { if (is_null($import)) { continue; } if (!array_key_exists($import, $lang_array)) { continue; } if (is_null($lang_array[$import])) { continue; } $text = do_lang(strtolower($lang_array[$import]) != $lang_array[$import] ? $lang_array[$import] : strtoupper($lang_array[$import])); $_import_list_2[$import] = $text; } if (array_key_exists('ocf_members', $_import_list_2) && get_forum_type() == $importer && $db_name == get_db_forums() && $db_table_prefix == $GLOBALS['FORUM_DB']->get_table_prefix()) { $_import_list_2['ocf_switch'] = do_lang_tempcode('SWITCH_TO_OCF'); } $import_list = new ocp_tempcode(); // asort($_import_list_2); Let's preserve order here $just = get_param('just', NULL); $first = true; $skip_hidden = array(); $parts_done = collapse_2d_complexity('imp_id', 'imp_session', $GLOBALS['SITE_DB']->query_select('import_parts_done', array('imp_id', 'imp_session'), array('imp_session' => get_session_id()))); foreach ($_import_list_2 as $import => $text) { if (array_key_exists($import, $parts_done)) { $import_list->attach(do_template('IMPORT_ACTION_LINE', array('CHECKED' => false, 'DISABLED' => true, 'NAME' => 'import_' . $import, 'TEXT' => $text, 'ADVANCED_URL' => $info['supports_advanced_import'] ? build_url(array('page' => '_SELF', 'type' => 'advanced_hook', 'session' => $session, 'content_type' => $import, 'importer' => $importer), '_SELF') : new ocp_tempcode()))); } else { $checked = is_null($just) && $first; $import_list->attach(do_template('IMPORT_ACTION_LINE', array('_GUID' => 'f2215115f920200a0a1ba6bc776ad945', 'CHECKED' => $checked, 'NAME' => 'import_' . $import, 'TEXT' => $text, 'ADVANCED_URL' => $info['supports_advanced_import'] ? build_url(array('page' => '_SELF', 'type' => 'advanced_hook', 'session' => $session, 'content_type' => $import, 'importer' => $importer), '_SELF') : new ocp_tempcode()))); } if ($just == $import) { $first = true; $just = NULL; } else { $first = false; } $skip_hidden[] = 'import_' . $import; } $message = array_key_exists('message', $info) ? $info['message'] : ''; if (count($parts_done) == count($_import_list_2)) { inform_exit(do_lang_tempcode($message === '' ? '_IMPORT_ALL_FINISHED' : 'IMPORT_ALL_FINISHED', $message)); } $url = build_url(array('page' => '_SELF', 'type' => 'import', 'session' => $session, 'importer' => $importer), '_SELF'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('IMPORT')), array('_SELF:_SELF:session:importer=' . $importer, do_lang_tempcode('IMPORT_SESSION')))); $hidden = new ocp_tempcode(); $hidden->attach(build_keep_post_fields($skip_hidden)); $hidden->attach(build_keep_form_fields('', true)); return do_template('IMPORT_ACTION_SCREEN', array('_GUID' => 'a3a69637e541923ad76e9e7e6ec7e1af', 'EXTRA' => $extra, 'MESSAGE' => $message, 'TITLE' => $title, 'FIELDS' => '', 'HIDDEN' => $hidden, 'IMPORTER' => $importer, 'IMPORT_LIST' => $import_list, 'URL' => $url)); }
/** * The actualiser to move a page. * * @return tempcode The UI */ function _move() { $title = get_page_title('MOVE_PAGES'); if (get_file_base() != get_custom_file_base()) { warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); } $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/move'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure'; $zone = post_param('zone', NULL); if (is_null($zone)) { $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true); $hidden = build_keep_form_fields('', true); return do_template('YESNO_SCREEN', array('_GUID' => 'c6e872cc62bdc7cf1c5157fbfdb2dfd6', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('Q_SURE'), 'URL' => $post_url, 'HIDDEN' => $hidden)); } $new_zone = post_param('destination_zone', ''); if (substr($new_zone, -1) == ':') { $new_zone = substr($new_zone, 0, strlen($new_zone) - 1); } //$pages=find_all_pages_wrap($zone); $pages = array(); require_code('site'); foreach ($_POST as $key => $val) { if (substr($key, 0, 6) == 'page__' && $val === '1') { $page = substr($key, 6); $page_details = _request_page($page, $zone, NULL, NULL, true); if ($page_details === false) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $pages[$page] = strtolower($page_details[0]); if (array_key_exists(3, $page_details)) { $pages[$page] .= '/' . $page_details[3]; } } } $afm_needed = false; foreach ($pages as $page => $type) { if (post_param_integer('page__' . $page, 0) == 1) { if ($type != 'comcode_custom') { $afm_needed = true; } } } if ($afm_needed) { require_code('abstract_file_manager'); force_have_afm_details(); } $cannot_move = new ocp_tempcode(); foreach ($pages as $page => $type) { if (!is_string($page)) { $page = strval($page); } if (post_param_integer('page__' . $page, 0) == 1) { if (substr($type, 0, 7) == 'modules') { $_page = $page . '.php'; } elseif (substr($type, 0, 7) == 'comcode') { $_page = $page . '.txt'; } elseif (substr($type, 0, 4) == 'html') { $_page = $page . '.htm'; } if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) { if (!$cannot_move->is_empty()) { $cannot_move->attach(do_lang_tempcode('LIST_SEP')); } $cannot_move->attach(do_lang_tempcode('PAGE_WRITE', escape_html($page))); continue; } } } $moved_something = NULL; foreach ($pages as $page => $type) { if (!is_string($page)) { $page = strval($page); } if (post_param_integer('page__' . $page, 0) == 1) { $moved_something = $page; if (substr($type, 0, 7) == 'modules') { $_page = $page . '.php'; } elseif (substr($type, 0, 7) == 'comcode') { $_page = $page . '.txt'; } elseif (substr($type, 0, 4) == 'html') { $_page = $page . '.htm'; } if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) { continue; } if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) { if ($afm_needed) { afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true)); } else { rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page)); } } // If a non-overridden one is there too, need to move that too if (strpos($type, '_custom') !== false && file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page)) && !file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page))) { if ($afm_needed) { afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true)); } else { rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page)); } } log_it('MOVE_PAGES', $page); } } if (is_null($moved_something)) { warn_exit(do_lang_tempcode('NOTHING_SELECTED')); } persistant_cache_empty(); require_lang('addons'); if ($cannot_move->is_empty()) { $message = do_lang_tempcode('SUCCESS'); } else { $message = do_lang_tempcode('WOULD_NOT_OVERWRITE_BUT_SUCCESS', $cannot_move); } breadcrumb_set_self(do_lang_tempcode('DONE')); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:move', do_lang_tempcode('MOVE_PAGES')))); decache('main_sitemap'); if (has_js()) { return inform_screen($title, $message); // Came from site-tree editor, so want to just close this window when done } return $this->do_next_manager($title, $moved_something, $new_zone, new ocp_tempcode()); }
/** * The UI to choose a page to edit. * * @return tempcode The UI */ function ed() { $title = get_page_title('COMCODE_PAGE_EDIT'); $lang = choose_language($title, true); if (is_object($lang)) { return $lang; } require_code('form_templates'); $add_new_permission = has_specific_permission(get_member(), 'submit_highrange_content'); if (!$add_new_permission && !has_specific_permission(get_member(), 'edit_highrange_content') && !has_specific_permission(get_member(), 'edit_own_highrange_content')) { check_edit_permission('high', NULL); } $fields = new ocp_tempcode(); if ($add_new_permission) { $fields->attach(form_input_line(do_lang_tempcode('NEW'), do_lang_tempcode('DESCRIPTION_NEW_COMCODE_PAGE'), 'page_link_2', '', true)); $submit_name = do_lang_tempcode('ADD'); } else { $submit_name = NULL; } $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('lang', $lang)); $hidden->attach(form_input_hidden('type', '_ed')); $hidden->attach(build_keep_form_fields('_SELF')); $map = array('page' => '_SELF', 'type' => '_ed', 'lang' => $lang); $post_url = build_url($map, '_SELF', NULL, false, true); breadcrumb_set_self(do_lang_tempcode('CHOOSE')); $search_url = build_url(array('page' => 'search', 'id' => 'comcode_pages'), get_module_zone('search')); $sitemap_zone = get_page_zone('sitemap', false); if ($sitemap_zone !== NULL) { $archive_url = build_url(array('page' => 'sitemap'), $sitemap_zone); } else { $archive_url = build_url(array('page' => ''), ''); } $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($search_url->evaluate()), escape_html($archive_url->evaluate()))); if (addon_installed('page_management')) { if (has_actual_page_access(get_member(), 'admin_sitetree')) { $page_wizard = build_url(array('page' => 'admin_sitetree', 'type' => 'pagewizard'), get_module_zone('admin_sitetree')); $site_tree_editor = build_url(array('page' => 'admin_sitetree', 'type' => 'site_tree'), get_module_zone('admin_sitetree')); attach_message(do_lang_tempcode('SUGGEST_PAGE_WIZARD', escape_html($page_wizard->evaluate()), escape_html($site_tree_editor->evaluate())), 'inform'); } } require_code('templates_results_table'); $current_ordering = get_param('sort', 'page_title ASC'); if (strpos($current_ordering, ' ') === false) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } list($sortable, $sort_order) = explode(' ', $current_ordering, 2); $sortables = array('page_title' => do_lang_tempcode('TITLE'), 'page' => do_lang_tempcode('PAGE'), 'zone_name' => do_lang_tempcode('ZONE'), 'pagelink' => do_lang_tempcode('PAGE_LINK')); 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('PAGE'), do_lang_tempcode('ZONE'), do_lang_tempcode('PAGE_LINK'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $all_zones = find_all_zones(false, true); $number_pages_parsed_for_titles = 0; $GLOBALS['NO_QUERY_LIMIT'] = true; $start = get_param_integer('start', 0); $max = get_param_integer('max', 50); $filesarray = $this->get_comcode_files_array($lang); if (count($filesarray) >= 300) { $orderer = 'p_add_date ASC'; switch ($sortable) { case 'page_title': $orderer = 't.text_original ' . $sort_order; break; case 'page': $orderer = 'c.the_page ' . $sort_order; break; case 'zone_name': $orderer = 'c.the_zone ' . $sort_order; break; case 'pagelink': $orderer = 'c.the_zone ' . $sort_order . ',c.the_page ' . $sort_order; break; } $group_by = ''; if (can_arbitrary_groupby()) { $group_by = 'GROUP BY c.the_zone,c.the_page'; } $where_map = '(' . db_string_equal_to('language', $lang) . ' OR language IS NULL)'; if (!has_specific_permission(get_member(), 'edit_highrange_content')) { $where_map .= ' AND submitter=' . strval(get_member()); } $ttable = get_table_prefix() . 'comcode_pages c LEFT JOIN ' . get_table_prefix() . 'cached_comcode_pages a ON c.the_page=a.the_page AND c.the_zone=a.the_zone LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=a.cc_page_title'; $page_rows = $GLOBALS['SITE_DB']->query('SELECT c.*,cc_page_title FROM ' . $ttable . ' WHERE ' . $where_map . $group_by . ' ORDER BY ' . $orderer, $max, $start); $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(DISTINCT c.the_zone,c.the_page) FROM ' . $ttable . ' WHERE ' . $where_map); $filesarray = array(); foreach ($page_rows as $row) { $located = _request_page($row['the_page'], $row['the_zone'], NULL, $lang); if ($located !== false) { $filesarray[$row['the_zone'] . ':' . $row['the_page']] = array($row['the_zone'] . '/pages/' . strtolower($located[0]) . '/' . $row['the_page'], NULL, $row); } } $found_via_query = true; } else { $max_rows = 0; ksort($filesarray); $found_via_query = false; } // Render table rows $_table_rows = array(); foreach ($filesarray as $pagelink => $path_bits) { list($zone, $page) = explode(':', $pagelink, 2); if (!is_string($page)) { $page = strval($page); } $edit_link = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $pagelink, 'lang' => $lang), '_SELF'); $clone_link = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':', 'restore_from' => $path_bits[0] . '.txt', 'lang' => $lang), '_SELF'); $zone_name = array_key_exists($zone, $all_zones) ? $all_zones[$zone][1] : $zone; // We need to separately read from DB to work out meta data? $row = mixed(); if (!array_key_exists(2, $path_bits)) { $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages c LEFT JOIN ' . get_table_prefix() . 'cached_comcode_pages a ON c.the_page=a.the_page AND c.the_zone=a.the_zone', array('c.*', 'cc_page_title'), array('c.the_zone' => $zone, 'c.the_page' => $page), '', 1); if (!array_key_exists(0, $rows) && $number_pages_parsed_for_titles < 15) { $result = request_page($page, false, $zone, 'comcode_custom', true); $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages c LEFT JOIN ' . get_table_prefix() . 'cached_comcode_pages a ON c.the_page=a.the_page AND c.the_zone=a.the_zone', array('c.*', 'cc_page_title'), array('c.the_zone' => $zone, 'c.the_page' => $page), '', 1); $number_pages_parsed_for_titles++; } $row = array_key_exists(0, $rows) ? $rows[0] : NULL; } else { $row = $path_bits[2]; } // Work out meta data $page_title = do_lang_tempcode('NA_EM'); if (!is_null($row)) { $username = protect_from_escaping($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['p_submitter'])); $parent_page = $row['p_parent_page']; $add_date = get_timezoned_date($row['p_add_date']); $validated = $row['p_validated'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('YES'); if (!is_null($row['cc_page_title'])) { $_page_title = get_translated_text($row['cc_page_title'], NULL, NULL, true); if (!is_null($_page_title)) { if ($_page_title != '') { $page_title = make_string_tempcode($_page_title); } } } } else { $username = do_lang('UNKNOWN'); $parent_page = ''; $add_date = get_timezoned_date(filectime(get_file_base() . '/index.php')); $validated = do_lang_tempcode('YES'); } $wrappable_pagelink = preg_replace('#([^ ]):([\\w\\-]{10,})$#', '${1}: ${2}', preg_replace('#(^[\\w\\-]{10,}):#', '${1}: ', $pagelink)); $actions = do_template('COMCODE_PAGE_EDIT_ACTIONS', array('EDIT_URL' => $edit_link, 'CLONE_URL' => $clone_link)); $_table_rows[] = array('page_title' => $page_title, 'page' => $page, 'zone' => $zone, 'zone_name' => $zone_name, 'pagelink' => $pagelink, 'wrappable_pagelink' => $wrappable_pagelink, 'actions' => $actions); } // Manual sorting global $M_SORT_KEY; $M_SORT_KEY = $sortable; usort($_table_rows, 'multi_sort'); if ($sort_order == 'DESC') { $_table_rows = array_reverse($_table_rows); } $table_rows = new ocp_tempcode(); if (!$found_via_query) { $max_rows = count($_table_rows); } foreach ($_table_rows as $i => $table_row) { if (!$found_via_query) { if ($i < $start) { continue; } if ($i > $max + $start) { break; } } $table_rows->attach(results_entry(array(protect_from_escaping(hyperlink(build_url(array('page' => $table_row['page']), $table_row['zone']), $table_row['page_title'])), protect_from_escaping(do_template('COMCODE_TELETYPE', array('CONTENT' => preg_replace('#([\\w\\d\\_]{22})#', '${1}<br />', escape_html($table_row['page']))))), protect_from_escaping(hyperlink(build_url(array('page' => ''), $table_row['zone']), $table_row['zone_name'], false, true)), protect_from_escaping(do_template('COMCODE_TELETYPE', array('CONTENT' => preg_replace('#([\\w\\d\\_]{22})#', '${1}<br />', escape_html($table_row['wrappable_pagelink']))))), protect_from_escaping($table_row['actions'])), true)); } $table = results_table(do_lang('COMCODE_PAGES'), $start, 'start', $max, 'max', $max_rows, $header_row, $table_rows, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, NULL, 8, 'fdgfdfdfdggfd', true); return do_template('TABLE_TABLE_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'TABLE' => $table, 'FIELDS' => $fields, 'POST_URL' => $post_url, 'GET' => true, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => $submit_name)); }
/** * The UI to show the member directory. * * @return tempcode The UI */ function directory() { require_javascript('javascript_ajax'); require_javascript('javascript_ajax_people_lists'); $title = get_page_title('MEMBERS'); require_code('templates_internalise_screen'); $test_tpl = internalise_own_screen($title); if (is_object($test_tpl)) { return $test_tpl; } if (running_script('iframe')) { $get_url = find_script('iframe'); } else { $get_url = find_script('index'); } $hidden = new ocp_tempcode(); $hidden->attach(build_keep_form_fields('_SELF', true, array('filter'))); $hidden->attach(form_input_hidden('zone', get_zone_name())); $start = get_param_integer('md_start', 0); $max = get_param_integer('md_max', 50); $sortables = array('m_username' => do_lang_tempcode('USERNAME'), 'm_primary_group' => do_lang_tempcode('PRIMARY_GROUP'), 'm_cache_num_posts' => do_lang_tempcode('COUNT_POSTS'), 'm_join_time' => do_lang_tempcode('JOIN_DATE')); $default_sort_order = get_value('md_default_sort_order'); if (is_null($default_sort_order)) { $default_sort_order = 'm_join_time DESC'; } $test = explode(' ', get_param('md_sort', $default_sort_order), 2); if (count($test) == 1) { $test[] = 'ASC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'md_sort'; $group_filter = get_param('group_filter', ''); $_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, $group_filter == '' ? NULL : array(intval($group_filter))); $usergroups = array(); require_code('ocf_groups2'); foreach ($_usergroups as $group_id => $group) { $num = ocf_get_group_members_raw_count($group_id, true); $usergroups[$group_id] = array('USERGROUP' => $group, 'NUM' => strval($num)); } $query = 'FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id()); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $query .= ' AND m_validated=1'; } if ($group_filter != '') { if (is_numeric($group_filter)) { $title = get_page_title('USERGROUP', true, array(escape_html($usergroups[intval($group_filter)]['USERGROUP']))); } require_code('ocfiltering'); $filter = ocfilter_to_sqlfragment($group_filter, 'm_primary_group', 'f_groups', NULL, 'm_primary_group', 'id'); $query .= ' AND ' . $filter; } $search = get_param('filter', ''); $sup = $search != '' ? ' AND m_username LIKE \'' . db_encode_like(str_replace('*', '%', $search)) . '\'' : ''; if ($sortable == 'm_join_time') { $query .= $sup . ' ORDER BY m_join_time ' . $sort_order . ',' . 'id ' . $sort_order; } else { $query .= $sup . ' ORDER BY ' . $sortable . ' ' . $sort_order; } $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query); $rows = $GLOBALS['FORUM_DB']->query('SELECT * ' . $query, $max, $start); if (count($rows) == 0) { return inform_screen($title, do_lang_tempcode('NO_RESULTS')); } $members = new ocp_tempcode(); $member_boxes = array(); require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('PRIMARY_GROUP'), do_lang_tempcode('COUNT_POSTS'), do_lang_tempcode('JOIN_DATE')), $sortables, 'md_sort', $sortable . ' ' . $sort_order); require_code('ocf_members2'); foreach ($rows as $row) { $link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['id'], true, $row['m_username']); if ($row['m_validated'] == 0) { $link->attach(do_lang_tempcode('MEMBER_IS_UNVALIDATED')); } if ($row['m_validated_email_confirm_code'] != '') { $link->attach(do_lang_tempcode('MEMBER_IS_UNCONFIRMED')); } $member_primary_group = ocf_get_member_primary_group($row['id']); $primary_group = ocf_get_group_link($member_primary_group); $members->attach(results_entry(array($link, $primary_group, escape_html(integer_format($row['m_cache_num_posts'])), escape_html(get_timezoned_date($row['m_join_time']))))); $member_boxes[] = ocf_show_member_box($row['id'], true); } $results_table = results_table(do_lang_tempcode('MEMBERS'), $start, 'md_start', $max, 'md_max', $max_rows, $fields_title, $members, $sortables, $sortable, $sort_order, 'md_sort'); $results_browser = results_browser(do_lang_tempcode('MEMBERS'), NULL, $start, 'md_start', $max, 'md_max', $max_rows, NULL, NULL, true, true); $symbols = NULL; if (get_option('allow_alpha_search') == '1') { $alpha_query = $GLOBALS['FORUM_DB']->query('SELECT m_username FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id()) . ' ORDER BY m_username ASC'); $symbols = array(array('START' => '0', 'SYMBOL' => do_lang('ALL')), array('START' => '0', 'SYMBOL' => '#')); foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z') as $s) { foreach ($alpha_query as $i => $q) { if (strtolower(substr($q['m_username'], 0, 1)) == $s) { break; } } if (substr(strtolower($q['m_username']), 0, 1) != $s) { $i = intval($symbols[count($symbols) - 1]['START']); } $symbols[] = array('START' => strval(intval($max * floor(floatval($i) / floatval($max)))), 'SYMBOL' => $s); } } return do_template('OCF_MEMBER_DIRECTORY_SCREEN', array('_GUID' => '096767e9aaabce9cb3e6591b7bcf95b8', 'MAX' => strval($max), 'RESULTS_BROWSER' => $results_browser, 'MEMBER_BOXES' => $member_boxes, 'USERGROUPS' => $usergroups, 'HIDDEN' => $hidden, 'SYMBOLS' => $symbols, 'SEARCH' => $search, 'GET_URL' => $get_url, 'TITLE' => $title, 'RESULTS_TABLE' => $results_table)); }
function form() { $title = get_page_title('REPORT_CONTENT'); require_code('form_templates'); $url = get_param('url', false, true); $content_type = get_param('content_type'); // Equates to a content_meta_aware hook $content_id = get_param('content_id'); require_code('content'); if (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('reported_content', 'r_counts', array('r_session_id' => get_session_id(), 'r_content_type' => $content_type, 'r_content_id' => $content_id)))) { warn_exit(do_lang_tempcode('ALREADY_REPORTED_CONTENT')); } list($content_title, $poster_id, ) = content_get_details($content_type, $content_id); if ($content_title == '') { $content_title = $content_type . ' #' . $content_id; } $poster = $GLOBALS['FORUM_DRIVER']->get_username($poster_id); // Show form with input field and CAPTCHA, like forum's report post... $member = $poster; if (!is_guest($poster_id)) { $member = '[page type="view" id="' . strval($poster_id) . '" param="' . get_module_zone('members') . '" caption="' . $poster . '"]members[/page]'; } $hidden_fields = build_keep_form_fields('', true); $text = paragraph(do_lang_tempcode('DESCRIPTION_REPORT_CONTENT', escape_html($content_title), escape_html(integer_format(intval(get_option('reported_times')))))); $specialisation = new ocp_tempcode(); if (!is_guest()) { $options = array(); if (get_option('is_on_anonymous_posts') == '1') { $options[] = array(do_lang_tempcode('_MAKE_ANONYMOUS_POST'), 'anonymous', false, do_lang_tempcode('MAKE_ANONYMOUS_POST_DESCRIPTION')); } $specialisation = form_input_various_ticks($options, ''); } else { $specialisation = new ocp_tempcode(); } if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $specialisation->attach(form_input_captcha()); $text->attach(paragraph(do_lang_tempcode('FORM_TIME_SECURITY'))); } } if (addon_installed('points')) { $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login')); $_login_url = escape_html($login_url->evaluate()); if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) { $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url))); } } $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF'); $post = do_template('REPORTED_CONTENT_FCOMCODE', array('URL' => $url, 'CONTENT_ID' => $content_id, 'MEMBER' => $member, 'CONTENT_TITLE' => $content_title, 'POSTER' => $poster)); $posting_form = get_posting_form(do_lang('REPORT_CONTENT'), $post->evaluate(), $post_url, $hidden_fields, $specialisation, NULL, '', NULL, NULL, NULL, NULL, true, false); return do_template('POSTING_SCREEN', array('TITLE' => $title, 'JAVASCRIPT' => function_exists('captcha_ajax_check') ? captcha_ajax_check() : '', 'TEXT' => $text, 'POSTING_FORM' => $posting_form)); }