/** * Standard modular run function. * * @return tempcode Results */ function run() { $out = new ocp_tempcode(); $tables = $GLOBALS['SITE_DB']->query_select('db_meta', array('DISTINCT m_table')); if (count($GLOBALS['SITE_DB']->connection_write) > 4) { $GLOBALS['SITE_DB']->connection_write = call_user_func_array(array($GLOBALS['SITE_DB']->static_ob, 'db_get_connection'), $GLOBALS['SITE_DB']->connection_write); _general_db_init(); } list($db, $db_name) = $GLOBALS['SITE_DB']->connection_write; mysql_select_db($db_name, $db); foreach ($tables as $table) { if ($table['m_table'] == 'sessions') { continue; } // HEAP, so can't be repaired $table = get_table_prefix() . $table['m_table']; // Check/Repair $result = mysql_query('CHECK TABLE ' . $table . ' FAST', $db); echo mysql_error($db); mysql_data_seek($result, mysql_num_rows($result) - 1); $status_row = mysql_fetch_assoc($result); if ($status_row['Msg_type'] != 'status') { $out->attach(paragraph(do_lang_tempcode('TABLE_ERROR', escape_html($table), escape_html($status_row['Msg_type']), array(escape_html($status_row['Msg_text']))), 'dfsdgdsgfgd')); $result2 = mysql_query('REPAIR TABLE ' . $table, $db); mysql_data_seek($result2, mysql_num_rows($result2) - 1); $status_row_2 = mysql_fetch_assoc($result2); $out->attach(paragraph(do_lang_tempcode('TABLE_FIXED', escape_html($table), escape_html($status_row_2['Msg_type']), array(escape_html($status_row_2['Msg_text']))), 'dfsdfgdst4')); } // Optimise mysql_unbuffered_query('OPTIMIZE TABLE ' . $table, $db); } return $out; }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $sup = get_param('block_map_sup', '', true); $_map = get_param('block_map', false, true); if ($sup != '') { $_map .= ',' . $sup; } require_code('blocks'); $map = block_params_str_to_arr($_map); if (!array_key_exists('block', $map)) { return new ocp_tempcode(); } $auth_key = get_param_integer('auth_key'); // Check permissions $test = $GLOBALS['SITE_DB']->query_value_null_ok('temp_block_permissions', 'p_block_constraints', array('p_session_id' => get_session_id(), 'id' => $auth_key)); if (is_null($test) || !block_signature_check(block_params_str_to_arr($test), $map)) { require_lang('permissions'); return paragraph(do_lang_tempcode('ACCESS_DENIED__ACCESS_DENIED', escape_html($map['block']))); } // Cleanup $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'temp_block_permissions WHERE p_time<' . strval(time() - 60 * 60 * intval(get_option('session_expiry_time')))); // Return block snippet global $CSSS, $JAVASCRIPTS; $CSSS = array(); $JAVASCRIPTS = array(); $out = new ocp_tempcode(); $out->attach(symbol_tempcode('CSS_TEMPCODE')); $out->attach(symbol_tempcode('JS_TEMPCODE')); $out->attach(do_block($map['block'], $map)); return $out; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { $url = array_key_exists('param', $map) ? $map['param'] : 'http://ocportal.com/backend.php?type=rss&mode=news&filter=16,17,18,19,20'; // http://channel9.msdn.com/Feeds/RSS/ require_code('rss'); $rss = new rss($url); if (!is_null($rss->error)) { return paragraph($rss->error, 'gfgrtyhyyfhd'); } global $NEWS_CATS; $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); $_postdetailss = array(); // Now for the actual stream contents $max = array_key_exists('max_entries', $map) ? intval($map['max_entries']) : 10; $content = new ocp_tempcode(); foreach ($rss->gleamed_items as $i => $item) { if ($i >= $max) { break; } if (array_key_exists('full_url', $item)) { $full_url = $item['full_url']; } elseif (array_key_exists('guid', $item)) { $full_url = $item['guid']; } elseif (array_key_exists('comment_url', $item)) { $full_url = $item['comment_url']; } else { $full_url = ''; } $_title = $item['title']; $date = array_key_exists('clean_add_date', $item) ? get_timezoned_date($item['clean_add_date']) : array_key_exists('add_date', $item) ? $item['add_date'] : ''; $_postdetailss[] = array('DATE' => $date, 'FULL_URL' => $full_url, 'NEWS_TITLE' => $_title); } return do_template('BLOCK_BOTTOM_NEWS', array('_GUID' => '0fc123199c4d4b7af5a26706271b1f4f', 'POSTS' => $_postdetailss)); }
/** * 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)); } }
/** * Get information about new versions of ocPortal (or more accurately, what's wrong with this version). * * @return tempcode Information about the installed ocPortal version */ function get_future_version_information() { require_lang('version'); $url = 'http://ocportal.com/version.php?version=' . rawurlencode(ocp_version_full()) . '&lang=' . rawurlencode(user_lang()); $data = http_download_file($url, NULL, false); if (!is_null($data)) { $data = str_replace('"../upgrader.php"', '"' . get_base_url() . '/upgrader.php"', $data); if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($data); } require_code('character_sets'); $data = convert_to_internal_encoding($data); $table = new ocp_tempcode(); $lines = explode(chr(10), $data); foreach ($lines as $line) { if (trim($line) != '') { $table->attach(paragraph($line)); } } $table = make_string_tempcode(preg_replace('#<p>\\s*</p>#', '', $table->evaluate())); } else { $table = paragraph(do_lang_tempcode('CANNOT_CONNECT_HOME'), 'dfsdff32ffd'); } require_code('xhtml'); /*$table->attach('<script type="text/javascript">// <![CDATA[ window.open(\''.$url.'\'); //]]></script>');*/ return make_string_tempcode(xhtmlise_html($table->evaluate())); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); $forum = get_forum_type(); $out = new ocp_tempcode(); if ($forum != 'none') { // Standard welcome back vs into greeting $member = get_member(); if (is_guest($member)) { $redirect = get_self_url(true, true); $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $redirect), get_module_zone('login')); $join_url = $GLOBALS['FORUM_DRIVER']->join_url(); $join_bits = do_template('JOIN_OR_LOGIN', array('LOGIN_URL' => $login_url, 'JOIN_URL' => $join_url)); $p = do_lang_tempcode('WELCOME', $join_bits); $out->attach(paragraph($p, 'hhrt4dsgdsgd')); } else { $out->attach(paragraph(do_lang_tempcode('WELCOME_BACK', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member))), 'gfgdf9gjd')); } } $message = get_option('welcome_message'); if (has_actual_page_access(get_member(), 'admin_config')) { if ($message != '') { $message .= ' [[page="_SEARCH:admin_config:category:SITE#group_GENERAL"]' . do_lang('EDIT') . '[/page]]'; } } $out->attach(comcode_to_tempcode($message, NULL, true)); return $out; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('type_validation'); require_lang('phpdoc'); require_code('php'); require_css('adminzone'); disable_php_memory_limit(); $filename = (array_key_exists('param', $map) ? $map['param'] : 'sources/global2') . '.php'; if (substr($filename, -8) == '.php.php') { $filename = substr($filename, 0, strlen($filename) - 4); } $full_path = (get_file_base() != '' ? get_file_base() . '/' : '') . filter_naughty($filename); if (!file_exists($full_path)) { return paragraph(do_lang_tempcode('MISSING_RESOURCE')); } $_classes = get_php_file_api($filename); $classes = new ocp_tempcode(); foreach ($_classes as $class) { if ($class['name'] == '__global') { $class['name'] = do_lang('GLOBAL_FUNCTIONS') . '_' . basename($filename); } $function_summaries = new ocp_tempcode(); $functions = new ocp_tempcode(); foreach ($class['functions'] as $function) { $ret = render_php_function($function, $class); $functions->attach($ret[0]); $function_summaries->attach($ret[1]); } $classes->attach(do_template('PHP_CLASS', array('_GUID' => '5d58fc42c5fd3a5dd190f3f3699610c2', 'CLASS_NAME' => $class['name'], 'FUNCTION_SUMMARIES' => $function_summaries, 'FUNCTIONS' => $functions))); } return do_template('PHP_FILE', array('_GUID' => '6f422e6a6e846d49864d7325b212109f', 'FILENAME' => $filename, 'CLASSES' => $classes)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); require_lang('custom_comcode'); $tags = array(); $wmap = array('tag_enabled' => 1); if (!has_specific_permission(get_member(), 'comcode_dangerous')) { $wmap['tag_dangerous_tag'] = 0; } $tags = array_merge($tags, $GLOBALS['SITE_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap)); if (isset($GLOBALS['FORUM_DB']) && $GLOBALS['FORUM_DB']->connection_write != $GLOBALS['SITE_DB']->connection_write && get_forum_type() == 'ocf') { $tags = array_merge($tags, $GLOBALS['FORUM_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap)); } // From Comcode hooks $hooks = find_all_hooks('systems', 'comcode'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/comcode/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_comcode_' . filter_naughty_harsh($hook), true); $tags[] = $object->get_tag(); } if (!array_key_exists(0, $tags)) { return paragraph(do_lang_tempcode('NONE_EM'), '', 'nothing_here'); } $content = new ocp_tempcode(); foreach ($tags as $tag) { $content->attach(do_template('CUSTOM_COMCODE_TAG_ROW', array('_GUID' => '28c257f5d0c596aa828fd9556b0df4a9', 'TITLE' => is_string($tag['tag_title']) ? $tag['tag_title'] : get_translated_text($tag['tag_title']), 'DESCRIPTION' => is_string($tag['tag_description']) ? $tag['tag_description'] : get_translated_text($tag['tag_description']), 'EXAMPLE' => $tag['tag_example']))); } return do_template('BLOCK_MAIN_CUSTOM_COMCODE_TAGS', array('_GUID' => 'b8d3436e6e5fe679ae9b0a368e607610', 'TAGS' => $content)); }
/** * Standard modular render function for profile tab 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 triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('MODULE_TRANS_NAME_warnings'); $order = 80; if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } require_lang('ocf'); require_css('ocf'); $warnings = new ocp_tempcode(); $rows = $GLOBALS['FORUM_DB']->query_select('f_warnings', array('*'), array('w_member_id' => $member_id_of, 'w_is_warning' => 1)); foreach ($rows as $row) { $warning_by = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['w_by']); $date = get_timezoned_date($row['w_time']); if ($row['w_explanation'] == '') { $row['w_explanation'] = '?'; } else { $row['w_explanation'] = str_replace(chr(10), ' ', $row['w_explanation']); } $row['w_explanation_orig'] = $row['w_explanation']; if (strlen($row['w_explanation']) > 30) { $row['w_explanation'] = substr($row['w_explanation'], 0, 27) . '...'; } $explanation = hyperlink(build_url(array('page' => 'warnings', 'type' => '_ed', 'id' => $row['id'], 'redirect' => get_self_url(true)), get_module_zone('warnings')), $row['w_explanation'], false, true, $row['w_explanation_orig']); $warnings->attach(paragraph(do_lang_tempcode('MEMBER_WARNING', $explanation, $warning_by, array(make_string_tempcode(escape_html($date)))), 'treyerhy34y')); } $content = do_template('OCF_MEMBER_PROFILE_WARNINGS', array('MEMBER_ID' => strval($member_id_of), 'WARNINGS' => $warnings)); return array($title, $content, $order); }
function entry() { $paragraphs = ""; $i = 0; while ($i <= 4) { $paragraphs .= "<p>" . paragraph() . "</p>"; $i++; } return $paragraphs; }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev) { if (is_object($ev)) { return $ev; } $ret = new ocp_tempcode(); foreach (explode(chr(10), $ev) as $ev) { $ret->attach(paragraph(escape_html($ev))); } return $ret; }
/** * Get tempcode for a catalogue category 'feature box' for the given row * * @param array The database field row of it * @param ID_TEXT The zone to use * @param boolean Whether to put it in a box * @return tempcode A box for it, linking to the full page */ function get_catalogue_category_html($row, $zone = '_SEARCH', $put_in_box = true) { $content = paragraph(get_translated_tempcode($row['cc_description']), 'yghjgfjftgerr'); $url = build_url(array('page' => 'catalogues', 'type' => 'category', 'id' => $row['id']), $zone); $tree = catalogue_category_breadcrumbs($row['id']); if (!$tree->is_empty()) { $content->attach(paragraph(do_lang_tempcode('LOCATED_IN', $tree))); } $preview = do_template('SIMPLE_PREVIEW_BOX', array('SUMMARY' => $content, 'URL' => $url)); if (!$put_in_box) { return $preview; } return put_in_standard_box($preview, get_translated_text($row['cc_title'])); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); $title = get_page_title('OCGIFTS_TITLE'); require_code('form_templates'); $fields = new ocp_tempcode(); $fields->attach(form_input_username(do_lang_tempcode('TO_USERNAME'), do_lang_tempcode('MEMBER_TO_GIVE'), 'username', get_param('username', ''), true)); $fields->attach(form_input_text(do_lang_tempcode('GIFT_MESSAGE'), do_lang_tempcode('DESCRIPTION_GIFT_MESSAGE'), 'gift_message', '', true)); $fields->attach(form_input_tick(do_lang_tempcode('ANONYMOUS'), do_lang_tempcode('DESCRIPTION_ANONYMOUS'), 'anonymous', false)); $submit_name = do_lang_tempcode('SEND_GIFT'); $text = paragraph(do_lang_tempcode('CHOOSE_MEMBER')); $post_url = build_url(array('page' => 'pointstore', 'type' => 'action_done2', 'id' => 'ocgifts', 'gift' => get_param('gift', 0)), '_SEARCH'); return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'STAFF_HELP_URL' => '', 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev) { if (is_object($ev)) { return $ev; } if ($ev == '') { return new ocp_tempcode(); } $out = new ocp_tempcode(); foreach (explode(chr(10), $ev) as $ev) { $out->attach(paragraph($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink(intval($ev)))); } return $out; }
/** * Standard stage of pointstore item purchase. * * @return tempcode The UI */ function _text() { if (get_option('is_on_flagrant_buy') == '0') { return new ocp_tempcode(); } $title = get_page_title('TITLE_NEWTEXT'); // Build up fields require_code('form_templates'); $fields = form_input_line_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('MESSAGE_DESCRIPTION'), 'message', '', true); $fields->attach(form_input_integer(do_lang_tempcode('NUMBER_DAYS'), do_lang_tempcode('NUMBER_DAYS_DESCRIPTION'), 'days', 1, true)); $price = intval(get_option('text')); $text = paragraph(do_lang_tempcode('FLAGRANT_GUIDE', integer_format($price))); // Return template $post_url = build_url(array('page' => '_SELF', 'type' => '__text', 'id' => 'flagrant'), '_SELF'); return do_template('FORM_SCREEN', array('_GUID' => '3584ba6a16c9a51829dc3b25b58067f6', 'HIDDEN' => '', 'TITLE' => $title, 'ACTION' => do_lang_tempcode('TITLE_NEWTEXT'), 'TEXT' => $text, 'URL' => $post_url, 'SUBMIT_NAME' => do_lang_tempcode('PURCHASE'), 'FIELDS' => $fields)); }
/** * Shows an HTML page of all authors clickably. */ function authors_script() { require_lang('authors'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $start = get_param_integer('start', 0); $max = get_param_integer('max', 300); $author_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%author') . '\''); $rows = array(); foreach ($author_fields as $field) { if ($field['m_table'] != 'addons' && $field['m_table'] != 'blocks' && $field['m_table'] != 'modules') { $rows_new = $GLOBALS['SITE_DB']->query('SELECT DISTINCT ' . $field['m_name'] . ' AS author FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' WHERE ' . db_string_not_equal_to($field['m_name'], '') . ' ORDER BY ' . $field['m_name'], $max + $start); foreach ($rows_new as $a) { if (!array_key_exists($a['author'], $rows) || $field['m_table'] == 'authors') { $rows[$a['author']] = $field['m_table']; } } } } $rows = array_unique($rows); $field_name = get_param('field_name'); $content = new ocp_tempcode(); $i = 0; foreach ($rows as $author => $table) { if ($i >= $start && $i < $start + $max) { if ($table == 'authors') { $content->attach(do_template('AUTHOR_POPUP_WINDOW_DEFINED', array('_GUID' => 'cffa9926cebd3ec2920677266a3299ea', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author))); } else { $content->attach(do_template('AUTHOR_POPUP_WINDOW_UNDEFINED', array('_GUID' => '6210be6d1eef4bc2bda7f49947301f97', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author))); } } $i++; } if ($content->is_empty()) { $content = paragraph(do_lang_tempcode('NO_ENTRIES'), 'dfids09fi;lk;3'); } if ($i >= $start + $max) { $keep = symbol_tempcode('KEEP'); $next_link = find_script('authors') . '?field_name=' . urlencode($field_name) . '&start=' . strval($start + $max) . '&max=' . strval($max) . $keep->evaluate(); } else { $next_link = NULL; } $echo = do_template('STYLED_HTML_WRAP', array('_GUID' => 'ab8d8c9d276530d82ddd84202aacf32f', 'TITLE' => do_lang_tempcode('CHOOSE_AUTHOR'), 'NEXT_LINK' => $next_link, 'CONTENT' => $content)); $echo->evaluate_echo(); }
/** * Get tempcode for a CEDI post 'feature box' for the given row * * @param array The database field row of it * @param ID_TEXT The zone to use * @param boolean Whether to put it in a box * @return tempcode A box for it, linking to the full page */ function get_cedi_page_html($row, $zone = '_SEARCH', $put_in_box = true) { $content = paragraph(get_translated_tempcode($row['description']), 'tyrtfjhggfdf'); $url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $row['id'] == db_get_first_id() ? NULL : $row['id']), $zone); if ($put_in_box) { $chain = cedi_derive_chain($row['id']); $chain = preg_replace('#/[^/]+#', '', $chain); if ($chain != '') { $tree = cedi_breadcrumbs($chain, NULL, true); if (!$tree->is_empty()) { $content->attach(paragraph(do_lang_tempcode('LOCATED_IN', $tree))); } } } $preview = do_template('SIMPLE_PREVIEW_BOX', array('SUMMARY' => $content, 'URL' => $url)); if (!$put_in_box) { return $preview; } return put_in_standard_box($preview, do_lang_tempcode('CEDI_PAGE', escape_html(get_translated_text($row['title'])))); }
/** * 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('PHOTO'); $order = 30; // Actualiser if (post_param_integer('submitting_photo_tab', 0) == 1) { require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_photo('photo_url', 'photo_file', $member_id_of); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_url'); $thumb_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_thumb_url'); // UI fields $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'photo_file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'photo_url', $photo_url, false)); if (get_option('is_on_gd') == '0' || !function_exists('imagetypes')) { $thumb_width = get_option('thumb_width'); $fields->attach(form_input_upload(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('DESCRIPTION_THUMBNAIL', escape_html($thumb_width)), 'photo_file2', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'photo_thumb_url', $thumb_url, false)); } $hidden = new ocp_tempcode(); handle_max_file_size($hidden, 'image'); $hidden->attach(form_input_hidden('submitting_photo_tab', '1')); $text = new ocp_tempcode(); require_code('images'); $max = floatval(get_max_image_size()) / floatval(1024 * 1024); if ($max < 3.0) { require_code('files2'); $config_url = get_upload_limit_config_url(); $text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), is_null($config_url) ? '' : escape_html($config_url)))); } $text = do_template('OCF_EDIT_PHOTO_TAB', array('TEXT' => $text, 'MEMBER_ID' => strval($member_id_of), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id_of), 'PHOTO' => $GLOBALS['FORUM_DRIVER']->get_member_photo_url($member_id_of))); $javascript = ''; return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('newsletter'); require_lang('javascript'); $newsletter_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id(); $_newsletter_title = $GLOBALS['SITE_DB']->query_value_null_ok('newsletters', 'title', array('id' => $newsletter_id)); if (is_null($_newsletter_title)) { return paragraph(do_lang_tempcode('MISSING_RESOURCE')); } $newsletter_title = get_translated_text($_newsletter_title); $address = post_param('address' . strval($newsletter_id), ''); if ($address != '') { require_code('newsletter'); require_code('type_validation'); if (!is_valid_email_address($address)) { $msg = do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INVALID_EMAIL_ADDRESS'))); return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('URL' => get_self_url(), 'MSG' => $msg)); } if (!array_key_exists('path', $map)) { $map['path'] = 'uploads/website_specific/signup.txt'; } require_code('character_sets'); $password = basic_newsletter_join($address, 4, NULL, !file_exists(get_custom_file_base() . '/' . $map['path']), $newsletter_id, post_param('firstname' . strval($newsletter_id), ''), post_param('lastname' . strval($newsletter_id), '')); if ($password == '') { return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('NEWSLETTER_THIS_ALSO'))); } if ($password == do_lang('NA')) { $manage_url = build_url(array('page' => 'newsletter', 'email' => $address), get_module_zone('newsletter')); return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('ALREADY_EMAIL_ADDRESS', escape_html($manage_url->evaluate())))); } require_code('mail'); if (file_exists(get_custom_file_base() . '/' . $map['path'])) { $url = (url_is_local($map['path']) ? get_custom_base_url() . '/' : '') . $map['path']; mail_wrap(array_key_exists('subject', $map) ? $map['subject'] : do_lang('WELCOME'), convert_to_internal_encoding(http_download_file($url)), array($address), array_key_exists('to', $map) ? $map['to'] : '', '', '', 3, NULL, false, NULL, true); } return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP_DONE', array('_GUID' => '9953c83685df4970de8f23fcd5dd15bb', 'NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'PASSWORD' => $password)); } else { return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'URL' => get_self_url())); } }
/** * The actualiser to decline a members joining of a usergroup. * * @return tempcode The UI */ function decline() { $title = get_page_title('DECLINE_FROM_GROUP'); $id = post_param_integer('id', NULL); if (is_null($id)) { $id = get_param_integer('id'); require_code('form_templates'); $text = paragraph(do_lang_tempcode('OPTIONAL_REASON')); $submit_name = do_lang_tempcode('DECLINE_FROM_GROUP'); $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true); $fields = new ocp_tempcode(); $hidden = form_input_hidden('id', strval($id)); $fields->attach(form_input_line(do_lang_tempcode('REASON'), '', 'reason', '', false)); return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); } if (!ocf_may_control_group($id, get_member())) { access_denied('I_ERROR'); } $member_id = get_param_integer('member_id'); ocf_member_validate_into_group($id, $member_id, true, post_param('reason')); $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * The UI to delete all chat rooms. * * @return tempcode The UI */ function delete_all() { $title = get_page_title('DELETE_ALL_ROOMS'); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_tick(do_lang_tempcode('PROCEED'), do_lang_tempcode('Q_SURE'), 'continue_delete', false)); $posting_name = do_lang_tempcode('PROCEED'); //$posting_url=build_url(array('page'=>'_SELF','mode'=>$mode,'type'=>'private_add'),'_SELF'); $posting_url = build_url(array('page' => '_SELF', 'type' => '_delete_all'), '_SELF'); $text = paragraph(do_lang_tempcode('CONFIRM_DELETE_ALL_ROOMS')); return do_template('FORM_SCREEN', array('_GUID' => 'fdf02f5b3a3b9ce6d1abaccf0970ed73', 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'SUBMIT_NAME' => $posting_name, 'URL' => $posting_url, 'TEXT' => $text)); }
/** * Choose a test section to edit. * * @return tempcode The result of execution. */ function ed() { $title = get_page_title('EDIT_TEST_SECTION'); check_specific_permission('edit_own_tests'); if (!$GLOBALS['FORUM_DRIVER']->is_staff(get_member())) { access_denied('STAFF_ONLY'); } $list = $this->get_section_list(); if ($list->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST')); $post_url = build_url(array('page' => '_SELF', 'type' => '_ed'), '_SELF', NULL, false, true); require_code('form_templates'); $fields = form_input_list(do_lang_tempcode('NAME'), '', 'id', $list, NULL, true); $submit_name = do_lang_tempcode('PROCEED'); return do_template('FORM_SCREEN', array('_GUID' => '37f70ba9d23204bceda6e84375b52270', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); }
/** * 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)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('catalogues'); require_lang('main_google_map'); // Set up config/defaults if (!array_key_exists('title', $map)) { $map['title'] = ''; } if (!array_key_exists('region', $map)) { $map['region'] = ''; } if (!array_key_exists('latitude', $map)) { $map['latitude'] = '0'; } if (!array_key_exists('longitude', $map)) { $map['longitude'] = '0'; } $mapwidth = array_key_exists('width', $map) ? $map['width'] : '100%'; $mapheight = array_key_exists('height', $map) ? $map['height'] : '300px'; $api_key = array_key_exists('api_key', $map) ? $map['api_key'] : ''; $set_zoom = array_key_exists('zoom', $map) ? $map['zoom'] : '3'; $set_center = array_key_exists('center', $map) ? $map['center'] : '0'; $set_show_links = array_key_exists('show_links', $map) ? $map['show_links'] : '1'; $cluster = array_key_exists('cluster', $map) ? $map['cluster'] : '0'; if (!array_key_exists('catalogue', $map)) { $map['catalogue'] = ''; } if (!array_key_exists('longfield', $map)) { $map['longfield'] = 'Longitude'; } if (!array_key_exists('latfield', $map)) { $map['latfield'] = 'Latitude'; } $min_latitude = array_key_exists('min_latitude', $map) ? $map['min_latitude'] : ''; $max_latitude = array_key_exists('max_latitude', $map) ? $map['max_latitude'] : ''; $min_longitude = array_key_exists('min_longitude', $map) ? $map['min_longitude'] : ''; $max_longitude = array_key_exists('max_longitude', $map) ? $map['max_longitude'] : ''; $longitude_key = $map['longfield']; $latitude_key = $map['latfield']; $catalogue_name = $map['catalogue']; $star_entry = array_key_exists('star_entry', $map) ? $map['star_entry'] : ''; $max_results = array_key_exists('max_results', $map) && $map['max_results'] != '' ? intval($map['max_results']) : 1000; $icon = array_key_exists('icon', $map) ? $map['icon'] : ''; if (!array_key_exists('filter_category', $map)) { $map['filter_category'] = ''; } if (!array_key_exists('filter_rating', $map)) { $map['filter_rating'] = ''; } if (!array_key_exists('filter_term', $map)) { $map['filter_term'] = ''; } if (!array_key_exists('filter_hours', $map)) { $map['filter_hours'] = ''; } $data = array(); if ($catalogue_name != '') { // Data query $query = 'SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'catalogue_entries WHERE ce_validated=1 AND ' . db_string_equal_to('c_name', $catalogue_name); // Filtering if ($map['filter_category'] != '') { require_code('ocfiltering'); $query .= ' AND (' . ocfilter_to_sqlfragment($map['filter_category'], 'id', 'catalogue_categories', 'cc_parent_id', 'cc_id', 'id') . ')'; } if ($map['filter_hours'] != '') { $query .= ' AND ce_add_date>' . strval(time() - 60 * 60 * intval($map['filter_hours'])); } if ($map['filter_rating'] != '') { $query .= ' AND (SELECT AVG(rating) FROM rating WHERE ' . db_string_equal_to('rating_for_type', 'catalogue_entry') . ' AND rating_for_id=id)>' . strval(intval($map['filter_rating'])); } // Info about our catalogue $catalogue_rows = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1); if (!array_key_exists(0, $catalogue_rows)) { return paragraph('Could not find the catalogue named "' . escape_html($catalogue_name) . '".', '', 'nothing_here'); } $catalogue_row = $catalogue_rows[0]; // Get results $entries_to_show = array(); if ($star_entry != '') { $entries_to_show = array_merge($entries_to_show, $GLOBALS['SITE_DB']->query($query . ' AND id=' . strval(intval($star_entry)))); $query .= ' AND id<>' . strval(intval($star_entry)); } $entries_to_show = array_merge($entries_to_show, $GLOBALS['SITE_DB']->query($query . ' ORDER BY ce_add_date DESC', $max_results)); if (count($entries_to_show) == 0 && ($min_latitude == '' || $max_latitude == '' || $min_longitude == '' || $max_longitude == '')) { //return paragraph(do_lang_tempcode('NO_ENTRIES'),'','nothing_here'); } // Make marker data Javascript-friendly foreach ($entries_to_show as $i => $entry_row) { $entry_row['allow_rating'] = 0; // Performance: So rating is not loaded $details = get_catalogue_entry_map($entry_row, $catalogue_row, 'CATEGORY', $catalogue_name, NULL); $two_d_list = $details['FIELDS_2D']; $longitude = NULL; $latitude = NULL; $entry_title = ''; $all_output = ''; foreach ($two_d_list as $index => $l) { if ($l['NAME'] == $longitude_key) { $longitude = $l['VALUE']; } if ($l['NAME'] == $latitude_key) { $latitude = $l['VALUE']; } if ($index == 0) { $entry_title = $l['VALUE']; } $all_output .= (is_object($l['VALUE']) ? $l['VALUE']->evaluate() : $l['VALUE']) . ' '; } if (is_object($longitude)) { $longitude = $longitude->evaluate(); } if (is_object($latitude)) { $latitude = $latitude->evaluate(); } if (is_object($entry_title)) { $entry_title = $entry_title->evaluate(); } if (is_numeric($longitude) && is_numeric($latitude)) { if ($map['filter_term'] == '' || strpos(strtolower($all_output), strtolower($map['filter_term'])) !== false) { $details['LONGITUDE'] = float_to_raw_string(floatval($longitude)); $details['LATITUDE'] = float_to_raw_string(floatval($latitude)); $details['ENTRY_TITLE'] = $entry_title; $entry_content = do_template('CATALOGUE_googlemap_ENTRY_EMBED', $details, NULL, false, 'CATALOGUE_DEFAULT_ENTRY_EMBED'); //put_in_standard_box(hyperlink($url,do_lang_tempcode('VIEW')),do_lang_tempcode('CATALOGUE_ENTRY').' ('.do_lang_tempcode('IN',get_translated_text($catalogue['c_title'])).')'); $details['ENTRY_CONTENT'] = $entry_content; $details['STAR'] = '0'; if ($star_entry != '') { if ($entry_row['id'] == intval($star_entry)) { $details['STAR'] = '1'; } } $details['CC_ID'] = strval($entry_row['cc_id']); $details['ICON'] = ''; $data[] = $details; } } } } $hooks_to_use = explode('|', array_key_exists('extra_sources', $map) ? $map['extra_sources'] : ''); $hooks = find_all_hooks('blocks', 'main_google_map'); foreach (array_keys($hooks) as $hook) { if (in_array($hook, $hooks_to_use)) { require_code('hooks/blocks/main_google_map/' . $hook); $ob = object_factory('Hook_Map_' . $hook); $data = array_merge($data, $ob->get_data($map, $max_results, $min_latitude, $max_latitude, $min_longitude, $max_longitude, $latitude_key, $longitude_key, $catalogue_row, $catalogue_name)); } } $uniqid = uniqid('', true); $div_id = 'div_' . $catalogue_name . '_' . $uniqid; return do_template('BLOCK_MAIN_GOOGLE_MAP', array('TITLE' => $map['title'], 'ICON' => $icon, 'MIN_LATITUDE' => $min_latitude, 'MAX_LATITUDE' => $max_latitude, 'MIN_LONGITUDE' => $min_longitude, 'MAX_LONGITUDE' => $max_longitude, 'DATA' => $data, 'SHOW_LINKS' => $set_show_links, 'DIV_ID' => $div_id, 'CLUSTER' => $cluster, 'REGION' => $map['region'], 'WIDTH' => $mapwidth, 'HEIGHT' => $mapheight, 'LATITUDE' => $map['latitude'], 'LONGITUDE' => $map['longitude'], 'ZOOM' => $set_zoom, 'CENTER' => $set_center)); }
/** * Function to display export order list filters * * @return tempcode The interface. */ function order_export() { require_code('shopping'); require_code('form_templates'); $title = get_page_title('EXPORT_ORDER_LIST'); breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('ORDERS')), array('_SELF:_SELF:show_orders', do_lang_tempcode('ORDER_LIST')))); $fields = new ocp_tempcode(); $order_status_list = get_order_status_list(); $fields->attach(form_input_list(do_lang_tempcode('ORDER_STATUS'), do_lang_tempcode('ORDER_STATUS_FILTER_DESCRIPTION'), 'order_status', $order_status_list, NULL, false, false)); // Dates $start_year = intval(date('Y')) - 1; $start_month = intval(date('m')); $start_day = intval(date('d')); $start_hour = intval(date('H')); $start_minute = intval(date('i')); $end_year = $start_year + 1; $end_month = $start_month; $end_day = $start_day; $end_hour = $start_hour; $end_minute = $start_minute; $fields->attach(form_input_date(do_lang_tempcode('ST_START_PERIOD'), do_lang_tempcode('ST_START_PERIOD_DESCRIPTION'), 'start_date', false, false, true, array($start_minute, $start_hour, $start_month, $start_day, $start_year))); $fields->attach(form_input_date(do_lang_tempcode('ST_END_PERIOD'), do_lang_tempcode('ST_END_PERIOD_DESCRIPTION'), 'end_date', false, false, true, array($end_minute, $end_hour, $end_month, $end_day, $end_year))); return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'TITLE' => $title, 'SUBMIT_NAME' => do_lang_tempcode('EXPORT_ORDER_LIST'), 'TEXT' => paragraph(do_lang_tempcode('EXPORT_ORDER_LIST_TEXT')), 'URL' => build_url(array('page' => '_SELF', 'type' => '_order_export'), '_SELF'), 'HIDDEN' => '', 'FIELDS' => $fields)); }
/** * Fourth installation step. * * @return tempcode Progress report / UI */ function step_4() { global $LANG; if (count($_POST) == 0) { exit(do_lang('INST_POST_ERROR')); } require_code('database/' . post_param('db_type')); $GLOBALS['DB_STATIC_OBJECT'] = object_factory('Database_Static_' . post_param('db_type')); $domain = ocp_srv('HTTP_HOST'); if (substr($domain, 0, 4) == 'www.') { $domain = substr($domain, 4); } $colon_pos = strpos($domain, ':'); if ($colon_pos !== false) { $domain = substr($domain, 0, $colon_pos); } $pos = strpos(ocp_srv('PHP_SELF'), 'install.php'); if ($pos === false) { $pos = strlen(ocp_srv('PHP_SELF')); } else { $pos--; } $port = ocp_srv('SERVER_PORT'); if ($port == '' || $port == '80' || $port == '443') { $port = ''; } else { $port = ':' . $port; } $base_url = post_param('base_url', 'http://' . $domain . $port . substr(ocp_srv('PHP_SELF'), 0, $pos)); if (substr($base_url, -1) == '/') { $base_url = substr($base_url, 0, strlen($base_url) - 1); } // Our forum is $forum_type = post_param('forum_type'); require_code('forum/' . $forum_type); $GLOBALS['FORUM_DRIVER'] = object_factory('forum_driver_' . filter_naughty_harsh($forum_type)); $GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED = array(); // Try and grab ourselves forum details global $INFO; $INFO['sql_database'] = ''; $INFO['sql_user'] = ''; $INFO['sql_pass'] = ''; $board_path = post_param('board_path'); find_forum_path($board_path); if (!array_key_exists('board_url', $INFO) || !(strlen($INFO['board_url']) > 0)) { $file_base = get_file_base(); for ($i = 0; $i < strlen($board_path); $i++) { if ($i >= strlen($file_base)) { break; } if ($board_path[$i] != $file_base[$i]) { break; } } $append = str_replace('\\', '/', substr($board_path, $i)); $INFO['board_url'] = strlen($append) < 15 ? substr($base_url, 0, strlen($base_url) - ($i - strlen($board_path))) . (strlen($append) > 0 && $append[0] == '/' ? '' : '/') . $append : $base_url . '/forums'; } if (!array_key_exists('cookie_member_id', $INFO)) { $INFO['cookie_member_id'] = 'ocp_member_id'; } if (!array_key_exists('cookie_member_hash', $INFO)) { $INFO['cookie_member_hash'] = 'ocp_member_hash'; } $cookie_domain = ''; //(($domain=='localhost') || (strpos($domain,'.')===false))?'':('.'.$domain); $cookie_path = '/'; $cookie_days = '120'; $use_persistent = false; require_code('version'); $table_prefix = $domain == 'test.ocportal.com' ? $forum_type . '_ocp_' : 'ocp_'; if (strpos(strtoupper(PHP_OS), 'WIN') !== false) { $db_site_host = '127.0.0.1'; } else { $db_site_host = 'localhost'; } $db_site_user = $INFO['sql_user']; $db_site_password = $INFO['sql_pass']; $db_site = $INFO['sql_database']; $db_forums_host = $db_site_host; $db_forums_user = $db_site_user; $db_forums_password = $db_site_password; $db_forums = $db_site; $board_prefix = $INFO['board_url']; $member_cookie = $INFO['cookie_member_id']; $pass_cookie = $INFO['cookie_member_hash']; if (function_exists('posix_getpwuid') && strpos(@ini_get('disable_functions'), 'posix_getpwuid') === false) { $u_info = posix_getpwuid(fileowner(get_file_base() . '/install.php')); if ($u_info !== false) { $ftp_username = $u_info['name']; } else { $ftp_username = ''; } } else { $ftp_username = ''; } if (is_null($ftp_username)) { $ftp_username = ''; } $dr = array_key_exists('DOCUMENT_ROOT', $_SERVER) ? $_SERVER['DOCUMENT_ROOT'] : (array_key_exists('DOCUMENT_ROOT', $_ENV) ? $_ENV['DOCUMENT_ROOT'] : ''); if (strpos($dr, '/') !== false) { $dr_parts = explode('/', $dr); } else { $dr_parts = explode('\\', $dr); } $webdir_stub = $dr_parts[count($dr_parts) - 1]; // If we have a host where the FTP is two+ levels down (often when we have one FTP covering multiple virtual hosts), then this "last component" rule would be insufficient; do a search through for critical strings to try and make a better guess $special_root_dirs = array('public_html', 'www', 'webroot', 'httpdocs', 'wwwroot'); $webdir_stub = $dr_parts[count($dr_parts) - 1]; foreach ($dr_parts as $i => $part) { if (in_array($part, $special_root_dirs)) { $webdir_stub = implode('/', array_slice($dr_parts, $i)); } } $ftp_folder = '/' . $webdir_stub . substr(ocp_srv('PHP_SELF'), 0, $pos); $ftp_domain = $domain; $specifics = $GLOBALS['FORUM_DRIVER']->install_specifics(); // Now we've gone through all the work of detecting it, lets grab from info.php to see what we had last time we installed global $SITE_INFO; if (file_exists(get_file_base() . '/info.php') && filesize(get_file_base() . '/info.php') != 0) { require_once get_file_base() . '/info.php'; if ($INFO['sql_database'] != '') { if (!array_key_exists('forum_type', $SITE_INFO) || $SITE_INFO['forum_type'] != $forum_type) { unset($SITE_INFO['user_cookie']); unset($SITE_INFO['pass_cookie']); } foreach ($specifics as $specific) { if (array_key_exists($specific['name'], $SITE_INFO)) { unset($SITE_INFO[$specific['name']]); } } unset($SITE_INFO['db_forums_host']); unset($SITE_INFO['db_forums_user']); unset($SITE_INFO['db_forums_password']); unset($SITE_INFO['db_forums']); unset($SITE_INFO['db_site_host']); unset($SITE_INFO['db_site_user']); unset($SITE_INFO['db_site_password']); unset($SITE_INFO['db_site']); } unset($SITE_INFO['base_url']); } $sections = new ocp_tempcode(); // Is this autoinstaller? global $FILE_ARRAY; if (@is_array($FILE_ARRAY) && !is_suexec_like()) { $title = protect_from_escaping(escape_html('FTP')); $text = do_lang_tempcode('AUTO_INSTALL'); $hidden = new ocp_tempcode(); $options = new ocp_tempcode(); $options->attach(make_option(do_lang_tempcode('FTP_DOMAIN'), new ocp_tempcode(), 'ftp_domain', post_param('ftp_domain', $ftp_domain), false, true)); $options->attach(make_option(do_lang_tempcode('FTP_USERNAME'), new ocp_tempcode(), 'ftp_username', post_param('ftp_username', $ftp_username), false, true)); $options->attach(make_option(do_lang_tempcode('FTP_PASSWORD'), new ocp_tempcode(), 'ftp_password', post_param('ftp_password', ''), true)); $options->attach(make_option(do_lang_tempcode('FTP_DIRECTORY'), do_lang_tempcode('FTP_FOLDER'), 'ftp_folder', post_param('ftp_folder', $ftp_folder))); $options->attach(make_option(do_lang_tempcode('FTP_FILES_PER_GO'), do_lang_tempcode('DESCRIPTION_FTP_FILES_PER_GO'), 'max', post_param('max', '1000'))); $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => '50fcb00f4d1da1813e94d86529ea0862', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'OPTIONS' => $options))); } $title = do_lang_tempcode('GENERAL_SETTINGS'); $text = new ocp_tempcode(); $options = new ocp_tempcode(); $hidden = new ocp_tempcode(); $options->attach(make_option(do_lang_tempcode('DOMAIN'), example('DOMAIN_EXAMPLE', 'DOMAIN_TEXT'), 'domain', $domain, false, true)); $options->attach(make_option(do_lang_tempcode('BASE_URL'), example('BASE_URL_EXAMPLE', 'BASE_URL_TEXT'), 'base_url', $base_url, false, true)); if (post_param('db_type') != 'xml') { $options->attach(make_option(do_lang_tempcode('TABLE_PREFIX'), example('TABLE_PREFIX_EXAMPLE', 'TABLE_PREFIX_TEXT'), 'table_prefix', $table_prefix)); } else { $hidden->attach(form_input_hidden('table_prefix', $table_prefix)); } $admin_password = ''; $options->attach(make_option(do_lang_tempcode('MASTER_PASSWORD'), example('', 'CHOOSE_ADMIN_PASSWORD'), 'admin_password', $admin_password, true)); $options->attach(make_tick(do_lang_tempcode('USE_PERSISTENT'), example('', 'USE_PERSISTENT_TEXT'), 'use_persistent', $use_persistent ? 1 : 0)); // $options->attach(make_tick(do_lang_tempcode('MULTI_LANG'),example('','MULTI_LANG_TEXT'),'multi_lang',true)); require_lang('config'); $options->attach(make_tick(do_lang_tempcode('SEND_ERROR_EMAILS_OCPRODUCTS'), example('', 'CONFIG_OPTION_send_error_emails_ocproducts'), 'allow_reports_default', 1)); $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => 'f051465e86a7a53ec078e0d9de773993', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'OPTIONS' => $options))); $hidden = new ocp_tempcode(); $forum_text = new ocp_tempcode(); if ($forum_type == 'ocf' || $forum_type == 'none') { $forum_title = do_lang_tempcode('FORUM_SETTINGS'); } else { $_forum_type = do_lang('FORUM_CLASS_' . preg_replace('#\\d+$#', '', $forum_type), NULL, NULL, NULL, NULL, false); if (is_null($_forum_type)) { $_forum_type = ucwords($forum_type); } $forum_title = do_lang_tempcode('_FORUM_SETTINGS', escape_html($_forum_type)); } $forum_options = new ocp_tempcode(); $use_msn = post_param_integer('use_msn', 0); if ($use_msn == 0) { $use_msn = post_param_integer('use_multi_db', 0); } $forum_type = post_param('forum_type'); if ($forum_type != 'none') { if ($use_msn == 1) { if ($forum_type != 'ocf') { $forum_text = do_lang_tempcode('AUTODETECT'); } $forum_options->attach(make_option(do_lang_tempcode('DATABASE_NAME'), new ocp_tempcode(), 'db_forums', $db_forums, false, true)); if (!$GLOBALS['DB_STATIC_OBJECT']->db_is_flat_file_simple()) { $forum_options->attach(make_option(do_lang_tempcode('DATABASE_HOST'), example('', 'DATABASE_HOST_TEXT'), 'db_forums_host', $db_forums_host, false, true)); $forum_options->attach(make_option(do_lang_tempcode('DATABASE_USERNAME'), new ocp_tempcode(), 'db_forums_user', $db_forums_user, false, true)); $forum_options->attach(make_option(do_lang_tempcode('DATABASE_PASSWORD'), new ocp_tempcode(), 'db_forums_password', $db_forums_password, true)); } else { $hidden->attach(form_input_hidden('db_forums_host', 'localhost')); $hidden->attach(form_input_hidden('db_forums_user', '')); $hidden->attach(form_input_hidden('db_forums_password', '')); } $hidden->attach(form_input_hidden('use_msn', strval($use_msn))); } if ($forum_type != 'ocf' || $use_msn == 1) { $forum_options->attach(make_option(do_lang_tempcode('BASE_URL'), example('FORUM_BASE_URL_EXAMPLE', 'BASE_URL_TEXT_FORUM'), 'board_prefix', $board_prefix, false, true)); } } foreach ($specifics as $specific) { if ($specific['name'] == 'clear_existing_forums_on_install') { $hidden->attach(form_input_hidden('clear_existing_forums_on_install', 'yes')); } elseif ($specific['name'] == 'ocf_table_prefix' && $use_msn == 0) { // Nothing } else { $forum_options->attach(make_option(is_object($specific['title']) ? $specific['title'] : make_string_tempcode($specific['title']), is_object($specific['description']) ? $specific['description'] : make_string_tempcode($specific['description']), $specific['name'], array_key_exists($specific['name'], $SITE_INFO) ? $SITE_INFO[$specific['name']] : $specific['default'], strpos($specific['name'], 'password') !== false)); } } $text = $use_msn == 1 ? do_lang_tempcode($forum_type == 'ocf' ? 'DUPLICATE_OCF' : 'DUPLICATE') : new ocp_tempcode(); $options = make_option(do_lang_tempcode('DATABASE_NAME'), new ocp_tempcode(), 'db_site', $db_site, false, true); if (!$GLOBALS['DB_STATIC_OBJECT']->db_is_flat_file_simple()) { $options->attach(make_option(do_lang_tempcode('DATABASE_HOST'), example('', 'DATABASE_HOST_TEXT'), 'db_site_host', $db_site_host, false, true)); $options->attach(make_option(do_lang_tempcode('DATABASE_USERNAME'), new ocp_tempcode(), 'db_site_user', $db_site_user, false, true)); $options->attach(make_option(do_lang_tempcode('DATABASE_PASSWORD'), new ocp_tempcode(), 'db_site_password', $db_site_password, true)); } else { $hidden->attach(form_input_hidden('db_site_host', 'localhost')); $hidden->attach(form_input_hidden('db_site_user', '')); $hidden->attach(form_input_hidden('db_site_password', '')); } if ($use_msn == 0 && $forum_type != 'ocf') { $forum_options->attach($options); $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('HIDDEN' => $hidden, 'TITLE' => $forum_title, 'TEXT' => $forum_text, 'OPTIONS' => $forum_options))); } else { $title = do_lang_tempcode('OCPORTAL_SETTINGS'); if (!$forum_options->is_empty()) { $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => '232b69a995f384275c1cd9269a42c3b8', 'HIDDEN' => '', 'TITLE' => $forum_title, 'TEXT' => $forum_text, 'OPTIONS' => $forum_options))); } $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => '15e0f275f78414b6c4fe7775a1cacb23', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'OPTIONS' => $options))); } $title = do_lang_tempcode('COOKIE_SETTINGS'); $text = new ocp_tempcode(); $options = new ocp_tempcode(); $hidden = new ocp_tempcode(); $options->attach(make_option(do_lang_tempcode('COOKIE'), example('COOKIE_EXAMPLE', 'COOKIE_TEXT'), 'user_cookie', $member_cookie, false, true)); $options->attach(make_option(do_lang_tempcode('COOKIE_PASSWORD'), example('COOKIE_PASSWORD_EXAMPLE', 'COOKIE_PASSWORD_TEXT'), 'pass_cookie', $pass_cookie, false, true)); $options->attach(make_option(do_lang_tempcode('COOKIE_DOMAIN'), example('COOKIE_DOMAIN_EXAMPLE', 'COOKIE_DOMAIN_TEXT'), 'cookie_domain', $cookie_domain)); $options->attach(make_option(do_lang_tempcode('COOKIE_PATH'), example('COOKIE_PATH_EXAMPLE', 'COOKIE_PATH_TEXT'), 'cookie_path', $cookie_path)); $options->attach(make_option(do_lang_tempcode('COOKIE_DAYS'), example('COOKIE_DAYS_EXAMPLE', 'COOKIE_DAYS_TEXT'), 'cookie_days', $cookie_days, false, true)); $temp = do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => '3b9ea022164801f4b60780a4a966006f', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'OPTIONS' => $options)); $sections->attach(do_template('INSTALLER_STEP_4_SECTION_HIDE', array('_GUID' => '42eb3d44bcf8ef99987b6daa9e6530aa', 'TITLE' => $title, 'CONTENT' => $temp))); $js = do_template('JAVASCRIPT'); $js->attach(chr(10)); $js->attach(do_template('JAVASCRIPT_AJAX')); $message = paragraph(do_lang_tempcode('BASIC_CONFIG')); if ($forum_type != 'none' && $forum_type != 'ocf') { $message->attach(paragraph(do_lang_tempcode('FORUM_DRIVER_NATIVE_LOGIN'))); } return do_template('INSTALLER_STEP_4', array('_GUID' => '73c3ac0a7108709b74b2e89cae30be12', 'JS' => $js, 'MESSAGE' => $message, 'LANG' => $LANG, 'DB_TYPE' => post_param('db_type'), 'FORUM_TYPE' => $forum_type, 'BOARD_PATH' => $board_path, 'SECTIONS' => $sections, 'MAX' => strval(post_param_integer('max', 1000)))); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { if (has_no_forum()) { return new ocp_tempcode(); } require_css('news'); // Read in variables $forum_name = array_key_exists('param', $map) ? $map['param'] : 'General chat'; $limit = array_key_exists('limit', $map) ? intval($map['limit']) : 6; $hot = array_key_exists('hot', $map) ? intval($map['hot']) : 0; $date_key = array_key_exists('date_key', $map) ? $map['date_key'] : 'lasttime'; if ($date_key != 'lasttime' && $date_key != 'firsttime') { $date_key = 'firsttime'; } $username_key = array_key_exists('username_key', $map) ? $map['username_key'] : 'firstusername'; if ($username_key != 'lastusername' && $username_key != 'firstusername') { $username_key = 'firstusername'; } $memberid_key = $username_key == 'firstusername' ? 'firstmemberid' : 'lastmemberid'; // Work out exactly what forums we're reading $forum_ids = array(); if (get_forum_type() == 'ocf' && (strpos($forum_name, ',') !== false || strpos($forum_name, '*') !== false || preg_match('#\\d[-\\*\\+]#', $forum_name) != 0 || is_numeric($forum_name))) { require_code('ocfiltering'); $forum_names = ocfilter_to_idlist_using_db($forum_name, 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']); } else { $forum_names = explode(',', $forum_name); } foreach ($forum_names as $forum_name) { if (!is_string($forum_name)) { $forum_name = strval($forum_name); } $forum_name = trim($forum_name); if ($forum_name == '<announce>') { $forum_id = NULL; } else { $forum_id = is_numeric($forum_name) ? intval($forum_name) : $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name); } if (get_forum_type() == 'ocf' && array_key_exists('check', $map) && $map['check'] == '1') { if (!has_category_access(get_member(), 'forums', strval($forum_id))) { continue; } } if (!is_null($forum_id)) { $forum_ids[$forum_id] = $forum_name; } } // Block title $forum_name = array_key_exists('param', $map) ? $map['param'] : 'General chat'; if (is_numeric($forum_name) && get_forum_type() == 'ocf') { $forum_name = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('id' => intval($forum_name))); if (is_null($forum_name)) { return paragraph(do_lang_tempcode('MISSING_RESOURCE')); } } $_title = do_lang_tempcode('ACTIVE_TOPICS_IN', escape_html($forum_name)); if (array_key_exists('title', $map) && $map['title'] != '') { $_title = protect_from_escaping(escape_html($map['title'])); } // Add topic link if (count($forum_names) == 1 && get_forum_type() == 'ocf' && !is_null($forum_id)) { $submit_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $forum_id), get_module_zone('topics')); $add_name = do_lang_tempcode('ADD_TOPIC'); } else { $submit_url = new ocp_tempcode(); $add_name = new ocp_tempcode(); } // Show all topics if (get_forum_type() == 'ocf') { $forum_names_map = collapse_2d_complexity('id', 'f_name', $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0')); } else { $forum_names_map = NULL; } if (!has_no_forum()) { $max_rows = 0; $topics = $GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_ids, $limit, 0, $max_rows, '', true, $date_key, $hot == 1); $out = new ocp_tempcode(); if (!is_null($topics)) { global $M_SORT_KEY; $M_SORT_KEY = $date_key; usort($topics, 'multi_sort'); $topics = array_reverse($topics, false); if (count($topics) < $limit && $hot == 1) { $more_topics = $GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_ids, $limit, 0, $max_rows, '', true, $date_key); if (is_null($more_topics)) { $more_topics = array(); } $topics = array_merge($topics, $more_topics); } $done = 0; $seen = array(); foreach ($topics as $topic) { if (array_key_exists($topic['id'], $seen)) { continue; } $seen[$topic['id']] = 1; $topic_url = $GLOBALS['FORUM_DRIVER']->topic_url($topic['id'], $forum_name); $topic_url_unread = mixed(); if (get_forum_type() == 'ocf') { $topic_url_unread = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'first_unread'), get_module_zone('topicview'), NULL, false, false, false, 'first_unread'); } $title = escape_html($topic['title']); $date = get_timezoned_date($topic[$date_key]); $username = $topic[$username_key]; $member_id = array_key_exists($memberid_key, $topic) ? $topic[$memberid_key] : NULL; if (!is_null($forum_names_map) && !array_key_exists($topic['forum_id'], $forum_names_map)) { continue; } // Maybe Private Topic, slipped in via reference to a missing forum $forum_name = is_null($forum_names_map) ? NULL : $forum_names_map[$topic['forum_id']]; $out->attach(do_template('BLOCK_MAIN_FORUM_TOPICS_TOPIC', array('_GUID' => 'ae4e351b3fa5422bf8ecdfb7e49076d1', 'POST' => $topic['firstpost'], 'FORUM_ID' => is_null($forum_names_map) ? NULL : strval($topic['forum_id']), 'FORUM_NAME' => $forum_name, 'TOPIC_LINK' => $topic_url, 'TOPIC_LINK_UNREAD' => $topic_url_unread, 'TITLE' => $title, 'DATE' => $date, 'DATE_RAW' => strval($topic[$date_key]), 'USERNAME' => $username, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'NUM_POSTS' => integer_format($topic['num'])))); $done++; if ($done == $limit) { break; } } } if ($out->is_empty()) { return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'c76ab018a0746c2875c6cf69c92a01fb', 'HIGH' => false, 'FORUM_NAME' => array_key_exists('param', $map) ? $map['param'] : 'General chat', 'TITLE' => $_title, 'MESSAGE' => do_lang_tempcode($hot == 1 ? 'NO_TOPICS_HOT' : 'NO_TOPICS'), 'ADD_NAME' => $add_name, 'SUBMIT_URL' => $submit_url)); } return do_template('BLOCK_MAIN_FORUM_TOPICS', array('_GUID' => '368b80c49a335ad035b00510681d5008', 'TITLE' => $_title, 'CONTENT' => $out, 'FORUM_NAME' => array_key_exists('param', $map) ? $map['param'] : 'General chat', 'SUBMIT_URL' => $submit_url)); } else { return new ocp_tempcode(); } }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { if (!array_key_exists('param', $map)) { $map['param'] = 'main'; } if (!array_key_exists('page', $map)) { $map['page'] = str_replace('-', '_', get_page_name()); } if (array_key_exists('extra_param_from', $map)) { $extra = '_' . $map['extra_param_from']; } else { $extra = ''; } require_code('feedback'); $submitted = post_param_integer('_comment_form_post', 0) == 1; $self_url = build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, true); $self_title = $map['page']; $test_changed = post_param('title', NULL); if (!is_null($test_changed)) { decache('main_comments'); } $hidden = $submitted ? actualise_post_comment(true, 'block_main_comments', $map['page'] . '_' . $map['param'] . $extra, $self_url, $self_title, array_key_exists('forum', $map) ? $map['forum'] : NULL, false, NULL, get_page_name() == 'guestbook') : false; $out = new ocp_tempcode(); if (array_key_exists('title', $_POST) && $hidden && $submitted) { $out->attach(paragraph(do_lang_tempcode('MESSAGE_POSTED'), 'dsgdgdfl;gkd09')); if (get_forum_type() == 'ocf') { if (addon_installed('unvalidated')) { require_code('submit'); $validate_url = get_self_url(true, false, array('keep_session' => NULL)); $_validate_url = build_url(array('page' => 'topics', 'type' => 'validate_post', 'id' => $GLOBALS['LAST_POST_ID'], 'redirect' => $validate_url), get_module_zone('topics'), NULL, false, false, true); $validate_url = $_validate_url->evaluate(); send_validation_request('MAKE_POST', 'f_posts', false, $GLOBALS['LAST_POST_ID'], $validate_url); } } } $invisible_if_no_comments = array_key_exists('invisible_if_no_comments', $map) && $map['invisible_if_no_comments'] == '1'; $reverse = array_key_exists('reverse', $map) && $map['reverse'] == '1'; $allow_reviews = !array_key_exists('reviews', $map) || $map['reviews'] == '1'; $out->attach(get_comments('block_main_comments', true, $map['page'] . '_' . $map['param'] . $extra, $invisible_if_no_comments, array_key_exists('forum', $map) ? $map['forum'] : NULL, NULL, NULL, get_page_name() == 'guestbook', $reverse, NULL, $allow_reviews)); return $out; }
/** * Get a tempcoded version of a normal XHTML template. It is perhaps the most common ocPortal function to load up templates using do_template, and then attach them together either as parameters to each other, or via the tempcode attach method. * * @param ID_TEXT The codename of the template being loaded * @param ?array A map of parameters for the template (key to value) (NULL: no parameters) * @param ?LANGUAGE_NAME The language to load the template in (templates can embed language references) (NULL: users own language) * @param boolean Whether to not produce a stack dump if the template is missing * @param ?ID_TEXT Alternate template to use if the primary one does not exist (NULL: none) * @param string File type suffix of template file (e.g. .tpl) * @param string Subdirectory type to look in * @set templates css * @param ID_TEXT Theme to use * @return tempcode The tempcode for this template */ function do_template($codename, $parameters = NULL, $lang = NULL, $light_error = false, $fallback = NULL, $suffix = '.tpl', $type = 'templates', $theme = NULL) { if (is_null($lang) || $lang == '') { global $USER_LANG_CACHED; $lang = isset($USER_LANG_CACHED) ? $USER_LANG_CACHED : (function_exists('user_lang') ? user_lang() : 'EN'); } if ($GLOBALS['SEMI_DEBUG_MODE']) { if ($codename != 'tempcode_test' && $codename != 'handle_conflict_resolution' && strtoupper($codename) != strtoupper($codename)) { fatal_exit('Template names should be in upper case, and the files should be stored in upper case.'); } if (substr($codename, -7) == '_SCREEN' || $codename == 'POOR_XHTML_WRAPPER' || $codename == 'OCF_WRAPPER') { $GLOBALS['SCREEN_TEMPLATE_CALLED'] = $codename; } } if (is_null($parameters)) { $parameters = array(); } global $RECORD_TEMPLATES_USED, $FILE_ARRAY, $MEM_CACHE, $CACHE_TEMPLATES, $KEEP_MARKERS, $SHOW_EDIT_LINKS, $XHTML_SPIT_OUT, $TEMPLATE_CACHE, $MOBILE, $FORUM_DRIVER; $special_treatment = ($KEEP_MARKERS || $SHOW_EDIT_LINKS) && is_null($XHTML_SPIT_OUT); // Is it already loaded? if ($RECORD_TEMPLATES_USED) { global $RECORDED_TEMPLATES_USED; $RECORDED_TEMPLATES_USED[] = $codename; } // Variables we'll need if (!isset($theme)) { $theme = isset($FORUM_DRIVER) && is_object($FORUM_DRIVER) && method_exists($FORUM_DRIVER, 'get_theme') ? filter_naughty($FORUM_DRIVER->get_theme()) : 'default'; } $_codename = $MOBILE ? $codename . '_mobile' : $codename; if (isset($TEMPLATE_CACHE[$theme][$codename][$lang])) { $_data = $TEMPLATE_CACHE[$theme][$codename][$lang]->bind($parameters, $codename); // Copy and pasted to remove need for an function call if ($special_treatment) { if ($KEEP_MARKERS) { $__data = make_string_tempcode('<!-- START-TEMPLATE=' . $codename . ' -->'); $__data->attach($_data); $__data->attach('<!-- END-TEMPLATE=' . $codename . ' -->'); $_data = $__data; } if ($SHOW_EDIT_LINKS) { $edit_url = build_url(array('page' => 'admin_themes', 'theme' => $FORUM_DRIVER->get_theme(), 'template' => $codename), 'adminzone'); $_data->attach('<br /><a href="' . escape_html($edit_url->evaluate()) . '">' . do_lang('EDIT') . ' ' . $codename . '</a>'); } } return $_data; } // Is it structurally cached on disk yet? $data = mixed(); if ($CACHE_TEMPLATES) { if (!is_null($MEM_CACHE)) { $data = persistant_cache_get(array('TEMPLATE', $theme, $lang, $_codename)); if (!is_null($data)) { $_data = new ocp_tempcode(); $_data->from_assembly($data); if ($_data->bits == array()) { $data = false; } // Corrupt somehow } else { $data = false; } } elseif (is_null($data)) { $_data = new ocp_tempcode(); $tcp_path = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . $lang . '/' . $_codename . $suffix . '.tcd'; $data = @file_get_contents($tcp_path, FILE_BINARY); if ($data === '') { $data = false; } // '' needed for PHP4 - weird if ($data !== false) { $_data->from_assembly($data); if ($_data->bits == array()) { $data = false; } // Corrupt somehow } } } else { $data = false; } if ($data === false) { if (!isset($FILE_ARRAY)) { $_data = NULL; $prefix_default = get_file_base() . '/themes/'; $prefix = $theme == 'default' ? $prefix_default : get_custom_file_base() . '/themes/'; if (file_exists($prefix . $theme . '/' . $type . '_custom/' . $_codename . $suffix)) { $_data = _do_template($theme, '/' . $type . '_custom/', $_codename, $_codename, $lang, $suffix, $theme); } elseif (file_exists($prefix . $theme . '/' . $type . '/' . $_codename . $suffix)) { $_data = _do_template($theme, '/' . $type . '/', $_codename, $_codename, $lang, $suffix, $theme); } elseif (!is_null($GLOBALS['CURRENT_SHARE_USER']) && $theme != 'default' && file_exists($prefix_default . $theme . '/' . $type . '_custom/' . $_codename . $suffix)) { $_data = _do_template($theme, '/' . $type . '_custom/', $_codename, $_codename, $lang, $suffix, $theme); } elseif (!is_null($GLOBALS['CURRENT_SHARE_USER']) && $theme != 'default' && file_exists($prefix_default . $theme . '/' . $type . '/' . $_codename . $suffix)) { $_data = _do_template($theme, '/' . $type . '/', $_codename, $_codename, $lang, $suffix, $theme); } elseif (file_exists($prefix_default . 'default' . '/' . $type . '_custom/' . $_codename . $suffix)) { $_data = _do_template('default', '/' . $type . '_custom/', $_codename, $_codename, $lang, $suffix, $theme); } elseif (file_exists($prefix_default . 'default' . '/' . $type . '/' . $_codename . $suffix)) { $_data = _do_template('default', '/' . $type . '/', $_codename, $_codename, $lang, $suffix, $theme); } elseif ($codename != $_codename) { if (file_exists($prefix . $theme . '/' . $type . '_custom/' . $codename . $suffix)) { $_data = _do_template($theme, '/' . $type . '_custom/', $codename, $_codename, $lang, $suffix, $theme); } elseif (file_exists($prefix . $theme . '/' . $type . '/' . $codename . $suffix)) { $_data = _do_template($theme, '/' . $type . '/', $codename, $_codename, $lang, $suffix, $theme); } elseif (file_exists($prefix_default . 'default' . '/' . $type . '_custom/' . $codename . $suffix)) { $_data = _do_template('default', '/' . $type . '_custom/', $codename, $_codename, $lang, $suffix, $theme); } elseif (file_exists($prefix_default . 'default' . '/' . $type . '/' . $codename . $suffix)) { $_data = _do_template('default', '/' . $type . '/', $codename, $_codename, $lang, $suffix, $theme); } } if (is_null($_data)) { if (is_null($fallback)) { if ($light_error) { return paragraph(do_lang_tempcode('MISSING_TEMPLATE_FILE', escape_html($codename))); } fatal_exit(do_lang_tempcode('MISSING_TEMPLATE_FILE', escape_html($codename))); } else { $result = do_template($fallback, $parameters, $lang); $TEMPLATE_CACHE[$theme][$codename][$lang] = $TEMPLATE_CACHE[$fallback][$lang]; return $result; } } } else { $_data = _do_template('default', '/' . $type . '/', $codename, $codename, $lang, $suffix, $theme); } } $TEMPLATE_CACHE[$theme][$codename][$lang] = $_data; $ret = $_data->bind($parameters, $codename); if ($special_treatment) { if ($KEEP_MARKERS) { $__data = new ocp_tempcode(); $__data->attach('<!-- START-TEMPLATE=' . $codename . ' -->'); $__data->attach($ret); $__data->attach('<!-- END-TEMPLATE=' . $codename . ' -->'); $ret = $__data; } if ($SHOW_EDIT_LINKS && $codename != 'PARAM_INFO') { $param_info = do_template('PARAM_INFO', array('MAP' => $parameters)); $edit_url = build_url(array('page' => 'admin_themes', 'theme' => $FORUM_DRIVER->get_theme(), 'template' => $codename), 'adminzone'); $SHOW_EDIT_LINKS = false; $ret = do_template('TEMPLATE_EDIT_LINK', array('_GUID' => '511ae911d31a5b237a4371ff22fc78fd', 'PARAM_INFO' => $param_info, 'CONTENTS' => $ret, 'CODENAME' => $codename, 'EDIT_URL' => $edit_url)); $SHOW_EDIT_LINKS = true; } } return $ret; }
/** * View survey results. * * @return tempcode The result of execution. */ function _survey_results() { $title = get_page_title('SURVEY_RESULTS'); breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('MANAGE_QUIZZES')))); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/survey_results'; $id = get_param_integer('id'); // quiz ID $fields = new ocp_tempcode(); require_code('templates_results_table'); require_code('templates_view_space'); // Show summary $question_rows = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id), 'ORDER BY id'); foreach ($question_rows as $q) { $question = get_translated_text($q['q_question_text']); $answers = new ocp_tempcode(); $answer_rows = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $q['id']), 'ORDER BY id'); $all_answers = array(); foreach ($answer_rows as $i => $a) { $answer = get_translated_text($a['q_answer_text']); $count = $GLOBALS['SITE_DB']->query_value('quiz_entry_answer', 'COUNT(*)', array('q_answer' => strval($a['id']))); $all_answers[serialize(array($answer, $i))] = $count; } arsort($all_answers); foreach ($all_answers as $bits => $count) { list($answer, $i) = unserialize($bits); $answers->attach(paragraph(do_lang_tempcode('SURVEY_ANSWER_RESULT', escape_html($answer), integer_format($count), integer_format($i + 1)))); } if ($answers->is_empty()) { $answers = do_lang_tempcode('FREE_ENTRY_ANSWER'); } $fields->attach(view_space_field($question, $answers, true)); } $summary = do_template('VIEW_SPACE', array('_GUID' => '2b0c2ba0070ba810c5e4b5b4aedcb15f', 'WIDTH' => '300', 'FIELDS' => $fields)); // Show results table $start = get_param_integer('start', 0); $max = get_param_integer('max', 50); $sortables = array('q_time' => do_lang_tempcode('DATE')); $test = explode(' ', get_param('sort', 'q_time DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; $max_rows = $GLOBALS['SITE_DB']->query_value('quiz_entries', 'COUNT(*)', array('q_quiz' => $id)); $rows = $GLOBALS['SITE_DB']->query_select('quiz_entries', array('id', 'q_time', 'q_member'), array('q_quiz' => $id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start); if (count($rows) == 0) { return inform_screen($title, do_lang_tempcode('NO_ENTRIES')); } $fields = new ocp_tempcode(); $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('USERNAME')), $sortables, 'sort', $sortable . ' ' . $sort_order); foreach ($rows as $myrow) { $date_link = hyperlink(build_url(array('page' => '_SELF', 'type' => '__survey_results', 'id' => $myrow['id']), '_SELF'), escape_html(get_timezoned_date($myrow['q_time']))); $member_link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['q_member']); $fields->attach(results_entry(array($date_link, $member_link), false)); } if ($fields->is_empty()) { warn_exit(do_lang_tempcode('NO_ENTRIES')); } $results = results_table(do_lang_tempcode('SURVEY_RESULTS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort'); return do_template('SURVEY_RESULTS_SCREEN', array('_GUID' => '3f38ac1b94fb4de8219b8f7108c7b0a3', 'TITLE' => $title, 'SUMMARY' => $summary, 'RESULTS' => $results)); }