/** * Get details for an ajax-tree-list of entries for the content covered by this search hook. * * @return array A pair: the hook, and the options */ function ajax_tree() { $catalogue_name = get_param('catalogue_name', ''); if ($catalogue_name == '') { @ob_end_clean(); $tree = nice_get_catalogues(NULL, true); if ($tree->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } require_code('form_templates'); $fields = form_input_list(do_lang_tempcode('NAME'), '', 'catalogue_name', $tree, NULL, true); if (running_script('iframe')) { $post_url = get_self_url_easy(); } else { $post_url = get_self_url(false, false, NULL, false, true); } $submit_name = do_lang_tempcode('PROCEED'); $hidden = build_keep_post_fields(); $title = get_page_title('SEARCH'); $tpl = do_template('FORM_SCREEN', array('_GUID' => 'a2812ac8056903811f444682d45ee448', 'TARGET' => '_self', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); $echo = globalise($tpl, NULL, '', true); $echo->evaluate_echo(); exit; } return array('choose_catalogue_category', array('catalogue_name' => $catalogue_name)); }
/** * Standard modular render function for profile tabs edit 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 tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('DELETE_MEMBER'); $order = 200; // Actualiser $delete_account = post_param_integer('delete', 0); if ($delete_account == 1) { if (is_guest($member_id_of)) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } ocf_delete_member($member_id_of); inform_exit(do_lang_tempcode('SUCCESS')); } if ($leave_to_ajax_if_possible) { return NULL; } // UI fields $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); $text = do_lang_tempcode('_DELETE_MEMBER' . ($member_id_of == get_member() ? '_SUICIDAL' : ''), escape_html($username)); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); $javascript = ''; return array($title, $fields, $text, $javascript, $order); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_lang('bulkupload'); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/bulkuploadassistant'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_adv_comcode'; $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_BULK_UPLOAD'); $title = get_page_title('BULK_UPLOAD'); $parameter = post_param('parameter', ''); require_code('form_templates'); if ($parameter == '') { $post_url = build_url(array('page' => '_SELF'), '_SELF'); $text = paragraph(do_lang_tempcode('BULK_UPLOAD_HELP')); $submit_name = do_lang_tempcode('BULK_UPLOAD'); $fields = form_input_line(do_lang_tempcode('DIRECTORY'), do_lang_tempcode('DIRECTORY_BULK'), 'parameter', 'uploads/attachments/' . date('Y-m-d', utctime_to_usertime()), true); return do_template('FORM_SCREEN', array('_GUID' => '77a2ca460745145d8a1d18cf24971fea', 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'TITLE' => $title, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name)); } else { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('BULK_UPLOAD')))); breadcrumb_set_self(do_lang_tempcode('_RESULTS')); $out = $this->do_dir(get_custom_file_base() . '/' . filter_naughty($parameter, true)); if ($out->is_empty()) { inform_exit(do_lang_tempcode('NO_FILES')); } return do_template('BULK_HELPER_RESULTS_SCREEN', array('_GUID' => '5d373553cf21a58f15006bd4e600a9ee', 'TITLE' => $title, 'RESULTS' => $out)); } }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/ssl'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_security'; if (get_file_base() != get_custom_file_base()) { warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); } require_lang('security'); if (get_option('enable_https') == '0') { $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => 'SECURITY'), get_module_zone('admin_config')); $config_url = $_config_url->evaluate(); inform_exit(do_lang_tempcode('HTTPS_DISABLED', escape_html($config_url . '#group_GENERAL'))); } $type = get_param('type', 'misc'); if ($type == 'set') { return $this->set(); } if ($type == 'misc') { return $this->ssl_interface(); } return new ocp_tempcode(); }
/** * The UI to select to view a past newsletter. * * @return tempcode The UI */ function archive() { $title = get_page_title('NEWSLETTER_ARCHIVE'); $lang = choose_language($title); if (is_object($lang)) { return $lang; } $newsletters = new ocp_tempcode(); $where = multi_lang() ? array('language' => $lang) : NULL; $rows = $GLOBALS['SITE_DB']->query_select('newsletter_archive', array('id', 'subject', 'date_and_time'), $where, 'ORDER BY date_and_time DESC'); foreach ($rows as $newsletter) { $newsletters->attach(form_input_list_entry(strval($newsletter['id']), false, $newsletter['subject'])); } if ($newsletters->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } require_code('form_templates'); $fields = form_input_list(do_lang_tempcode('NEWSLETTER'), '', 'id', $newsletters, NULL, true); $hidden = form_input_hidden('lang', $lang); $submit_name = do_lang_tempcode('VIEW'); $post_url = build_url(array('page' => '_SELF', 'type' => 'view'), '_SELF', NULL, false, true); return do_template('FORM_SCREEN', array('_GUID' => 'ee295e41dc86c4583c123e6e0e445380', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); }
/** * Get the tempcode for an AJAX-powered tree listbox. * * @param mixed A human intelligible name for this input field * @param mixed A description for this input field * @param ID_TEXT The name which this input field is for * @param ?ID_TEXT The ID to do under (NULL: root) * @param string The ajax tree-list hook that drives our data * @param array A map of special options * @param boolean Whether this is a required input field * @param ?string The default value for the field (NULL: none) * @param boolean Whether to use the server-ID in the list instead of the ID in the list * @param ?integer The tab index of the field (NULL: not specified) * @return tempcode The input field */ function form_input_tree_list($pretty_name, $description, $name, $root_id, $hook, $options, $required, $default = NULL, $use_server_id = false, $tabindex = NULL) { require_javascript('javascript_tree_list'); require_javascript('javascript_more'); require_code('hooks/systems/ajax_tree/' . $hook); $object = object_factory('Hook_' . $hook); if (!has_js() || get_option('tree_lists') == '0') { $simple_content = new ocp_tempcode(); $simple_content->attach(form_input_list_entry('', false, do_lang('NA'))); $simple_content->attach($object->simple($root_id, $options, $default)); if ($simple_content->is_empty()) { if ($required) { inform_exit(do_lang_tempcode('NO_OF_THIS', $pretty_name)); } return new ocp_tempcode(); } return form_input_list($pretty_name, $description, $name, $simple_content, $tabindex, false, $required); } $tabindex = get_form_field_tabindex($tabindex); require_javascript('javascript_ajax'); $nice_label = $default; /*if (!is_null($default)) Now we auto-expand to it { $simple_content=$object->simple($root_id,$options,$default); $simple_content_evaluated=$simple_content->evaluate(); $matches=array(); if (preg_match('#<option [^>]*value="'.str_replace('#','\#',preg_quote($default)).'"[^>]*>([^>]* > )?([^>]*)</option>#',$simple_content_evaluated,$matches)!=0) { $nice_label=preg_replace('# \(.*\)#','',trim($matches[2])); } }*/ $_required = $required ? '_required' : ''; $input = do_template('FORM_SCREEN_INPUT_TREE_LIST', array('_GUID' => '21e9644eeac24356f38459ebe37f693a', 'NICE_LABEL' => is_null($nice_label) || $nice_label == '-1' ? '' : $nice_label, 'USE_SERVER_ID' => $use_server_id, 'TABINDEX' => strval($tabindex), 'NAME' => $name, 'REQUIRED' => $_required, 'DEFAULT' => is_null($default) ? '' : $default, 'HOOK' => $hook, 'ROOT_ID' => is_null($root_id) ? '' : $root_id, 'OPTIONS' => serialize($options))); return _form_input($name, $pretty_name, $description, $input, $required, false, $tabindex); }
/** * The main user interface for moderating a chat room. * * @return tempcode The UI. */ function moderate_chat_room() { $title = get_page_title('CHAT_MOD_PANEL'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')))); $room_id = get_param_integer('id'); check_chatroom_access($room_id); $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1); if (!array_key_exists(0, $room_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $row = $room_details[0]; $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $room_id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms'); if (!$has_mod_access) { access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content'); } $start = get_param_integer('start', 0); $max = get_param_integer('max', 50); $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'user_id' => do_lang_tempcode('MEMBER')); $test = explode(' ', get_param('sort', 'date_and_time DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; $max_rows = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)', array('room_id' => $room_id)); $rows = $GLOBALS['SITE_DB']->query_select('chat_messages', array('*'), array('room_id' => $room_id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start); $fields = new ocp_tempcode(); require_code('templates_results_table'); $array = array(do_lang_tempcode('MEMBER'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('MESSAGE')); if (has_js()) { $array[] = do_lang_tempcode('DELETE'); } $fields_title = results_field_title($array, $sortables, 'sort', $sortable . ' ' . $sort_order); foreach ($rows as $myrow) { $url = build_url(array('page' => '_SELF', 'type' => 'ed', 'room_id' => $room_id, 'id' => $myrow['id']), '_SELF'); $username = $GLOBALS['FORUM_DRIVER']->get_username($myrow['user_id']); if (is_null($username)) { $username = ''; } //do_lang('UNKNOWN'); $message = get_translated_tempcode($myrow['the_message']); $link_time = hyperlink($url, escape_html(get_timezoned_date($myrow['date_and_time']))); $_row = array($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($GLOBALS['FORUM_DRIVER']->get_member_from_username($username), false, $username), escape_html($link_time), $message); if (has_js()) { $deletion_tick = do_template('RESULTS_TABLE_TICK', array('ID' => strval($myrow['id']))); $_row[] = $deletion_tick; } $fields->attach(results_entry($_row)); } if ($fields->is_empty()) { if ($start != 0) { $_GET['start'] = strval(max(0, $start - $max)); return $this->moderate_chat_room(); } inform_exit(do_lang_tempcode('NO_ENTRIES')); } $content = results_table(do_lang_tempcode('MESSAGES'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort'); $mod_link = hyperlink(build_url(array('page' => '_SELF', 'type' => 'delete', 'stage' => 0, 'id' => $room_id), '_SELF'), do_lang_tempcode('DELETE_ALL_MESSAGES')); $view_link = hyperlink(build_url(array('page' => 'chat', 'type' => 'room', 'id' => $room_id), get_module_zone('chat')), do_lang_tempcode('VIEW')); $logs_link = hyperlink(build_url(array('page' => 'chat', 'type' => 'download_logs', 'id' => $room_id), get_module_zone('chat')), do_lang_tempcode('CHAT_DOWNLOAD_LOGS')); $links = array($mod_link, $view_link, $logs_link); $delete_url = build_url(array('page' => '_SELF', 'type' => 'mass_delete', 'room_id' => $room_id, 'start' => $start, 'max' => $max), '_SELF'); return do_template('CHAT_MODERATE_SCREEN', array('_GUID' => '940de7e8c9a0ac3c575892887c7ef3c0', 'URL' => $delete_url, 'TITLE' => $title, 'INTRODUCTION' => '', 'CONTENT' => $content, 'LINKS' => $links)); }
/** * The UI to browse IOTDs. * * @return tempcode The UI */ function iotd_browse() { $title = get_page_title('IOTD_ARCHIVE'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $start = get_param_integer('start', 0); $max = get_param_integer('max', 20); $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('used' => 1), 'ORDER BY date_and_time DESC', $max, $start); $max_rows = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)', array('used' => 1)); $content = new ocp_tempcode(); foreach ($rows as $myrow) { $date = get_timezoned_date($myrow['date_and_time']); $url = build_url(array('page' => '_SELF', 'type' => 'view', 'wide' => 1, 'id' => $myrow['id']), '_SELF'); $thumb_url = $myrow['thumb_url']; $caption = get_translated_tempcode($myrow['i_title']); require_code('images'); $thumb_url = ensure_thumbnail($myrow['url'], $thumb_url, 'iotds', 'iotd', $myrow['id']); $thumb = do_image_thumb($thumb_url, ''); $content->attach(do_template('IOTD_VIEW_SCREEN_IOTD', array('SUBMITTER' => strval($myrow['submitter']), 'ID' => strval($myrow['id']), 'VIEWS' => integer_format($myrow['iotd_views']), 'THUMB' => $thumb, 'DATE' => $date, 'DATE_RAW' => strval($myrow['date_and_time']), 'URL' => $url, 'CAPTION' => $caption))); } if ($content->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $page_num = intval(floor(floatval($start) / floatval($max))) + 1; $num_pages = intval(ceil(floatval($max_rows) / floatval($max))); $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max == 0 ? NULL : $start - $max), '_SELF'); $next_url = count($rows) != $max ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF'); $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => 'b6933ab44e16fef7e1bec62014254383', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages))); return do_template('NEXT_BROWSER_SCREEN', array('_GUID' => 'd8a493c2b007d98074f104ea433c8091', 'TITLE' => $title, 'CONTENT' => $content, 'BROWSE' => $browse)); }
/** * Get a form for entering a booking. * * @param ?array Details of the booking (NULL: new). * @param ?MEMBER Who the booking is for (NULL: current member). * @return array Tuple: form fields, hidden fields. */ function get_form_fields($details = NULL, $member_id = NULL) { $hidden = new ocp_tempcode(); $fields = new ocp_tempcode(); if (is_null($details)) { $bookable_id = get_param_integer('bookable_id', NULL); if (is_null($bookable_id)) { // Form to choose bookable @ob_end_clean(); $bookables = $GLOBALS['SITE_DB']->query_select('bookable', array('*'), NULL, 'ORDER BY sort_order'); if (count($bookables) == 0) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } $bookables_list = new ocp_tempcode(); foreach ($bookables as $bookable) { $bookables_list->attach(form_input_list_entry(strval($bookable['id']), false, get_translated_text($bookable['title']))); } $fields = form_input_list(do_lang_tempcode('BOOKABLE'), '', 'bookable_id', $bookables_list, NULL, true); $post_url = get_self_url(false, false, NULL, false, true); $submit_name = do_lang_tempcode('PROCEED'); $hidden = build_keep_post_fields(); $title = get_page_title('ADD_BOOKING'); $tpl = do_template('FORM_SCREEN', array('TARGET' => '_self', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); $echo = globalise($tpl, NULL, '', true); $echo->evaluate_echo(); exit; } $details = array('bookable_id' => $bookable_id, 'start_day' => get_param_integer('day', intval(date('d'))), 'start_month' => get_param_integer('month', intval(date('m'))), 'start_year' => get_param_integer('year', intval(date('Y'))), 'end_day' => get_param_integer('day', intval(date('d'))), 'end_month' => get_param_integer('month', intval(date('m'))), 'end_year' => get_param_integer('year', intval(date('Y'))), 'quantity' => 1, 'notes' => '', 'supplements' => array()); } if (is_null($member_id)) { $member_id = get_member(); } $_bookable = $GLOBALS['SITE_DB']->query_select('bookable', array('*'), array('id' => $details['bookable_id']), '', 1); if (!array_key_exists(0, $_bookable)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $bookable = $_bookable[0]; $fields->attach(form_input_date(do_lang_tempcode('FROM'), '', 'bookable_' . strval($details['bookable_id']) . '_date_from', false, false, false, array(0, 0, $details['start_month'], $details['start_day'], $details['start_year']), 10, NULL, NULL, NULL, true, get_server_timezone())); if ($bookable['dates_are_ranges'] == 1) { $fields->attach(form_input_date(do_lang_tempcode('TO'), '', 'bookable_' . strval($details['bookable_id']) . '_date_to', false, false, false, array(0, 0, $details['end_month'], $details['end_day'], $details['end_year']), 10, NULL, NULL, NULL, true, get_server_timezone())); } $fields->attach(form_input_integer(do_lang_tempcode('QUANTITY'), '', 'bookable_' . strval($details['bookable_id']) . '_quantity', $details['quantity'], true)); $fields->attach(form_input_text(do_lang_tempcode('NOTES'), '', 'bookable_' . strval($details['bookable_id']) . '_notes', $details['notes'], false)); $member_directory_url = build_url(array('page' => 'members'), get_module_zone('members')); $fields->attach(form_input_username(do_lang_tempcode('BOOKING_FOR'), do_lang_tempcode('DESCRIPTION_BOOKING_FOR', escape_html($member_directory_url->evaluate())), 'username', $GLOBALS['FORUM_DRIVER']->get_username($member_id), true, false)); $supplement_rows = $GLOBALS['SITE_DB']->query_select('bookable_supplement a JOIN ' . get_table_prefix() . 'bookable_supplement_for b ON a.id=b.supplement_id', array('a.*'), array('bookable_id' => $details['bookable_id']), 'ORDER BY sort_order'); foreach ($supplement_rows as $supplement_row) { $quantity = 0; $notes = ''; if (array_key_exists($supplement_row['id'], $details['supplements'])) { $quantity = $details['supplements'][$supplement_row['id']]['quantity']; $notes = $details['supplements'][$supplement_row['id']]['notes']; } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SUPPLEMENT', escape_html(get_translated_text($supplement_row['title'])))))); if ($supplement_row['supports_quantities'] == 1) { $fields->attach(form_input_integer(do_lang_tempcode('QUANTITY'), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_quantity', $quantity, true)); } else { $fields->attach(form_input_tick(get_translated_text($supplement_row['title']), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_quantity', $quantity == 1)); } $fields->attach(form_input_text(do_lang_tempcode('NOTES'), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_notes', $notes, false)); } return array($fields, $hidden); }
/** * Choose a test section to edit. * * @return tempcode The result of execution. */ function ed() { $title = get_page_title('EDIT_TEST_SECTION'); check_specific_permission('edit_own_tests'); if (!$GLOBALS['FORUM_DRIVER']->is_staff(get_member())) { access_denied('STAFF_ONLY'); } $list = $this->get_section_list(); if ($list->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST')); $post_url = build_url(array('page' => '_SELF', 'type' => '_ed'), '_SELF', NULL, false, true); require_code('form_templates'); $fields = form_input_list(do_lang_tempcode('NAME'), '', 'id', $list, NULL, true); $submit_name = do_lang_tempcode('PROCEED'); return do_template('FORM_SCREEN', array('_GUID' => '37f70ba9d23204bceda6e84375b52270', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); }
/** * Show undelivered invoices. * * @return tempcode The interface. */ function undelivered() { $title = get_page_title('UNDELIVERED_INVOICES'); breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('INVOICES')))); $invoices = array(); $rows = $GLOBALS['SITE_DB']->query_select('invoices', array('*'), array('i_state' => 'paid')); foreach ($rows as $row) { $invoice_title = do_lang('CUSTOM_PRODUCT_' . $row['i_type_code']); $time = get_timezoned_date($row['i_time']); $username = $GLOBALS['FORUM_DRIVER']->get_username($row['i_member_id']); $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($row['i_member_id'], false, true); $invoices[] = array('INVOICE_TITLE' => $invoice_title, 'PROFILE_URL' => $profile_url, 'USERNAME' => $username, 'ID' => strval($row['id']), 'STATE' => $row['i_state'], 'AMOUNT' => $row['i_amount'], 'TIME' => $time, '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_OUTSTANDING_INVOICES_SCREEN', array('_GUID' => '672e41d8cbe06f046a47762ff75c8337', 'TITLE' => $title, 'FROM' => 'undelivered', 'INVOICES' => $invoices)); }
/** * The UI to download chat logs. * * @return tempcode The UI */ function chat_download_logs() { $title = get_page_title('CHAT_DOWNLOAD_LOGS'); $chatrooms = chat_get_all_rooms(); $select = new ocp_tempcode(); $select_by_default = get_param_integer('id', NULL); foreach ($chatrooms as $value) { $select->attach(form_input_list_entry(strval($value['id']), $value['id'] == $select_by_default, $value['room_name'], false)); } $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_list(do_lang_tempcode('ROOM_NAME'), do_lang_tempcode('CHAT_DOWNLOAD_LOGS_ROOM_NAME'), 'room_name', $select)); $fields->attach(form_input_date(do_lang_tempcode('CHAT_DOWNLOAD_LOGS_START_DATE'), do_lang_tempcode('CHAT_DOWNLOAD_LOGS_START_DATE_DESCRIPTION'), 'start', false, false, true, time() - 4 * 60 * 60, 26)); $fields->attach(form_input_date(do_lang_tempcode('CHAT_DOWNLOAD_LOGS_FINISH_DATE'), do_lang_tempcode('CHAT_DOWNLOAD_LOGS_FINISH_DATE_DESCRIPTION'), 'finish', false, false, true, time(), 26)); $posting_name = do_lang_tempcode('CHAT_DOWNLOAD_LOGS'); $posting_url = build_url(array('page' => '_SELF', 'type' => '_download_logs'), '_SELF', NULL, false, true); if (count($chatrooms) == 0) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY')))); return do_template('FORM_SCREEN', array('_GUID' => '6741ef01d1c6dd8d2de9be3290666db7', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'SUBMIT_NAME' => $posting_name, 'URL' => $posting_url, 'TEXT' => '')); }
/** * Finish step. * * @param tempcode The page title. * @return tempcode The result of execution. */ function finish($title) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PURCHASING')))); $message = get_param('message', NULL, true); if (get_param_integer('cancel', 0) == 0) { if (perform_local_payment()) { $trans_id = post_param('trans_id'); $transaction_rows = $GLOBALS['SITE_DB']->query_select('trans_expecting', array('*'), array('id' => $trans_id), '', 1); if (!array_key_exists(0, $transaction_rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $transaction_row = $transaction_rows[0]; $amount = $transaction_row['e_amount']; $length = $transaction_row['e_length']; $length_units = $transaction_row['e_length_units']; $via = get_option('payment_gateway'); require_code('hooks/systems/ecommerce_via/' . filter_naughty_harsh($via)); $object = object_factory('Hook_' . $via); $name = post_param('name'); $card_number = post_param('card_number'); $expiry_date = str_replace('/', '', post_param('expiry_date')); $issue_number = post_param_integer('issue_number', NULL); $start_date = str_replace('/', '', post_param('start_date')); $card_type = post_param('card_type'); $cv2 = post_param('cv2'); list($success, , $message, $message_raw) = $object->do_transaction($trans_id, $name, $card_number, $amount, $expiry_date, $issue_number, $start_date, $card_type, $cv2, $length, $length_units); if ($success || !is_null($length)) { $status = !is_null($length) && !$success ? 'SCancelled' : 'Completed'; handle_confirmed_transaction($transaction_row['e_purchase_id'], $transaction_row['e_item_name'], $status, $message_raw, '', '', $amount, get_option('currency'), $trans_id, '', $via, is_null($length) ? '' : strtolower(strval($length) . ' ' . $length_units)); } if ($success) { $member_id = $transaction_row['e_member_id']; require_code('notifications'); dispatch_notification('payment_received', NULL, do_lang('PAYMENT_RECEIVED_SUBJECT', $trans_id), do_lang('PAYMENT_RECEIVED_BODY', float_format(floatval($amount)), get_option('currency'), get_site_name()), array($member_id), A_FROM_SYSTEM_PRIVILEGED); } } $product = get_param('product', ''); if ($product != '') { if (count($_POST) != 0) { handle_transaction_script(); } attach_message(do_lang_tempcode('SUCCESS'), 'inform'); $object = find_product($product); if (method_exists($object, 'get_finish_url')) { return redirect_screen($title, $object->get_finish_url($product), $message); } } return $this->wrap(do_template('PURCHASE_WIZARD_STAGE_FINISH', array('_GUID' => '43f706793719ea893c280604efffacfe', 'TITLE' => $title, 'MESSAGE' => $message)), $title, NULL); } if (!is_null($message)) { return $this->wrap(do_template('PURCHASE_WIZARD_STAGE_FINISH', array('_GUID' => '859c31e8f0f02a2a46951be698dd22cf', 'TITLE' => $title, 'MESSAGE' => $message)), $title, NULL); } inform_exit(do_lang_tempcode('PRODUCT_PURCHASE_CANCEL')); return new ocp_tempcode(); // Will never get here }
function referrer_report_script($ret = false) { $member_id = get_param_integer('member_id', NULL); if (!has_zone_access(get_member(), 'adminzone') && $member_id !== get_member()) { access_denied('ZONE_ACCESS', 'adminzone'); } require_lang('referrals'); $csv = get_param_integer('csv', 0) == 1; $where = db_string_not_equal_to('i_email_address', '') . ' AND i_inviter<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()); if ($member_id !== NULL) { $where .= ' AND referrer.id=' . strval($member_id); } $max = get_param_integer('max', $csv ? 10000 : 30); $start = get_param_integer('start', 0); $data = array(); $table = 'f_invites i LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referrer ON referrer.id=i_inviter LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referee ON referee.m_email_address=i_email_address'; $referrals = $GLOBALS['FORUM_DB']->query('SELECT i_time AS time,referrer.id AS referrer_id,referrer.m_username AS referrer,referrer.m_email_address AS referrer_email,referee.id AS referee_id,referee.m_username AS referee,referee.m_email_address AS referee_email,i_taken AS qualified FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where . ' ORDER BY i_time DESC', $max, $start); $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where); if (count($referrals) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } foreach ($referrals as $ref) { $data_row = array(); $data_row[do_lang('DATE_TIME')] = get_timezoned_date($ref['time'], true, true, false, true); if (is_null($member_id)) { if ($csv) { $deleted = true; $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referrer']; } else { $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer_id']) ? '' : strval($ref['referrer_id']); } $data_row[do_lang('TYPE_REFERRER') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = $ref['referrer_email']; $data_row[do_lang('QUALIFIED_REFERRER')] = do_lang(referrer_is_qualified($ref['referrer_id']) ? 'YES' : 'NO'); } $deleted = false; if (is_null($ref['referee'])) { $deleted = $ref['qualified'] == 1; //!is_null($GLOBALS['SITE_DB']->query_value_null_ok('adminlogs','id',array('the_type'=>'DELETE_MEMBER','param_b'=>TODO Unfortunately we can't tell))); } if ($csv) { $data_row[do_lang('REFEREE')] = is_null($ref['referee']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referee']; } else { $data_row[do_lang('REFEREE')] = is_null($ref['referee_id']) ? '' : strval($ref['referee_id']); } $data_row[do_lang('REFEREE') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = is_null($ref['referee_email']) ? '' : $ref['referee_email']; $data_row[do_lang('QUALIFIED_REFERRAL')] = do_lang($ref['qualified'] == 1 ? 'YES' : 'NO'); $data[] = $data_row; } if ($csv) { require_code('files2'); make_csv($data, (is_null($member_id) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($member_id)) . ' referrals.csv'); } else { require_code('templates_results_table'); $fields_title = new ocp_tempcode(); $fields = new ocp_tempcode(); foreach ($data as $i => $data_row) { if ($i == 0) { $fields_title->attach(results_field_title(array_keys($data_row))); } foreach ($data_row as $key => $val) { if ($key == do_lang('REFEREE') || $key == do_lang('TYPE_REFERRER')) { if ($val == '') { $val = do_lang('UNKNOWN'); } else { $val = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($val, true); } } $data_row[$key] = escape_html($val); } $fields->attach(results_entry($data_row)); } $table = results_table(do_lang('REFERRALS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields); if ($ret) { return $table; } $title = get_page_title('REFERRALS'); $out = new ocp_tempcode(); $out->attach($title); $out->attach($table); $out = globalise($out, NULL, '', true); $out->evaluate_echo(); } return NULL; }
/** * The UI to edit an author (effectively deleting and re-adding them). * * @return tempcode The UI */ function ed() { $title = get_page_title('EDIT_MERGE_AUTHORS'); $authors = $this->nice_get_authors(); if ($authors->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } require_code('form_templates'); $fields = form_input_list(do_lang_tempcode('NAME'), '', 'author', $authors, NULL, true); $post_url = build_url(array('page' => '_SELF', 'type' => '_ad'), '_SELF'); $submit_name = do_lang_tempcode('PROCEED'); $define_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'GET' => true, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); if (has_specific_permission(get_member(), 'delete_midrange_content')) { $fields = form_input_list(do_lang_tempcode('NAME'), '', 'mauthor', $authors); $fields->attach(form_input_list(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'mauthor2', $authors)); $post_url = build_url(array('page' => '_SELF', 'type' => '_mg'), '_SELF'); $submit_name = do_lang_tempcode('MERGE_AUTHORS'); $merge_form = do_template('FORM', array('_GUID' => 'd0dd075a54b72cfe47d3c2d9fe987c89', 'TABINDEX' => strval(get_form_field_tabindex()), 'SECONDARY_FORM' => true, 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); } else { $merge_form = new ocp_tempcode(); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('AUTHOR_MANAGE')))); return do_template('AUTHOR_MANAGE_SCREEN', array('_GUID' => '84f8de5d53090d138cb653bb861f2f70', 'TITLE' => $title, 'MERGE_FORM' => $merge_form, 'DEFINE_FORM' => $define_form)); }
/** * The UI to manage the IOTD. * * @return tempcode The UI */ function ed() { $count = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)'); if ($count == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $used = get_param_integer('used', 0); $title = get_page_title('EDIT_OR_CHOOSE_IOTD'); $only_owned = has_specific_permission(get_member(), 'edit_midrange_content', 'cms_iotds') ? NULL : get_member(); $current_iotd = $this->nice_get_iotds_link(1, 1); $unused_iotd = $this->nice_get_iotds_link(0, 0, $only_owned); $used_iotd = new ocp_tempcode(); if ($used == 1) { $used_iotd = $this->nice_get_iotds_link(1); } $used_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'used' => 1), '_SELF'); $search_url = build_url(array('page' => 'search', 'id' => 'iotds'), get_module_zone('search')); $archive_url = build_url(array('page' => 'iotds'), get_module_zone('iotds')); $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($search_url->evaluate()), escape_html($archive_url->evaluate()))); return do_template('IOTD_ADMIN_CHOOSE_SCREEN', array('_GUID' => '3ee2847c986bf349caa40d462f45eb9c', 'SHOWING_OLD' => $used == 1, 'TITLE' => $title, 'TEXT' => $text, 'USED_URL' => $used_url, 'CURRENT_IOTD' => $current_iotd, 'UNUSED_IOTD' => $unused_iotd, 'USED_IOTD' => $used_iotd)); }
/** * The UI for confirming the deletion results of delurk criteria. * * @return tempcode The UI */ function _delurk() { $title = get_page_title('DELETE_LURKERS'); if (function_exists('set_time_limit')) { @set_time_limit(100); } require_lang('ocf_lurkers'); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/deletelurkers'; $max_posts = post_param_integer('max_posts'); $max_points = post_param_integer('max_points'); $max_logged_actions = post_param_integer('max_logged_actions'); $min_days_since_login = post_param_integer('min_days_since_login'); $min_days_since_join = post_param_integer('min_days_since_join'); $usergroups = array(); if (array_key_exists('usergroups', $_POST)) { foreach ($_POST['usergroups'] as $g_id) { $usergroups[] = intval($g_id); } } $lurkers = $this->find_lurkers($max_posts, $max_points, $max_logged_actions, $min_days_since_login, $min_days_since_join, $usergroups); if (count($lurkers) == 0) { inform_exit(do_lang_tempcode('NO_LURKERS_FOUND')); } $_lurkers = array(); foreach ($lurkers as $id => $username) { if (is_guest($id)) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } $_lurkers[] = array('ID' => strval($id), 'USERNAME' => $username, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($id, false, true)); } $url = build_url(array('page' => '_SELF', 'type' => '__delurk'), '_SELF'); breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')), array('_SEARCH:admin_ocf_join:delurk', do_lang_tempcode('DELETE_LURKERS')))); breadcrumb_set_self(do_lang_tempcode('CONFIRM')); return do_template('OCF_DELURK_CONFIRM', array('_GUID' => '52870b8546653782e354533602531970', 'TITLE' => $title, 'LURKERS' => $_lurkers, 'URL' => $url)); }
/** * The UI to view a catalogue category tree. * * @return tempcode The UI */ function tree_view_screen() { require_code('splurgh'); $catalogue_name = get_param('id'); if ($GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)', array('c_name' => $catalogue_name)) > 1000) { warn_exit(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM')); } $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter='; $url_stub = build_url(array('page' => '_SELF', 'type' => 'category'), '_SELF', NULL, false, false, true); $last_change_time = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'MAX(cc_add_date)'); if (!has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'catalogues_catalogue', $catalogue_name)) { access_denied('CATALOGUE_ACCESS'); } $category_rows = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title', 'cc_parent_id'), array('c_name' => $catalogue_name)); $map = array(); foreach ($category_rows as $i => $category) { if ($i != 0) { if (!has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'catalogues_category', strval($category['id']))) { continue; } } $id = $category['id']; $map[$id]['title'] = get_translated_text($category['cc_title']); $children = array(); foreach ($category_rows as $child) { if ($child['cc_parent_id'] == $id) { $children[] = $child['id']; } } $map[$id]['children'] = $children; } if (count($map) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $content = splurgh_master_build('id', $map, $url_stub->evaluate(), 'catalogue_' . $catalogue_name . '_tree_made', $last_change_time, $category_rows[0]['id']); $title = get_page_title('CATEGORIES'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . (is_ecommerce_catalogue($catalogue_name) ? ':ecommerce=1' : ''), do_lang_tempcode('CATALOGUES')))); return do_template('SPLURGH_SCREEN', array('_GUID' => '7cbb5d410887e3834a01265e133a9b33', 'TITLE' => $title, 'CONTENT' => $content)); }
/** * The UI to translate code. * * @return tempcode The UI */ function interface_code() { $lang = filter_naughty_harsh(get_param('lang', '')); $lang_new = get_param('lang_new', $lang); if ($lang_new != '') { require_code('type_validation'); if (!is_alphanumeric($lang_new, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } if (strlen($lang_new) > 5) { warn_exit(do_lang_tempcode('INVALID_LANG_CODE')); } $lang = $lang_new; } if ($lang == '') { $title = get_page_title('TRANSLATE_CODE'); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_FIND_LANG_STRING_TIP'); return $this->choose_lang($title, true, true, do_lang_tempcode('CHOOSE_EDIT_LIST_LANG_FILE')); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')))); breadcrumb_set_self(do_lang_tempcode('TRANSLATE_CODE')); $base_lang = fallback_lang(); $map_a = get_file_base() . '/lang/langs.ini'; $map_b = get_custom_file_base() . '/lang_custom/langs.ini'; $search = get_param('search', '', true); if ($search != '') { $title = get_page_title('TRANSLATE_CODE'); require_code('form_templates'); $fields = new ocp_tempcode(); global $LANGUAGE; foreach ($LANGUAGE[user_lang()] as $key => $value) { if (strpos(strtolower($value), strtolower($search)) !== false) { $fields->attach(form_input_text($key, '', 'l_' . $key, str_replace('\\n', chr(10), $value), false)); } } if ($fields->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $post_url = build_url(array('page' => '_SELF', 'type' => '_code2'), '_SELF'); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('redirect', get_self_url(true))); $hidden->attach(form_input_hidden('lang', $lang)); return do_template('FORM_SCREEN', array('_GUID' => '2d7356fd2c4497ceb19450e65331c9c5', 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => '', 'SUBMIT_NAME' => do_lang('TRANSLATE_CODE'))); } $lang_file = get_param('lang_file'); if (!file_exists($map_b)) { $map_b = $map_a; } $map = better_parse_ini_file($map_b); $title = get_page_title('_TRANSLATE_CODE', true, array(escape_html($lang_file), escape_html(array_key_exists($lang, $map) ? $map[$lang] : $lang))); // Upgrade to custom if not there yet (or maybe we are creating a new lang - same difference) $custom_dir = get_custom_file_base() . '/lang_custom/' . $lang; if (!file_exists($custom_dir)) { require_code('abstract_file_manager'); force_have_afm_details(); afm_make_directory('lang_custom/' . $lang, true); $cached_dir = get_custom_file_base() . '/lang_cached/' . $lang; if (!file_exists($cached_dir)) { afm_make_directory('lang_cached/' . $lang, true); } // Make comcode page dirs $zones = find_all_zones(); foreach ($zones as $zone) { $_special_dir = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang; if (!file_exists($_special_dir)) { afm_make_directory($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang, true); } $_special_dir = get_custom_file_base() . '/' . $zone . '/pages/html_custom/' . $lang; if (!file_exists($_special_dir)) { afm_make_directory($zone . ($zone == '' ? '' : '/') . 'pages/html_custom/' . $lang, true); } } // Make templates_cached dirs require_code('themes2'); $themes = find_all_themes(); foreach (array_keys($themes) as $theme) { $_special_dir = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . $lang; if (!file_exists($_special_dir)) { afm_make_directory('themes/' . $theme . '/templates_cached/' . $lang, true); } } } // Get some stuff $for_lang = get_lang_file_map($lang, $lang_file); $for_base_lang = get_lang_file_map($base_lang, $lang_file, true); $descriptions = get_lang_file_descriptions($base_lang, $lang_file); // Make our translation page $lines = ''; $intertrans = $this->get_intertran_conv($lang); $actions = new ocp_tempcode(); $next = 0; $trans_lot = ''; $delimit = chr(10) . '=-=-=-=-=-=-=-=-' . chr(10); foreach ($for_base_lang as $name => $old) { if (array_key_exists($name, $for_lang)) { $current = $for_lang[$name]; } else { $current = ''; //$this->find_lang_matches($old,$lang); Too slow / useless for code translation } if ($current == '' && strtolower($name) != $name) { $trans_lot .= str_replace('\\n', chr(10), str_replace(array('{', '}'), array('(((', ')))'), $old)) . $delimit; } } $translated_stuff = array(); if ($trans_lot != '' && $intertrans != '') { $result = http_download_file('http://translate.google.com/translate_t', NULL, false, false, 'ocPortal', array('text' => $trans_lot, 'langpair' => 'en|' . $intertrans)); if (!is_null($result)) { require_code('character_sets'); $result = convert_to_internal_encoding($result); $matches = array(); if (preg_match('#<div id=result_box dir="ltr">(.*)</div>#Us', convert_to_internal_encoding($result), $matches) != 0) { $result2 = $matches[1]; $result2 = @html_entity_decode($result2, ENT_QUOTES, get_charset()); $result2 = preg_replace('#\\s?<br>\\s?#', chr(10), $result2); $result2 = str_replace('> ', '>', str_replace(' <', ' <', str_replace('</ ', '</', str_replace(array('(((', ')))'), array('{', '}'), $result2)))); $translated_stuff = explode(trim($delimit), $result2 . chr(10)); } } } foreach ($for_base_lang + $for_lang as $name => $old) { if (array_key_exists($name, $for_lang)) { $current = $for_lang[$name]; } else { $current = ''; //$this->find_lang_matches($old,$lang); Too slow / useless for code translation } $description = array_key_exists($name, $descriptions) ? $descriptions[$name] : ''; if ($current == '' && strtolower($name) != $name && array_key_exists($next, $translated_stuff)) { $_current = ''; $translate_auto = trim($translated_stuff[$next]); $next++; } else { $_current = str_replace('\\n', chr(10), $current); $translate_auto = NULL; } if ($_current == '') { $_current = str_replace('\\n', chr(10), $old); } if ($intertrans != '' && get_value('google_translate_api_key') !== NULL) { $actions = do_template('TRANSLATE_ACTION', array('_GUID' => '9e9a68cb2c1a1e23a901b84c9af2280b', 'LANG_FROM' => get_site_default_lang(), 'LANG_TO' => $lang, 'NAME' => 'trans_' . $name, 'OLD' => $_current)); } $temp = do_template('TRANSLATE_LINE', array('_GUID' => '9cb331f5852ee043e6ad30b45aedc43b', 'TRANSLATE_AUTO' => $translate_auto, 'DESCRIPTION' => $description, 'NAME' => $name, 'OLD' => str_replace('\\n', chr(10), $old), 'CURRENT' => $_current, 'ACTIONS' => $actions)); $lines .= $temp->evaluate(); } $url = build_url(array('page' => '_SELF', 'type' => '_code', 'lang_file' => $lang_file, 'lang' => $lang), '_SELF'); return do_template('TRANSLATE_SCREEN', array('_GUID' => 'b3429f8bd0b4eb79c33709ca43e3207c', 'PAGE' => $lang_file, 'INTERTRANS' => get_value('google_translate_api_key') !== NULL ? $intertrans : '', 'LANG' => $lang, 'LINES' => $lines, 'TITLE' => $title, 'URL' => $url)); }
/** * 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)); }
/** * Standard modular UI to choose an entry to edit. * * @return tempcode The UI */ function ed() { if (!is_null($this->permissions_require) && is_null($this->permissions_cat_require)) { check_some_edit_permission($this->permissions_require, NULL, $this->permission_page_name); } $doing = 'EDIT_' . $this->lang_type; if ($this->catalogue && get_param('catalogue_name', '') != '') { $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name')))); if ($this->type_code == 'd') { $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title)); } elseif ($this->type_code == 'c') { $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title)); } } $title = get_page_title($doing); $test = $this->choose_catalogue($title); if (!is_null($test)) { return $test; } $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST')); $next_type = '_e' . $this->type_code; if (get_param('type', 'ed') == 'edit_catalogue') { $next_type = '_edit_catalogue'; } $map = array('page' => '_SELF', 'type' => $next_type); if (either_param('catalogue_name', '') != '') { $map['catalogue_name'] = either_param('catalogue_name'); } if (!is_null(get_param('redirect', NULL))) { $map['redirect'] = get_param('redirect'); } if (!is_null(get_param('continue', NULL))) { $map['continue'] = get_param('continue'); } $description = $this->select_name_description != '' ? do_lang_tempcode($this->select_name_description) : new ocp_tempcode(); if (method_exists($this, 'nice_get_radio_entries')) { $entries = $this->nice_get_radio_entries(); if ($entries->is_empty()) { inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES')); } $fields = form_input_radio(do_lang_tempcode($this->select_name), $description, 'id', $entries, $this->no_blank_ids, true, ''); } elseif (method_exists($this, 'nice_get_ajax_tree') && ($_fields = $this->nice_get_ajax_tree()) !== NULL) { if (is_array($_fields)) { $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($_fields[1]->evaluate()), escape_html($_fields[2]->evaluate()))); $fields = $_fields[0]; } else { $fields = $_fields; } } elseif (method_exists($this, 'nice_get_choose_table')) { list($test, ) = $this->get_entry_rows(); if (count($test) == 0) { inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES')); } $table_result = $this->nice_get_choose_table($map); if (is_null($table_result)) { inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES')); } $table = $table_result[0]; $has_ordering = $table_result[1]; if (array_key_exists(2, $table_result) && !is_null($table_result[2])) { $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_TABLE_EXTRA', escape_html($table_result[2]->evaluate()), escape_html($table_result[3]->evaluate()))); } else { $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_TABLE')); } return do_template('TABLE_TABLE_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'TABLE' => $table, 'SUBMIT_NAME' => $has_ordering ? do_lang_tempcode('ORDER') : NULL, 'POST_URL' => get_self_url())); } else { $_entries = $this->nice_get_entries(); if (is_array($_entries)) { $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($_entries[1]->evaluate()), escape_html($_entries[2]->evaluate()))); $entries = $_entries[0]; } else { $entries = $_entries; } if ($entries->is_empty()) { inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES')); } $fields = form_input_list(do_lang_tempcode($this->select_name), $description, 'id', $entries, NULL, true, $this->no_blank_ids); } $post_url = build_url($map, '_SELF', NULL, false, true); //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing); $submit_name = do_lang_tempcode('PROCEED'); $keep = symbol_tempcode('KEEP'); $iframe_url = NULL; if (!$this->special_edit_frontend && has_js()) { $iframe_url = find_script('iframe') . '?zone=' . get_zone_name() . '&wide_high=1&opens_below=1'; foreach ($map as $key => $val) { $iframe_url .= '&' . $key . '=' . urlencode(str_replace('_SELF', get_page_name(), $val)); } $iframe_url .= $keep->evaluate(); } return do_template('FORM_SCREEN', array('_GUID' => '228a05e24253f324ea286ea8ac3d8b02' . get_class($this), 'GET' => true, 'IFRAME_URL' => $iframe_url, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'SKIP_VALIDATION' => true)); }
/** * Show my subscriptions. * * @return tempcode The interface. */ function my() { $title = get_page_title('MY_SUBSCRIPTIONS'); $member_id = get_member(); if (has_specific_permission(get_member(), 'assume_any_member')) { $member_id = get_param_integer('id', $member_id); } $subscriptions = array(); $rows = $GLOBALS['SITE_DB']->query_select('subscriptions', array('*'), array('s_member_id' => $member_id)); foreach ($rows as $row) { $product = $row['s_type_code']; $object = find_product($product); if (is_null($object)) { continue; } $products = $object->get_products(false, $product); $subscription_title = $products[$product][4]; $time = get_timezoned_date($row['s_time'], true, false, false, true); $state = do_lang_tempcode('PAYMENT_STATE_' . $row['s_state']); $cancel_button = make_cancel_button($row['s_auto_fund_key'], $row['s_via']); $per = do_lang('_LENGTH_UNIT_' . $products[$product][3]['length_units'], integer_format($products[$product][3]['length'])); $subscriptions[] = array('SUBSCRIPTION_TITLE' => $subscription_title, 'ID' => strval($row['id']), 'PER' => $per, 'AMOUNT' => $row['s_amount'], 'TIME' => $time, 'STATE' => $state, 'TYPE_CODE' => $row['s_type_code'], 'CANCEL_BUTTON' => $cancel_button); } if (count($subscriptions) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } return do_template('ECOM_SUBSCRIPTIONS_SCREEN', array('_GUID' => 'e39cd1883ba7b87599314c1f8b67902d', 'TITLE' => $title, 'SUBSCRIPTIONS' => $subscriptions)); }
/** * Actualiser: find quiz winner. * * @return tempcode The result of execution. */ function _find_winner() { $id = post_param_integer('id'); // Test to see if we have not yet chosen winners $winners = $GLOBALS['SITE_DB']->query_select('quiz_winner', array('q_entry'), array('q_quiz' => $id)); if (!array_key_exists(0, $winners)) { // Close competition $close_time = $GLOBALS['SITE_DB']->query_value('quizzes', 'q_close_time', array('id' => $id)); if (is_null($close_time)) { $GLOBALS['SITE_DB']->query_update('quizzes', array('q_close_time' => time()), array('id' => $id), '', 1); } // Choose all entries $entries = $GLOBALS['SITE_DB']->query('SELECT id,q_member,q_results FROM ' . get_table_prefix() . 'quiz_entries WHERE q_quiz=' . strval($id) . ' AND q_member<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' ORDER BY q_results DESC'); // Choose the maximum number of rows we'll need who could potentially win $num_winners = $GLOBALS['SITE_DB']->query_value('quizzes', 'q_num_winners', array('id' => $id)); if ($num_winners == 0) { $num_winners = 3; } // Having 0 helps nobody, and having more than 0 if zero set hurts nobody if ($num_winners < 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } if ($num_winners >= count($entries)) { $min = 0; } else { $min = $entries[$num_winners]['q_results']; } $filtered_entries = array(); foreach ($entries as $entry) { if ($entry['q_results'] >= $min) { if (!array_key_exists($entry['q_results'], $filtered_entries)) { $filtered_entries[$entry['q_results']] = array(); } // Shuffle around this level $temp = $filtered_entries[$entry['q_results']]; $temp[] = $entry; shuffle($temp); $filtered_entries[$entry['q_results']] = $temp; } } if (count($filtered_entries) == 0) { warn_exit(do_lang_tempcode('NO_POSSIBLE_WINNERS')); } // Pick winners: store for ($i = 0; $i < $num_winners; $i++) { $k = array_keys($filtered_entries); rsort($k); $temp = $filtered_entries[$k[0]]; $_entry = array_shift($temp); if (!is_null($_entry)) { $filtered_entries[$k[0]] = $temp; $winners[] = array('q_entry' => $_entry['id']); $GLOBALS['SITE_DB']->query_insert('quiz_winner', array('q_quiz' => $id, 'q_entry' => $_entry['id'], 'q_winner_level' => $i)); } else { break; } } } $_winners = new ocp_tempcode(); foreach ($winners as $i => $winner) { $member_id = $GLOBALS['SITE_DB']->query_value('quiz_entries', 'q_member', array('id' => $winner['q_entry'])); $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true); switch ($i) { case 0: $name = do_lang_tempcode('WINNER_FIRST', escape_html(integer_format($i + 1)), escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id))); break; case 1: $name = do_lang_tempcode('WINNER_SECOND', escape_html(integer_format($i + 1)), escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id))); break; case 2: $name = do_lang_tempcode('WINNER_THIRD', escape_html(integer_format($i + 1)), escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id))); break; default: $name = do_lang_tempcode('WINNER', escape_html(integer_format($i + 1)), escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id))); break; } $_winners->attach(do_template('INDEX_SCREEN_ENTRY', array('_GUID' => '85f558c8dc99b027dbf4de821de0e419', 'URL' => $url, 'NAME' => $name, 'TARGET' => '_blank'))); } breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('MANAGE_QUIZZES')), array('_SELF:_SELF:find_winner', do_lang_tempcode('CHOOSE')))); // Show the winners $title = get_page_title('FIND_WINNERS'); return do_template('INDEX_SCREEN', array('_GUID' => 'd427ec7300a325ee4f00020ea59468e2', 'TITLE' => $title, 'CONTENT' => $_winners, 'PRE' => do_lang_tempcode('WINNERS_FOUND_AS_FOLLOWS'), 'POST' => '')); }
/** * View an overview of the members adverts on the system. * * @return tempcode The UI */ function adverts() { require_lang('classifieds'); require_code('catalogues'); require_code('ecommerce'); $member_id = get_param_integer('member_id', get_member()); $title = get_page_title($member_id == get_member() ? 'CLASSIFIED_ADVERTS' : '_CLASSIFIED_ADVERTS', true, array($GLOBALS['FORUM_DRIVER']->get_username($member_id))); if (is_guest()) { access_denied('NOT_AS_GUEST'); } enforce_personal_access($member_id); $start = get_param_integer('start', 0); $max = get_param_integer('max', 30); require_code('templates_results_browser'); $max_rows = $GLOBALS['SITE_DB']->query_value('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices c ON c.c_catalogue_name=e.c_name', 'COUNT(*)', array('ce_submitter' => $member_id)); $rows = $GLOBALS['SITE_DB']->query_select('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices c ON c.c_catalogue_name=e.c_name', array('e.*'), array('ce_submitter' => $member_id), 'GROUP BY e.id ORDER BY ce_add_date DESC'); if (count($rows) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $ads = array(); foreach ($rows as $row) { $root = get_param_integer('root', NULL); $data_map = get_catalogue_entry_map($row, NULL, 'CATEGORY', 'DEFAULT', $root, NULL, array(0)); $ad_title = $data_map['FIELD_0']; $purchase_url = build_url(array('page' => 'purchase', 'type' => 'misc', 'filter' => 'CLASSIFIEDS_ADVERT', 'id' => $row['id']), get_module_zone('purchase')); // We'll show all transactions against this ad $transaction_details = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'transactions WHERE purchase_id=' . strval($row['id']) . ' AND item LIKE \'' . db_encode_like('CLASSIFIEDS\\_ADVERT\\_%') . '\''); $_transaction_details = array(); foreach ($transaction_details as $t) { list($found, ) = find_product_row($t['item']); if (!is_null($found)) { $item_title = $found[4]; } else { $item_title = $t['item']; } $_transaction_details[] = array('T_ID' => strval($t['id']), 'PURCHASE_ID' => strval($t['purchase_id']), 'STATUS' => $t['status'], 'REASON' => $t['reason'], 'AMOUNT' => float_format($t['amount']), 'T_CURRENCY' => $t['t_currency'], 'LINKED' => $t['linked'], 'T_TIME' => strval($t['t_time']), 'ITEM' => $t['item'], 'ITEM_TITLE' => $item_title, 'PENDING_REASON' => $t['pending_reason'], 'T_MEMO' => $t['t_memo'], 'T_VIA' => $t['t_via']); } $url_map = array('page' => 'catalogues', 'type' => 'entry', 'id' => $row['id'], 'root' => $root); $url = build_url($url_map, '_SELF'); // No known expiry status: put on free, or let expire if ($row['ce_last_moved'] == $row['ce_add_date']) { require_code('classifieds'); initialise_classified_listing($row); } $ads[] = array('AD_TITLE' => $ad_title, 'TRANSACTION_DETAILS' => $_transaction_details, 'DATE' => get_timezoned_date($row['ce_add_date']), 'DATE_RAW' => strval($row['ce_add_date']), 'EXPIRES_DATE' => get_timezoned_date($row['ce_last_moved']), 'EXPIRES_DATE_RAW' => strval($row['ce_last_moved']), 'ACTIVE' => $row['ce_validated'] == 1, 'PURCHASE_URL' => $purchase_url, 'ID' => strval($row['id']), 'URL' => $url, 'NUM_VIEWS' => integer_format($row['ce_views'])); } $results_browser = results_browser(do_lang('_CLASSIFIED_ADVERTS'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, NULL, true); return do_template('CLASSIFIED_ADVERTS_SCREEN', array('TITLE' => $title, 'RESULTS_BROWSER' => $results_browser, 'ADS' => $ads)); }
/** * 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 browse quizzes/surveys/tests. * * @return tempcode The UI */ function archive() { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $start = get_param_integer('start', 0); $title = get_page_title('QUIZZES'); require_code('quiz'); $max = get_param_integer('max', 20); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'quizzes WHERE ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? 'q_validated=1 AND ' : '') . 'q_open_time<' . strval((int) time()) . ' AND (q_close_time IS NULL OR q_close_time>' . strval((int) time()) . ') ORDER BY q_type ASC,id DESC', $max, $start); $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'quizzes WHERE ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? 'q_validated=1 AND ' : '') . 'q_open_time<' . strval((int) time()) . ' AND (q_close_time IS NULL OR q_close_time>' . strval((int) time()) . ')'); if (count($rows) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $content_tests = new ocp_tempcode(); $content_competitions = new ocp_tempcode(); $content_surveys = new ocp_tempcode(); foreach ($rows as $myrow) { $link = show_quiz_html($myrow); switch ($myrow['q_type']) { case 'SURVEY': $content_surveys->attach($link); break; case 'TEST': $content_tests->attach($link); break; case 'COMPETITION': $content_competitions->attach($link); break; } } $page_num = intval(floor(floatval($start) / floatval($max))) + 1; $num_pages = intval(ceil(floatval($max_rows) / floatval($max))); $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max == 0 ? NULL : $start - $max), '_SELF'); $next_url = count($rows) != $max ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF'); $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => 'ab0d27890dd2c1476dcdf82a46d5be90', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages))); return do_template('QUIZ_ARCHIVE_SCREEN', array('_GUID' => '3073f74b500deba96b7a3031a2e9c8d8', 'TITLE' => $title, 'CONTENT_SURVEYS' => $content_surveys, 'CONTENT_COMPETITIONS' => $content_competitions, 'CONTENT_TESTS' => $content_tests, 'BROWSE' => $browse)); }
/** * 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)); }
/** * Get tempcode for adding/editing form. * * @param ?AUTO_LINK The ID of the award (NULL: not added yet) * @param SHORT_TEXT The title * @param LONG_TEXT The description * @param integer How many points are given to the awardee * @param ID_TEXT The content type the award type is for * @param BINARY Whether to not show the awardee when displaying this award * @param integer The approximate time in hours between awards (e.g. 168 for a week) * @return tempcode The input fields */ function get_form_fields($id = NULL, $title = '', $description = '', $points = 0, $content_type = 'download', $hide_awardee = 0, $update_time_hours = 168) { $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, true)); if (addon_installed('points')) { $fields->attach(form_input_integer(do_lang_tempcode('POINTS'), do_lang_tempcode('DESCRIPTION_AWARD_POINTS'), 'points', $points, true)); } $list = new ocp_tempcode(); $_hooks = array(); $hooks = find_all_hooks('systems', 'awards'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/awards/' . $hook); $hook_object = object_factory('Hook_awards_' . $hook, true); if (is_null($hook_object)) { continue; } $hook_info = $hook_object->info(); if (!is_null($hook_info)) { $_hooks[$hook] = $hook_info['title']->evaluate(); } } asort($_hooks); foreach ($_hooks as $hook => $hook_title) { $list->attach(form_input_list_entry($hook, $hook == $content_type, protect_from_escaping($hook_title))); } if ($list->is_empty()) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields->attach(form_input_list(do_lang_tempcode('CONTENT_TYPE'), do_lang_tempcode('DESCRIPTION_CONTENT_TYPE'), 'content_type', $list)); $fields->attach(form_input_tick(do_lang_tempcode('HIDE_AWARDEE'), do_lang_tempcode('DESCRIPTION_HIDE_AWARDEE'), 'hide_awardee', $hide_awardee == 1)); $fields->attach(form_input_integer(do_lang_tempcode('AWARD_UPDATE_TIME_HOURS'), do_lang_tempcode('DESCRIPTION_AWARD_UPDATE_TIME_HOURS'), 'update_time_hours', $update_time_hours, true)); // Permissions $fields->attach($this->get_permission_fields(is_null($id) ? NULL : strval($id), do_lang_tempcode('AWARD_PERMISSION_HELP'), false, do_lang_tempcode('GIVE_AWARD'))); return $fields; }
/** * Show an order details * * @return tempcode The interface. */ function order_det() { $id = get_param_integer('id'); $title = get_page_title('_MY_ORDER_DETAILS', true, array($id)); $products = array(); $rows = $GLOBALS['SITE_DB']->query_select('shopping_order_details', array('*'), array('order_id' => $id)); breadcrumb_set_parents(array(array('_SELF:orders:misc', do_lang_tempcode('MY_ORDERS')))); foreach ($rows as $row) { $product_info_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $row['p_id']), get_module_zone('catalogues')); $products[] = array('PRODUCT_NAME' => $row['p_name'], 'ID' => strval($row['p_id']), 'AMOUNT' => strval($row['p_price']), 'QUANTITY' => strval($row['p_quantity']), 'DISPATCH_STATUS' => do_lang_tempcode($row['dispatch_status']), 'PRODUCT_DET_URL' => $product_info_url, 'DELIVERABLE' => ''); } if (count($products) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } return do_template('ECOM_ORDERS_DETAILS_SCREEN', array('TITLE' => $title, 'CURRENCY' => get_option('currency'), 'PRODUCTS' => $products)); }
/** * View the warning/punishment history for a member. * * @return tempcode The output of the run */ function history() { $title = get_page_title('PUNITIVE_HISTORY'); require_code('templates_results_table'); $member_id = get_param_integer('id'); $rows = $GLOBALS['FORUM_DB']->query_select('f_warnings', array('*'), array('w_member_id' => $member_id)); if (count($rows) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $max_rows = count($rows); $out = new ocp_tempcode(); $f = array(do_lang_tempcode('SLASH_OR', do_lang_tempcode('DATE'), do_lang_tempcode('BY')), do_lang('WHETHER_MAKE_WARNING'), do_lang('CHANGED_USERGROUP'), do_lang('PUNISHMENT_UNDOING')); $fields_title = results_field_title($f, array()); foreach ($rows as $row) { $date = hyperlink(build_url(array('page' => '_SELF', 'type' => '_ed', 'id' => $row['id'], 'redirect' => get_self_url(true)), '_SELF'), get_timezoned_date($row['w_time']), false, true, $row['w_explanation']); $by = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['w_by']); $date_by = new ocp_tempcode(); $date_by->attach(do_lang_tempcode('SLASH_OR', $date, $by)); $is_warning = escape_html($row['w_is_warning'] ? do_lang_tempcode('YES') : do_lang_tempcode('NO')); $changed_usergroup_from = escape_html(is_null($row['p_changed_usergroup_from']) ? do_lang_tempcode('NO') : do_lang_tempcode('YES')); $charged_points = $row['p_charged_points'] == 0 ? new ocp_tempcode() : div(hyperlink(build_url(array('page' => '_SELF', 'type' => 'undo_charge'), '_SELF'), do_lang_tempcode('RESTORE_POINTS', integer_format($row['p_charged_points'])), false, true, '', NULL, form_input_hidden('id', strval($row['id']))), 'dsgsgdfgddgdf'); $undoing = new ocp_tempcode(); if ($row['p_probation'] == 0) { $_undoing_link = new ocp_tempcode(); } else { $_undoing_url = build_url(array('page' => '_SELF', 'type' => 'undo_probation'), '_SELF'); $_undoing_link = div(hyperlink($_undoing_url, do_lang_tempcode('REMOVE_PROBATION_DAYS', integer_format($row['p_probation'])), false, false, '', NULL, form_input_hidden('id', strval($row['id']))), '46t54yhrtghdfhdhdfg'); } $undoing->attach($_undoing_link); if (addon_installed('points')) { $undoing->attach($charged_points); } if ($row['p_banned_ip'] != '') { $undoing->attach(div(hyperlink(build_url(array('page' => '_SELF', 'type' => 'undo_banned_ip'), '_SELF'), do_lang_tempcode('UNBAN_IP'), false, true, '', NULL, form_input_hidden('id', strval($row['id']))), '4teryeryrydfhyhrgf')); } if ($row['p_banned_member'] == 1) { $undoing->attach(div(hyperlink(build_url(array('page' => '_SELF', 'type' => 'undo_banned_member'), '_SELF'), do_lang_tempcode('UNBAN_MEMBER'), false, true, '', NULL, form_input_hidden('id', strval($row['id']))), '56ytryrtyhrtyrt')); } if (!is_null($row['p_silence_from_topic'])) { $undoing->attach(div(hyperlink(build_url(array('page' => '_SELF', 'type' => 'undo_silence_from_topic'), '_SELF'), do_lang_tempcode('UNSILENCE_TOPIC'), false, true, '', NULL, form_input_hidden('id', strval($row['id']))), 'rgergdfhfhg')); } if (!is_null($row['p_silence_from_forum'])) { $undoing->attach(div(hyperlink(build_url(array('page' => '_SELF', 'type' => 'undo_silence_from_forum'), '_SELF'), do_lang_tempcode('UNSILENCE_FORUM'), false, true, '', NULL, form_input_hidden('id', strval($row['id']))), 'ghgfhfghggf')); } if ($undoing->is_empty()) { $undoing = do_lang_tempcode('NA_EM'); } $g = array($date_by, $is_warning, $changed_usergroup_from, $undoing); $out->attach(results_entry($g)); } $results_table = results_table(do_lang_tempcode('PUNITIVE_HISTORY'), 0, 'start', 1000000, 'max', $max_rows, $fields_title, $out, NULL, NULL, NULL, NULL, paragraph(do_lang_tempcode('PUNITIVE_HISTORY_TEXT'), '4t4ygyerhrth4')); $add_warning_url = build_url(array('page' => '_SELF', 'type' => 'ad', 'id' => $member_id, 'redirect' => get_self_url(true)), '_SELF'); $view_profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true); $edit_profile_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $member_id), get_module_zone('members'), NULL, false, false, false, 'tab__edit'); return do_template('OCF_WARNING_HISTORY_SCREEN', array('_GUID' => '4444beed9305f0460a6c00e6c87d4208', 'TITLE' => $title, 'MEMBER_ID' => strval($member_id), 'EDIT_PROFILE_URL' => $edit_profile_url, 'VIEW_PROFILE_URL' => $view_profile_url, 'ADD_WARNING_URL' => $add_warning_url, 'RESULTS_TABLE' => $results_table)); }