From e5afc20e9b77eb942e53b4a3500614337fdaccfc Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 11:36:35 +0200 Subject: [PATCH] spamadmin view --- htdocs/application/config/routes.php | 1 + htdocs/application/controllers/spamadmin.php | 22 +-------- htdocs/application/models/pastes.php | 47 ++++++++++++++++++++ htdocs/application/views/spamlist.php | 44 ++++++++++++++++++ 4 files changed, 94 insertions(+), 20 deletions(-) create mode 100755 htdocs/application/views/spamlist.php diff --git a/htdocs/application/config/routes.php b/htdocs/application/config/routes.php index 5e8a6c5..8a8d923 100644 --- a/htdocs/application/config/routes.php +++ b/htdocs/application/config/routes.php @@ -52,6 +52,7 @@ $route['view/:any'] = 'main/view'; $route['lists'] = 'main/lists'; $route['lists/rss'] = 'main/lists/rss'; $route['lists/:num'] = 'main/lists/$1'; +$route['spamadmin/:num'] = 'spamadmin/index'; $route['about'] = 'main/about'; $route['iphone/:num'] = 'iphone'; diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index f46a3b3..cdd72e5 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -4,7 +4,6 @@ * Function list: * - __construct() * - index() - * - lists() * Classes list: * - Spamadmin extends CI_Controller */ @@ -18,26 +17,9 @@ class Spamadmin extends CI_Controller } function index() - { - } - - function lists() { $this->load->model('pastes'); - $data = $this->pastes->getLists(); - - if ($this->uri->segment(2) == 'rss') - { - $this->load->helper('text'); - $data['page_title'] = $this->config->item('site_name'); - $data['feed_url'] = site_url('lists/rss'); - $data['replies'] = $data['pastes']; - unset($data['pastes']); - $this->load->view('view/rss', $data); - } - else - { - $this->load->view('list', $data); - } + $data = $this->pastes->getSpamLists(); + $this->load->view('spamlist', $data); } } diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 37972be..761a03b 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -10,6 +10,7 @@ * - getPaste() * - getReplies() * - getLists() + * - getSpamLists() * - cron() * Classes list: * - Pastes extends CI_Model @@ -366,6 +367,52 @@ class Pastes extends CI_Model return $data; } + function getSpamLists($root = 'spamadmin/', $seg = 2) + { + $this->load->library('pagination'); + $this->load->library('process'); + $amount = $this->config->item('per_page'); + + if (!$this->uri->segment(2)) + { + $page = 0; + } + else + { + $page = $this->uri->segment(2); + } + $this->db->select('id, title, name, created, pid, lang, session_id'); + $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']; + $data['pastes'][$n]['session_id'] = $row['session_id']; + $n++; + } + } + $config['base_url'] = site_url($root); + $config['total_rows'] = $this->countPastes(); + $config['per_page'] = $amount; + $config['num_links'] = 9; + $config['full_tag_open'] = '
'; + $config['full_tag_close'] = '
'; + $config['uri_segment'] = $seg; + $this->pagination->initialize($config); + $data['pages'] = $this->pagination->create_links(); + return $data; + } + function cron() { $now = now(); diff --git a/htdocs/application/views/spamlist.php b/htdocs/application/views/spamlist.php new file mode 100755 index 0000000..b388a28 --- /dev/null +++ b/htdocs/application/views/spamlist.php @@ -0,0 +1,44 @@ +load->view('defaults/header');?> +

Spamadmin

+ + + + + + + + + + + + + + + + + + + + + + + +
TitleNameLanguageWhenSession
"> ago.[...]
+ +

There have been no pastes :(

+ + +
+load->view('defaults/footer');?>