/** * record a click * * @param string the external url that is targeted * */ public static function click($url) { global $context; // we record only GET requests if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') { return; } // do not count crawling if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(blo\\.gs|\\bblog|bot\\b|crawler\\b|frontier\\b|slurp\\b|spider\\b)/i', $_SERVER['HTTP_USER_AGENT'])) { return; } // record the activity Activities::post($url, 'click'); // do not record clicks driving to search engines if (preg_match('/\\b(google|yahoo)\\b/i', $url)) { return; } // if this url is known $query = "SELECT * FROM " . SQL::table_name('links') . " AS links" . " WHERE links.link_url LIKE '" . SQL::escape($url) . "'"; if ($item = SQL::query_first($query)) { // increment the number of clicks $query = "UPDATE " . SQL::table_name('links') . " SET hits=hits+1 WHERE id = " . SQL::escape($item['id']); SQL::query($query); // else create a new record with a count of one click } else { // get the section for clicks $anchor = Sections::lookup('clicks'); // no section yet, create one if (!$anchor) { $fields['nick_name'] = 'clicks'; $fields['title'] = i18n::c('Clicks'); $fields['introduction'] = i18n::c('Clicked links are referenced here.'); $fields['description'] = i18n::c('YACS ties automatically external links to this section on use. Therefore, you will have below a global picture of external sites that are referenced through your site.'); $fields['active_set'] = 'N'; // for associates only $fields['locked'] = 'Y'; // no direct contributions $fields['index_map'] = 'N'; // listd only to associates $fields['rank'] = 20000; // towards the end of the list // reference the new section if ($fields['id'] = Sections::post($fields)) { $anchor = 'section:' . $fields['id']; } } // create a new link in the database $fields = array(); $fields['anchor'] = $anchor; $fields['link_url'] = $url; $fields['hits'] = 1; Surfer::check_default_editor($fields); if ($fields['id'] = Links::post($fields)) { Links::clear($fields); } } }
} else { $box_id = 'featured'; } // make an extra box -- the css id is either #featured, #scrolling_featured or #rotating_featured $text .= Skin::build_box($title, $items, 'news', $box_id); } } } // save in cache, whatever change, for 5 minutes Cache::put($cache_id, $text, 'stable', 300); } // news $context['components']['news'] = $text; // list extra boxes $text = ''; if ($anchor = Sections::lookup('extra_boxes')) { // the maximum number of boxes is a global parameter if (!isset($context['site_extra_maximum']) || !$context['site_extra_maximum']) { $context['site_extra_maximum'] = 7; } // articles to be displayed as extra boxes if ($items =& Articles::list_for_anchor_by('publication', $anchor, 0, $context['site_extra_maximum'], 'boxes')) { foreach ($items as $title => $attributes) { $text .= Skin::build_box($title, $attributes['content'], 'boxes', $attributes['id']) . "\n"; } } } // boxes $context['components']['boxes'] = $text; // referrals, if any if (Surfer::is_associate() || isset($context['with_referrals']) && $context['with_referrals'] == 'Y') {
// the submit button $context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Send'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n"; // end of the form $context['text'] .= '</div></form>'; // the script used for form handling at the browser Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . ' // letter_title is mandatory' . "\n" . ' if(!container.letter_title.value) {' . "\n" . ' alert("' . i18n::s('No title has been provided.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' return true;' . "\n" . '}' . "\n" . "\n" . 'document.main_form.letter_title.focus();' . "\n"); // no mail in demo mode } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && file_exists($context['path_to_root'] . 'parameters/demo.flag')) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.')); // handle posted data } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') { // ensure all letters will be sent even if the browser connection dies Safe::ignore_user_abort(TRUE); // always archive the letter $anchor = Sections::lookup('letters'); // no section yet, create one if (!$anchor) { $context['text'] .= i18n::s('Creating a section for archived letters') . BR . "\n"; $fields['nick_name'] = 'letters'; $fields['title'] = i18n::c('Archived letters'); $fields['introduction'] = i18n::c('To remember our previous messages'); $fields['description'] = i18n::c('YACS puts automatically sent letters into this section.'); $fields['locked'] = 'Y'; // no direct contributions $fields['index_map'] = 'N'; // listed only to associates $fields['rank'] = 30000; // at the end of the list // reference the new section if ($fields['id'] = Sections::post($fields, FALSE)) {
$fields['nick_name'] = 'my_sub_category'; $fields['anchor'] = $anchor; $fields['title'] = i18n::c('My sub-category'); $fields['introduction'] = i18n::c('Sample sub category'); $fields['description'] = i18n::c('This category has been created for experimentation purpose. Feel free to change this text, to add some images, to play with codes, etc. Have you checked the help link on the side of this page? Once you will feel more comfortable with the handling of categories, just delete this one and create other categories of your own.'); if (Categories::post($fields)) { $text .= sprintf(i18n::s('A category "%s" has been created.'), $fields['nick_name']) . BR . "\n"; } } // articles // $text .= Skin::build_block(i18n::s('Pages'), 'subtitle'); // 'my_article' article if (Articles::get('my_article')) { $text .= sprintf(i18n::s('A page "%s" already exists.'), 'my_article') . BR . "\n"; } elseif ($anchor = Sections::lookup('my_section')) { $fields = array(); $fields['anchor'] = $anchor; $fields['nick_name'] = 'my_article'; $fields['title'] = i18n::c('Edit me'); $fields['introduction'] = i18n::c('Sample article'); $fields['description'] = i18n::c('This is a sample article to let you learn and practice.') . "\n\nabcdefghijklmnopqrstuvwxyz" . " &é\"'(-è_çà )=~#{[|`\\x^@]}" . " ^βêîôϋ¨δλοφό£ù%*µ,;:!?./§¤" . "\\a\\b\\c\\d\f\\g\\h\\i\\j\\k\\l\\m\\o\\p\\q\r\\s\t\\u\v\\w\\x\\y\\z" . "\n:) 8) :D :O ;) :( X( !! ?? ?! -- ++ >> §§" . "\n[b]bold[/b] and [i]italic[/i][nl][u]underlined[/u]" . "\n<a href=\"http://myweb/mypage.html\">anchor</a><!-- comment -->" . "\nCheck my [link=document]http://myweb/mypage.html[/link] on this subject;" . " more info [email=here>>]me@dummy.com[/email]" . "\n[code]// say hello\necho \"hello world\";[/code]" . "\n[quote]Once upon a time...[/quote]" . "\n[*]First item[nl][nl][*]Second item" . "\n[list][*]First item [*]Second item[/list]" . "\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. " . "\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. "; $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S'); if (Articles::post($fields)) { $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['nick_name']) . BR . "\n"; } else { $text .= Logger::error_pop() . BR . "\n"; } } // comments //
* @reference * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License */ // common definitions and initial processing include_once '../shared/global.php'; // load the skin load_skin('articles'); // the path to this page $context['path_bar'] = array('articles/' => i18n::s('All pages')); // the title of the page $context['page_title'] = i18n::s('Review queue'); // the menu bar for this page $context['page_menu'] = array('articles/' => i18n::s('All pages')); // list queries if (Surfer::is_associate()) { $anchor = Sections::lookup('queries'); if ($anchor && ($rows =& Articles::list_for_anchor_by('publication', $anchor, 0, 5))) { if (is_array($rows)) { $rows = Skin::build_list($rows, 'decorated'); } $context['text'] .= Skin::build_box(i18n::s('Submitted queries'), $rows, 'header1', 'queries'); } } // list draft articles if ($rows =& Articles::list_by('draft')) { // set a title to the section only if we have other sections if (Surfer::is_associate()) { $context['text'] .= Skin::build_block(i18n::s('Submitted articles'), 'title', 'submitted'); } if (is_array($rows)) { $context['text'] .= Skin::build_list($rows, 'decorated');
function parse_tag_close($parser, $tag) { global $context; global $in_overlay, $overlay_class, $overlay_parameters; global $parsed_cdata, $parsed_item, $parsed_overlay, $parsing_report; // save gathered data if necessary switch ($tag) { case 'article': // end of article // transcode owner id $parsed_item['owner_id'] = Surfer::get_id(); if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) { $parsed_item['owner_id'] = $user['id']; } // transcode creator id $parsed_item['create_id'] = Surfer::get_id(); if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) { $parsed_item['create_id'] = $user['id']; } // transcode editor id $parsed_item['edit_id'] = Surfer::get_id(); if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) { $parsed_item['edit_id'] = $user['id']; } // transcode publisher id $parsed_item['publish_id'] = Surfer::get_id(); if (isset($parsed_item['publish_nick_name']) && ($user = Users::get($parsed_item['publish_nick_name']))) { $parsed_item['publish_id'] = $user['id']; } // bind to given overlay $overlay = NULL; if ($overlay_class) { $overlay = Overlay::bind($overlay_class . ' ' . $overlay_parameters); } // when the page has been overlaid if (is_object($overlay)) { // update the overlay from content foreach ($parsed_overlay as $label => $value) { $overlay->attributes[$label] = $value; } // save content of the overlay in this item $parsed_item['overlay'] = $overlay->save(); $parsed_item['overlay_id'] = $overlay->get_id(); } // find anchor from handle if (isset($parsed_item['anchor_handle']) && ($reference = Sections::lookup($parsed_item['anchor_handle']))) { $parsed_item['anchor'] = $reference; } // update an existing page if (isset($parsed_item['handle']) && ($item = Articles::get($parsed_item['handle']))) { // transcode page id $parsed_item['id'] = $item['id']; // stop on error if (!Articles::put($parsed_item) || is_object($overlay) && !$overlay->remember('update', $parsed_item, 'article:' . $item['id'])) { Logger::error(sprintf('Unable to save article %s', $parsed_item['title'] . ' (' . $parsed_item['id'] . ')')); } // create a new page } else { unset($parsed_item['id']); // stop on error if (!($parsed_item['id'] = Articles::post($parsed_item))) { Logger::error(sprintf('Unable to save article %s', $parsed_item['title'])); } else { // save overlay content if (is_object($overlay)) { $overlay->remember('insert', $parsed_item, 'article:' . $parsed_item['id']); } } } // report to surfer $parsing_report .= '<li>' . Skin::build_link(Articles::get_permalink($parsed_item), $parsed_item['title']) . "</li>\n"; // ready for next item $overlay_class = NULL; $overlay_parameters = ''; $parsed_overlay = array(); $parsed_item = array(); Safe::set_time_limit(30); break; case 'overlay': // end of overlay data $in_overlay = FALSE; break; case 'section': // end of section // transcode owner id $parsed_item['owner_id'] = Surfer::get_id(); if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) { $parsed_item['owner_id'] = $user['id']; } // transcode creator id $parsed_item['create_id'] = Surfer::get_id(); if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) { $parsed_item['create_id'] = $user['id']; } // transcode editor id $parsed_item['edit_id'] = Surfer::get_id(); if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) { $parsed_item['edit_id'] = $user['id']; } // bind to given overlay $overlay = NULL; if ($overlay_class) { $overlay = Overlay::bind($overlay_class . ' ' . $overlay_parameters); } // when the page has been overlaid if (is_object($overlay)) { // update the overlay from content foreach ($parsed_overlay as $label => $value) { $overlay->attributes[$label] = $value; } // save content of the overlay in this item $parsed_item['overlay'] = $overlay->save(); $parsed_item['overlay_id'] = $overlay->get_id(); } // find anchor from handle if (isset($parsed_item['anchor_handle']) && ($reference = Sections::lookup($parsed_item['anchor_handle']))) { $parsed_item['anchor'] = $reference; } // update an existing section if (isset($parsed_item['handle']) && ($item = Sections::get($parsed_item['handle']))) { // transcode section id $parsed_item['id'] = $item['id']; // stop on error if (!Sections::put($parsed_item) || is_object($overlay) && !$overlay->remember('update', $parsed_item, 'section:' . $item['id'])) { Logger::error(sprintf('Unable to save section %s', $parsed_item['title'] . ' (' . $parsed_item['id'] . ')')); } // create a new page } else { unset($parsed_item['id']); // stop on error if (!($parsed_item['id'] = Sections::post($parsed_item))) { Logger::error(sprintf('Unable to save section %s', $parsed_item['title'])); } else { // save overlay content if (is_object($overlay)) { $overlay->remember('insert', $parsed_item, 'section:' . $parsed_item['id']); } } } // report to surfer $parsing_report .= '<li>' . Skin::build_link(Sections::get_permalink($parsed_item), $parsed_item['title']) . "</li>\n"; // ready for next item $overlay_class = NULL; $overlay_parameters = ''; $parsed_overlay = array(); $parsed_item = array(); Safe::set_time_limit(30); break; default: // just another attribute // decode cdata $parsed_cdata = trim(preg_replace(array('/</', '/>/'), array('<', '>'), $parsed_cdata)); // feeding the overlay or the item itself if ($in_overlay) { $parsed_overlay[$tag] = $parsed_cdata; } else { $parsed_item[$tag] = $parsed_cdata; } // ready for next attribute $parsed_cdata = ''; break; } }
if (isset($item['overlay']) && $item['overlay']) { $overlay = Overlay::load($item, 'user:'******'id']); } elseif (isset($context['users_overlay']) && $context['users_overlay']) { $overlay = Overlay::bind($context['users_overlay']); } // an error occured if (count($context['error'])) { } elseif (isset($context['users_without_private_pages']) && $context['users_without_private_pages'] == 'Y') { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // permission denied } elseif (!Surfer::is_member()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // the place for private pages } elseif (!($anchor = Sections::lookup('threads'))) { header('Status: 500 Internal Error', TRUE, 500); Logger::error(i18n::s('Impossible to add a page.')); // process submitted data } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') { // react to overlaid POST by a overlaid response global $render_overlaid; if ($render_overlaid) { $context['text'] .= '<div class="hidden require-overlaid"></div>' . "\n"; } // target user statut doesn't allow MP, except from associates if (!Surfer::is_associate() && ($overlay->attributes['user_status'] == 'donotdisturb' || $overlay->attributes['user_status'] == 'anonymous' || $item['without_alerts'] == 'Y')) { $context['text'] .= sprintf(i18n::s('Sorry, %s wish not to receive private message'), $item['nick_name']); render_skin(); finalize_page(TRUE); }
$item = Articles::get($id); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor']) && $item['anchor']) { $anchor = Anchors::get($item['anchor']); } elseif (isset($_REQUEST['anchor']) && $_REQUEST['anchor']) { $anchor = Anchors::get($_REQUEST['anchor']); } elseif (isset($_REQUEST['section']) && $_REQUEST['section']) { $anchor = Anchors::get('section:' . $_REQUEST['section']); } elseif (isset($_REQUEST['blogid']) && $_REQUEST['blogid']) { $anchor = Anchors::get('section:' . $_REQUEST['blogid']); } elseif (isset($_SESSION['anchor_reference']) && $_SESSION['anchor_reference']) { $anchor = Anchors::get($_SESSION['anchor_reference']); } // the default is to create a thread if (!is_object($anchor) && !isset($item['id']) && ($reference = Sections::lookup('threads'))) { $anchor = Anchors::get($reference); } // reflect access rights from anchor if (!isset($item['active']) && is_object($anchor)) { $item['active'] = $anchor->get_active(); } // get the related overlay, if any -- overlay_type will be considered later on $overlay = NULL; if (isset($item['overlay']) && $item['overlay']) { $overlay = Overlay::load($item, 'article:' . $item['id']); } elseif (isset($_REQUEST['variant']) && $_REQUEST['variant']) { $overlay = Overlay::bind($_REQUEST['variant']); } elseif (isset($_SESSION['pasted_variant']) && $_SESSION['pasted_variant']) { $overlay = Overlay::bind($_SESSION['pasted_variant']); unset($_SESSION['pasted_variant']);
public static function list_surfer_threads($offset = 0, $count = 50, $variant = NULL) { if (!($threads = Sections::lookup('threads'))) { return null; } $query = "SELECT articles.* FROM " . SQL::table_name('articles') . " AS articles " . " INNER JOIN " . SQL::table_name('members') . " AS member_mine" . " ON member_mine.anchor = CONCAT('article:',articles.id)" . " WHERE" . " articles.anchor = '" . $threads . "'" . " AND member_mine.member = 'user:"******"'" . " ORDER BY articles.edit_date DESC LIMIT " . $offset . ',' . $count; // use existing listing facility $output = Users::list_selected(SQL::query($query), $variant); return $output; }
$fields['title'] = i18n::c('USTREAM broadcast'); $fields['introduction'] = i18n::c('Drive your audience to a USTREAM show. At the given date and time participants are invited to join the channel.'); $fields['options'] = 'edit_as_thread'; $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S'); $fields['thumbnail_url'] = $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/thumbnails/conference.gif'; $overlay = Overlay::bind('ustream_meeting'); $fields['overlay'] = $overlay->save(); $fields['overlay_id'] = $overlay->get_id(); if (Articles::post($fields)) { $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']) . BR . "\n"; } else { $text .= Logger::error_pop() . BR . "\n"; } } // 'wiki_template' article if (!Articles::get('wiki_template') && ($anchor = Sections::lookup('templates'))) { $fields = array(); $fields['anchor'] = $anchor; $fields['nick_name'] = 'wiki_template'; $fields['title'] = i18n::c('Wiki page'); $fields['introduction'] = i18n::c('Create an initial page and invite participants to follow-up. Modifications are saved, to allow for fall-back.'); $fields['options'] = 'edit_as_simple members_edit view_as_wiki'; $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S'); $fields['thumbnail_url'] = $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/thumbnails/page.gif'; if (Articles::post($fields)) { $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']) . BR . "\n"; } else { $text .= Logger::error_pop() . BR . "\n"; } } // nothing added
/** * get news from remote servers * * This function queries remote sources and populate the table of links based on fetched news. * * On tick, the including hook calls [code]Feeds::tick_hook()[/code]. * See [script]control/scan.php[/script] for a more complete description of hooks. * * The function browses the database to locate servers acting as feeders, and read the URLs to use. * * A round-robin algorithm is implemented, meaning that servers are polled in sequence throughout successive ticks. * At most 1 feed is parsed on each tick, to limit impact when the "poor-man" cron mechanism is used, * which is the default setting. * * XML feeds are fetched and parsed according to their type. * At the moment YACS is able to process RSS and slashdot feeds. * Link records are created or updated in the database saving as much of possible of provided data. * Item data is reflected in Link, Title, and Description fields. * Channel data is used to populate the Source field. * Stamping information is based on feeding date, and channel title. * Also, the edit action 'link:feed' marks links that are collected from feeders. * The anchor field is set to the category assigned in the server profile. * * At the end of the feeding process, the database is purged from oldest links according to the limit * defined in parameters/feeds.include.php, set through feeds/configure.php. * See Links::purge_old_news(). * * @param boolean if set to true, fetch news on each call; else use normal period of time * @return a string to be displayed in resulting page, if any * * @see control/scan.php * @see feeds/configure.php */ public static function tick_hook($forced = FALSE) { global $context; // load librairies only once include_once $context['path_to_root'] . 'links/links.php'; include_once $context['path_to_root'] . 'servers/servers.php'; include_once $context['path_to_root'] . 'shared/values.php'; // feeds.tick // get feeding parameters Safe::load('parameters/feeds.include.php'); // delay between feeds - minimum is 5 minutes if (!isset($context['minutes_between_feeds']) || $context['minutes_between_feeds'] < 5) { $context['minutes_between_feeds'] = 5; } // do not wait for the end of a feeding cycle if ($forced) { $threshold = gmstrftime('%Y-%m-%d %H:%M:%S'); } else { $threshold = gmstrftime('%Y-%m-%d %H:%M:%S', time() - $context['minutes_between_feeds'] * 60); } // get a batch of feeders if (!($feeders = Servers::list_for_feed(0, 1, 'feed'))) { return 'feeds/feeds.php: no feed has been defined' . BR; } // remember start time $start_time = get_micro_time(); // list banned tokens $banned_pattern = Servers::get_banned_pattern(); // browse each feed $count = 0; foreach ($feeders as $server_id => $attributes) { // get specific feed parameters list($feed_url, $feed_title, $anchor, $stamp) = $attributes; // skip servers processed recently if ($stamp > $threshold) { continue; } // flag this record to enable round-robin even on error Servers::stamp($server_id); // fetch news from the provided link if (!($news = Feeds::get_remote_news_from($feed_url)) || !is_array($news)) { continue; } // no anchor has been defined for this feed if (!$anchor) { // create a default section if necessary if (!($anchor = Sections::lookup('external_news'))) { $fields = array(); $fields['nick_name'] = 'external_news'; $fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time()); $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time()); $fields['index_map'] = 'N'; $fields['locked'] = 'Y'; // no direct contributions $fields['rank'] = 40000; // at the end of the list $fields['title'] = i18n::c('External News'); $fields['description'] = i18n::c('Received from feeding servers'); if (!($fields['id'] = Sections::post($fields))) { Logger::remember('feeds/feeds.php: Impossible to add a section.'); return; } $anchor = 'section:' . $fields['id']; } } // process retrieved links $links = 0; foreach ($news as $item) { // link has to be valid if (!isset($item['link']) || !($item['title'] . $item['description'])) { if (isset($context['debug_feeds']) && $context['debug_feeds'] == 'Y') { Logger::remember('feeds/feeds.php: feed item is invalid', $item, 'debug'); } continue; } // skip banned servers if ($banned_pattern && preg_match($banned_pattern, $item['link'])) { if (isset($context['debug_feeds']) && $context['debug_feeds'] == 'Y') { Logger::remember('feeds/feeds.php: feed host has been banned', $item['link'], 'debug'); } continue; } // one link processed $links++; // link description $fields = array(); $fields['anchor'] = $anchor; $fields['link_url'] = $item['link']; $fields['title'] = $item['title']; $fields['description'] = $item['description']; if ($item['category']) { $fields['description'] .= ' (' . $item['category'] . ')'; } $fields['edit_name'] = $feed_title; $fields['edit_address'] = $feed_url; $fields['edit_action'] = 'link:feed'; if ($item['pubDate']) { $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', strtotime($item['pubDate'])); } // update links that already exist in the database if (Links::have($item['link'], $anchor, $fields)) { continue; } // save link in the database if (!Links::post($fields)) { Logger::remember('feeds/feeds.php: Impossible to save feed link: ' . Logger::error_pop()); } } // one feed has been processed $count += 1; // remember tick date Values::set('feeds.tick.' . $feed_url, $links); } // cap the number of links used for news if (!isset($context['maximum_news']) || !$context['maximum_news']) { $context['maximum_news'] = 1000; } if ($context['maximum_news'] > 10) { include_once $context['path_to_root'] . 'links/links.php'; Links::purge_old_news($context['maximum_news']); } // compute execution time $time = round(get_micro_time() - $start_time, 2); // report on work achieved if ($count > 1) { return 'feeds/feeds.php: ' . $count . ' feeds have been processed (' . $time . ' seconds)' . BR; } elseif ($count == 1) { return 'feeds/feeds.php: 1 feed has been processed (' . $time . ' seconds)' . BR; } else { return 'feeds/feeds.php: nothing to do (' . $time . ' seconds)' . BR; } }
$input = '<input type="radio" name="submit_feed" value="N"'; if (!isset($item['submit_feed']) || $item['submit_feed'] == 'N') { $input .= ' checked="checked"'; } $input .= '/> ' . i18n::s('Do not read news from this server') . BR . '<input type="radio" name="submit_feed" value="Y"'; if (isset($item['submit_feed']) && $item['submit_feed'] == 'Y') { $input .= ' checked="checked"'; } if (!isset($item['feed_url']) || !$item['feed_url']) { $item['feed_url'] = 'http://' . (isset($item['host_name']) ? $item['host_name'] : '__server__') . '/feeds/rss.php'; } $input .= '/> ' . sprintf(i18n::s('Aggregate news from this server by reading the XML feed at %s'), '<input type="text" name="feed_url" size="50" value="' . encode_field($item['feed_url']) . '" />'); // set a default anchor if (!isset($item['anchor']) || !$item['anchor']) { // create a default section if necessary if (!($anchor = Sections::lookup('external_news'))) { $fields = array(); $fields['nick_name'] = 'external_news'; $fields['create_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time()); $fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time()); $fields['locked'] = 'Y'; // no direct contributions $fields['index_map'] = 'N'; // in a side box at the front page $fields['rank'] = 40000; // at the end of the list $fields['title'] = i18n::c('External News'); $fields['description'] = i18n::s('Received from feeding servers'); if ($fields['id'] = Sections::post($fields, FALSE)) { $anchor = 'section:' . $fields['id']; }