id) { header('HTTP/1.1 404 Not Found', true, 404); require_once LENCRIER_ROOT . '/include/tpl.php'; $tpl->display('journal_error.tpl'); exit; } // Désabonnement des écrits par mail // Doit être accessible quel que soit l'état du journal if ($path == '/' && utils::get('d')) { require_once LENCRIER_ROOT . '/include/tpl.php'; $abo = new Journal_Abonnements($j); $abo->remove(utils::get('d')); $tpl->assign('msg', 'UNSUBSCRIBED'); $tpl->assign('journal', $j->get_all()); $tpl->assign('csrf_key', 'abon_'.$j->get('id')); $tpl->display('journal_abonnement.tpl'); exit; } // Journal secret if ($j->isSecret()) { header('HTTP/1.1 403 Forbidden', true, 403); require_once LENCRIER_ROOT . '/include/tpl.php'; $tpl->display('journal_forbidden.tpl'); exit; } // Journal pas public = pas indexé if ($path == '/robots.txt' && !$j->isPublic()) { echo "User-Agent: *\nDisallow: /"; exit; } // Redirection vers les images (sert dans les mails envoyés par abonnement) elseif (strpos($path, '/i/') === 0) { header('Location: ' . utils::getJournalDatasURL($j->get('id'), 'documents') . 'images/' . substr($path, 3)); exit; } // Formulaire de contact public elseif ($path == '/contact/post/' && $j->get('contact')) { require_once LENCRIER_ROOT . '/include/tpl.php'; $msg = false; $csrf_key = 'send_'.$j->get('id'); if (!empty($_POST)) { if (!trim(utils::post('texte'))) { $msg = 'EMPTY_TEXT'; } elseif ((int) utils::post('parent') == 0 && !trim(utils::post('titre'))) { $msg = 'EMPTY_TITLE'; } elseif (trim(utils::post('contact')) && !filter_var(utils::post('contact'), FILTER_VALIDATE_EMAIL) && !filter_var(utils::post('contact'), FILTER_VALIDATE_URL)) { $msg = 'WRONG_CONTACT'; } if (utils::post('confirm_send') && !$msg) { if (!utils::CSRF_check($csrf_key)) { $msg = 'OTHER'; } elseif ((bool) utils::post('envoyer_copie') && !filter_var(utils::post('contact'), FILTER_VALIDATE_EMAIL)) { $msg = 'WRONG_CONTACT'; } elseif (Forum::checkFlood()) { $msg = 'FLOOD'; } elseif ($spam = Forum::checkSpam(utils::post('texte'), utils::post('titre'), utils::post('nom'), utils::post('contact'))) { if ($spam === true) { $msg = 'SPAM'; } elseif ($spam == Forum::IGNORE) { utils::redirect($j->get('url') . 'contact/?ok'); } } elseif (!preg_match('!^quarante[- ]?deux$!i', trim(utils::post('titre2')))) { $msg = 'CHECKSPAM'; } else { list($id, $uri) = $j->contact( utils::post('texte'), utils::post('titre'), utils::post('nom'), utils::post('contact'), (bool) utils::post('envoyer_copie') ); utils::redirect($j->get('url') . 'contact/?ok'); } } } else { $tpl->assign('no_send', true); } $tpl->assign('msg', $msg); $tpl->assign('csrf_key', $csrf_key); $tpl->assign('journal', $j->get_all()); $tpl->display('journal_contact.tpl'); exit; } // Journal privé : vérif que l'on y a accès if ($j->isPrivate()) { if (!empty($_POST['login']) || !Journal_Prive::userIsAllowed($id)) { require_once LENCRIER_ROOT . '/include/tpl.php'; $tpl->assign('journal', $j->get_all()); if ($path == '/contact/') { $tpl->assign('msg', false); $tpl->assign('csrf_key', 'send_'.$j->get('id')); $tpl->display('journal_contact.tpl'); } else { if (!empty($_POST['login']) && !empty($_POST['password'])) { if (Journal_Prive::userLogin($j->get('id'), $_POST['login'], $_POST['password'])) { utils::redirect(utils::getJournalURL($id)); } $tpl->assign('login_error', true); } $tpl->assign('journal', $j->get_all()); $tpl->display('journal_login.tpl'); } exit; } } $jr = new Journal_Rendu($j); if ($path == '/') { $jr->renderHome(); } elseif ($path == '/backend/') { $jr->renderFeed(); } elseif (strpos($path, '/abonnement/') === 0) { require_once LENCRIER_ROOT . '/include/tpl.php'; $msg = false; $csrf_key = 'abon_'.$j->get('id'); $abo = new Journal_Abonnements($j); if (preg_match('!^/abonnement/([a-f0-9]{10})$!', $path, $match)) { if ($abo->confirm($match[1])) { $msg = 'SUBSCRIBED'; } else { $msg = 'ROTTEN'; } } if (utils::post('abon')) { if (!utils::CSRF_check($csrf_key)) { $msg = 'OTHER'; } elseif (!trim(utils::post('email'))) { $msg = 'EMAIL'; } elseif (Forum::checkSpam('', '', '', utils::post('email')) == Forum::IGNORE) { // Ignorer les spammeurs, bannis et relous ici aussi utils::redirect($j->get('url') . 'abonnement/?ok'); } elseif (!$abo->add(utils::post('email'))) { $msg = 'EMAIL'; } else { utils::redirect($j->get('url') . 'abonnement/?ok'); } } $tpl->assign('msg', $msg); $tpl->assign('csrf_key', $csrf_key); $tpl->assign('journal', $j->get_all()); $tpl->display('journal_abonnement.tpl'); } elseif ($path == '/contact/' && $j->get('contact')) { $jr->renderContact(); } elseif ($path == '/forum/post/') { require_once LENCRIER_ROOT . '/include/tpl.php'; $msg = false; $csrf_key = 'post_'.$j->get('id'); if (!trim(utils::post('texte'))) { $msg = 'EMPTY_TEXT'; } elseif ((int) utils::post('parent') == 0 && !trim(utils::post('titre'))) { $msg = 'EMPTY_TITLE'; } elseif (trim(utils::post('contact')) && !filter_var(utils::post('contact'), FILTER_VALIDATE_EMAIL) && !filter_var(utils::post('contact'), FILTER_VALIDATE_URL)) { $msg = 'WRONG_CONTACT'; } if (utils::post('confirm_post') && !$msg) { if (!utils::CSRF_check($csrf_key)) { $msg = 'OTHER'; } elseif (Forum::checkFlood()) { $msg = 'FLOOD'; } elseif ($spam = Forum::checkSpam(utils::post('texte'), utils::post('titre'), utils::post('nom'), utils::post('contact'))) { if ($spam === true) { $msg = 'SPAM'; } elseif ($spam == Forum::IGNORE) { utils::redirect(utils::getForumUrl($j->get('id'))); } } elseif (!preg_match('!^quarante[- ]?deux$!i', trim(utils::post('titre2')))) { $msg = 'CHECKSPAM'; } else { list($id, $uri) = Forum::post( $j, utils::post('texte'), (int) utils::post('parent'), utils::post('titre'), utils::post('nom'), utils::post('contact'), true ); if ((int) utils::post('parent') == 0) $url = utils::getForumMessageUrl($j->get('id'), $uri); else $url = utils::getForumMessageUrl($j->get('id'), $uri, $id); utils::redirect($url); } } $tpl->assign('msg', $msg); $tpl->assign('csrf_key', $csrf_key); $tpl->assign('parent', (int)utils::post('parent')); $tpl->assign('journal', $j->get_all()); $tpl->display('journal_post.tpl'); } elseif (preg_match('!^/((?:\d{4})/(?:\d{2})/(?:\d{2})-.*)$!', $path, $match)) { $jr->renderEcrit($match[1]); } elseif (preg_match('!^/(\d{4})/(\d{2})/$!', $path, $match)) { $mois = $match[1] . $match[2]; $jr->renderArchive($mois); } elseif (preg_match('!^/forum/(?:\+(\d+))?$!', $path, $match)) { $debut = isset($match[1]) ? (int) $match[1] : 0; $jr->renderForumList($debut); } elseif (preg_match('!^/forum/(.*)$!', $path, $match)) { $jr->renderForumThread($match[1]); } elseif (preg_match('!^/([a-z0-9_-]+)(?:/(.*)/?)?$!i', $path, $match) && $jr->checkCustom($match[1])) { $opts = array(); if (!empty($match[2])) { $opts = explode('/', $match[2]); } $jr->renderCustom($match[1], $opts); } else { $jr->renderEcrit(substr($path, 1)); } ?>