Guest User

Untitled

a guest
Jun 23rd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.50 KB | None | 0 0
  1. <?php
  2. include 'allowhtml/allowHTML.php';
  3. class CMS {
  4.    
  5.     public $dbhost;
  6.     public $dbusername;
  7.     public $dbpassword;
  8.     public $db;
  9.    
  10.     function __construct()
  11.     {
  12.         $this->dbhost = 'localhost';
  13.         $this->dbusername = 'root';
  14.         $this->dbpassword = 'thehundreds';
  15.         $this->db = 'oopsite';
  16.    
  17.     }
  18.    
  19.     function connect() {
  20.         $con = mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword);
  21.         if (!$con)
  22.         {
  23.             die('Could not connect: ' . mysql_error());
  24.         }
  25.        
  26.         mysql_select_db($this->db, $con);
  27.        
  28.     }
  29.  
  30. function get_BlogContent($inID = null) {
  31.        
  32.         if ($inID != null)
  33.         {
  34.             $inID = mysql_real_escape_string($inID);
  35.             $sql = "SELECT * FROM blog_posts WHERE id = '{$inID}'";
  36.             echo "<p><a href='blog.php'>Back to blog</a></p>";
  37.        
  38.         }
  39.         else
  40.         {
  41.             $sql = "SELECT * FROM blog_posts ORDER BY id DESC";
  42.         }
  43.        
  44.        
  45.         $res = mysql_query($sql) or die (mysql_error());
  46.        
  47.        
  48.         if(mysql_num_rows($res) != 0)
  49.         {
  50.            
  51.            
  52.             while ($row = mysql_fetch_assoc($res)) {
  53.            
  54.            
  55.             $body = $row['post'];
  56.             $safeBody = allowHTML($body);
  57.             echo '<div id="post1">';
  58.             echo '<h3><a href="blog.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h3>';
  59.             echo '<p>' . $safeBody . '</p>';
  60.             echo "<p class='p2'>Posted By - " . $this->getBlogPostAuthor($row['id']) . "</p>";
  61.             echo '<br>';
  62.             echo '<p class="p2">' . $row['date_posted'] . '</p>';
  63.             echo '</div>';
  64.             echo '<hr>';
  65.             echo '<br>';
  66.             }
  67.         }
  68.         else
  69.         {
  70.             echo "<p> No Posts Exist</p>";
  71.         }
  72.         echo $return;
  73.     }
  74.  
  75. }
Add Comment
Please, Sign In to add comment