Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('inc/config.php');
- include('inc/functions.php');
- if(!isset($_SESSION['id'])) header('Location: index.php');
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <?php include('inc/head.php'); ?>
- </head>
- <body>
- <?php include('inc/navbar.php'); ?>
- <div id="page-wrapper">
- <div class="container-fluid">
- <div class="row">
- <div class="col-lg-12">
- <h1 class="page-header">
- Dashboard
- </h1>
- <ol class="breadcrumb">
- <li class="active">
- <i class="fa fa-dashboard"></i> Dashboard
- </li>
- </ol>
- </div>
- </div>
- <center>
- <?php
- if(isset($_POST['sendnews'])){
- $textnews = dbin($_POST['textnews']);
- $titlenews = dbin($_POST['titlenews']);
- $errorsnews = array();
- if(strlen($titlenews) < 1){
- $errorsnews[1] = 'Insert a title!';
- }
- if(strlen($textnews) < 1){
- $errorsnews[1] = 'Enter any text for the news!';
- }
- if(count($errorsnews) == 0){
- $username = dbin($_SESSION['realname']);
- mysqli_query($conn, "INSERT INTO $dbsite.news(id, title, text, author) VALUES(NULL, '$titlenews', '$textnews', '$username'");
- echo '<p class="alert alert-success">News inserted successfully!</p>';
- echo '<meta http-equiv="refresh" content="3;url=news.php" />';
- }else{
- foreach($errorsnews as $listnews){
- echo '<p class="alert alert-danger">',$listnews,'</p>';
- }
- }
- }
- ?>
- <script src="js/tiny/tinymce.min.js" language="javascript" type="text/javascript"></script>
- <script language="javascript" type="text/javascript">
- tinyMCE.init({
- mode : "specific_textareas",
- editor_selector : "mceEditor"
- });
- </script>
- <h2>News </h2>
- <div style="width: 50%;">
- <form action='' method='POST'>
- <b>
- <p>Title: <input class="form-control" type="text" name="titlenews"/></p>
- <br />
- <p>Text: <textarea id="myarea1" class="mceEditor" name="textnews"> </textarea></p>
- <br />
- <button type="submit" class="btn btn-success" name="sendnews">Send</button>
- <button type="reset" class="btn btn-danger">Reset</button>
- </b>
- </form>
- </div>
- <hr />
- <h2>List News</h2>
- <?php
- if(isset($_POST['id'])){
- $id = dbin($_POST['id']);
- mysqli_query($conn, "DELETE FROM $dbsite.news WHERE id='$id'");
- echo '<p class="alert alert-success">Deleted successfully!</p>';
- echo '<meta http-equiv="refresh" content="3;url=news.php" />';
- }
- $page = dbin(@$_GET['p']);
- $pag = dbin(($page + 0)*10);
- $listnews = mysqli_query($conn, "SELECT * FROM $dbsite.news ORDER BY date LIMIT $pag,10");
- if($listnews && mysqli_num_rows($listnews) > 0){
- ?>
- <div class="mex">
- <table>
- <thead>
- <tr>
- <th>Title:</th>
- <th>Text:</th>
- <th>Author:</th>
- <th>Date:</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <?php
- while($listrow = mysqli_fetch_assoc($listnews)){
- ?>
- <form action="" method="POST">
- <tr>
- <td><textarea class="form-control" disabled><?php echo $listrow['title']; ?></textarea></td>
- <td><textarea class="form-control" disabled><?php echo $listrow['text']; ?></textarea></td>
- <td><input class="form-control" type="text" value="<?php echo $listrow['author']; ?>" disabled /></td>
- <td><input class="form-control"type="text" value="<?php echo $listrow['date']; ?>" disabled /></td>
- <td><button type="submit" name="id" class="btn btn-danger" value="<?php echo $listrow['id']; ?>">Delete</button></td>
- </tr>
- </form>
- <?php } ?>
- </tbody>
- </table>
- <ul class="pagination">
- <?php
- if($page != 0) echo '<li><a href="news.php?p=' .($page-1) .'">« Back</a></td></tr>';
- if($page < 50) echo '<li><a href="news.php?p=' .($page+1) .'">Forward »</a></td></tr>';
- ?>
- </ul>
- </div>
- <?php
- }else{
- echo '<p class="alert alert-danger">There are no news!</p>';
- echo'<ul class="pagination">';
- if($page > 0) echo '<li><a href="news.php?p=' .($page-1) .'">« Back</a></td></tr>';
- echo'</ul>';
- } ?>
- </center>
- </div>
- </div>
- </div>
- <?php include('inc/footer.php'); ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement