Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "database.php";
- /* Blog System */
- class Blog
- {
- private $databaseName = "blog";
- function __construct($app=null)
- {
- $this->app = $app;
- }
- function tags($postID=null)
- {
- $ret = array();
- $con = DatabaseConnect(1);
- if($postID!==null)
- {
- $query = "Select tag from {$this->databaseName}.post_tags where post=".mysql_real_escape_string($postID);
- $result = mysql_query($query,$con);
- while($row = mysql_fetch_array($result))
- array_push($ret,$row['tag']);
- }
- else
- {
- $query = "Select tag,quantity from {$this->databaseName}.popularblogtags";
- $result = mysql_query($query,$con);
- while($row = mysql_fetch_array($result))
- array_push($ret,array(
- 'tag' => $row['tag'],
- 'quantity' => $row['quantity']
- ));
- }
- return $ret;
- }
- function posts($conditions="true")
- {
- $con = DatabaseConnect(1);
- $query = "select * from {$this->databaseName}.posts where true and($conditions)";
- $result = mysql_query($query,$con) or die(mysql_error());
- $ret = array();
- while($row = mysql_fetch_array($result))
- array_push($ret,array(
- 'id' => $row['id'],
- 'title' => $row['title'],
- 'content' => $row['content'],
- 'description' => $row['description'],
- 'modified' => strtotime($row['modified']),
- 'meta' => array(
- 'tag' => $this->tags($row['id']),
- 'date' => $row['modified'],
- 'author' => $row['author']
- ),
- 'type' => $row['sticky']==0?'post':'page'
- ));
- return $ret;
- }
- function authors($conditions="true")
- {
- $con = DatabaseConnect(1);
- $query = "Select distinct author from {$this->databaseName}.posts where true and ($conditions)";
- $result = mysql_query($query,$con);
- $ret = array();
- while($row = mysql_fetch_array($result))
- array_push($ret,$row['author']);
- return $ret;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement