} $id = (int) $_GET['id']; if ($id != '') { $content = get_content($link, $id); $content = $content['content']; $messages = get_messages($link); for ($i = 0; $i < count($messages); $i++) { if ($messages[$i]['id_new'] == $id) { $title = $messages[$i]['name']; } } } else { $content = 'Ошибка 404 - такой статьи нет!'; } if (isset($_POST['Delete'])) { delete_new($link, $id); header('Location: ../index.php'); exit; } elseif (isset($_POST['Save'])) { $title = trim($_POST['title']); $content = trim($_POST['content']); if ($content == '') { $message = "Незаполнено поле контент, а надо бы :)"; } elseif (mb_strlen($content) > 1000) { $message = "Статья превышает 1000 знаков! Будьте лаконичны ;)"; } elseif (new_exists($link, $id)) { update_new($link, $id, $content, $title); header('Location: ../index.php'); exit; } else { add_new($link, $title, $content, $id_user);
if ($_REQUEST['title']) { $rs_title = $_REQUEST['title']; } if ($_REQUEST['content']) { $rs_content = $_REQUEST['content']; } if ($_REQUEST['createDate']) { $rs_createDate = $_REQUEST['createDate']; } $result = update_new($rs_id, $rs_title, $rs_content, $rs_createDate, $rs_chondm); if (!$result) { echo "<div class='alert alert-block alert-danger fade in'>Lỗi! Không lưu được.</div>"; } } if (isset($_REQUEST['xoatin'])) { $result = delete_new($_REQUEST['xoatin']); if ($result) { echo "<div class='alert alert-block alert-success fade in'>Xóa thành công.</div>"; } else { echo "<div class='alert alert-block alert-danger fade in'>Lỗi! Không xóa được.</div>"; } } ?> <div class="row"> <div class="col-lg-12"> <h3 class="page-header"><i class="fa fa-laptop"></i> Tin tức</h3> <ol class="breadcrumb"> <li><i class="fa fa-home"></i><a href="admin.php">Trang chủ</a></li> <li><i class="fa fa-laptop"></i>Tin tức</li> </ol>