/** * 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)); }
/** * Get the tempcode for a confirmation page. * * @param tempcode The title for the confirmation page (out of get_page_title) * @param tempcode The preview that's being confirmed for actualisation * @param ID_TEXT The URL type to confirm through to * @param mixed The URL type if we click back OR a full URL (if long, or if tempcode) * @param ?array A map of supplementary post data to get passed through upon confirmation (NULL: none) * @param ?tempcode Form fields to pass through as post data on confirmation (NULL: none) * @return tempcode The confirmation page */ function form_confirm_screen($title, $preview, $url_type, $back_url_type, $sup_post = NULL, $fields = NULL) { if (is_null($sup_post)) { $sup_post = array(); } if (is_string($back_url_type) && strlen($back_url_type) < 10) { $back_url = build_url(array('page' => '_SELF', 'type' => $back_url_type), '_SELF', NULL, true); } else { $back_url = $back_url_type; } $url = build_url(array('page' => '_SELF', 'type' => $url_type), '_SELF', NULL, true); if (is_null($fields)) { $fields = new ocp_tempcode(); } $fields->attach(build_keep_post_fields(array_keys($sup_post))); // Everything EXCEPT what might have been passed in sup_post foreach ($sup_post as $key => $val) { $fields->attach(form_input_hidden($key, is_string($val) ? $val : strval($val))); } return do_template('FORM_CONFIRM_SCREEN', array('_GUID' => 'a99b861d24ab876a40cc010af2b26bc8', 'URL' => $url, 'BACK_URL' => $back_url, 'PREVIEW' => $preview, 'FIELDS' => $fields, 'TITLE' => $title)); }
/** * Give the user an option to see a stack trace by adding in a link, but only if they have permission */ function suggest_fatalistic() { if (may_see_stack_dumps() && get_param_integer('keep_fatalistic', 0) == 0 && running_script('index')) { if (count($_POST) == 0) { $stack_trace_url = build_url(array('page' => '_SELF', 'keep_fatalistic' => 1), '_SELF', NULL, true); $st = do_lang_tempcode('WARN_TO_STACK_TRACE', escape_html($stack_trace_url->evaluate())); } elseif (count($_FILES) == 0) { $stack_trace_url = build_url(array('page' => '_SELF', 'keep_fatalistic' => 1), '_SELF', NULL, true); $p = build_keep_post_fields(); $st = do_lang_tempcode('WARN_TO_STACK_TRACE_2', escape_html($stack_trace_url->evaluate()), $p->evaluate()); } else { $stack_trace_url = build_url(array('page' => '', 'keep_fatalistic' => 1), ''); $st = do_lang_tempcode('WARN_TO_STACK_TRACE_3', escape_html($stack_trace_url->evaluate())); } require_code('site'); attach_message($st, 'inform'); } }
/** * Ninth installation step. * * @return tempcode Progress report / UI */ function step_9() { big_installation_common(); $log = new ocp_tempcode(); $modules = find_all_modules('forum'); foreach ($modules as $module => $type) { if (reinstall_module('forum', $module)) { $log->attach(do_template('INSTALLER_DONE_SOMETHING', array('_GUID' => 'c1d95b9713006acb491b44ff6c79099c', 'SOMETHING' => do_lang_tempcode('INSTALL_MODULE', escape_html($module))))); } } $modules = find_all_modules('cms'); foreach ($modules as $module => $type) { if (reinstall_module('cms', $module)) { $log->attach(do_template('INSTALLER_DONE_SOMETHING', array('_GUID' => '8fdbc968cae73c47d9faf3b4148ac7e1', 'SOMETHING' => do_lang_tempcode('INSTALL_MODULE', escape_html($module))))); } } $blocks = find_all_blocks(); foreach ($blocks as $block => $type) { echo '<!-- Installing block: ' . $block . ' -->' . "\n"; if (reinstall_block($block)) { $log->attach(do_template('INSTALLER_DONE_SOMETHING', array('_GUID' => 'dc9f833239d501f77729778b5c6681b6', 'SOMETHING' => do_lang_tempcode('INSTALL_BLOCK', escape_html($block))))); } } $url = 'install.php?step=10'; return do_template('INSTALLER_STEP_LOG', array('_GUID' => 'b20121b8f4f84dd8e625e3b821c753b3', 'PREVIOUS_STEP' => '8', 'URL' => $url, 'LOG' => $log, 'HIDDEN' => build_keep_post_fields())); }
/** * The UI to confirm which subscribers to prune. * * @return tempcode The UI */ function bounce_filter_c() { $title = get_page_title('BOUNCE_FILTER'); disable_php_memory_limit(); // In case of a huge number $username = post_param('username'); $password = post_param('password'); $server = post_param('server'); $port = post_param_integer('port'); $box = post_param('box'); $mbox = @imap_open($box, $username, $password); if ($mbox === false) { warn_exit(do_lang_tempcode('IMAP_ERROR', imap_last_error())); } $fields = ''; //new ocp_tempcode(); require_code('form_templates'); $all_subscribers = array(); $all_subscribers += collapse_2d_complexity('email', 'id', $GLOBALS['SITE_DB']->query_select('newsletter', array('email', 'id'))); if (get_forum_type() == 'ocf') { $all_subscribers += collapse_2d_complexity('m_email_address', 'id', $GLOBALS['FORUM_DB']->query_select('f_members', array('m_email_address', 'id'), array('m_allow_emails_from_staff' => 1))); } $headers = imap_search($mbox, 'UNDELETED'); if ($headers === false) { $headers = array(); } $num = 0; foreach ($headers as $val) { $msg = imap_body($mbox, $val); $matches = array(); $num_matches = preg_match_all("#<([^\n<>@]+@[^\n<>@]+)>#", $msg, $matches); if ($num_matches != 0) { $overview = imap_headerinfo($mbox, $val); $body = imap_body($mbox, $val); $checked = strpos($body, 'X-Failed-Recipients') !== false || strpos($body, '5.1.1') !== false || strpos($body, '5.1.6') !== false || strpos($body, '5.7.1') !== false; for ($i = 0; $i < $num_matches; $i++) { $m = $matches[1][$i]; $m = str_replace('@localhost.localdomain', '', $m); if ($m != get_option('staff_address') && array_key_exists($m, $all_subscribers)) { $tick = form_input_tick($m, $overview->subject . '.', 'email_' . strval($num), $checked, NULL, $m); $fields .= $tick->evaluate(); // HTMLHTML //$fields->attach($tick); $num++; unset($all_subscribers[$m]); // So as to make the list no longer than needed; each subscriber only considered once } } } } imap_close($mbox); if ($num == 0) { warn_exit(do_lang_tempcode('NO_ENTRIES')); } $submit_name = do_lang_tempcode('PROCEED'); $post_url = get_self_url(); $post_url = build_url(array('page' => '_SELF', 'type' => 'bounce_filter_d'), '_SELF'); return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => build_keep_post_fields(), 'TITLE' => $title, 'TEXT' => do_lang_tempcode('BOUNCE_WHICH'), 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); }
/** * The actualiser for logging in. * * @return tempcode The UI. */ function login_after() { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('_LOGIN')))); $username = trim(post_param('login_username')); $feedback = $GLOBALS['FORUM_DRIVER']->forum_authorise_login($username, NULL, apply_forum_driver_md5_variant(trim(post_param('password')), $username), trim(post_param('password'))); $id = $feedback['id']; if (!is_null($id)) { $title = get_page_title('LOGGED_IN'); $url = enforce_sessioned_url(either_param('redirect')); //set_session_id(get_session_id()); // Just in case something earlier set it to a pre-logged-in one Not needed if (count($_POST) <= 4) { require_code('site2'); assign_refresh($url, 0.0); $post = new ocp_tempcode(); $refresh = new ocp_tempcode(); } else { $post = build_keep_post_fields(array('redirect', 'redirect_passon')); $redirect_passon = post_param('redirect_passon', NULL); if (!is_null($redirect_passon)) { $post->attach(form_input_hidden('redirect', $redirect_passon)); } $refresh = do_template('JS_REFRESH', array('_GUID' => 'c7d2f9e7a2cc637f3cf9ac4d1cf97eca', 'FORM_NAME' => 'redir_form')); } decache('side_users_online'); return do_template('LOGIN_REDIRECT_SCREEN', array('_GUID' => '82e056de9150bbed185120eac3571f40', 'REFRESH' => $refresh, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('_LOGIN_TEXT'), 'URL' => $url, 'POST' => $post)); } else { get_page_title('USER_LOGIN_ERROR'); $text = $feedback['error']; attach_message($text, 'warn'); if (get_forum_type() == 'ocf') { require_lang('ocf'); $forgotten_link = build_url(array('page' => 'lostpassword'), get_module_zone('lostpassword')); $extra = do_lang_tempcode('IF_FORGOTTEN_PASSWORD', escape_html($forgotten_link->evaluate())); attach_message($extra, 'inform'); } return $this->login_before(); } }
/** * The UI to import in bulk from an archive file. * * @return tempcode The UI */ function import() { $title = get_page_title('IMPORT_EMOTICONS'); require_code('form_templates'); $post_url = build_url(array('page' => '_SELF', 'type' => '_import', 'uploading' => 1), '_SELF'); $fields = new ocp_tempcode(); $supported = 'tar'; if (function_exists('zip_open') || get_option('unzip_cmd') != '') { $supported .= ', zip'; } $fields->attach(form_input_upload_multi(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_ARCHIVE_IMAGES', escape_html($supported), escape_html(str_replace(',', ', ', get_option('valid_images')))), 'file', true, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',' . $supported))); $text = paragraph(do_lang_tempcode('IMPORT_EMOTICONS_WARNING')); require_code('images'); $max = floatval(get_max_image_size()) / floatval(1024 * 1024); /*if ($max<1.0) Ok - this is silly! Emoticons are tiny. { require_code('files2'); $config_url=get_upload_limit_config_url(); $text->attach(paragraph(do_lang_tempcode(is_null($config_url)?'MAXIMUM_UPLOAD':'MAXIMUM_UPLOAD_STAFF',escape_html(($max>10.0)?integer_format(intval($max)):float_format($max)),escape_html(is_null($config_url)?'':$config_url)))); }*/ breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('EMOTICONS')), array('_SELF:_SELF:import', do_lang_tempcode('CHOOSE')))); $hidden = build_keep_post_fields(); $hidden->attach(form_input_hidden('test', '1')); handle_max_file_size($hidden); return do_template('FORM_SCREEN', array('_GUID' => '1910e01ec183392f6b254671dc7050a3', 'TITLE' => $title, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('BATCH_IMPORT_ARCHIVE_CONTENTS'), 'URL' => $post_url, 'TEXT' => $text, 'HIDDEN' => $hidden)); }
/** * Check for existing FAQs matching a ticket to be submitted, via searching. * * @param tempcode Page title * @param string Ticket ID we'd be creating * @param string What is being searched for * @return ?tempcode The search results (NULL: could not search) */ function do_search($title, $ticket_id, $content) { require_code('database_search'); // We don't want to display too many --- just enough to show the top results $max = 10; // Search under all hooks we've asked to search under $results = array(); require_code('hooks/modules/search/catalogue_entries'); $object = object_factory('Hook_search_catalogue_entries'); $info = $object->info(); if (is_null($info)) { return NULL; } // Get the ID of the default FAQ catalogue $catalogue_id = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'id', array('c_name' => 'faqs')); if (is_null($catalogue_id)) { return NULL; } // Category filter $where_clause = 'r.' . $info['category'] . '=' . strval($catalogue_id); $boolean_operator = 'OR'; $content_where = build_content_where($content, true, $boolean_operator); $hook_results = $object->run($content, false, 'ASC', $max, 0, false, $content_where, '', NULL, NULL, 'relevance', NULL, $boolean_operator, $where_clause, NULL, true); if (is_null($hook_results) || count($hook_results) == 0) { return NULL; } foreach ($hook_results as $i => $result) { $result['object'] = $object; $result['type'] = 'catalogue_entries'; $hook_results[$i] = $result; } $results = sort_search_results($hook_results, array(), 'ASC'); $out = build_search_results_interface($results, 0, $max, 'ASC'); return do_template('SUPPORT_TICKETS_SEARCH_SCREEN', array('_GUID' => '427e28208e15494a8f126eb4fb2aa60c', 'TITLE' => $title, 'URL' => build_url(array('page' => '_SELF', 'id' => $ticket_id, 'type' => 'post'), '_SELF'), 'POST_FIELDS' => build_keep_post_fields(), 'RESULTS' => $out)); }
/** * UI to choose a language. * * @param tempcode Title for the form * @param boolean Whether to give a tip about edit order * @param boolean Whether to add an 'all' entry to the list * @return mixed The UI (tempcode) or the language to use (string/LANGUAGE_NAME) */ function choose_language($title, $tip = false, $allow_all_selection = false) { if (!multi_lang()) { return user_lang(); } $lang = either_param('lang', NULL); if (!is_null($lang)) { return filter_naughty($lang); } if (!$tip) { $text = do_lang_tempcode('CHOOSE_LANG_DESCRIP'); } else { global $LANGS_MAP; if ($LANGS_MAP === NULL) { $map_a = get_file_base() . '/lang/langs.ini'; $map_b = get_custom_file_base() . '/lang_custom/langs.ini'; if (!is_file($map_b)) { $map_b = $map_a; } $LANGS_MAP = better_parse_ini_file($map_b); } $lang_name = get_site_default_lang(); if (array_key_exists($lang_name, $LANGS_MAP)) { $lang_name = $LANGS_MAP[$lang_name]; } $text = do_lang_tempcode('CHOOSE_LANG_DESCRIP_ADD_TO_MAIN_LANG_FIRST', escape_html($lang_name)); } $langs = new ocp_tempcode(); if ($allow_all_selection) { $langs->attach(form_input_list_entry('', false, do_lang_tempcode('_ALL'))); } $langs->attach(nice_get_langs()); require_code('form_templates'); $fields = form_input_list(do_lang_tempcode('LANGUAGE'), do_lang_tempcode('DESCRIPTION_LANGUAGE'), 'lang', $langs, NULL, true); $hidden = build_keep_post_fields(); $url = get_self_url(); return do_template('FORM_SCREEN', array('_GUID' => '1a2823d450237aa299c095bf9c689a2a', 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $url, 'TEXT' => $text)); }
/** * UI for a setup wizard step (close-status). * * @return tempcode The UI */ function step9() { $title = get_page_title('SETUP_WIZARD_STEP', true, array(integer_format(9), integer_format(10))); $post_url = build_url(array('page' => '_SELF', 'type' => 'step10'), '_SELF'); $text = do_lang_tempcode('SETUP_WIZARD_9_DESCRIBE'); $submit_name = do_lang_tempcode('PROCEED'); require_code('form_templates'); $fields = new ocp_tempcode(); $fields->attach(form_input_tick(do_lang_tempcode('CLOSED_SITE'), do_lang_tempcode('CONFIG_OPTION_site_closed'), 'site_closed', true)); $fields->attach(form_input_text(do_lang_tempcode('MESSAGE'), do_lang_tempcode('CONFIG_OPTION_closed'), 'closed', get_option('closed'), false)); $javascript = "document.getElementById('site_closed').onchange=function() { document.getElementById('closed').disabled=!this.checked; }"; //breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang_tempcode('START')))); return do_template('FORM_SCREEN', array('_GUID' => 'c405a64a08328f78ac0e3f22a8365411', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'SKIPPABLE' => 'skip_9', 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => static_evaluate_tempcode(build_keep_post_fields()), 'JAVASCRIPT' => $javascript)); }
/** * The UI to export an addon (2). * * @return tempcode The UI */ function _addon_export() { $hidden = build_keep_post_fields(); $theme = get_param('theme', NULL, true); $title = get_page_title('EXPORT_ADDON'); // Default meta data $name = ''; $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $organisation = get_site_name(); $description = ''; // ... but the theme might already define some of this if (!is_null($theme)) { $ini_file = ($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini'; if (file_exists($ini_file)) { $details = better_parse_ini_file($ini_file); if (array_key_exists('title', $details)) { $name = $details['title']; } if (array_key_exists('description', $details)) { $description = $details['description']; } if (array_key_exists('author', $details)) { $author = $details['author']; } } } if (get_param('exp', 'custom') == 'lang') { $lang = post_param('lang'); $ini_file = get_custom_file_base() . '/lang_custom/langs.ini'; if (!file_exists($ini_file)) { $ini_file = get_file_base() . '/lang/langs.ini'; } if (file_exists($ini_file)) { $details = better_parse_ini_file($ini_file); if (array_key_exists($lang, $details)) { $name = $details[$lang]; $description = $details[$lang]; } } } $fields = ''; /*XHTMLXHTML*/ require_code('form_templates'); $field = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('AUTHOR'), do_lang_tempcode('DESCRIPTION_AUTHOR'), 'author', $author, true); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('ORGANISATION'), do_lang_tempcode('DESCRIPTION_ORGANISATION'), 'organisation', $organisation, false); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('_VERSION'), do_lang_tempcode('DESCRIPTION_VERSION'), 'version', '1.0', true); $fields .= $field->evaluate(); $field = form_input_text(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, true); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('DEPENDENCIES'), do_lang_tempcode('DESCRIPTION_DEPENDENCIES'), 'dependencies', '', false); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('INCOMPATIBILITIES'), do_lang_tempcode('DESCRIPTION_INCOMPATIBILITIES'), 'incompatibilities', '', false); $fields .= $field->evaluate(); if (get_param('exp', 'custom') == 'theme') { $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_releasing_themes'; if (!is_null($theme)) { // Option for selecting exactly what files are used $field = do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('COUNT_FILES'))); $fields .= $field->evaluate(); $files = $this->do_dir('themes/' . $theme); $i = 0; foreach (array_keys($files) as $file) { $field = form_input_tick(str_replace(array('/', '_'), array('/ ', '_ '), preg_replace('#^themes/' . str_replace('#', '\\#', preg_quote($theme)) . '/#', '', $file)), '', 'file_' . strval($i), true, NULL, $file); $fields .= $field->evaluate(); $i++; } // Option for selecting Comcode pages require_lang('themes'); $field = do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PAGES'), 'HELP' => do_lang_tempcode('THEME_ALSO_INCLUDE_PAGES'))); $fields .= $field->evaluate(); $files = $this->do_dir(''); ksort($files); $fields_after = ''; foreach (array_keys($files) as $file) { if (substr($file, 0, strlen($theme) + 2) == $theme . '__') { $file = substr($file, strlen($theme) + 2); } if (substr($file, -4) == '.txt' && strpos($file, '/comcode_custom/') !== false) { $matches = array(); if (preg_match('#^/((\\w+)/)?pages/comcode_custom/[^/]*/(\\w+)\\.txt$#', $file, $matches) != 0 && $matches[1] != 'docs' . strval(ocp_version())) { $auto_ticked = false; if ($matches[1] == '') { $auto_ticked = $matches[3] == 'start' || substr($matches[3], 0, 6) == 'panel_'; } $field = form_input_tick($matches[1] . ': ' . $matches[3], '', 'file_' . strval($i), $auto_ticked, NULL, $file); if ($auto_ticked) { $fields .= $field->evaluate(); } else { $fields_after .= $field->evaluate(); } $i++; } } } $fields .= $fields_after; } } $submit_name = do_lang_tempcode('EXPORT_ADDON'); $map = array('page' => '_SELF', 'type' => '__addon_export'); if (!is_null($theme)) { $_redirect = build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'); $redirect = $_redirect->evaluate(); $map['redirect'] = $redirect; $map['theme'] = $theme; } $post_url = build_url($map, '_SELF'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ADDONS')), array('_SELF:_SELF:misc', do_lang_tempcode('EXPORT_ADDON')))); breadcrumb_set_self(do_lang_tempcode('CONFIRM')); return do_template('FORM_SCREEN', array('_GUID' => 'dd8bea111b0dfc7df7ddc7e2246f0ef9', 'HIDDEN' => $hidden, 'TITLE' => $title, 'SUBMIT_NAME' => $submit_name, 'FIELDS' => $fields, 'TEXT' => '', 'URL' => $post_url)); }
/** * Script to show previews of content being added/edited. */ function preview_script() { $_GET['wide_high'] = '1'; require_code('preview'); list($output, $validation, $keyword_density, $spelling) = build_preview(true); $output = do_template('PREVIEW_SCRIPT', array('_GUID' => '97bd8909e8b9983a0bbf7ab68fab92f3', 'OUTPUT' => $output->evaluate(), 'VALIDATION' => $validation, 'KEYWORD_DENSITY' => $keyword_density, 'SPELLING' => $spelling, 'HIDDEN' => build_keep_post_fields())); $tpl = do_template('STYLED_HTML_WRAP', array('TITLE' => do_lang_tempcode('PREVIEW'), 'EXTRA_HEAD' => $GLOBALS['EXTRA_HEAD'], 'EXTRA_FOOT' => $GLOBALS['EXTRA_FOOT'], 'FRAME' => true, 'TARGET' => '_top', 'CONTENT' => $output)); $tpl->handle_symbol_preprocessing(); $tpl->evaluate_echo(); }
/** * The actualiser to reverse a point gift transaction. * * @return tempcode The UI */ function reverse() { $title = get_page_title('REVERSE_TITLE'); $id = post_param_integer('id'); $rows = $GLOBALS['SITE_DB']->query_select('gifts', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $amount = $myrow['amount']; $sender_id = $myrow['gift_from']; $recipient_id = $myrow['gift_to']; $confirm = get_param_integer('confirm', 0); if ($confirm == 0) { $_sender_id = is_guest($sender_id) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($sender_id); $_recipient_id = is_guest($recipient_id) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($recipient_id); if (is_null($_sender_id)) { $_sender_id = do_lang('UNKNOWN'); } if (is_null($_recipient_id)) { $_recipient_id = do_lang('UNKNOWN'); } $preview = do_lang_tempcode('ARE_YOU_SURE_REVERSE', escape_html(integer_format($amount)), escape_html($_sender_id), escape_html($_recipient_id)); return do_template('CONFIRM_SCREEN', array('_GUID' => 'd3d654c7dcffb353638d08b53697488b', 'TITLE' => $title, 'PREVIEW' => $preview, 'URL' => get_self_url(false, false, array('confirm' => 1)), 'FIELDS' => build_keep_post_fields())); } $GLOBALS['SITE_DB']->query_delete('gifts', array('id' => $id), '', 1); if (!is_guest($sender_id)) { $_sender_gift_points_used = point_info($sender_id); $sender_gift_points_used = array_key_exists('gift_points_used', $_sender_gift_points_used) ? $_sender_gift_points_used['gift_points_used'] : 0; $GLOBALS['FORUM_DRIVER']->set_custom_field($sender_id, 'gift_points_used', strval($sender_gift_points_used - $amount)); } $temp_points = point_info($recipient_id); $GLOBALS['FORUM_DRIVER']->set_custom_field($recipient_id, 'points_gained_given', strval((array_key_exists('points_gained_given', $temp_points) ? $temp_points['points_gained_given'] : 0) - $amount)); // Show it worked / Refresh $url = get_param('redirect', NULL); if (is_null($url)) { $_url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); $url = $_url->evaluate(); } return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * 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); }
/** * Get a form for finishing off a member profile (such as for LDAP or httpauth, where a partial profile is automatically made, but needs completion). * * @param SHORT_TEXT The username for the member profile. * @param ID_TEXT The type of member profile we are finishing off. * @param string Auto-detected e-mail address (blank: none) * @param ?integer Auto-detected DOB day (NULL: unknown) * @param ?integer Auto-detected DOB month (NULL: unknown) * @param ?integer Auto-detected DOB year (NULL: unknown) * @param ?ID_TEXT Auto-detected Timezone (NULL: unknown) * @param ?ID_TEXT Auto-detected Language (NULL: unknown) * @return tempcode The form. */ function ocf_member_external_linker_ask($username, $type, $email_address = '', $dob_day = NULL, $dob_month = NULL, $dob_year = NULL, $timezone = NULL, $language = NULL) { // If somehow, we're not fully started up, or in a messy state require_code('urls'); @ob_end_clean(); if (!function_exists('do_header')) { require_code('site'); } $title = get_page_title('FINISH_PROFILE'); if ($username != '' && $type != 'ldap') { $username = get_username_from_human_name($username); } list($fields, $hidden) = ocf_get_member_fields(true, NULL, NULL, $email_address, 1, $dob_day, $dob_month, $dob_year, $timezone, NULL, NULL, 1, 0, NULL, $language, 1, 1, 1, NULL, $username, 0, $type); $hidden->attach(build_keep_post_fields()); $hidden->attach(form_input_hidden('finishing_profile', '1')); $text = do_lang_tempcode('ENTER_PROFILE_DETAILS_FINISH'); $submit_name = do_lang_tempcode('PROCEED'); $url = get_self_url(); return do_template('FORM_SCREEN', array('_GUID' => 'f3fa74f4842f3660f0831f8d708d256d', 'HIDDEN' => $hidden, 'TITLE' => $title, 'FIELDS' => $fields, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'URL' => $url)); }
/** * Force an AFM login. */ function get_afm_form() { $fields = get_afm_form_fields(); $title = get_page_title('ABSTRACT_FILE_MANAGEMENT'); $post_url = running_script('index') ? get_self_url(true) : get_self_url_easy(); $submit_name = do_lang_tempcode('PROCEED'); $hidden = build_keep_post_fields(); $hidden->attach(form_input_hidden('got_ftp_details', '1')); if (str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1') { $hidden->attach(form_input_hidden('uses_ftp', '1')); } $javascript = "var ftp_ticker=function() { var uses_ftp=document.getElementById('uses_ftp'); if (!uses_ftp) return; var form=uses_ftp.form; form.elements['ftp_domain'].disabled=!uses_ftp.checked; form.elements['ftp_directory'].disabled=!uses_ftp.checked; form.elements['ftp_username'].disabled=!uses_ftp.checked; form.elements['ftp_password'].disabled=!uses_ftp.checked; form.elements['remember_password'].disabled=!uses_ftp.checked; }; ftp_ticker(); document.getElementById('uses_ftp').onclick=ftp_ticker;"; @ob_end_clean(); $middle = do_template('FORM_SCREEN', array('_GUID' => 'c47a31fca47a7b22eeef3a6269cc2407', 'JAVASCRIPT' => $javascript, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => $submit_name, 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => paragraph(do_lang_tempcode('TEXT_ABSTRACT_FILE_MANAGEMENT')))); $echo = globalise($middle, NULL, '', true); $echo->evaluate_echo(); exit; }
/** * 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)); }
/** * Get information for the user relating to an addon that they are intending to uninstall. * * @param string Name of the addon * @param ?array List of addons that we're currently uninstalling (so dependencies from these are irrelevant). (NULL: none) * @param ?array Addon details. (NULL: load in function) * @return array Pair: warnings, files */ function inform_about_addon_uninstall($name, $also_uninstalling = NULL, $addon_row = NULL) { if (is_null($also_uninstalling)) { $also_uninstalling = array(); } // Read/show info if (is_null($addon_row)) { $addon_row = read_addon_info($name); } $files = new ocp_tempcode(); // The files can come in as either a newline-separated string or an array. // If its an array then we use it as-is, if it's a string then we explode it first. if (is_array($addon_row['addon_files'])) { $loopable = $addon_row['addon_files']; } else { $loopable = explode(chr(10), $addon_row['addon_files']); } foreach ($loopable as $i => $filename) { $files->attach(do_template('ADDON_INSTALL_FILES', array('I' => strval($i), 'DISABLED' => true, 'PATH' => $filename))); } // Check dependencies $dependencies = $addon_row['addon_dependencies_on_this']; foreach ($also_uninstalling as $d) { if (in_array($d, $dependencies)) { unset($dependencies[array_search($d, $dependencies)]); } } $warnings = new ocp_tempcode(); $_dependencies_str = new ocp_tempcode(); foreach ($dependencies as $in) { if (!$_dependencies_str->is_empty()) { $_dependencies_str->attach(do_lang_tempcode('LIST_SEP')); } $_dependencies_str->attach(escape_html($in)); } if (count($dependencies) != 0) { if ($addon_row['addon_author'] == 'Core Team') { $post_fields = build_keep_post_fields(); foreach ($dependencies as $in) { $post_fields->attach(form_input_hidden('uninstall_' . $in, $in)); } if (get_param('type', 'misc') == 'addon_uninstall') { $post_fields->attach(form_input_hidden('uninstall_' . $name, $name)); $url = static_evaluate_tempcode(build_url(array('page' => '_SELF', 'type' => 'multi_action'), '_SELF')); } else { $url = get_self_url(true); } warn_exit(do_lang_tempcode('_ADDON_WARNING_PRESENT_DEPENDENCIES', $_dependencies_str->evaluate(), escape_html($name), array(escape_html($url), $post_fields))); } else { $warnings->attach(do_template('ADDON_INSTALL_WARNING', array('WARNING' => do_lang_tempcode('ADDON_WARNING_PRESENT_DEPENDENCIES', $_dependencies_str, escape_html($name))))); } } return array($warnings, $files); }
/** * 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)); }
/** * Exit with a message about word-filtering. * * @param ?ID_TEXT The name of the parameter this is coming from. Certain parameters are not checked, for reasons of efficiency (avoiding loading whole word check list if not needed) (NULL: don't know param, do not check to avoid) * @param tempcode Error message */ function warn_exit_wordfilter($name, $message) { global $WORD_FILTERING_ALREADY; $WORD_FILTERING_ALREADY = true; if (is_null($name)) { warn_exit($message); } // Output our error / correction form @ob_end_clean(); $hidden = build_keep_post_fields(array($name)); require_code('form_templates'); $value = post_param($name); if (strpos($value, chr(10)) === false) { $fields = form_input_line(do_lang_tempcode('CHANGE'), '', $name, $value, true); } else { $fields = form_input_text(do_lang_tempcode('CHANGE'), '', $name, $value, true); } $post_url = get_self_url(); $output = do_template('FORM_SCREEN', array('TITLE' => get_page_title('ERROR_OCCURRED'), 'TEXT' => $message, 'URL' => $post_url, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'))); $echo = new ocp_tempcode(); if (!running_script('preview')) { $echo = globalise($output, NULL, '', true); $echo->handle_symbol_preprocessing(); } else { $echo->attach(do_template('STYLED_HTML_WRAP', array('TITLE' => do_lang_tempcode('PREVIEW'), 'TARGET' => '_top', 'CONTENT' => $output))); } $echo->evaluate_echo(); exit; }
/** * Do some tests, to make sure we're happy to continue importing. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from * @return ?tempcode Error/warning UI (NULL: no error/warning) */ function pre_import_tests($db, $table_prefix, $file_base) { $title = get_page_title('IMPORT'); $bad = false; // Check actually is ocPortal DB (ERROR) $test = $db->query_value('zones', 'zone_name'); if (is_null($test)) { return warn_screen($title, do_lang_tempcode('ERROR_NOT_CORRECT_DATABASE')); } // Check version (WARNING) $test = $db->query_value_null_ok('values', 'the_value', array('the_name' => 'version')); if (is_null($test) || intval($test) != ocp_version()) { attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_VERSION'), 'warn'); $bad = true; } // Check actually is ocPortal file path (ERROR) if (!file_exists($file_base . '/info.php') || !file_exists($file_base . '/sources_custom')) { attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_FILES'), 'warn'); if (isset($GLOBALS['FORUM_DB']) && $db->connection_write != $GLOBALS['FORUM_DB']->connection_write && !file_exists($file_base . '/info.php')) { attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_LINKING_POSSIBLY'), 'warn'); } $bad = true; } // Check is on same MSN or is OCF (WARNING) if (file_exists($file_base . '/info.php')) { global $SITE_INFO; $backup_site_info = $SITE_INFO; $SITE_INFO = NULL; @(include $file_base . '/info.php'); if (is_null($SITE_INFO)) { $SITE_INFO = $backup_site_info; attach_message(do_lang_tempcode('ERROR_INACESSIBLE_DIR'), 'warn'); if (isset($GLOBALS['FORUM_DB']) && $db->connection_write != $GLOBALS['FORUM_DB']->connection_write) { attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_LINKING_POSSIBLY'), 'warn'); } $bad = true; } else { $this_site_info = $SITE_INFO; $SITE_INFO = $backup_site_info; if (!array_key_exists('db_forums_host', $SITE_INFO)) { $SITE_INFO['db_forums_host'] = 'localhost'; } $same_forum = $this_site_info['db_forums'] == $SITE_INFO['db_forums'] && $this_site_info['db_forums_host'] == $SITE_INFO['db_forums_host'] && $db->table_prefix; if ($this_site_info['forum_type'] != 'ocf' && !$same_forum) { attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_LINKING'), 'warn'); $bad = true; } } } // Show warning if ($bad) { return do_template('CONFIRM_SCREEN', array('_GUID' => '286928b79830cdff4ac506e4f4f00f3a', 'TITLE' => $title, 'PREVIEW' => do_lang_tempcode('IMPORT_WARNINGS_GIVEN'), 'FIELDS' => build_keep_post_fields(), 'URL' => get_self_url(false, false, array('happy' => 1)))); } return NULL; }
/** * Let the user login / do an inline join. * * @return tempcode The result of execution. */ function join_or_login() { $title = get_page_title('CREATE_BOOKING'); // Check login: skip to thanks if logged in if (!is_guest()) { return $this->thanks(); } $url = build_url(array('page' => '_SELF', 'type' => 'done'), '_SELF'); list($javascript, $form) = ocf_join_form($url, true, false, false, false); $hidden = build_keep_post_fields(); return do_template('BOOKING_JOIN_OR_LOGIN_SCREEN', array('TITLE' => $title, 'JAVASCRIPT' => $javascript, 'FORM' => $form, 'HIDDEN' => $hidden)); }
/** * The actualiser for deleting a folder. * * @return tempcode The UI. */ function module_do_delete_folder() { $title = get_page_title('FILEDUMP_DELETE_FOLDER'); $file = filter_naughty(get_param('file')); $place = filter_naughty(get_param('place')); breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('FILE_DUMP')))); if (post_param_integer('confirmed', 0) != 1) { $url = get_self_url(); $text = do_lang_tempcode('CONFIRM_DELETE', $file); breadcrumb_set_self(do_lang_tempcode('CONFIRM')); $hidden = build_keep_post_fields(); $hidden->attach(form_input_hidden('confirmed', '1')); return do_template('CONFIRM_SCREEN', array('_GUID' => '55cd4cafa3bf8285028da9862508d811', 'TITLE' => $title, 'FIELDS' => $hidden, 'PREVIEW' => $text, 'URL' => $url)); } $ret = @rmdir(get_custom_file_base() . '/uploads/filedump' . $place . $file); sync_file('uploads/filedump/' . $place . $file); if ($ret) { $return_url = build_url(array('page' => '_SELF', 'type' => 'misc', 'place' => $place), '_SELF'); log_it('FILEDUMP_DELETE_FOLDER', $file, $place); return redirect_screen($title, $return_url, do_lang_tempcode('SUCCESS')); } else { warn_exit(do_lang_tempcode('FOLDER_DELETE_ERROR')); } return new ocp_tempcode(); }
/** * Show a comcode parser error. * * @param boolean Whether this is being pre-parsed, to pick up errors before row insertion. * @param array Error message details to pass to do_lang, or if the first in the list is NULL, use directly * @param integer The position during parsing that the error occurred at * @param LONG_TEXT The comcode the parser error occurred in * @param boolean Whether to only check the Comcode. * @return tempcode An error message to put in the output stream (shown in certain situations, where in other situations we bomb out). */ function comcode_parse_error($preparse_mode, $_message, $pos, $comcode, $check_only = false) { //echo $comcode; require_lang('comcode'); if (is_null($_message[0])) { $message = $_message[1]; } else { if (strpos($_message[0], ':') === false) { $_message[0] = 'comcode:' . $_message[0]; } $message = call_user_func_array('do_lang_tempcode', array_map('escape_html', $_message)); } $posted = false; foreach ($_POST + $_GET as $name => $val) { if (is_array($val)) { continue; } if (is_integer($name)) { $name = strval($name); } if (post_param($name, '') == $comcode || substr($name, -7) == '_parsed') { $posted = true; } } if (!$check_only) { if ((get_page_name() == 'admin_import' || count($_POST) == 0 || !$posted) && !$preparse_mode) { $line = substr_count(substr($comcode, 0, $pos), chr(10)) + 1; $out = do_template('COMCODE_CRITICAL_PARSE_ERROR', array('LINE' => integer_format($line), 'MESSAGE' => $message, 'SOURCE' => $comcode)); // Won't parse, but we can't help it, so we will skip on return $out; } } $len = strlen($comcode); $lines = new ocp_tempcode(); $number = 1; $sofar = ''; $line = NULL; for ($i = 0; $i < $len; $i++) { $char = $comcode[$i]; if ($i == $pos) { $tmp_tpl = do_template('COMCODE_MISTAKE_ERROR'); $sofar .= $tmp_tpl->evaluate(); $line = $number; } if ($char == chr(10)) { $lines->attach(do_template('COMCODE_MISTAKE_LINE', array('_GUID' => '2022be3de10590d525f333b6ac0da37b', 'NUMBER' => integer_format($number), 'LINE' => make_string_tempcode($sofar)))); $sofar = ''; $number++; } $sofar .= escape_html($char); } if ($i == $pos) { $tmp_tpl = do_template('COMCODE_MISTAKE_ERROR'); $sofar .= $tmp_tpl->evaluate(); } $lines->attach(do_template('COMCODE_MISTAKE_LINE', array('_GUID' => 'eebfe1342f3129d4e31fc9fc1963af2b', 'NUMBER' => integer_format($number), 'LINE' => make_string_tempcode($sofar)))); if (is_null($line)) { $line = $number; } // Now, using some kind of miracle, we need to find out what parameter name blew-up. Let's look through the parameters and see what // is equal to $comcode. I'd rather not do this in a hackerish way - but the architecture was not designed for this. $name = NULL; foreach ($_POST as $key => $val) { if (!is_string($val)) { continue; } if (post_param($key) == $comcode) { $name = $key; break; } } if (is_null($name)) { if ($check_only) { foreach ($_POST as $key => $val) { if (!is_string($val)) { continue; } $val = post_param($key); if (strlen($val) > 10 && (strpos($comcode, $val) === 0 || strpos($comcode, $val) === strlen($comcode) - strlen($val))) { $name = $key; break; } } } if (is_null($name)) { warn_exit(do_lang_tempcode('COMCODE_ERROR', $message, integer_format($line))); } } if (!running_script('comcode_convert')) { $GLOBALS['HTTP_STATUS_CODE'] = '400'; if (!headers_sent()) { // NB: Very important this doesn't run on IE. IE is supposed to show error screens literally if more than 512 bytes, and this is much more (irregardless of compression) - but sometimes seems to still hide it with a "friendly" error anyway if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) { header('HTTP/1.0 400 Bad Request'); } } } // Output our error / correction form @ob_end_clean(); $hidden = build_keep_post_fields(array($name)); require_code('form_templates'); $fields = form_input_text_comcode(do_lang_tempcode('NEW'), do_lang_tempcode('COMCODE_REPLACEMENT'), $name, $comcode, true, NULL, true); $post_url = get_self_url(); $form = do_template('FORM', array('_GUID' => '207bad1252add775029b34ba36e02856', 'URL' => $post_url, 'TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'))); $output = do_template('COMCODE_MISTAKE_SCREEN', array('_GUID' => '0010230e6612b0775566d07ddf54305a', 'EDITABLE' => !running_script('preview'), 'FORM' => $form, 'TITLE' => get_page_title('ERROR_OCCURRED'), 'LINE' => integer_format($line), 'MESSAGE' => $message, 'LINES' => $lines)); $echo = new ocp_tempcode(); if (!running_script('preview')) { $echo = globalise($output, NULL, '', true); $echo->handle_symbol_preprocessing(); } else { $echo->attach(do_template('STYLED_HTML_WRAP', array('TITLE' => do_lang_tempcode('PREVIEW'), 'TARGET' => '_top', 'CONTENT' => $output))); } $echo->evaluate_echo(); exit; return new ocp_tempcode(); // to trick code checker }
/** * Standard modular UI for a separate preview. * * @param tempcode The page title * @return tempcode The UI */ function preview_intercept($title) { require_code('preview'); $output = build_preview(); $url = get_self_url(false, false, array('preview' => 0)); $fields = build_keep_post_fields(); return do_template('CONFIRM_SCREEN', array('_GUID' => '06a3eb06338a7f821676d8ca3eb66aa6', 'TITLE' => $title, 'PREVIEW' => $output, 'URL' => $url, 'FIELDS' => $fields)); }
/** * Standard modular run function. * * @return tempcode Results */ function run() { require_lang('stats'); require_lang('dates'); $delete_older_than = post_param_integer('delete_older_than', NULL); if (is_null($delete_older_than)) { @ob_end_clean(); $delete_older_than = intval(get_option('stats_store_time')); require_code('form_templates'); $fields = form_input_integer(do_lang_tempcode('DPLU_DAYS'), do_lang_tempcode('DESCRIPTION_DELETE_DAYS'), 'delete_older_than', $delete_older_than, true); $post_url = get_self_url(false, false, NULL, false, true); $submit_name = do_lang_tempcode('DELETE'); $hidden = build_keep_post_fields(); $title = get_page_title('PAGE_STATS_DELETE'); $tpl = do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('DELETE_DATA_AVAILABLE'), 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); $echo = globalise($tpl, NULL, '', true); $echo->evaluate_echo(); exit; } if (function_exists('set_time_limit')) { @set_time_limit(0); } // Write install.php file $template = get_custom_file_base() . '/data_custom/modules/admin_cleanup/page_stats.php.pre'; if (!file_exists($template)) { $template = get_file_base() . '/data/modules/admin_cleanup/page_stats.php.pre'; } $_install_php_file = file_get_contents($template); $install_php_file = ocp_tempnam('ps'); $tmpfile = fopen($install_php_file, 'wb'); fwrite($tmpfile, substr($_install_php_file, 0, strpos($_install_php_file, '{!!DB!!}'))); // Get old data do { $or_list = ''; $data = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'stats WHERE date_and_time<' . strval(time() - 60 * 60 * 24 * $delete_older_than), 500); foreach ($data as $d) { $list = ''; foreach ($d as $name => $value) { if (is_null($value)) { continue; } if ($list != '') { $list .= ','; } $list .= "'" . (is_string($name) ? $name : strval($name)) . "'=>"; if (!is_integer($value)) { $list .= "'" . str_replace('\'', '\\\'', $value) . "'"; } else { $list .= strval($value); } } fwrite($tmpfile, "\t\$GLOBALS['SITE_DB']->query_insert('stats',array({$list}));\n"); if ($or_list != '') { $or_list .= ' OR '; } $or_list .= 'id=' . strval($d['id']); } if ($or_list != '') { $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'stats WHERE ' . $or_list); } } while ($data != array()); fwrite($tmpfile, substr($_install_php_file, strpos($_install_php_file, '{!!DB!!}') + 8)); // Make tar require_code('tar'); $file = 'stats-leading-to-' . date('Y-m-d', utctime_to_usertime(time() - 60 * 60 * 24 * $delete_older_than)); $stats_backup_url = get_custom_base_url() . '/exports/backups/' . $file . '.tar'; $myfile = tar_open(get_custom_file_base() . '/exports/backups/' . $file . '.tar', 'wb'); tar_add_file($myfile, $file . '.php', $install_php_file, 0664, time(), true); tar_close($myfile); fclose($tmpfile); @unlink($install_php_file); $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'stats WHERE date_and_time<' . strval(time() - 60 * 60 * 24 * $delete_older_than)); return do_template('CLEANUP_PAGE_STATS', array('_GUID' => '1df213eee7c5c6b97168e5a34e92d3b0', 'STATS_BACKUP_URL' => $stats_backup_url)); }
/** * Actualiser to delete an invoice. * * @return tempcode The result. */ function delete() { $title = get_page_title('DELETE_INVOICE'); breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('INVOICES')), array('_SELF:_SELF:undelivered', do_lang_tempcode('UNDELIVERED_INVOICES')))); if (post_param_integer('confirmed', 0) != 1) { $url = get_self_url(); $text = do_lang_tempcode('DELETE_INVOICE'); breadcrumb_set_self(do_lang_tempcode('CONFIRM')); $hidden = build_keep_post_fields(); $hidden->attach(form_input_hidden('confirmed', '1')); $hidden->attach(form_input_hidden('from', get_param('from', 'misc'))); return do_template('CONFIRM_SCREEN', array('_GUID' => '45707062c00588c33726b256e8f9ba40', 'TITLE' => $title, 'FIELDS' => $hidden, 'PREVIEW' => $text, 'URL' => $url)); } breadcrumb_set_self(do_lang_tempcode('DONE')); $GLOBALS['SITE_DB']->query_delete('invoices', array('id' => get_param_integer('id')), '', 1); $url = build_url(array('page' => '_SELF', 'type' => post_param('from', 'misc')), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * Get the join form. * * @param tempcode URL to direct to * @param boolean Whether to handle CAPTCHA (if enabled at all) * @param boolean Whether to ask for intro messages (if enabled at all) * @param boolean Whether to check for invites (if enabled at all) * @param boolean Whether to check email-address restrictions (if enabled at all) * @return array A tuple: Necessary Javascript code, the form */ function ocf_join_form($url, $captcha_if_enabled = true, $intro_message_if_enabled = true, $invites_if_enabled = true, $one_per_email_address_if_enabled = true) { ocf_require_all_forum_stuff(); require_css('ocf'); require_code('ocf_members_action'); require_code('ocf_members_action2'); require_code('form_templates'); $hidden = new ocp_tempcode(); $hidden->attach(build_keep_post_fields()); $groups = ocf_get_all_default_groups(true); $primary_group = either_param_integer('primary_group', NULL); if ($primary_group !== NULL && !in_array($primary_group, $groups)) { // Check security $test = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_is_presented_at_install', array('id' => $primary_group)); if ($test == 1) { $groups = ocf_get_all_default_groups(false); $hidden = form_input_hidden('primary_group', strval($primary_group)); $groups[] = $primary_group; } } list($fields, $_hidden) = ocf_get_member_fields(true, NULL, $groups); $hidden->attach($_hidden); if ($intro_message_if_enabled) { $forum_id = get_option('intro_forum_id'); if ($forum_id != '') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('INTRODUCE_YOURSELF')))); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'intro_title', do_lang('INTRO_POST_DEFAULT', '___'), false)); $fields->attach(form_input_text_comcode(do_lang_tempcode('POST_COMMENT'), do_lang_tempcode('DESCRIPTION_INTRO_POST'), 'intro_post', '', false)); } } $text = do_lang_tempcode('ENTER_PROFILE_DETAILS'); if ($captcha_if_enabled) { if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $fields->attach(form_input_captcha()); $text->attach(' '); $text->attach(do_lang_tempcode('FORM_TIME_SECURITY')); } } } $submit_name = do_lang_tempcode('PROCEED'); require_javascript('javascript_ajax'); $script = find_script('username_check'); $javascript = "\n\t\tvar form=document.getElementById('username').form;\n\t\tform.elements['username'].onchange=function()\n\t\t{\n\t\t\tif (form.elements['intro_title'])\n\t\t\t\tform.elements['intro_title'].value='" . addslashes(do_lang('INTRO_POST_DEFAULT')) . "'.replace(/\\{1\\}/g,form.elements['username'].value);\n\t\t}\n\t\tform.old_submit=form.onsubmit;\n\t\tform.onsubmit=function()\n\t\t\t{\n\t\t\t\tif ((form.elements['email_address_confirm']) && (form.elements['email_address_confirm'].value!=form.elements['email_address'].value))\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('EMAIL_ADDRESS_MISMATCH')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['password'].value))\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\tvar url='" . addslashes($script) . "?username='******'username'].value);\n\t\t\t\tif (!do_ajax_field_test(url,'password='******'password'].value)))\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t"; $script = find_script('snippet'); if ($invites_if_enabled) { if (get_option('is_on_invites') == '1') { $javascript .= "\n\t\t\t\t\turl='" . addslashes($script) . "?snippet=invite_missing&name='+window.encodeURIComponent(form.elements['email_address'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t"; } } if ($one_per_email_address_if_enabled) { if (get_option('one_per_email_address') == '1') { $javascript .= "\n\t\t\t\t\turl='" . addslashes($script) . "?snippet=email_exists&name='+window.encodeURIComponent(form.elements['email_address'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t"; } } if ($captcha_if_enabled) { if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $javascript .= "\n\t\t\t\t\t\turl='" . addslashes($script) . "?snippet=captcha_wrong&name='+window.encodeURIComponent(form.elements['security_image'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t"; } } } $javascript .= "\n\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\treturn true;\n\t\t\t};\n\t"; $form = do_template('FORM', array('TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $url)); return array($javascript, $form); }