<?php
	session_start();
	
	include('database.php');
	DB_connexion(); 
	
	ini_set( 'display_errors', '0');
	error_reporting( 0 );
	
	/*if(!isset($_SESSION['logged']) )
	{		header ('Location: interdiction.php');
	}
	
	if($_SESSION['logged']== "no")
	{
		header ('Location: interdiction.php');
	}    */
	
	if($_SESSION['logged']== "ok")
	{		
	   echo '<div id="connexion">';
		echo $_SESSION['login'];
		echo '</div>';
	
	    echo '<div id="image_login">';
		echo '<a href="compte.php" title="Accés à ton compte">';
		echo '<img src="images/login.png" border="0" alt="Pb affichage ?" ></a>';
		echo '</div>';
	
		$nom_page = basename (__FILE__ );
		
		$str = '';
		$str .= '<a href="logout.php?page=';
		$str .= 'acceuil.php' ; /*$nom_page;*/
		$str .= '"';
		$str .=	' title="Déconnexion">';
		$str .= '<img src="images/logout.png" border="0" alt="Pb affichage ?" ></a>';
		
		echo '<div id="image_logout">';
		echo $str;
		echo '</div>';
	}

	$_SESSION['page_active'] = basename (__FILE__ );	
	
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="Description" content="Liens sur des ouvrages" />
<meta name="Keywords" content="WEBSITE perso " />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Distribution" content="Global" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="Content-Language" content="fr" />
<meta name="rating" content="general" />
<meta name="author" content="Patrice DELPY" />
<meta name="copyright" content="Copyright 2012" />
<meta name="generator" content="Patoche">
<title>En cours de développemment ...</title>
<link rel="shortcut icon" href="images/mosfet.ico" type="image/x-icon">

<!-- <link href="css/style04.css" rel="stylesheet" type="text/css">	-->

<link href="css/style_menu01.css" rel="stylesheet" type="text/css">	
<link href="css/template.css" rel="stylesheet" type="text/css">	
<link href="css/form_login.css" rel="stylesheet" type="text/css">	
<link href="css/style_formulaire.css" rel="stylesheet" type="text/css">
<link href="css/menu_liste_compte.css" rel="stylesheet" type="text/css">	

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=1.4.2"></script>

<script type="text/javascript" src="js/login.js"></script>    
<script type="text/javascript" src="js/connexion.js"></script>   

<link rel="stylesheet" type="text/css" href="css/style_forum.css">
<link rel="stylesheet" type="text/css" href="css/navigation.css">

<style type="text/css">

#div_menu_liste{
	position:absolute;
	top:80px;
	left:60px;
	width: 100%; /*500px;*/
	height:200px;
	/*background-color:#00ff00;
	border:2px dashed #000000;*/
	}

#message_menu_liste{
					position:absolute;
					top:40px;
					left:220px;
					width:600px;
					height:200px;
					background-color:#00ff00;
					border:2px dashed #000000;
				}

#table_forum{
					position:absolute;
					top:40px;
					/*left:50px;*/
					width: 800px ;
					margin-left: auto ;
					margin-right: auto ;
					
				}
				
#aff	{	width:780px; 
			margin:0 auto;
		}
 
</style>


</head>

<body>

<!----------------------------->

<div id="container">

<!----------------------------->
        <div id="login_intergration">
            <div id="login_container">
                <a href="#" id="loginButton"><span>Login</span><em></em></a>
                <div style="clear:both"></div>
                <div id="loginBox">                
					<form method="get" id="loginForm" name="loginForm" action="acceuil.php" >
                        <fieldset id="body">
                            <fieldset>
							    <input type="hidden" name="valide_login" id="valide_login" value="none" />
                                <label for="login">Login :</label>
                                <input type="text" name="login" id="idlogin" />
                            </fieldset>
                            <fieldset>
                                <label for="password">Password :</label>
                                <input type="password" name="password" id="idpassword" />
                            </fieldset>
                            <input type="button" id="login" value="Connexion" onclick="return valider_connexion()"  /> 
                            <div id="statut"></div>
							</br>
							</br>
							</br>
							<input type="button" id="compte" name="compte" value="Créer mon compte" onclick="javascript:location.href='inscription.php'" />
							 </fieldset>
						<span><a href="envoi_identifiant.php">Identifiant oublié ?</a></span>  
						
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    
<!----------------------------->	
	
	<div id="box_message">
		<div id="balise_titre">
		<span style="font-size:28pt; font-family:Georgia, serif; color:#000000; ">Patoche</span>
		</div>
		
		<div id="balise_citation">
		<span style="font-size:14pt; font-family:Georgia, serif; color:#6A6A6A; ">&quot;Etre conscient que l'on est ignorant est un grand pas vers le savoir&quot;
        </span>
		</div>
	</div>

<!----------------------------->	
	<div id="banniere">
	</div>
<!----------------------------->		
<?php	
	include("include_menu.php");
?>
<!----------------------------->	
		
	<div id="contenu">
	
<!--	<div id="new">
	<h3>Navigation</h3>		
	</br>	
	<ul> 
	<li><a href="ajouter_categorie.php">Ajouter categorie</a></li>
	<li><a href="ajouter_topic.php">Ajouter topic</a></li>
	</ul>
	</div> -->
	
			<h2>Section Forum </h2>
			
			<div id="div_menu_liste">
			
			<div id="navigation_horizontale">
			<!--<div class="titlebar" style="margin-top: 12px">Navigation</div> -->
	
			<ul class="menu_forum">
			<li class="forum_tag_selected"><a href="forum.php" title="aller à la section">Forum</a></li>
			<li class="categorie_tag"><a href="ajouter_categorie.php" title="aller à la section">Ajouter catégorie</a></li>
			<li class="topic_tag"><a href="ajouter_topic.php" title="aller à la section">Ajouter topic</a></li>
			</ul>
			</div>
			
			<div id="table_forum">
	
<?php

		$sql = "SELECT	categories.cat_id, categories.cat_name,	categories.cat_description,
			    COUNT(topics.topic_id) AS topics
				FROM categories
				LEFT JOIN topics
				ON topics.topic_id = categories.cat_id
				GROUP BY categories.cat_name, categories.cat_description, categories.cat_id";

		$result = mysql_query($sql);
		
		echo '
		<table class="tborder" align="center" border="0" cellpadding="6" cellspacing="1" width="100%">
		<thead>
		<tr align="center">
		<td width="1" class="thead">&nbsp;&nbsp;&nbsp;&nbsp;</td>
	    <td class="thead" align="left" width="150">Forum</td>
	    <td class="thead" width="550">Dernier Post</td>
	    <td width="50" class="thead">Topics</td>
	    <td width="50" class="thead">Posts</td>
  	    </tr>
		</thead>'; 

		/*for($i = 0 ; $i <= 5 ; $i++)
		{*/
		
	while($row = mysql_fetch_assoc($result))
		{	
		
		$topicsql = "SELECT 
									topic_id,
									topic_subject,
									topic_date,
									topic_cat,
									topic_by
								FROM
									topics
								WHERE
									topic_cat = " . $row['cat_id'] . "
								ORDER BY
									topic_date
								DESC
								LIMIT
									1";
								
		$topicsresult = mysql_query($topicsql);
				
		
		$topicrow = mysql_fetch_assoc($topicsresult);
		//echo "+++ " .$topicrow['topic_by'];
		//echo '<a href="topic.php?id=' . $topicrow['topic_id'] . '">' . $topicrow['topic_subject'] . '</a>
		
		//$posts_sql = "SELECT user_name FROM users WHERE ";
		
		$id = $topicrow['topic_id'];
		
		$posts_sql = "SELECT 	
						posts.post_topic,
						posts.post_content,
						posts.post_date,
						posts.post_by,
						users.user_id,
						users.user_name
					FROM
						posts
					LEFT JOIN
						users
					ON
						posts.post_by = users.user_id
					WHERE
						posts.post_topic =  '".$id."' ";
						
		$posts_result = mysql_query($posts_sql);
		
		$posts_row = mysql_fetch_assoc($posts_result);
		
		
		echo '
		<tbody>
		<tr align="center">
		<td class="alt1Active" colspan="2" id="f7" align="left">
		
		<table border="0" cellpadding="0" cellspacing="0">
		<tbody><tr>
		<td><img src="Webmaster%20Forums%20-%20GIDForums_fichiers/forum_old.gif" alt="" border="0"></td>
		<td><img src="Webmaster%20Forums%20-%20GIDForums_fichiers/clear.gif" alt="" border="0" height="1" width="9"></td>
		<td>
		<div>
		<a href="http://www.gidforums.com/f-7.html"><strong>
		<a href="categorie.php?id=' . $row['cat_id'] . '">' . $row['cat_name'] . '</a>
		</strong></a>
		</div>
		</td>
		</tr>
		</tbody>
        </table>
		
		</td>
		<td class="alt2" nowrap="nowrap">
		<div class="smallfont" align="left">
		<div style="clear:both">
		<a href="page.html" title=""><strong> ';
		echo $topicrow['topic_subject'] ;
		
		echo '</strong></a>
		</div>
		<div>
        Par: ';
		
		echo $posts_row['user_name'];
		echo '
		</div>
		<div align="right">	';
		echo date('d-m-Y H:i:s', strtotime($topicrow['topic_date'])) ;
//		echo '
//		<span class="time">04:02</span> ';
		
		echo '
		<a href="http://toto.html">
        <img title="Go to last post" class="inlineimg" src="images/lastpost.gif" alt="Go to last post" border="0"></a>

		</div>
		</div>
		</td>
		<td class="alt1">692</td>
		<td class="alt2">2,818</td>
		</tr>
		</tbody> ';
		}
		?>

<!----------------------------------------------------------------->

		</table>

		</div>
	
		</div>
		
		</div>

<!----------------------------------------------------------------->
	<div id="footer">
		<p class="copyright">©  2012 Copyright. All Rights Reserved. | Patrice Delpy </p>        
	</div>
<!----------------------------------------------------------------->
	
</body>
</html>