/** * Find whether a member may edit the detailed post. * * @param MEMBER The owner of the post. * @param ?AUTO_LINK The forum the post is in (NULL: is a Private Topic). * @param ?MEMBER The member (NULL: current member). * @return boolean The answer. */ function ocf_may_edit_post_by($resource_owner, $forum_id, $member_id = NULL) { if (is_null($member_id)) { $member_id = get_member(); } if (is_null($forum_id)) { if ($resource_owner == $member_id && has_specific_permission($member_id, 'edit_personal_topic_posts')) { return true; } } if (is_null($forum_id)) { return false; } if (!has_category_access($member_id, 'forums', strval($forum_id))) { return false; } return has_edit_permission('low', $member_id, $resource_owner, 'topics', array('forums', $forum_id)); }
/** * Get a list of maps containing all the downloads, and path information, under the specified category - and those beneath it, recursively. * * @param ?MEMBER Only show images/videos submitted by this member (NULL: no filter) * @param ?AUTO_LINK The category being at the root of our recursion (NULL: true root) * @param ?string The tree up to this point in the recursion (NULL: blank, as we are starting the recursion) * @param ?ID_TEXT The name of the $category_id we are currently going through (NULL: look it up). This is here for efficiency reasons, as finding children IDs to recurse to also reveals the childs title * @param ?integer The number of recursive levels to search (NULL: all) * @param ?AUTO_LINK Download we do not want to show (NULL: none to not show) * @param boolean Whether to get a list of child categories (not just direct ones, recursively), instead of just IDs * @param boolean Whether to only show for what may be edited by the current member * @param boolean Whether to only show entries that are tar files (addons) * @return array A list of maps for all categories. Each map entry containins the fields 'id' (category ID) and 'tree' (tree path to the category, including the categories own title), and more. Or if $use_compound_list, the tree structure built with pairs containing the compound list in addition to the child branches */ function get_downloads_tree($submitter = NULL, $category_id = NULL, $tree = NULL, $title = NULL, $shun = NULL, $levels = NULL, $use_compound_list = false, $editable_filter = false, $tar_filter = false) { if (is_null($category_id)) { $category_id = db_get_first_id(); } if (!has_category_access(get_member(), 'downloads', strval($category_id))) { return array(); } if (is_null($tree)) { $tree = ''; } // Put our title onto our tree if (is_null($title)) { $title = get_translated_text($GLOBALS['SITE_DB']->query_value('download_categories', 'category', array('id' => $category_id))); } $tree .= $title; $compound_list = strval($category_id) . ','; // We'll be putting all children in this entire tree into a single list $children = array(); $children[0] = array(); $children[0]['id'] = $category_id; $children[0]['title'] = $title; $children[0]['tree'] = $tree; // Children of this category $rows = $GLOBALS['SITE_DB']->query_select('download_categories c LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=c.category AND ' . db_string_equal_to('language', user_lang()), array('c.id', 'c.category'), array('parent_id' => $category_id), 'ORDER BY text_original', 300); if (count($rows) == 300) { $rows = array(); } $where = array('category_id' => $category_id); if (!is_null($submitter)) { $where['submitter'] = $submitter; } $erows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('id', 'name', 'submitter', 'original_filename'), $where, 'ORDER BY add_date DESC', 300); $children[0]['entries'] = array(); foreach ($erows as $row) { if ($tar_filter && substr(strtolower($row['original_filename']), -4) != '.tar') { continue; } if ($editable_filter && !has_edit_permission('mid', get_member(), $row['submitter'], 'cms_downloads', array('download_downloads', $category_id))) { continue; } if (!is_null($shun) && $shun == $row['id']) { continue; } $children[0]['entries'][$row['id']] = get_translated_text($row['name']); } $children[0]['child_entry_count'] = count($children[0]['entries']); if ($levels === 0) { $children[0]['entries'] = array(); } $children[0]['child_count'] = count($rows); $tree .= ' > '; if ($levels !== 0 || $use_compound_list) { foreach ($rows as $child) { $child_id = $child['id']; $child_title = get_translated_text($child['category']); $child_tree = $tree; $child_children = get_downloads_tree($submitter, $child_id, $child_tree, $child_title, $shun, is_null($levels) ? NULL : max(0, $levels - 1), $use_compound_list, $editable_filter, $tar_filter); if ($use_compound_list) { list($child_children, $_compound_list) = $child_children; $compound_list .= $_compound_list; } if ($levels !== 0) { $children = array_merge($children, $child_children); } } } $children[0]['compound_list'] = $compound_list; return $use_compound_list ? array($children, $compound_list) : $children; }
/** * The UI to view a download. * * @return tempcode The UI */ function dloadinfo_screen() { $id = get_param_integer('id'); $root = get_param_integer('root', db_get_first_id(), true); // Basic Init $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen(get_page_title('SECTION_DOWNLOADS'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=downloads&filter=' . strval($myrow['category_id']); if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) { access_denied('CATEGORY_ACCESS'); } $name = get_translated_text($myrow['name']); list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $id), '_SELF', NULL, false, false, true), $name, get_value('comment_forum__downloads')); // Views if (get_db_type() != 'xml') { $myrow['download_views']++; $GLOBALS['SITE_DB']->query_update('download_downloads', array('download_views' => $myrow['download_views']), array('id' => $id), '', 1, NULL, false, true); } // Tree $tree = download_breadcrumbs($myrow['category_id'], $root, false, get_zone_name()); $title_to_use = do_lang_tempcode('DOWNLOAD_TITLE', escape_html($name)); $title_to_use_2 = do_lang('DOWNLOAD_TITLE', $name); if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('download', strval($id)); } else { $awards = array(); } $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('downloads_download', strval($id), $title_to_use_2); $warning_details = new ocp_tempcode(); // Validation if ($myrow['validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '5b1781b8fbb1ef9b8f47693afcff02b9', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')))); } // Cost warning if ($myrow['download_cost'] != 0 && addon_installed('points')) { require_lang('points'); $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '05fc448bf79b373385723c5af5ec93af', 'WARNING' => do_lang_tempcode('WILL_COST', integer_format($myrow['download_cost']))))); } // Admin functions $edit_url = new ocp_tempcode(); $add_img_url = new ocp_tempcode(); if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_downloads', array('downloads', $myrow['category_id']))) { $edit_url = build_url(array('page' => 'cms_downloads', 'type' => '_ed', 'id' => $id), get_module_zone('cms_downloads')); } if (addon_installed('galleries')) { if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) { require_lang('galleries'); $add_img_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => 'download_' . strval($id)), get_module_zone('cms_galleries')); } } // Outmoding if (!is_null($myrow['out_mode_id'])) { $outmode_url = build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $myrow['out_mode_id'], 'root' => $root == db_get_first_id() ? NULL : $root), '_SELF'); } else { $outmode_url = new ocp_tempcode(); } // Stats $add_date = get_timezoned_date($myrow['add_date'], false); // Additional information $additional_details = get_translated_tempcode($myrow['comments']); // Edit date if (!is_null($myrow['edit_date'])) { $edit_date = make_string_tempcode(get_timezoned_date($myrow['edit_date'], false)); } else { $edit_date = new ocp_tempcode(); } $images_details = new ocp_tempcode(); $image_url = ''; $counter = 0; if (addon_installed('galleries')) { // Images require_lang('galleries'); $cat = 'download_' . strval($id); $map = array('cat' => $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $map['validated'] = 1; } $rows = $GLOBALS['SITE_DB']->query_select('images', array('*'), $map, 'ORDER BY id', 200); $div = 2; $_out = new ocp_tempcode(); $_row = new ocp_tempcode(); require_code('images'); while (array_key_exists($counter, $rows)) { $row = $rows[$counter]; // $view_url=build_url(array('page'=>'galleries','type'=>'image','wide'=>1,'id'=>$row['id']),get_module_zone('galleries')); $view_url = $row['url']; if ($image_url == '') { $image_url = $row['url']; } if (url_is_local($view_url)) { $view_url = get_custom_base_url() . '/' . $view_url; } $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', 'images', $row['id']); $comment = get_translated_tempcode($row['comments']); $thumb = do_image_thumb($thumb_url, ''); if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $row['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) { $iedit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ed', 'id' => $row['id']), get_module_zone('cms_galleries')); } else { $iedit_url = new ocp_tempcode(); } $_content = do_template('DOWNLOAD_SCREEN_IMAGE', array('_GUID' => 'fba0e309aa0ae04891e32c65a625b177', 'ID' => strval($row['id']), 'VIEW_URL' => $view_url, 'EDIT_URL' => $iedit_url, 'THUMB' => $thumb, 'COMMENT' => $comment)); $_row->attach(do_template('DOWNLOAD_GALLERY_IMAGE_CELL', array('_GUID' => '8400a832dbed64bb63f264eb3a038895', 'CONTENT' => $_content))); if ($counter % $div == 1 && $counter != 0) { $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => '205c4f5387e98c534d5be1bdfcccdd7d', 'CELLS' => $_row))); $_row = new ocp_tempcode(); } $counter++; } if (!$_row->is_empty()) { $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => 'e9667ca2545ac72f85a873f236cbbd6f', 'CELLS' => $_row))); } $images_details = $_out; } // Download link $author = $myrow['author']; $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')) : new ocp_tempcode(); // Licence $licence_title = NULL; $licence_url = NULL; $licence_hyperlink = NULL; $licence = $myrow['download_licence']; if (!is_null($licence)) { $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence)); if (!is_null($licence_title)) { $keep = symbol_tempcode('KEEP'); $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate(); $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license')); } else { $licence = NULL; // Orphaned } } breadcrumb_add_segment($tree, $title_to_use); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Download', 'title' => get_translated_text($myrow['name']), 'identifier' => '_SEARCH:downloads:view:' . strval($id), 'description' => get_translated_text($myrow['description']), 'image' => $image_url); return do_template('DOWNLOAD_SCREEN', array('_GUID' => 'a9af438f84783d0d38c20b5f9a62dbdb', 'ORIGINAL_FILENAME' => $myrow['original_filename'], 'URL' => $myrow['url'], 'NUM_IMAGES' => strval($counter), 'TAGS' => get_loaded_tags('downloads'), 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink, 'SUBMITTER' => strval($myrow['submitter']), 'EDIT_DATE' => $edit_date, 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'VIEWS' => integer_format($myrow['download_views']), 'NAME' => $name, 'DATE' => $add_date, 'DATE_RAW' => strval($myrow['add_date']), 'NUM_DOWNLOADS' => integer_format($myrow['num_downloads']), 'TITLE' => $title, 'OUTMODE_URL' => $outmode_url, 'WARNING_DETAILS' => $warning_details, 'EDIT_URL' => $edit_url, 'ADD_IMG_URL' => $add_img_url, 'DESCRIPTION' => get_translated_tempcode($myrow['description']), 'ADDITIONAL_DETAILS' => $additional_details, 'IMAGES_DETAILS' => $images_details, 'ID' => strval($id), 'FILE_SIZE' => clean_file_size($myrow['file_size']), 'AUTHOR_URL' => $author_url, 'AUTHOR' => $author, 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENTS_DETAILS' => $comment_details)); }
/** * Get a list of maps containing all the catalogue entries, and path information, under the specified category - and those beneath it, recursively. * * @param ID_TEXT The catalogue name * @param ?AUTO_LINK Only show entries submitted by this member (NULL: no filter) * @param ?AUTO_LINK The category being at the root of our recursion (NULL: true root) * @param ?string The tree up to this point in the recursion (NULL: blank, as we are starting the recursion) * @param ?ID_TEXT The name of the $category_id we are currently going through (NULL: look it up). This is here for efficiency reasons, as finding children IDs to recurse to also reveals the childs title * @param ?integer The number of recursive levels to search (NULL: all) * @param boolean Whether to only show for what may be edited by the current member * @return array A list of maps for all categories. Each map entry containins the fields 'id' (category ID) and 'tree' (tree path to the category, including the categories own title), and more. */ function get_catalogue_entries_tree($catalogue_name, $submitter = NULL, $category_id = NULL, $tree = NULL, $title = NULL, $levels = NULL, $editable_filter = false) { if (is_null($category_id)) { $is_tree = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_is_tree', array('c_name' => $catalogue_name)); } if (is_null($category_id) && is_null($levels)) { if ($GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)', array('c_name' => $catalogue_name)) > 1000) { return array(); } // Too many! } if (is_null($category_id)) { if (is_null($is_tree)) { return array(); } if ($is_tree == 0) { $temp_rows = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title'), array('c_name' => $catalogue_name, 'cc_parent_id' => NULL), 'ORDER BY id DESC', 300); if (get_page_name() == 'cms_catalogues') { if (count($temp_rows) == 300) { attach_message(do_lang_tempcode('TOO_MUCH_CHOOSE__RECENT_ONLY', escape_html(integer_format(300))), 'warn'); } } $children = array(); foreach ($temp_rows as $row) { $children = array_merge(get_catalogue_entries_tree($catalogue_name, $submitter, $row['id'], NULL, get_translated_text($row['cc_title']), 1, $editable_filter), $children); } return $children; } $temp_rows = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title'), array('c_name' => $catalogue_name, 'cc_parent_id' => NULL), 'ORDER BY id', 1); if (!array_key_exists(0, $temp_rows)) { return array(); } $category_id = $temp_rows[0]['id']; $title = get_translated_text($temp_rows[0]['cc_title']); } if (is_null($tree)) { $tree = ''; } if (!has_category_access(get_member(), 'catalogues_catalogue', $catalogue_name)) { return array(); } if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($category_id))) { return array(); } // Put our title onto our tree if (is_null($title)) { $title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogue_categories', 'cc_title', array('id' => $category_id))); } $tree .= $title; // We'll be putting all children in this entire tree into a single list $children = array(); $children[0] = array(); $children[0]['id'] = $category_id; $children[0]['title'] = $title; $children[0]['tree'] = $tree; // Children of this category $rows = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title'), array('cc_parent_id' => $category_id), '', 300); if (get_page_name() == 'cms_catalogues') { if (count($rows) == 300) { attach_message(do_lang_tempcode('TOO_MUCH_CHOOSE__RECENT_ONLY', escape_html(integer_format(300))), 'warn'); } } $where = array('cc_id' => $category_id); if (!is_null($submitter)) { $where['ce_submitter'] = $submitter; } $erows = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('id', 'ce_submitter'), $where, 'ORDER BY ce_add_date DESC', 300); if (get_page_name() == 'cms_catalogues') { if (count($erows) == 300) { attach_message(do_lang_tempcode('TOO_MUCH_CHOOSE__RECENT_ONLY', escape_html(integer_format(300))), 'warn'); } } $children[0]['entries'] = array(); foreach ($erows as $row) { if ($editable_filter && !has_edit_permission('mid', get_member(), $row['ce_submitter'], 'cms_catalogues', array('catalogues_catalogue', $catalogue_name, 'catalogues_category', $category_id))) { continue; } $entry_fields = get_catalogue_entry_field_values($catalogue_name, $row['id'], array(0)); $name = $entry_fields[0]['effective_value']; // 'Name' is value of first field $children[0]['entries'][$row['id']] = $name; } $children[0]['child_entry_count'] = count($children[0]['entries']); if ($levels === 0) { $children[0]['entries'] = array(); } $children[0]['child_count'] = count($rows); $tree .= ' > '; if ($levels !== 0) { foreach ($rows as $i => $child) { $rows[$i]['_cc_title'] = get_translated_text($child['cc_title']); } global $M_SORT_KEY; $M_SORT_KEY = '_cc_title'; usort($rows, 'multi_sort'); foreach ($rows as $child) { $child_id = $child['id']; $child_title = $child['_cc_title']; $child_tree = $tree; $child_children = get_catalogue_entries_tree($catalogue_name, $submitter, $child_id, $child_tree, $child_title, is_null($levels) ? NULL : $levels - 1, $editable_filter); $children = array_merge($children, $child_children); } } return $children; }
/** * Get a nice formatted XHTML list of news. * * @param ?AUTO_LINK The selected news entry (NULL: none) * @param ?MEMBER Limit news to those submitted by this member (NULL: show all) * @param boolean Whether to only show for what may be edited by the current member * @param boolean Whether to only show blog posts * @return tempcode The list */ function nice_get_news($it, $only_owned = NULL, $editable_filter = false, $only_in_blog = false) { $where = is_null($only_owned) ? '1' : 'submitter=' . strval($only_owned); if ($only_in_blog) { $rows = $GLOBALS['SITE_DB']->query('SELECT n.* FROM ' . get_table_prefix() . 'news n JOIN ' . get_table_prefix() . 'news_categories c ON c.id=n.news_category AND ' . $where . ' AND nc_owner IS NOT NULL ORDER BY date_and_time DESC', 300); } else { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'news WHERE ' . $where . ' ORDER BY date_and_time DESC', 300); } if (count($rows) == 300) { attach_message(do_lang_tempcode('TOO_MUCH_CHOOSE__RECENT_ONLY', escape_html(integer_format(300))), 'warn'); } $out = new ocp_tempcode(); foreach ($rows as $myrow) { if (!has_category_access(get_member(), 'news', strval($myrow['news_category']))) { continue; } if ($editable_filter && !has_edit_permission('high', get_member(), $myrow['submitter'], 'cms_news', array('news', $myrow['news_category']))) { continue; } $selected = $myrow['id'] == $it; $out->attach(form_input_list_entry(strval($myrow['id']), $selected, get_translated_text($myrow['title']))); } return $out; }
/** * The UI for doing a quiz. * * @return tempcode The result of execution. */ function do_quiz() { $id = get_param_integer('id'); $quizzes = $GLOBALS['SITE_DB']->query_select('quizzes', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $quizzes)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $quiz = $quizzes[0]; $this->enforcement_checks($quiz); if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('quiz', strval($id)); } else { $awards = array(); } $quiz_name = get_translated_text($quiz['q_name']); $title_to_use = do_lang_tempcode('THIS_WITH', do_lang_tempcode($quiz['q_type']), make_string_tempcode(escape_html($quiz_name))); $title_to_use_2 = do_lang('THIS_WITH_SIMPLE', do_lang($quiz['q_type']), $quiz_name); $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('quiz', strval($id), $title_to_use_2); $last_visit_time = $GLOBALS['SITE_DB']->query_value_null_ok('quiz_member_last_visit', 'v_time', array('v_quiz_id' => $id, 'v_member_id' => get_member()), 'ORDER BY v_time DESC'); if (!is_null($last_visit_time)) { $timer_offset = time() - $last_visit_time; if (is_null($quiz['q_timeout']) || $timer_offset >= $quiz['q_timeout'] * 60) { $GLOBALS['SITE_DB']->query_delete('quiz_member_last_visit', array('v_member_id' => get_member(), 'v_quiz_id' => $id)); $GLOBALS['SITE_DB']->query_insert('quiz_member_last_visit', array('v_quiz_id' => $id, 'v_time' => time(), 'v_member_id' => get_member())); $timer_offset = 0; } } else { $GLOBALS['SITE_DB']->query_insert('quiz_member_last_visit', array('v_quiz_id' => $id, 'v_time' => time(), 'v_member_id' => get_member())); $timer_offset = 0; } $questions = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id), 'ORDER BY q_order'); // If a test/quiz, randomly order questions // if ($quiz['q_type']!='SURVEY') shuffle($questions); No, could cause problems foreach ($questions as $i => $question) { $answers = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $question['id']), 'ORDER BY q_order'); // If a test/quiz, randomly order answers if ($quiz['q_type'] != 'SURVEY') { shuffle($answers); } $questions[$i]['answers'] = $answers; } require_code('quiz'); $fields = render_quiz($questions); breadcrumb_set_self(make_string_tempcode(escape_html(get_translated_text($quiz['q_name'])))); // Validation if ($quiz['q_validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } $type = 'Quiz'; switch ($quiz['q_type']) { case 'COMPETITION': $type = 'Competition'; break; case 'SURVEY': $type = 'Survey'; break; case 'TEST': $type = 'Test'; break; } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $quiz['q_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($quiz['q_submitter']), 'publisher' => '', 'modified' => '', 'type' => $type, 'title' => get_translated_text($quiz['q_name']), 'identifier' => '_SEARCH:quiz:do:' . strval($id), 'description' => get_translated_text($quiz['q_start_text']), 'image' => find_theme_image('bigicons/quiz')); $edit_url = new ocp_tempcode(); if (has_actual_page_access(NULL, 'cms_quiz', NULL, NULL) && has_edit_permission('mid', get_member(), $quiz['q_submitter'], 'cms_quiz', array('quiz', $id))) { $edit_url = build_url(array('page' => 'cms_quiz', 'type' => '_ed', 'id' => $id), get_module_zone('cms_quiz')); } // Display UI: start text, questions. Including timeout $start_text = get_translated_tempcode($quiz['q_start_text']); $post_url = build_url(array('page' => '_SELF', 'type' => '_do', 'id' => $id), '_SELF'); return do_template('QUIZ_SCREEN', array('_GUID' => 'f390877672938ba62f79f9528bef742f', 'EDIT_URL' => $edit_url, 'TAGS' => get_loaded_tags('quiz'), 'ID' => strval($id), 'WARNING_DETAILS' => $warning_details, 'URL' => $post_url, 'TITLE' => $title, 'START_TEXT' => $start_text, 'FIELDS' => $fields, 'TIMEOUT' => is_null($quiz['q_timeout']) ? '' : strval($quiz['q_timeout'] * 60 - $timer_offset))); }
/** * Get a list of maps containing all the gallery entries, and path information, under the specified gallery - and those beneath it, recursively. * * @param ID_TEXT The table we are working with * @set images videos * @param ?AUTO_LINK Only show images/videos submitted by this member (NULL: no filter) * @param ?ID_TEXT The gallery being at the root of our recursion (NULL: true root) * @param ?string The tree up to this point in the recursion (NULL: blank, as we are starting the recursion) * @param ?ID_TEXT The name of the $gallery we are currently going through (NULL: look it up). This is here for efficiency reasons, as finding children IDs to recurse to also reveals the childs title * @param ?integer The number of recursive levels to search (NULL: all) * @param boolean Whether to get a list of child galleries (not just direct ones, recursively), instead of just IDs * @param boolean Whether to only show for what may be edited by the current member * @return array A list of maps for all galleries. Each map entry containins the fields 'id' (gallery ID) and 'tree' (tree path to the category, including the categories own title), and more. Or if $use_compound_list, the tree structure built with pairs containing the compound list in addition to the child branches */ function get_gallery_content_tree($table, $submitter = NULL, $gallery = NULL, $tree = NULL, $title = NULL, $levels = NULL, $use_compound_list = false, $editable_filter = false) { if (is_null($gallery)) { $gallery = 'root'; } if (!has_category_access(get_member(), 'galleries', $gallery)) { return array(); } if (is_null($tree)) { $tree = ''; } // Put our title onto our tree if (is_null($title)) { $title = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $gallery))); } $tree .= $title; // We'll be putting all children in this entire tree into a single list $children = array(); $children[0] = array(); $children[0]['id'] = $gallery; $children[0]['title'] = $title; $children[0]['tree'] = $tree; $compound_list = $gallery . ','; // Children of this category $rows = $GLOBALS['SITE_DB']->query_select('galleries', array('name', 'fullname'), array('parent_id' => $gallery), 'ORDER BY add_date DESC', 300); $where = array('cat' => $gallery); if (!is_null($submitter)) { $where['submitter'] = $submitter; } $erows = $GLOBALS['SITE_DB']->query_select($table, array('id', 'url', 'submitter', 'title'), $where, 'ORDER BY add_date DESC', 300); $children[0]['entries'] = array(); foreach ($erows as $row) { if ($editable_filter && !has_edit_permission('mid', get_member(), $row['submitter'], 'cms_galleries', array('galleries', $gallery))) { continue; } $e_title = get_translated_text($row['title']); if ($e_title == '') { $e_title = basename($row['url']); } $children[0]['entries'][$row['id']] = $e_title; } $children[0]['child_entry_count'] = count($children[0]['entries']); if ($levels === 0) { $children[0]['entries'] = array(); } $children[0]['child_count'] = count($rows); $tree .= ' > '; if ($levels !== 0) { foreach ($rows as $child) { $child_id = $child['name']; $child_title = get_translated_text($child['fullname']); $child_tree = $tree; $child_children = get_gallery_content_tree($table, $submitter, $child_id, $child_tree, $child_title, is_null($levels) ? NULL : $levels - 1, $use_compound_list, $editable_filter); if ($use_compound_list) { list($child_children, $_compound_list) = $child_children; $compound_list .= $_compound_list; } $children = array_merge($children, $child_children); } } $children[0]['compound_list'] = $compound_list; return $use_compound_list ? array($children, $compound_list) : $children; }
/** * The UI to view a poll. * * @return tempcode The UI */ function view() { $title = get_page_title('POLL'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('POLL_ARCHIVE')))); $id = get_param_integer('id'); $_GET['poll_id'] = strval($id); $rows = $GLOBALS['SITE_DB']->query_select('poll', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen($title, do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; // Views if (get_db_type() != 'xml') { $myrow['poll_views']++; $GLOBALS['SITE_DB']->query_update('poll', array('poll_views' => $myrow['poll_views']), array('id' => $id), '', 1, NULL, false, true); } $date_raw = is_null($myrow['date_and_time']) ? '' : strval($myrow['date_and_time']); $add_date_raw = strval($myrow['add_time']); $edit_date_raw = is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']); $date = get_timezoned_date($myrow['date_and_time']); $add_date = get_timezoned_date($myrow['add_time']); $edit_date = get_timezoned_date($myrow['edit_date']); $_title = get_translated_text($myrow['question']); list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], is_null($myrow['date_and_time']) ? 0 : 1, $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF', NULL, false, false, true), $_title, get_value('comment_forum__polls')); if (has_actual_page_access(NULL, 'cms_polls', NULL, NULL) && has_edit_permission('high', get_member(), $myrow['submitter'], 'cms_polls')) { $edit_url = build_url(array('page' => 'cms_polls', 'type' => '_ed', 'id' => $id), get_module_zone('cms_polls')); } else { $edit_url = new ocp_tempcode(); } $poll_details = do_block('main_poll'); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_time']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Poll', 'title' => $_title, 'identifier' => '_SEARCH:polls:view:' . strval($id), 'description' => '', 'image' => find_theme_image('bigicons/polls')); return do_template('POLL_SCREEN', array('_GUID' => '1463a42354c3ad154e2c6bb0c96be3b9', 'TITLE' => $title, 'ID' => strval($id), 'DATE_RAW' => $date_raw, 'ADD_DATE_RAW' => $add_date_raw, 'EDIT_DATE_RAW' => $edit_date_raw, 'DATE' => $date, 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'VIEWS' => integer_format($myrow['poll_views']), 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'POLL_DETAILS' => $poll_details)); }
/** * View an event. * * @return tempcode The UI */ function view_event() { check_specific_permission('view_calendar'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'back'; $id = get_param_integer('id'); $filter = $this->get_filter(); $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=calendar&filter=' . implode(',', $this->get_and_filter()); $rows = $GLOBALS['SITE_DB']->query_select('calendar_events e LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'calendar_types t ON t.id=e.e_type', array('*'), array('e.id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $event = $rows[0]; if ($event['e_is_public'] == 0) { enforce_personal_access($event['e_submitter'], 'view_personal_events'); } if (!has_category_access(get_member(), 'calendar', strval($event['e_type']))) { access_denied('CATEGORY_ACCESS'); } // Validation $warning_details = new ocp_tempcode(); if ($event['validated'] == 0 && $event['e_is_public'] == 1) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '332faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')))); } if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('event', strval($id)); } else { $awards = array(); } $_title = get_translated_text($event['e_title']); $title_to_use = do_lang_tempcode('CALENDAR_EVENT_VCAL', escape_html($_title)); $title_to_use_2 = do_lang('CALENDAR_EVENT', $_title); $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('event', strval($id), $title_to_use_2); $content = $event['e_type'] == db_get_first_id() ? make_string_tempcode(get_translated_text($event['e_content'])) : get_translated_tempcode($event['e_content']); $type = get_translated_text($event['t_title']); $subscribed = new ocp_tempcode(); if (has_specific_permission(get_member(), 'view_event_subscriptions') && cron_installed()) { $subscriptions = $GLOBALS['SITE_DB']->query_select('calendar_reminders', array('DISTINCT n_member_id'), array('e_id' => $id), '', 100); if (count($subscriptions) < 100) { foreach ($subscriptions as $subscription) { $username = $GLOBALS['FORUM_DRIVER']->get_username($subscription['n_member_id']); if (!is_null($username)) { $member_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($subscription['n_member_id'], false, true); $subscribed->attach(do_template('CALENDAR_SCREEN_SUBSCRIPTION', array('_GUID' => 'c756b8b3f0c57494fd46a94e9abce029', 'MEMBER_URL' => $member_url, 'USERNAME' => $username))); } } } } $__first_date = mktime($event['e_start_hour'], $event['e_start_minute'], 0, $event['e_start_month'], $event['e_start_day'], $event['e_start_year']); $_first_date = cal_utctime_to_usertime($__first_date, $event['e_timezone'], $event['e_do_timezone_conv'] == 1); $first_date = date('Y-m-d', $_first_date); $date = get_param('date', $first_date); // It's year 10,000 compliant when it comes to year display ;). $back_type = get_param('back', 'day'); $map = array_merge($filter, array('page' => '_SELF', 'type' => 'misc', 'view' => $back_type, 'id' => $date)); if (get_param_integer('member_id', get_member()) != get_member()) { $map['member_id'] = get_param_integer('member_id'); } $back_url = build_url($map, '_SELF'); list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('events', strval($id) . ($event['e_seg_recurrences'] == 1 ? '_' . $date : ''), $event['allow_rating'], $event['allow_comments'], $event['allow_trackbacks'], get_option('is_on_strong_forum_tie') == '0' || $event['e_is_public'] == 1 ? 1 : 0, $event['e_submitter'], build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF', NULL, false, false, true), $_title, get_value('comment_forum__calendar')); $_subscriptions = new ocp_tempcode(); if (is_guest() || !cron_installed()) { $subscribe_url = new ocp_tempcode(); } else { $subscriptions = $GLOBALS['SITE_DB']->query_select('calendar_reminders', array('id', 'n_seconds_before'), array('e_id' => $id, 'n_member_id' => get_member())); foreach ($subscriptions as $subscription) { $time = display_time_period(intval($subscription['n_seconds_before'])); $unsubscribe_url = build_url(array('page' => '_SELF', 'type' => 'unsubscribe_event', 'id' => $id, 'reminder_id' => $subscription['id']), '_SELF'); $_subscriptions->attach(do_template('CALENDAR_SCREEN_PERSONAL_SUBSCRIPTION', array('_GUID' => 'cc36c75ea516abfab1c65328c0e290fc', 'UNSUBSCRIBE_URL' => $unsubscribe_url, 'TIME' => $time))); } $subscribe_url = build_url(array('page' => '_SELF', 'type' => 'subscribe_event', 'id' => $id), '_SELF'); } if (has_actual_page_access(NULL, 'cms_calendar', NULL, NULL) && has_edit_permission($event['e_is_public'] == 0 ? 'low' : 'mid', get_member(), $event['e_submitter'], 'cms_calendar', array('calendar', $event['e_type']))) { $edit_url = build_url(array('page' => 'cms_calendar', 'type' => '_ed', 'id' => $id), get_module_zone('cms_calendar')); } else { $edit_url = new ocp_tempcode(); } if ($event['e_seg_recurrences'] == 0) { $NON_CANONICAL_PARAMS[] = 'day'; $NON_CANONICAL_PARAMS[] = 'date'; } $day = get_param('day', ''); if ($day != '') { $explode = explode('-', $day); if (count($explode) == 3) { if (is_null($event['e_start_hour'])) { if (is_null($event['e_end_year']) || is_null($event['e_end_month']) || is_null($event['e_end_day'])) { $event['e_end_day'] = $event['e_start_day']; $event['e_end_month'] = $event['e_start_month']; $event['e_end_year'] = $event['e_start_year']; } } if (!is_null($event['e_end_year']) && !is_null($event['e_end_month']) && !is_null($event['e_end_day'])) { $event['e_end_year'] += intval($explode[0]) - $event['e_start_year']; $event['e_end_month'] += intval($explode[1]) - $event['e_start_month']; $event['e_end_day'] += intval($explode[2]) - $event['e_start_day']; } $event['e_start_year'] = intval($explode[0]); $event['e_start_month'] = intval($explode[1]); $event['e_start_day'] = intval($explode[2]); } } $time_raw = cal_get_start_utctime_for_event($event['e_timezone'], $event['e_start_year'], $event['e_start_month'], $event['e_start_day'], $event['e_start_hour'], $event['e_start_minute'], $event['e_do_timezone_conv'] == 1); $from = cal_utctime_to_usertime($time_raw, $event['e_timezone'], $event['e_do_timezone_conv'] == 1); $day_formatted = locale_filter(date(do_lang('calendar_date'), $from)); if (!is_null($event['e_end_year']) && !is_null($event['e_end_month']) && !is_null($event['e_end_day'])) { $to_raw = cal_get_end_utctime_for_event($event['e_timezone'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day'], $event['e_end_hour'], $event['e_end_minute'], $event['e_do_timezone_conv'] == 1); $to = cal_utctime_to_usertime($to_raw, $event['e_timezone'], $event['e_do_timezone_conv'] == 1); $to_day_formatted = locale_filter(date(do_lang('calendar_date'), $to)); $time2 = date_range($from, $to, !is_null($event['e_start_hour'])); } else { $to_raw = NULL; $time2 = is_null($event['e_start_hour']) ? '' : locale_filter(my_strftime(do_lang('calendar_minute'), $from)); $to = NULL; $to_day_formatted = NULL; } $priority = $event['e_priority']; $is_public = $event['e_is_public'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $recurrence = do_lang_tempcode('NA_EM'); if ($event['e_recurrence'] != 'none' && $event['e_recurrence'] != '') { $l_code = explode(' ', strtoupper($event['e_recurrence'])); $recurrence = do_lang_tempcode($l_code[0]); if (!is_null($event['e_recurrences'])) { $recurrence = do_lang_tempcode('RECURRENCE_ITERATION', $recurrence, make_string_tempcode(integer_format($event['e_recurrences']))); } } elseif ($day == '') { $day = $first_date; } $priority_lang = do_lang_tempcode('PRIORITY_' . strval($priority)); // Views if (get_db_type() != 'xml') { $event['e_views']++; $GLOBALS['SITE_DB']->query_update('calendar_events', array('e_views' => $event['e_views']), array('id' => $id), '', 1, NULL, false, true); } breadcrumb_set_parents(array(array($back_url, do_lang_tempcode('CALENDAR')))); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $event['e_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($event['e_submitter']), 'publisher' => '', 'modified' => is_null($event['e_edit_date']) ? '' : date('Y-m-d', $event['e_edit_date']), 'type' => 'Calendar event', 'title' => get_translated_text($event['e_title']), 'identifier' => '_SEARCH:calendar:view:' . strval($id), 'description' => get_translated_text($event['e_content']), 'image' => find_theme_image('bigicons/calendar')); $map = array('TITLE' => $title, '_TITLE' => get_translated_text($event['e_title']), 'ID' => strval($id), 'TAGS' => get_loaded_tags('calendar'), 'WARNING_DETAILS' => $warning_details, 'SUBMITTER' => strval($event['e_submitter']), 'ADD_DATE' => get_timezoned_date($event['e_add_date']), 'ADD_DATE_RAW' => strval($event['e_add_date']), 'EDIT_DATE_RAW' => is_null($event['e_edit_date']) ? '' : strval($event['e_edit_date']), 'VIEWS' => integer_format($event['e_views']), 'LOGO' => $event['t_logo'], 'DAY' => $day_formatted, 'TO_DAY' => $to_day_formatted, 'RECURRENCE' => $recurrence, 'IS_PUBLIC' => $is_public, 'PRIORITY' => strval($priority), 'PRIORITY_LANG' => $priority_lang, 'TYPE' => $type, 'TIME' => $time2, 'TIME_RAW' => strval($time_raw), 'TIME_VCAL' => date('Y-m-d', $time_raw) . ' ' . date('H:i:s', $time_raw), 'TO_TIME_VCAL' => is_null($to_raw) ? NULL : date('Y-m-d', $to_raw) . ' ' . date('H:i:s', $to_raw), 'EDIT_URL' => $edit_url, 'SUBSCRIPTIONS' => $_subscriptions, 'SUBSCRIBE_URL' => $subscribe_url, 'BACK_URL' => $back_url, 'CONTENT' => $content, 'SUBSCRIBED' => $subscribed, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, '_GUID' => '602e6f86f586ef0a24efed950eafd426'); if ($event['e_do_timezone_conv'] == 0) { $timezone_map = get_timezone_list(); $map['TIMEZONE'] = $timezone_map[$event['e_timezone']]; } return do_template('CALENDAR_SCREEN', $map); }
/** * Find whether a member may edit topics in a certain forum. * * @param AUTO_LINK The forum the topic would be in. * @param MEMBER The member checking access for. * @param MEMBER The member that owns this resource * @return boolean The answer. */ function ocf_may_edit_topics_by($forum_id, $member_id, $resource_owner) { if (is_null($member_id)) { $member_id = get_member(); } if (is_null($forum_id)) { return has_specific_permission($member_id, 'moderate_personal_topic'); } return has_edit_permission('mid', $member_id, $resource_owner, 'topics', array('forums', $forum_id)); }
/** * Get all pages. * * @param LANGUAGE_NAME The language we are searching for pages of * @return array The map (page name => path/time) */ function get_comcode_files_array($lang) { $zones = find_all_zones(); $out = array(); foreach ($zones as $zone) { $_out = array(); $_out = array_merge($_out, find_all_pages($zone, 'comcode/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST)); $_out = array_merge($_out, find_all_pages($zone, 'comcode_custom/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST)); if ($lang != get_site_default_lang()) { $_out = array_merge($_out, find_all_pages($zone, 'comcode/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST)); $_out = array_merge($_out, find_all_pages($zone, 'comcode_custom/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST)); } foreach ($_out as $page => $subdir) { if (is_integer($page)) { $page = strval($page); } $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $page)); if (!has_edit_permission('high', get_member(), $resource_owner, 'cms_comcode_pages')) { continue; } $out[$zone . ':' . $page] = array($zone . '/pages/' . $subdir . '/' . $page, NULL); } } return $out; }
/** * Check to see if a member's has permission to edit an item. If it doesn't, an error message is outputted. * * @param string The range of permission we are checking to see if they have; these ranges are like trust levels * @set low mid high cat_low cat_mid cat_high * @param ?MEMBER The member that owns this resource (NULL: no-one) * @param ?array A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (NULL: N/A) * @param ?ID_TEXT The ID code for the page being checked (NULL: current page) */ function check_edit_permission($range, $resource_owner, $cats = NULL, $page = NULL) { if (is_null($page)) { $page = get_page_name(); } if (!has_edit_permission($range, get_member(), $resource_owner, $page, $cats)) { access_denied('SPECIFIC_PERMISSION', 'edit_' . ($resource_owner == get_member() ? 'own_' : '') . $range . 'range_content'); } }
/** * Standard aed_module edit actualiser. * * @param ID_TEXT The entry being edited */ function edit_actualisation($_id) { $id = intval($_id); $cat = post_param('cat'); if (can_submit_to_gallery($cat) === false) { access_denied('SUBMIT_HERE'); } make_member_gallery_if_needed($cat); $this->check_images_allowed($cat); $this->handle_resizing_and_watermarking(); $validated = post_param_integer('validated', 0); $urls = get_url('url', 'file', 'uploads/galleries' . (get_value('use_gallery_subdirs') == '1' ? '/' . $cat : ''), 0, OCP_UPLOAD_IMAGE, true, 'thumb_url', 'file2'); if ($urls[0] == '') { $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url'), array('id' => $id), '', 1); $urls = $rows[0]; $url = $urls['url']; $thumb_url = $urls['thumb_url']; } else { $url = $urls[0]; $thumb_url = $urls[1]; } if (substr($urls[0], 0, 8) != 'uploads/' && $urls[0] != '' && is_null(http_download_file($urls[0], 0, false)) && !is_null($GLOBALS['HTTP_MESSAGE_B'])) { attach_message($GLOBALS['HTTP_MESSAGE_B'], 'warn'); } $comments = post_param('comments'); $allow_rating = post_param_integer('allow_rating', 0); $allow_comments = post_param_integer('allow_comments', 0); $notes = post_param('notes', ''); $allow_trackbacks = post_param_integer('allow_trackbacks', 0); $title = post_param('title'); $this->donext_type = $cat; if ($validated == 1 && $GLOBALS['SITE_DB']->query_value('images', 'validated', array('id' => $id)) == 0) { $submitter = $GLOBALS['SITE_DB']->query_value('images', 'submitter', array('id' => $id)); if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'galleries') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'galleries', $cat)) { syndicate_described_activity($submitter != get_member() ? 'galleries:ACTIVITY_VALIDATE_IMAGE' : 'galleries:ACTIVITY_ADD_IMAGE', $title == '' ? $urls[2] : $title, '', '', '_SEARCH:galleries:image:' . strval($id), '', '', 'galleries', 1, NULL); } } edit_image($id, $title, $cat, $comments, $url, $thumb_url, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, post_param('meta_keywords', ''), post_param('meta_description', '')); if (has_edit_permission('cat_mid', get_member(), get_member_id_from_gallery_name($cat), 'cms_galleries', array('galleries', $cat)) && post_param_integer('rep_image', 0) == 1) { $GLOBALS['SITE_DB']->query_update('galleries', array('rep_image' => $thumb_url), array('name' => $cat), '', 1); } }
/** * Evaluate a conventional tempcode variable, handling escaping * * @param LANGUAGE_NAME The language to evaluate this symbol in (some symbols refer to language elements) * @param array Array of escaping operations * @param integer The type of symbol this is (TC_SYMBOL, TC_LANGUAGE_REFERENCE) * @set 0 2 * @param ID_TEXT The name of the symbol * @param array Parameters to the symbol. For all but directive it is an array of strings. For directives it is an array of Tempcode objects. Actually there may be template-style parameters in here, as an influence of singular_bind and these may be Tempcode, but we ignore them. * @return mixed The result. Either tempcode, or a string. */ function ecv($lang, $escaped, $type, $name, $param) { global $TEMPCODE_SETGET, $CYCLES, $PREPROCESSABLE_SYMBOLS, $DISPLAYED_TITLE; //echo '<!--'.$name.'-->'."\n"; if ($type == TC_SYMBOL) { $escaped_codes = $name . ($escaped == array() ? '' : serialize($escaped)); $cacheable = $param == array() && !isset($GLOBALS['NON_CACHEABLE_SYMBOLS'][$name]); if ($cacheable) { global $SYMBOL_CACHE; if (isset($SYMBOL_CACHE[$escaped_codes])) { return $SYMBOL_CACHE[$escaped_codes]; } } $value = ''; if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($value); } $temp_array = array(); if (isset($PREPROCESSABLE_SYMBOLS[$name]) && $name != 'PAGE_LINK') { handle_symbol_preprocessing(array($escaped, $type, $name, $param), $temp_array); } // Late preprocessing. Should not be needed in case of full screen output (as this was properly preprocessed), but is in other cases switch ($name) { case 'PAGE_LINK': if (isset($param[0])) { list($zone, $map, $hash) = page_link_decode(is_object($param[0]) ? $param[0]->evaluate() : $param[0]); $skip = NULL; if (isset($param[4])) { $skip = array_flip(explode('|', $param[4])); } $avoid_remap = isset($param[1]) && $param[1] == '1'; $skip_keep = isset($param[2]) && $param[2] == '1'; $keep_all = isset($param[3]) && $param[3] == '1'; foreach ($map as $key => $val) { if (is_object($val)) { $map[$key] = $val->evaluate(); } } $value = _build_url($map, $zone, $skip, $keep_all, $avoid_remap, $skip_keep, $hash); } else { $value = get_zone_name() . ':' . get_page_name(); foreach ($_GET as $key => $val) { if ($key == 'page') { continue; } if (is_array($val)) { continue; } if (substr($key, 0, 5) == 'keep_' && !skippable_keep($key, $val)) { continue; } $value .= ':' . $key . '=' . $val; } } break; case 'SET': if (isset($param[1])) { if (isset($param[1]) && is_object($param[1])) { $TEMPCODE_SETGET[$param[0]] = $param[1]; } else { $param_copy = $param; unset($param_copy[0]); $TEMPCODE_SETGET[$param[0]] = implode(',', $param_copy); } } break; case 'GET': if (isset($param[0])) { if (isset($TEMPCODE_SETGET[$param[0]])) { if (is_object($TEMPCODE_SETGET[$param[0]])) { $TEMPCODE_SETGET[$param[0]] = $TEMPCODE_SETGET[$param[0]]->evaluate(); } $value = $TEMPCODE_SETGET[$param[0]]; } } break; case 'EQ': if (isset($param[1])) { $first = array_shift($param); $count = 0; foreach ($param as $test) { if ($first == $test) { $count++; break; } } $value = $count != 0 ? '1' : '0'; } break; case 'NEQ': if (isset($param[1])) { $first = array_shift($param); $count = 0; foreach ($param as $test) { if ($first == $test) { $count++; } } $value = $count == 0 ? '1' : '0'; } break; case 'NOT': if (isset($param[0])) { $value = $param[0] == '1' || $param[0] == '1' ? '0' : '1'; } break; case 'OR': $count = 0; foreach ($param as $test) { if ($test == '1' || $test == '1') { $count++; } } $value = $count > 0 ? '1' : '0'; break; case 'AND': $count = 0; foreach ($param as $test) { if ($test == '1' || $test == '1') { $count++; } } $value = $count == count($param) ? '1' : '0'; break; case 'HAS_ACTUAL_PAGE_ACCESS': if (isset($param[0])) { $value = has_actual_page_access($param !== NULL && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], isset($param[1]) ? $param[1] : NULL) ? '1' : '0'; } break; case '?': if (isset($param[1])) { $value = $param[0] == '1' || $param[0] == '1' ? $param[1] : (isset($param[2]) ? $param[2] : $value); } break; case 'IMG': if (isset($param[0]) && isset($GLOBALS['SITE_DB']) && function_exists('find_theme_image') && $GLOBALS['IN_MINIKERNEL_VERSION'] == 0) { $value = find_theme_image($param[0], isset($param[3]) && $param[3] == '1', false, array_key_exists(2, $param) && $param[2] != '' ? $param[2] : NULL, NULL, isset($param[1]) && $param[1] == '1' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']); } break; case '': break; case 'META_DATA': if (isset($param[0])) { global $META_DATA; if (isset($param[1])) { $matches = array(); if ($param[0] == 'image' && preg_match('#^' . preg_quote(find_script('attachment'), '#') . '\\?id=(\\d+)#', $param[1], $matches) != 0) { require_code('attachments'); if (!has_attachment_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), intval($matches[1]))) { break; } } $META_DATA[$param[0]] = $param[1]; } else { $value = isset($META_DATA[$param[0]]) ? strip_comcode($META_DATA[$param[0]]) : ''; if ($value === NULL) { $value = ''; } } } break; case 'SPECIAL_CLICK_TO_EDIT': $_value = do_lang_tempcode('SPECIAL_CLICK_TO_EDIT'); $value = $_value->evaluate(); break; case 'KEEP': // What needs preserving in the URL $value = keep_symbol($param); break; case 'BROWSER': if (isset($param[1])) { $q = false; foreach (explode('|', $param[0]) as $browser) { $q = browser_matches($browser); if ($q) { break; } } $value = $q ? $param[1] : (isset($param[2]) ? $param[2] : ''); if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($value); } } break; case 'JAVASCRIPT_INCLUDE': if (isset($param[0])) { require_javascript($param[0]); /*// Has to do this inline, as you're not allowed to reference scripts outside head if (!array_key_exists($param[0],$GLOBALS['JAVASCRIPTS'])) { $GLOBALS['JAVASCRIPTS'][$param[0]]=1; $file=javascript_enforce($param[0]); $_value=do_template('JAVASCRIPT_NEED_INLINE',array('_GUID'=>'d6c907e26c5a8dd8c65f1d36a1a674a9','CODE'=>file_get_contents($file,FILE_TEXT))); $value=$_value->evaluate(); }*/ } break; case 'FACILITATE_AJAX_BLOCK_CALL': if (isset($param[0])) { require_javascript('javascript_ajax'); require_code('blocks'); $_block_constraints = block_params_to_block_signature(block_params_str_to_arr($param[0])); if (array_key_exists(1, $param)) { $_block_constraints = array_merge($_block_constraints, block_params_str_to_arr($param[1])); ksort($_block_constraints); } $block_constraints = block_params_arr_to_str($_block_constraints); // Store permissions $_auth_key = $GLOBALS['SITE_DB']->query_select('temp_block_permissions', array('id', 'p_time'), array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints), '', 1); if (!array_key_exists(0, $_auth_key)) { $auth_key = $GLOBALS['SITE_DB']->query_insert('temp_block_permissions', array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints, 'p_time' => time()), true); } else { $auth_key = $_auth_key[0]['id']; if (time() - $_auth_key[0]['p_time'] > 100) { $GLOBALS['SITE_DB']->query_update('temp_block_permissions', array('p_time' => time()), array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints), '', 1); } } $keep = symbol_tempcode('KEEP'); $value = find_script('snippet') . '?snippet=block&auth_key=' . urlencode(strval($auth_key)) . '&block_map=' . urlencode($param[0]) . $keep->evaluate(); } break; case 'LANG': $value = user_lang(); break; case '_GET': if (isset($param[0])) { $value = get_param($param[0], isset($param[1]) ? $param[1] : '', true); } break; case 'QUERY_STRING': $value = ocp_srv('QUERY_STRING'); break; case 'USER_AGENT': $value = ocp_srv('HTTP_USER_AGENT'); break; case 'STRIP_TAGS': if (isset($param[0])) { if (isset($param[1]) && $param[1] == '1') { $value = strip_tags(str_replace('))', ')', str_replace('((', '(', str_replace('<em>', '(', str_replace('</em>', ')', $param[0]))))); } else { $value = strip_tags($param[0], array_key_exists(2, $param) ? $param[2] : ''); } if (isset($param[1]) && $param[1] == '1') { $value = @html_entity_decode($value, ENT_QUOTES, get_charset()); } } break; case 'CONFIG_OPTION': if (isset($param[0])) { if (!isset($GLOBALS['OPTIONS'])) { $value = '0'; } else { $value = get_option($param[0], true); if ($value === NULL) { $value = ''; } } } break; case 'TRUNCATE_LEFT': // Truncate the left length of a string. 0: text to truncate, 1: the truncate length, 2: whether to use a tooltip mouse-over if it is truncated, 3: whether it is encoded as HTML (0=no [default, plain-text], 1=yes) $value = symbol_truncator($param, 'left'); break; case 'TRUNCATE_RIGHT': $value = symbol_truncator($param, 'right'); break; case 'TRUNCATE_SPREAD': $value = symbol_truncator($param, 'spread'); break; case 'TRUNCATE_EXPAND': $value = symbol_truncator($param, 'expand'); break; case 'THEME': if (isset($GLOBALS['FORUM_DRIVER'])) { $value = $GLOBALS['FORUM_DRIVER']->get_theme(); } else { $value = 'default'; } break; case 'REVERSE': if (isset($param[0])) { $value = implode(',', array_reverse(explode(',', $param[0]))); } break; case 'COMMA_LIST_GET': if (isset($param[1])) { require_code('blocks'); $values = block_params_str_to_arr($param[0]); $value = isset($values[$param[1]]) ? $values[$param[1]] : ''; } break; case 'COMMA_LIST_SET': if (isset($param[2])) { require_code('blocks'); $values = block_params_str_to_arr($param[0]); $values[$param[1]] = $param[2]; $value = block_params_arr_to_str($values); } break; case 'IS_EMPTY': if (isset($param[0])) { $value = $param[0] == '' ? '1' : '0'; } break; case 'IS_NON_EMPTY': if (isset($param[0])) { $value = $param[0] != '' ? '1' : '0'; } break; case 'CUSTOM_BASE_URL': $value = get_custom_base_url(isset($param[0]) && $param[0] != '' ? $param[0] == '1' : NULL); if (isset($param[1]) && $param[1] == '1') { $value = cdn_filter($value); } break; case 'LOAD_PANEL': foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } global $LOADED_PANELS; if (strpos($param[0], ':') !== false) { $param = array_reverse(explode(':', $param[0], 2)); } if (substr($param[0], 0, 6) == 'panel_') { $param[0] = substr($param[0], 6); } $sr = serialize($param); $value = array_key_exists($sr, $LOADED_PANELS) ? $LOADED_PANELS[$sr] : ''; break; case 'HAS_JS': case 'JS_ON': if (isset($param[1])) { $value = has_js() ? $param[0] : $param[1]; } else { $value = has_js() ? '1' : '0'; } break; case 'BASE_URL_NOHTTP': $value = preg_replace('#^https?://[^/]+#', '', get_base_url()); if (substr($value, 0, 2) == '//') { $value = substr($value, 1); } if (!$GLOBALS['DEBUG_MODE']) { break; } // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on... // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on... case 'CUSTOM_BASE_URL_NOHTTP': $value = preg_replace('#^https?://[^/]+/#', '/', get_custom_base_url()); if (substr($value, 0, 2) == '//') { $value = substr($value, 1); } if (!$GLOBALS['DEBUG_MODE']) { break; } // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on... // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on... case 'BASE_URL': $value = get_base_url(isset($param[0]) ? $param[0] == '1' : NULL); break; case 'ZONE': $value = get_zone_name(); break; case 'PAGE': $value = get_page_name(); break; case 'SITE_NAME': $value = get_site_name(); break; case 'HEADER_TEXT': global $ZONE; $value = $ZONE['zone_header_text_trans']; break; case 'PANEL_WIDTH': if (isset($TEMPCODE_SETGET['PANEL_WIDTH']) && $TEMPCODE_SETGET['PANEL_WIDTH'] != '') { $value = $TEMPCODE_SETGET['PANEL_WIDTH']; } else { $value = get_option('panel_width', true); if ($value === NULL) { $value = '13.3em'; } } break; case 'PANEL_WIDTH_SPACED': if (isset($TEMPCODE_SETGET['PANEL_WIDTH_SPACED']) && $TEMPCODE_SETGET['PANEL_WIDTH_SPACED'] != '') { $value = $TEMPCODE_SETGET['PANEL_WIDTH_SPACED']; } else { $value = get_option('panel_width_spaced', true); if (is_null($value)) { $value = '14.3em'; } } break; case 'TRIM': if (isset($param[0])) { $value = preg_replace(array('#^\\s+#', '#^(<br\\s*/?' . '>\\s*)+#', '#^( )+#', '#\\s+$#', '#(<br\\s*/?' . '>\\s*)+$#', '#( )+$#'), array('', '', '', '', '', ''), $param[0]); } break; case 'CPF_VALUE': if (isset($param[0])) { if (is_numeric($param[0])) { require_code('ocf_members'); $fields = ocf_get_custom_fields_member(isset($param[1]) ? intval($param[1]) : get_member()); if (array_key_exists(intval($param[0]), $fields)) { $_value = $fields[intval($param[0])]; } } elseif (substr($param[0], 0, 2) == 'm_' && strpos(strtolower($param[0]), 'hash') === false && strpos(strtolower($param[0]), 'salt') === false) { $_value = $GLOBALS['FORUM_DRIVER']->get_member_row_field(isset($param[1]) ? intval($param[1]) : get_member(), $param[0]); } else { $_value = get_ocp_cpf($param[0], isset($param[1]) ? intval($param[1]) : NULL); } if (!is_string($_value)) { $value = is_null($_value) ? '' : strval($_value); } else { $value = $_value; } } break; case 'BANNER': if (addon_installed('banners')) { global $SITE_INFO; $is_on_banners = get_option('is_on_banners') == '1' && (!has_specific_permission(get_member(), 'banner_free') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) && get_option('admin_banners') == '1' || !is_null($GLOBALS['CURRENT_SHARE_USER'])); if (array_key_exists('throttle_bandwidth_registered', $SITE_INFO)) { $views_till_now = intval(get_value('page_views')); $bandwidth_allowed = $SITE_INFO['throttle_bandwidth_registered']; $total_bandwidth = intval(get_value('download_bandwidth')); if ($bandwidth_allowed * 1024 * 1024 >= $total_bandwidth) { $is_on_banners = false; } } if ($is_on_banners && !is_page_https(get_zone_name(), get_page_name())) { require_code('banners'); $b_type = isset($param[0]) ? $param[0] : ''; $internal_only = isset($param[1]) ? intval($param[1]) : ($b_type == '' ? 0 : 1); if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) { $_value = banners_script(true, '', '', $b_type, $internal_only, ''); $value = $_value->evaluate(); } else { $value = 'Banner goes here'; } } } break; case 'AVATAR': $value = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url(isset($param[0]) ? intval($param[0]) : get_member()); if (url_is_local($value) && $value != '') { $value = get_custom_base_url() . '/' . $value; } break; case 'IS_GUEST': if (isset($param[0])) { $value = is_guest(intval($param[0])) ? '1' : '0'; } else { $value = is_guest() ? '1' : '0'; } break; case 'MEMBER': $value = strval(get_member()); break; case 'USER': if (!isset($param[0])) { $value = strval(get_member()); } else { $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($param[0]); $value = is_null($member_id) ? '' : strval($member_id); } break; case 'CSS_INCLUDE': if (isset($param[0])) { require_css($param[0]); /*// Has to do this inline, as you're not allowed to reference sheets outside head if (!array_key_exists($param[0],$GLOBALS['CSSS'])) { $GLOBALS['CSSS'][$param[0]]=1; $file=css_enforce($param[0]); $_value=do_template('CSS_NEED_INLINE',array('_GUID'=>'9de994d2f6d47a622d49347feb7ebe96','CSS'=>str_replace('../../../../',get_base_url().'/',file_get_contents($file,FILE_TEXT)))); $value=$_value->evaluate(); }*/ } break; case 'USER_OVERIDE': $value = get_param('id', ''); if (!is_numeric($value) || $value == '') { $value = strval(get_member()); } break; case 'IS_HTTPAUTH_LOGIN': $value = is_httpauth_login() ? '1' : '0'; break; case 'MEMBER_PROFILE_LINK': $value = $GLOBALS['FORUM_DRIVER']->member_profile_url(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member(), false, true); if (is_null($value)) { $value = ''; } break; case 'USERNAME': $value = $GLOBALS['FORUM_DRIVER']->get_username(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member()); if (is_null($value)) { $value = do_lang('UNKNOWN'); } break; case 'CYCLE': if (isset($param[0])) { if (!isset($CYCLES[$param[0]])) { $CYCLES[$param[0]] = 0; } if (!isset($param[1])) { $value = strval($CYCLES[$param[0]]); } else { if (count($param) == 2) { $param = array_merge(array($param[0]), explode(',', $param[1])); } ++$CYCLES[$param[0]]; if (!array_key_exists($CYCLES[$param[0]], $param)) { $CYCLES[$param[0]] = 1; } $value = $param[$CYCLES[$param[0]]]; } } break; case 'THUMBNAIL': require_code('images'); $value = _symbol_thumbnail($param); break; case 'IMAGE_WIDTH': require_code('images'); list($value, ) = _symbol_image_dims($param); break; case 'IMAGE_HEIGHT': require_code('images'); list(, $value) = _symbol_image_dims($param); break; case 'IS_IN_GROUP': if (isset($param[0])) { if (in_array($param[count($param) - 1], array('', 'primary', 'secondary'))) { $last_param = $param[count($param) - 1]; unset($param[count($param) - 1]); } else { $last_param = ''; } $member_id = get_member(); $new_param = ''; $param_2 = array(); foreach ($param as $group) { if (substr($group, 0, 1) == '!' && is_numeric(substr($group, 1))) { $member_id = intval(substr($group, 1)); } else { $param_2 = array_merge($param_2, explode(',', $group)); } } foreach ($param_2 as $group) { if ($new_param != '') { $new_param .= ','; } $new_param .= $group; } if ($last_param == 'primary') { $member_row = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id); $real_group_list = array($GLOBALS['FORUM_DRIVER']->pname_group($member_row)); } elseif ($last_param == 'secondary') { $real_group_list = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id); $member_row = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id); $real_group_list = array_diff($real_group_list, array($GLOBALS['FORUM_DRIVER']->pname_group($member_row))); } else { $real_group_list = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id); } require_code('ocfiltering'); $value = count(array_intersect(ocfilter_to_idlist_using_memory($new_param, $GLOBALS['FORUM_DRIVER']->get_usergroup_list()), $real_group_list)) != 0 ? '1' : '0'; } break; case 'IS_STAFF': if (isset($GLOBALS['FORUM_DRIVER'])) { $value = $GLOBALS['FORUM_DRIVER']->is_staff(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member()) ? '1' : '0'; } else { $value = '0'; } break; case 'IS_SUPER_ADMIN': if (isset($GLOBALS['FORUM_DRIVER'])) { $value = $GLOBALS['FORUM_DRIVER']->is_super_admin(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member()) ? '1' : '0'; } else { $value = '0'; } break; case 'PHOTO': if (isset($param[0])) { $value = $GLOBALS['FORUM_DRIVER']->get_member_photo_url(intval($param[0])); if (url_is_local($value) && $value != '') { $value = get_custom_base_url() . '/' . $value; } } break; case 'OCF_RANK_IMAGE': if (addon_installed('ocf_forum')) { require_code('ocf_groups'); $rank_images = new ocp_tempcode(); $member_id = isset($param[0]) ? intval($param[0]) : get_member(); $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id, true); foreach ($posters_groups as $group) { $rank_image = ocf_get_group_property($group, 'rank_image'); $group_leader = ocf_get_group_property($group, 'group_leader'); $group_name = ocf_get_group_name($group); $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only'); if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_primary_group'))) { $rank_images->attach(do_template('OCF_RANK_IMAGE', array('USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id), 'GROUP_NAME' => $group_name, 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $member_id))); } } $value = $rank_images->evaluate(); } break; case 'TOTAL_POINTS': if (addon_installed('points')) { require_code('points'); $value = strval(total_points(isset($param[0]) ? intval($param[0]) : get_member())); } break; case 'POINTS_USED': if (addon_installed('points')) { require_code('points'); $value = strval(points_used(isset($param[0]) ? intval($param[0]) : get_member())); } break; case 'AVAILABLE_POINTS': if (addon_installed('points')) { require_code('points'); $value = strval(available_points(isset($param[0]) ? intval($param[0]) : get_member())); } break; case 'URL_FOR_GET_FORM': if (isset($param[0])) { $url_bits = parse_url($param[0]); if (array_key_exists('scheme', $url_bits)) { $value = $url_bits['scheme'] . '://' . (array_key_exists('host', $url_bits) ? $url_bits['host'] : 'localhost'); if (array_key_exists('port', $url_bits) && $url_bits['port'] != 80) { $value .= ':' . strval($url_bits['port']); } } if (array_key_exists('path', $url_bits)) { $value .= $url_bits['path']; } } break; case 'HIDDENS_FOR_GET_FORM': $_value = new ocp_tempcode(); $url_bits = parse_url($param[0]); if (array_key_exists('query', $url_bits) && $url_bits['query'] != '') { foreach (explode('&', $url_bits['query']) as $exp) { $parts = explode('=', $exp, 2); if (count($parts) == 2) { if (!in_array($parts[0], $param)) { $_value->attach(form_input_hidden($parts[0], urldecode($parts[1]))); } } } } $value = $_value->evaluate(); break; case 'NOTIFICATIONS_ENABLED': $value = ''; if (array_key_exists(0, $param)) { require_code('notifications'); $value = notifications_enabled(array_key_exists(1, $param) ? $param[1] : get_page_name(), $param[0]) ? '1' : '0'; } break; case 'DOCUMENT_HELP': global $DOCUMENT_HELP, $HELPER_PANEL_TUTORIAL; $value = $DOCUMENT_HELP; if ($value == '' && $HELPER_PANEL_TUTORIAL != '') { $value = brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/' . $HELPER_PANEL_TUTORIAL; } break; case 'HTTP_STATUS_CODE': global $HTTP_STATUS_CODE; $value = $HTTP_STATUS_CODE; break; case 'TEMPCODE': if (isset($param[0])) { require_code('tempcode_compiler'); $_value = template_to_tempcode($param[0]); $value = $_value->evaluate(); } break; case 'COMCODE': if (isset($param[0])) { $_value = comcode_to_tempcode($param[0], NULL, true); $value = $_value->evaluate(); } break; case 'FLAGRANT': $_value = get_flagrant(); $value = $_value->evaluate(); break; case 'IMG_WIDTH': case 'IMG_HEIGHT': if (isset($param[0]) && isset($GLOBALS['SITE_DB']) && function_exists('find_theme_image') && $GLOBALS['IN_MINIKERNEL_VERSION'] == 0) { global $THEME_IMG_DIMS_CACHE; if (!isset($THEME_IMG_DIMS_CACHE)) { $THEME_IMG_DIMS_CACHE = function_exists('persistant_cache_get') ? persistant_cache_get('THEME_IMG_DIMS') : array(); } if (isset($THEME_IMG_DIMS_CACHE[$param[0]])) { list($width, $height) = $THEME_IMG_DIMS_CACHE[$param[0]]; $value = $name == 'IMG_WIDTH' ? $width : $height; } else { if (strpos($param[0], '://') === false) { $img_url = find_theme_image($param[0], false, false, array_key_exists(2, $param) ? $param[2] : NULL, NULL, isset($param[1]) && $param[1] == '1' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']); } else { $img_url = $param[0]; } require_code('images'); list($width, $height) = _symbol_image_dims(array($img_url)); $value = $name == 'IMG_WIDTH' ? $width : $height; $THEME_IMG_DIMS_CACHE[$param[0]] = array($width, $height); if (function_exists('persistant_cache_set')) { persistant_cache_set('THEME_IMG_DIMS', $THEME_IMG_DIMS_CACHE); } } } break; case 'CLEAN_FILE_SIZE': if (isset($param[0])) { $bytes = is_numeric($param[0]) ? intval($param[0]) : NULL; require_code('files'); $value = clean_file_size($bytes); } break; case 'TIME_PERIOD': if (isset($param[0])) { $value = display_time_period(intval($param[0])); } break; case 'MAKE_RELATIVE_DATE': if (isset($param[0])) { if (get_option('use_contextual_dates') == '0' && (!array_key_exists(1, $param) || $param[1] != '1')) { $value = get_timezoned_date(intval($param[0])); } else { $value = display_time_period(time() - intval($param[0])); } } break; case 'TIMEZONE': $value = make_nice_timezone_name(get_site_timezone()); break; case 'LOAD_PAGE': foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } global $LOADED_PAGES; if (strpos($param[0], ':') !== false) { $param = array_reverse(explode(':', $param[0], 2)); } $_value = $LOADED_PAGES[serialize($param)]; $value = $_value->evaluate(); break; case 'RUNNING_SCRIPT': if (isset($param[0])) { $value = running_script($param[0]) ? '1' : '0'; } break; case 'MATCH_KEY_MATCH': $value = '0'; foreach ($param as $match_key) { if ($match_key == '1' || $match_key == '0' || $match_key == '') { continue; } if (match_key_match($match_key, isset($param[1]) && $match_key == '1')) { $value = '1'; } } break; case 'VERSION': $value = strval(ocp_version()); break; case 'PREVIEW_VALIDATION': $value = get_option('is_on_preview_validation') == '1' ? '1' : '0'; break; case 'BLOCK': if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) { foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } if (count($param) == 1 && strpos($param[0], ',') !== false) { $param = preg_split('#((?<!\\\\)|(?<=\\\\\\\\)|(?<=^)),#', $param[0]); foreach ($param as $key => $val) { $param[$key] = str_replace('\\,', ',', $val); } } global $LOADED_BLOCKS; if (isset($LOADED_BLOCKS[serialize($param)])) { // Will always be set $value = $LOADED_BLOCKS[serialize($param)]->evaluate(); } } break; case 'CURRENCY': if (addon_installed('ecommerce')) { if (isset($param[0])) { require_code('currency'); $value = currency_convert(floatval(str_replace(',', '', $param[0])), isset($param[1]) && $param[1] != '' ? $param[1] : get_option('currency'), isset($param[2]) && $param[2] != '' ? $param[2] : NULL, isset($param[3]) && $param[3] == '1'); if (is_null($value)) { $value = do_lang('INTERNAL_ERROR'); } } else { $value = get_option('currency'); } } break; case 'CURRENCY_SYMBOL': if (addon_installed('ecommerce')) { require_code('ecommerce'); $value = ecommerce_get_currency_symbol(); } break; case 'GEOLOCATE': $value = geolocate_ip(isset($param[0]) ? $param[0] : NULL); break; case 'NO_SAFE_MODE': $value = str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1' ? '0' : '1'; break; case 'FORCE_PREVIEWS': if (get_option('forced_preview_option') == '1') { if (get_forum_type() == 'ocf') { if (is_guest() && get_option('default_preview_guests') == '0') { $value = '0'; } else { $value = $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_preview_posts') == 1 ? '1' : '0'; } } else { $value = get_option('default_preview_guests') == '0' ? '0' : '1'; } } else { $value = '0'; } break; case 'PREVIEW_URL': $value = find_script('preview'); $value .= '?page=' . get_page_name(); $value .= '&type=' . get_param('type', '', true); break; case 'ADDON_INSTALLED': if (isset($param[0]) && !running_script('install')) { $value = addon_installed($param[0]) ? '1' : '0'; } break; case 'VALUE_OPTION': if (isset($param[0])) { $value = function_exists('get_value') ? get_value($param[0]) : ''; if (is_null($value)) { $value = function_exists('get_long_value') ? get_long_value($param[0]) : ''; if (is_null($value)) { $value = isset($param[1]) ? $param[1] : ''; if ($param[0] == 'textmate' && (ocp_srv('HTTP_HOST') == 'localhost' && strpos(ocp_srv('HTTP_USER_AGENT'), 'Macintosh') !== false)) { $value = '1'; } } } } break; case 'KEEP_INDEX': // What needs preserving in the URL $value = 'index.php'; if (count($_GET) > 0) { foreach ($_GET as $key => $val) { if (is_array($val)) { continue; } if (get_magic_quotes_gpc()) { $val = stripslashes($val); } if (substr($key, 0, 5) == 'keep_' && !skippable_keep($key, $val) && strpos($key, '_expand_') === false) { $value .= ($value == 'index.php' ? '?' : '&') . urlencode($key) . '=' . ocp_url_encode($val); } } } break; case 'HIDE_HELP_PANEL': $value = array_key_exists('hide_help_panel', $_COOKIE) && $_COOKIE['hide_help_panel'] == '1' ? '1' : '0'; break; case 'URLISE_LANG': if (isset($param[1])) { $_value = urlise_lang($param[0], $param[1], isset($param[2]) ? $param[2] : '', isset($param[3]) ? $param[3] == '1' : false); $value = $_value->evaluate(); } break; case 'FIND_SCRIPT_NOHTTP': if (isset($param[0]) && function_exists('find_script')) { $value = preg_replace('#^https?://[^/]+#', '', find_script($param[0], false, isset($param[1]) ? intval($param[1]) : 0)); } if (!$GLOBALS['DEBUG_MODE']) { break; } // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on... // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on... case 'FIND_SCRIPT': if (isset($param[0]) && function_exists('find_script')) { $value = find_script($param[0], false, isset($param[1]) ? intval($param[1]) : 0); } break; case 'MOBILE': $value = is_mobile(NULL, array_key_exists(0, $param) ? $param[0] == '1' : false) ? '1' : '0'; break; case 'VALID_FILE_TYPES': $value = get_option('valid_types'); $types = array_flip(explode(',', $value)); $value = ''; ksort($types); foreach (array_flip($types) as $val) { $value .= $val . ','; } $value = substr($value, 0, strlen($value) - 1); break; case 'BROWSER_UA': $browser = get_browser_string(); $value = $browser; break; case 'OS': $os = get_os_string(); if (is_null($os)) { $os = ''; } $value = $os; break; case 'ANCHOR': if (isset($param[0])) { $_value = do_template('ANCHOR', array('_GUID' => '8795c70c9dd7c6217bb765264ac24092', 'NAME' => $param[0])); $value = $_value->evaluate(); } break; case 'CSS_TEMPCODE': $_value = css_tempcode(); $value = $_value->evaluate(); break; case 'JS_TEMPCODE': $_value = javascript_tempcode(isset($param[0]) ? $param[0] : NULL); $value = $_value->evaluate(); break; case 'PAD_LEFT': if (array_key_exists(1, $param)) { $value = str_pad($param[0], intval($param[1]), array_key_exists(2, $param) ? $param[2] : '', STR_PAD_LEFT); } break; case 'PAD_RIGHT': if (array_key_exists(1, $param)) { $value = str_pad($param[0], intval($param[1]), array_key_exists(2, $param) ? $param[2] : '', STR_PAD_RIGHT); } break; case 'PAGE_TITLE': $value = is_null($DISPLAYED_TITLE) ? '' : $DISPLAYED_TITLE->evaluate(); break; case 'SET_TITLE': if (array_key_exists(0, $param)) { get_page_title($param[0], false); } break; case 'EXTRA_HEAD': $_value = $GLOBALS['EXTRA_HEAD']; if ($_value === NULL) { $_value = new ocp_tempcode(); } $value = $_value->evaluate(); break; case 'EXTRA_FOOT': if ($GLOBALS['EXTRA_FOOT'] === NULL) { $GLOBALS['EXTRA_FOOT'] = new ocp_tempcode(); } $_value = $GLOBALS['EXTRA_FOOT']; if (array_key_exists(0, $param)) { $GLOBALS['EXTRA_FOOT']->attach($param[0]); } else { $value = $_value->evaluate(); } break; case 'RAND': if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['RAND'])) { $GLOBALS['NO_EVAL_CACHE'] = true; $value = strval(mt_rand(0, 32000)); } else { $value = '4'; } break; case 'SET_RAND': if (isset($param[0])) { if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) { $GLOBALS['NO_EVAL_CACHE'] = true; $value = $param[mt_rand(0, count($param) - 1)]; } else { $value = $param[0]; } } break; case 'COPYRIGHT': $value = str_replace('$CURRENT_YEAR', date('Y'), get_option('copyright')); break; case 'KEYWORDS_SPACED': $value = str_replace(',', ' ', get_option('keywords')); break; case 'STAFF_ADDRESS_PURE': $value = get_option('staff_address'); break; case 'STAFF_ADDRESS': require_code('obfuscate'); $value = obfuscate_email_address(get_option('staff_address')); break; case 'DOMAIN': $value = get_domain(); break; case 'BRAND_NAME': $value = function_exists('get_value') ? get_value('rebrand_name') : NULL; if (is_null($value)) { $value = 'ocPortal'; } break; case 'BRAND_BASE_URL': $value = brand_base_url(); break; case 'SHOW_DOCS': $value = get_option('show_docs') === '0' ? '0' : '1'; break; case 'MEMBER_EMAIL': $value = $GLOBALS['FORUM_DRIVER']->get_member_email_address(isset($param[0]) ? intval($param[0]) : get_member()); break; case 'OCF_MEMBER_HTML': if (get_forum_type() == 'ocf') { require_code('ocf_members'); require_code('ocf_members2'); $_value = ocf_show_member_box(isset($param[0]) ? intval($param[0]) : get_member()); $value = $_value->evaluate(); } break; case 'HAS_SPECIFIC_PERMISSION': if (isset($param[0])) { $value = has_specific_permission(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0'; } break; case 'HAS_ZONE_ACCESS': if (isset($param[0])) { $value = has_zone_access(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0'; } break; case 'HAS_PAGE_ACCESS': if (isset($param[0]) && isset($param[1])) { $value = has_page_access(!is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], $param[1], !is_null($param) && isset($param[3]) ? $param[3] == '1' : false) ? '1' : '0'; } break; case 'HAS_CATEGORY_ACCESS': if (isset($param[0])) { $value = has_category_access(!is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], $param[1]) ? '1' : '0'; } break; case 'HAS_ATTACHMENT_ACCESS': if (isset($param[0])) { require_code('attachments'); $value = has_attachment_access(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0'; } break; case 'HAS_SUBMIT_PERMISSION': if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high')) { $value = has_submit_permission(strtolower($param[0]), !is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), !is_null($param) && isset($param[2]) ? $param[2] : get_ip_address(), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0'; } break; case 'HAS_DELETE_PERMISSION': if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high') && isset($param[1])) { $value = has_delete_permission(strtolower($param[0]), !is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), intval($param[1]), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0'; } break; case 'HAS_EDIT_PERMISSION': if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high') && isset($param[1])) { $value = has_edit_permission(strtolower($param[0]), !is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), intval($param[1]), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0'; } break; case 'ENTITY_DECODE': if (isset($param[0])) { $value = @html_entity_decode($param[0], ENT_QUOTES, get_charset()); } break; case 'RESET_CYCLE': if (isset($param[0])) { $CYCLES[$param[0]] = 0; } break; case 'SITE_SCOPE': $value = get_option('site_scope'); break; case 'LAST_VISIT_TIME': if (get_forum_type() == 'ocf') { $member_info = ocf_read_in_member_profile(get_member(), true); $value = strval($member_info['last_visit_time']); } break; case 'NUM_NEW_TOPICS': if (get_forum_type() == 'ocf') { $member_info = ocf_read_in_member_profile(get_member(), true); $_new_topics = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE NOT t_forum_id IS NULL AND t_cache_first_time>' . strval((int) $member_info['last_visit_time'])); $new_topics = $_new_topics[0]['mycnt']; $value = strval($new_topics); } break; case 'NUM_NEW_POSTS': if (get_forum_type() == 'ocf') { $member_info = ocf_read_in_member_profile(get_member(), true); $_new_posts = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE NOT p_cache_forum_id IS NULL AND p_time>' . strval((int) $member_info['last_visit_time'])); $new_posts = $_new_posts[0]['mycnt']; $value = strval($new_posts); } break; case 'HAS_FORUM': $value = has_no_forum() ? '0' : '1'; break; case 'OCF': $value = get_forum_type() == 'ocf' ? '1' : '0'; break; case 'BOARD_PREFIX': $value = get_forum_base_url(); break; case 'DATE_AND_TIME': $use_contextual_dates = isset($param[0]) && $param[0] == '1'; $verbose = isset($param[1]) && $param[1] == '1'; $server_time = isset($param[2]) && $param[2] == '1'; $time = isset($param[3]) ? intval($param[3]) : time(); $value = get_timezoned_date($time, true, $verbose, $server_time, !$use_contextual_dates); break; case 'DATE': $use_contextual_dates = isset($param[0]) && $param[0] == '1'; $verbose = isset($param[1]) && $param[1] == '1'; $server_time = isset($param[2]) && $param[2] == '1'; $time = isset($param[3]) ? intval($param[3]) : time(); $value = get_timezoned_date($time, false, $verbose, $server_time, !$use_contextual_dates); break; case 'TIME': $time = isset($param[0]) ? intval($param[0]) : time(); $value = get_timezoned_time($time); break; case 'SECONDS_PERIOD': if (array_key_exists(0, $param)) { $value = display_seconds_period(intval($param[0])); } break; case 'FROM_TIMESTAMP': if (isset($param[0])) { $timestamp = isset($param[1]) ? intval($param[1]) : time(); if (!array_key_exists(2, $param) || $param[2] == '1') { $timestamp = utctime_to_usertime($timestamp); } $value = locale_filter(my_strftime($param[0], $timestamp)); if ($value == $param[0]) { // If no conversion happened then the syntax must have been for 'date' not 'strftime' $value = date($param[0], $timestamp); } } else { $timestamp = time(); $value = strval($timestamp); } break; case 'TO_TIMESTAMP': if (isset($param[0])) { $value = strval(strtotime($param[0])); if (array_key_exists(1, $param) && $param[1] == '1') { $value = strval(usertime_to_utctime(intval($value))); } // '1' means date was in user-time so needs converting to a UTC timestamp } else { $value = strval(time()); } break; case 'SESSION_HASHED': $value = md5(strval(get_session_id())); break; case 'SESSION': $value = strval(get_session_id()); break; case 'IN_ARRAY': if (isset($param[1])) { $array = array_slice($param, 1); $value = in_array($param[0], $array) ? '1' : '0'; } break; case 'MULT': if (isset($param[1])) { $value = float_to_raw_string(floatval($param[0]) * floatval($param[1]), 2, true); } break; case 'ROUND': if (isset($param[0])) { $amount = isset($param[1]) ? intval($param[1]) : 0; if ($amount > 0) { $value = float_format(floatval($param[0]), $amount); } else { $value = strval(intval(round(floatval($param[0]), $amount))); } } break; case 'DEV_MODE': $value = $GLOBALS['DEBUG_MODE'] ? '1' : '0'; break; case 'BROWSER_MATCHES': if (isset($param[0])) { $q = false; foreach (explode('|', $param[0]) as $browser) { $q = browser_matches($browser); if ($q) { break; } } $value = $q ? '1' : '0'; } break; case 'ISSET': if (isset($param[0])) { $value = isset($TEMPCODE_SETGET[$param[0]]) ? '1' : '0'; } break; case 'INIT': if (isset($param[1])) { if (!isset($TEMPCODE_SETGET[$param[0]])) { $TEMPCODE_SETGET[$param[0]] = $param[1]; } } break; case 'INC': if (isset($param[0])) { if (!isset($TEMPCODE_SETGET[$param[0]])) { $TEMPCODE_SETGET[$param[0]] = '0'; } $TEMPCODE_SETGET[$param[0]] = strval(intval($TEMPCODE_SETGET[$param[0]]) + 1); } break; case 'DEC': if (isset($param[0])) { if (!isset($TEMPCODE_SETGET[$param[0]])) { $TEMPCODE_SETGET[$param[0]] = '0'; } $TEMPCODE_SETGET[$param[0]] = strval(intval($TEMPCODE_SETGET[$param[0]]) - 1); } break; case 'PREG_MATCH': if (isset($param[1])) { $value = preg_match('#' . str_replace('#', '\\#', $param[0]) . '#' . (isset($param[2]) ? str_replace('e', '', $param[2]) : ''), $param[1]) != 0 ? '1' : '0'; } break; case 'PREG_REPLACE': if (isset($param[2])) { $value = preg_replace('#' . str_replace('#', '\\#', $param[0]) . '#' . (isset($param[3]) ? str_replace('e', '', $param[3]) : ''), $param[1], $param[2]); } break; case 'MAX': if (isset($param[0])) { $value = strval(max(intval($param[0]), intval($param[1]))); } break; case 'MIN': if (isset($param[0])) { $value = strval(min(intval($param[0]), intval($param[1]))); } break; case 'MOD': if (isset($param[0])) { $value = strval(max(intval($param[0]), -intval($param[0]))); } break; case 'REM': if (isset($param[1])) { $value = strval(intval($param[0]) % intval($param[1])); } break; case 'DIV_FLOAT': if (isset($param[1])) { $value = float_to_raw_string(floatval($param[0]) / floatval($param[1]), 2, true); } break; case 'DIV': if (isset($param[1])) { $value = strval(intval(floor(floatval($param[0]) / floatval($param[1])))); } break; case 'SUBTRACT': if (isset($param[1])) { $value = float_to_raw_string(floatval(str_replace(',', '', $param[0])) - floatval(str_replace(',', '', $param[1])), 2, true); } break; case 'ADD': if (isset($param[1])) { $value = float_to_raw_string(floatval(str_replace(',', '', $param[0])) + floatval(str_replace(',', '', $param[1])), 2, true); } break; case 'WCASE': if (isset($param[0])) { $value = ucwords($param[0]); } break; case 'LCASE': if (isset($param[0])) { $value = ocp_mb_strtolower($param[0]); } break; case 'UCASE': if (isset($param[0])) { $value = ocp_mb_strtoupper($param[0]); } break; case '_POST': if (isset($param[0])) { $value = post_param($param[0], isset($param[1]) ? $param[1] : ''); } break; case 'REPLACE': if (isset($param[2])) { $value = str_replace($param[0], $param[1], $param[2]); if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) { ocp_mark_as_escaped($value); } } break; case 'AT': if (isset($param[1])) { $value = ocp_mb_substr($param[0], intval($param[1]), 1); } break; case 'STRPOS': if (isset($param[1])) { $t_value = strpos($param[0], $param[1]); $value = $t_value === false ? '0' : strval($t_value); } break; case 'IN_STR': if (isset($param[1])) { if ($param[1] == '') { $value = '0'; } else { $value = '0'; foreach ($param as $i => $check) { if (is_integer($i) && $i != 0 && $check != '') { if (strpos($param[0], $check) !== false) { $value = '1'; break; } } } } } break; case 'SUBSTR_COUNT': if (isset($param[1])) { $value = strval(substr_count($param[0], $param[1])); } break; case 'SUBSTR': if (isset($param[1])) { $value = ocp_mb_substr($param[0], intval($param[1]), isset($param[2]) ? intval($param[2]) : strlen($param[0])); } break; case 'LENGTH': if (isset($param[0])) { $value = strval(ocp_mb_strlen($param[0])); } break; case 'WORDWRAP': if (isset($param[1])) { $cut = isset($param[3]) && $param[3] == '1'; $value = wordwrap($param[0], intval($param[1]), isset($param[2]) ? $param[2] : '<br />', $cut); if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) { ocp_mark_as_escaped($value); } } break; case 'ALTERNATOR_TRUNCATED': // Alternate values according to whether some given text WOULD have been truncated. 0: text to check against, 1: the truncate length, 2:IF would not be do this, 3: if it would be do this, 4: whether given text is encoded as HTML (0=no [default, plain-text], 1=yes) if (isset($param[3])) { $amount = intval($param[1]); $is_html = isset($param[4]) && $param[4] == '1'; if (strlen($is_html ? strip_tags($param[0]) : $param[0]) > $amount) { $value = $param[3]; } else { $value = $param[2]; } } break; case 'ESCAPE': if (isset($param[0])) { $d_escaping = array(isset($param[1]) ? constant($param[1]) : ENTITY_ESCAPED); if (is_string($param[0])) { apply_tempcode_escaping($d_escaping, $param[0]); } $value = $param[0]; } break; case 'COOKIE_PATH': $value = function_exists('get_cookie_path') ? get_cookie_path() : '/'; break; case 'COOKIE_DOMAIN': $s_value = function_exists('get_cookie_domain') ? get_cookie_domain() : ''; $value = is_null($s_value) ? '' : $s_value; break; case 'IS_A_COOKIE_LOGIN': global $IS_A_COOKIE_LOGIN; $value = $IS_A_COOKIE_LOGIN && ini_get('suhosin.cookie.max_name_length') !== '64' ? '1' : '0'; break; case 'GROUP_ID': if (isset($param[0])) { $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(isset($param[1]) ? intval($param[1]) : get_member()); $value = array_key_exists(intval($param[0]), $groups) ? strval($groups[intval($param[0])]) : ''; } break; case 'GROUP_NAME': if (isset($param[0])) { $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(isset($param[1]) ? intval($param[1]) : get_member()); if (array_key_exists(intval($param[0]), $groups)) { $all_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); $value = $all_usergroups[$groups[intval($param[0])]]; } if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) { ocp_mark_as_escaped($value); } } break; case 'NEGATE': if (isset($param[0])) { $value = strval(-intval($param[0])); } break; case 'XOR': $count = 0; foreach ($param as $test) { if ($test == '1' || $test == '1') { $count++; } } $value = $count == 1 ? '1' : '0'; break; case 'NOR': $count = 0; foreach ($param as $test) { if ($test == '1' || $test == '1') { $count++; } } $value = $count > 0 ? '0' : '1'; break; case 'NAND': $count = 0; foreach ($param as $test) { if ($test == '1' || $test == '1') { $count++; } } $value = $count == count($param) ? '0' : '1'; break; case 'LT': if (isset($param[1])) { $value = intval($param[0]) < intval($param[1]) ? '1' : '0'; } break; case 'GT': if (isset($param[1])) { $value = intval($param[0]) > intval($param[1]) ? '1' : '0'; } break; case 'COPPA_ON': $value = get_option('is_on_coppa') == '1' ? '1' : '0'; break; case 'OBFUSCATE': if (isset($param[0])) { require_code('obfuscate'); $value = obfuscate_entities($param[0]); } break; case 'FIX_ID': if (isset($param[0])) { $value = fix_id($param[0]); if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($value); } } break; case 'MAILTO': require_code('obfuscate'); $value = mailto_obfuscated(); break; case 'INLINE_STATS': $value = get_option('show_inline_stats') == '1' ? '1' : '0'; break; case 'ATTACHMENT_DOWNLOADS': if (isset($param[0])) { $db = $GLOBALS['SITE_DB']; if (isset($param[1]) && $param[1] == '1') { $db = $GLOBALS['FORUM_DB']; } $_value = $db->query_value_null_ok('attachments', 'a_num_downloads', array('id' => intval($param[0]))); $value = is_null($_value) ? '?' : strval($_value); } break; case 'CSS_DIMENSION_REDUCE': if (isset($param[1])) { $value = $param[0]; if (substr($value, -2) == 'px') { $b = $param[1]; $value = strval(intval(substr($value, 0, -2)) - intval($b)) . 'px'; } if ($value == '') { $value = '0px'; } } break; case 'COMMENT_COUNT': if (isset($param[1])) { if (get_option('is_on_comments') == '1') { $count = 0; $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier(get_option('comments_forum_name'), $param[0] . '_' . $param[1]), $count, 0, 0, false); $_value = do_lang_tempcode('_COMMENTS', integer_format(0)); if (is_array($_comments)) { $_value = do_lang_tempcode('_COMMENTS', escape_html(integer_format($count))); } $value = $_value->evaluate(); } else { $value = do_lang('VIEW'); } } break; case 'CAN_SPELLCHECK': $value = function_exists('pspell_check') ? '1' : '0'; break; case 'AWARD_ID': if (array_key_exists(0, $param)) { $value = $GLOBALS['SITE_DB']->query_value_null_ok('award_archive', 'content_id', array('a_type_id' => intval($param[0])), 'ORDER BY date_and_time DESC'); if (is_null($value)) { $value = ''; } } break; case 'SELF_PAGE_LINK': $value = ''; if (running_script('index') || running_script('iframe')) { $value = get_zone_name() . ':' . get_page_name(); foreach ($_GET as $key => $val) { if ($key == 'page') { continue; } if (is_array($val)) { continue; } if (substr($key, 0, 5) == 'keep_') { continue; } $value .= ':' . $key . '=' . $val; } } break; case 'SET_TUTORIAL_LINK': $value = ''; if (array_key_exists(1, $param) && $param[1] != '' && $param[1][0] != '#') { set_tutorial_link($param[0], $param[1]); } break; case 'DISPLAY_CONCEPT': $value = ''; if (array_key_exists(0, $param)) { $key = $param[0]; $page_link = get_tutorial_link('concept___' . preg_replace('#[^\\w_]#', '_', $key)); if (is_null($page_link)) { $temp_tpl = make_string_tempcode($key); } else { list($zone, $attributes, $hash) = page_link_decode($page_link); $_url = build_url($attributes, $zone, NULL, false, false, false, $hash); $temp_tpl = do_template('COMCODE_CONCEPT', array('_GUID' => 'ee0cd05f87329923f05145180004d8a8', 'TEXT' => $key, 'URL' => $_url)); } $value = $temp_tpl->evaluate(); } break; case 'SELF_URL': $extra_params = NULL; if (isset($param[3])) { $extra_params = array(); $i = 3; while (isset($param[$i])) { $bits = explode('=', $param[$i], 2); if ($bits[1] == '<null>') { $bits[1] = NULL; } $extra_params[$bits[0]] = $bits[1]; $i++; } } $value = get_self_url(true, isset($param[0]) && $param[0] == '1', $extra_params, isset($param[1]) && $param[1] == '1', isset($param[2]) && $param[2] == '1'); break; case 'SHIFT_DECODE': if (isset($param[0])) { global $SHIFT_VARIABLES; $key = $param[0]; $value = isset($SHIFT_VARIABLES[$key]) ? $SHIFT_VARIABLES[$key]->evaluate() : ''; } break; case 'NUMBER_FORMAT': if (isset($param[0])) { $value = integer_format(intval($param[0])); } break; case 'FLOAT_FORMAT': if (isset($param[0])) { $value = float_format(floatval($param[0])); } break; case 'CURRENTLY_INVISIBLE': $value = is_invisible() ? '1' : '0'; break; case 'IS_FRIEND': if (isset($param[0])) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('chat_buddies', 'member_likes', array('member_likes' => isset($param[1]) ? intval($param[1]) : get_member(), 'member_liked' => intval($param[0]))); $value = is_null($test) ? '0' : '1'; } break; case 'SSW': $value = get_option('ssw') == '1' ? '1' : '0'; break; case 'RATING': if (isset($param[1])) { require_code('feedback'); $rating = get_rating_simple_array(array_key_exists(3, $param) ? $param[3] : get_self_url(true), array_key_exists(4, $param) ? $param[4] : (is_null($DISPLAYED_TITLE) ? '' : $DISPLAYED_TITLE->evaluate()), $param[0], $param[1], array_key_exists(5, $param) ? $param[5] : 'RATING_FORM', array_key_exists(2, $param) ? $param[2] : NULL); if ($rating !== NULL) { if (!array_key_exists(2, $param) || $param[2] == '0') { $value = isset($rating['ALL_RATING_CRITERIA'][0]['RATING']) ? $rating['ALL_RATING_CRITERIA'][0]['RATING'] : ''; } else { $value = do_template('RATING_INLINE_STATIC', $rating); } if (is_object($value)) { $value = $value->evaluate(); } } } break; case 'VIEWS': if (isset($param[2])) { $id_field = 'id'; // Not allowed for security reasons if (preg_match('#^\\w*views\\w*$#', $param[1]) != 0) { $test = $GLOBALS['SITE_DB']->query_value_null_ok($param[0], $param[1], array($id_field => $param[2])); if (!is_null($test)) { $value = integer_format($test); } } } break; default: global $EXTRA_SYMBOLS; if (is_null($EXTRA_SYMBOLS)) { $EXTRA_SYMBOLS = array(); $hooks = find_all_hooks('systems', 'symbols'); foreach (array_keys($hooks) as $hook) { $EXTRA_SYMBOLS[$hook] = array(); } } if (array_key_exists($name, $EXTRA_SYMBOLS)) { if (!array_key_exists('ob', $EXTRA_SYMBOLS[$name])) { require_code('hooks/systems/symbols/' . filter_naughty_harsh($name)); $EXTRA_SYMBOLS[$name]['ob'] = object_factory('Hook_symbol_' . filter_naughty_harsh($name)); } $value = $EXTRA_SYMBOLS[$name]['ob']->run($param); break; } if (defined($name)) { $value = @strval(constant($name)); break; } $value = ''; require_code('site'); attach_message(do_lang_tempcode('MISSING_SYMBOL', escape_html($name)), 'warn'); } if ($escaped != array()) { if (is_object($value)) { $value = $value->evaluate(); } apply_tempcode_escaping($escaped, $value); } if ($cacheable) { $SYMBOL_CACHE[$escaped_codes] = $value; } return $value; } // Is it a directive? if ($type == TC_DIRECTIVE) { $value = ''; if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($value); } // In our param we should have a map of bubbled template parameters (under 'vars') and our numbered directive parameters if ($param === NULL) { $param = array(); } // Closure-based Tempcode parser may send in strings, so we need to adapt... foreach ($param as $key => $val) { if (is_string($val)) { $param[$key] = make_string_tempcode($val); } } if (!isset($param['vars'])) { $param['vars'] = array(); } switch ($name) { case 'SHIFT_ENCODE': break; case 'PARAM_INFO': $_value = do_template('PARAM_INFO', array('MAP' => $param['vars'])); $value = $_value->evaluate(); break; case 'CSS_INHERIT': // e.g. {+START,CSS_INHERIT,global,default,#886aa9}{+END} if (isset($param[0])) { require_code('css_and_js'); $css_file = $param[0]->evaluate(); $theme = isset($param[1]) ? $param[1]->evaluate() : 'default'; $seed = isset($param[2]) ? $param[2]->evaluate() : NULL; if ($seed == '') { $seed = NULL; } $dark = isset($param[3]) ? $param[3]->evaluate() == '1' : false; $algorithm = isset($param[4]) ? $param[4]->evaluate() : 'equations'; $value = css_inherit($css_file, $theme, $GLOBALS['FORUM_DRIVER']->get_theme(), $seed, $dark, $algorithm); } break; case 'FRACTIONAL_EDITABLE': foreach (array_keys($param) as $key) { if (!is_numeric($key)) { unset($param[$key]); } } if (isset($param[3])) { $edit_text = $param[0]->evaluate(); $edit_param_name = $param[1]->evaluate(); $edit_pagelink = $param[2]->evaluate(); $supports_comcode = (isset($param[4]) ? $param[3]->evaluate() : '0') == '1'; list($zone, $attributes, ) = page_link_decode($edit_pagelink); if ($zone == '_SEARCH') { $zone = get_module_zone($attributes['page']); } if (has_actual_page_access(get_member(), $attributes['page'], $zone) && has_zone_access(get_member(), 'adminzone')) { $keep = symbol_tempcode('KEEP'); $url = find_script('fractional_edit') . '?edit_param_name=' . urlencode($edit_param_name) . '&supports_comcode=' . ($supports_comcode ? '1' : '0') . '&zone=' . urlencode($zone) . $keep->evaluate(); foreach ($attributes as $key => $val) { $url .= '&' . $key . '=' . urlencode($val); } $_value = $param[count($param) - 1]; $_value = do_template('FRACTIONAL_EDIT', array('_GUID' => '075ac126c427d28b309004bc67b32b08', 'VALUE' => $_value, 'URL' => $url, 'EDIT_TEXT' => $edit_text, 'EDIT_PARAM_NAME' => $edit_param_name)); $value = $_value->evaluate(); } else { $value = $param[count($param) - 1]->evaluate(); } } break; case 'SET': if (isset($param[1])) { $var = $param[0]->evaluate(); $set_val = ''; $i = 1; while (isset($param[$i])) { if ($i != 1) { $set_val .= ','; } $set_val .= $param[1]->evaluate(); $i++; } $TEMPCODE_SETGET[$var] = $set_val; } break; case 'IN_ARRAY': if (isset($param[1])) { $key = $param[1]->evaluate(); $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array(); $value = in_array($param[0]->evaluate(), $array) ? '1' : '0'; } break; case 'NOT_IN_ARRAY': if (isset($param[1])) { $key = $param[1]->evaluate(); $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array(); $value = in_array($param[0]->evaluate(), $array) ? '0' : '1'; } break; case 'IF_IN_ARRAY': if (isset($param[2])) { $key = $param[1]->evaluate(); $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array(); $value = in_array($param[0]->evaluate(), $array) ? $param[2]->evaluate() : ''; } break; case 'IF_NOT_IN_ARRAY': if (isset($param[2])) { $key = $param[1]->evaluate(); $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array(); $value = in_array($param[0]->evaluate(), $array) ? '' : $param[2]->evaluate(); } break; case 'IMPLODE': if (isset($param[1])) { $key = $param[1]->evaluate(); $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array(); if (isset($param[2]) && $param[2]->evaluate() == '1') { $delim = $param[0]->evaluate(); foreach ($array as $key => $val) { if ($value != '') { $value .= $delim; } $value .= (is_integer($key) ? integer_format($key) : $key) . ' = ' . $val; } } else { $value = implode($param[0]->evaluate(), $array); } } break; case 'COUNT': if (isset($param[0])) { $key = $param[0]->evaluate(); $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array(); $value = strval(count($array)); } break; case 'BOX': unset($param['vars']); $title = isset($param[1]) ? $param[0]->evaluate() : ''; $dimensions = isset($param[2]) ? $param[1]->evaluate() : '100%'; if ($dimensions == '') { $dimensions = '100%'; } $box_type = isset($param[3]) ? $param[2]->evaluate() : 'classic'; $options = isset($param[4]) ? $param[3]->evaluate() : ''; $meta = isset($param[5]) ? $param[4]->evaluate() : ''; $links = isset($param[6]) ? $param[5]->evaluate() : ''; $expand = isset($param[7]) ? $param[6]->evaluate() == '1' : false; $toplink = isset($param[8]) ? $param[7]->evaluate() : ''; $tmp = put_in_standard_box(array_pop($param), $title, $dimensions, $box_type, $options, $meta, $links, $expand, $toplink); $value = $tmp->evaluate(); break; case 'IF_NON_EMPTY': if (isset($param[1])) { if (!$param[0]->is_really_empty()) { $value = $param[1]->evaluate(); } } break; case 'IF_PASSED': if (isset($param[1])) { $t = $param[0]->evaluate(); if (isset($param['vars'][$t])) { $value = $param[1]->evaluate(); } } break; case 'IF_NON_PASSED': if (isset($param[1])) { $t = $param[0]->evaluate(); if (!isset($param['vars'][$t])) { $value = $param[1]->evaluate(); } } break; case 'IF_EMPTY': if (isset($param[1])) { if ($param[0]->is_really_empty()) { $value = $param[1]->evaluate(); } } break; case 'IF_ARRAY_EMPTY': if (isset($param[0])) { $looking_at = $param[0]->evaluate(); if (array_key_exists($looking_at, $param['vars'])) { if (count($param['vars'][$looking_at]) == 0) { $value = $param[1]->evaluate(); } } } break; case 'IF_ARRAY_NON_EMPTY': if (isset($param[0])) { $looking_at = $param[0]->evaluate(); if (array_key_exists($looking_at, $param['vars'])) { if (count($param['vars'][$looking_at]) != 0) { $value = $param[1]->evaluate(); } } } break; case 'OF': if (isset($param[1])) { $key = $param[0]->evaluate(); $x = $param[1]->evaluate(); $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array(); $x2 = is_numeric($x) ? intval($x) : $x; if (is_integer($x2)) { if ($x2 < 0) { $x2 = count($array) - 1; } elseif ($x2 >= count($array)) { $x2 -= count($array); } } $value = array_key_exists($x2, $array) ? $array[$x2] : ''; if (is_object($value)) { $value = $value->evaluate(); } } break; case 'INCLUDE': if (isset($param[1])) { $tpl_params = $param['vars']; $explode = explode(chr(10), $param[1]->evaluate()); foreach ($explode as $val) { $bits = explode('=', $val, 2); if (count($bits) == 2) { $tpl_params[ltrim($bits[0])] = $bits[1]; } } $td = isset($param[3]) ? $param[2]->evaluate() : ''; if ($td == '') { $td = 'templates'; } $ex = isset($param[2]) ? $param[1]->evaluate() : ''; if ($ex == '') { $ex = '.tpl'; } $_value = do_template($param[0]->evaluate(), $tpl_params, NULL, false, NULL, $ex, $td); $value = $_value->evaluate(); } break; case 'WHILE': if (isset($param[1])) { $_p = $param[0]->evaluate(); if ($_p == '1' || $_p == '1') { $value = ''; $value .= $param[1]->evaluate(); $value .= ecv($lang, $escaped, $type, $name, $param); } } break; case 'IF': if (isset($param[1])) { $_p = $param[0]->evaluate(); if ($_p == '1' || $_p == '1') { $value = $param[1]->evaluate(); } } break; case 'LOOP': if (isset($param[0])) { if (!array_key_exists($param[0]->evaluate(), $param['vars'])) { require_code('site'); attach_message(do_lang_tempcode('MISSING_TEMPLATE_PARAMETER', $param[0]->evaluate(), '???'), 'warn'); return ''; } $array_key = $param[0]->evaluate(); if (is_numeric($array_key) || strpos($array_key, ',') !== false) { $array = explode(',', $array_key); } else { $array = array_key_exists($array_key, $param['vars']) ? $param['vars'][$array_key] : array(); if (!is_array($array)) { $array = array(); } } $value = ''; if (array_key_exists(1 + 1, $param)) { $columns = $param[1]->evaluate(); $row_starter = array_key_exists(2 + 1, $param) ? $param[2]->evaluate() : '<tr>'; $row_terminator = array_key_exists(3 + 1, $param) ? $param[3]->evaluate() : '</tr>'; $value .= $row_starter; // Sorting if (array_key_exists(4 + 1, $param)) { $sort_key = $param[4]->evaluate(); $rev = array_key_exists(5 + 1, $param) && $param[5]->evaluate() == 'DESC'; if ($sort_key != '') { global $M_SORT_KEY; $M_SORT_KEY = $sort_key; uasort($array, 'multi_sort'); } if ($rev) { $array = array_reverse($array); } } } $last = count($param) - 2; $col = 0; $first = true; foreach ($array as $go_key => $go) { if (!is_array($go)) { $go = array('_loop_key' => make_string_tempcode(is_integer($go_key) ? strval($go_key) : $go_key), '_loop_var' => make_string_tempcode($go)); } // In case it's not a list of maps, but just a list if (isset($param[2]) && $col % $columns == 0 && $col != 0) { $value .= $row_starter; } $ps = $go + $param['vars'] + array('_loop_key' => make_string_tempcode(is_integer($go_key) ? strval($go_key) : $go_key), '_i' => strval($col), '_first' => $first, '_last' => $col == count($array) - 1); $bound = $param[$last]->bind($ps, ''); $value .= $bound->evaluate(); ++$col; if (isset($param[3]) && $col % $columns == 0) { $value .= $row_terminator; } $first = false; } if (isset($param[2]) && $col % $columns != 0) { $value .= $row_terminator; } } break; default: require_code('site'); attach_message(do_lang_tempcode('UNKNOWN_DIRECTIVE', escape_html($name)), 'warn'); } if ($escaped != array()) { apply_tempcode_escaping($escaped, $value); } return $value; } // By elimination, it's language $a = isset($param[0]) ? is_object($param[0]) ? $param[0]->evaluate() : $param[0] : NULL; $b = isset($param[1]) ? is_object($param[1]) ? $param[1]->evaluate() : $param[1] : NULL; $c = isset($param[2]) ? array_splice($param, 2) : NULL; if ($c !== NULL) { foreach ($c as $i => $cc) { if (is_object($cc)) { $c[$i] = $cc->evaluate(); } } } static $dle = false; if (!$dle) { $dle = function_exists('do_lang'); } $ret = $dle ? do_lang($name, $a, $b, $c, $lang, false) : escape_html($name . ':' . (!is_null($a) ? $a : '') . ',' . (!is_null($b) ? $b : '')); if ($ret === NULL) { if ($type != TC_PARAMETER) { require_code('site'); attach_message(do_lang_tempcode('MISSING_LANG_ENTRY', escape_html($name)), 'warn'); } $value = ''; if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($value); } return $value; } if ($escaped != array() && $escaped != array(ENTITY_ESCAPED)) { apply_tempcode_escaping(array_diff($escaped, array(ENTITY_ESCAPED)), $ret); } // Escape but without ENTITY_ESCAPED because we don't do that on lang strings return $ret; }
/** * The UI to view a banner. * * @return tempcode The UI */ function view_banner() { $title = get_page_title('BANNER_INFORMATION'); $source = get_param('source'); $rows = $GLOBALS['SITE_DB']->query_select('banners', array('*'), array('name' => $source)); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('BANNER_MISSING_SOURCE')); } $myrow = $rows[0]; if (is_guest($myrow['submitter']) || $myrow['submitter'] != get_member()) { check_specific_permission('view_anyones_banner_stats'); } switch ($myrow['the_type']) { case 0: $type = do_lang_tempcode('BANNER_PERMANENT'); break; case 1: $type = do_lang_tempcode('_BANNER_HITS_LEFT', do_lang_tempcode('BANNER_CAMPAIGN'), make_string_tempcode(integer_format($myrow['campaign_remaining']))); break; case 2: $type = do_lang_tempcode('BANNER_DEFAULT'); break; } if ($myrow['views_to'] != 0) { $click_through = protect_from_escaping(escape_html(float_format(100.0 * ($myrow['hits_to'] / $myrow['views_to'])))); } else { $click_through = do_lang_tempcode('NA_EM'); } $has_banner_network = $GLOBALS['SITE_DB']->query_value('banners', 'SUM(views_from)') != 0.0; $fields = new ocp_tempcode(); require_code('templates_view_space'); $fields->attach(view_space_field(do_lang_tempcode('TYPE'), $type)); if ($myrow['b_type'] != '') { $fields->attach(view_space_field(do_lang_tempcode('_BANNER_TYPE'), $myrow['b_type'])); } $expiry_date = is_null($myrow['expiry_date']) ? do_lang_tempcode('NA_EM') : make_string_tempcode(escape_html(get_timezoned_date($myrow['expiry_date'], true))); $fields->attach(view_space_field(do_lang_tempcode('EXPIRY_DATE'), $expiry_date)); if ($has_banner_network) { $fields->attach(view_space_field(do_lang_tempcode('BANNER_HITSFROM'), integer_format($myrow['hits_from']), false, 'hits_from')); $fields->attach(view_space_field(do_lang_tempcode('BANNER_VIEWSFROM'), integer_format($myrow['views_from']), false, 'views_from')); } $fields->attach(view_space_field(do_lang_tempcode('BANNER_HITSTO'), $myrow['site_url'] == '' ? do_lang_tempcode('CANT_TRACK') : protect_from_escaping(escape_html(integer_format($myrow['hits_to']))), false, 'hits_to')); $fields->attach(view_space_field(do_lang_tempcode('BANNER_VIEWSTO'), $myrow['site_url'] == '' ? do_lang_tempcode('CANT_TRACK') : protect_from_escaping(escape_html(integer_format($myrow['views_to']))), false, 'views_to')); $fields->attach(view_space_field(do_lang_tempcode('BANNER_CLICKTHROUGH'), $click_through)); $username = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['submitter']); $fields->attach(view_space_field(do_lang_tempcode('SUBMITTER'), $username, true)); $view_space = do_template('VIEW_SPACE', array('_GUID' => 'eb97a46d8e9813da7081991d5beed270', 'WIDTH' => '300', 'FIELDS' => $fields)); $banner = show_banner($myrow['name'], $myrow['b_title_text'], get_translated_tempcode($myrow['caption']), $myrow['img_url'], $source, $myrow['site_url'], $myrow['b_type']); $edit_url = new ocp_tempcode(); if (has_actual_page_access(NULL, 'cms_banners', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_banners')) { $edit_url = build_url(array('page' => 'cms_banners', 'type' => '_ed', 'id' => $source), get_module_zone('cms_banners')); } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Banner', 'title' => get_translated_text($myrow['caption']), 'identifier' => '_SEARCH:banners:view:' . $source, 'description' => '', 'image' => $myrow['img_url']); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')))); return do_template('BANNER_VIEW_SCREEN', array('_GUID' => 'ed923ae0682c6ed679c0efda688c49ea', 'TITLE' => $title, 'EDIT_URL' => $edit_url, 'VIEW_SPACE' => $view_space, 'BANNER' => $banner)); }
/** * The UI to show a video. * * @param ?string Alternate category name to use (NULL: use standard one). This is useful if you are overriding this code to show images in virtual galleries. * @param ?tempcode Breadcrumbs (NULL: derive in this function). * @return tempcode The UI */ function show_video($category_name = NULL, $tree = NULL) { $id = get_param_integer('id'); if (get_param_integer('ajax', 0) == 1) { header('Content-type: text/xml'); } list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order(); if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('video', strval($id)); } else { $awards = array(); } // Pic up some info $rows = $GLOBALS['SITE_DB']->query_select('videos', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen(get_page_title('ERROR_OCCURRED'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $url = $myrow['url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $cat = $myrow['cat']; $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=galleries&filter=' . urlencode($cat); if (get_value('no_individual_gallery_view') === '1' && $GLOBALS['SITE_DB']->query_value('galleries', 'flow_mode_interface', array('name' => $cat)) == '1') { require_code('site2'); assign_refresh(build_url(array('page' => '_SELF', 'type' => 'misc', 'id' => $cat, 'probe_id' => $id, 'probe_type' => 'video'), '_SELF'), 0.0); } $true_category_name = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $cat))); if (is_null($category_name)) { $category_name = $true_category_name; } if (get_param_integer('slideshow', 0) == 1) { $title = get_page_title('VIEW_SLIDESHOW', true, array(escape_html($category_name))); global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML } else { $title = get_page_title(get_translated_text($myrow['title']) == '' ? 'VIEW_VIDEO' : '_VIEW_VIDEO', true, array(escape_html(get_translated_text($myrow['title']))), NULL, $awards); } $root = get_param('root', 'root'); seo_meta_load_for('video', strval($id)); $thumb_url = $myrow['thumb_url']; if (url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } if (!has_category_access(get_member(), 'galleries', $cat)) { access_denied('CATEGORY_ACCESS'); } // Views if (get_db_type() != 'xml') { $myrow['video_views']++; $GLOBALS['SITE_DB']->query_update('videos', array('video_views' => $myrow['video_views']), array('id' => $id), '', 1, NULL, false, true); } list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('videos', strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'video', 'id' => $id), '_SELF', NULL, false, false, true), get_translated_text($myrow['title']) == '' ? do_lang('VIEW_VIDEO_IN', $true_category_name) : get_translated_text($myrow['title']), get_value('comment_forum__videos')); // Validation if ($myrow['validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details = do_template('WARNING_TABLE', array('_GUID' => 'b32faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } // Comments $comments = get_translated_tempcode($myrow['comments']); if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', $cat))) { $edit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ev', 'id' => $id), get_module_zone('cms_galleries')); } else { $edit_url = new ocp_tempcode(); } $add_date = get_timezoned_date($myrow['add_date']); $edit_date = is_null($myrow['edit_date']) ? '' : get_timezoned_date($myrow['edit_date']); // Video HTML $video = show_gallery_media($url, $thumb_url, $myrow['video_width'], $myrow['video_height'], $myrow['video_length']); $extension = get_file_extension($url); require_code('mime_types'); $mime_type = get_mime_type($extension); list($n, $x, $nav) = $this->build_set_navigation(db_string_equal_to('cat', $cat), '', $category_name, $id, $root, 'video', get_param_integer('slideshow', 0), get_param_integer('wide_high', 0), get_param_integer('start', 0), get_param_integer('max', get_default_gallery_max()), $cat, $sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos, get_param('select', '*'), get_param('video_select', '*')); $member_id = get_member_id_from_gallery_name($cat, NULL, true); if (get_forum_type() == 'ocf') { require_code('ocf_members'); require_code('ocf_members2'); } $member_details = is_null($member_id) || get_forum_type() != 'ocf' ? new ocp_tempcode() : ocf_show_member_box($member_id); $video_details = show_video_details($myrow); if (is_null($tree)) { $tree = gallery_breadcrumbs($cat, $root, false, get_module_zone('galleries')); } breadcrumb_add_segment($tree, do_lang_tempcode('VIEW_VIDEO')); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Video', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:galleries:video:' . strval($id), 'description' => get_translated_text($myrow['comments']), 'image' => $thumb_url, 'video' => $url, 'video:height' => strval($myrow['video_height']), 'video:width' => strval($myrow['video_width']), 'video:type' => $mime_type); return do_template('GALLERY_ENTRY_SCREEN', array('_GUID' => '91e231906ed899513ec2db8a2974dddf', 'MEDIA_TYPE' => 'video', 'E_TITLE' => get_translated_text($myrow['title']), 'CAT' => $cat, 'SLIDESHOW' => get_param_integer('slideshow', 0) == 1, 'TRUE_GALLERY_TITLE' => $true_category_name, 'GALLERY_TITLE' => $category_name, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'ID' => strval($id), 'TAGS' => get_loaded_tags('videos'), 'TITLE' => $title, 'SUBMITTER' => strval($myrow['submitter']), 'URL' => $url, 'VIDEO_DETAILS' => $video_details, 'MEMBER_DETAILS' => $member_details, 'X' => integer_format($x), 'N' => integer_format($n), 'VIEWS' => integer_format($myrow['video_views']), 'ADD_DATE_RAW' => strval($myrow['add_date']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'NAV' => $nav, 'COMMENTS' => $comments, 'VIDEO' => $video, 'WARNING_DETAILS' => $warning_details)); }
/** * The UI to view an IOTD. * * @return tempcode The UI */ function view() { $title = get_page_title('IOTD'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('IOTD_ARCHIVE')))); $id = get_param_integer('id'); $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen($title, do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], is_null($myrow['date_and_time']) && $myrow['used'] == 0 ? 0 : 1, $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF', NULL, false, false, true), get_translated_text($myrow['i_title']), get_value('comment_forum__iotds')); $date_raw = strval($myrow['date_and_time']); $add_date_raw = strval($myrow['add_date']); $edit_date_raw = is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']); $date = get_timezoned_date($myrow['date_and_time']); $add_date = get_timezoned_date($myrow['add_date']); $edit_date = get_timezoned_date($myrow['edit_date']); // Views if (get_db_type() != 'xml') { $myrow['iotd_views']++; $GLOBALS['SITE_DB']->query_update('iotd', array('iotd_views' => $myrow['iotd_views']), array('id' => $id), '', 1, NULL, false, true); } if (has_actual_page_access(NULL, 'cms_iotds', NULL, NULL) && has_edit_permission('high', get_member(), $myrow['submitter'], 'cms_iotds')) { $edit_url = build_url(array('page' => 'cms_iotds', 'type' => '_ed', 'id' => $id), get_module_zone('cms_iotds')); } else { $edit_url = new ocp_tempcode(); } $url = $myrow['url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Poll', 'title' => get_translated_text($myrow['i_title']), 'identifier' => '_SEARCH:iotds:view:' . strval($id), 'description' => '', 'image' => $url); return do_template('IOTD_VIEW_SCREEN', array('_GUID' => 'f508d483459b88fab44cd8b9f4db780b', 'TITLE' => $title, 'SUBMITTER' => strval($myrow['submitter']), 'I_TITLE' => get_translated_tempcode($myrow['i_title']), 'CAPTION' => get_translated_tempcode($myrow['caption']), 'DATE_RAW' => $date_raw, 'ADD_DATE_RAW' => $add_date_raw, 'EDIT_DATE_RAW' => $edit_date_raw, 'DATE' => $date, 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'VIEWS' => integer_format($myrow['iotd_views']), 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'URL' => $url)); }
/** * The UI to view a news entry. * * @return tempcode The UI */ function view_news() { $id = get_param_integer('id'); $blog = get_param_integer('blog', NULL); $filter = get_param('filter', '*'); $filter_and = get_param('filter_and', '*'); if ($blog === 1) { $first_bc = array('_SELF:_SELF:blog_select', do_lang_tempcode('BLOGS')); } elseif ($blog === 0) { $first_bc = array('_SELF:_SELF:cat_select', do_lang_tempcode('JUST_NEWS_CATEGORIES')); } else { $first_bc = array('_SELF:_SELF:select', do_lang_tempcode('NEWS_CATEGORIES')); } if ($blog === 1) { $parent_title = do_lang_tempcode('BLOG_NEWS_ARCHIVE'); } else { if (is_numeric($filter)) { $news_cat_title = $GLOBALS['SITE_DB']->query_select('news_categories', array('nc_title'), array('id' => intval($filter)), '', 1); if (array_key_exists(0, $news_cat_title)) { $news_cat_title[0]['text_original'] = get_translated_text($news_cat_title[0]['nc_title']); $parent_title = make_string_tempcode(escape_html($news_cat_title[0]['text_original'])); } else { $parent_title = do_lang_tempcode('NEWS_ARCHIVE'); } } else { $parent_title = do_lang_tempcode('NEWS_ARCHIVE'); } } breadcrumb_set_parents(array($first_bc, array('_SELF:_SELF:misc' . ($blog === 1 ? ':blog=1' : ($blog === 0 ? ':blog=0' : '')) . ($filter == '*' ? '' : (is_numeric($filter) ? ':id=' . $filter : ':filter=' . $filter)) . ($filter_and == '*' ? '' : ':filter_and=' . $filter_and), $parent_title))); $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen(get_page_title('NEWS'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; if (!has_category_access(get_member(), 'news', strval($myrow['news_category']))) { access_denied('CATEGORY_ACCESS'); } if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('news', strval($id)); } else { $awards = array(); } $_title = get_translated_tempcode($myrow['title']); $title_to_use = do_lang_tempcode($blog === 1 ? 'BLOG__NEWS' : '_NEWS', $_title); $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('news', strval($id), do_lang($blog === 1 ? 'BLOG__NEWS' : '_NEWS', get_translated_text($myrow['title']))); // Rating and comments $self_url_map = array('page' => '_SELF', 'type' => 'view', 'id' => $id); /*if ($filter!='*') $self_url_map['filter']=$filter; Potentially makes URL too long for content topic to store, and we probably don't want to store this assumptive context anyway if (($filter_and!='*') && ($filter_and!='')) $self_url_map['filter_and']=$filter_and;*/ if (!is_null($blog)) { $self_url_map['blog'] = $blog; } list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url($self_url_map, '_SELF', NULL, false, false, true), get_translated_text($myrow['title']), get_value('comment_forum__news')); $date = get_timezoned_date($myrow['date_and_time']); $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $myrow['author']), get_module_zone('authors')) : new ocp_tempcode(); $author = $myrow['author']; $news_full = get_translated_tempcode($myrow['news_article']); $news_full_plain = get_translated_text($myrow['news_article']); if ($news_full->is_empty()) { $news_full = get_translated_tempcode($myrow['news']); $news_full_plain = get_translated_text($myrow['news']); } if (has_actual_page_access(NULL, $blog === 1 ? 'cms_blogs' : 'cms_news', NULL, NULL) && has_edit_permission('high', get_member(), $myrow['submitter'], $blog === 1 ? 'cms_blogs' : 'cms_news', array('news', $myrow['news_category']))) { $edit_url = build_url(array('page' => $blog === 1 ? 'cms_blogs' : 'cms_news', 'type' => '_ed', 'id' => $id), get_module_zone($blog === 1 ? 'cms_blogs' : 'cms_news')); } else { $edit_url = new ocp_tempcode(); } $tmp = array('page' => '_SELF', 'type' => 'misc'); if ($filter != '*') { $tmp[is_numeric($filter) ? 'id' : 'filter'] = $filter; } if ($filter_and != '*' && $filter_and != '') { $tmp['filter_and'] = $filter_and; } if (!is_null($blog)) { $tmp['blog'] = $blog; } $archive_url = build_url($tmp, '_SELF'); // Validation if ($myrow['validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details = do_template('WARNING_TABLE', array('_GUID' => '5fd82328dc2ac9695dc25646237065b0', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } // Views if (get_db_type() != 'xml') { $myrow['news_views']++; $GLOBALS['SITE_DB']->query_update('news', array('news_views' => $myrow['news_views']), array('id' => $id), '', 1, NULL, false, true); } if (($blog !== 1 || has_specific_permission(get_member(), 'have_personal_category', 'cms_news')) && has_actual_page_access(NULL, $blog === 1 ? 'cms_blogs' : 'cms_news', NULL, NULL) && has_submit_permission('high', get_member(), get_ip_address(), 'cms_news', array('news', $myrow['news_category']))) { $map = array('page' => $blog === 1 ? 'cms_blogs' : 'cms_news', 'type' => 'ad'); if (is_numeric($filter)) { $map['cat'] = $filter; } $submit_url = build_url($map, get_module_zone('cms_news')); } else { $submit_url = new ocp_tempcode(); } $news_cats = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'news_categories WHERE nc_owner IS NULL OR id=' . strval($myrow['news_category'])); $news_cats = list_to_map('id', $news_cats); $img = find_theme_image($news_cats[$myrow['news_category']]['nc_img']); if (is_null($img)) { $img = ''; } if ($myrow['news_image'] != '') { $img = $myrow['news_image']; if (url_is_local($img)) { $img = get_custom_base_url() . '/' . $img; } } $category = get_translated_text($news_cats[$myrow['news_category']]['nc_title']); $categories = array(strval($myrow['news_category']) => $category); $all_categories_for_this = $GLOBALS['SITE_DB']->query_select('news_category_entries', array('*'), array('news_entry' => $id)); $NEWS_CATS = array(); foreach ($all_categories_for_this as $category_for_this) { if (!array_key_exists($category_for_this['news_entry_category'], $news_cats)) { $_news_cats = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('id' => $category_for_this['news_entry_category']), '', 1); if (array_key_exists(0, $_news_cats)) { $NEWS_CATS[$category_for_this['news_entry_category']] = $_news_cats[0]; } } if (array_key_exists($category_for_this['news_entry_category'], $news_cats)) { $categories[strval($category_for_this['news_entry_category'])] = get_translated_text($news_cats[$category_for_this['news_entry_category']]['nc_title']); } } $newsletter_url = new ocp_tempcode(); if (addon_installed('newsletter')) { require_lang('newsletter'); if (has_actual_page_access(get_member(), 'admin_newsletter')) { $newsletter_url = build_url(array('page' => 'admin_newsletter', 'type' => 'new', 'from_news' => $id), get_module_zone('admin_newsletter')); } } breadcrumb_set_self(get_translated_tempcode($myrow['title'])); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['date_and_time']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'News article', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:news:view:' . strval($id), 'image' => $img, 'description' => strip_comcode(get_translated_text($myrow['news']))); return do_template('NEWS_FULL_SCREEN', array('_GUID' => '7686b23934e22c493d4ac10ba6c475c4', 'ID' => strval($id), 'CATEGORY_ID' => strval($myrow['news_category']), 'BLOG' => $blog === 1, '_TITLE' => $_title, 'TAGS' => get_loaded_tags('news'), 'CATEGORIES' => $categories, 'NEWSLETTER_URL' => $newsletter_url, 'ADD_DATE_RAW' => strval($myrow['date_and_time']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'SUBMITTER' => strval($myrow['submitter']), 'CATEGORY' => $category, 'IMG' => $img, 'TITLE' => $title, 'VIEWS' => integer_format($myrow['news_views']), 'COMMENT_DETAILS' => $comment_details, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'DATE' => $date, 'AUTHOR' => $author, 'AUTHOR_URL' => $author_url, 'NEWS_FULL' => $news_full, 'NEWS_FULL_PLAIN' => $news_full_plain, 'EDIT_URL' => $edit_url, 'ARCHIVE_URL' => $archive_url, 'SUBMIT_URL' => $submit_url, 'WARNING_DETAILS' => $warning_details)); }