Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'allowhtml/allowHTML.php';
- class CMS {
- public $dbhost;
- public $dbusername;
- public $dbpassword;
- public $db;
- function __construct()
- {
- $this->dbhost = 'localhost';
- $this->dbusername = 'root';
- $this->dbpassword = 'thehundreds';
- $this->db = 'oopsite';
- }
- function connect() {
- $con = mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword);
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db($this->db, $con);
- }
- function get_BlogContent($inID = null) {
- if ($inID != null)
- {
- $inID = mysql_real_escape_string($inID);
- $sql = "SELECT * FROM blog_posts WHERE id = '{$inID}'";
- echo "<p><a href='blog.php'>Back to blog</a></p>";
- }
- else
- {
- $sql = "SELECT * FROM blog_posts ORDER BY id DESC";
- }
- $res = mysql_query($sql) or die (mysql_error());
- if(mysql_num_rows($res) != 0)
- {
- while ($row = mysql_fetch_assoc($res)) {
- $body = $row['post'];
- $safeBody = allowHTML($body);
- echo '<div id="post1">';
- echo '<h3><a href="blog.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h3>';
- echo '<p>' . $safeBody . '</p>';
- echo "<p class='p2'>Posted By - " . $this->getBlogPostAuthor($row['id']) . "</p>";
- echo '<br>';
- echo '<p class="p2">' . $row['date_posted'] . '</p>';
- echo '</div>';
- echo '<hr>';
- echo '<br>';
- }
- }
- else
- {
- echo "<p> No Posts Exist</p>";
- }
- echo $return;
- }
- }
Add Comment
Please, Sign In to add comment