/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { if (!addon_installed('galleries')) { return NULL; } if (!has_actual_page_access(get_member(), 'galleries')) { return NULL; } $filters_1 = ocfilter_to_sqlfragment($_filters, 'name', 'galleries', 'parent_id', 'name', 'name', false, false); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $filters = ocfilter_to_sqlfragment($_filters, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) require_lang('galleries'); $content = new ocp_tempcode(); $_galleries = array(); if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1) < 3000) { $_galleries = $GLOBALS['SITE_DB']->query('SELECT fullname,name FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1); foreach ($_galleries as $i => $_gallery) { $_galleries[$i]['text_original'] = get_translated_text($_gallery['fullname']); } } $galleries = collapse_2d_complexity('name', 'text_original', $_galleries); $rows1 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max); $rows2 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'images WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max); $rows = array_merge($rows1, $rows2); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['submitter']); if (is_null($author)) { $author = ''; } $news_date = date($date_string, $row['add_date']); $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']); $news_title = xmlentities(do_lang('THIS_WITH_SIMPLE', array_key_exists('video_views', $row) ? do_lang('VIDEO') : do_lang('IMAGE'), strval($row['id']))); $_summary = get_translated_tempcode($row['comments']); $summary = xmlentities($_summary->evaluate()); $news = ''; if (!array_key_exists($row['cat'], $galleries)) { $_fullname = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'fullname', array('name' => $row['cat'])); if (is_null($_fullname)) { continue; } $galleries[$row['cat']] = get_translated_text($_fullname); } $category = $galleries[$row['cat']]; $category_raw = $row['cat']; $view_url = build_url(array('page' => 'galleries', 'type' => array_key_exists('video_views', $row) ? 'video' : 'image', 'id' => $row['id']), get_module_zone('galleries'), NULL, false, false, true); if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= '1') { $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => '65dc0cec8c75f565c58c95fa1667aa1e', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id']))); } else { $if_comments = new ocp_tempcode(); } require_code('images'); $enclosure_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', array_key_exists('video_views', $row) ? 'videos' : 'images', $row['id']); list($enclosure_length, $enclosure_type) = get_enclosure_details($row['url'], $enclosure_url); $content->attach(do_template($prefix . 'ENTRY', array('ENCLOSURE_URL' => $enclosure_url, 'ENCLOSURE_LENGTH' => $enclosure_length, 'ENCLOSURE_TYPE' => $enclosure_type, 'VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } require_lang('galleries'); return array($content, do_lang('GALLERIES')); }
/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { unset($_filters); // Not used if (!addon_installed('iotds')) { return NULL; } if (!has_actual_page_access(get_member(), 'iotds')) { return NULL; } $content = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'iotd WHERE add_date>' . strval((int) $cutoff) . ' AND (used=1 OR is_current=1) ORDER BY add_date DESC', $max); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['submitter']); if (is_null($author)) { $author = ''; } $news_date = date($date_string, $row['add_date']); $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']); $_news_title = get_translated_tempcode($row['i_title']); $news_title = xmlentities($_news_title->evaluate()); $_summary = get_translated_tempcode($row['caption']); $summary = xmlentities($_summary->evaluate()); $news = ''; $category = ''; $category_raw = ''; $view_url = build_url(array('page' => 'iotds', 'type' => 'view', 'id' => $row['id']), get_module_zone('iotds'), NULL, false, false, true); if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= 1) { $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'a8ccf291cb27c8ffb34f023416b85664', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id']))); } else { $if_comments = new ocp_tempcode(); } require_code('images'); $enclosure_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'iotds', 'iotd', $row['id']); list($enclosure_length, $enclosure_type) = get_enclosure_details($row['url'], $enclosure_url); $content->attach(do_template($prefix . 'ENTRY', array('ENCLOSURE_URL' => $enclosure_url, 'ENCLOSURE_LENGTH' => $enclosure_length, 'ENCLOSURE_TYPE' => $enclosure_type, 'VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } require_lang('iotds'); return array($content, do_lang('IOTDS')); }
/** * Standard modular render function for profile tab hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return array A triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('PROFILE'); $order = 10; $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_url'); if ($photo_url != '' && addon_installed('ocf_member_photos') && has_specific_permission($member_id_viewing, 'view_member_photos')) { require_code('images'); $photo_thumb_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_thumb_url'); $photo_thumb_url = ensure_thumbnail($photo_url, $photo_thumb_url, strpos($photo_url, 'uploads/photos') !== false ? 'photos' : 'ocf_photos', 'f_members', $member_id_of, 'm_photo_thumb_url'); if (url_is_local($photo_url)) { $photo_url = get_complex_base_url($photo_url) . '/' . $photo_url; } if (url_is_local($photo_thumb_url)) { $photo_thumb_url = get_complex_base_url($photo_thumb_url) . '/' . $photo_thumb_url; } } else { $photo_url = ''; $photo_thumb_url = ''; } $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id_of); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); // Things staff can do with this user $modules = array(); if (has_specific_permission($member_id_viewing, 'warn_members') && has_actual_page_access($member_id_viewing, 'warnings') && addon_installed('ocf_warnings')) { $redir_url = get_self_url(true); $modules[] = array('usage', do_lang_tempcode('WARN_MEMBER'), build_url(array('page' => 'warnings', 'type' => 'ad', 'id' => $member_id_of, 'redirect' => $redir_url), get_module_zone('warnings'))); $modules[] = array('usage', do_lang_tempcode('PUNITIVE_HISTORY'), build_url(array('page' => 'warnings', 'type' => 'history', 'id' => $member_id_of), get_module_zone('warnings'))); } if (has_specific_permission($member_id_viewing, 'view_content_history') && has_actual_page_access($member_id_viewing, 'admin_ocf_history')) { $modules[] = !addon_installed('ocf_forum') ? NULL : array('usage', do_lang_tempcode('POST_HISTORY'), build_url(array('page' => 'admin_ocf_history', 'member_id' => $member_id_of), 'adminzone')); } if (has_actual_page_access($member_id_viewing, 'admin_lookup')) { require_lang('submitban'); $modules[] = array('usage', do_lang_tempcode('INVESTIGATE_USER'), build_url(array('page' => 'admin_lookup', 'param' => $member_id_of), 'adminzone')); } if (has_actual_page_access($member_id_viewing, 'admin_security')) { require_lang('security'); $modules[] = array('usage', do_lang_tempcode('SECURITY_LOGGING'), build_url(array('page' => 'admin_security', 'member_id' => $member_id_of), 'adminzone')); } if (addon_installed('actionlog')) { if (has_actual_page_access($member_id_viewing, 'admin_actionlog')) { require_lang('submitban'); $modules[] = array('usage', do_lang_tempcode('VIEW_ACTION_LOGS'), build_url(array('page' => 'admin_actionlog', 'type' => 'list', 'id' => $member_id_of), 'adminzone')); } } if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('ocf_forum') && addon_installed('search')) { $modules[] = array('content', do_lang_tempcode('SEARCH_POSTS'), build_url(array('page' => 'search', 'type' => 'results', 'id' => 'ocf_posts', 'author' => $username, 'sort' => 'add_date', 'direction' => 'DESC', 'content' => ''), get_module_zone('search')), 'search'); } if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('search')) { $modules[] = array('content', do_lang_tempcode('SEARCH'), build_url(array('page' => 'search', 'type' => 'misc', 'author' => $username), get_module_zone('search')), 'search'); } if (addon_installed('authors')) { $author = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT author FROM ' . get_table_prefix() . 'authors WHERE (forum_handle=' . strval($member_id_viewing) . ') OR (forum_handle IS NULL AND ' . db_string_equal_to('author', $username) . ')'); if (has_actual_page_access($member_id_viewing, 'authors') && !is_null($author)) { $modules[] = array('content', do_lang_tempcode('AUTHOR'), build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')), 'me'); } } require_code('ocf_members2'); if (!is_guest() && ocf_may_whisper($member_id_of) && has_actual_page_access($member_id_viewing, 'topics') && ocf_may_make_personal_topic() && $member_id_viewing != $member_id_of) { $modules[] = !addon_installed('ocf_forum') ? NULL : array('contact', do_lang_tempcode('ADD_PERSONAL_TOPIC'), build_url(array('page' => 'topics', 'type' => 'new_pt', 'id' => $member_id_of), get_module_zone('topics')), 'reply'); } $extra_sections = array(); $info_details = array(); $hooks = find_all_hooks('modules', 'members'); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/members/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_members_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } if (method_exists($object, 'run')) { $hook_result = $object->run($member_id_of); $modules = array_merge($modules, $hook_result); } if (method_exists($object, 'get_info_details')) { $hook_result = $object->get_info_details($member_id_of); $info_details = array_merge($info_details, $hook_result); } if (method_exists($object, 'get_sections')) { $hook_result = $object->get_sections($member_id_of); $extra_sections = array_merge($extra_sections, $hook_result); } } if (addon_installed('ocf_contactmember')) { if (($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_allow_emails') == 1 || get_option('allow_email_disable') == '0') && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address') != '' && !is_guest($member_id_of) && has_actual_page_access($member_id_viewing, 'contactmember') && $member_id_viewing != $member_id_of) { $redirect = get_self_url(true); $modules[] = array('contact', do_lang_tempcode('_EMAIL_MEMBER'), build_url(array('page' => 'contactmember', 'redirect' => $redirect, 'id' => $member_id_of), get_module_zone('contactmember')), 'reply'); } } require_lang('menus'); $sections = array('contact' => do_lang_tempcode('CONTACT'), 'profile' => do_lang_tempcode('EDIT_PROFILE'), 'views' => do_lang_tempcode('ACCOUNT'), 'usage' => do_lang_tempcode('USAGE'), 'content' => do_lang_tempcode('CONTENT')); $actions = array(); global $M_SORT_KEY; $M_SORT_KEY = mixed(); $M_SORT_KEY = 1; @uasort($modules, 'multi_sort'); /* @ is to stop PHP bug warning about altered array contents when Tempcode copies are evaluated internally */ foreach ($sections as $section_code => $section_title) { $links = new ocp_tempcode(); foreach ($modules as $module) { if (count($module) == 3) { list($_section_code, $lang, $url) = $module; $rel = NULL; } else { list($_section_code, $lang, $url, $rel) = $module; } if ($section_code == $_section_code) { $links->attach(do_template('OCF_MEMBER_ACTION', array('_GUID' => '67b2a640a368c6f53f1b1fa10f922fd0', 'ID' => strval($member_id_of), 'URL' => $url, 'LANG' => $lang, 'REL' => $rel))); } } $actions[$section_code] = $links; } // Custom fields $_custom_fields = ocf_get_all_custom_fields_match_member($member_id_of, $member_id_viewing != $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_viewing == $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL); $custom_fields = array(); require_code('encryption'); $value = mixed(); foreach ($_custom_fields as $name => $_value) { $value = $_value['RAW']; $rendered_value = $_value['RENDERED']; $encrypted_value = ''; if (is_data_encrypted($value)) { $encrypted_value = remove_magic_encryption_marker($value); } elseif (is_integer($value)) { $value = strval($value); } elseif (is_float($value)) { $value = float_to_raw_string($value); } if (!is_object($value) && $value != '' || is_object($value) && !$value->is_empty()) { $custom_fields[] = array('NAME' => $name, 'RAW_VALUE' => $value, 'VALUE' => $rendered_value, 'ENCRYPTED_VALUE' => $encrypted_value); if ($name == do_lang('KEYWORDS')) { $GLOBALS['SEO_KEYWORDS'] = is_object($value) ? $value->evaluate() : $value; } if ($name == do_lang('DESCRIPTION')) { $GLOBALS['SEO_DESCRIPTION'] = is_object($value) ? $value->evaluate() : $value; } } } // Birthday $dob = ''; if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_reveal_age') == 1) { $day = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_day'); $month = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_month'); $year = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_year'); if (!is_null($day)) { if (@strftime('%Y', @mktime(0, 0, 0, 1, 1, 1963)) != '1963') { $dob = strval($year) . '-' . str_pad(strval($month), 2, '0', STR_PAD_LEFT) . '-' . str_pad(strval($day), 2, '0', STR_PAD_LEFT); } else { $dob = get_timezoned_date(mktime(12, 0, 0, $month, $day, $year), false, true, true); } } } // Find forum with most posts $forums = $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0'); $best_yet_forum = 0; // Initialise to integer type $best_yet_forum = NULL; $most_active_forum = NULL; $_best_yet_forum = $GLOBALS['FORUM_DB']->query_select('f_posts', array('COUNT(*) as cnt', 'p_cache_forum_id'), array('p_poster' => $member_id_of), 'GROUP BY p_cache_forum_id'); $_best_yet_forum = collapse_2d_complexity('p_cache_forum_id', 'cnt', $_best_yet_forum); foreach ($forums as $forum) { if (array_key_exists($forum['id'], $_best_yet_forum) && (is_null($best_yet_forum) || $_best_yet_forum[$forum['id']] > $best_yet_forum)) { $most_active_forum = has_category_access($member_id_viewing, 'forums', strval($forum['id'])) ? protect_from_escaping(escape_html($forum['f_name'])) : do_lang_tempcode('PROTECTED_FORUM'); $best_yet_forum = $_best_yet_forum[$forum['id']]; } } $post_count = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_cache_num_posts'); $best_post_fraction = $post_count == 0 ? do_lang_tempcode('NA_EM') : make_string_tempcode(integer_format(100 * $best_yet_forum / $post_count)); $most_active_forum = is_null($best_yet_forum) ? new ocp_tempcode() : do_lang_tempcode('_MOST_ACTIVE_FORUM', $most_active_forum, make_string_tempcode(integer_format($best_yet_forum)), array($best_post_fraction)); $time_for_them_raw = tz_time(time(), get_users_timezone($member_id_of)); $time_for_them = get_timezoned_time(time(), true, $member_id_of); $banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned') == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $last_submit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_submit_time'); $submit_days_ago = intval(floor(floatval(time() - $last_submit_time) / 60.0 / 60.0 / 24.0)); require_code('ocf_groups'); $primary_group_id = ocf_get_member_primary_group($member_id_of); $primary_group = ocf_get_group_link($primary_group_id); $signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']); $last_visit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_visit_time'); if (member_is_online($member_id_of)) { $online_now = do_lang_tempcode('YES'); $_online_now = true; } else { $_online_now = false; $minutes_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0)); $hours_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0)); $days_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0)); $months_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0 / 31.0)); if ($minutes_ago < 180) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MINUTES', integer_format($minutes_ago)); } elseif ($hours_ago < 72) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_HOURS', integer_format($hours_ago)); } elseif ($days_ago < 93) { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_DAYS', integer_format($days_ago)); } else { $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MONTHS', integer_format($months_ago)); } } $join_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_join_time'); $days_joined = intval(round((time() - $join_time) / 60 / 60 / 24)); $total_posts = $GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)'); $join_date = $join_time == 0 ? '' : get_timezoned_date($join_time, false); $count_posts = do_lang_tempcode('_COUNT_POSTS', integer_format($post_count), float_format(floatval($post_count) / floatval($days_joined == 0 ? 1 : $days_joined)), array(float_format(floatval(100 * $post_count) / floatval($total_posts == 0 ? 1 : $total_posts)))); $a = $avatar_url == '' ? 0 : ocf_get_member_best_group_property($member_id_of, 'max_avatar_width'); $b = $photo_thumb_url == '' ? 0 : intval(get_option('thumb_width')); $right_margin = max($a, $b) == 0 ? 'auto' : strval(max($a, $b) + 6) . 'px'; breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MEMBERS')))); if (has_specific_permission($member_id_viewing, 'see_ip')) { $ip_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_ip_address'); } else { $ip_address = ''; } $secondary_groups = ocf_get_members_groups($member_id_of, true); unset($secondary_groups[$primary_group_id]); if (count($secondary_groups) > 0) { $_secondary_groups = array(); $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, array_keys($secondary_groups), $member_id_of); foreach (array_keys($secondary_groups) as $key) { $_secondary_groups[$key] = $all_groups[$key]; } $secondary_groups = $_secondary_groups; } if (addon_installed('points')) { require_code('points'); $count_points = integer_format(total_points($member_id_of)); } else { $count_points = ''; } $user_agent = NULL; $operating_system = NULL; if (has_specific_permission($member_id_viewing, 'show_user_browsing') && addon_installed('stats')) { $last_stats = $GLOBALS['SITE_DB']->query_select('stats', array('browser', 'operating_system'), array('the_user' => $member_id_of), 'ORDER BY date_and_time DESC', 1); if (array_key_exists(0, $last_stats)) { $user_agent = $last_stats[0]['browser']; $operating_system = $last_stats[0]['operating_system']; } } /*if ((get_option('allow_member_integration')!='off') && (get_option('allow_member_integration')!='hidden')) { $remote=$GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of,'m_password_compat_scheme')=='remote'; } else */ $remote = NULL; $_on_probation = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until'); if (is_null($_on_probation) || $_on_probation <= time()) { $on_probation = NULL; } else { $on_probation = strval($_on_probation); } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $join_time), 'creator' => $username, 'publisher' => '', 'modified' => '', 'type' => 'Member', 'title' => '', 'identifier' => '_SEARCH:members:view:' . strval($member_id_of), 'description' => '', 'image' => $avatar_url == '' && has_specific_permission($member_id_viewing, 'view_member_photos') ? $photo_url : $avatar_url); // Look up member's clubs $clubs = array(); if (addon_installed('ocf_clubs')) { $club_ids = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of, true); $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1), '', 200)); if (count($club_rows) == 200) { $club_rows = NULL; } foreach ($club_ids as $club_id) { if (is_null($club_rows)) { $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1, 'id' => $club_id), '', 200)); if (!array_key_exists($club_id, $club_rows)) { continue; } $club_row = $club_rows[$club_id]; $club_rows = NULL; } else { if (!array_key_exists($club_id, $club_rows)) { continue; } $club_row = $club_rows[$club_id]; } $club_name = get_translated_text($club_row['g_name'], $GLOBALS['FORUM_DB']); $club_forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.f_description', 'f.id', array('text_original' => do_lang('FORUM_FOR_CLUB', $club_name))); $clubs[] = array('CLUB_NAME' => $club_name, 'CLUB_ID' => strval($club_row['id']), 'CLUB_FORUM' => is_null($club_forum) ? '' : strval($club_forum)); } } $content = do_template('OCF_MEMBER_PROFILE_ABOUT', array('_GUID' => 'fodfjdsfjsdljfdls', 'CLUBS' => $clubs, 'REMOTE' => $remote, 'RIGHT_MARGIN' => $right_margin, 'AVATAR_WIDTH' => strval($a) . 'px', 'PHOTO_WIDTH' => strval($b) . 'px', 'MOST_ACTIVE_FORUM' => $most_active_forum, 'TIME_FOR_THEM' => $time_for_them, 'TIME_FOR_THEM_RAW' => strval($time_for_them_raw), 'SUBMIT_DAYS_AGO' => integer_format($submit_days_ago), 'SUBMIT_TIME_RAW' => strval($last_submit_time), 'LAST_VISIT_TIME_RAW' => strval($last_visit_time), 'ONLINE_NOW' => $online_now, '_ONLINE_NOW' => $_online_now, 'BANNED' => $banned, 'USER_AGENT' => $user_agent, 'OPERATING_SYSTEM' => $operating_system, 'DOB' => $dob, 'IP_ADDRESS' => $ip_address, 'COUNT_POSTS' => $count_posts, 'COUNT_POINTS' => $count_points, 'PRIMARY_GROUP' => $primary_group, 'PRIMARY_GROUP_ID' => strval($primary_group_id), 'PHOTO_URL' => $photo_url, 'PHOTO_THUMB_URL' => $photo_thumb_url, 'EMAIL_ADDRESS' => $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address'), 'AVATAR_URL' => $avatar_url, 'SIGNATURE' => $signature, 'JOIN_DATE' => $join_date, 'JOIN_DATE_RAW' => strval($join_time), 'CUSTOM_FIELDS' => $custom_fields, 'ACTIONS_contact' => $actions['contact'], 'ACTIONS_profile' => $actions['profile'], 'ACTIONS_views' => $actions['views'], 'ACTIONS_usage' => $actions['usage'], 'ACTIONS_content' => $actions['content'], 'USERNAME' => $username, 'MEMBER_ID' => strval($member_id_of), 'SECONDARY_GROUPS' => $secondary_groups, 'VIEW_PROFILES' => $member_id_viewing == $member_id_of || has_specific_permission($member_id_viewing, 'view_profiles'), 'ON_PROBATION' => $on_probation, 'EXTRA_INFO_DETAILS' => $info_details, 'EXTRA_SECTIONS' => $extra_sections)); return array($title, $content, $order); }
/** * The UI to browse IOTDs. * * @return tempcode The UI */ function iotd_browse() { $title = get_page_title('IOTD_ARCHIVE'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $start = get_param_integer('start', 0); $max = get_param_integer('max', 20); $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('used' => 1), 'ORDER BY date_and_time DESC', $max, $start); $max_rows = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)', array('used' => 1)); $content = new ocp_tempcode(); foreach ($rows as $myrow) { $date = get_timezoned_date($myrow['date_and_time']); $url = build_url(array('page' => '_SELF', 'type' => 'view', 'wide' => 1, 'id' => $myrow['id']), '_SELF'); $thumb_url = $myrow['thumb_url']; $caption = get_translated_tempcode($myrow['i_title']); require_code('images'); $thumb_url = ensure_thumbnail($myrow['url'], $thumb_url, 'iotds', 'iotd', $myrow['id']); $thumb = do_image_thumb($thumb_url, ''); $content->attach(do_template('IOTD_VIEW_SCREEN_IOTD', array('SUBMITTER' => strval($myrow['submitter']), 'ID' => strval($myrow['id']), 'VIEWS' => integer_format($myrow['iotd_views']), 'THUMB' => $thumb, 'DATE' => $date, 'DATE_RAW' => strval($myrow['date_and_time']), 'URL' => $url, 'CAPTION' => $caption))); } if ($content->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $page_num = intval(floor(floatval($start) / floatval($max))) + 1; $num_pages = intval(ceil(floatval($max_rows) / floatval($max))); $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max == 0 ? NULL : $start - $max), '_SELF'); $next_url = count($rows) != $max ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF'); $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => 'b6933ab44e16fef7e1bec62014254383', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages))); return do_template('NEXT_BROWSER_SCREEN', array('_GUID' => 'd8a493c2b007d98074f104ea433c8091', 'TITLE' => $title, 'CONTENT' => $content, 'BROWSE' => $browse)); }
/** * Get tempcode for a Comcode rich-media attachment. * * @param ID_TEXT The attachment tag * @set attachment attachment_safe attachment2 * @param array A map of the attributes (name=>val) for the tag * @param array A map of the attachment properties (name=>val) for the attachment * @param string A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post) * @param MEMBER The member who is responsible for this Comcode * @param boolean Whether to check as arbitrary admin * @param object The database connection to use * @param ?array A list of words to highlight (NULL: none) * @param ?MEMBER The member we are running on behalf of, with respect to how attachments are handled; we may use this members attachments that are already within this post, and our new attachments will be handed to this member (NULL: member evaluating) * @param boolean Whether to parse so as to create something that would fit inside a semihtml tag. It means we generate HTML, with Comcode written into it where the tag could never be reverse-converted (e.g. a block). * @return tempcode The tempcode for the attachment */ function render_attachment($tag, $attributes, $attachment, $pass_id, $source_member, $as_admin, $connection, $highlight_bits = NULL, $on_behalf_of_member = NULL, $semiparse_mode = false) { require_code('comcode_renderer'); $extension = get_file_extension($attachment['a_original_filename']); require_code('mime_types'); $mime_type = get_mime_type($extension); $attachment['CLEAN_SIZE'] = clean_file_size($attachment['a_file_size']); $attachment['MIME_TYPE'] = $mime_type; $attachment['PASS_ID'] = intval($pass_id) < 0 ? strval(mt_rand(0, 10000)) : $pass_id; $attachment['SCRIPT'] = find_script('attachment'); $attachment['RAND'] = strval(mt_rand(0, 32000)); if ($connection->connection_write != $GLOBALS['SITE_DB']->connection_write) { $attachment['SUP_PARAMS'] = '&forum_db=1'; $attachment['FORUM_DB_BIN'] = '1'; } else { $attachment['SUP_PARAMS'] = ''; $attachment['FORUM_DB_BIN'] = ''; } $type = trim(array_key_exists('type', $attributes) ? $attributes['type'] : 'auto'); $attachment['id'] = strval($attachment['id']); $attachment['a_member_id'] = strval($attachment['a_member_id']); $attachment['a_file_size'] = strval($attachment['a_file_size']); $attachment['a_last_downloaded_time'] = is_null($attachment['a_last_downloaded_time']) ? '' : strval($attachment['a_last_downloaded_time']); $attachment['a_add_time'] = strval($attachment['a_add_time']); $attachment['a_num_downloads'] = integer_format($attachment['a_num_downloads']); require_code('images'); $attachment['a_width'] = array_key_exists('width', $attributes) ? strval(intval($attributes['width'])) : ''; $attachment['a_height'] = array_key_exists('height', $attributes) ? strval(intval($attributes['height'])) : ''; if ($attachment['a_width'] == '' || $attachment['a_height'] == '') { if (addon_installed('galleries') && is_video($attachment['a_original_filename']) && url_is_local($attachment['a_url'])) { require_code('galleries2'); $vid_details = get_video_details(get_custom_file_base() . '/' . rawurldecode($attachment['a_url']), $attachment['a_original_filename'], true); if ($vid_details !== false) { list($_width, $_height, ) = $vid_details; if ($attachment['a_width'] == '') { $attachment['a_width'] = strval($_width); } if ($attachment['a_height'] == '') { $attachment['a_height'] = strval($_height); } } } if ($attachment['a_width'] == '' || $attachment['a_height'] == '') { if ($attachment['a_width'] == '') { $attachment['a_width'] = '240'; } if ($attachment['a_height'] == '') { $attachment['a_height'] = '216'; } } } $attachment['a_align'] = array_key_exists('align', $attributes) ? $attributes['align'] : 'left'; if (!array_key_exists('a_description', $attachment)) { if (array_key_exists('description', $attributes)) { $attachment['description'] = $attributes['description']; } if (!array_key_exists('description', $attachment)) { $attachment['description'] = ''; } $attachment['a_description'] = is_object($attachment['description']) ? $attachment['description'] : comcode_to_tempcode($attachment['description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member); } else { $attachment['a_description'] = comcode_to_tempcode($attachment['a_description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member); } $attachment['a_type'] = $type; $attachment['a_thumb'] = array_key_exists('thumb', $attributes) ? $attributes['thumb'] : '1'; if ($attachment['a_thumb'] != '0') { $attachment['a_thumb'] = '1'; } $attachment['a_thumb_url'] = array_key_exists('thumb_url', $attributes) ? $attributes['thumb_url'] : $attachment['a_thumb_url']; switch ($type) { case 'email': require_code('mail'); global $EMAIL_ATTACHMENTS; if (url_is_local($attachment['a_url'])) { $attachment['a_url'] = get_custom_base_url() . '/' . $attachment['a_url']; } $EMAIL_ATTACHMENTS[$attachment['a_url']] = $attachment['a_original_filename']; $temp_tpl = new ocp_tempcode(); break; case 'code': $url = $attachment['a_url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $file_contents = http_download_file($url, 1024 * 1024 * 20); list($_embed, $title) = do_code_box($extension, make_string_tempcode($file_contents)); if ($attachment['a_original_filename'] != '') { $title = escape_html($attachment['a_original_filename']); } $temp_tpl = do_template('COMCODE_CODE', array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'STYLE' => '', 'TYPE' => $extension, 'CONTENT' => $_embed, 'TITLE' => $title)); break; case 'hyperlink': if ($tag == 'attachment') { $keep = symbol_tempcode('KEEP'); $_url = new ocp_tempcode(); $_url->attach(find_script('attachment') . '?id=' . urlencode($attachment['id']) . $keep->evaluate()); if (get_option('anti_leech') == '1') { $_url->attach('&for_session='); $_url->attach(symbol_tempcode('SESSION_HASHED')); } } else { $url = $attachment['a_url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $_url = make_string_tempcode($url); } $temp_tpl = hyperlink($_url, is_object($attachment['a_description']) ? $attachment['a_description']->evaluate() : $attachment['a_description'] != '' ? $attachment['a_description'] : $attachment['a_original_filename'], true); break; default: if (is_image($attachment['a_original_filename'])) { if ($type == 'inline' || $type == 'left_inline' || $type == 'right_inline') { $attachment['mini'] = '1'; } require_code('images'); ensure_thumbnail($attachment['a_url'], $attachment['a_thumb_url'], 'attachments', 'attachments', intval($attachment['id']), 'a_thumb_url'); $temp_tpl = do_template('ATTACHMENT_IMG' . (array_key_exists('mini', $attachment) && $attachment['mini'] == '1' ? '_MINI' : ''), map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); if ($type == 'left' || $type == 'left_inline') { $temp_tpl = do_template('ATTACHMENT_LEFT', array('_GUID' => 'aee2a6842d369c8dae212c3478a3a3e9', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl)); } if ($type == 'right' || $type == 'right_inline') { $temp_tpl = do_template('ATTACHMENT_RIGHT', array('_GUID' => '1a7209d67d91db740c86e7a331720195', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl)); } break; } elseif ($extension == 'swf') { $temp_tpl = do_template('ATTACHMENT_SWF', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif (addon_installed('jwplayer') && ($mime_type == 'video/x-flv' || $mime_type == 'video/mp4' || $mime_type == 'video/webm')) { $temp_tpl = do_template('ATTACHMENT_FLV', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif ($mime_type == 'video/quicktime') { $temp_tpl = do_template('ATTACHMENT_QT', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif ($mime_type == 'audio/x-pn-realaudio') { $temp_tpl = do_template('ATTACHMENT_RM', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } elseif (substr($mime_type, 0, 5) == 'video' || substr($mime_type, 0, 5) == 'audio') { $temp_tpl = do_template('ATTACHMENT_MEDIA', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); break; } // Continues on, as it's not a media type... // Continues on, as it's not a media type... case 'download': if (is_null($attachment['a_file_size'])) { $temp_tpl = do_template('ATTACHMENT_DOWNLOAD_REMOTE', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); } else { $temp_tpl = do_template('ATTACHMENT_DOWNLOAD', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true)); } break; } return $temp_tpl; }
/** * The UI for an "regular mode" gallery. * * @param tempcode Rating area * @param tempcode Commenting area * @param ID_TEXT Our gallery ID * @param ID_TEXT Virtual root gallery * @param tempcode The description of the gallery * @param tempcode The tempcode for our visible child galleries * @param boolean Whether may "download this gallery" * @param tempcode The URL to "edit this gallery" * @param tempcode The URL to "add a gallery" * @param tempcode The URL to "submit an image to this gallery" * @param tempcode The URL to "submit a video to this gallery" * @param tempcode The title of the page (our of get_page_title) * @param string The gallery title * @param tempcode Sorting UI * @return tempcode The UI */ function do_gallery_regular_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $fullname, $sorting) { $max = get_param_integer('max', get_default_gallery_max()); $start = get_param_integer('start', 0); if ($max < 1) { $max = 1; } $page_num = $max == 0 ? 0 : intval(floor(floatval($start) / floatval($max))) + 1; // Work out totals $num_images = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)', array('cat' => $cat)); $num_videos = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)', array('cat' => $cat)); $total_rows = $num_images + $num_videos; $total_pages = $max == 0 ? 1 : intval(ceil(floatval($total_rows) / floatval($max))); if ($total_pages == 0) { $total_pages = 1; } list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order(); $where = db_string_equal_to('cat', $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where .= ' AND validated=1'; } if (get_param('days', '') != '') { $where .= ' AND add_date>' . strval(time() - get_param_integer('days') * 60 * 60 * 24); } $rows = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_videos . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $where . ' ORDER BY ' . $sort, $max, $start); if (count($rows) < $max) { $where = db_string_equal_to('cat', $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where .= ' AND validated=1'; } $rows2 = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_images . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $where . ' ORDER BY ' . $sort, $max - count($rows), max(0, $start - $num_videos)); } else { $rows2 = array(); } $entries = new ocp_tempcode(); $image_select = get_param('select', '*'); $video_select = get_param('video_select', '*'); // Display videos foreach ($rows as $row_video) { $view_url = build_url(array('page' => '_SELF', 'type' => 'video', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_video['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $start == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF'); $thumb_url = ensure_thumbnail($row_video['url'], $row_video['thumb_url'], 'galleries', 'videos', $row_video['id']); if ($thumb_url == '') { $thumb_url = find_theme_image('na'); } $thumb = do_image_thumb($thumb_url, '', true); $this_full_url = $row_video['url']; if (url_is_local($this_full_url)) { $this_full_url = get_custom_base_url() . '/' . $this_full_url; } $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL; $map = array('_GUID' => '395f0aa1212e69da5752d228a6efe54d', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_video['id']), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date']), 'SUBMITTER' => strval($row_video['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIDEO_DETAILS' => show_video_details($row_video)); $entry = do_template('GALLERY_VIDEO', $map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'bc0d3de5d0160b00e3250d78658888c1', 'ENTRY' => $entry) + $map)); } // Display images foreach ($rows2 as $row_image) { $view_url = build_url(array('page' => '_SELF', 'type' => 'image', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_image['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $max == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF'); $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']); $thumb = do_image_thumb($thumb_url, '', true); $this_full_url = $row_image['url']; if (url_is_local($this_full_url)) { $file_size = file_exists(get_custom_file_base() . '/' . rawurldecode($this_full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($this_full_url))) : ''; $this_full_url = get_custom_base_url() . '/' . $this_full_url; } else { $file_size = ''; } $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL; $map = array('_GUID' => 'aa70f543297e25379c49fa25d6dbcac0', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'FILE_SIZE' => $file_size, 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_image['id']), 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date']), 'SUBMITTER' => strval($row_image['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url); $entry = do_template('GALLERY_IMAGE', $map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'ea12d7acf47eab493b6fb4658b3c0346', 'ENTRY' => $entry) + $map)); } // Member gallery? $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); // Results browser require_code('templates_results_browser'); $_selectors = array_map('intval', explode(',', get_option('gallery_selectors'))); $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'start', $max, 'max', $total_rows, $root, 'misc', true, false, 10, $_selectors); return do_template('GALLERY_REGULAR_MODE_SCREEN', array('_GUID' => 'cec405597f47f5079b7c7f581fa6b5c2', 'SORTING' => $sorting, '_TITLE' => $fullname, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'RESULTS_BROWSER' => $results_browser, 'TAGS' => get_loaded_tags('galleries'), 'CAT' => $cat, 'MEMBER_DETAILS' => $member_details, 'RATING_DETAILS' => $rating_details, 'COMMENT_DETAILS' => $comment_details, 'ADD_GALLERY_URL' => $add_gallery_url, 'EDIT_URL' => $edit_url, 'CHILDREN' => $children, 'TITLE' => $title, 'DESCRIPTION' => $description, 'IMAGE_URL' => $submit_image_url, 'VIDEO_URL' => $submit_video_url, 'MAY_DOWNLOAD' => $may_download, 'ENTRIES' => $entries)); }
/** * Get tempcode for a download 'feature box' for the sgiven row * * @param array The database field row of this download * @param boolean Whether to show a picture * @param boolean Whether to show breadcrumbs * @param ?ID_TEXT The zone the download module we're using is in (NULL: find it) * @param ?string Text summary for result (e.g. highlighted portion of actual file from search result) (NULL: none) * @return tempcode A box for this download, linking to the full download page */ function get_download_html($row, $pic = true, $breadcrumbs = true, $zone = NULL, $text_summary = NULL) { require_css('downloads'); if (is_null($zone)) { $zone = get_module_zone('downloads'); } // Details $filesize = $row['file_size']; $filesize = $filesize > 0 ? clean_file_size($filesize) : do_lang('UNKNOWN'); $description = get_translated_tempcode($row['description']); $root = get_param_integer('root', db_get_first_id(), true); $download_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $row['id'], 'root' => $root == db_get_first_id() ? NULL : $root), $zone); $date = get_timezoned_date($row['add_date'], false); $date_raw = $row['add_date']; $tree = get_option('show_dload_trees') == '1' && $breadcrumbs ? download_breadcrumbs($row['category_id'], NULL, false, $zone) : new ocp_tempcode(); $pic_suffix = ''; $thumb_url = ''; $full_img_url = ''; if (addon_installed('galleries') && $pic) { // Images $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url', 'id'), array('cat' => 'download_' . strval($row['id'])), '', 1, $row['default_pic'] - 1); if (array_key_exists(0, $rows)) { $pic_suffix = '_pic'; require_code('images'); $full_img_url = $rows[0]['url']; $thumb_url = ensure_thumbnail($rows[0]['url'], $rows[0]['thumb_url'], 'galleries', 'images', $rows[0]['id']); $imgcode = do_image_thumb($thumb_url, do_lang('DOWNLOAD_THUMBNAIL')); } else { $imgcode = new ocp_tempcode(); } } else { $imgcode = new ocp_tempcode(); } require_code('feedback'); $rating = $row['allow_rating'] == 1 ? display_rating($download_url, get_translated_text($row['name']), 'downloads', strval($row['id']), 'RATING_INLINE_STATIC', $row['submitter']) : NULL; if (!is_null($rating)) { if (trim($rating->evaluate()) == '') { $rating = NULL; } } $licence_title = NULL; $licence_url = NULL; $licence_hyperlink = NULL; $licence = $row['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 } } // Final template if ($full_img_url != '' && url_is_local($full_img_url)) { $full_img_url = get_custom_base_url() . '/' . $full_img_url; } return do_template('DOWNLOAD_BOX', array('TEXT_SUMMARY' => $text_summary, 'AUTHOR' => $row['author'], 'ID' => strval($row['id']), 'RATING' => $rating, 'VIEWS' => integer_format($row['download_views']), 'SUBMITTER' => strval($row['submitter']), 'DESCRIPTION' => $description, 'FILE_SIZE' => $filesize, 'DOWNLOADS' => integer_format($row['num_downloads']), 'DATE_RAW' => strval($date_raw), 'DATE' => $date, 'EDIT_DATE_RAW' => is_null($row['edit_date']) ? '' : strval($row['edit_date']), 'SIZE' => $filesize, 'URL' => $download_url, 'NAME' => get_translated_text($row['name']), 'TREE' => $tree, 'IMG_URL' => $thumb_url, 'FULL_IMG_URL' => $full_img_url, 'IMGCODE' => $imgcode, 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink)); }
/** * 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)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('iotds'); require_css('iotds'); $mode = array_key_exists('param', $map) ? $map['param'] : 'current'; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('iotds'); if (has_actual_page_access(NULL, 'cms_iotds', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_iotds')) { $submit_url = build_url(array('page' => 'cms_iotds', 'type' => 'ad', 'redirect' => SELF_REDIRECT), get_module_zone('cms_iotds')); } else { $submit_url = new ocp_tempcode(); } if ($mode == 'current') { $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('is_current' => 1), 'ORDER BY id DESC', 1); } elseif (is_numeric($mode)) { $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('id' => intval($mode)), '', 1); if (!array_key_exists(0, $iotd)) { return do_template('BLOCK_NO_ENTRIES', array('HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url)); } } else { $cnt = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)', array('used' => 1)); if ($cnt == 0) { return do_template('BLOCK_NO_ENTRIES', array('HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url)); } $at = mt_rand(0, $cnt - 1); $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('used' => 1), '', 1, $at); } if (!array_key_exists(0, $iotd)) { return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '62baa388e068d4334f7a6c6093ead56a', 'HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url)); } $myrow = $iotd[0]; $image_url = $myrow['url']; if (url_is_local($image_url)) { $image_url = get_custom_base_url() . '/' . $image_url; } $view_url = build_url(array('page' => 'iotds', 'wide' => 1, 'type' => 'view', 'id' => $myrow['id']), $zone); require_code('images'); $thumb_url = ensure_thumbnail($myrow['url'], $myrow['thumb_url'], 'iotds', 'iotd', $myrow['id']); $caption = get_translated_tempcode($myrow['i_title']); $image = do_image_thumb($thumb_url, do_lang('IOTD')); $archive_url = build_url(array('page' => 'iotds', 'type' => 'misc'), $zone); $tpl = do_template('IOTD', array('_GUID' => 'ca9c4b4941c12c15f7bdfe4cb57cd266', 'ID' => strval($myrow['id']), 'IMAGE_URL' => $image_url, 'SUBMITTER' => strval($myrow['submitter']), 'VIEW_URL' => $view_url, 'CAPTION' => $caption, 'IMAGE' => $image)); $map2 = array('_GUID' => 'd710da3675a1775867168ae37db02ad4', 'CURRENT' => $mode == 'current', 'FULL_URL' => $view_url, 'ID' => strval($myrow['id']), 'CONTENT' => $tpl, 'ARCHIVE_URL' => $archive_url, 'SUBMIT_URL' => $submit_url); if (get_option('is_on_comments') == '1' && get_forum_type() != 'none' && $myrow['allow_comments'] >= 1) { $map2['COMMENT_COUNT'] = '1'; } return do_template('BLOCK_MAIN_IOTD', $map2); }
/** * Get preview detailing for a gallery. * * @param array The database row of the gallery * @param ID_TEXT The virtual root of the gallery * @param boolean Whether to show member stats if it is a member owned gallery * @param ID_TEXT The zone that the gallery module we are linking to is in * @param boolean Whether to not show anything if the gallery is empty * @param boolean Whether only to show 'preview' details * @return tempcode The preview */ function show_gallery_box($child, $root = 'root', $show_member_stats_if_appropriate = false, $zone = '_SEARCH', $quit_if_empty = true, $preview = false) { $member_id = get_member_id_from_gallery_name($child['name'], $child, true); $url = build_url(array('page' => 'galleries', 'type' => 'misc', 'root' => $root == 'root' ? NULL : $root, 'id' => $child['name']), $zone); $_title = get_translated_text($child['fullname']); $pic = $child['rep_image']; $is_member = !is_null($member_id); if ($pic == '' && $is_member) { $pic = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id); } $add_date = get_timezoned_date($child['add_date'], false); $comments = get_translated_tempcode($child['description']); if ($show_member_stats_if_appropriate) { if ($is_member && get_forum_type() == 'ocf') { require_code('ocf_members'); require_code('ocf_members2'); $member_info = ocf_show_member_box($member_id, true); } else { $member_info = new ocp_tempcode(); } } else { $member_info = new ocp_tempcode(); } list($num_children, $num_images, $num_videos) = get_recursive_gallery_details($child['name']); if ($quit_if_empty && $num_images == 0 && $num_videos == 0 && $num_children == 0) { return new ocp_tempcode(); } $thumb_order = 'ORDER BY id ASC'; if (get_option('reverse_thumb_order') == '1') { $thumb_order = 'ORDER BY id DESC'; } if ($pic == '') { $pic = $GLOBALS['SITE_DB']->query_value_null_ok('images', 'thumb_url', array('cat' => $child['name'], 'validated' => 1), $thumb_order); if ($pic === '') { require_code('images'); $temp = $GLOBALS['SITE_DB']->query_select('images', array('id', 'url'), array('cat' => $child['name'], 'validated' => 1), $thumb_order, 1); $thumb_url = ensure_thumbnail($temp[0]['url'], '', 'galleries', 'images', $temp[0]['id']); } } if (is_null($pic)) { $pic = $GLOBALS['SITE_DB']->query_value_null_ok('videos', 'thumb_url', array('cat' => $child['name'], 'validated' => 1), $thumb_order); } if (is_null($pic)) { $pic = ''; } if ($pic != '' && url_is_local($pic)) { $pic = get_custom_base_url() . '/' . $pic; } if ($pic != '') { require_code('images'); $thumb = do_image_thumb($pic, ''); } else { $thumb = new ocp_tempcode(); } if ($num_children == 0) { if ($child['accept_videos'] == 0) { $lang = do_lang_tempcode('_SUBGALLERY_BITS_IMAGES', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos)); } elseif ($child['accept_images'] == 0) { $lang = do_lang_tempcode('_SUBGALLERY_BITS_VIDEOS', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos)); } else { $lang = do_lang_tempcode('_SUBGALLERY_BITS', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos)); } } else { if ($child['accept_videos'] == 0) { $lang = do_lang_tempcode('SUBGALLERY_BITS_IMAGES', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos))); } elseif ($child['accept_images'] == 0) { $lang = do_lang_tempcode('SUBGALLERY_BITS_VIDEOS', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos))); } else { $lang = do_lang_tempcode('SUBGALLERY_BITS', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos))); } } $tpl = do_template('GALLERY_SUBGALLERY', array('_GUID' => '0dbec2f11de63b0402471fe5c8b32865', 'NUM_VIDEOS' => strval($num_videos), 'NUM_IMAGES' => strval($num_images), 'NUM_CHILDREN' => strval($num_children), 'ID' => $child['name'], 'LANG' => $lang, 'ADD_DATE' => $add_date, 'ADD_DATE_RAW' => strval($child['add_date']), 'MEMBER_INFO' => $member_info, 'URL' => $url, 'THUMB' => $thumb, 'PIC' => $pic, 'TITLE' => $_title, 'COMMENTS' => $comments)); return $tpl; }
/** * Get the photo thumbnail URL for the specified member id. * * @param MEMBER The member id * @return URLPATH The URL (blank: none) */ function get_member_photo_url($member) { if (!addon_installed('ocf_member_photos')) { if (!addon_installed('ocf_member_avatars')) { return ''; } return $this->get_member_avatar_url($member); } $pic = $this->get_member_row_field($member, 'm_photo_thumb_url'); if ($pic == '') { $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_photo_url'); if ($photo_url != '') { require_code('images'); $pic = ensure_thumbnail($photo_url, $pic, strpos($photo_url, 'uploads/photos') !== false ? 'photos' : 'ocf_photos', 'f_members', $member, 'm_photo_thumb_url'); } } if (is_null($pic)) { $pic = ''; } elseif (url_is_local($pic) && $pic != '') { $pic = get_complex_base_url($pic) . '/' . $pic; } return $pic; }
/** * Get an interface for choosing an IOTD. * * @param BINARY Whether to show used IOTDs * @param BINARY Whether to show the current IOTD * @param ?MEMBER The member to only show iotds submitted-by (NULL: do not filter) * @return tempcode The UI */ function nice_get_iotds_link($used = 0, $current = 0, $submitter = NULL) { require_code('images'); $where = array('used' => $used, 'is_current' => $current); if (!is_null($submitter)) { $where['submitter'] = $submitter; } $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('i_title', 'submitter', 'is_current', 'used', 'id', 'thumb_url', 'url'), $where, 'ORDER BY id DESC', 100); if (count($rows) == 100) { $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('i_title', 'submitter', 'is_current', 'used', 'id', 'thumb_url', 'url'), $where, 'ORDER BY add_date DESC', 100); } $previews = new ocp_tempcode(); foreach ($rows as $myrow) { $caption = get_translated_tempcode($myrow['i_title']); $choose_url = build_url(array('page' => '_SELF', 'type' => '_choose'), '_SELF'); $delete_url = build_url(array('page' => '_SELF', 'type' => '_delete'), '_SELF'); $edit_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'id' => $myrow['id']), '_SELF'); $submitter = $myrow['submitter']; $username_link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($submitter); $username = $GLOBALS['FORUM_DRIVER']->get_username($submitter); $thumb_url = ensure_thumbnail($myrow['url'], $myrow['thumb_url'], 'iotds', 'iotd', $myrow['id']); $full_url = build_url(array('page' => 'iotds', 'type' => 'view', 'wide' => 1, 'id' => $myrow['id']), get_module_zone('iotds')); $previews->attach(do_template('IOTD_ADMIN_CHOOSE_SCREEN_IOTD', array('_GUID' => 'a6479902d2cd7b4119be7159147e0a0b', 'IS_CURRENT' => $current == 1, 'USERNAME_LINK' => $username_link, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $full_url, 'ID' => strval($myrow['id']), 'EDIT_URL' => $edit_url, 'DELETE_URL' => $delete_url, 'CHOOSE_URL' => $choose_url, 'CAPTION' => $caption, 'USER' => strval($submitter), 'USERNAME' => $username))); } if ($previews->is_empty() && $current == 1) { return new ocp_tempcode(); } return $previews; }
/** * Standard modular run function for rendering a search result. * * @param array The data row stored when we retrieved the result * @return tempcode The output */ function render($row) { require_code('images'); $url = build_url(array('page' => 'iotds', 'type' => 'view', 'id' => $row['id']), get_module_zone('iotds')); $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'iotds', 'iotd', $row['id']); return put_in_standard_box(hyperlink($url, do_image_thumb($thumb_url, get_translated_tempcode($row['i_title']), true)), do_lang_tempcode('IOTD')); }
/** * Standard modular run function for ajax-tree hooks. Generates XML for a tree list, which is interpreted by Javascript and expanded on-demand (via new calls). * * @param ?ID_TEXT The ID to do under (NULL: root) * @param array Options being passed through * @param ?ID_TEXT The ID to select by default (NULL: none) * @return string XML in the special category,entry format */ function run($id, $options, $default = NULL) { require_code('downloads'); if (!is_numeric($id) && $id != '') { if (substr($id, 0, 8) == 'Version ') { $id_float = floatval(substr($id, 8)); do { $str = 'Version ' . float_to_raw_string($id_float, 1); $_id = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON t.id=c.category', 'c.id', array('parent_id' => 3, 'text_original' => $str)); if (is_null($_id)) { $id_float -= 0.1; } } while (is_null($_id) && $id_float != 0.0); } else { $_id = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON t.id=c.category', 'c.id', array('text_original' => $id)); } if (is_null($_id)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $id = strval($_id); } $only_owned = array_key_exists('only_owned', $options) ? is_null($options['only_owned']) ? NULL : intval($options['only_owned']) : NULL; $shun = array_key_exists('shun', $options) ? $options['shun'] : NULL; $editable_filter = array_key_exists('editable_filter', $options) ? $options['editable_filter'] : false; $tar_filter = array_key_exists('tar_filter', $options) ? $options['original_filename'] : false; $tree = get_downloads_tree($only_owned, is_null($id) ? NULL : intval($id), NULL, NULL, $shun, is_null($id) ? 0 : 1, false, $editable_filter, $tar_filter); if (!has_actual_page_access(NULL, 'downloads')) { $tree = array(); } $file_type = get_param('file_type', ''); $out = ''; foreach ($tree as $t) { $_id = $t['id']; if ($id === strval($_id)) { asort($t['entries']); foreach ($t['entries'] as $eid => $etitle) { $row = $GLOBALS['SITE_DB']->query_select('download_downloads', array('description', 'original_filename'), array('id' => $eid), '', 1); if ($file_type != '') { if (substr($row[0]['original_filename'], -strlen($file_type) - 1) != '.' . $file_type) { continue; } } $lang_id = $row[0]['description']; $description = get_translated_text($lang_id); $description_html = get_translated_tempcode($lang_id); $images_details = new ocp_tempcode(); if (addon_installed('galleries')) { // Images $_out = new ocp_tempcode(); require_lang('galleries'); $cat = 'download_' . strval($eid); $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); $counter = 0; $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 (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, ''); $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 = put_in_standard_box($_out); } $description_html->attach($images_details); $out .= '<entry id="' . xmlentities(strval($eid)) . '" description="' . xmlentities(strip_comcode($description)) . '" description_html="' . xmlentities($description_html->evaluate()) . '" title="' . xmlentities($etitle) . '" selectable="true"></entry>'; } continue; } $title = $t['title']; $has_children = $t['child_count'] != 0 || $t['child_entry_count'] != 0; $out .= '<category id="' . xmlentities(strval($_id)) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="false"></category>'; } // Mark parent cats for pre-expansion if (!is_null($default) && $default != '') { $cat = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'category_id', array('id' => intval($default))); while (!is_null($cat)) { $out .= '<expand>' . strval($cat) . '</expand>'; $cat = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories', 'parent_id', array('id' => $cat)); } } return '<result>' . $out . '</result>'; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_css('galleries'); require_lang('galleries'); require_code('galleries'); require_code('images'); require_code('feedback'); require_code('ocfiltering'); $cat = array_key_exists('param', $map) ? $map['param'] : 'root'; $cat_select = ocfilter_to_sqlfragment($cat, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false); $title = array_key_exists('title', $map) ? $map['title'] : ''; /*if ((file_exists(get_custom_file_base().'/themes/default/templates_custom/JAVASCRIPT_GALLERIES.tpl')) || (file_exists(get_file_base().'/themes/default/templates/JAVASCRIPT_GALLERIES.tpl'))) require_javascript('javascript_galleries');*/ $max = get_param_integer('mge_max', array_key_exists('max', $map) ? intval($map['max']) : 30); $start = get_param_integer('mge_start', 0); if (!array_key_exists('select', $map)) { $map['select'] = '*'; } $image_select = ocfilter_to_sqlfragment($map['select'], 'id'); if (!array_key_exists('video_select', $map)) { $map['video_select'] = '*'; } $video_select = ocfilter_to_sqlfragment($map['video_select'], 'id'); $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries'); $_days = array_key_exists('days', $map) ? $map['days'] : ''; $days = mixed(); $days = $_days == '' ? NULL : intval($_days); $where_sup = ''; if (!is_null($days)) { $where_sup .= ' AND add_date>=' . strval(time() - $days * 60 * 60 * 24); } $sort = array_key_exists('sort', $map) ? $map['sort'] : 'add_date DESC'; if ($sort != 'random ASC' && $sort != 'fixed_random ASC' && $sort != 'compound_rating DESC' && $sort != 'compound_rating ASC' && $sort != 'add_date DESC' && $sort != 'add_date ASC' && $sort != 'url DESC' && $sort != 'url ASC') { $sort = 'add_date DESC'; } list($_sort, $_dir) = explode(' ', $sort, 2); $total_images = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'images WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup); $total_videos = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'videos WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup); if ($_sort == 'random') { $start = 0; $max = min($total_images + $total_videos, $max); $done_images = '1=1'; $done_videos = '1=1'; $rows_images = array(); $rows_videos = array(); for ($i = 0; $i < $max; $i++) { if (mt_rand(0, 1) == 0 || $total_videos - count($rows_videos) == 0) { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'images e WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup . ' AND ' . $done_images, 1, mt_rand(0, $total_images - count($rows_images) - 1)); $rows_images[] = $rows[0]; $done_images .= ' AND '; $done_images .= 'id<>' . strval($rows[0]['id']); } else { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'videos e WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup . ' AND ' . $done_videos, 1, mt_rand(0, $total_videos - count($rows_videos) - 1)); $rows_videos[] = $rows[0]; $done_videos .= ' AND '; $done_videos .= 'id<>' . strval($rows[0]['id']); } } } else { if ($_sort == 'compound_rating') { $rating_sort = ',(SELECT AVG(rating) FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'images') . ' AND rating_for_id=e.id) AS compound_rating'; } elseif ($_sort == 'fixed_random') { $rating_sort = ',(MOD(id,3.142)) AS fixed_random'; } else { $rating_sort = ''; } $rows_images = $GLOBALS['SITE_DB']->query('SELECT *' . $rating_sort . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup . ' ORDER BY ' . $sort, $max + $start); if ($_sort == 'compound_rating') { $rating_sort = ',(SELECT AVG(rating) FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'videos') . ' AND rating_for_id=e.id) AS compound_rating'; } elseif ($_sort == 'fixed_random') { $rating_sort = ',(MOD(id,3.142)) AS fixed_random'; } else { $rating_sort = ''; } $rows_videos = $GLOBALS['SITE_DB']->query('SELECT *' . $rating_sort . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup . ' ORDER BY ' . $sort, $max + $start); } // Sort $combined = array(); foreach ($rows_images as $row_image) { $combined[] = array($row_image, 'image', $_sort == 'random' ? NULL : $row_image[$_sort]); } foreach ($rows_videos as $row_video) { $combined[] = array($row_video, 'video', $_sort == 'random' ? NULL : $row_video[$_sort]); } if ($_sort == 'random') { shuffle($combined); } else { global $M_SORT_KEY; $M_SORT_KEY = 2; usort($combined, 'multi_sort'); if ($_dir == 'DESC') { $combined = array_reverse($combined); } } // Display $entries = new ocp_tempcode(); foreach ($combined as $i => $c) { if ($i >= $start) { switch ($c[1]) { case 'image': // Display image $row_image = $c[0]; $view_url = build_url(array('page' => 'galleries', 'type' => 'image', 'wide' => 1, 'id' => $row_image['id']), $zone); $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']); $thumb = do_image_thumb($thumb_url, '', true); $full_url = $row_image['url']; $file_size = url_is_local($full_url) ? file_exists(get_custom_file_base() . '/' . rawurldecode($full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($full_url))) : '' : ''; if (url_is_local($full_url)) { $full_url = get_custom_base_url() . '/' . $full_url; } $thumb_url = $row_image['thumb_url']; if (url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating($view_url, get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL; $entry_map = array('_GUID' => '043ac7d15ce02715ac02309f6e8340ff', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'ID' => strval($row_image['id']), 'FILE_SIZE' => $file_size, 'SUBMITTER' => strval($row_image['submitter']), 'FULL_URL' => $full_url, 'THUMB_URL' => $thumb_url, 'CAT' => $cat, 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date'])); $entry = do_template('GALLERY_IMAGE', $entry_map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => '13134830e1ebea158ab44885eeec0953', 'ENTRY' => $entry) + $entry_map)); break; case 'video': // Display video $row_video = $c[0]; $view_url = build_url(array('page' => 'galleries', 'type' => 'video', 'wide' => 1, 'id' => $row_video['id']), $zone); $thumb_url = $row_video['thumb_url']; if ($thumb_url != '' && url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } if ($thumb_url == '') { $thumb_url = find_theme_image('na'); } $thumb = do_image_thumb($thumb_url, '', true); $full_url = $row_video['url']; if (url_is_local($full_url)) { $full_url = get_custom_base_url() . '/' . $full_url; } $thumb_url = $row_video['thumb_url']; if ($thumb_url != '' && url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating($view_url, get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL; $entry_map = array('_GUID' => '66b7fb4d3b61ef79d6803c170d102cbf', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'ID' => strval($row_video['id']), 'CAT' => $cat, 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'SUBMITTER' => strval($row_video['submitter']), 'FULL_URL' => $full_url, 'THUMB_URL' => $thumb_url, 'VIDEO_DETAILS' => show_video_details($row_video), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date'])); $entry = do_template('GALLERY_VIDEO', $entry_map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'a0ff010ae7fd1f7b3341993072ed23cf', 'ENTRY' => $entry) + $entry_map)); break; } } $i++; if ($i == $start + $max) { break; } } if (!isset($map['render_if_empty']) || $map['render_if_empty'] != '1') { if ($entries->is_empty()) { if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_galleries', array('galleries', $cat))) { $submit_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => $cat, 'redirect' => SELF_REDIRECT), get_module_zone('cms_galleries')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'bf84d65b8dd134ba6cd7b1b7bde99de2', 'HIGH' => false, 'TITLE' => do_lang_tempcode('GALLERY'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IMAGE'), 'SUBMIT_URL' => $submit_url)); } } // Results browser require_code('templates_results_browser'); $_selectors = array_map('intval', explode(',', get_option('gallery_selectors'))); $root = get_param('root', 'root'); $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'mge_start', $max, 'mge_max', $total_videos + $total_images, $root, 'misc', true, false, 10, $_selectors); $tpl = do_template('BLOCK_MAIN_GALLERY_EMBED', array('_GUID' => 'b7b969c8fe8c398dd6e3af7ee06717ea', 'IMAGE_SELECT' => $map['select'], 'VIDEO_SELECT' => $map['video_select'], 'DAYS' => $_days, 'SORT' => $sort, 'BLOCK_PARAMS' => block_params_arr_to_str($map), 'RESULTS_BROWSER' => $results_browser, 'TITLE' => $title, 'CAT' => $cat, 'IMAGES' => $entries, 'MAX' => strval($max), 'ZONE' => $zone, 'TOTAL_VIDEOS' => strval($total_videos), 'TOTAL_IMAGES' => strval($total_images), 'TOTAL' => strval($total_videos + $total_images))); return $tpl; }