Jump to content

RSS to HTML file Help


twittoris

Recommended Posts

Here is my index.php file

 

<?php

require_once('Smarty.class.php');

require_once('config.php');

 

if(!is_writable('smarty_cache') && !is_writable('smarty_compile')) {

  if(function_exists('chmod')) {

    if(!(chmod('smarty_cache', 0777) && chmod('smarty_compile', 0777)))

      print 'The directories <code>smarty_cache</code> and <code>smarty_compile</code> are not writable and this problem could not be fixed automatically. Please chmod these directories to 755.';

  } else

    print 'The directories <code>smarty_cache</code> and <code>smarty_compile</code> are not writable and this problem could not be fixed automatically. Please chmod these directories to 755.';

}

require_once('rss_fetch.inc');

 

$smarty = new Smarty;

$smarty->assign('site_name', $config['site_name']);

$smarty->assign('adsense_id', $config['adsense_id']);

$smarty->assign('disable_tooltips', $config['disable_tooltips']);

$smarty->assign('disable_search', $config['disable_search']);

$smarty->assign('links_new_window', $config['links_new_window']);

$smarty->template_dir = 'template';

$smarty->compile_dir = 'smarty_compile';

$smarty->cache_dir = 'smarty_cache';

 

$feeds = file('feeds.txt');

$data = array();

 

 

error_reporting(0);

 

 

foreach($feeds as $feed) {

  $i = 0;

  $title = '';

  if(preg_match('/^([^ ]*) (.*)$/', $feed, $m)) {

    $feed = $m[1];

    $title = $m[2];

  } else

    $feed = trim($feed);

  $fetcher = fetch_rss($feed);

  if($fetcher->items) {

    array_push($data, array('title' => ($title?$title:$fetcher->channel['title'])));

    $data[(count($data)-1)]['link'] = $fetcher->channel['link'];

    $data[(count($data)-1)]['links'] = array();

    foreach($fetcher->items as $item) {

      if($i++ < $config['items_per_feed'])

        array_push($data[(count($data)-1)]['links'], array('title' => ($config['max_headline_length'] && strlen($item['title']) > $config['max_headline_length'])?(substr($item['title'], 0, $config['max_headline_length']-3).'...'):($item['title']), 'link' => $item['link'], 'desc' => preg_replace('/<([^>]*)>/', '',$item['summary']?$item['summary']:($item['atom_content']?$item['atom_content']:$item['description'])), 'id' => ($id++)+0));

    }

  }

}

$smarty->assign('data', $data);

$smarty->display('index.tpl');

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.