/** * Standard aed_module run_start. * * @param ID_TEXT The type of module execution * @return tempcode The output of the run */ function run_start($type) { $this->cat_aed_module = new Module_cms_calendar_cat(); $this->javascript = "\n\t\t\tvar form=document.getElementById('recurrence_pattern').form;\n\t\t\tvar crf=function() {\n\t\t\t\tvar s=(form.elements['recurrence'][0].checked);\n\t\t\t\tif (form.elements['recurrence_pattern']) form.elements['recurrence_pattern'].disabled=s;\n\t\t\t\tif (form.elements['recurrences']) form.elements['recurrences'].disabled=s;\n\t\t\t\tif (form.elements['seg_recurrences']) form.elements['seg_recurrences'].disabled=s;\n\t\t\t};\n\t\t\tcrf();\n\t\t\tfor (var i=0;i<form.elements['recurrence'].length;i++) form.elements['recurrence'][i].onclick=crf;\n\n\t\t\tvar crf2=function() {\n\t\t\t\tvar s=document.getElementById('all_day_event').checked;\n\t\t\t\tdocument.getElementById('start_hour').disabled=s;\n\t\t\t\tdocument.getElementById('start_minute').disabled=s;\n\t\t\t\tdocument.getElementById('end_hour').disabled=s;\n\t\t\t\tdocument.getElementById('end_minute').disabled=s;\n\t\t\t}\n\t\t\tcrf2();\n\t\t\tdocument.getElementById('all_day_event').onclick=crf2;\n\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif (form.elements['end_day'].selectedIndex!=0)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar start=new Date(window.parseInt(form.elements['start_year'].value),window.parseInt(form.elements['start_month'].value)-1,window.parseInt(form.elements['start_day'].value),window.parseInt(form.elements['start_hour'].value),window.parseInt(form.elements['start_minute'].value));\n\t\t\t\t\t\tvar end=new Date(window.parseInt(form.elements['end_year'].value),window.parseInt(form.elements['end_month'].value)-1,window.parseInt(form.elements['end_day'].value),window.parseInt(form.elements['end_hour'].value),window.parseInt(form.elements['end_minute'].value));\n\n\t\t\t\t\t\tif (start>end)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('EVENT_CANNOT_AROUND')) . "');\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/calendar'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_calendar'; $this->posting_form_title = do_lang_tempcode('EVENT_TEXT'); require_lang('calendar'); require_lang('dates'); require_css('calendar'); require_code('calendar2'); // Decide what to do if ($type == 'misc') { return $this->misc(); } // Decide what to do if ($type == 'import') { return $this->import_ical(); } if ($type == '_import_ical') { return $this->_import_ical(); } if ($type == 'export') { return $this->export_ical(); } if ($type == '_export') { return $this->_export_ical(); } return new ocp_tempcode(); }
/** * Standard modular run function. Creates custom graphics from parameters. * * @param array Map of hook parameters (relayed from block parameters map). * @param object The block itself (contains utility methods). * @return tempcode HTML to output. */ function run($map, &$block) { if (!function_exists('imagettftext') || !array_key_exists('FreeType Support', gd_info()) || @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') === false) { return do_lang_tempcode('REQUIRES_TTF'); } if (!array_key_exists('img1', $map)) { $map['img1'] = 'button1'; } $img_path_1 = find_theme_image($map['img1'], true, true); if ($img_path_1 == '') { return do_lang_tempcode('NO_SUCH_THEME_IMAGE', $map['img1']); } $cache_id_1 = 'rollover1_' . md5(serialize($map)); $url_1 = $block->_do_image($cache_id_1, $map, $img_path_1); if (is_object($url_1)) { return $url_1; } if (!array_key_exists('img2', $map)) { $map['img2'] = 'button2'; } $img_path_2 = find_theme_image($map['img2'], true, true); if ($img_path_2 == '') { return do_lang_tempcode('NO_SUCH_THEME_IMAGE', $map['img2']); } $cache_id_2 = 'rollover2_' . md5(serialize($map)); $url_2 = $block->_do_image($cache_id_2, $map, $img_path_2); if (is_object($url_2)) { return $url_2; } $comb_id = 'rollover_' . uniqid('', true); $ret = '<img id="' . php_addslashes($comb_id) . '" class="gfx_text_overlay" alt="' . str_replace(chr(10), ' ', escape_html($map['data'])) . '" src="' . escape_html($url_1) . '" />'; $ret .= ' <script type="text/javascript">// <![CDATA[ create_rollover("' . php_addslashes($comb_id) . '","' . php_addslashes($url_2) . '"); //]]></script> '; if (function_exists('ocp_mark_as_escaped')) { ocp_mark_as_escaped($ret); } return make_string_tempcode($ret); }
/** * Standard modular run function. Creates custom graphics from parameters. * * @param array Map of hook parameters (relayed from block parameters map). * @param object The block itself (contains utility methods). * @return tempcode HTML to output. */ function run($map, &$Block) { require_css('sifr'); require_javascript('javascript_sifr'); $tag = array_key_exists('tag', $map) ? $map['tag'] : 'h2'; if (!array_key_exists('data', $map)) { $map['data'] = do_lang('FILL_IN_DATA_PARAM'); } $id = 'sifr' . uniqid(''); $font = array_key_exists('font', $map) ? $map['font'] : 'tradegothic'; if (substr($font, -4) == '.swf') { $font = substr($font, 0, strlen($font) - 4); } if (file_exists(get_file_base() . '/data_custom/sifr/' . $font . '.swf')) { $font = get_base_url() . '/data_custom/sifr/' . $font . '.swf'; } else { $font = get_base_url() . '/data/sifr/' . $font . '.swf'; } $extra = ''; if (!array_key_exists('color', $map)) { $map['color'] = '#000000'; } $extra .= ', sColor:"' . php_addslashes($map['color']) . '"'; if (array_key_exists('link_color', $map)) { $extra .= ', sBgColor:"' . php_addslashes($map['link_color']) . '"'; } if (array_key_exists('hover_color', $map)) { $extra .= ', sHoverColor:"' . php_addslashes($map['hover_color']) . '"'; } if (array_key_exists('padding_top', $map)) { $extra .= ', nPaddingTop:"' . php_addslashes($map['padding_top']) . '"'; } if (array_key_exists('padding_bottom', $map)) { $extra .= ', nPaddingBottom:"' . php_addslashes($map['padding_bottom']) . '"'; } if (array_key_exists('padding_left', $map)) { $extra .= ', nPaddingLeft:"' . php_addslashes($map['padding_left']) . '"'; } if (array_key_exists('padding_right', $map)) { $extra .= ', nPaddingRight:"' . php_addslashes($map['padding_right']) . '"'; } if (array_key_exists('flash_vars', $map)) { $extra .= ', sFlashVars:"' . php_addslashes($map['flash_vars']) . '"'; } if (array_key_exists('case', $map)) { $extra .= ', sCase:"' . php_addslashes($map['case']) . '"'; } if (!array_key_exists('wmode', $map)) { $map['wmode'] = 'transparent'; } $extra .= ', sWmode:"' . php_addslashes($map['wmode']) . '"'; $ret = '<' . $tag . ' id="' . escape_html($id) . '">' . $map['data'] . '</' . $tag . '>'; $ret .= ' <script type="text/javascript">//<![CDATA[ if (typeof sIFR=="function") sIFR.replaceElement(named({sSelector:"#' . php_addslashes($id) . '", sFlashSrc:"' . php_addslashes($font) . '"' . $extra . '})); //]]></script>'; if (function_exists('ocp_mark_as_escaped')) { ocp_mark_as_escaped($ret); } return make_string_tempcode($ret); }
/** * Escape a string to fit within PHP double quotes TWICE. Needed sometimes when generating code. This function exists for performance reasons. * * @param string String in * @return string Resultant string */ function php_addslashes_twice($in) { return php_addslashes(php_addslashes($in)); /*// This code does not work, provides awfully confusing Tempcode errors... global $PHP_REP_FROM,$PHP_REP_TO_TWICE; return str_replace($PHP_REP_FROM,$PHP_REP_TO_TWICE,$in); //return str_replace("\n",'\n',str_replace('$','\$',str_replace('\\\'','\'',addslashes($in))));*/ }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $order = 0; // Actualiser if (post_param('submitting_settings_tab', NULL) !== NULL) { require_code('ocf_members_action2'); $is_ldap = ocf_is_ldap_member($member_id_of); $is_httpauth = ocf_is_httpauth_member($member_id_of); $is_remote = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_password_compat_scheme') == 'remote'; if ($is_ldap || $is_httpauth || $is_remote || $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'assume_any_member')) { $password = NULL; } else { $password = post_param('edit_password'); if ($password == '') { $password = NULL; } else { $password_confirm = trim(post_param('password_confirm')); if ($password != $password_confirm) { warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH')))); } } } $custom_fields = ocf_get_all_custom_fields_match($GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of), $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_of != $member_id_viewing ? NULL : 1, $member_id_of != $member_id_viewing ? NULL : 1); $actual_custom_fields = ocf_read_in_custom_fields($custom_fields, $member_id_of); $pt_allow = array_key_exists('pt_allow', $_POST) ? implode(',', $_POST['pt_allow']) : ''; $tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true); $all_pt_allow = ''; foreach (array_keys($tmp_groups) as $key) { if ($key != db_get_first_id()) { if ($all_pt_allow != '') { $all_pt_allow .= ','; } $all_pt_allow .= strval($key); } } if ($pt_allow == $all_pt_allow) { $pt_allow = '*'; } $pt_rules_text = post_param('pt_rules_text', NULL); if (has_specific_permission($member_id_viewing, 'member_maintenance')) { $validated = post_param_integer('validated', 0); $primary_group = $is_ldap || !has_specific_permission($member_id_viewing, 'assume_any_member') ? NULL : post_param_integer('primary_group', NULL); $is_perm_banned = post_param_integer('is_perm_banned', 0); $old_is_perm_banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned'); if ($old_is_perm_banned != $is_perm_banned) { if ($is_perm_banned == 1) { ocf_ban_member($member_id_of); } else { ocf_unban_member($member_id_of); } } $highlighted_name = post_param_integer('highlighted_name', 0); if (has_specific_permission($member_id_viewing, 'probate_members')) { $on_probation_until = get_input_date('on_probation_until'); $current__on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until'); if ((is_null($on_probation_until) || $on_probation_until <= time()) && $current__on_probation_until > time()) { log_it('STOP_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $on_probation_until > time() && $current__on_probation_until <= time()) { log_it('START_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until > $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('REDUCE_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until < $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('EXTEND_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } } else { $on_probation_until = NULL; } } else { $validated = NULL; $primary_group = NULL; $highlighted_name = NULL; $on_probation_until = NULL; } if (has_actual_page_access($member_id_viewing, 'admin_ocf_join') || has_specific_permission($member_id_of, 'rename_self')) { $username = $is_ldap || $is_remote ? NULL : post_param('edit_username', NULL); } else { $username = NULL; } $email = post_param('email_address', NULL); if (!is_null($email)) { $email = trim($email); } $theme = post_param('theme', NULL); if ($is_remote) { $preview_posts = NULL; $zone_wide = NULL; $auto_monitor_contrib_content = NULL; $views_signatures = NULL; $timezone = NULL; } else { $preview_posts = post_param_integer('preview_posts', 0); $zone_wide = post_param_integer('zone_wide', 0); $auto_monitor_contrib_content = NULL; //post_param_integer('auto_monitor_contrib_content',0); Moved to notifications tab $views_signatures = post_param_integer('views_signatures', 0); $timezone = post_param('timezone', get_site_timezone()); } ocf_edit_member($member_id_of, $email, $preview_posts, post_param_integer('dob_day', -1), post_param_integer('dob_month', -1), post_param_integer('dob_year', -1), $timezone, $primary_group, $actual_custom_fields, $theme, post_param_integer('reveal_age', 0), $views_signatures, $auto_monitor_contrib_content, post_param('language', NULL), post_param_integer('allow_emails', 0), post_param_integer('allow_emails_from_staff', 0), $validated, $username, $password, $zone_wide, $highlighted_name, $pt_allow, $pt_rules_text, $on_probation_until); if (!array_key_exists('secondary_groups', $_POST)) { $_POST['secondary_groups'] = array(); } require_code('ocf_groups_action2'); $members_groups = $GLOBALS['OCF_DRIVER']->get_members_groups($member_id_of); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $groups = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL)); foreach ($_POST['secondary_groups'] as $group_id) { $group = $groups[intval($group_id)]; if ($group['g_hidden'] == 1 && !in_array($group['id'], $members_groups) && !has_specific_permission($member_id_viewing, 'see_hidden_groups')) { continue; } if (!in_array($group['id'], $members_groups) && (has_specific_permission($member_id_viewing, 'assume_any_member') || $group['g_open_membership'] == 1)) { ocf_add_member_to_group($member_id_of, $group['id']); } } foreach ($members_groups as $group_id) { if (!in_array(strval($group_id), $_POST['secondary_groups'])) { ocf_member_leave_group($group_id, $member_id_of); } } $GLOBALS['FORUM_DB']->query('DELETE FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_known_login_ips WHERE i_member_id=' . strval($member_id_of) . ' AND ' . db_string_not_equal_to('i_val_code', '')); // So any re-confirms can happen if (addon_installed('awards')) { require_code('awards'); handle_award_setting('member', strval($member_id_of)); } attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI $title = do_lang_tempcode('SETTINGS'); $myrow = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id_of); if (is_null($myrow)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } require_code('ocf_members_action2'); list($fields, $hidden) = ocf_get_member_fields_settings(false, $member_id_of, NULL, $myrow['m_email_address'], $myrow['m_preview_posts'], $myrow['m_dob_day'], $myrow['m_dob_month'], $myrow['m_dob_year'], get_users_timezone($member_id_of), $myrow['m_theme'], $myrow['m_reveal_age'], $myrow['m_views_signatures'], $myrow['m_auto_monitor_contrib_content'], $myrow['m_language'], $myrow['m_allow_emails'], $myrow['m_allow_emails_from_staff'], $myrow['m_validated'], $myrow['m_primary_group'], $myrow['m_username'], $myrow['m_is_perm_banned'], '', $myrow['m_zone_wide'], $myrow['m_highlighted_name'], $myrow['m_pt_allow'], get_translated_text($myrow['m_pt_rules_text'], $GLOBALS['FORUM_DB']), $myrow['m_on_probation_until']); // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('member', strval($member_id_of))); } $redirect = get_param('redirect', NULL); if (!is_null($redirect)) { $hidden->attach(form_input_hidden('redirect', $redirect)); } $hidden->attach(form_input_hidden('submitting_settings_tab', '1')); $javascript = "\n\t\t\tvar form=document.getElementById('email_address').form;\n\t\t\tform.prior_profile_edit_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif (typeof form.elements['edit_password']!='undefined')\n\t\t\t\t\t{\n\t\t\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['edit_password'].value))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.prior_profile_edit_submit!='undefined' && form.prior_profile_edit_submit) return form.prior_profile_edit_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; $text = ''; return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * The actualiser to send a newsletter. * * @return tempcode The UI */ function send_message() { $title = get_page_title('NEWSLETTER_SEND'); $lang = choose_language($title); if (is_object($lang)) { return $lang; } if (get_param('old_type', '') == 'whatsnew') { set_value('newsletter_whatsnew', strval(time())); } $message = post_param('message'); $subject = post_param('subject'); $csv_data = post_param('csv_data', ''); // serialized PHP array $template = post_param('template', 'MAIL'); $in_full = post_param_integer('in_full', 0); $html_only = post_param_integer('html_only', 0); $from_email = post_param('from_email', ''); $from_name = post_param('from_name', ''); $priority = post_param_integer('priority', 3); $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('id')); $send_details = array(); foreach ($newsletters as $newsletter) { $send_details[strval($newsletter['id'])] = post_param_integer(strval($newsletter['id']), 0); } if (get_forum_type() == 'ocf') { $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach (array_keys($groups) as $id) { $send_details['g' . strval($id)] = post_param_integer('g' . strval($id), 0); } $send_details['-1'] = post_param_integer('-1', 0); } if (post_param_integer('make_periodic', 0) == 1) { // We're a periodic newsletter, so we don't actually want to be sent // out now. Rather, we store the newsletter settings so that it can be // regenerated as needed. // Next we store all of our settings in the newsletter_periodic table $when = post_param('periodic_when'); $day = 1; if ($when == 'monthly') { $day = post_param_integer('periodic_monthly') % 29; } elseif ($when == 'biweekly') { $day = post_param_integer('periodic_weekday_biweekly', 5); } elseif ($when == 'weekly') { $day = post_param_integer('periodic_weekday_weekly', 5); } $map = array('np_message' => post_param('chosen_categories', ''), 'np_subject' => $subject, 'np_lang' => $lang, 'np_send_details' => serialize($send_details), 'np_html_only' => $html_only, 'np_from_email' => $from_email, 'np_from_name' => $from_name, 'np_priority' => $priority, 'np_csv_data' => $csv_data, 'np_frequency' => $when, 'np_day' => $day, 'np_in_full' => $in_full, 'np_template' => $template); require_lang('dates'); $week_days = array(1 => do_lang('MONDAY'), 2 => do_lang('TUESDAY'), 3 => do_lang('WEDNESDAY'), 4 => do_lang('THURSDAY'), 5 => do_lang('FRIDAY'), 6 => do_lang('SATURDAY'), 7 => do_lang('SUNDAY')); if ($when == 'weekly') { $each = $week_days[$day]; } elseif ($when == 'biweekly') { $each = $week_days[$day]; } else { $suffix = gmdate('S', gmmktime(0, 0, 0, 1, $day, 1990)); $each = strval($day) . $suffix; } $matches = array(); if (preg_match('#^replace_existing\\_(\\d+)$#', post_param('periodic_choice', ''), $matches) != 0) { if (post_param('periodic_for') != 'future') { $map['np_last_sent'] = 0; } $GLOBALS['SITE_DB']->query_update('newsletter_periodic', $map, array('id' => intval($matches[1])), '', 1); $message = do_lang('PERIODIC_SUCCESS_MESSAGE_EDIT', $when, $each); } else { $last_sent = post_param('periodic_for') == 'future' ? time() : 0; $map['np_last_sent'] = $last_sent; $GLOBALS['SITE_DB']->query_insert('newsletter_periodic', $map, true); $message = do_lang('PERIODIC_SUCCESS_MESSAGE_ADD', $when, $each); } $url = build_url(array('page' => 'admin_newsletter', 'type' => 'misc', 'redirected' => '1'), get_module_zone('admin_newsletter')); return redirect_screen(do_lang('SUCCESS'), $url, $message, false, 'inform'); } if (addon_installed('calendar')) { $schedule = get_input_date('schedule'); if (!is_null($schedule)) { require_code('calendar'); require_code('calendar2'); $send_details_string_exp = ''; foreach ($send_details as $key => $val) { $send_details_string_exp .= '"' . str_replace(chr(10), '\\n', addslashes($key)) . '"=>"' . str_replace(chr(10), '\\n', addslashes($val)) . '",'; } $schedule_code = ':require_code(\'newsletter\'); actual_send_newsletter("' . php_addslashes($message) . '","' . php_addslashes($subject) . '","' . php_addslashes($lang) . '",array(' . $send_details_string_exp . '),' . strval($html_only) . ',"' . php_addslashes($from_email) . '","' . php_addslashes($from_name) . '",' . strval($priority) . ',"' . php_addslashes($template) . '");'; $start_year = post_param_integer('schedule_year'); $start_month = post_param_integer('schedule_month'); $start_day = post_param_integer('schedule_day'); $start_hour = post_param_integer('schedule_hour'); $start_minute = post_param_integer('schedule_minute'); $event_id = add_calendar_event(db_get_first_id(), '', NULL, 0, do_lang('NEWSLETTER_SEND', $subject), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute); regenerate_event_reminder_jobs($event_id); return inform_screen($title, do_lang_tempcode('NEWSLETTER_DEFERRED', get_timezoned_date($schedule))); } } actual_send_newsletter($message, $subject, $lang, $send_details, $html_only, $from_email, $from_name, $priority, $csv_data, $template); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWSLETTER')), array('_SELF:_SELF:new', do_lang_tempcode('NEWSLETTER_SEND')))); breadcrumb_set_self(do_lang_tempcode('DONE')); return inform_screen($title, do_lang_tempcode('SENDING_NEWSLETTER')); }
/** * Get Javascript to restrict post lengths. * * @return string The post Javascript */ function _post_javascript() { $size = ocf_get_member_best_group_property(get_member(), 'max_post_length_comcode'); $javascript = ''; $javascript .= "\n\t\t\tvar form=document.getElementById('post').form;\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function() {\n\t\t\t\tvar post=form.elements['post'];\n\t\t\t\tvar text_value;\n\t\t\t\tif (is_wysiwyg_field(post))\n\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\ttext_value=window.CKEDITOR.instances['post'].getData();\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {};\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif ((!post.value) && (post[1])) post=post[1];\n\t\t\t\t\ttext_value=post.value;\n\t\t\t\t}\n\t\t\t\tif (text_value.length>" . strval($size) . ")\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('_POST_TOO_LONG')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t"; $stub = unixify_line_format(either_param('stub', '')); if ($stub != '') { $javascript .= "\n\t\t\t\tvar df='" . str_replace(chr(10), '\\n', addslashes($stub)) . "';\n\n\t\t\t\tvar pv=post.value;\n\t\t\t\tif ((post) && (pv.substring(0,df.length)==df))\n\t\t\t\t{\n\t\t\t\t\tpv=pv.substring(df.length,pv.length);\n\t\t\t\t}\n\t\t\t\tpost.value=pv;\n\t\t"; } $javascript .= "\n\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\n\t\t\t\treturn true;\n\t\t\t};\n\t\t"; return $javascript; }
/** * Build a closure function for a compiled template. * * @param string The function name * @param array An array of lines to be output, each one in PHP format * @return string Finished PHP code */ function build_closure_function($myfunc, $parts) { if ($parts == array()) { $parts = array('""'); } $code = ''; foreach ($parts as $i => $part) { if ($i != 0) { $code .= ',' . chr(10) . "\t"; } $code .= $part; } global $FUNC_STYLE_TPL; $func_style = false; foreach ($FUNC_STYLE_TPL as $s) { if (strpos($myfunc, $s) !== false) { $func_style = true; } } if ($func_style) { if (strpos($code, '$bound') === false) { $funcdef = "\$TPL_FUNCS['{$myfunc}']=\$KEEP_TPL_FUNCS['{$myfunc}']=create_function('\$parameters,\$cl,\$last_attach',\"echo " . php_addslashes($code) . ";\");\n"; } else { $funcdef = "\$TPL_FUNCS['{$myfunc}']=\$KEEP_TPL_FUNCS['{$myfunc}']=create_function('\$parameters,\$cl,\$last_attach',\"extract(\\\$parameters,EXTR_PREFIX_ALL,'bound'); echo " . php_addslashes($code) . ";\");\n"; } } else { $unset_code = ''; if (strpos($code, 'isset($bound') !== false) { // Horrible but efficient code needed to allow IF_PASSED/IF_NON_PASSED to keep working when templates are put adjacent to each other, where some have it, and don't. This is needed as eval does not set a scope block. $reset_code = "eval(\\\$FULL_RESET_VAR_CODE);"; } elseif (strpos($code, '$bound') !== false) { $reset_code = "eval(\\\$RESET_VAR_CODE);"; } else { $reset_code = ''; } $funcdef = "\$TPL_FUNCS['{$myfunc}']=\"{$reset_code} echo " . php_addslashes($code) . ";\";\n"; } return $funcdef; }
/** * Standard stage of pointstore item purchase. * * @return tempcode The UI */ function newpop3() { if (get_option('is_on_pop3_buy') == '0') { return new ocp_tempcode(); } $title = get_page_title('TITLE_NEWPOP3'); pointstore_handle_error_already_has('pop3'); // What addresses are there? $member_id = get_member(); $pointsleft = available_points($member_id); // the number of points this member has left $list = get_mail_domains('pop3_', $pointsleft); if ($list->is_empty()) { return warn_screen($title, do_lang_tempcode('NO_POP3S')); } // Build up fields $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('ADDRESS_DESIRED_STUB'), '', 'email-prefix', $GLOBALS['FORUM_DRIVER']->get_username(get_member()), true)); $fields->attach(form_input_list(do_lang_tempcode('ADDRESS_DESIRED_DOMAIN'), '', 'esuffix', $list)); $fields->attach(form_input_password(do_lang_tempcode('PASSWORD'), '', 'pass1', true)); $fields->attach(form_input_password(do_lang_tempcode('CONFIRM_PASSWORD'), '', 'pass2', true)); $javascript = "\n\t\t\tvar form=document.getElementById('pass1').form;\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif ((form.elements['pass1'].value!=form.elements['pass2'].value))\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; // Return template $newpop_url = build_url(array('page' => '_SELF', 'type' => '_newpop3', 'id' => 'pop3'), '_SELF'); return do_template('FORM_SCREEN', array('_GUID' => 'addf1563770845ba5fe4aaf2e60ca6fc', 'JAVASCRIPT' => $javascript, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => paragraph(do_lang_tempcode('ADDRESSES_ABOUT')), 'URL' => $newpop_url, 'SUBMIT_NAME' => do_lang_tempcode('PURCHASE'), 'FIELDS' => $fields)); }
/** * The opposite of to_assembly - it decodes a tempcode storage representation and turns it into a proper tempcode object. This version handles the result of evaled code. * * @param PATH The file to load * @param array List of parameters for a forced reload if required * @return boolean Success status (it can fail, if the compiled cache file is corrupt) */ function from_assembly_executed($file, $forced_reload_details) { if ($GLOBALS['RECORD_TEMPLATES_TREE']) { $this->fresh = false; $this->children = array(); } $result = @(include $file); // We don't eval on this because we want it to potentially be op-code cached by e.g. Zend Accelerator if (!is_array($result)) { return false; } // May never get here, as PHP fatal errors can't be suppressed or skipped over $this->cached_output = NULL; list($this->seq_parts, $this->preprocessable_bits, $this->codename, $this->last_attach, $this->pure_lang, $this->code_to_preexecute) = $result; if ($forced_reload_details[6] === NULL) { $forced_reload_details[6] = ''; } if (isset($this->code_to_preexecute[800]) && $GLOBALS['CACHE_TEMPLATES']) { // We don't actually use $code_to_preexecute, because it uses too much RAM and DB space throwing full templates into the cacheing. Instead we rewrite to custom load it whenever it's needed. This isn't inefficient due to normal opcode cacheing and optimizer opcode cacheing, and because we cache Tempcode object's evaluations at runtime so it can only happen once per screen view. $this->code_to_preexecute = 'if (($result=@include(\'' . php_addslashes($file) . '\'))===false) { $tmp=do_template(\'' . php_addslashes($forced_reload_details[0]) . '\',NULL,\'' . php_addslashes($forced_reload_details[2]) . '\',false,\'' . ($forced_reload_details[6] == '' ? '' : php_addslashes($forced_reload_details[6])) . '\',\'' . $forced_reload_details[4] . '\',\'' . $forced_reload_details[5] . '\'); clearstatcache(); if (!is_file(\'' . php_addslashes($file) . '\')) { $GLOBALS[\'CACHE_TEMPLATES\']=false; } eval($tmp->code_to_preexecute); unset($tmp); } else { eval($result[5]); unset($result); }'; } global $SITE_INFO; if ((!isset($SITE_INFO['disable_decaching_shift_encode']) || $SITE_INFO['disable_decaching_shift_encode'] != '1') && @strpos(file_get_contents($file), 'SHIFT_ENCODE') !== false) { $this->code_to_preexecute .= '/*SHIFT_ENCODE*/'; } if ($GLOBALS['XSS_DETECT']) { $this->_mark_all_as_escaped(); } return true; }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('SIGNATURE'); $order = 40; // Actualiser $new_signature = post_param('signature', NULL); if ($new_signature !== NULL) { require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_signature($new_signature, $member_id_of); require_code('autosave'); clear_ocp_autosave(); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI $_signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']); $signature = $_signature->is_empty() ? do_lang_tempcode('NONE_EM') : $_signature; $_signature_original = get_translated_text($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']); $size = ocf_get_member_best_group_property($member_id_of, 'max_sig_length_comcode'); $javascript = "\n\t\t\tvar form=document.getElementById('signature').form;\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tvar post=form.elements['signature'];\n\t\t\t\t\tif ((!post.value) && (post[1])) post=post[1];\n\t\t\t\t\tif (post.value.length>" . strval($size) . ")\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('SIGNATURE_TOO_BIG')) . "');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; require_code('form_templates'); $required = false; $has_preview = true; require_lang('javascript'); require_javascript('javascript_posting'); require_javascript('javascript_editing'); require_javascript('javascript_ajax'); require_javascript('javascript_swfupload'); require_css('swfupload'); require_lang('comcode'); $tabindex = get_form_field_tabindex(); $post_comment = do_lang_tempcode('SIGNATURE'); list($attachments, $attach_size_field) = get_attachments('signature'); $hidden_fields = new ocp_tempcode(); $hidden_fields->attach($attach_size_field); $continue_url = get_self_url(); $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)); $emoticon_chooser = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); $comcode_editor = get_comcode_editor(); $comcode_editor_small = get_comcode_editor('signature', true); $w = has_js() && (browser_matches('wysiwyg') && strpos($_signature_original, '{$,page hint: no_wysiwyg}') === false); $class = ''; global $JAVASCRIPT, $WYSIWYG_ATTACHED; if (!$WYSIWYG_ATTACHED) { $JAVASCRIPT->attach(do_template('HTML_EDIT')); } $WYSIWYG_ATTACHED = true; @header('Content-type: text/html; charset=' . get_charset()); if ($w) { $class .= ' wysiwyg'; } global $LAX_COMCODE; $temp = $LAX_COMCODE; $LAX_COMCODE = true; $GLOBALS['COMCODE_PARSE_URLS_CHECKED'] = 100; // Little hack to stop it checking any URLs /*if (is_null($default_parsed)) */ $default_parsed = comcode_to_tempcode($_signature_original, NULL, false, 60, NULL, NULL, true); $LAX_COMCODE = $temp; $fields = new ocp_tempcode(); $fields->attach(do_template('POSTING_FIELD', array('PRETTY_NAME' => do_lang_tempcode('SIGNATURE'), 'DESCRIPTION' => '', 'HIDDEN_FIELDS' => $hidden_fields, 'NAME' => 'signature', 'REQUIRED' => $required, 'TABINDEX_PF' => strval($tabindex), 'COMCODE_EDITOR' => $comcode_editor, 'COMCODE_EDITOR_SMALL' => $comcode_editor_small, 'CLASS' => $class, 'COMCODE_URL' => build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)), 'EXTRA' => '', 'POST_COMMENT' => $post_comment, 'EMOTICON_CHOOSER' => $emoticon_chooser, 'COMCODE_HELP' => $comcode_help, 'POST' => $_signature_original, 'DEFAULT_PARSED' => $default_parsed, 'CONTINUE_URL' => $continue_url, 'ATTACHMENTS' => $attachments))); $text = do_template('OCF_EDIT_SIGNATURE_TAB', array('_GUID' => 'f5f2eb2552c34840c9cf46886422401e', 'SIZE' => integer_format($size), 'SIGNATURE' => $signature, 'TITLE' => $title)); return array($title, $fields, $text, $javascript, $order); }
/** * The UI to sign up to the newsletter (actually, generally manage subscription). * * @return tempcode The UI */ function newsletter_form() { $title = get_page_title('_NEWSLETTER_JOIN', true, array(escape_html(get_option('newsletter_title')))); $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('*')); if (count($newsletters) == 0) { warn_exit(do_lang_tempcode('NO_ENTRIES')); } $post_url = build_url(array('page' => '_SELF', 'type' => 'do'), '_SELF'); $submit_name = do_lang_tempcode('NEWSLETTER_JOIN'); if (!is_guest()) { $their_email = get_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())); } else { $their_email = get_param('email', ''); } $forename = ''; $surname = ''; $message = get_option('newsletter_text'); if (has_actual_page_access(get_member(), 'admin_config')) { if ($message != '') { $message .= ' [[page="_SEARCH:admin_config:category:FEATURE#group_NEWSLETTER"]' . do_lang('EDIT') . '[/page]]'; } } $text = comcode_to_tempcode($message, NULL, true); // Build up the join form $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('EMAIL_ADDRESS'), do_lang_tempcode('DESCRIPTION_SUBSCRIBE_ADDRESS'), 'email', $their_email, true)); $fields->attach(form_input_line(do_lang_tempcode('FORENAME'), '', 'forename', $forename, false)); $fields->attach(form_input_line(do_lang_tempcode('SURNAME'), '', 'surname', $surname, false)); $fields->attach(form_input_password(do_lang_tempcode('YOUR_PASSWORD'), do_lang_tempcode('DESCRIPTION_MAINTENANCE_PASSWORD'), 'password', true)); $fields->attach(form_input_password(do_lang_tempcode('CONFIRM_PASSWORD'), '', 'password_confirm', true)); if (count(find_all_langs()) != 1) { $fields->attach(form_input_list(do_lang_tempcode('LANGUAGE'), '', 'lang', nice_get_langs(user_lang()))); } $level = get_param_integer('level', NULL); if (is_null($level)) { $level = 3; } $l = form_input_list_entry('0', false, do_lang_tempcode('NEWSLETTER_0')); $l->attach(form_input_list_entry('1', $level == 1, do_lang_tempcode('NEWSLETTER_1'))); $l->attach(form_input_list_entry('2', $level == 2, do_lang_tempcode('NEWSLETTER_2'))); $l->attach(form_input_list_entry('3', $level == 3, do_lang_tempcode('NEWSLETTER_3'))); $l->attach(form_input_list_entry('4', $level == 4, do_lang_tempcode('NEWSLETTER_4'))); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('NEWSLETTER_SUBSCRIPTIONS')))); foreach ($newsletters as $newsletter) { $newsletter_title = get_translated_text($newsletter['title']); $newsletter_description = get_translated_text($newsletter['description']); if (get_option('interest_levels') == '1') { $fields->attach(form_input_list(do_lang_tempcode('SUBSCRIPTION_LEVEL_FOR', make_string_tempcode(escape_html($newsletter_title))), do_lang_tempcode('DESCRIPTION_SUBSCRIPTION_LEVEL', escape_html($newsletter_description)), 'level' . strval($newsletter['id']), $l)); } else { $fields->attach(form_input_tick(do_lang_tempcode('SUBSCRIBE_TO', make_string_tempcode(escape_html($newsletter_title))), make_string_tempcode(escape_html($newsletter_description)), 'level' . strval($newsletter['id']), $level != 0)); } } $text->attach(paragraph(do_lang_tempcode('CHANGE_SETTINGS_BY_RESUBSCRIBING'))); $javascript = "\n\t\t\tvar form=document.getElementById('password').form;\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['password'].value))\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; return do_template('FORM_SCREEN', array('_GUID' => '24d7575465152f450c5a8e62650bf6c8', 'JAVASCRIPT' => $javascript, 'HIDDEN' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url, 'TITLE' => $title, 'TEXT' => $text)); }
/** * Write PHP code for the restoration of database data into file. * * @param resource The logfile to write to * @param ID_TEXT The meta tablename * @param ID_TEXT The index-meta tablename * @param resource File to write in to */ function get_table_backup($logfile, $db_meta, $db_meta_indices, &$install_php_file) { $GLOBALS['NO_DB_SCOPE_CHECK'] = true; // Get a list of tables $tables = $GLOBALS['SITE_DB']->query_select($db_meta, array('DISTINCT m_table AS m_table')); // For each table, build up an ocPortal table creation command foreach ($tables as $_table) { $table = $_table['m_table']; $fields = $GLOBALS['SITE_DB']->query_select($db_meta, array('*'), array('m_table' => $table)); fwrite($install_php_file, " \$GLOBALS['SITE_DB']->drop_if_exists('{$table}');\n"); $array = ''; foreach ($fields as $field) { $name = $field['m_name']; $type = $field['m_type']; if ($array != '') { $array .= ",\n"; } $array .= "\t\t'" . $name . "'=>'" . $type . "'"; } fwrite($install_php_file, " \$GLOBALS['SITE_DB']->create_table('{$table}',array(\n{$array}));\n"); if ($table == 'stats' || $table == 'cache') { $data = array(); } else { if ($table != 'edit_pings' && $table != 'cache') { $start = 0; do { $data = $GLOBALS['SITE_DB']->query_select($table, array('*'), NULL, '', 100, $start, false, array()); foreach ($data as $d) { $list = ''; foreach ($d as $name => $value) { if ($table == 'translate' && $name == 'text_parsed') { $value = ''; } if (is_null($value)) { continue; } if ($list != '') { $list .= ','; } $list .= "'" . (is_string($name) ? $name : strval($name)) . "'=>"; if (!is_integer($value)) { $list .= '"' . php_addslashes($value) . '"'; } else { $list .= strval($value); } } fwrite($install_php_file, " \$GLOBALS['SITE_DB']->query_insert('{$table}',array({$list}));\n"); } $start += 100; } while (count($data) != 0); } } fwrite($logfile, 'Backed up table ' . $table . "\n"); } // For each index, build up an ocPortal index creation command $indices = $GLOBALS['SITE_DB']->query_select($db_meta_indices, array('*')); foreach ($indices as $index) { if (fwrite($install_php_file, ' $GLOBALS[\'SITE_DB\']->create_index(\'' . $index['i_table'] . '\',\'' . $index['i_name'] . '\',array(\'' . str_replace(',', '\',\'', $index['i_fields']) . '\'));' . "\n") == 0) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } } $GLOBALS['NO_DB_SCOPE_CHECK'] = false; }
/** * Server opensearch requests. */ function opensearch_script() { header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past if (!has_actual_page_access(get_member(), 'search')) { return; } // No access $type = get_param('type', 'misc'); switch ($type) { // Make a search suggestion (like Google Suggest) case 'suggest': header('Content-type: text/plain; charset=' . get_charset()); $request = get_param('request', false, true); if (strlen($request) < 3) { return; } $suggestions = array(); $q = 'SELECT s_primary,COUNT(*) as cnt,MAX(s_num_results) AS s_num_results FROM ' . get_table_prefix() . 'searches_logged WHERE '; if (db_has_full_text($GLOBALS['SITE_DB']->connection_read) && method_exists($GLOBALS['SITE_DB']->static_ob, 'db_has_full_text_boolean') && $GLOBALS['SITE_DB']->static_ob->db_has_full_text_boolean() && !is_under_radar($request)) { $q .= preg_replace('#\\?#', 's_primary', db_full_text_assemble($request, false)); } else { $q .= 's_primary LIKE \'' . db_encode_like($request . '%') . '\''; } $q .= ' AND s_primary NOT LIKE \'' . db_encode_like('%<%') . '\' AND ' . db_string_not_equal_to('s_primary', '') . ' GROUP BY s_primary ORDER BY cnt DESC'; $past_searches = $GLOBALS['SITE_DB']->query($q, 20); foreach ($past_searches as $search) { if ($search['cnt'] > 5) { $suggestions[$search['s_primary']] = $search['s_num_results']; } } require_lang('search'); @ini_set('ocproducts.xss_detect', '0'); // JSON format echo '[' . chr(10); // Original request echo '"' . php_addslashes($request) . '",' . chr(10); // Suggestions echo '['; foreach (array_keys($suggestions) as $i => $suggestion) { if ($i != 0) { echo ','; } echo '"' . php_addslashes($suggestion) . '"'; } echo '],' . chr(10); // Descriptions of suggestions echo '['; foreach (array_values($suggestions) as $i => $suggestion) { if ($i != 0) { echo ','; } echo '"' . php_addslashes(do_lang('NUM_RESULTS', integer_format($suggestion))) . '"'; } echo '],' . chr(10); // URLs to search suggestions $filter = get_param('filter', ''); $filter_map = array(); if ($filter != '') { foreach (explode(':', $filter) as $f) { if ($f != '') { $parts = explode('=', $f, 2); if (count($parts) == 1) { $parts = array($parts[0], '1'); } $filter_map[$parts[0]] = $parts[1]; } } } echo '['; foreach (array_keys($suggestions) as $i => $suggestion) { if ($i != 0) { echo ','; } $map = array('page' => 'search', 'type' => 'results', 'content' => $suggestion) + $filter_map; $_search_url = build_url($map, get_param('zone', get_module_zone('search'))); $search_url = $_search_url->evaluate(); echo '"' . php_addslashes($search_url) . '"'; } echo ']' . chr(10); echo ']' . chr(10); break; // Provide details about the site search engine // Provide details about the site search engine default: //header('Content-Type: application/opensearchdescription+xml'); header('Content-Type: text/xml'); $tpl = do_template('OPENSEARCH', array('DESCRIPTION' => get_option('description'))); $tpl->evaluate_echo(); break; } }
/** * Get the join form. * * @param tempcode URL to direct to * @param boolean Whether to handle CAPTCHA (if enabled at all) * @param boolean Whether to ask for intro messages (if enabled at all) * @param boolean Whether to check for invites (if enabled at all) * @param boolean Whether to check email-address restrictions (if enabled at all) * @return array A tuple: Necessary Javascript code, the form */ function ocf_join_form($url, $captcha_if_enabled = true, $intro_message_if_enabled = true, $invites_if_enabled = true, $one_per_email_address_if_enabled = true) { ocf_require_all_forum_stuff(); require_css('ocf'); require_code('ocf_members_action'); require_code('ocf_members_action2'); require_code('form_templates'); $hidden = new ocp_tempcode(); $hidden->attach(build_keep_post_fields()); $groups = ocf_get_all_default_groups(true); $primary_group = either_param_integer('primary_group', NULL); if ($primary_group !== NULL && !in_array($primary_group, $groups)) { // Check security $test = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_is_presented_at_install', array('id' => $primary_group)); if ($test == 1) { $groups = ocf_get_all_default_groups(false); $hidden = form_input_hidden('primary_group', strval($primary_group)); $groups[] = $primary_group; } } list($fields, $_hidden) = ocf_get_member_fields(true, NULL, $groups); $hidden->attach($_hidden); if ($intro_message_if_enabled) { $forum_id = get_option('intro_forum_id'); if ($forum_id != '') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('INTRODUCE_YOURSELF')))); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'intro_title', do_lang('INTRO_POST_DEFAULT', '___'), false)); $fields->attach(form_input_text_comcode(do_lang_tempcode('POST_COMMENT'), do_lang_tempcode('DESCRIPTION_INTRO_POST'), 'intro_post', '', false)); } } $text = do_lang_tempcode('ENTER_PROFILE_DETAILS'); if ($captcha_if_enabled) { if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $fields->attach(form_input_captcha()); $text->attach(' '); $text->attach(do_lang_tempcode('FORM_TIME_SECURITY')); } } } $submit_name = do_lang_tempcode('PROCEED'); require_javascript('javascript_ajax'); $script = find_script('username_check'); $javascript = "\n\t\tvar form=document.getElementById('username').form;\n\t\tform.elements['username'].onchange=function()\n\t\t{\n\t\t\tif (form.elements['intro_title'])\n\t\t\t\tform.elements['intro_title'].value='" . addslashes(do_lang('INTRO_POST_DEFAULT')) . "'.replace(/\\{1\\}/g,form.elements['username'].value);\n\t\t}\n\t\tform.old_submit=form.onsubmit;\n\t\tform.onsubmit=function()\n\t\t\t{\n\t\t\t\tif ((form.elements['email_address_confirm']) && (form.elements['email_address_confirm'].value!=form.elements['email_address'].value))\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('EMAIL_ADDRESS_MISMATCH')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['password'].value))\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\tvar url='" . addslashes($script) . "?username='******'username'].value);\n\t\t\t\tif (!do_ajax_field_test(url,'password='******'password'].value)))\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t"; $script = find_script('snippet'); if ($invites_if_enabled) { if (get_option('is_on_invites') == '1') { $javascript .= "\n\t\t\t\t\turl='" . addslashes($script) . "?snippet=invite_missing&name='+window.encodeURIComponent(form.elements['email_address'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t"; } } if ($one_per_email_address_if_enabled) { if (get_option('one_per_email_address') == '1') { $javascript .= "\n\t\t\t\t\turl='" . addslashes($script) . "?snippet=email_exists&name='+window.encodeURIComponent(form.elements['email_address'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t"; } } if ($captcha_if_enabled) { if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $javascript .= "\n\t\t\t\t\t\turl='" . addslashes($script) . "?snippet=captcha_wrong&name='+window.encodeURIComponent(form.elements['security_image'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t"; } } } $javascript .= "\n\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\treturn true;\n\t\t\t};\n\t"; $form = do_template('FORM', array('TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $url)); return array($javascript, $form); }