Skip to content

Commit

Permalink
Fixed blowoff bug, migration bug and added screenshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsnook committed Jul 1, 2018
1 parent 816b6bd commit 951cf72
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 28 deletions.
19 changes: 10 additions & 9 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @property array $ignorables Array of controller actions and IPs to ignore
* @property array $urlRules Array of rules for a UrlManger configured to pretty Url
*
* @author John Snook <[email protected]> The masta with a blasta
* @author John Snook <[email protected]>
*/
class Module extends BaseModule implements BootstrapInterface {

Expand Down Expand Up @@ -69,7 +69,7 @@ class Module extends BaseModule implements BootstrapInterface {
/**
* @var string The route to your blowoff page telling the user to pound sand
*/
public $blowOff = 'visitor/blowoff';
public $blowOff = 'ipFilter/visitor/blowoff';

/**
* @var string $ipInfoKey Go to https://ipinfo.io/signup for a free API key
Expand Down Expand Up @@ -104,11 +104,11 @@ class Module extends BaseModule implements BootstrapInterface {
/** @var array The rules to be used in URL management. */
public $urlRules = [
// 'visitor/<action:\w+>' => '/ipFilter/visitor/<action>',
'visitor' => '/ipFilter/visitor/index',
'visitor/index' => '/ipFilter/visitor/index',
'visitor/blowoff' => '/ipFilter/visitor/blowoff',
'visitor/<id>' => 'ipFilter/visitor/view',
'visitor/update/<id>' => 'ipFilter/visitor/update',
'visitor' => 'ipFilter/visitor/index',
'/visitor/index' => 'ipFilter/visitor/index',
'/visitor/blowoff' => 'ipFilter/visitor/blowoff',
'/visitor/<id>' => '/ipFilter/visitor/view',
'/visitor/update/<id>' => '/ipFilter/visitor/update',
];

/**
Expand All @@ -129,9 +129,10 @@ public function init() {
*/
public function bootstrap($app) {


if ($app->hasModule('ipFilter') && ($module = $app->getModule('ipFilter')) instanceof Module) {
$app->getUrlManager()->addRules($this->urlRules, false);

//die(json_encode($app->getUrlManager()->rules));
/** this allows me to do some importing from my old security system */
if ($app instanceof \yii\console\Application) {
$this->controllerNamespace = 'johnsnook\ipFilter\commands';
Expand Down Expand Up @@ -184,7 +185,7 @@ public function metalDetector(ActionEvent $event) {
return true;
} elseif (!$alreadyFuckingOff && $visitor->is_blacklisted) {
$event->handled = true;
return \Yii::$app->getResponse()->redirect([$this->blowOff, 'visitor' => $visitor])->send();
return \Yii::$app->getResponse()->redirect([$this->blowOff])->send();
}
}

Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,20 @@ php yii ipFilter/import/logs '/my/own/private/idaho'
php yii ipFilter/import/logs '/etc/httpd/logs' access_log-20180603,access_log-20180610
```

To see it live, check out https://snooky.biz/visitor
To see it live, check out https://snooky.biz/visitor

Screenshots!
-----

The main screen
![ipfilter1](https://user-images.githubusercontent.com/4065107/42129954-e352eaea-7ca1-11e8-8db8-8cb44ce4f2fc.png)

Detail visitor view
![ipfilter2](https://user-images.githubusercontent.com/4065107/42129951-e330717c-7ca1-11e8-9337-52f16c8c8a5e.png)

Updating the name and/or message for a visitor.
![ipfilter3](https://user-images.githubusercontent.com/4065107/42129952-e33bce3c-7ca1-11e8-9fd2-9e06a9833a2f.png)

The default blocked user view. (As seen from Tor)
![ipfilter4](https://user-images.githubusercontent.com/4065107/42129953-e3476580-7ca1-11e8-84cf-aef11158446b.png)

6 changes: 2 additions & 4 deletions controllers/VisitorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,9 @@ public function actionBlacklist($id) {
* Displays a blowoff Visitor message.
* @return mixed
*/
public function actionBlowoff($visitor) {
public function actionBlowoff() {
$this->layout = 'blowy';
return $this->render('blowoff', [
'visitor' => $visitor,
]);
return $this->render('blowoff');
}

/**
Expand Down
16 changes: 7 additions & 9 deletions migrations/m180630_142222_create_table_visitor_service_error.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

use yii\db\Migration;

class m180630_142222_create_table_visitor_service_error extends Migration
{
public function up()
{
class m180630_142222_create_table_visitor_service_error extends Migration {

public function up() {
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
Expand All @@ -17,13 +16,12 @@ public function up()
'url' => $this->string()->notNull(),
'params' => $this->json(),
'message' => $this->text()->notNull(),
'is_resolved' => $this->boolean()->notNull()->defaultValue(''),
], $tableOptions);

'is_resolved' => $this->boolean()->notNull()->defaultValue(false),
], $tableOptions);
}

public function down()
{
public function down() {
$this->dropTable('{{%visitor_service_error}}');
}

}
19 changes: 14 additions & 5 deletions views/visitor/blowoff.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,27 @@
*/
/* @var $this yii\web\View */
/* @var $visitor johnsnook\ipFilter\models\Visitor */
$name = (!empty($visitor->name) ? $visitor->name : 'Stranger');
$message = (!empty($visitor->message) ? $visitor->message : "What's this you've said to me, my good friend? Ill have you know I graduated top of my class in conflict resolution, and Ive been involved in numerous friendly discussions, and I have over 300 confirmed friends. I am trained in polite discussions and I'm the top mediator in the entire neighborhood. You are worth more to me than just another target. I hope we will come to have a friendship never before seen on this Earth. Don't you think you might be hurting someone's feelings saying that over the internet? Think about it, my friend. As we speak I am contacting my good friends across the USA and your P.O. box is being traced right now so you better prepare for the greeting cards, friend. The greeting cards that help you with your hate. You should look forward to it, friend. I can be anywhere, anytime for you, and I can calm you in over seven hundred ways, and that's just with my chess set. Not only am I extensively trained in conflict resolution, but I have access to the entire group of my friends and I will use them to their full extent to start our new friendship. If only you could have known what kindness and love your little comment was about to bring you, maybe you would have reached out sooner. But you couldn't, you didn't, and now we get to start a new friendship, you unique person. I will give you gifts and you might have a hard time keeping up. You're finally living, friend.");
$visitor = \Yii::$app->getModule('ipFilter')->visitor;

$this->title = 'Do\'t go away mad, just go away.';
$name = (!empty($visitor->name) ? $visitor->name : 'Visitor');
if (!empty($visitor->message)) {
$message = $visitor->message;
} else {
if ($visitor->proxy === 'no') {
$message = 'An adminstrator has banned your IP address.';
} else {
$message = "Your IP address has been automatically banned for using a proxy of type $visitor->proxy.";
}
}

$this->title = 'Don\'t go away mad, just go away.';
?>

<div class="visitor-log-view">


<div class="jumbotron">
<h1>Dear <?= $name ?>,</h1>
<p><?= $message ?></p>
<p>If you feel this is in error, you can contact an <a href="mailto:<?= \Yii::$app->params['adminEmail'] ?>">administrator</a> </p>
</div>>

</div>

0 comments on commit 951cf72

Please sign in to comment.