From 1d02b922b53e4124e63f1bbcc9d976f348447416 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 08:28:47 +0200 Subject: [PATCH 01/41] +spamadmin --- htdocs/application/controllers/spamadmin.php | 69 ++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 htdocs/application/controllers/spamadmin.php diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php new file mode 100755 index 0000000..a7ba2e3 --- /dev/null +++ b/htdocs/application/controllers/spamadmin.php @@ -0,0 +1,69 @@ +load->model('languages'); + + if (!$this->db->table_exists('pid_ip')) + { + $this->load->dbforge(); + $fields = array( + 'id' => array( + 'type' => 'INT', + 'constraint' => 10, + 'auto_increment' => TRUE, + ) , + 'pid' => array( + 'type' => 'VARCHAR', + 'constraint' => 8, + ) , + 'ip' => array( + 'type' => 'VARCHAR', + 'constraint' => 15, + ) , + ); + $this->dbforge->add_field($fields); + $this->dbforge->add_key('id', true); + $this->dbforge->add_key('pid'); + $this->dbforge->add_key('ip'); + $this->dbforge->create_table('pastes', true); + } + } + + 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); + } + } +} From b6288679dc0d9f6162d89254dc42991d79e4b037 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 08:30:17 +0200 Subject: [PATCH 02/41] table --- htdocs/application/controllers/spamadmin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index a7ba2e3..755efa7 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -39,7 +39,7 @@ class Spamadmin extends CI_Controller $this->dbforge->add_key('id', true); $this->dbforge->add_key('pid'); $this->dbforge->add_key('ip'); - $this->dbforge->create_table('pastes', true); + $this->dbforge->create_table('pid_ip', true); } } From ae00c1a480ceb27c98abcb0859ea91fda653cd28 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 08:47:27 +0200 Subject: [PATCH 03/41] tables --- htdocs/application/controllers/main.php | 11 ++++++++ htdocs/application/controllers/spamadmin.php | 28 +------------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index d88c650..a70bdfe 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -120,6 +120,11 @@ class Main extends CI_Controller 'type' => 'VARCHAR', 'constraint' => 8, ) , + 'session_id' => array( + 'type' => 'VARCHAR', + 'constraint' => 40, + 'null' => TRUE, + ) , ); $this->dbforge->add_field($fields); $this->dbforge->add_key('id', true); @@ -127,8 +132,14 @@ class Main extends CI_Controller $this->dbforge->add_key('private'); $this->dbforge->add_key('replyto'); $this->dbforge->add_key('created'); + $this->dbforge->add_key('session_id'); $this->dbforge->create_table('pastes', true); } + + //check if field session_id exists + //todo + + } function _form_prep($lang = false, $title = '', $paste = '', $reply = false) diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index 755efa7..f46a3b3 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -6,7 +6,7 @@ * - index() * - lists() * Classes list: - * - Main extends CI_Controller + * - Spamadmin extends CI_Controller */ class Spamadmin extends CI_Controller @@ -15,32 +15,6 @@ class Spamadmin extends CI_Controller function __construct() { parent::__construct(); - $this->load->model('languages'); - - if (!$this->db->table_exists('pid_ip')) - { - $this->load->dbforge(); - $fields = array( - 'id' => array( - 'type' => 'INT', - 'constraint' => 10, - 'auto_increment' => TRUE, - ) , - 'pid' => array( - 'type' => 'VARCHAR', - 'constraint' => 8, - ) , - 'ip' => array( - 'type' => 'VARCHAR', - 'constraint' => 15, - ) , - ); - $this->dbforge->add_field($fields); - $this->dbforge->add_key('id', true); - $this->dbforge->add_key('pid'); - $this->dbforge->add_key('ip'); - $this->dbforge->create_table('pid_ip', true); - } } function index() From b415f65249a9cb8a4d1a3ae4107b85408cafacb1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 09:13:09 +0200 Subject: [PATCH 04/41] blocked_ips --- htdocs/application/controllers/main.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index a70bdfe..809d3a7 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -135,6 +135,21 @@ class Main extends CI_Controller $this->dbforge->add_key('session_id'); $this->dbforge->create_table('pastes', true); } + + if (!$this->db->table_exists('blocked_ips')) + { + $this->load->dbforge(); + $fields = array( + 'ip_address' => array( + 'type' => 'VARCHAR', + 'constraint' => 16, + 'default' => 0, + ) , + ); + $this->dbforge->add_field($fields); + $this->dbforge->add_key('ip_address', true); + $this->dbforge->create_table('blocked_ips', true); + } //check if field session_id exists //todo From 1b8e236e4972c5eb1b25f759b4e1c09036774104 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 09:22:00 +0200 Subject: [PATCH 05/41] sessid --- htdocs/application/models/pastes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 76515ba..37972be 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -148,6 +148,7 @@ class Pastes extends CI_Model $data['snipurl'] = false; } } + $data['session_id'] = $this->input->cookie('ci_session'); $this->db->insert('pastes', $data); return 'view/' . $data['pid']; } From 83fac19ebe163659aa4d226a53dffca90778949c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 09:33:28 +0200 Subject: [PATCH 06/41] adding session_id --- htdocs/application/controllers/main.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index 809d3a7..cdc8268 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -152,9 +152,18 @@ class Main extends CI_Controller } //check if field session_id exists - //todo - + if (!$this->db->field_exists('session_id', 'pastes')) + { + $fields = array( + 'session_id' => array( + 'type' => 'VARCHAR', + 'constraint' => 40, + 'null' => TRUE, + ) , + ); + $this->dbforge->add_column('pastes', $fields); + } } function _form_prep($lang = false, $title = '', $paste = '', $reply = false) From 79d35012da440dfaa08c79154cdd0ac5e97e7c98 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 09:51:25 +0200 Subject: [PATCH 07/41] session expiration --- htdocs/application/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/application/config/config.php b/htdocs/application/config/config.php index 5a91023..72c01fb 100644 --- a/htdocs/application/config/config.php +++ b/htdocs/application/config/config.php @@ -245,7 +245,7 @@ $config['encryption_key'] = ''; | */ $config['sess_cookie_name'] = 'ci_session'; -$config['sess_expiration'] = 7200; +$config['sess_expiration'] = 30*24*60*60; $config['sess_expire_on_close'] = FALSE; $config['sess_encrypt_cookie'] = FALSE; $config['sess_use_database'] = TRUE; From e5afc20e9b77eb942e53b4a3500614337fdaccfc Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 11:36:35 +0200 Subject: [PATCH 08/41] 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');?> From 8a5d5f28445f001c34e5347f116746107d6fde6e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 11:42:32 +0200 Subject: [PATCH 09/41] sessionlist --- htdocs/application/config/routes.php | 1 + htdocs/application/controllers/spamadmin.php | 9 ++++ htdocs/application/views/list_sessionid.php | 44 ++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100755 htdocs/application/views/list_sessionid.php diff --git a/htdocs/application/config/routes.php b/htdocs/application/config/routes.php index 8a8d923..7bfac99 100644 --- a/htdocs/application/config/routes.php +++ b/htdocs/application/config/routes.php @@ -53,6 +53,7 @@ $route['lists'] = 'main/lists'; $route['lists/rss'] = 'main/lists/rss'; $route['lists/:num'] = 'main/lists/$1'; $route['spamadmin/:num'] = 'spamadmin/index'; +$route['spamadmin/session/:any'] = 'spamadmin/session'; $route['about'] = 'main/about'; $route['iphone/:num'] = 'iphone'; diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index cdd72e5..c5b2783 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -4,6 +4,7 @@ * Function list: * - __construct() * - index() + * - session() * Classes list: * - Spamadmin extends CI_Controller */ @@ -22,4 +23,12 @@ class Spamadmin extends CI_Controller $data = $this->pastes->getSpamLists(); $this->load->view('spamlist', $data); } + + function session() + { + $this->load->model('pastes'); + $session_id = 'sdf'; + $data = $this->pastes->getSpamLists($session_id); + $this->load->view('list_sessionid', $data); + } } diff --git a/htdocs/application/views/list_sessionid.php b/htdocs/application/views/list_sessionid.php new file mode 100755 index 0000000..b388a28 --- /dev/null +++ b/htdocs/application/views/list_sessionid.php @@ -0,0 +1,44 @@ +load->view('defaults/header');?> +

Spamadmin

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

There have been no pastes :(

+ + +
+load->view('defaults/footer');?> From 32106be13edd841496b6292529cadbc06024a129 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 12:51:45 +0200 Subject: [PATCH 10/41] sessionlist --- htdocs/application/controllers/spamadmin.php | 5 +++-- htdocs/application/models/pastes.php | 20 +++++++++++++++----- htdocs/application/views/list_sessionid.php | 4 +--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index c5b2783..59b808d 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -27,8 +27,9 @@ class Spamadmin extends CI_Controller function session() { $this->load->model('pastes'); - $session_id = 'sdf'; - $data = $this->pastes->getSpamLists($session_id); + $session_id = $this->uri->segment(3); + $data = $this->pastes->getSpamLists('spamadmin/session/' . $session_id, $seg = 4, $session_id); + $data['session_id'] = $session_id; $this->load->view('list_sessionid', $data); } } diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 761a03b..f771b82 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -24,9 +24,14 @@ class Pastes extends CI_Model parent::__construct(); } - function countPastes() + function countPastes($session_id = false) { $this->db->where('private', 0); + + if ($session_id) + { + $this->db->where('session_id', $session_id); + } $query = $this->db->get('pastes'); return $query->num_rows(); } @@ -367,22 +372,27 @@ class Pastes extends CI_Model return $data; } - function getSpamLists($root = 'spamadmin/', $seg = 2) + function getSpamLists($root = 'spamadmin/', $seg = 2, $session_id = false) { $this->load->library('pagination'); $this->load->library('process'); $amount = $this->config->item('per_page'); - if (!$this->uri->segment(2)) + if (!$this->uri->segment($seg)) { $page = 0; } else { - $page = $this->uri->segment(2); + $page = $this->uri->segment($seg); } $this->db->select('id, title, name, created, pid, lang, session_id'); $this->db->where('private', 0); + + if ($session_id) + { + $this->db->where('session_id', $session_id); + } $this->db->order_by('created', 'desc'); $query = $this->db->get('pastes', $amount, $page); @@ -402,7 +412,7 @@ class Pastes extends CI_Model } } $config['base_url'] = site_url($root); - $config['total_rows'] = $this->countPastes(); + $config['total_rows'] = $this->countPastes($session_id); $config['per_page'] = $amount; $config['num_links'] = 9; $config['full_tag_open'] = '
'; diff --git a/htdocs/application/views/list_sessionid.php b/htdocs/application/views/list_sessionid.php index b388a28..e4d6f4e 100755 --- a/htdocs/application/views/list_sessionid.php +++ b/htdocs/application/views/list_sessionid.php @@ -1,5 +1,5 @@ load->view('defaults/header');?> -

Spamadmin

+

Spamadmin - Pastes for sessionid

Name Language When - Session ago. - [...] From a80dfde39f724a5722788dd10eead822288e3ec4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 13:16:33 +0200 Subject: [PATCH 11/41] ip --- htdocs/application/controllers/spamadmin.php | 6 ++++++ htdocs/application/views/list_sessionid.php | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index 59b808d..7a506e0 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -28,8 +28,14 @@ class Spamadmin extends CI_Controller { $this->load->model('pastes'); $session_id = $this->uri->segment(3); + $this->db->select('ip_address'); + $this->db->where('session_id', $session_id); + $query = $this->db->get('ci_sessions'); + $r = $query->result_array(); + $ip_address = $r[0]['ip_address']; $data = $this->pastes->getSpamLists('spamadmin/session/' . $session_id, $seg = 4, $session_id); $data['session_id'] = $session_id; + $data['ip_address'] = $ip_address; $this->load->view('list_sessionid', $data); } } diff --git a/htdocs/application/views/list_sessionid.php b/htdocs/application/views/list_sessionid.php index e4d6f4e..2f5c6ab 100755 --- a/htdocs/application/views/list_sessionid.php +++ b/htdocs/application/views/list_sessionid.php @@ -1,5 +1,18 @@ load->view('defaults/header');?> -

Spamadmin - Pastes for sessionid

+

Spamadmin - Pastes for sessionid

+ +
+ +
+ +
+ +
+ +
+
+ +
Date: Thu, 14 Jun 2012 13:25:29 +0200 Subject: [PATCH 12/41] removal action --- htdocs/application/controllers/spamadmin.php | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index 7a506e0..95ed986 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -27,15 +27,38 @@ class Spamadmin extends CI_Controller function session() { $this->load->model('pastes'); + + //sessionid $session_id = $this->uri->segment(3); + + //get ip $this->db->select('ip_address'); $this->db->where('session_id', $session_id); $query = $this->db->get('ci_sessions'); $r = $query->result_array(); $ip_address = $r[0]['ip_address']; + + //removal + + if ($this->input->post('confirm_remove') && $session_id != '') + { + $this->db->where('session_id', $session_id); + $this->db->delete('pastes'); + + if ($this->input->post('block_ip')) + { + $this->db->insert('blocked_ips', array( + 'ip_address' => $ip_address + )); + } + } + + //fill data $data = $this->pastes->getSpamLists('spamadmin/session/' . $session_id, $seg = 4, $session_id); $data['session_id'] = $session_id; $data['ip_address'] = $ip_address; + + //view $this->load->view('list_sessionid', $data); } } From c747bd54aef8c1f8c96fbf49491c6df4d0ab9c95 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 13:29:57 +0200 Subject: [PATCH 13/41] block_it --- htdocs/application/views/list_sessionid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/application/views/list_sessionid.php b/htdocs/application/views/list_sessionid.php index 2f5c6ab..cf57962 100755 --- a/htdocs/application/views/list_sessionid.php +++ b/htdocs/application/views/list_sessionid.php @@ -4,7 +4,7 @@
- +
From 500b05cc7e05adad0bcbb99c312071cc690c53da Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 14:55:25 +0200 Subject: [PATCH 14/41] protection --- htdocs/application/config/stikked.php | 2 ++ htdocs/application/controllers/spamadmin.php | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/htdocs/application/config/stikked.php b/htdocs/application/config/stikked.php index be3c0fc..ece4fb3 100755 --- a/htdocs/application/config/stikked.php +++ b/htdocs/application/config/stikked.php @@ -72,6 +72,8 @@ $config['per_page'] = 10; **/ $config['private_only'] = false; $config['enable_captcha'] = false; +$config['spamadmin_user'] = ''; +$config['spamadmin_pass'] = ''; /** * Default language diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index 95ed986..560810e 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -15,6 +15,17 @@ class Spamadmin extends CI_Controller function __construct() { parent::__construct(); + + //protection + $user = $this->config->item('spamadmin_user'); + $pass = $this->config->item('spamadmin_pass'); + + if ($user == '' || $pass == '' || !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) + { + header('WWW-Authenticate: Basic realm="Backup"'); + header('HTTP/1.0 401 Unauthorized'); + exit; + } } function index() From 0116204a40f60db1158597449aca4fc28173d88d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 14 Jun 2012 15:36:53 +0200 Subject: [PATCH 15/41] must be valid ip --- htdocs/application/controllers/main.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index cdc8268..519a9b7 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -16,6 +16,7 @@ * - captcha() * - _valid_lang() * - _valid_captcha() + * - _valid_ip() * - get_cm_js() * - error_404() * Classes list: @@ -255,6 +256,11 @@ class Main extends CI_Controller 'label' => 'Captcha', 'rules' => 'callback__valid_captcha', ) , + array( + 'field' => 'valid_ip', + 'label' => 'Valid IP', + 'rules' => 'callback__valid_ip', + ) , ); //form validation @@ -476,6 +482,15 @@ class Main extends CI_Controller } } + function _valid_ip() + { + $this->form_validation->set_message('_valid_ip', 'You are not allowed to paste.'); + $query = $this->db->get_where('blocked_ips', array( + 'ip_address' => $this->input->ip_address() + ) , 1); + return count($query->result_array()) == 0; + } + function get_cm_js() { $lang = $this->uri->segment(3); From 052375267573744c6efff156e691ee1932e34ae3 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 26 Jun 2012 17:41:36 +0200 Subject: [PATCH 16/41] ip_address instead of session_id --- htdocs/application/controllers/main.php | 13 +++++++------ htdocs/application/models/pastes.php | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index 519a9b7..2d47034 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -121,9 +121,9 @@ class Main extends CI_Controller 'type' => 'VARCHAR', 'constraint' => 8, ) , - 'session_id' => array( + 'ip_address' => array( 'type' => 'VARCHAR', - 'constraint' => 40, + 'constraint' => 16, 'null' => TRUE, ) , ); @@ -133,7 +133,7 @@ class Main extends CI_Controller $this->dbforge->add_key('private'); $this->dbforge->add_key('replyto'); $this->dbforge->add_key('created'); - $this->dbforge->add_key('session_id'); + $this->dbforge->add_key('ip_address'); $this->dbforge->create_table('pastes', true); } @@ -154,12 +154,13 @@ class Main extends CI_Controller //check if field session_id exists - if (!$this->db->field_exists('session_id', 'pastes')) + if (!$this->db->field_exists('ip_address', 'pastes')) { + $this->load->dbforge(); $fields = array( - 'session_id' => array( + 'ip_address' => array( 'type' => 'VARCHAR', - 'constraint' => 40, + 'constraint' => 16, 'null' => TRUE, ) , ); diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index f771b82..82f0a39 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -154,7 +154,7 @@ class Pastes extends CI_Model $data['snipurl'] = false; } } - $data['session_id'] = $this->input->cookie('ci_session'); + $data['ip_address'] = $this->input->ip_address(); $this->db->insert('pastes', $data); return 'view/' . $data['pid']; } From 7eac462a1ff87ed65223d819025842916a7eddf9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 26 Jun 2012 18:14:45 +0200 Subject: [PATCH 17/41] ip admin --- htdocs/application/config/routes.php | 2 +- htdocs/application/controllers/main.php | 2 -- htdocs/application/controllers/spamadmin.php | 26 +++++-------------- htdocs/application/models/pastes.php | 18 ++++++------- .../views/{spamlist.php => list_ips.php} | 12 ++++----- .../{list_sessionid.php => spam_detail.php} | 10 +++---- 6 files changed, 28 insertions(+), 42 deletions(-) rename htdocs/application/views/{spamlist.php => list_ips.php} (81%) rename htdocs/application/views/{list_sessionid.php => spam_detail.php} (93%) diff --git a/htdocs/application/config/routes.php b/htdocs/application/config/routes.php index 7bfac99..dc97a0e 100644 --- a/htdocs/application/config/routes.php +++ b/htdocs/application/config/routes.php @@ -53,7 +53,7 @@ $route['lists'] = 'main/lists'; $route['lists/rss'] = 'main/lists/rss'; $route['lists/:num'] = 'main/lists/$1'; $route['spamadmin/:num'] = 'spamadmin/index'; -$route['spamadmin/session/:any'] = 'spamadmin/session'; +$route['spamadmin/:any'] = 'spamadmin/spam_detail'; $route['about'] = 'main/about'; $route['iphone/:num'] = 'iphone'; diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index 2d47034..de1299a 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -151,8 +151,6 @@ class Main extends CI_Controller $this->dbforge->add_key('ip_address', true); $this->dbforge->create_table('blocked_ips', true); } - - //check if field session_id exists if (!$this->db->field_exists('ip_address', 'pastes')) { diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index 560810e..d137acc 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -32,28 +32,17 @@ class Spamadmin extends CI_Controller { $this->load->model('pastes'); $data = $this->pastes->getSpamLists(); - $this->load->view('spamlist', $data); + $this->load->view('list_ips', $data); } - function session() + function spam_detail() { $this->load->model('pastes'); - - //sessionid - $session_id = $this->uri->segment(3); - - //get ip - $this->db->select('ip_address'); - $this->db->where('session_id', $session_id); - $query = $this->db->get('ci_sessions'); - $r = $query->result_array(); - $ip_address = $r[0]['ip_address']; - - //removal + $ip_address = $this->uri->segment(2); - if ($this->input->post('confirm_remove') && $session_id != '') + if ($this->input->post('confirm_remove') && $ip_address != '') { - $this->db->where('session_id', $session_id); + $this->db->where('ip_address', $ip_address); $this->db->delete('pastes'); if ($this->input->post('block_ip')) @@ -65,11 +54,10 @@ class Spamadmin extends CI_Controller } //fill data - $data = $this->pastes->getSpamLists('spamadmin/session/' . $session_id, $seg = 4, $session_id); - $data['session_id'] = $session_id; + $data = $this->pastes->getSpamLists('spamadmin/' . $ip_address, $seg = 3, $ip_address); $data['ip_address'] = $ip_address; //view - $this->load->view('list_sessionid', $data); + $this->load->view('spam_detail', $data); } } diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 82f0a39..1c25f2d 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -24,13 +24,13 @@ class Pastes extends CI_Model parent::__construct(); } - function countPastes($session_id = false) + function countPastes($ip_address = false) { $this->db->where('private', 0); - if ($session_id) + if ($ip_address) { - $this->db->where('session_id', $session_id); + $this->db->where('ip_address', $ip_address); } $query = $this->db->get('pastes'); return $query->num_rows(); @@ -372,7 +372,7 @@ class Pastes extends CI_Model return $data; } - function getSpamLists($root = 'spamadmin/', $seg = 2, $session_id = false) + function getSpamLists($root = 'spamadmin/', $seg = 2, $ip_address = false) { $this->load->library('pagination'); $this->load->library('process'); @@ -386,12 +386,12 @@ class Pastes extends CI_Model { $page = $this->uri->segment($seg); } - $this->db->select('id, title, name, created, pid, lang, session_id'); + $this->db->select('id, title, name, created, pid, lang, ip_address'); $this->db->where('private', 0); - if ($session_id) + if ($ip_address) { - $this->db->where('session_id', $session_id); + $this->db->where('ip_address', $ip_address); } $this->db->order_by('created', 'desc'); $query = $this->db->get('pastes', $amount, $page); @@ -407,12 +407,12 @@ class Pastes extends CI_Model $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']; + $data['pastes'][$n]['ip_address'] = $row['ip_address']; $n++; } } $config['base_url'] = site_url($root); - $config['total_rows'] = $this->countPastes($session_id); + $config['total_rows'] = $this->countPastes($ip_address); $config['per_page'] = $amount; $config['num_links'] = 9; $config['full_tag_open'] = '
'; diff --git a/htdocs/application/views/spamlist.php b/htdocs/application/views/list_ips.php similarity index 81% rename from htdocs/application/views/spamlist.php rename to htdocs/application/views/list_ips.php index b388a28..ed6fcf6 100755 --- a/htdocs/application/views/spamlist.php +++ b/htdocs/application/views/list_ips.php @@ -1,11 +1,11 @@ load->view('defaults/header');?>

Spamadmin

- @@ -14,7 +14,7 @@ - + + ?> - + -
Name Language WhenSessionIP
"> ago.[...]
+

There have been no pastes :(

diff --git a/htdocs/application/views/list_sessionid.php b/htdocs/application/views/spam_detail.php similarity index 93% rename from htdocs/application/views/list_sessionid.php rename to htdocs/application/views/spam_detail.php index cf57962..0a1933e 100755 --- a/htdocs/application/views/list_sessionid.php +++ b/htdocs/application/views/spam_detail.php @@ -1,5 +1,5 @@ load->view('defaults/header');?> -

Spamadmin - Pastes for sessionid

+

Spamadmin - Pastes for ip

@@ -14,11 +14,11 @@
- @@ -35,7 +35,7 @@ $eo = "odd"; } $n++; - ?> + ?> @@ -46,7 +46,7 @@ -
">
+

There have been no pastes :(

From 196a95410df939ea14dd8c8be388686fd1950106 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 26 Jun 2012 22:36:30 +0200 Subject: [PATCH 18/41] checked --- htdocs/application/views/spam_detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/application/views/spam_detail.php b/htdocs/application/views/spam_detail.php index 0a1933e..70b7e03 100755 --- a/htdocs/application/views/spam_detail.php +++ b/htdocs/application/views/spam_detail.php @@ -4,7 +4,7 @@
- +
From f7cf39c04b360dba95216790b27c57de6099c2eb Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Jul 2012 07:11:36 +0200 Subject: [PATCH 19/41] session time --- htdocs/application/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/application/config/config.php b/htdocs/application/config/config.php index 72c01fb..3ec5aca 100644 --- a/htdocs/application/config/config.php +++ b/htdocs/application/config/config.php @@ -245,7 +245,7 @@ $config['encryption_key'] = ''; | */ $config['sess_cookie_name'] = 'ci_session'; -$config['sess_expiration'] = 30*24*60*60; +$config['sess_expiration'] = 60*60*24*1; $config['sess_expire_on_close'] = FALSE; $config['sess_encrypt_cookie'] = FALSE; $config['sess_use_database'] = TRUE; From dc01a2d1b003f750dad0449b64e029b4eb681841 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Aug 2012 12:28:05 +0200 Subject: [PATCH 20/41] more strict ip blocker --- htdocs/application/controllers/main.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index de1299a..bff3323 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -483,10 +483,21 @@ class Main extends CI_Controller function _valid_ip() { + + //get ip + $ip = $this->input->ip_address(); + $ip = explode('.', $ip); + $ip_firstpart = $ip[0] . '.' . $ip[1] . '.'; + + //setup message $this->form_validation->set_message('_valid_ip', 'You are not allowed to paste.'); - $query = $this->db->get_where('blocked_ips', array( - 'ip_address' => $this->input->ip_address() - ) , 1); + + //lookup + $this->db->select('ip_address'); + $this->db->like('ip_address', $ip_firstpart, 'after'); + $query = $this->db->get('blocked_ips'); + + //return return count($query->result_array()) == 0; } From 81119ff8e451f04200ac2ce78c567d3f5b5b9312 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Aug 2012 22:42:24 +0200 Subject: [PATCH 21/41] spamadmin: basic styling --- htdocs/application/config/stikked.php | 4 ++-- htdocs/application/controllers/spamadmin.php | 2 +- htdocs/application/views/spam_detail.php | 22 ++++++++++++-------- htdocs/static/styles/main.css | 4 ++++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/htdocs/application/config/stikked.php b/htdocs/application/config/stikked.php index ece4fb3..dc7b27f 100755 --- a/htdocs/application/config/stikked.php +++ b/htdocs/application/config/stikked.php @@ -72,8 +72,8 @@ $config['per_page'] = 10; **/ $config['private_only'] = false; $config['enable_captcha'] = false; -$config['spamadmin_user'] = ''; -$config['spamadmin_pass'] = ''; +$config['spamadmin_user'] = 'a'; +$config['spamadmin_pass'] = 'a'; /** * Default language diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index d137acc..23c2b24 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -22,7 +22,7 @@ class Spamadmin extends CI_Controller if ($user == '' || $pass == '' || !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) { - header('WWW-Authenticate: Basic realm="Backup"'); + header('WWW-Authenticate: Basic realm="Spamadmin"'); header('HTTP/1.0 401 Unauthorized'); exit; } diff --git a/htdocs/application/views/spam_detail.php b/htdocs/application/views/spam_detail.php index 70b7e03..6b5de64 100755 --- a/htdocs/application/views/spam_detail.php +++ b/htdocs/application/views/spam_detail.php @@ -1,16 +1,20 @@ load->view('defaults/header');?>

Spamadmin - Pastes for ip

- - -
- -
+
 
-
- -
- +
+
+ +
+ +
+ + +
+
diff --git a/htdocs/static/styles/main.css b/htdocs/static/styles/main.css index 99b60d5..208f94f 100644 --- a/htdocs/static/styles/main.css +++ b/htdocs/static/styles/main.css @@ -254,6 +254,10 @@ h4 { margin-top: 20px; } +.form_wrapper .dangerbutton:hover { + background: #f00; +} + .form_wrapper .message_wrapper .message { margin-top: -10px; } From 1d5303de409518ec3cd576ef168ac72693b9ae6c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Aug 2012 22:45:38 +0200 Subject: [PATCH 22/41] clear --- htdocs/application/views/spam_detail.php | 2 +- htdocs/static/styles/main.css | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/application/views/spam_detail.php b/htdocs/application/views/spam_detail.php index 6b5de64..231bfbb 100755 --- a/htdocs/application/views/spam_detail.php +++ b/htdocs/application/views/spam_detail.php @@ -52,7 +52,7 @@ -

There have been no pastes :(

+

There have been no pastes :(

diff --git a/htdocs/static/styles/main.css b/htdocs/static/styles/main.css index 208f94f..98abf27 100644 --- a/htdocs/static/styles/main.css +++ b/htdocs/static/styles/main.css @@ -267,6 +267,10 @@ h4 { height: 1px; } +.clear { + clear: both; +} + .explain { font-size: 12px; color: #666; From c872b5339c99a02668fa3e7e7f10b5fd8b741ad2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Aug 2012 22:56:47 +0200 Subject: [PATCH 23/41] confirm removal --- htdocs/application/controllers/spamadmin.php | 4 +++- htdocs/application/views/spam_detail.php | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index 23c2b24..4d6da3e 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -4,7 +4,7 @@ * Function list: * - __construct() * - index() - * - session() + * - spam_detail() * Classes list: * - Spamadmin extends CI_Controller */ @@ -44,6 +44,8 @@ class Spamadmin extends CI_Controller { $this->db->where('ip_address', $ip_address); $this->db->delete('pastes'); + + //todo: catch duplicate error if ($this->input->post('block_ip')) { diff --git a/htdocs/application/views/spam_detail.php b/htdocs/application/views/spam_detail.php index 231bfbb..993a0fc 100755 --- a/htdocs/application/views/spam_detail.php +++ b/htdocs/application/views/spam_detail.php @@ -12,7 +12,11 @@
+uri->segment(3) == 'confirm') { ?> + +

Remove all pastes below

+
From 22e9e548fed07a97c9d9a70f76b13a3131f1ec53 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Aug 2012 23:03:10 +0200 Subject: [PATCH 24/41] styling --- htdocs/application/views/spam_detail.php | 13 +++++++------ htdocs/static/styles/main.css | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/application/views/spam_detail.php b/htdocs/application/views/spam_detail.php index 993a0fc..c6dd0d7 100755 --- a/htdocs/application/views/spam_detail.php +++ b/htdocs/application/views/spam_detail.php @@ -5,18 +5,19 @@
+uri->segment(3) == 'confirm') { ?> + + + +
- -uri->segment(3) == 'confirm') { ?> - - -

Remove all pastes below

-
diff --git a/htdocs/static/styles/main.css b/htdocs/static/styles/main.css index 98abf27..369bb6b 100644 --- a/htdocs/static/styles/main.css +++ b/htdocs/static/styles/main.css @@ -220,6 +220,11 @@ h4 { float: left; } +.form_wrapper .text_beside_wide { + width: 223px; + float: left; +} + .form_wrapper .text_beside input, .form_wrapper .item_group .item .text_beside input { margin-right: 5px; float: left; From 59e6a12d8219bd8fc9f2689404e52a3057ca7c27 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Aug 2012 23:13:09 +0200 Subject: [PATCH 25/41] docs --- htdocs/application/config/stikked.php | 1 + htdocs/application/controllers/main.php | 5 +++++ htdocs/application/controllers/spamadmin.php | 3 +++ htdocs/application/views/spam_detail.php | 4 ++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/application/config/stikked.php b/htdocs/application/config/stikked.php index dc7b27f..482f1bd 100755 --- a/htdocs/application/config/stikked.php +++ b/htdocs/application/config/stikked.php @@ -72,6 +72,7 @@ $config['per_page'] = 10; **/ $config['private_only'] = false; $config['enable_captcha'] = false; +//spamadmin: accessible via /spamadmin (only active when user + pass is set) $config['spamadmin_user'] = 'a'; $config['spamadmin_pass'] = 'a'; diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index bff3323..ac2113b 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -146,6 +146,11 @@ class Main extends CI_Controller 'constraint' => 16, 'default' => 0, ) , + 'spam_attempts' => array( + 'type' => 'INT', + 'constraint' => 6, + 'default' => 0, + ) , ); $this->dbforge->add_field($fields); $this->dbforge->add_key('ip_address', true); diff --git a/htdocs/application/controllers/spamadmin.php b/htdocs/application/controllers/spamadmin.php index 4d6da3e..c4a16b9 100755 --- a/htdocs/application/controllers/spamadmin.php +++ b/htdocs/application/controllers/spamadmin.php @@ -58,6 +58,9 @@ class Spamadmin extends CI_Controller //fill data $data = $this->pastes->getSpamLists('spamadmin/' . $ip_address, $seg = 3, $ip_address); $data['ip_address'] = $ip_address; + $ip = explode('.', $ip_address); + $ip_firstpart = $ip[0] . '.' . $ip[1] . '.'; + $data['ip_range'] = $ip_firstpart . '*.*'; //view $this->load->view('spam_detail', $data); diff --git a/htdocs/application/views/spam_detail.php b/htdocs/application/views/spam_detail.php index c6dd0d7..f88cd41 100755 --- a/htdocs/application/views/spam_detail.php +++ b/htdocs/application/views/spam_detail.php @@ -12,8 +12,8 @@ Remove all pastes below
-