. */ require_once dirname(__FILE__) . '/head.php'; if (empty($_GET['id']) || !is_numeric($_GET['id'])) die('Page invalide'); $id = (int) $_GET['id']; $comment = ''; define('CSRF_ID', 'edit_page_' . $id); define('CSRF_FIELD', 'oneTripOneNoise'); $page = $nk->getPage($id); if (!empty($_POST)) { if (!admin_check_csrf(CSRF_ID, CSRF_FIELD)) { form_error('OTHER'); } $fields = array( 'title' => '', 'content' => '', 'uri' => '', 'lang' => '', 'parent' => 0, 'allow_comments' => 0, 'content' => '', 'status' => 0, ); foreach ($fields as $key => $value) { if (is_int($value)) { if (!array_key_exists($key, $_POST)) { $page[$key] = $value; } else { $page[$key] = (int) $_POST[$key]; } } else { if (!array_key_exists($key, $_POST)) { form_error('OTHER'); } else { $page[$key] = trim((string)$_POST[$key]); } } } if (empty($page['title'])) form_error('EMPTY_TITLE'); if (empty($page['lang'])) form_error('EMPTY_LANG'); if (!utils::checkLangCode($page['lang'])) form_error('INVALID_LANG'); if (array_key_exists('comment', $_POST)) $comment = trim($_POST['comment']); if (!form_has_errors()) { $nk->editPage($id, $page, $comment); if (!isset($_GET['inFrame'])) { header('Location: '.$nk->getPageURI($page)); exit; } else { inc('_reload'); exit; } } } tpl_assign($page); tpl_assign('comment', $comment); tpl_assign('csrf_check', utils::CSRF_create(CSRF_ID)); tpl_error('OTHER', 'Une erreur technique est survenue, merci de bien vouloir renvoyer le formulaire.'); tpl_error('EMPTY_TITLE', 'Le titre ne peut ĂȘtre vide.'); tpl_error('EMPTY_LANG', 'Vous devez choisir une langue pour cette page.'); tpl_error('INVALID_LANG', 'Cette langue est invalide ou inconnue.'); inc('page_edit'); ?>