<?
	include "Tesserae/cache_manager.inc";
	$for = $_GET['for'] ? $_GET['for'] : 'sf';

	$cachefile = cache_create_name('ticker-');
	if (!$_POST && cache_try("cache", $cachefile, 'mm=10', '')) {
		exit;
	} else {
	
	include "Tesserae/db.php";
	$db = connetti("delosnetwork",'delos','delfino','localhost','utf8');
	
	$url = array(
		'sf' => 'http://www.fantascienza.com/',
		'fm' => 'http://www.fantasymagazine.it/',
		'hm' => 'http://www.horrormagazine.it/',
		'tm' => 'http://www.thrillermagazine.it/',
		'sm' => 'http://www.sherlockmagazine.it/'
	);
	
	$schema = array(
		'sf' => 'http://www.fantascienza.com/magazine/notizie/',
		'fm' => 'http://www.fantasymagazine.it/notizie/',
		'hm' => 'http://www.horrormagazine.it/notizie/',
		'tm' => 'http://www.thrillermagazine.it/notizie/',
		'sm' => 'http://www.sherlockmagazine.it/notizie/'
	);
	
	$title = array(
		'sf' => 'Fantascienza.com',
		'fm' => 'FantasyMagazine',
		'hm' => 'HorrorMagazine',
		'tm' => 'ThrillerMagazine',
		'sm' => 'SherlockMagazine'
	);
	
	$bg = array(
		'sf' => '#f4f8ff',
		'fm' => '#eef8f8',
		'hm' => '#ccc',
		'tm' => '#d2dcfb',
		'sm' => '#f4f8ff'
	);
	
	$sort = array(
		'sf' => array('fm' => 5, 'hm' => 4, 'tm' => 2,'sm' => 2),
		'fm' => array('sf' => 5, 'hm' => 4, 'tm' => 2,'sm' => 2),
		'hm' => array('fm' => 4, 'sf' => 3, 'tm' => 3,'sm' => 2),
		'tm' => array('sm' => 4, 'hm' => 4, 'sf' => 2,'fm' => 2),
		'sm' => array('tm' => 5, 'hm' => 4, 'sf' => 2,'fm' => 2)
	);		
	
	
	if ($sort[$for]['sf']) $db->carica($news['sf'], "magazine_sf.articoli", "classe='notizie' AND data_edizione<=CURDATE() AND status='pubblicata'", "data_edizione DESC, ordine, id DESC", "id, titolo", 0, $sort[$for]['sf']);
	if ($sort[$for]['fm']) $db->carica($news['fm'], "magazine_fm.articoli", "classe='notizie' AND data_edizione<=CURDATE() AND status='pubblicata'", "data_edizione DESC, ordine, id DESC", "id, titolo", 0, $sort[$for]['fm']);
	if ($sort[$for]['hm']) $db->carica($news['hm'], "magazine_hm.articoli", "classe='notizie' AND data_edizione<=CURDATE() AND status='pubblicata'", "data_edizione DESC, ordine, id DESC", "id, titolo", 0, $sort[$for]['hm']);
	if ($sort[$for]['tm']) $db->carica($news['tm'], "thrillermagazine.articoli", "classe='notizie' AND data_edizione<=CURDATE() AND status='pubblicata'", "data_edizione DESC, ordine, id DESC", "id, titolo", 0, $sort[$for]['tm']);
	if ($sort[$for]['sm']) $db->carica($news['sm'], "magazine_sm.articoli", "classe='notizie' AND data_edizione<=CURDATE() AND status='pubblicata'", "data_edizione DESC, ordine, id DESC", "id, titolo", 0, $sort[$for]['sm']);

	$bg = $_GET['bg'] ? $_GET['bg'] : $bg[$for];

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html lang="it">
<head>
	<meta http-equiv="content-type" content="text/html; charset=windows-1252">
	<title>Delos Network</title>
	<meta name="generator" content="BBEdit 8.7">
<style type="text/css">
body { margin: 0px; padding: 0; background-color: <?=$bg?>; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
#list { width: 120px; border: none; height: 600px; background: <?=$bg?> url(img/crossbot.gif) left bottom no-repeat; overflow: hidden; }
h3 { font: normal 11px "Arial",sans-serif; margin: 10px 0; color: #eee; height: 40px; padding: 0 4px; line-height: 18px; margin: 0; }
h3 a { color: white; font-weight: bold; font-size: 13px; line-height: 22px; }

ul { list-style: none; margin: 0; padding: 0; margin-bottom: 4px; }
ul li { list-style: none; display: block; margin: 3px 0; padding: 0; padding-top: 3px; border-top: 1px solid #999; font: normal 11px "Arial",sans-serif; color: #444; line-height: 110%; }
ul li:first-child { margin-top: 0; border-top: none; }
ul li a { color: #444; padding: 0; }

.fm h3 { background: url(img/fmbg.jpg); }
.sf h3 { background: url(img/sfbg.jpg); }
.hm h3 { background: url(img/hmbg.jpg); }
.tm h3 { background: url(img/tmbg.jpg); }
.sm h3 { background: url(img/smbg.jpg); }

</style>
</head>
<body>
<div id="list">
<img src="img/crosshd.gif" alt="DelosNetwork" width="120" height="18">
<? foreach($sort[$for] as $site => $cnt) { ?>
<div class="<?=$site?>">
<h3><a href="<?=$url[$site]?>" target="_top"><?=$title[$site]?></a><br>ultime notizie</h3>
<ul>
<? foreach ($news[$site] as $art) { ?>
<li><a href="<?=$schema[$site]?><?=$art['id']?>/" target="_top"><?=htmlentities($art['titolo'])?></a></li>
<? } ?>
</ul>
</div>
<? } ?>
</div>
</body>
</html>
<?
		cache_done("cache", $cachefile);
	}
?>