<?php
include('inc/config.php');
include('fonctions.php');
include('libs/gaga.class.php');
$tpl = new gagatemplate();
$tpl->assign('design', $theme);
$tpl->assign(array(
'titre_page' => '',
'sitename' => $sitename,
'slogan' => $slogan,
'siteurl' => $siteurl,
'motcle' => $motcle,
'description' => $description,
'act' => $_GET['act'],
'id' => $_GET['id']
));
$sql = 'SELECT count(*) FROM forum_question';
$resultat = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
$nb_total = mysql_fetch_array($resultat);
// on teste si ce nombre de vaut pas 0
if (($nb_total = $nb_total[0]) == 0) {
echo 'Pas encore de question';
}
else {
if (!isset($_GET['debut'])) $_GET['debut'] = 0;
if (!isset($_GET['act'])) {
$act = '';
} else {
$act = $_GET['act'];
}
$nb_affichage_par_page = 10;
switch($act)
{
case 'Recent';
$sql='SELECT * FROM forum_question ORDER BY id DESC LIMIT '.$_GET['debut'].','.$nb_affichage_par_page;
break;
case 'populaires';
$sql='SELECT * FROM forum_question ORDER BY view DESC LIMIT '.$_GET['debut'].','.$nb_affichage_par_page;
break;
default:
$sql='SELECT * FROM forum_question ORDER BY id DESC LIMIT '.$_GET['debut'].','.$nb_affichage_par_page;
}
$result=mysql_query($sql)or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
switch($act){
case 'recent':
$instyle1 = " style=\"background:#CCCCCC\"";
break;
case 'populaires':
$instyle2 = " style=\"background:#DCDCDC\"";
break;
default:
$instyle1 = " style=\"background:#DCDCDC\"";
}
while($quest = mysql_fetch_array($result))
{
$tpl->assign_array('list_quest', array(
'id' => $quest['id'],
'topic' => $quest['topic'],
'name' => $quest['name'],
'detail' => $quest['detail'],
'dateheure' => $quest['datetime'],
'vu' => $quest['view'],
'reponse' => $quest['reply']));
}
$tpl ->assign(array(
'nb' => $nb_total,
'nbpage' => $nb_affichage_par_page,
'debut' => $_GET['debut'],
'nbbarre' => 15
));
}
$req = mysql_query('SELECT * FROM forum_categorie ORDER BY cat_nom');
while($data = mysql_fetch_assoc($req))
{
$tpl->assign_array('list_cat', array(
'id' => $data['cat_id'],
'nom' => $data['cat_nom']
));
}
$tpl->cache_time = 300; //on met le cache à 5 minutes (300 sec)
$tpl->cache = false; //active la mise en cache
$tpl->parse(''.$theme.'/header.tpl');
$tpl->parse(''.$theme.'/index.tpl');
$tpl->parse(''.$theme.'/footer.tpl');
//$tpl->debug('http://127.0.0.1/template/', 4);