/** * 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 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('downloads')) { return NULL; } $filters = ocfilter_to_sqlfragment($_filters, 'category_id', 'download_categories', 'parent_id', 'category_id', 'id'); // 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('downloads'); if (!has_actual_page_access(get_member(), 'downloads')) { return NULL; } $content = new ocp_tempcode(); $_categories = $GLOBALS['SITE_DB']->query_select('download_categories', array('id', 'category'), NULL, '', 300); foreach ($_categories as $i => $_category) { $_categories[$i]['text_original'] = get_translated_text($_category['category']); } $categories = collapse_2d_complexity('id', 'text_original', $_categories); $query = 'SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'download_downloads WHERE add_date>' . strval((int) $cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' AND ' . $filters . ' ORDER BY add_date DESC'; $rows = $GLOBALS['SITE_DB']->query($query, $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 = xmlentities(escape_html(get_translated_text($row['name']))); $_summary = get_translated_tempcode($row['description']); $summary = xmlentities($_summary->evaluate()); $news = ''; if (!array_key_exists($row['category_id'], $categories)) { $c = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories', 'category', array('id' => $row['category_id'])); if (is_null($c)) { continue; } // Slight corruption $categories[$row['category_id']] = get_translated_text($c); } if (!array_key_exists($row['category_id'], $categories)) { continue; } $category = $categories[$row['category_id']]; $category_raw = strval($row['category_id']); $view_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $row['id']), get_module_zone('downloads'), 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' => '2a3615d747190e5268df1e7d9eaee7be', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id']))); } else { $if_comments = new ocp_tempcode(); } $keep = symbol_tempcode('KEEP'); $enclosure_url = find_script('dload') . '?id=' . strval($row['id']) . $keep->evaluate(); $full_url = $row['url']; if (url_is_local($full_url)) { $full_url = get_custom_base_url() . '/' . $full_url; } list($enclosure_length, ) = get_enclosure_details($row['url'], $full_url); $enclosure_type = 'application/octet-stream'; $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('downloads'); return array($content, do_lang('SECTION_DOWNLOADS')); }