assign('liste', $vendus->listByCritere($_GET['critere'])); $tpl->assign('critere', $_GET['critere']); $tpl->display('critere.tpl'); } elseif (isset($_GET['nom'])) { $tpl->assign('liste', $vendus->listByName($_GET['nom'])); $tpl->assign('nom', urldecode($_GET['nom'])); $tpl->display('nom.tpl'); } elseif (isset($_GET['permalien'])) { $tpl->assign('item', $vendus->getById($_GET['permalien'])); $tpl->display('item.tpl'); } elseif (isset($_GET['add'])) { $error = 0; session_start(); if (isset($_POST['add'])) { if (empty($_POST['checkMe']) OR $_POST['checkMe'] != $_SESSION['check']) die('session invalide'); if (empty($_POST['nom']) OR empty($_POST['critere']) OR empty($_POST['citation']) OR empty($_POST['source'])) { $error = 1; } if (empty($error)) { if (!$vendus->add($_POST['nom'], $_POST['critere'], $_POST['source'], $_POST['citation'])) { $error = 2; } else { @mail('bohwaz@bohwaz.net', 'Nouveau vendu', $_POST['nom']." (".$_POST['critere'].")\n\n". $_POST['source']."\n\n".$_POST['citation']); header('Location: ./?addok'); exit; } } } else { $_SESSION['check'] = md5(time() . ADM_PASSWORD . ADM_LOGIN . 'miam'); } $tpl->assign('error', $error); $tpl->assign('check', $_SESSION['check']); $tpl->display('add.tpl'); } else { if (!isset($_GET['addok'])) $tpl->cache = true; if (!$tpl->is_cached('index.tpl')) $tpl->assign('liste', $vendus->listLastItems(20)); $tpl->assign('add_ok', isset($_GET['addok'])); $tpl->display('index.tpl'); } ?>