Merge branch 'spamadmin' into dev

This commit is contained in:
Claude 2016-09-04 16:43:41 +02:00
commit 4cf85b1a21
13 changed files with 133 additions and 16 deletions

View File

@ -3,6 +3,9 @@ RewriteEngine on
RewriteCond $1 !^(index\.php|static|favicon\.ico|robots\.txt|sitemap.xml|google(.+)\.html) RewriteCond $1 !^(index\.php|static|favicon\.ico|robots\.txt|sitemap.xml|google(.+)\.html)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L] RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
# basic auth for PHP with fastcgi
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
SetOutputFilter DEFLATE SetOutputFilter DEFLATE
FileETag MTime Size FileETag MTime Size
@ -32,3 +35,5 @@ FileETag MTime Size
#AuthName "Backend" #AuthName "Backend"
#AuthUserFile /path/to/.htpasswd #create one with htpasswd -c .htpasswd username #AuthUserFile /path/to/.htpasswd #create one with htpasswd -c .htpasswd username
#Require user username #Require user username
AddHandler php5-fastcgi .php .php5

View File

@ -22,6 +22,9 @@ class Spamadmin extends CI_Controller
$user = $this->config->item('spamadmin_user'); $user = $this->config->item('spamadmin_user');
$pass = $this->config->item('spamadmin_pass'); $pass = $this->config->item('spamadmin_pass');
// basic auth for fastcgi
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
if ($user == '' || $pass == '' || !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) if ($user == '' || $pass == '' || !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass)
{ {
header('WWW-Authenticate: Basic realm="Spamadmin"'); header('WWW-Authenticate: Basic realm="Spamadmin"');
@ -33,6 +36,19 @@ class Spamadmin extends CI_Controller
function index() function index()
{ {
$this->load->model('pastes'); $this->load->model('pastes');
$pastes_to_delete = $this->input->post('pastes_to_delete');
if ($pastes_to_delete)
{
foreach (explode(' ', $pastes_to_delete) as $pid)
{
$this->db->where('pid', $pid);
$this->db->delete('pastes');
}
redirect(site_url('spamadmin/' . $this->uri->segment(2)));
}
//render view
$data = $this->pastes->getSpamLists(); $data = $this->pastes->getSpamLists();
$this->load->view('list_ips', $data); $this->load->view('list_ips', $data);
} }

View File

@ -5,7 +5,7 @@
} }
} }
.hidden { .hidden, .inv {
display: none; display: none;
} }
@ -127,3 +127,11 @@ table.table thead .sorting_desc_disabled { background: url('../images/sort_desc_
word-wrap: break-word; word-wrap: break-word;
} }
.ui-selectable>.ui-selected { background-color: #a6c9e2; }
.ui-selectable>.ui-selecting { background: #FECA40; }
.ui-selectable-helper {
position: absolute;
z-index: 100;
border:1px dotted black;
}

File diff suppressed because one or more lines are too long

View File

@ -16,6 +16,48 @@ ST.show_embed = function() {
}); });
}; };
ST.spamadmin = function() {
if ($('.content h1').text() == 'Spamadmin') {
$('.content .hidden').show();
$('.content .quick_remove').live('click', function(ev) {
var ip = $(ev.target).data('ip');
if (confirm('Delete all pastes belonging to ' + ip + '?')) {
$.post(base_url + 'spamadmin/' + ip, {
'confirm_remove': 'yes',
'block_ip': 1
}, function() {
window.location.reload();
});
}
return false;
});
}
// needed by .selectable
$.fn.addBack = function(selector) {
return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector));
}
$('.selectable>tbody').selectable({
filter: 'tr',
cancel: 'a',
stop: function() {
var $deletestack = $(".paste_deletestack");
var $input = $("input[name=pastes_to_delete]");
$('.inv').show();
$deletestack.empty();
$input.empty();
var res = [];
$(".ui-selected").each(function(i, el) {
var id = $('a', el).attr('href').split('view/')[1];
res.push(id);
});
$deletestack.text(res.join(' '));
$input.val(res.join(' '));
}
});
};
ST.line_highlighter = function() { ST.line_highlighter = function() {
var org_href = window.location.href.replace(/(.*?)#(.*)/, '$1'); var org_href = window.location.href.replace(/(.*?)#(.*)/, '$1');
var first_line = false; var first_line = false;
@ -293,6 +335,7 @@ ST.clickable_urls = function() {
ST.init = function() { ST.init = function() {
ST.show_embed(); ST.show_embed();
ST.spamadmin();
ST.line_highlighter(); ST.line_highlighter();
ST.crypto(); ST.crypto();
ST.dragdrop(); ST.dragdrop();

View File

@ -18,6 +18,7 @@ if(isset($ace_modes)){
//Javascript //Javascript
$this->carabiner->js('jquery.js'); $this->carabiner->js('jquery.js');
$this->carabiner->js('jquery.timers.js'); $this->carabiner->js('jquery.timers.js');
$this->carabiner->js('jquery-ui-selectable-combined.min.js');
$this->carabiner->js('bootstrap.min.js'); $this->carabiner->js('bootstrap.min.js');
$this->carabiner->js('crypto-js/rollups/aes.js'); $this->carabiner->js('crypto-js/rollups/aes.js');
$this->carabiner->js('lz-string-1.3.3-min.js'); $this->carabiner->js('lz-string-1.3.3-min.js');

View File

@ -9,10 +9,8 @@
<?php } else { ?> <?php } else { ?>
<?php echo $page['title']; ?> <?php echo $page['title']; ?>
<?php } ?> <?php } ?>
</h1> </h1>
</div> </div>
</div> </div>
<div class="span12"> <div class="span12">
<form action="<?php echo base_url(); ?>" method="post" class="form-vertical well"> <form action="<?php echo base_url(); ?>" method="post" class="form-vertical well">
@ -20,19 +18,15 @@
<div class="span3"> <div class="span3">
<label for="name"><?php echo lang('paste_author'); ?> <label for="name"><?php echo lang('paste_author'); ?>
</label> </label>
<?php $set = array('name' => 'name', 'id' => 'name', 'class' => 'span3', 'value' => $name_set, 'maxlength' => '32', 'tabindex' => '1'); <?php $set = array('name' => 'name', 'id' => 'name', 'class' => 'span3', 'value' => $name_set, 'maxlength' => '32', 'tabindex' => '1');
echo form_input($set);?> echo form_input($set);?>
</div> </div>
<div class="span3"> <div class="span3">
<label for="title"> <label for="title">
<?php echo lang('paste_title'); ?> <?php echo lang('paste_title'); ?>
</label> </label>
<input value="<?php if(isset($title_set)){ echo $title_set; }?>" class="span3" type="text" id="title" name="title" tabindex="2" maxlength="50" /> <input value="<?php if(isset($title_set)){ echo $title_set; }?>" class="span3" type="text" id="title" name="title" tabindex="2" maxlength="50" />
</div> </div>
<div class="span3"> <div class="span3">
<label for="lang"> <label for="lang">
<?php echo lang('paste_lang'); ?> <?php echo lang('paste_lang'); ?>
@ -40,7 +34,6 @@
<?php $lang_extra = 'id="lang" class="select span3" tabindex="3"'; echo form_dropdown('lang', $languages, $lang_set, $lang_extra); ?> <?php $lang_extra = 'id="lang" class="select span3" tabindex="3"'; echo form_dropdown('lang', $languages, $lang_set, $lang_extra); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
<label for="code"><?php echo lang('paste_yourpaste'); ?> <label for="code"><?php echo lang('paste_yourpaste'); ?>
@ -109,11 +102,9 @@
</div> </div>
</div> </div>
</div> </div>
<?php if($reply){ ?> <?php if($reply){ ?>
<input type="hidden" value="<?php echo $reply; ?>" name="reply" /> <input type="hidden" value="<?php echo $reply; ?>" name="reply" />
<?php } ?> <?php } ?>
<?php if($this->config->item('enable_captcha') && $this->session->userdata('is_human') === null){ ?> <?php if($this->config->item('enable_captcha') && $this->session->userdata('is_human') === null){ ?>
<div class="item_group"> <div class="item_group">
<div class="item item_captcha"> <div class="item item_captcha">

View File

@ -172,7 +172,7 @@ h4 {
margin-bottom: 10px; margin-bottom: 10px;
} }
.hidden, .email, .url { .hidden, .email, .url, .inv {
display: none; display: none;
} }
@ -565,3 +565,11 @@ h4 {
word-wrap: break-word; word-wrap: break-word;
} }
.ui-selectable>.ui-selected { background-color: #a6c9e2; }
.ui-selectable>.ui-selecting { background: #FECA40; }
.ui-selectable-helper {
position: absolute;
z-index: 100;
border:1px dotted black;
}

File diff suppressed because one or more lines are too long

View File

@ -51,6 +51,30 @@ ST.spamadmin = function() {
return false; return false;
}); });
} }
// needed by .selectable
$.fn.addBack = function(selector) {
return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector));
}
$('.selectable>tbody').selectable({
filter: 'tr',
cancel: 'a',
stop: function() {
var $deletestack = $(".paste_deletestack");
var $input = $("input[name=pastes_to_delete]");
$('.inv').show();
$deletestack.empty();
$input.empty();
var res = [];
$(".ui-selected").each(function(i, el) {
var id = $('a', el).attr('href').split('view/')[1];
res.push(id);
});
$deletestack.text(res.join(' '));
$input.val(res.join(' '));
}
});
}; };
ST.line_highlighter = function() { ST.line_highlighter = function() {

View File

@ -18,6 +18,7 @@ if(isset($ace_modes)){
//Javascript //Javascript
$this->carabiner->js('jquery.js'); $this->carabiner->js('jquery.js');
$this->carabiner->js('jquery.timers.js'); $this->carabiner->js('jquery.timers.js');
$this->carabiner->js('jquery-ui-selectable-combined.min.js');
$this->carabiner->js('crypto-js/rollups/aes.js'); $this->carabiner->js('crypto-js/rollups/aes.js');
$this->carabiner->js('lz-string-1.3.3-min.js'); $this->carabiner->js('lz-string-1.3.3-min.js');
$this->carabiner->js('filereader.js'); $this->carabiner->js('filereader.js');

View File

@ -1,4 +1,3 @@
<?php echo validation_errors(); ?> <?php echo validation_errors(); ?>
<div class="form_wrapper margin"> <div class="form_wrapper margin">

View File

@ -8,14 +8,14 @@
} }
$n = 0; $n = 0;
if(!empty($pastes)){ ?> if(!empty($pastes)){ ?>
<table class="recent"> <table class="recent selectable">
<tbody> <tbody>
<tr> <tr>
<th class="title">Title</th> <th class="title">Title</th>
<th class="name">Name</th> <th class="name">Name</th>
<th class="time">When</th> <th class="time">When</th>
<th class="time">IP</th> <th class="time">IP</th>
<th title="Quick remove" class="qr hidden">X</th> <th title="Quick remove" class="hidden">X</th>
</tr> </tr>
<?php foreach($pastes as $paste) { <?php foreach($pastes as $paste) {
if(checkNum($n) == TRUE) { if(checkNum($n) == TRUE) {
@ -37,6 +37,15 @@
<?php }?> <?php }?>
</tbody> </tbody>
</table> </table>
<form action="" method="post">
<h2 class="confirm_title inv">Confirm deletion of the following pastes:</h2>
<div class="paste_deletestack"></div>
<input type="hidden" name="pastes_to_delete" />
<input type="submit" name="delete_pastes" value="Delete selected pastes" class="inv" />
</form>
<?php } else { ?> <?php } else { ?>
<p><?php echo lang('paste_missing'); ?> :(</p> <p><?php echo lang('paste_missing'); ?> :(</p>
<?php }?> <?php }?>