<?php

/********************************************************************************
	- MemHT Portal -
	
	Copyright (C) 2007-2008 by Miltenovik Manojlo
	http://www.memht.com
	
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your opinion) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License along
	with this program; if not, see <http://www.gnu.org/licenses/> (GPLv2)
	or write to the Free Software Foundation, Inc., 51 Franklin Street,
	Fifth Floor, Boston, MA02110-1301, USA.
		
********************************************************************************/
		
if (!defined("_LOAD_PAGE_")) {
	die("<table style='padding: 2px; border: 1px solid #999; background-color: #EEE; font-family: Verdana; font-size: 10px;' align='center'><tr><td><b>Error:</b> This file cannot be opened directly!</td></tr></table>");
}

		$pagerow = $dblink->get_row("SELECT fullscreen FROM memht_pagine WHERE nome='$page'");
		$fullScreen = intval($pagerow['fullscreen']);
		
		require_once("inc/inc_header.php");
		if (isset($_GET['page'])) { page_title($page); }
		
		openTable();
			if ($dblink->get_num("SELECT id FROM memht_articoli WHERE enabled=1")>0) {
				$row = $dblink->get_row("SELECT titolo FROM memht_pagine WHERE nome='articles'");
				echo "<div><a href='rss.php?page=articles' title='".outCode($row['titolo'])."' target='_blank'><img src='images/rss-syndicate_box.gif' border='0' alt='RSS'> <b>".outCode($row['titolo'])."</b></a></div>\n";
				if ($result = $dblink->get_list("SELECT * FROM memht_articoli AS art JOIN memht_argomenti AS arg ON arg.id=art.argomento GROUP BY arg.nome")) {
					foreach ($result as $row) {
						$id = intval($row['id']);
						$nome = outCode($row['nome']);
						echo "<div style='margin:1px 0;'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='rss.php?page=articles&topic=$id' title='"._ARTRSSFEED_."'>- $nome</a></div>";
					}
				}
				echo "<br>";
			}
			
			if ($dblink->get_num("SELECT id FROM memht_blog_posts WHERE enabled=1")>0) {
				$row = $dblink->get_row("SELECT titolo FROM memht_pagine WHERE nome='blog'");
				echo "<div><a href='rss.php?page=blog' title='".outCode($row['titolo'])."' target='_blank'><img src='images/rss-syndicate_box.gif' border='0' alt='RSS'> <b>".outCode($row['titolo'])."</b></a></div>\n";
				if ($result = $dblink->get_list("SELECT * FROM memht_blog_posts AS bp JOIN memht_blog_categories AS cat ON cat.id=bp.category WHERE bp.enabled=1 GROUP BY cat.name")) {
					foreach ($result as $row) {
						$id = intval($row['id']);
						$name = outCode($row['name']);
						echo "<div style='margin:1px 0;'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='rss.php?page=blog&cat=$id' title='Blog "._BLOGRSSFEED_."'>- $name</a></div>";
					}
				}
				echo "<br>";
			}
			
			$secn = 100;
			$spcs = "&nbsp;&nbsp;&nbsp;&nbsp;";
			function godeep($id,$secn,$spcs) {
				global $dblink;
				
				$parent = intval($id);
				
				if ($result = $dblink->get_list("SELECT id,nome FROM memht_download_categorie WHERE parent=$parent ORDER BY nome") AND $secn>0) {
					$spcs .= "&nbsp;&nbsp;&nbsp;&nbsp;";
					foreach ($result as $row) {
						$id = intval($row['id']);
						$nome = outCode($row['nome']);
						echo "<div style='margin:1px 0;'>$spcs<a href='rss.php?page=download&cat=$id' title='"._DWNRSSFEED_."'>- $nome</a></div>";
						$secn--;
						godeep($id,$secn,$spcs);
					}
				}
			}
			
			if ($dblink->get_num("SELECT id FROM memht_download")>0) {
				$row = $dblink->get_row("SELECT titolo FROM memht_pagine WHERE nome='download'");
				echo "<div><a href='rss.php?page=download' title='".outCode($row['titolo'])."' target='_blank'><img src='images/rss-syndicate_box.gif' border='0' alt='RSS'> <b>".outCode($row['titolo'])."</b></a></div>\n";
				if ($result = $dblink->get_list("SELECT id,nome FROM memht_download_categorie WHERE parent=0 ORDER BY nome")) {
					foreach ($result as $row) {
						$id = intval($row['id']);
						$nome = outCode($row['nome']);
						echo "<div style='margin:1px 0;'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='rss.php?page=download&cat=$id' title='"._DWNRSSFEED_."'>- $nome</a></div>";
						godeep($id,$secn,$spcs);
					}	
				}
				
				echo "<br>";
			}
			
			if ($dblink->get_num("SELECT id FROM memht_forum_posts")>0) {
				$row = $dblink->get_row("SELECT titolo FROM memht_pagine WHERE nome='forum'");
				echo "<div><a href='rss.php?page=forum' title='".outCode($row['titolo'])."' target='_blank'><img src='images/rss-syndicate_box.gif' border='0' alt='RSS'> <b>".outCode($row['titolo'])."</b></a></div>\n";
				if ($result = $dblink->get_list("SELECT * FROM memht_forum_posts AS fp JOIN memht_forum_forums AS ff ON ff.id=fp.forum GROUP BY ff.name")) {
					foreach ($result as $row) {
						$id = intval($row['id']);
						$name = outCode($row['name']);
						echo "<div style='margin:1px 0;'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='rss.php?page=forum&forum=$id' title='"._FORUMRSSFEED_."'>- $name</a></div>";
						
						if ($sresult = $dblink->get_list("SELECT * FROM memht_forum_posts AS fp JOIN memht_forum_forums AS ff ON ff.id=fp.forum WHERE ff.parent=$id GROUP BY ff.name")) {
							foreach ($sresult as $srow) {
								$sid = intval($srow['id']);
								$sname = outCode($srow['name']);
								echo "<div style='margin:1px 0;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='rss.php?page=forum&forum=$sid' title='"._FORUMRSSFEED_."'>- $sname</a></div>";
							}
						}
						
					}
				}
				echo "<br>";
			}
			
			if ($dblink->get_num("SELECT id FROM memht_guide WHERE enabled=1")>0) {
				$row = $dblink->get_row("SELECT titolo FROM memht_pagine WHERE nome='guide'");
				echo "<div><a href='rss.php?page=guide' title='".outCode($row['titolo'])."' target='_blank'><img src='images/rss-syndicate_box.gif' border='0' alt='RSS'> <b>".outCode($row['titolo'])."</b></a></div>\n";
				if ($result = $dblink->get_list("SELECT * FROM memht_guide AS gui JOIN memht_argomenti AS arg ON arg.id=gui.argomento GROUP BY arg.nome")) {
					foreach ($result as $row) {
						$id = intval($row['id']);
						$nome = outCode($row['nome']);
						echo "<div style='margin:1px 0;'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='rss.php?page=guide&topic=$id' title='"._GUIRSSFEED_. "'>- $nome</a></div>";
					}
				}
				echo "<br>";
			}
			
			if ($dblink->get_num("SELECT id FROM memht_news WHERE enabled=1")>0) {
				$row = $dblink->get_row("SELECT titolo FROM memht_pagine WHERE nome='news'");
				echo "<div><a href='rss.php?page=news' title='".outCode($row['titolo'])."' target='_blank'><img src='images/rss-syndicate_box.gif' border='0' alt='RSS'> <b>".outCode($row['titolo'])."</b></a></div>\n";
				if ($result = $dblink->get_list("SELECT * FROM memht_news AS new JOIN memht_argomenti AS arg ON arg.id=new.argomento GROUP BY arg.nome")) {
					foreach ($result as $row) {
						$id = intval($row['id']);
						$nome = outCode($row['nome']);
						echo "<div style='margin:1px 0;'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='rss.php?page=news&topic=$id' title='"._NEWSRSSFEED_."'>- $nome</a></div>";
					}
				}
				echo "<br>";
			}
			
			echo "<div><a href='sitemap.php' target='_blank' title='Sitemap'><img src='images/rss-syndicate_box.gif' title='Sitemap' border='0' alt='RSS'> <b>Sitemap</b></a></div>\n";
	
		closeTable();
		
		require_once("inc/inc_footer.php");

?>