/** * 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)); } }
/** * The actualiser for LDAP synchronisation. * * @return tempcode The UI */ function actual() { $title = get_page_title('LDAP_SYNC'); $all_ldap_groups = ocf_get_all_ldap_groups(); foreach ($all_ldap_groups as $group) { if (post_param_integer('add_group_' . str_replace(' ', '_space_', $group), 0) == 1) { ocf_make_group($group, 0, 0, 0, ''); } } $all_ocp_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach ($all_ocp_groups as $id => $group) { if (post_param_integer('delete_group_' . strval($id), 0) == 1) { ocf_delete_group($id); } } $all_ldap_members = $GLOBALS['FORUM_DB']->query_select('f_members', array('id'), array('m_password_compat_scheme' => 'ldap')); require_code('ocf_groups_action'); require_code('ocf_groups_action2'); foreach ($all_ldap_members as $row) { $id = $row['id']; if (post_param_integer('delete_member_' . strval($id), 0) == 1) { ocf_delete_member($id); } } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('LDAP_SYNC')))); breadcrumb_set_self(do_lang_tempcode('DONE')); $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * The actualiser to apply to join a usergroup. * * @return tempcode The UI */ function apply() { $id = post_param_integer('id', NULL); if (is_null($id)) { $_id = get_param('id'); if (is_numeric($_id)) { $id = intval($_id); } else { $id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'g.id', array('text_original' => $_id)); if (is_null($id)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } } if ($id == db_get_first_id()) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } $_leader = ocf_get_group_property($id, 'group_leader'); $free_access = ocf_get_group_property($id, 'open_membership') == 1; $name = ocf_get_group_name($id); $title = get_page_title('_APPLY_TO_GROUP', true, array(escape_html($name))); $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true); $hidden = form_input_hidden('id', strval($id)); if ($free_access) { $text = do_lang_tempcode('ABOUT_TO_APPLY_FREE_ACCESS', escape_html($name)); } else { if (is_null($_leader) || is_null($GLOBALS['FORUM_DRIVER']->get_username($_leader))) { $text = do_lang_tempcode('ABOUT_TO_APPLY_STAFF', escape_html($name), escape_html(get_site_name())); } else { $leader_username = $GLOBALS['FORUM_DRIVER']->get_username($_leader); if (is_null($leader_username)) { $leader_username = do_lang('UNKNOWN'); } $leader_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($_leader, false, true); $text = do_lang_tempcode('ABOUT_TO_APPLY_LEADER', escape_html($name), escape_html($leader_username), escape_html($leader_url)); } } return do_template('YESNO_SCREEN', array('_GUID' => 'ceafde00ade4492c65ed2e6e2309a0e7', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'HIDDEN' => $hidden)); } if ($id == db_get_first_id()) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } $_name = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_name', array('id' => $id)); $name = get_translated_text($_name, $GLOBALS['FORUM_DB']); $title = get_page_title('_APPLY_TO_GROUP', true, array(escape_html($name))); $free_access = ocf_get_group_property($id, 'open_membership') == 1; if (is_guest()) { access_denied('I_ERROR'); } require_code('ocf_groups'); if (ocf_get_group_property($id, 'open_membership') == 1) { return $this->add_to(true, $GLOBALS['FORUM_DRIVER']->get_username(get_member())); } ocf_member_ask_join_group($id, get_member()); breadcrumb_set_self(do_lang_tempcode('DONE')); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USERGROUPS')), array('_SELF:_SELF:view:id=' . strval($id), do_lang_tempcode('USERGROUP', escape_html($name))))); $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('AWAITING_GROUP_LEADER')); }
/** * The do-next manager for order module * * @return tempcode The UI */ function misc() { breadcrumb_set_self(do_lang_tempcode('ORDERS')); breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')))); require_code('templates_donext'); return do_next_manager(get_page_title('ORDERS'), comcode_lang_string('DOC_ECOMMERCE'), array(array('show_orders', array('_SELF', array('type' => 'show_orders'), '_SELF'), do_lang('SHOW_ORDERS')), array('undispatched', array('_SELF', array('type' => 'show_orders', 'filter' => 'undispatched'), '_SELF'), do_lang('UNDISPATCHED_ORDERS'))), do_lang('ORDERS')); }
/** * View a single filled-in survey. * * @return tempcode The result of execution. */ function __survey_results() { $title = get_page_title('SURVEY_RESULTS'); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/survey_results'; require_code('templates_view_space'); $id = get_param_integer('id'); // entry ID $fields = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('quiz_entries', array('q_time', 'q_member'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $member_id = $rows[0]['q_member']; $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id); if (is_null($username)) { $username = do_lang('UNKNOWN'); } $date = get_timezoned_date($rows[0]['q_time']); $question_rows = $GLOBALS['SITE_DB']->query_select('quiz_questions q LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'quiz_entry_answer a ON q.id=a.q_question', array('q.id', 'q_question_text', 'q_answer', 'q_quiz'), array('q_entry' => $id), 'ORDER BY q.id'); foreach ($question_rows as $q) { $quiz_id = $q['q_quiz']; $answer = $q['q_answer']; if (is_numeric($answer)) { $answer_rows = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('q_answer_text'), array('q_question' => $q['id'], 'id' => intval($answer)), 'ORDER BY id'); if (array_key_exists(0, $answer_rows)) { $answer = get_translated_text($answer_rows[0]['q_answer_text']); } } $fields->attach(view_space_field(get_translated_text($q['q_question_text']), $answer)); } breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('MANAGE_QUIZZES')), array('_SELF:_SELF:_survey_results:id=' . strval($quiz_id), do_lang_tempcode('SURVEY_RESULTS')))); breadcrumb_set_self(do_lang_tempcode('RESULT')); $member_url = get_base_url(); if (!is_guest($member_id)) { $member_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true); if (is_object($member_url)) { $member_url = $member_url->evaluate(); } } return do_template('VIEW_SPACE_SCREEN', array('_GUID' => '02b4dd6d52feaf3844e631e56395c4da', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('SURVEY_WAS_ENTERED_AS_FOLLOWS', escape_html($username), escape_html($member_url), escape_html($date)), 'FIELDS' => $fields)); }
/** * 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 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(); }
function view() { $id = NULL; $name = ''; $image = ''; $cure = ''; $cure_price = 0; $immunization = ''; $immunization_price = 0; $spread_rate = 0; $points_per_spread = 10; $enabled = do_lang_tempcode('DISEASE_DISABLED'); $id = get_param_integer('id', 0); if ($id > 0) { $rows = $GLOBALS['SITE_DB']->query_select('diseases', array('*'), array('id' => $id)); if (isset($rows[0]['id']) && $rows[0]['id'] > 0) { $id = $rows[0]['id']; $name = $rows[0]['name']; $image = $rows[0]['image']; $cure = $rows[0]['cure']; $cure_price = $rows[0]['cure_price']; $immunization = $rows[0]['immunisation']; $immunization_price = $rows[0]['immunisation_price']; $spread_rate = $rows[0]['spread_rate']; $points_per_spread = $rows[0]['points_per_spread']; $enabled = $rows[0]['enabled'] == 1 ? do_lang_tempcode('DISEASE_ENABLED') : do_lang_tempcode('DISEASE_DISABLED'); } } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('OCDEADPEOPLE_TITLE')))); breadcrumb_set_self(do_lang_tempcode('VIEW_DISEASE')); require_code('templates_view_space'); return view_space(get_page_title('VIEW_DISEASE'), array('NAME' => $name, 'IMAGE' => $image, 'CURE' => $cure, 'CURE_PRICE' => integer_format($cure_price), 'IMMUNIZATION' => $immunization, 'IMMUNIZATION_PRICE' => integer_format($immunization_price), 'SPREAD_RATE' => integer_format($spread_rate), 'POINTS_PER_SPREAD' => integer_format($points_per_spread), 'ENABLED' => $enabled)); }
/** * Actualiser: process quiz results. * * @return tempcode The result of execution. */ function _do_quiz() { $id = get_param_integer('id'); $quizzes = $GLOBALS['SITE_DB']->query_select('quizzes', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $quizzes)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $quiz = $quizzes[0]; $this->enforcement_checks($quiz); $last_visit_time = $GLOBALS['SITE_DB']->query_value_null_ok('quiz_member_last_visit', 'v_time', array('v_quiz_id' => $id, 'v_member_id' => get_member()), 'ORDER BY v_time DESC'); if (is_null($last_visit_time)) { warn_exit(do_lang_tempcode('QUIZ_TWICE')); } if (!is_null($quiz['q_timeout'])) { if (time() - $last_visit_time > $quiz['q_timeout'] * 60 + 10) { warn_exit(do_lang_tempcode('TOO_LONG_ON_SCREEN')); } // +10 is for page load time, worst case scenario to be fair } // Our entry $entry_id = $GLOBALS['SITE_DB']->query_insert('quiz_entries', array('q_time' => time(), 'q_member' => get_member(), 'q_quiz' => $id, 'q_results' => 0), true); $GLOBALS['SITE_DB']->query_update('quiz_member_last_visit', array('v_time' => time() - (is_null($quiz['q_timeout']) ? 0 : $quiz['q_timeout']) * 60), array('v_member_id' => get_member(), 'v_quiz_id' => $id), '', 1); // Calculate results and store $questions = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id)); foreach ($questions as $i => $question) { $answers = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $question['id'])); $questions[$i]['answers'] = $answers; } $marks = 0.0; $potential_extra_marks = 0; $out_of = count($questions); if ($out_of == 0) { $out_of = 1; } $results = array(); $corrections = array(); $unknowns = array(); foreach ($questions as $i => $question) { $name = 'q_' . strval($question['id']); if ($question['q_num_choosable_answers'] == 0) { if (count($question['answers']) == 0) { $potential_extra_marks++; $unknowns[] = array(get_translated_text($question['q_question_text']), post_param($name)); } else { $was_right = false; $correct_answer = new ocp_tempcode(); $correct_explanation = NULL; foreach ($question['answers'] as $a) { if ($a['q_is_correct'] == 1) { $correct_answer = make_string_tempcode(escape_html(get_translated_text($a['q_answer_text']))); } if ($a['q_is_correct'] == 1 && get_translated_text($a['q_answer_text']) == post_param($name)) { $marks++; $was_right = true; break; } if (get_translated_text($a['q_answer_text']) == post_param($name)) { $correct_explanation = $a['q_explanation']; } } if (!$was_right) { $correction = array($question['id'], get_translated_text($question['q_question_text']), $correct_answer, post_param($name)); if (!is_null($correct_explanation)) { $explanation = get_translated_text($correct_explanation); if ($explanation != '') { $correction[] = $explanation; } } $corrections[] = $correction; } } $results[$i] = post_param($name); $GLOBALS['SITE_DB']->query_insert('quiz_entry_answer', array('q_entry' => $entry_id, 'q_question' => $question['id'], 'q_answer' => $results[$i])); } elseif ($question['q_num_choosable_answers'] > 1) { // Vector distance $wrongness = 0.0; $accum = new ocp_tempcode(); $correct_answer = new ocp_tempcode(); $correct_explanation = NULL; foreach ($question['answers'] as $a) { $for_this = post_param_integer($name . '_' . strval($a['id']), 0); $should_be_this = $a['q_is_correct']; $dist = $for_this - $should_be_this; $wrongness += $dist * $dist; if ($should_be_this == 1) { if (!$correct_answer->is_empty()) { $correct_answer->attach(do_lang_tempcode('LIST_SEP')); } $correct_answer->attach(escape_html(get_translated_text($a['q_answer_text']))); $correct_explanation = $a['q_explanation']; } if ($for_this == 1) { if (!$accum->is_empty()) { $accum->attach(do_lang_tempcode('LIST_SEP')); } $accum->attach(escape_html(get_translated_text($a['q_answer_text']))); $GLOBALS['SITE_DB']->query_insert('quiz_entry_answer', array('q_entry' => $entry_id, 'q_question' => $question['id'], 'q_answer' => strval($a['id']))); } } $wrongness = sqrt($wrongness); // Normalise it $wrongness /= count($question['answers']); // And get our complement $correctness = 1.0 - $wrongness; $marks += $correctness; if ($correctness != 1.0) { $correction = array($question['id'], get_translated_text($question['q_question_text']), $correct_answer, $accum); if (!is_null($correct_explanation)) { $explanation = get_translated_text($correct_explanation); if ($explanation != '') { $correction[] = $explanation; } } $corrections[] = $correction; } $results[$i] = $accum->evaluate(); } else { $was_right = false; $correct_answer = new ocp_tempcode(); $correct_explanation = NULL; foreach ($question['answers'] as $a) { if ($a['q_is_correct'] == 1) { $correct_answer = make_string_tempcode(escape_html(get_translated_text($a['q_answer_text']))); } if (post_param_integer($name, -1) == $a['id']) { $results[$i] = get_translated_text($a['q_answer_text']); if ($a['q_is_correct'] == 1) { $was_right = true; $marks++; break; } $correct_explanation = $a['q_explanation']; } } $GLOBALS['SITE_DB']->query_insert('quiz_entry_answer', array('q_entry' => $entry_id, 'q_question' => $question['id'], 'q_answer' => post_param($name, ''))); if (!array_key_exists($i, $results)) { $results[$i] = '/'; } if (!$was_right) { $correction = array($question['id'], get_translated_text($question['q_question_text']), $correct_answer, $results[$i]); if (!is_null($correct_explanation)) { $explanation = get_translated_text($correct_explanation); if ($explanation != '') { $correction[] = $explanation; } } $corrections[] = $correction; } } } $mail_title = do_lang('EMAIL_TITLE', do_lang($quiz['q_type']), $GLOBALS['FORUM_DRIVER']->get_username(get_member()), strval($entry_id), get_site_default_lang()); $_corrections = new ocp_tempcode(); $_corrections_to_show = new ocp_tempcode(); foreach ($corrections as $correction) { $this_correction = new ocp_tempcode(); $this_correction->attach(do_lang('QUIZ_MISTAKE', is_object($correction[1]) ? $correction[1]->evaluate() : $correction[1], is_object($correction[3]) ? $correction[3]->evaluate() : $correction[3], array(is_object($correction[2]) ? $correction[2]->evaluate() : $correction[2], array_key_exists(4, $correction) ? $correction[4] : ''))); if (array_key_exists(4, $correction)) { $_corrections_to_show->attach($this_correction); } $_corrections->attach($this_correction); } $_answers = new ocp_tempcode(); foreach ($results as $i => $result) { $_answers->attach(do_lang('QUIZ_RESULT', get_translated_text($questions[$i]['q_question_text']), is_null($result) ? '' : $result)); } $_unknowns = new ocp_tempcode(); foreach ($unknowns as $unknown) { $_unknowns->attach(do_lang('QUIZ_UNKNOWN', $unknown[0], $unknown[1])); } require_code('notifications'); // Award points? if ($out_of == 0) { $out_of = 1; } $minimum_percentage = intval(round(100.0 * $marks / $out_of)); $maximum_percentage = intval(round(100.0 * ($marks + $potential_extra_marks) / $out_of)); if (addon_installed('points') && $quiz['q_points_for_passing'] != 0 && ($quiz['q_type'] != 'TEST' || $minimum_percentage >= $quiz['q_percentage'])) { require_code('points2'); $points_difference = $quiz['q_points_for_passing']; system_gift_transfer(do_lang('POINTS_COMPLETED_QUIZ', get_translated_text($quiz['q_name'])), $points_difference, get_member()); } else { $points_difference = 0; } // Give them their result if it is a test. if ($quiz['q_type'] == 'TEST') { $result = new ocp_tempcode(); $result->attach(paragraph(do_lang_tempcode('MARKS_OUT_OF', float_format($marks) . ($potential_extra_marks == 0 ? '' : '-' . float_format($marks + $potential_extra_marks)), integer_format($out_of), strval($minimum_percentage) . ($potential_extra_marks == 0 ? '' : '-' . strval($maximum_percentage))), 'trete9r0itre')); $result2 = do_lang_tempcode('MAIL_MARKS_OUT_OF', float_format($marks) . ($potential_extra_marks == 0 ? '' : '-' . float_format($marks + $potential_extra_marks)), integer_format($out_of), strval($minimum_percentage) . ($potential_extra_marks == 0 ? '' : '-' . strval($maximum_percentage))); if ($minimum_percentage >= $quiz['q_percentage']) { $result->attach(paragraph(do_lang_tempcode('TEST_PASS'), '4tfdhdhghh')); $result2->attach(do_lang_tempcode('MAIL_TEST_PASS')); syndicate_described_activity('quiz:ACTIVITY_PASSED_TEST', get_translated_text($quiz['q_name']), '', '', '_SEARCH:quiz:do:' . strval($id), '', '', 'quizzes'); } elseif ($maximum_percentage < $quiz['q_percentage']) { $result->attach(paragraph(do_lang_tempcode('TEST_FAIL'), '5yrgdgsdg')); $result2->attach(do_lang_tempcode('MAIL_TEST_FAIL')); } else { $result->attach(paragraph(do_lang_tempcode('TEST_UNKNOWN'), 'yteyrthrt')); $result2->attach(do_lang_tempcode('MAIL_TEST_UNKNOWN')); } // Send mail about the result to the staff: include result and corrections, and unknowns $mail = do_template('QUIZ_TEST_ANSWERS_MAIL', array('_GUID' => 'a0f8f47cdc1ef83b59c93135ebb5c114', 'UNKNOWNS' => $_unknowns, 'CORRECTIONS' => $_corrections, 'RESULT' => $result2, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username(get_member()))); dispatch_notification('quiz_results', strval($id), $mail_title, $mail->evaluate(get_site_default_lang())); } elseif ($quiz['q_type'] == 'COMPETITION') { $result = comcode_to_tempcode($_corrections->evaluate()); syndicate_described_activity('quiz:ACTIVITY_ENTERED_COMPETITION', get_translated_text($quiz['q_name']), '', '', '_SEARCH:quiz:do:' . strval($id), '', '', 'quizzes'); } else { $result = paragraph(do_lang_tempcode('SURVEY_THANKYOU'), '4rtyrthgf'); $_answers = do_template('QUIZ_ANSWERS_MAIL', array('_GUID' => '381f392c8e491b6e078bcae34adc45e8', 'ANSWERS' => $_answers, 'MEMBER_PROFILE_URL' => is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->member_profile_url(get_member(), false, true), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username(get_member()))); // Send mail of answers to the staff dispatch_notification('quiz_results', strval($id), $mail_title, $_answers->evaluate(get_site_default_lang())); syndicate_described_activity('quiz:ACTIVITY_FILLED_SURVEY', get_translated_text($quiz['q_name']), '', '', '_SEARCH:quiz:do:' . strval($id), '', '', 'quizzes'); } // Store results for entry $GLOBALS['SITE_DB']->query_update('quiz_entries', array('q_results' => intval(round($marks))), array('id' => $entry_id), '', 1); breadcrumb_set_self(do_lang_tempcode('DONE')); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', make_string_tempcode(escape_html(get_translated_text($quiz['q_name'])))))); // Show end text $title = get_page_title(do_lang_tempcode('THIS_WITH', do_lang_tempcode($quiz['q_type']), make_string_tempcode(escape_html(get_translated_text($quiz['q_name'])))), false); $fail_text = get_translated_tempcode($quiz['q_end_text_fail']); $message = $quiz['q_type'] != 'TEST' || $minimum_percentage >= $quiz['q_percentage'] || $fail_text->is_empty() ? get_translated_tempcode($quiz['q_end_text']) : get_translated_tempcode($quiz['q_end_text_fail']); return do_template('QUIZ_DONE_SCREEN', array('_GUID' => 'fa783f087eca7f8f577b134ec0bdc4ce', 'CORRECTIONS_TO_SHOW' => comcode_to_tempcode($_corrections_to_show->evaluate()), 'POINTS_DIFFERENCE' => strval($points_difference), 'RESULT' => $result, 'TITLE' => $title, 'TYPE' => $quiz['q_type'], 'MESSAGE' => $message)); }
/** * The actualiser to do an import. * * @return tempcode The UI */ function do_import() { $refresh_url = get_self_url(true, false, array('type' => 'import'), true); $refresh_time = either_param_integer('refresh_time', 15); // Shouldn't default, but reported on some systems to do so if (function_exists('set_time_limit')) { @set_time_limit($refresh_time); } header('Content-type: text/html; charset=' . get_charset()); @ini_set('log_errors', '0'); global $I_REFRESH_URL; $I_REFRESH_URL = $refresh_url; require_code('database_action'); $title = get_page_title('IMPORT'); $importer = get_param('importer'); require_code('hooks/modules/admin_import/' . filter_naughty_harsh($importer)); $object = object_factory('Hook_' . filter_naughty_harsh($importer)); // Get data $old_base_dir = either_param('old_base_dir'); if (method_exists($object, 'verify_base_path') && !$object->verify_base_path($old_base_dir)) { warn_exit(do_lang_tempcode('BAD_IMPORT_PATH', escape_html($old_base_dir))); } 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); // Some preliminary tests $happy = get_param_integer('happy', 0); if (method_exists($object, 'pre_import_tests') && $happy == 0) { $ui = $object->pre_import_tests($import_source, $db_table_prefix, $old_base_dir); if (!is_null($ui)) { return $ui; } } // Save data $GLOBALS['SITE_DB']->query_delete('import_session', array('imp_session' => get_session_id()), '', 1); $GLOBALS['SITE_DB']->query_insert('import_session', array('imp_hook' => '', 'imp_old_base_dir' => $old_base_dir, 'imp_db_name' => is_null($db_name) ? '' : $db_name, 'imp_db_user' => is_null($db_user) ? '' : $db_user, 'imp_db_table_prefix' => is_null($db_table_prefix) ? '' : $db_table_prefix, 'imp_refresh_time' => $refresh_time, 'imp_session' => get_session_id())); $info = $object->info(); $_import_list = $info['import']; $out = new ocp_tempcode(); $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()))); $import_last = '-1'; if (get_forum_type() != 'ocf') { require_code('forum/ocf'); $GLOBALS['OCF_DRIVER'] = new forum_driver_ocf(); $GLOBALS['OCF_DRIVER']->connection = $GLOBALS['SITE_DB']; $GLOBALS['OCF_DRIVER']->MEMBER_ROWS_CACHED = array(); } $_import_list[] = 'ocf_switch'; $all_skipped = true; $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(); } foreach ($_import_list as $import) { $import_this = either_param_integer('import_' . $import, 0); if ($import_this == 1) { $dependency = NULL; if (array_key_exists('dependencies', $info) && array_key_exists($import, $info['dependencies'])) { foreach ($info['dependencies'][$import] as $_dependency) { if (!array_key_exists($_dependency, $parts_done) && isset($lang_array[$_dependency])) { $dependency = $_dependency; } } } if (is_null($dependency)) { if ($import == 'ocf_switch') { $out->attach($this->ocf_switch()); } else { $function_name = 'import_' . $import; ocf_over_local(); $func_output = call_user_func_array(array($object, $function_name), array($import_source, $db_table_prefix, $old_base_dir)); if (!is_null($func_output)) { $out->attach($func_output); } ocf_over_msn(); } $parts_done[$import] = get_session_id(); $import_last = $import; $all_skipped = false; $GLOBALS['SITE_DB']->query_delete('import_parts_done', array('imp_id' => $import, 'imp_session' => get_session_id()), '', 1); $GLOBALS['SITE_DB']->query_insert('import_parts_done', array('imp_id' => $import, 'imp_session' => get_session_id())); } else { $out->attach(do_template('IMPORT_MESSAGE', array('_GUID' => 'b2a853f5fb93beada51a3eb8fbd1575f', 'MESSAGE' => do_lang_tempcode('IMPORT_OF_SKIPPED', escape_html($import), escape_html($dependency))))); } } } if (!$all_skipped) { $lang_code = 'SUCCESS'; if (count($GLOBALS['ATTACHED_MESSAGES_RAW']) != 0) { $lang_code = 'SOME_ERRORS_OCCURRED'; } $out->attach(do_template('IMPORT_MESSAGE', array('_GUID' => '4c4860d021814ffd1df6e21e712c7b44', 'MESSAGE' => do_lang_tempcode($lang_code)))); } log_it('IMPORT'); // Quick and simple decacheing. No need to be smart about this. delete_value('ocf_member_count'); delete_value('ocf_topic_count'); delete_value('ocf_post_count'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('IMPORT')), array('_SELF:_SELF:session', do_lang_tempcode('IMPORT_SESSION')), array('_SELF:_SELF:hook:importer=' . $importer . ':session=' . get_param('session'), do_lang_tempcode('IMPORT')))); breadcrumb_set_self(do_lang_tempcode('START')); $back_url = build_url(array('page' => '_SELF', 'type' => 'hook', 'importer' => get_param('importer'), 'just' => $import_last), '_SELF'); $_GET['just'] = $import_last; return $this->choose_actions($out); }
/** * The actualiser to set page access. * * @return tempcode The UI */ function set_page_access() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/permissionstree'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_permissions'; $title = get_page_title('PAGE_ACCESS'); // Delete to cleanup $zone = post_param('zone'); $GLOBALS['SITE_DB']->query('DELETE FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_page_access WHERE page_name NOT LIKE \'' . db_encode_like('%:%') . '\' AND ' . db_string_equal_to('zone_name', $zone)); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); // $zones=find_all_zones(); $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $zones = array($zone); foreach ($zones as $zone) { $pages = find_all_pages_wrap($zone); foreach (array_keys($pages) as $page) { foreach (array_keys($groups) as $id) { if (in_array($id, $admin_groups)) { continue; } $val = post_param_integer('p_' . $zone . '__' . $page . '__' . strval($id), 0); if ($val == 0) { $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $id)); } } } } breadcrumb_set_parents(array(array('_SELF:_SELF:page', do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:page:zone=' . $zone, do_lang_tempcode('PAGE_ACCESS')))); breadcrumb_set_self(do_lang_tempcode('DONE')); decache('main_sitemap'); $GLOBALS['SITE_DB']->query_delete('cache'); if (function_exists('persistant_cache_empty')) { persistant_cache_empty(); } // Show it worked / Refresh $url = build_url(array('page' => '_SELF', 'type' => 'page'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * The actualiser to move a page. * * @return tempcode The UI */ function _move() { $title = get_page_title('MOVE_PAGES'); if (get_file_base() != get_custom_file_base()) { warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); } $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/move'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure'; $zone = post_param('zone', NULL); if (is_null($zone)) { $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true); $hidden = build_keep_form_fields('', true); return do_template('YESNO_SCREEN', array('_GUID' => 'c6e872cc62bdc7cf1c5157fbfdb2dfd6', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('Q_SURE'), 'URL' => $post_url, 'HIDDEN' => $hidden)); } $new_zone = post_param('destination_zone', ''); if (substr($new_zone, -1) == ':') { $new_zone = substr($new_zone, 0, strlen($new_zone) - 1); } //$pages=find_all_pages_wrap($zone); $pages = array(); require_code('site'); foreach ($_POST as $key => $val) { if (substr($key, 0, 6) == 'page__' && $val === '1') { $page = substr($key, 6); $page_details = _request_page($page, $zone, NULL, NULL, true); if ($page_details === false) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $pages[$page] = strtolower($page_details[0]); if (array_key_exists(3, $page_details)) { $pages[$page] .= '/' . $page_details[3]; } } } $afm_needed = false; foreach ($pages as $page => $type) { if (post_param_integer('page__' . $page, 0) == 1) { if ($type != 'comcode_custom') { $afm_needed = true; } } } if ($afm_needed) { require_code('abstract_file_manager'); force_have_afm_details(); } $cannot_move = new ocp_tempcode(); foreach ($pages as $page => $type) { if (!is_string($page)) { $page = strval($page); } if (post_param_integer('page__' . $page, 0) == 1) { if (substr($type, 0, 7) == 'modules') { $_page = $page . '.php'; } elseif (substr($type, 0, 7) == 'comcode') { $_page = $page . '.txt'; } elseif (substr($type, 0, 4) == 'html') { $_page = $page . '.htm'; } if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) { if (!$cannot_move->is_empty()) { $cannot_move->attach(do_lang_tempcode('LIST_SEP')); } $cannot_move->attach(do_lang_tempcode('PAGE_WRITE', escape_html($page))); continue; } } } $moved_something = NULL; foreach ($pages as $page => $type) { if (!is_string($page)) { $page = strval($page); } if (post_param_integer('page__' . $page, 0) == 1) { $moved_something = $page; if (substr($type, 0, 7) == 'modules') { $_page = $page . '.php'; } elseif (substr($type, 0, 7) == 'comcode') { $_page = $page . '.txt'; } elseif (substr($type, 0, 4) == 'html') { $_page = $page . '.htm'; } if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) { continue; } if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) { if ($afm_needed) { afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true)); } else { rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page)); } } // If a non-overridden one is there too, need to move that too if (strpos($type, '_custom') !== false && file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page)) && !file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page))) { if ($afm_needed) { afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true)); } else { rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page)); } } log_it('MOVE_PAGES', $page); } } if (is_null($moved_something)) { warn_exit(do_lang_tempcode('NOTHING_SELECTED')); } persistant_cache_empty(); require_lang('addons'); if ($cannot_move->is_empty()) { $message = do_lang_tempcode('SUCCESS'); } else { $message = do_lang_tempcode('WOULD_NOT_OVERWRITE_BUT_SUCCESS', $cannot_move); } breadcrumb_set_self(do_lang_tempcode('DONE')); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:move', do_lang_tempcode('MOVE_PAGES')))); decache('main_sitemap'); if (has_js()) { return inform_screen($title, $message); // Came from site-tree editor, so want to just close this window when done } return $this->do_next_manager($title, $moved_something, $new_zone, new ocp_tempcode()); }
/** * Choose product step. * * @param tempcode The page title. * @return tempcode The result of execution. */ function choose($title) { breadcrumb_set_self(do_lang_tempcode('PURCHASING')); /*if (is_guest()) { $register=$GLOBALS['FORUM_DRIVER']->join_url(); if (is_object($register)) $register=$register->evaluate(); $_redirect=build_url(array('page'=>'_SELF','type'=>'misc'),'_SELF'); $redirect=$_redirect->evaluate(); $_login=build_url(array('page'=>'login','redirect'=>$redirect)); $login=$_login->evaluate(); return $this->wrap(do_template('PURCHASE_WIZARD_STAGE_GUEST',array('_GUID'=>'accf475a1457f73d7280b14d774acc6e','TITLE'=>$title,'TEXT'=>do_lang_tempcode('PURCHASE_NOT_LOGGED_IN_2',escape_html($register),escape_html($login)))),$title,NULL); }*/ $url = build_url(array('page' => '_SELF', 'type' => 'message', 'id' => get_param_integer('id', -1)), '_SELF', NULL, true, true); require_code('form_templates'); $list = new ocp_tempcode(); $filter = get_param('filter', ''); $products = find_all_products(); foreach ($products as $product => $details) { if ($filter != '') { if (!is_string($product) || substr($product, 0, strlen($filter)) != $filter) { continue; } } if (($details[0] == PRODUCT_PURCHASE_WIZARD || $details[0] == PRODUCT_SUBSCRIPTION || $details[0] == PRODUCT_CATALOGUE) && method_exists($details[count($details) - 1], 'is_available') && $details[count($details) - 1]->is_available($product, get_member())) { require_code('currency'); $currency = get_option('currency'); $price = currency_convert(floatval($details[1]), $currency, NULL, true); $description = $details[4]; if (strpos($details[4], strpos($details[4], '.') === false ? preg_replace('#\\.00($|[^\\d])#', '', $price) : $price) === false) { $description .= ' (' . $price . ')'; } $list->attach(form_input_list_entry($product, false, protect_from_escaping($description))); } } if ($list->is_empty()) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields = form_input_list(do_lang_tempcode('PRODUCT'), '', 'product', $list, NULL, true); return $this->wrap(do_template('PURCHASE_WIZARD_STAGE_CHOOSE', array('_GUID' => '47c22d48313ff50e6323f05a78342eae', 'FIELDS' => $fields, 'TITLE' => $title)), $title, $url, true); }
/** * The actualiser to import wordpress blog * * @return tempcode The UI */ function _import_wordpress() { check_specific_permission('mass_import', NULL, NULL, 'cms_news'); $title = get_page_title('IMPORT_WP_DB'); require_code('rss'); require_code('news'); require_code('news2'); $GLOBALS['LAX_COMCODE'] = true; require_code('uploads'); is_swf_upload(true); $is_validated = post_param_integer('wp_auto_validate', 0); $to_own_account = post_param_integer('wp_add_to_own', 0); //Wordpress post xml file importing method if (get_param('method') == 'xml') { $rss_url = post_param('xml_url', NULL); if (array_key_exists('file_novalidate', $_FILES)) { if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) { $rss_url = $_FILES['file_novalidate']['tmp_name']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } $rss = new rss($rss_url, true); if (!is_null($rss->error)) { warn_exit($rss->error); } $cat_id = NULL; $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); $extra_post_data = array(); foreach ($rss->gleamed_items as $item) { if (!array_key_exists('category', $item)) { $item['category'] = do_lang('NC_general'); } $extra_post_data[] = $item; foreach ($NEWS_CATS as $_cat => $news_cat) { if (get_translated_text($news_cat['nc_title']) == $item['category']) { $cat_id = $_cat; } } //Check for existing owner categories, if not create blog category for creator if ($to_own_account == 0) { $creator = $item['author']; $submitter_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($creator); } else { $submitter_id = get_member(); } //if(is_null($submitter_id)) continue; //Skip importing posts of nonexisting users $owner_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $submitter_id)); if (is_null($cat_id)) { $cat_id = add_news_category($item['category'], 'newscats/general', '', NULL); $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); } // Add news add_news($item['title'], html_to_comcode($item['news']), NULL, $is_validated, 1, 1, 1, '', array_key_exists('news_article', $item) ? html_to_comcode($item['news_article']) : '', $owner_category_id, array($cat_id), NULL, $submitter_id, 0, time(), NULL, ''); } if (url_is_local($rss_url)) { // Means it is a temp file @unlink($rss_url); } } elseif (get_param('method') == 'db') { import_wordpress_db(); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_BLOGS')), array('_SELF:_SELF:import_wordpress', do_lang_tempcode('IMPORT_WORDPRESS')))); breadcrumb_set_self(do_lang_tempcode('DONE')); return inform_screen($title, do_lang_tempcode('IMPORT_WORDPRESS_DONE')); }
/** * The actualiser to clear statistics. * * @return tempcode The UI */ function _clear() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/statistics_clear'; // Let's clear out the saved graphs $handle = opendir(get_custom_file_base() . '/data_custom/modules/admin_stats/'); if ($handle !== false) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && $file != 'index.html' && $file != 'Thumbs.db' && $file != 'Thumbs.db:encryptable' && $file != '.htaccess' && $file != 'IP_Country.txt' && !is_dir($file)) { $path = get_custom_file_base() . '/data_custom/modules/admin_stats/' . $file; @unlink($path) or intelligent_write_error($path); sync_file('data_custom/modules/admin_stats/' . $file); } } if (post_param('clear') == 'all') { // Clear ALL of the data stored stats in the db $GLOBALS['SITE_DB']->query_delete('hackattack'); $GLOBALS['SITE_DB']->query_delete('failedlogins'); $GLOBALS['SITE_DB']->query_delete('stats'); $GLOBALS['SITE_DB']->query_delete('usersonline_track'); } } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')), array('_SELF:_SELF:clear', do_lang_tempcode('CLEAR_STATISTICS')))); breadcrumb_set_self(do_lang_tempcode('DONE')); return inform_screen(get_page_title('CLEAR_STATISTICS'), do_lang_tempcode('SUCCESS')); }
/** * The UI to edit a configuration page. * * @return tempcode The UI */ function config_category() { require_javascript('javascript_validation'); /*$GLOBALS['HELPER_PANEL_PIC']='pagepics/config'; $GLOBALS['HELPER_PANEL_TUTORIAL']='tut_adv_configuration';*/ $page = get_param('id'); $title = get_page_title(do_lang_tempcode('CONFIG_CATEGORY_' . $page), false); $post_url = build_url(array('page' => '_SELF', 'type' => 'set', 'id' => $page, 'redirect' => get_param('redirect', NULL)), '_SELF'); $category_description = do_lang_tempcode('CONFIG_CATEGORY_DESCRIPTION__' . $page); $rows = $GLOBALS['SITE_DB']->query_select('config', array('*'), array('the_page' => $page)); // Addin special ones if ($page == 'SITE') { $rows[] = array('the_name' => 'timezone', 'human_name' => 'TIME_ZONE', 'config_value' => '', 'the_type' => 'special', 'eval' => '', 'the_page' => 'SITE', 'section' => 'GENERAL', 'explanation' => '', 'shared_hosting_restricted' => 0); } /*global $M_SORT_KEY; This is a lame sort - it doesn't preserve internal order $M_SORT_KEY='section'; usort($rows,'multi_sort');*/ // Better sort $all_known_groups = array(); foreach ($rows as $myrow) { $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false); if (is_null($_group)) { $_group = $myrow['section']; } $_group = strtolower(trim(preg_replace('#(&.*;)|[^\\w\\d\\s]#U', '', $_group))); if (array_key_exists($_group, $all_known_groups) && $all_known_groups[$_group] != $myrow['section']) { $_group = 'std_' . $myrow['section']; } // If cat names translate to same things or are in non-latin characters like Cyrillic $all_known_groups[$_group] = $myrow['section']; } $old_rows = $rows; $rows = array(); ksort($all_known_groups); foreach ($all_known_groups as $group_codename) { foreach ($old_rows as $myrow) { if ($myrow['section'] == $group_codename) { $rows[] = $myrow; } } } // Move advanced group options to the end $rows2 = array(); foreach ($rows as $i => $row) { if ($row['section'] == 'ADVANCED') { $rows2[] = $row; unset($rows[$i]); } } $rows = array_merge($rows, $rows2); // UI hooks $ui_hooks = find_all_hooks('modules', 'admin_config'); $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize'))); $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size'))); $groups = new ocp_tempcode(); require_code('form_templates'); $current_group = ''; $out = ''; $_groups = array(); foreach ($rows as $myrow) { if ($myrow['eval'] != '' && $myrow['the_name'] != 'detect_lang_forum') { if (defined('HIPHOP_PHP')) { require_code('hooks/systems/config_default/' . $myrow['the_name']); $hook = object_factory('Hook_config_default_' . $myrow['the_name']); if (is_null($hook->get_default())) { continue; } } else { $GLOBALS['REQUIRE_LANG_LOOP'] = 10; // LEGACY Workaround for corrupt webhost installers if (is_null(@eval($myrow['eval'] . ';'))) { continue; } // @'d in case default is corrupt, don't want it to give errors forever $GLOBALS['REQUIRE_LANG_LOOP'] = 0; // LEGACY } } $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false); $name = do_lang($myrow['human_name'], NULL, NULL, NULL, NULL, false); $_group_tempcode = is_null($_group) ? make_string_tempcode($myrow['section']) : do_lang_tempcode($myrow['section']); $name_tempcode = is_null($name) ? make_string_tempcode($myrow['human_name']) : do_lang_tempcode($myrow['human_name']); if (get_forum_type() == 'ocf' && $myrow['explanation'] == 'CONFIG_OPTION_forum_in_portal') { $exp_string = $myrow['explanation'] . '__ocf'; } else { $exp_string = $myrow['explanation']; } $_explanation = do_lang($exp_string, NULL, NULL, NULL, NULL, false); if (is_null($_explanation)) { $_explanation = do_lang('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section'], NULL, NULL, NULL, NULL, false); if (is_null($_explanation)) { $explanation = new ocp_tempcode(); } else { $explanation = do_lang_tempcode('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section']); } } else { $explanation = do_lang_tempcode($exp_string); } if ($myrow['shared_hosting_restricted'] == 1 && !is_null($GLOBALS['CURRENT_SHARE_USER'])) { continue; } if ($myrow['section'] != $current_group && $current_group != '') { $_current_group = do_lang_tempcode($current_group); $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false); if (is_null($_group_description)) { $group_description = new ocp_tempcode(); } else { $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize)); } $group = do_template('CONFIG_GROUP', array('_GUID' => 'af4c31daa1bc39714ab83b11bd6d3e51', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_current_group)); $groups->attach($group->evaluate()); $out = ''; } $_groups[$myrow['section']] = $_group_tempcode; switch ($myrow['the_type']) { case 'special': switch ($myrow['the_name']) { case 'timezone': $list = ''; $timezone = get_site_timezone(); foreach (get_timezone_list() as $_timezone => $timezone_nice) { $list .= static_evaluate_tempcode(form_input_list_entry($_timezone, $_timezone == $timezone, $timezone_nice)); } $out .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('TIME_ZONE'), do_lang_tempcode('DESCRIPTION_TIMEZONE_SITE'), 'timezone', make_string_tempcode($list))); break; default: require_code('hooks/modules/admin_config/' . filter_naughty_harsh($myrow['the_name'])); $hook_ob = object_factory('Hook_admin_config_' . filter_naughty_harsh($myrow['the_name'])); $out .= static_evaluate_tempcode($hook_ob->run($myrow)); break; } break; case 'integer': $out .= static_evaluate_tempcode(form_input_integer($name_tempcode, $explanation, $myrow['the_name'], intval(get_option($myrow['the_name'])), false)); break; case 'line': if (strpos($myrow['the_name'], 'colour') !== false && substr(get_option($myrow['the_name']), 0, 1) == '#') { $out .= static_evaluate_tempcode(form_input_colour($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true)); } elseif ($myrow['the_name'] == 'currency') { $list = ''; require_code('currency'); $currencies = array_keys(get_currency_map()); foreach ($currencies as $currency) { $list .= static_evaluate_tempcode(form_input_list_entry($currency, $currency == get_option($myrow['the_name']))); } $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list))); } elseif ($myrow['the_name'] == 'payment_gateway') { $list = ''; $all_via = find_all_hooks('systems', 'ecommerce_via'); foreach (array_keys($all_via) as $via) { $list .= static_evaluate_tempcode(form_input_list_entry($via, $via == get_option($myrow['the_name']))); } $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list))); } else { /*if (strpos($myrow['the_name'],'password')!==false) password fields can't take defaults $out.=static_evaluate_tempcode(form_input_password($name_tempcode,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false)); else */ $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); } break; case 'list': $list = ''; $_value = get_option($myrow['the_name']); $values = explode('|', $myrow['c_data']); foreach ($values as $value) { $_option_text = do_lang('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value, NULL, NULL, NULL, NULL, false); if (!is_null($_option_text)) { $option_text = do_lang_tempcode('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value); } else { $option_text = make_string_tempcode($value); } $list .= static_evaluate_tempcode(form_input_list_entry($value, $_value == $value, $option_text)); } $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list), NULL, false, false)); break; case 'transline': $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); break; case 'text': $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true)); break; case 'transtext': $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true)); break; case 'float': $out .= static_evaluate_tempcode(form_input_float($name_tempcode, $explanation, $myrow['the_name'], floatval(get_option($myrow['the_name'])), false)); break; case 'tick': $out .= static_evaluate_tempcode(form_input_tick($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']) == '1')); break; case 'date': $out .= static_evaluate_tempcode(form_input_date($name_tempcode, $explanation, $myrow['the_name'], false, false, false, intval(get_option($myrow['the_name'])), 40, intval(date('Y')) - 20, NULL, false)); break; case 'forum': case '?forum': if (get_forum_type() == 'ocf' && addon_installed('ocf_forum')) { $current_setting = get_option($myrow['the_name']); if (!is_numeric($current_setting)) { $_current_setting = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $current_setting)); if (is_null($_current_setting)) { if ($myrow['the_type'] == '?forum') { $current_setting = NULL; } else { $current_setting = strval(db_get_first_id()); attach_message(do_lang_tempcode('FORUM_CURRENTLY_UNSET', $name_tempcode), 'notice'); } } else { $current_setting = strval($_current_setting); } } $out .= static_evaluate_tempcode(form_input_tree_list($name_tempcode, $explanation, $myrow['the_name'], NULL, 'choose_forum', array(), false, $current_setting)); } else { $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); } break; case 'category': if (get_forum_type() == 'ocf') { $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'id', array('c_title' => get_option($myrow['the_name']))); require_code('ocf_forums2'); $_list = ocf_nice_get_categories(NULL, $tmp_value); $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list)); } else { $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); } break; case 'usergroup': if (get_forum_type() == 'ocf') { $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'g.id', array('text_original' => get_option($myrow['the_name']))); require_code('ocf_groups'); $_list = ocf_nice_get_usergroups($tmp_value); $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list)); } else { $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false)); } break; } $current_group = $myrow['section']; } if ($out != '') { $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false); if (is_null($_group_description)) { $group_description = new ocp_tempcode(); } else { $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize)); } $group = do_template('CONFIG_GROUP', array('_GUID' => '84c0db86002a33a383a7c2e195dd3913', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_group_tempcode)); $groups->attach($group->evaluate()); } list($warning_details, $ping_url) = handle_conflict_resolution(); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CONFIGURATION')))); breadcrumb_set_self(do_lang_tempcode('CONFIG_CATEGORY_' . $page)); return do_template('CONFIG_CATEGORY_SCREEN', array('_GUID' => 'd01b28b71c38bbb52b6aaf877c7f7b0e', 'CATEGORY_DESCRIPTION' => $category_description, '_GROUPS' => $_groups, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'URL' => $post_url, 'GROUPS' => $groups, 'SUBMIT_NAME' => do_lang_tempcode('SAVE'))); }
/** * The actualiser for deleting all the ticked messages in a room. * * @return tempcode The UI. */ function _chat_delete_many_messages() { breadcrumb_set_self(do_lang_tempcode('DONE')); $title = get_page_title('DELETE_SOME_MESSAGES'); $room_id = get_param_integer('room_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'); } // Actualiser $count = 0; foreach (array_keys($_REQUEST) as $key) { if (substr($key, 0, 4) == 'del_') { delete_chat_messages(array('room_id' => $room_id, 'id' => intval(substr($key, 4)))); $count++; } } if ($count == 0) { warn_exit(do_lang_tempcode('NOTHING_SELECTED')); } decache('side_shoutbox'); $num_remaining = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)', array('room_id' => $room_id)); if ($num_remaining == 0) { $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); } else { $url = build_url(array('page' => '_SELF', 'type' => 'room', 'id' => $room_id, 'start' => get_param_integer('start'), 'max' => get_param_integer('max')), '_SELF'); } // Redirect return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * The UI to either show an existing ticket and allow a reply, or to start a new ticket. * * @return tempcode The UI */ function do_ticket() { require_lang('comcode'); $id = get_param('id', NULL); if ($id == '') { $id = NULL; } if (!is_null($id)) { $_temp = explode('_', $id); if (!isset($_temp[1])) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } // Normal topic, not a ticket! $ticket_owner = intval($_temp[0]); $ticket_id = $_temp[1]; if (is_guest()) { access_denied('NOT_AS_GUEST'); } $this->check_id($id); } else { $ticket_owner = get_member(); $ticket_id = uniqid('', true); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SUPPORT_TICKETS')))); $poster = ''; $new = true; $serialized_options = mixed(); $hash = mixed(); if (!is_guest() || is_null($id)) { $member = get_member(); $new = is_null($id); $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread'))); $start = get_param_integer('start_comments', 0); if ($new) { $id = strval($member) . '_' . $ticket_id; $title = get_page_title('ADD_TICKET'); } else { $ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $id)); $ticket_type_text = get_translated_text($ticket_type); $ticket_type_details = get_ticket_type($ticket_type); $forum = 1; $topic_id = 1; $_ticket_type = 1; // These will be returned by reference $_comments = get_ticket_posts($id, $forum, $topic_id, $_ticket_type, $start, $num_to_show_limit); $_comments_all = get_ticket_posts($id, $forum, $topic_id, $_ticket_type); if (!is_array($_comments) || !array_key_exists(0, $_comments)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $ticket_title = $_comments[0]['title']; if ($ticket_title == '') { $ticket_title = do_lang('UNKNOWN'); } $title = get_page_title('_VIEW_SUPPORT_TICKET', true, array(escape_html($ticket_title), escape_html($ticket_type_text))); breadcrumb_set_self($ticket_title); } $ticket_page_text = comcode_to_tempcode(get_option('ticket_text'), NULL, true); $staff_details = new ocp_tempcode(); $types = $this->build_types_list(get_param('default', '')); $results_browser = NULL; if (!$new) { require_code('templates_internalise_screen'); $test_tpl = internalise_own_screen($title, 30, $_comments_all); if (is_object($test_tpl)) { return $test_tpl; } if (is_null($_comments)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } if (has_specific_permission(get_member(), 'support_operator')) { $staff_details = make_string_tempcode($GLOBALS['FORUM_DRIVER']->topic_url($topic_id, escape_html(get_option('ticket_forum_name')))); } else { $staff_details = new ocp_tempcode(); } require_code('topics'); $renderer = new OCP_Topic(); $renderer->_inject_posts_for_scoring_algorithm($_comments); $renderer->topic_id = $topic_id; // Posts $max_thread_depth = get_param_integer('max_thread_depth', intval(get_option('max_thread_depth'))); list($comments, $serialized_options, $hash) = $renderer->render_posts($num_to_show_limit, $max_thread_depth, true, $ticket_owner, array(), $forum); // Pagination if (!$renderer->is_threaded) { if (count($_comments_all) > $num_to_show_limit) { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('COMMENTS'), NULL, $start, 'start_comments', $num_to_show_limit, 'max_comments', count($_comments_all), NULL, NULL, true); } } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $_comments[0]['date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($_comments[0]['user']), 'publisher' => '', 'modified' => '', 'type' => 'Support ticket', 'title' => $_comments[0]['title'], 'identifier' => '_SEARCH:tickets:ticket:' . $id, 'description' => '', 'image' => find_theme_image('bigicons/tickets')); // "Staff only reply" tickbox if (get_forum_type() == 'ocf' && $GLOBALS['FORUM_DRIVER']->is_staff(get_member())) { require_code('form_templates'); $staff_only = form_input_tick(do_lang('TICKET_STAFF_ONLY'), do_lang('TICKET_STAFF_ONLY_DESCRIPTION'), 'staff_only', false); } else { $staff_only = new ocp_tempcode(); } } else { $comments = new ocp_tempcode(); $staff_only = new ocp_tempcode(); $ticket_type_details = get_ticket_type(NULL); } if ($poster == '' || $GLOBALS['FORUM_DRIVER']->get_guest_id() != intval($poster)) { $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); require_javascript('javascript_validation'); require_javascript('javascript_posting'); require_javascript('javascript_swfupload'); require_css('swfupload'); require_code('form_templates'); list($attachments, $attach_size_field) = get_forum_type() == 'ocf' ? get_attachments('post') : array(NULL, NULL); if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $comment_form = do_template('COMMENTS_POSTING_FORM', array('_GUID' => 'aaa32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'ATTACHMENTS' => $attachments, 'ATTACH_SIZE_FIELD' => $attach_size_field, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => is_guest(), 'EMAIL_OPTIONAL' => is_guest() && $ticket_type_details['guest_emails_mandatory'], 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => '', 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'), 'TITLE' => do_lang_tempcode($new ? 'CREATE_TICKET_MAKE_POST' : 'MAKE_POST'))); } else { $comment_form = new ocp_tempcode(); } $post_url = build_url(array('page' => '_SELF', 'id' => $id, 'type' => 'post', 'redirect' => get_param('redirect', NULL)), '_SELF'); require_code('form_templates'); require_code('feedback'); list($warning_details, $ping_url) = handle_conflict_resolution(NULL, true); $other_tickets = new ocp_tempcode(); $our_topic = NULL; if (!is_guest($ticket_owner)) { $tickets_of_member = get_tickets($ticket_owner, NULL, true); if (!is_null($tickets_of_member)) { foreach ($tickets_of_member as $topic) { $ticket_id = extract_topic_identifier($topic['description']); if ($id != $ticket_id) { $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $ticket_id), '_SELF'); $_title = $topic['firsttitle']; $date = get_timezoned_date($topic['lasttime']); $ticket_owner_name = $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner); if (is_null($ticket_owner_name)) { $profile_link = ''; } else { $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($ticket_owner, false, true); } $last_poster = $topic['lastusername']; $unclosed = !$GLOBALS['FORUM_DRIVER']->is_staff($topic['lastmemberid']); $params = array('NUM_POSTS' => integer_format($topic['num'] - 1), 'CLOSED' => strval($topic['closed']), 'URL' => $url, 'TITLE' => $_title, 'DATE' => $date, 'DATE_RAW' => strval($topic['lasttime']), 'PROFILE_LINK' => $profile_link, 'LAST_POSTER' => $last_poster, 'UNCLOSED' => $unclosed); $other_tickets->attach(do_template('SUPPORT_TICKET_LINK', $params)); } else { $our_topic = $topic; } } } } $toggle_ticket_closed_url = NULL; if (get_forum_type() == 'ocf' && !$new) { $toggle_ticket_closed_url = build_url(array('page' => '_SELF', 'type' => 'toggle_ticket_closed', 'id' => $id), '_SELF'); } $map = array('page' => '_SELF', 'type' => 'ticket'); if (get_param('default', '') != '') { $map['default'] = get_param('default'); } $add_ticket_url = build_url($map, '_SELF'); return do_template('SUPPORT_TICKET_SCREEN', array('_GUID' => 'd21a9d161008c6c44fe7309a14be2c5b', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'TOGGLE_TICKET_CLOSED_URL' => $toggle_ticket_closed_url, 'CLOSED' => is_null($our_topic) ? '0' : strval($our_topic['closed']), 'OTHER_TICKETS' => $other_tickets, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner), 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'NEW' => $new, 'TICKET_PAGE_TEXT' => $ticket_page_text, 'TYPES' => $types, 'STAFF_ONLY' => $staff_only, 'POSTER' => $poster, 'TITLE' => $title, 'COMMENTS' => $comments, 'COMMENT_FORM' => $comment_form, 'STAFF_DETAILS' => $staff_details, 'URL' => $post_url, 'ADD_TICKET_URL' => $add_ticket_url, 'RESULTS_BROWSER' => $results_browser)); } else { return inform_screen(get_page_title('ADD_TICKET'), do_lang_tempcode('SUCCESS')); } }
/** * The actualiser for recommending the site. * * @return tempcode The UI. */ function actual() { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('RECOMMEND_SITE')))); $name = post_param('name'); $message = post_param('message'); $recommender_email_address = post_param('recommender_email_address'); $invite = false; if (addon_installed('captcha')) { require_code('captcha'); enforce_captcha(); } require_code('type_validation'); $email_adrs_to_send = array(); $names_to_send = array(); foreach ($_POST as $key => $email_address) { if (substr($key, 0, 14) != 'email_address_') { continue; } if ($email_address == '') { continue; } if (get_magic_quotes_gpc()) { $email_address = stripslashes($email_address); } if (!is_valid_email_address($email_address)) { attach_message(do_lang_tempcode('INVALID_EMAIL_ADDRESS'), 'warn'); return $this->gui(); } else { $email_adrs_to_send[] = $email_address; $names_to_send[] = $email_address; } if (is_guest()) { break; } } $adrbook_emails = array(); $adrbook_names = array(); $adrbook_use_these = array(); foreach ($_POST as $key => $email_address) { if (preg_match('#details_email_|details_name_|^use_details_#', $key) == 0) { continue; } if (preg_match('#details_email_#', $key) != 0) { if (get_magic_quotes_gpc()) { $email_address = stripslashes($email_address); } if (is_valid_email_address($email_address)) { $curr_num = intval(preg_replace('#details_email_#', '', $key)); $adrbook_emails[$curr_num] = $email_address; } } if (preg_match('#details_name_#', $key)) { $curr_num = intval(preg_replace('#details_name_#', '', $key)); $adrbook_names[$curr_num] = $email_address; } if (preg_match('#^use_details_#', $key)) { $curr_num = intval(preg_replace('#use_details_#', '', $key)); $adrbook_use_these[$curr_num] = $curr_num; } } //add emails from address book file foreach ($adrbook_use_these as $key => $value) { $cur_email = array_key_exists($key, $adrbook_emails) && strlen($adrbook_emails[$key]) > 0 ? $adrbook_emails[$key] : ''; $cur_name = array_key_exists($key, $adrbook_names) && strlen($adrbook_names[$key]) > 0 ? $adrbook_names[$key] : ''; if (strlen($cur_email) > 0) { $email_adrs_to_send[] = $cur_email; $names_to_send[] = strlen($cur_name) > 0 ? $cur_name : $cur_email; } } if (count($email_adrs_to_send) == 0) { warn_exit(do_lang_tempcode('ERROR_NO_CONTACTS_SELECTED')); } foreach ($email_adrs_to_send as $key => $email_address) { if (get_magic_quotes_gpc()) { $email_address = stripslashes($email_address); } if (post_param_integer('wrap_message', 0) == 1) { $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name()))); $referring_username = is_guest() ? NULL : get_member(); $_url = post_param_integer('invite', 0) == 1 ? build_url(array('page' => 'join', 'email_address' => $email_address, 'keep_referrer' => $referring_username), get_module_zone('join')) : build_url(array('page' => '', 'keep_referrer' => $referring_username), ''); $url = $_url->evaluate(); $join_url = $GLOBALS['FORUM_DRIVER']->join_url(); $_message = do_lang(post_param_integer('invite', 0) == 1 ? 'INVITE_MEMBER_MESSAGE' : 'RECOMMEND_MEMBER_MESSAGE', $name, $url, array(get_site_name(), $join_url)) . $message; } else { $title = get_page_title('RECOMMEND_LINK'); $_message = $message; } if (may_use_invites() && get_forum_type() == 'ocf' && !is_guest() && post_param_integer('invite', 0) == 1) { $invites = get_num_invites(get_member()); if ($invites > 0) { send_recommendation_email($name, $email_address, $_message, true, $recommender_email_address, post_param('subject', NULL), $names_to_send[$key]); $GLOBALS['FORUM_DB']->query_insert('f_invites', array('i_inviter' => get_member(), 'i_email_address' => $email_address, 'i_time' => time(), 'i_taken' => 0)); $invite = true; } } elseif (get_option('is_on_invites') == '0' && get_forum_type() == 'ocf') { $GLOBALS['FORUM_DB']->query_insert('f_invites', array('i_inviter' => get_member(), 'i_email_address' => $email_address, 'i_time' => time(), 'i_taken' => 0)); } if (!$invite) { send_recommendation_email($name, $email_address, $_message, false, $recommender_email_address, post_param('subject', NULL), $names_to_send[$key]); } } breadcrumb_set_self(do_lang_tempcode('DONE')); return inform_screen($title, do_lang_tempcode('RECOMMENDATION_MADE')); }
/** * The UI to view details of a specific moderation action. * * @return tempcode The UI */ function view_action() { breadcrumb_set_self(do_lang_tempcode('ENTRY')); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('VIEW_ACTION_LOGS')), array('_SELF:_SELF:list', do_lang_tempcode('RESULTS')))); $mode = get_param('mode', 'ocf'); $id = get_param_integer('id'); if ($mode == 'ocf') { $rows = $GLOBALS['FORUM_DB']->query_select('f_moderator_logs', array('l_reason AS reason', 'id', 'l_by AS the_user', 'l_date_and_time AS date_and_time', 'l_the_type AS the_type', 'l_param_a AS param_a', 'l_param_b AS param_b'), array('id' => $id), '', 1); } else { $rows = $GLOBALS['SITE_DB']->query_select('adminlogs', array('id', 'the_user', 'date_and_time', 'the_type', 'param_a', 'param_b', 'ip'), array('id' => $id), '', 1); } if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $row = $rows[0]; $title = get_page_title('VIEW_ACTION_LOGS'); $username = $GLOBALS['FORUM_DRIVER']->get_username($row['the_user']); if (is_null($username)) { $username = do_lang('UNKNOWN'); } $type_str = do_lang($row['the_type'], $row['param_a'], $row['param_b'], NULL, NULL, false); if (is_null($type_str)) { $type_str = $row['the_type']; } $fields = array('USERNAME' => $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['the_user']), 'DATE_TIME' => get_timezoned_date($row['date_and_time']), 'TYPE' => $type_str, 'PARAMETER_A' => is_null($row['param_a']) ? '' : $row['param_a'], 'PARAMETER_B' => is_null($row['param_b']) ? '' : $row['param_b']); if (array_key_exists('ip', $row)) { $fields['IP_ADDRESS'] = escape_html($row['ip']); } if (array_key_exists('reason', $row)) { $fields['REASON'] = escape_html($row['reason']); } if (addon_installed('securitylogging')) { if (array_key_exists('ip', $row)) { $banned_test_1 = $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_ip', 'ip', array('ip' => $row['ip'])); $fields['IP_BANNED'] = is_null($banned_test_1) ? do_lang_tempcode('NO') : do_lang_tempcode('YES'); if ($row['ip'] != get_ip_address()) { $fields['IP_BANNED']->attach(do_template('ACTION_LOGS_TOGGLE_LINK', array('URL' => build_url(array('page' => '_SELF', 'type' => 'toggle_ip_ban', 'id' => $row['ip']), '_SELF')))); } } $banned_test_2 = $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_member', 'the_member', array('the_member' => $row['the_user'])); $fields['SUBMITTER_BANNED'] = is_null($banned_test_2) ? do_lang_tempcode('NO') : do_lang_tempcode('YES'); if (!is_guest($row['the_user']) && $row['the_user'] != get_member()) { $fields['SUBMITTER_BANNED']->attach(do_template('ACTION_LOGS_TOGGLE_LINK', array('URL' => build_url(array('page' => '_SELF', 'type' => 'toggle_submitter_ban', 'id' => $row['the_user'], 'mode' => $mode, 'action_id' => $id), '_SELF')))); } $banned_test_3 = $GLOBALS['FORUM_DRIVER']->is_banned($row['the_user']); $fields['MEMBER_BANNED'] = $banned_test_3 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); if (get_forum_type() == 'ocf' && !is_guest($row['the_user']) && $row['the_user'] != get_member()) { $fields['MEMBER_BANNED']->attach(do_template('ACTION_LOGS_TOGGLE_LINK', array('URL' => build_url(array('page' => '_SELF', 'type' => 'toggle_member_ban', 'id' => $row['the_user'], 'mode' => $mode, 'action_id' => $id), '_SELF')))); } } $fields['INVESTIGATE_USER'] = hyperlink(build_url(array('page' => 'admin_lookup', 'id' => array_key_exists('ip', $row) ? $row['ip'] : $row['the_user']), '_SELF'), do_lang_tempcode('PROCEED')); require_code('templates_view_space'); return view_space($title, $fields); }
/** * The UI to view a past newsletter. * * @return tempcode The UI */ function view() { $id = get_param_integer('id'); $rows = $GLOBALS['SITE_DB']->query_select('newsletter_archive', array('*'), array('id' => $id)); $time = get_timezoned_date($rows[0]['date_and_time']); $subject = $rows[0]['subject']; $message = $rows[0]['newsletter']; $language = $rows[0]['language']; $level = $rows[0]['importance_level']; /*require_code('lang2'); $language=lookup_language_full_name($rows[0]['language']);*/ breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWSLETTER')), array('_SELF:_SELF:archive', do_lang_tempcode('NEWSLETTER_ARCHIVE')))); breadcrumb_set_self($subject); require_code('templates_view_space'); return view_space(get_page_title('NEWSLETTER'), array('DATE_TIME' => $time, 'LANGUAGE' => $language, 'SUBSCRIPTION_LEVEL' => integer_format($level), 'SUBJECT' => $subject, 'MESSAGE' => comcode_to_tempcode($message))); }
/** * The UI to view details of a gift. * * @return tempcode The UI */ function view() { $id = NULL; $name = ''; $image = ''; $price = 0; $category = ''; $enabled = do_lang_tempcode('GIFT_DISABLED'); $id = get_param_integer('id', NULL); if ($id !== NULL) { $rows = $GLOBALS['SITE_DB']->query_select('ocgifts', array('*'), array('id' => $id)); if (isset($rows[0]['id']) && $rows[0]['id'] > 0) { $id = $rows[0]['id']; $name = $rows[0]['name']; $image = $rows[0]['image']; $price = $rows[0]['price']; $category = $rows[0]['category']; $enabled = $rows[0]['enabled'] == 1 ? do_lang_tempcode('GIFT_ENABLED') : do_lang_tempcode('GIFT_DISABLED'); } } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('OCGIFTS_TITLE')))); breadcrumb_set_self(do_lang_tempcode('VIEW_GIFT')); require_code('templates_view_space'); return view_space(get_page_title('VIEW_GIFT'), array('NAME' => $name, 'IMAGE' => $image, 'PRICE' => integer_format($price), 'CATEGORY' => $category, 'ENABLED' => $enabled)); }
/** * The do-next manager for after content management. * * @param tempcode The title (output of get_page_title) * @param tempcode Some description to show, saying what happened * @param ?ID_TEXT The ID of whatever we are working with (NULL: deleted) * @return tempcode The UI */ function do_next_manager($title, $description, $id) { $archive_url = NULL; if (!is_null($this->archive_entry_point)) { list($zone, $attributes, ) = page_link_decode($this->archive_entry_point); $page = $attributes['page']; unset($attributes['page']); $archive_url = array($page, $attributes, $zone, !isset($this->archive_label) ? NULL : do_lang_tempcode($this->archive_label)); } $view_url = NULL; if (!is_null($this->view_entry_point)) { list($zone, $attributes, ) = page_link_decode(str_replace('_ID', $id, $this->view_entry_point)); $page = $attributes['page']; unset($attributes['page']); $view_url = array($page, $attributes, $zone, !isset($this->view_label) ? NULL : $this->view_label); } breadcrumb_set_self(do_lang_tempcode('DONE')); require_code('templates_donext'); return do_next_manager($title, $description, NULL, NULL, $this->do_next_editing_categories ? NULL : array('_SELF', array('type' => 'a' . $this->type_code), '_SELF', !is_null($this->add_one_label) ? $this->add_one_label : NULL), $this->do_next_editing_categories ? NULL : (is_null($id) || !is_null($this->permissions_require) && !has_specific_permission(get_member(), 'edit_own_' . $this->permissions_require . 'range_content', is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name) ? NULL : array('_SELF', array('type' => '_e' . $this->type_code, 'id' => $id), '_SELF', !is_null($this->edit_this_label) ? $this->edit_this_label : NULL)), $this->do_next_editing_categories ? NULL : (!is_null($this->permissions_require) && !has_specific_permission(get_member(), 'edit_own_' . $this->permissions_require . 'range_content', is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name) ? NULL : array('_SELF', array('type' => 'e' . $this->type_code), '_SELF', !is_null($this->edit_one_label) ? $this->edit_one_label : NULL)), $this->do_next_editing_categories ? NULL : is_null($id) ? NULL : $view_url, $archive_url, NULL, !$this->do_next_editing_categories ? NULL : array('_SELF', array('type' => 'a' . $this->type_code), '_SELF', !is_null($this->add_one_cat_label) ? $this->add_one_cat_label : NULL), !$this->do_next_editing_categories ? NULL : (!is_null($this->permissions_require) && !has_specific_permission(get_member(), 'edit_own_' . $this->permissions_require . 'range_content', is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name) ? NULL : array('_SELF', array('type' => 'e' . $this->type_code), '_SELF', !is_null($this->edit_one_cat_label) ? $this->edit_one_cat_label : NULL)), !$this->do_next_editing_categories ? NULL : (is_null($id) || !is_null($this->permissions_require) && !has_specific_permission(get_member(), 'edit_own_' . $this->permissions_require . 'range_content', is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name) ? NULL : array('_SELF', array('type' => '_e' . $this->type_code, 'id' => $id), '_SELF', !is_null($this->edit_this_cat_label) ? $this->edit_this_cat_label : NULL)), !$this->do_next_editing_categories ? NULL : $view_url, $this->extra_donext_entries, $this->extra_donext_categories, $this->extra_donext_whatever, $this->extra_donext_whatever_title, NULL, $this->entries_title, $this->categories_title); }
/** * The do-next manager for after banner content management. * * @param tempcode The title (output of get_page_title) * @param tempcode Some description to show, saying what happened * @param ?AUTO_LINK The ID of whatever was just handled (NULL: N/A) * @param ID_TEXT The type ID we were working in (NULL: N/A) * @return tempcode The UI */ function _do_next_manager($title, $description, $id, $type) { require_code('templates_donext'); breadcrumb_set_self(do_lang_tempcode('DONE')); if (is_null($id) && is_null($type)) { return do_next_manager($title, $description, NULL, NULL, array('_SELF', array('type' => 'ad'), '_SELF', do_lang_tempcode('ADD_BANNER')), NULL, has_specific_permission(get_member(), 'edit_own_lowrange_content', 'cms_banners') ? array('_SELF', array('type' => 'ed'), '_SELF', do_lang_tempcode('EDIT_BANNER')) : NULL, NULL, NULL, NULL, has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_banners') ? array('_SELF', array('type' => 'ac'), '_SELF', do_lang_tempcode('ADD_BANNER_TYPE')) : NULL, has_specific_permission(get_member(), 'edit_cat_highrange_content', 'cms_banners') ? array('_SELF', array('type' => 'ec'), '_SELF', do_lang_tempcode('EDIT_BANNER_TYPE')) : NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, do_lang_tempcode('BANNER_TYPES')); } return do_next_manager($title, $description, NULL, NULL, array('_SELF', array('type' => 'ad', 'b_type' => $type), '_SELF', do_lang_tempcode('ADD_BANNER')), is_null($id) || !has_specific_permission(get_member(), 'edit_own_lowrange_content', 'cms_banners') ? NULL : array('_SELF', array('type' => '_ed', 'id' => $id), '_SELF', do_lang_tempcode('EDIT_THIS_BANNER')), has_specific_permission(get_member(), 'edit_own_lowrange_content', 'cms_banners') ? array('_SELF', array('type' => 'ed'), '_SELF', do_lang_tempcode('EDIT_BANNER')) : NULL, is_null($id) ? NULL : array('banners', array('type' => 'view', 'source' => $id), get_module_zone('banners')), array('admin_banners', array('type' => 'misc'), get_module_zone('admin_banners')), NULL, has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_banners') ? array('_SELF', array('type' => 'ac'), '_SELF', do_lang_tempcode('ADD_BANNER_TYPE')) : NULL, has_specific_permission(get_member(), 'edit_cat_highrange_content', 'cms_banners') ? array('_SELF', array('type' => 'ec'), '_SELF', do_lang_tempcode('EDIT_BANNER_TYPE')) : NULL, has_specific_permission(get_member(), 'edit_cat_highrange_content', 'cms_banners') ? array('_SELF', array('type' => '_ec', 'id' => $type), '_SELF') : NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, do_lang_tempcode('BANNER_TYPES')); }
/** * Actualiser to deliver an invoice. * * @return tempcode The result. */ function deliver() { $title = get_page_title('MARK_AS_DELIVERED'); breadcrumb_set_self(do_lang_tempcode('DONE')); 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')))); $GLOBALS['SITE_DB']->query_update('invoices', array('i_state' => 'delivered'), array('id' => get_param_integer('id')), '', 1); $url = build_url(array('page' => '_SELF', 'type' => 'undelivered'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * The UI to choose a zone to edit. * * @param string The follow-on type * @param ?tempcode The title to use (NULL: the EDIT_ZONE title) * @return tempcode The UI */ function edit_zone($type = '_edit', $title = NULL) { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/zones'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure'; if (is_null($title)) { $title = get_page_title('EDIT_ZONE'); } $start = get_param_integer('start', 0); $max = get_param_integer('max', 50); $_zones = find_all_zones(false, true, false, $start, $max); $url_map = array('page' => '_SELF', 'type' => $type); if ($type == '_editor') { $url_map['wide'] = 1; } require_code('templates_results_table'); $current_ordering = 'name ASC'; if (strpos($current_ordering, ' ') === false) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } list($sortable, $sort_order) = explode(' ', $current_ordering, 2); $sortables = array(); $header_row = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('TITLE'), do_lang_tempcode('DEFAULT_PAGE'), do_lang_tempcode('THEME'), do_lang_tempcode('DISPLAYED_IN_MENU'), do_lang_tempcode('WIDE'), do_lang_tempcode('REQUIRE_SESSION'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); require_code('form_templates'); $max_rows = $GLOBALS['SITE_DB']->query_value('zones', 'COUNT(*)'); foreach ($_zones as $_zone_details) { list($zone_name, $zone_title, $zone_show_in_menu, $zone_default_page, $remaining_row) = $_zone_details; $edit_link = build_url($url_map + array('id' => $zone_name), '_SELF'); $fields->attach(results_entry(array(hyperlink(build_url(array('page' => ''), $zone_name), $zone_name == '' ? do_lang_tempcode('NA_EM') : make_string_tempcode(escape_html($zone_name))), $zone_title, $zone_default_page, $remaining_row['zone_theme'] == '-1' ? do_lang_tempcode('NA_EM') : hyperlink(build_url(array('page' => 'admin_themes'), 'adminzone'), escape_html($remaining_row['zone_theme'])), $zone_show_in_menu == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $remaining_row['zone_wide'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $remaining_row['zone_require_session'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, $zone_name))), true)); } $table = results_table(do_lang('ZONES'), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ZONES')))); breadcrumb_set_self(do_lang_tempcode('CHOOSE')); $text = do_lang_tempcode('CHOOSE_EDIT_LIST'); return do_template('TABLE_TABLE_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'TABLE' => $table, 'SUBMIT_NAME' => NULL, 'POST_URL' => get_self_url())); }
/** * The actualiser for emptying caches. * * @return tempcode The UI */ function do_rebuild() { $hooks = find_all_hooks('modules', 'admin_cleanup'); // Fiddle the order a bit if (array_key_exists('ocf_topics', $hooks)) { unset($hooks['ocf_topics']); $hooks['ocf_topics'] = 'sources_custom'; } if (array_key_exists('ocf', $hooks)) { unset($hooks['ocf']); $hooks['ocf'] = 'sources_custom'; } if (array_key_exists('ocf_members', $hooks)) { unset($hooks['ocf_members']); $hooks['ocf_members'] = 'sources_custom'; } $todo = array(); foreach (array_keys($hooks) as $hook) { if (post_param_integer($hook, 0) == 1) { $todo[] = $hook; } } $messages = ocportal_cleanup($todo); $messages->attach(paragraph(do_lang_tempcode('SUCCESS'))); $title = get_page_title('CLEANUP_TOOLS'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CLEANUP_TOOLS')))); breadcrumb_set_self(do_lang_tempcode('DONE')); return do_template('CLEANUP_COMPLETED_SCREEN', array('_GUID' => '598510a9ad9f01f3c0806319b32b5033', 'TITLE' => $title, 'MESSAGES' => $messages)); }
/** * The actualiser to contact a member. * * @return tempcode The UI */ function actual() { if (addon_installed('captcha')) { require_code('captcha'); enforce_captcha(); } $member_id = get_param_integer('id'); $email_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_email_address'); if (is_null($email_address)) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } $to_name = $GLOBALS['FORUM_DRIVER']->get_username($member_id); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('EMAIL_MEMBER', escape_html($to_name))))); if (is_null($to_name)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } $from_email = trim(post_param('email_address')); require_code('type_validation'); if (!is_valid_email_address($from_email)) { warn_exit(do_lang_tempcode('INVALID_EMAIL_ADDRESS')); } $from_name = post_param('name'); $title = get_page_title('EMAIL_MEMBER', true, array(escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id)))); require_code('mail'); $attachments = array(); $size_so_far = 0; require_code('uploads'); is_swf_upload(true); foreach ($_FILES as $file) { if (is_swf_upload() || is_uploaded_file($file['tmp_name'])) { $attachments[$file['tmp_name']] = $file['name']; $size_so_far += $file['size']; } else { if (defined('UPLOAD_ERR_NO_FILE') && array_key_exists('error', $file) && $file['error'] != UPLOAD_ERR_NO_FILE) { warn_exit(do_lang_tempcode('ERROR_UPLOADING_ATTACHMENTS')); } } } $size = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_max_email_attach_size_mb'); if ($size_so_far > $size * 1024 * 1024) { warn_exit(do_lang_tempcode('EXCEEDED_ATTACHMENT_SIZE', integer_format($size))); } mail_wrap(do_lang('EMAIL_MEMBER_SUBJECT', get_site_name(), post_param('subject'), NULL, get_lang($member_id)), post_param('message'), array($email_address), $to_name, $from_email, $from_name, 3, $attachments, false, get_member()); log_it('EMAIL', strval($member_id), $to_name); breadcrumb_set_self(do_lang_tempcode('DONE')); $url = get_param('redirect'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * The actualiser for setting up account confirmation. * * @return tempcode The UI */ function step4() { $title = get_page_title('_JOIN'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('_JOIN')))); breadcrumb_set_self(do_lang_tempcode('DONE')); // Check confirm code correct $_code = get_param('code', '-1'); // -1 allowed because people often seem to mess the e-mail link up $code = intval($_code); if ($code <= 0) { require_code('form_templates'); $fields = new ocp_tempcode(); $fields->attach(form_input_email(do_lang_tempcode('EMAIL_ADDRESS'), '', 'email', '', true)); $fields->attach(form_input_integer(do_lang_tempcode('CODE'), '', 'code', NULL, true)); $submit_name = do_lang_tempcode('PROCEED'); return do_template('FORM_SCREEN', array('_GUID' => 'e2c8c3762a308ac7489ec3fb32cc0cf8', 'TITLE' => $title, 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'URL' => get_self_url(false, false, NULL, false, true), 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('MISSING_CONFIRM_CODE'), 'SUBMIT_NAME' => $submit_name)); } $rows = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_validated'), array('m_validated_email_confirm_code' => strval($code), 'm_email_address' => trim(get_param('email')))); if (!array_key_exists(0, $rows)) { $rows = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_validated'), array('m_validated_email_confirm_code' => '', 'm_email_address' => trim(get_param('email')))); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('INCORRECT_CONFIRM_CODE')); } else { $redirect = get_param('redirect', ''); $map = array('page' => 'login', 'type' => 'misc'); if ($redirect != '') { $map['redirect'] = $redirect; } $url = build_url($map, get_module_zone('login')); return redirect_screen($title, $url, do_lang_tempcode('ALREADY_CONFIRMED_THIS')); } } $id = $rows[0]['id']; $validated = $rows[0]['m_validated']; // Activate user $GLOBALS['FORUM_DB']->query_update('f_members', array('m_validated_email_confirm_code' => ''), array('id' => $id), '', 1); if ($validated == 0) { return inform_screen($title, do_lang_tempcode('AWAITING_MEMBER_VALIDATION')); } // Alert user to situation $redirect = get_param('redirect', ''); $map = array('page' => 'login', 'type' => 'misc'); if ($redirect != '') { $map['redirect'] = $redirect; } $url = build_url($map, get_module_zone('login')); return redirect_screen($title, $url, do_lang_tempcode('SUCCESSFUL_CONFIRM')); }
/** * The UI and actualisation for sending out the confirm email. * * @return tempcode The UI */ function step2() { $title = get_page_title('RESET_PASSWORD'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('RESET_PASSWORD')))); breadcrumb_set_self(do_lang_tempcode('START')); $username = trim(post_param('username', '')); $email_address = trim(post_param('email_address', '')); if ($username == '' && $email_address == '') { warn_exit(do_lang_tempcode('PASSWORD_RESET_ERROR')); } if ($username != '') { $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($username); } else { $member = $GLOBALS['FORUM_DRIVER']->get_member_from_email_address($email_address); } if (is_null($member)) { warn_exit(do_lang_tempcode('PASSWORD_RESET_ERROR_2')); } $username = $GLOBALS['FORUM_DRIVER']->get_username($member); if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_password_compat_scheme') == '' && has_specific_permission($member, 'disable_lost_passwords') && !$GLOBALS['IS_ACTUALLY_ADMIN']) { warn_exit(do_lang_tempcode('NO_RESET_ACCESS')); } if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_password_compat_scheme') == 'remote') { warn_exit(do_lang_tempcode('NO_PASSWORD_RESET_REMOTE', ocp_srv('HTTP_HOST'))); } if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_password_compat_scheme') == 'httpauth') { warn_exit(do_lang_tempcode('NO_PASSWORD_RESET_HTTPAUTH')); } $is_ldap = ocf_is_ldap_member($member); $is_httpauth = ocf_is_httpauth_member($member); if ($is_ldap) { warn_exit(do_lang_tempcode('EXT_NO_PASSWORD_CHANGE')); } $code = mt_rand(0, mt_getrandmax()); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_password_change_code' => strval($code)), array('id' => $member), '', 1); $email = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_email_address'); if ($email == '') { warn_exit(do_lang_tempcode('MEMBER_NO_EMAIL_ADDRESS_RESET_TO')); } log_it('RESET_PASSWORD', strval($member), strval($code)); // Send confirm mail $zone = get_module_zone('lostpassword'); $_url = build_url(array('page' => 'lostpassword', 'type' => 'step3', 'code' => $code, 'member' => $member), $zone, NULL, false, false, true); $url = $_url->evaluate(); $_url_simple = build_url(array('page' => 'lostpassword', 'type' => 'step3', 'code' => NULL, 'username' => NULL, 'member' => NULL), $zone, NULL, false, false, true); $url_simple = $_url_simple->evaluate(); $message = do_lang('RESET_PASSWORD_TEXT', comcode_escape(get_site_name()), comcode_escape($username), array(comcode_escape($url), $url_simple, strval($member), strval($code)), get_lang($member)); require_code('mail'); mail_wrap(do_lang('RESET_PASSWORD', NULL, NULL, NULL, get_lang($member)), $message, array($email), $GLOBALS['FORUM_DRIVER']->get_username($member), '', '', 3, NULL, false, NULL, false, false, false, 'MAIL', true); breadcrumb_set_self(do_lang_tempcode('DONE')); return inform_screen($title, do_lang_tempcode('RESET_CODE_MAILED')); }