diff --git a/htdocs/application/controllers/api.php b/htdocs/application/controllers/api.php index afe2be6..8dadb3e 100644 --- a/htdocs/application/controllers/api.php +++ b/htdocs/application/controllers/api.php @@ -129,7 +129,7 @@ class Api extends Main show_404(); } $this->load->model('pastes'); - $pastes = $this->pastes->getLists(); + $pastes = $this->pastes->getLists('api/recent'); $pastes = $pastes['pastes']; $data = array(); foreach ($pastes as $paste) @@ -153,7 +153,7 @@ class Api extends Main show_404(); } $this->load->model('pastes'); - $pastes = $this->pastes->getTrends(); + $pastes = $this->pastes->getTrends('api/trending',2); $pastes = $pastes['pastes']; $data = array(); foreach ($pastes as $paste) diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 9c1bcb2..92cce00 100644 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -26,7 +26,7 @@ class Pastes extends CI_Model { - + function __construct() { parent::__construct(); @@ -470,6 +470,8 @@ class Pastes extends CI_Model // query if($this->db->dbdriver == "postgre") { $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $amount OFFSET $page"; + } else if ($root == 'api/recent'){ + $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT 0,15"; } else { $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $page,$amount"; } @@ -551,7 +553,9 @@ class Pastes extends CI_Model // query if($this->db->dbdriver == "postgre") { $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $amount OFFSET $page"; - } else { + } else if ($root == "api/trending"){ + $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT 0,15"; + }else { $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $page,$amount"; } $query = $this->db->query($sql, array(