diff --git a/htdocs/application/config/routes.php b/htdocs/application/config/routes.php index dbe2e55..cfe947f 100644 --- a/htdocs/application/config/routes.php +++ b/htdocs/application/config/routes.php @@ -52,6 +52,8 @@ $route['view/:any'] = 'main/view'; $route['lists'] = 'main/lists'; $route['lists/rss'] = 'main/lists/rss'; $route['lists/:num'] = 'main/lists/$1'; +$route['trends'] = 'main/trends'; +$route['trends/:any'] = 'main/trends/$1'; $route['spamadmin/:num'] = 'spamadmin/index'; $route['spamadmin/blacklist/unblock/(:any)'] = 'spamadmin/unblock_ip'; $route['spamadmin/blacklist/(:num)'] = 'spamadmin/blacklist'; diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index 062688f..accd0be 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -10,6 +10,7 @@ * - embed() * - download() * - lists() + * - trends() * - view() * - cron() * - about() @@ -470,6 +471,22 @@ class Main extends CI_Controller } } + function trends() + { + $this->_valid_authentication(); + + if ($this->config->item('private_only')) + { + show_404(); + } + else + { + $this->load->model('pastes'); + $data = $this->pastes->getTrends(); + $this->load->view('list', $data); + } + } + function view() { $this->_valid_authentication(); diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index e414e5d..f661d0d 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -333,6 +333,49 @@ class Pastes extends CI_Model return $data; } + function getTrends($root = 'lists/', $seg = 2) + { + $this->load->library('pagination'); + $this->load->library('process'); + $amount = $this->config->item('per_page'); + $page = ($this->uri->segment(2) ? $this->uri->segment(2) : 0); + $this->db->select('id, title, name, created, pid, lang, raw'); + $this->db->where('private', 0); + $this->db->order_by('created', 'desc'); + $query = $this->db->get('pastes', $amount, $page); + + if ($query->num_rows() > 0) + { + $n = 0; + foreach ($query->result_array() as $row) + { + $data['pastes'][$n]['id'] = $row['id']; + $data['pastes'][$n]['title'] = $row['title']; + $data['pastes'][$n]['name'] = $row['name']; + $data['pastes'][$n]['created'] = $row['created']; + $data['pastes'][$n]['lang'] = $row['lang']; + $data['pastes'][$n]['pid'] = $row['pid']; + + if ($this->uri->segment(2) == 'rss') + { + $data['pastes'][$n]['paste'] = $this->process->syntax(htmlspecialchars_decode($row['raw']) , $row['lang']); + } + $data['pastes'][$n]['raw'] = $row['raw']; + $n++; + } + } + $config['base_url'] = site_url($root); + $config['total_rows'] = $this->countPastes(); + $config['per_page'] = $amount; + $config['num_links'] = 9; + $config['full_tag_open'] = '