Advertisement
Guest User

Untitled

a guest
Jul 10th, 2018
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.37 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. error_reporting(E_ALL);
  5. ini_set('display_errors', 1);
  6. require('../required/db.php');
  7. require('../assets/nav.html');
  8.  
  9. if (isset($_SESSION['admin'])) {
  10.   if ($_SESSION['admin'] = 'positive') {
  11.  
  12.   }else {
  13.    header('Location:---');
  14.   }
  15. }else {
  16.  header('Location: ---');
  17. }
  18.  
  19. ?>
  20.  
  21.  
  22.     <!DOCTYPE html>
  23.     <html>
  24.        <head>
  25.           <meta charset="UTF-8">
  26.           <meta name="viewport" content="width=device-width,initial-scale=1">
  27.           <title>Blog - Admin</title>
  28.           <link rel="shortcut icon" href="../assets/favicon.ico">
  29.           <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  30.           <link rel="stylesheet" href="../assets/css/style.css" type="text/css">
  31.           <link rel="ico" href="../assets/favicon.ico">
  32.        </head>
  33.        <body>
  34.           <div class="cont">
  35.              <div class="flol">
  36.                <h1>Make a Post</h1>
  37.                 <form method="post">
  38.                    <input type="text" placeholder="Post Title" class="input-box top-margin" name="title" required maxlength="40">
  39.                    <br>
  40.                    <input type="text" placeholder="Author Name" class="input-box top-margin" name="author" required>
  41.                    <br>
  42.                    <input type="text" placeholder="Short Preview Text" class="input-box top-margin" name="ptext" required>
  43.                    <br>
  44.                    <input type="text" class="top-margin input-box top-margin" placeholder="Insert an image path..." name="imagepath" required>
  45.                    <br>
  46.                    <input type="text" class="top-margin input-box top-margin" placeholder="Enter Tags..." name="tags" required>
  47.                    <br>
  48.                    <input type="text" class="top margin input-box top-margin" placeholder="Enter Hidden Tags..." name="hidden_tags" required>
  49.                    <br>
  50.                    <textarea class="input-box top-margin" style="height:150px;" name="body" required></textarea>
  51.                    <br>
  52.                    <input type="submit" value="Launch Post" class="long-btn btn-def top-margin bottom-margin" name="post">
  53.                 </form>
  54.      
  55.                
  56.              </div>
  57.              <div class="flor">
  58.                <h1>Statistics</h1>
  59.                <h6><em>Sitewide Data Collection Enforced 26 / 6 / 18 8:35 PM</em></h6>
  60.                <?php
  61.                $sql = "SELECT COUNT(*) as value FROM ips";
  62.            $result = $con->query($sql);
  63.        
  64.         if ($result->num_rows > 0) {
  65.             // output data of each row
  66.             while($row = $result->fetch_assoc()) {
  67.                 echo '
  68.                   There have been '.$row['value'].' views overall<br>
  69.                
  70.               ';       
  71.                 }
  72.         } else {
  73.             echo "Whoops! The month must just started! We have no data for you.";
  74.         }
  75.         $date = date('M Y');
  76.         $sql = "SELECT COUNT(*) as value FROM ippm WHERE date='$date'";
  77.            $result = $con->query($sql);
  78.        
  79.         if ($result->num_rows > 0) {
  80.             // output data of each row
  81.             while($row = $result->fetch_assoc()) {
  82.                 echo '
  83.                   There have been '.$row['value'].' SW Views This Month
  84.                 </div>
  85.               </div>';         
  86.                 }
  87.         } else {
  88.             echo "Whoops! The month must just started! We have no data for you.";
  89.         }
  90.        
  91.     echo '<div style="padding-top:700px;"><div>';
  92.     $sql="SELECT id,title,author,prev_text,body FROM posts ORDER BY id DESC";
  93.  
  94.     if ($result=mysqli_query($con,$sql))
  95.   {
  96.   // Fetch one and one row
  97.   while ($row=mysqli_fetch_row($result))
  98.     {
  99.      
  100.       printf('<a href="view_post.php?post_id='.$row['0'].'"><div class="row"><div class="row-inner"><p><strong>%s</strong></a> | %s | <a style="color:#42d7f4; text-decoration:none;" href="/admin/edit.php?edid='.$row['0'].'">Edit</a> | <a style="color:red; text-decoration:none;" href="https://willwam.com/admin/delete.php?delposid='.$row['0'].'">Delete</a></p></div></div>', $row[0],$row[1], $row[2], $row[3]);
  101.   }
  102.  
  103.   // Free result set
  104.   mysqli_free_result($result);
  105. }
  106.  
  107. mysqli_close($con);
  108.  
  109. echo '</div></div>';
  110.        
  111.  
  112. ?>
  113.  
  114. <div class="wrapper">
  115.   <div class="container">
  116.     <form method="post" action="---">
  117.       <input type="submit" class="btn btn-def" name="logout" value="Log Out">
  118.     </form>
  119.   </div>
  120. </div>
  121.  
  122.              
  123.  
  124.  
  125.        
  126.  
  127. <?php
  128.  
  129.             if (isset($_POST['post'])) {
  130.               date_default_timezone_set('America/Chicago');
  131.               $title = $_POST['title'];
  132.               $author = $_POST['author'];
  133.               $ptext = $_POST['ptext'];
  134.               $imgpath = $_POST['imagepath'];
  135.               $tags = $_POST['tags'];
  136.               $hidden_tags = $_POST['hidden_tags'];
  137.               $body = $_POST['body'];
  138.               $post_date = date('Y/m/d H:i:s');
  139.               $pad = date('M Y');
  140.  
  141.  
  142.           $stmt = $con->prepare("INSERT INTO posts (title, author, prev_text, img_path, tags, hidden_tags, body, post_date, pad) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
  143.           $stmt->bind_param("sssssssss", $title, $author, $ptext, $imgpath, $tags, $hidden_tags, $body, $post_date, $pad);
  144.  
  145.  
  146.               $stmt->execute();
  147.               $stmt->close();
  148.  
  149.               header('Location: ---');
  150.             }
  151.            
  152.           if (isset($_POST['logout'])) {
  153.    
  154.             session_destroy();
  155.           }
  156.            
  157.          
  158.          
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement