From dd17acb51f670ad86508c55a85cd8019cb6c3118 Mon Sep 17 00:00:00 2001 From: ziggi Date: Mon, 11 Dec 2017 18:48:58 +0000 Subject: [PATCH] --- Makefile.am | 30 ++- maacom.pl | 291 ++++++++++++++++++++---- templs/forwarded-add-form.html.ep | 30 +++ templs/forwarded-add-handler.html.ep | 32 +++ templs/forwarded-delete-form.html.ep | 39 ++++ templs/forwarded-delete-handler.html.ep | 32 +++ templs/forwarded-list.html.ep | 74 ++++++ templs/forwarded-update-form.html.ep | 44 ++++ templs/forwarded-update-handler.html.ep | 41 ++++ templs/layouts/default.html.ep | 4 +- templs/trusted-add-form.html.ep | 30 +++ templs/trusted-add-handler.html.ep | 32 +++ templs/trusted-delete-form.html.ep | 39 ++++ templs/trusted-delete-handler.html.ep | 32 +++ templs/trusted-list.html.ep | 74 ++++++ templs/trusted-update-form.html.ep | 44 ++++ templs/trusted-update-handler.html.ep | 41 ++++ templs/unwanted-add-form.html.ep | 30 +++ templs/unwanted-add-handler.html.ep | 32 +++ templs/unwanted-delete-form.html.ep | 39 ++++ templs/unwanted-delete-handler.html.ep | 32 +++ templs/unwanted-list.html.ep | 74 ++++++ templs/unwanted-update-form.html.ep | 44 ++++ templs/unwanted-update-handler.html.ep | 41 ++++ 24 files changed, 1151 insertions(+), 50 deletions(-) create mode 100644 templs/forwarded-add-form.html.ep create mode 100644 templs/forwarded-add-handler.html.ep create mode 100644 templs/forwarded-delete-form.html.ep create mode 100644 templs/forwarded-delete-handler.html.ep create mode 100644 templs/forwarded-list.html.ep create mode 100644 templs/forwarded-update-form.html.ep create mode 100644 templs/forwarded-update-handler.html.ep create mode 100644 templs/trusted-add-form.html.ep create mode 100644 templs/trusted-add-handler.html.ep create mode 100644 templs/trusted-delete-form.html.ep create mode 100644 templs/trusted-delete-handler.html.ep create mode 100644 templs/trusted-list.html.ep create mode 100644 templs/trusted-update-form.html.ep create mode 100644 templs/trusted-update-handler.html.ep create mode 100644 templs/unwanted-add-form.html.ep create mode 100644 templs/unwanted-add-handler.html.ep create mode 100644 templs/unwanted-delete-form.html.ep create mode 100644 templs/unwanted-delete-handler.html.ep create mode 100644 templs/unwanted-list.html.ep create mode 100644 templs/unwanted-update-form.html.ep create mode 100644 templs/unwanted-update-handler.html.ep diff --git a/Makefile.am b/Makefile.am index 83073a1..2bd8527 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,13 +89,29 @@ nobase_dist_pkgdata_DATA = \ templs/alias-rename-form.html.ep \ templs/alias-rename-handler.html.ep \ \ - templs/forward-list.html.ep \ - templs/forward-add-form.html.ep \ - templs/forward-add-handler.html.ep \ - templs/forward-update-form.html.ep \ - templs/forward-update-handler.html.ep \ - templs/forward-delete-form.html.ep \ - templs/forward-delete-handler.html.ep \ + templs/forwarded-list.html.ep \ + templs/forwarded-add-form.html.ep \ + templs/forwarded-add-handler.html.ep \ + templs/forwarded-update-form.html.ep \ + templs/forwarded-update-handler.html.ep \ + templs/forwarded-delete-form.html.ep \ + templs/forwarded-delete-handler.html.ep \ + \ + templs/unwanted-list.html.ep \ + templs/unwanted-add-form.html.ep \ + templs/unwanted-add-handler.html.ep \ + templs/unwanted-update-form.html.ep \ + templs/unwanted-update-handler.html.ep \ + templs/unwanted-delete-form.html.ep \ + templs/unwanted-delete-handler.html.ep \ + \ + templs/trusted-list.html.ep \ + templs/trusted-add-form.html.ep \ + templs/trusted-add-handler.html.ep \ + templs/trusted-update-form.html.ep \ + templs/trusted-update-handler.html.ep \ + templs/trusted-delete-form.html.ep \ + templs/trusted-delete-handler.html.ep \ \ templs/exception.development.html.ep \ templs/exception.production.html.ep \ diff --git a/maacom.pl b/maacom.pl index b352e2e..bcdcfd1 100755 --- a/maacom.pl +++ b/maacom.pl @@ -525,66 +525,190 @@ sub user_delete { # --- FORWARD --- -sub forward_exist { +sub forwarded_exist { my ($self, $name) = @_; return undef unless $name; - my $res = $self->db->exec1("select id from forwards where name = '$name' order by id limit 1"); + my $res = $self->db->exec1("select id from forwarded where name = '$name' order by id limit 1"); $res->{id}; } -sub forward_profile { +sub forwarded_profile { my ($self, $id) = @_; return undef unless $id; - my $row = $self->db->exec1("select * from forwards where forwards.id = $id limit 1"); + my $row = $self->db->exec1("select * from forwarded where forwarded.id = $id limit 1"); $row; } -sub forward_nextid { +sub forwarded_nextid { my $self = shift; - my $res = $self->db->exec1("select id from forwards order by id desc limit 1"); + my $res = $self->db->exec1("select id from forwarded order by id desc limit 1"); my $id = $res->{id} || 0; $id += 1; } -sub forward_add { +sub forwarded_add { my ($self, $name) = @_; return undef unless $name; - return undef if $self->forward_exist($name); - my $next_id = $self->forward_nextid; - $self->db->do("insert into forwards (id, name) values ($next_id, '$name')"); - $self->forward_exist($name); + return undef if $self->forwarded_exist($name); + my $next_id = $self->forwarded_nextid; + $self->db->do("insert into forwarded (id, name) values ($next_id, '$name')"); + $self->forwarded_exist($name); } -sub forward_list { +sub forwarded_list { my $self = shift; - $self->db->exec("select * from forwards order by id"); + $self->db->exec("select * from forwarded order by id"); } -sub forward_update { +sub forwarded_update { my ($self, $id, %args) = @_; return undef unless $id; - my $prof = $self->forward_profile($id); + my $prof = $self->forwarded_profile($id); return undef unless $prof; my $name = $args{name} || $prof->{name}; - $self->db->do("update forwards set name = '$name' where id = $id"); - my $res = $self->forward_profile($id); + $self->db->do("update forwarded set name = '$name' where id = $id"); + my $res = $self->forwarded_profile($id); return undef unless $res->{name} eq $name; $id; } -sub forward_delete { +sub forwarded_delete { my ($self, $id) = @_; return undef unless $id; -# return $id unless $self->forward_profile($id); - $self->db->do("delete from forwards where id = $id"); - return undef if $self->forward_profile($id); +# return $id unless $self->forwarded_profile($id); + $self->db->do("delete from forwarded where id = $id"); + return undef if $self->forwarded_profile($id); $id; } +# --- UNWANTED --- + +sub unwanted_exist { + my ($self, $name) = @_; + return undef unless $name; + my $res = $self->db->exec1("select id from unwanted where name = '$name' order by id limit 1"); + $res->{id}; +} + +sub unwanted_profile { + my ($self, $id) = @_; + return undef unless $id; + my $row = $self->db->exec1("select * from unwanted where unwanted.id = $id limit 1"); + $row; +} + +sub unwanted_nextid { + my $self = shift; + my $res = $self->db->exec1("select id from unwanted order by id desc limit 1"); + my $id = $res->{id} || 0; + $id += 1; +} + +sub unwanted_add { + my ($self, $name) = @_; + return undef unless $name; + return undef if $self->unwanted_exist($name); + my $next_id = $self->unwanted_nextid; + $self->db->do("insert into unwanted (id, name) values ($next_id, '$name')"); + $self->unwanted_exist($name); +} + +sub unwanted_list { + my $self = shift; + $self->db->exec("select * from unwanted order by id"); +} + +sub unwanted_update { + my ($self, $id, %args) = @_; + return undef unless $id; + my $prof = $self->unwanted_profile($id); + return undef unless $prof; + + my $name = $args{name} || $prof->{name}; + + $self->db->do("update unwanted set name = '$name' where id = $id"); + my $res = $self->unwanted_profile($id); + return undef unless $res->{name} eq $name; + $id; +} + + +sub unwanted_delete { + my ($self, $id) = @_; + return undef unless $id; +# return $id unless $self->unwanted_profile($id); + $self->db->do("delete from unwanted where id = $id"); + return undef if $self->unwanted_profile($id); + $id; +} + +# --- TRUSTED --- + +sub trusted_exist { + my ($self, $name) = @_; + return undef unless $name; + my $res = $self->db->exec1("select id from trusted where name = '$name' order by id limit 1"); + $res->{id}; +} + +sub trusted_profile { + my ($self, $id) = @_; + return undef unless $id; + my $row = $self->db->exec1("select * from trusted where trusted.id = $id limit 1"); + $row; +} + +sub trusted_nextid { + my $self = shift; + my $res = $self->db->exec1("select id from trusted order by id desc limit 1"); + my $id = $res->{id} || 0; + $id += 1; +} + +sub trusted_add { + my ($self, $name) = @_; + return undef unless $name; + return undef if $self->trusted_exist($name); + my $next_id = $self->trusted_nextid; + $self->db->do("insert into trusted (id, name) values ($next_id, '$name')"); + $self->trusted_exist($name); +} + +sub trusted_list { + my $self = shift; + $self->db->exec("select * from trusted order by id"); +} + +sub trusted_update { + my ($self, $id, %args) = @_; + return undef unless $id; + my $prof = $self->trusted_profile($id); + return undef unless $prof; + + my $name = $args{name} || $prof->{name}; + + $self->db->do("update trusted set name = '$name' where id = $id"); + my $res = $self->trusted_profile($id); + return undef unless $res->{name} eq $name; + $id; +} + + +sub trusted_delete { + my ($self, $id) = @_; + return undef unless $id; +# return $id unless $self->trusted_profile($id); + $self->db->do("delete from trusted where id = $id"); + return undef if $self->trusted_profile($id); + $id; +} + + + 1; @@ -885,39 +1009,105 @@ sub mxlog { # --- FORWARD --- -sub forward_list { +sub forwarded_list { + my $self = shift; + $self->render(template => 'forwarded-list'); +} +sub forwarded_add_form { + my $self = shift; + $self->render(template => 'forwarded-add-form'); +} +sub forwarded_add_handler { + my $self = shift; + $self->render(template => 'forwarded-add-handler'); +} +sub forwarded_update_form { + my $self = shift; + $self->render(template => 'forwarded-update-form'); +} + +sub forwarded_update_handler { + my $self = shift; + $self->render(template => 'forwarded-update-handler'); +} + +sub forwarded_delete_form { my $self = shift; - $self->render(template => 'forward-list'); + $self->render(template => 'forwarded-delete-form'); } -sub forward_add_form { + +sub forwarded_delete_handler { my $self = shift; - $self->render(template => 'forward-add-form'); + $self->render(template => 'forwarded-delete-handler'); } -sub forward_add_handler { + +# --- UNWANTED --- + +sub unwanted_list { my $self = shift; - $self->render(template => 'forward-add-handler'); + $self->render(template => 'unwanted-list'); } -sub forward_update_form { +sub unwanted_add_form { + my $self = shift; + $self->render(template => 'unwanted-add-form'); +} +sub unwanted_add_handler { + my $self = shift; + $self->render(template => 'unwanted-add-handler'); +} +sub unwanted_update_form { my $self = shift; - $self->render(template => 'forward-update-form'); + $self->render(template => 'unwanted-update-form'); } -sub forward_update_handler { +sub unwanted_update_handler { my $self = shift; - $self->render(template => 'forward-update-handler'); + $self->render(template => 'unwanted-update-handler'); } -sub forward_delete_form { +sub unwanted_delete_form { my $self = shift; - $self->render(template => 'forward-delete-form'); + $self->render(template => 'unwanted-delete-form'); } -sub forward_delete_handler { +sub unwanted_delete_handler { my $self = shift; - $self->render(template => 'forward-delete-handler'); + $self->render(template => 'unwanted-delete-handler'); } +# --- TRUSTED --- +sub trusted_list { + my $self = shift; + $self->render(template => 'trusted-list'); +} +sub trusted_add_form { + my $self = shift; + $self->render(template => 'trusted-add-form'); +} +sub trusted_add_handler { + my $self = shift; + $self->render(template => 'trusted-add-handler'); +} +sub trusted_update_form { + my $self = shift; + $self->render(template => 'trusted-update-form'); +} + +sub trusted_update_handler { + my $self = shift; + $self->render(template => 'trusted-update-handler'); +} + +sub trusted_delete_form { + my $self = shift; + $self->render(template => 'trusted-delete-form'); +} + +sub trusted_delete_handler { + my $self = shift; + $self->render(template => 'trusted-delete-handler'); +} 1; @@ -1071,13 +1261,30 @@ $r->any('/alias/rename/handler')->over('auth')->to('controller#alias_rename_hand $r->any('/mxlog')->over('auth')->to('controller#mxlog' ); -$r->any('/forward/list')->over('auth')->to('controller#forward_list' ); -$r->any('/forward/add/form')->over('auth')->to('controller#forward_add_form' ); -$r->any('/forward/add/handler')->over('auth')->to('controller#forward_add_handler' ); -$r->any('/forward/update/form')->over('auth')->to('controller#forward_update_form' ); -$r->any('/forward/update/handler')->over('auth')->to('controller#forward_update_handler' ); -$r->any('/forward/delete/form')->over('auth')->to('controller#forward_delete_form' ); -$r->any('/forward/delete/handler')->over('auth')->to('controller#forward_delete_handler' ); +$r->any('/forwarded/list')->over('auth')->to('controller#forwarded_list' ); +$r->any('/forwarded/add/form')->over('auth')->to('controller#forwarded_add_form' ); +$r->any('/forwarded/add/handler')->over('auth')->to('controller#forwarded_add_handler' ); +$r->any('/forwarded/update/form')->over('auth')->to('controller#forwarded_update_form' ); +$r->any('/forwarded/update/handler')->over('auth')->to('controller#forwarded_update_handler' ); +$r->any('/forwarded/delete/form')->over('auth')->to('controller#forwarded_delete_form' ); +$r->any('/forwarded/delete/handler')->over('auth')->to('controller#forwarded_delete_handler' ); + +$r->any('/unwanted/list')->over('auth')->to('controller#unwanted_list' ); +$r->any('/unwanted/add/form')->over('auth')->to('controller#unwanted_add_form' ); +$r->any('/unwanted/add/handler')->over('auth')->to('controller#unwanted_add_handler' ); +$r->any('/unwanted/update/form')->over('auth')->to('controller#unwanted_update_form' ); +$r->any('/unwanted/update/handler')->over('auth')->to('controller#unwanted_update_handler' ); +$r->any('/unwanted/delete/form')->over('auth')->to('controller#unwanted_delete_form' ); +$r->any('/unwanted/delete/handler')->over('auth')->to('controller#unwanted_delete_handler' ); + + +$r->any('/trusted/list')->over('auth')->to('controller#trusted_list' ); +$r->any('/trusted/add/form')->over('auth')->to('controller#trusted_add_form' ); +$r->any('/trusted/add/handler')->over('auth')->to('controller#trusted_add_handler' ); +$r->any('/trusted/update/form')->over('auth')->to('controller#trusted_update_form' ); +$r->any('/trusted/update/handler')->over('auth')->to('controller#trusted_update_handler' ); +$r->any('/trusted/delete/form')->over('auth')->to('controller#trusted_delete_form' ); +$r->any('/trusted/delete/handler')->over('auth')->to('controller#trusted_delete_handler' ); #---------------- diff --git a/templs/forwarded-add-form.html.ep b/templs/forwarded-add-form.html.ep new file mode 100644 index 0000000..d7571a7 --- /dev/null +++ b/templs/forwarded-add-form.html.ep @@ -0,0 +1,30 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +
+
+
+ +
+
Add forwardeded domain
+ +
+ + Escape +
+
+ +
+
+
+%#EOF diff --git a/templs/forwarded-add-handler.html.ep b/templs/forwarded-add-handler.html.ep new file mode 100644 index 0000000..70361b2 --- /dev/null +++ b/templs/forwarded-add-handler.html.ep @@ -0,0 +1,32 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; +% my $name = $c->req->param('forwarded_name'); +% my $id = $u->forwarded_exist($name); + +% if ($id) { +
Domain <%= $name %> already exists
+% } + +% unless ($id) { + % my $res = $u->forwarded_add($name); + % if ($res) { +
Domain <%= $name %> has been added.
+ % } + + % unless ($res) { +
Domain <%= $name %> was not added.
+ % } +% } + +%#EOF + + + + diff --git a/templs/forwarded-delete-form.html.ep b/templs/forwarded-delete-form.html.ep new file mode 100644 index 0000000..ca05328 --- /dev/null +++ b/templs/forwarded-delete-form.html.ep @@ -0,0 +1,39 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $forwarded_id = $c->req->param('forwarded_id') || 0; +% my $profile = $u->forwarded_profile($forwarded_id); + +% if ($profile) { + % my $forwarded_name = $profile->{name}; + +
+
+
+ +
+
Delete domain <%= $forwarded_name %>
+ +
+ + Escape +
+
+ +
+
+
+% } + +% unless ($profile) { +
Domain with id <%= $forwarded_id %> not exist
+% } + +%#EOF diff --git a/templs/forwarded-delete-handler.html.ep b/templs/forwarded-delete-handler.html.ep new file mode 100644 index 0000000..53066d8 --- /dev/null +++ b/templs/forwarded-delete-handler.html.ep @@ -0,0 +1,32 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $forwarded_id = $c->req->param('forwarded_id') || 0; +% my $profile = $u->forwarded_profile($forwarded_id); + +% if ($profile) { + % my $name = $profile->{name}; + % my $res = $u->forwarded_delete($forwarded_id); + + % if ($res) { +
Domain <%= $name %> has been deleted
+ % } + + % unless ($res) { +
Domain <%= $name %> was not deleted
+ % } +% } + +% unless ($profile) { +
Domain with id <%= $forwarded_id %> not exist
+% } + +%#EOF + diff --git a/templs/forwarded-list.html.ep b/templs/forwarded-list.html.ep new file mode 100644 index 0000000..12a316b --- /dev/null +++ b/templs/forwarded-list.html.ep @@ -0,0 +1,74 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +
+ Domains + + + +
+ + +% my $list = $u->forwarded_list; + +% unless ($list) { +
+ Cannot list domains. May be wrong database? +
+% } + + + + + + + + + + + +% my $n = 0; + +% if ($list) { + % foreach my $row (@$list) { + % $n += 1; + % my $id = $row->{id}; + % my $name = $row->{name}; + % my $size = $row->{size}; + + + + + + + % } +% } + +
#domain
<%= $n %><%= $name %>
+ + + +%# EOF diff --git a/templs/forwarded-update-form.html.ep b/templs/forwarded-update-form.html.ep new file mode 100644 index 0000000..1ecbf6f --- /dev/null +++ b/templs/forwarded-update-form.html.ep @@ -0,0 +1,44 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $forwarded_id = $c->req->param('forwarded_id') || 0; +% my $profile = $u->forwarded_profile($forwarded_id); + +% if ($profile) { + % my $forwarded_name = $profile->{name}; + +
+
+
+ +
+
Edit domain
+ + +
+ + Escape +
+
+ +
+
+
+% } + +% unless ($profile) { +
Domain with id <%= $forwarded_id %> not exist
+% } + + +%#EOF diff --git a/templs/forwarded-update-handler.html.ep b/templs/forwarded-update-handler.html.ep new file mode 100644 index 0000000..24669c2 --- /dev/null +++ b/templs/forwarded-update-handler.html.ep @@ -0,0 +1,41 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $name = $c->req->param('forwarded_name'); +% my $forwarded_id = $c->req->param('forwarded_id') || 0; +% my $profile = $u->forwarded_profile($forwarded_id); + +% if ($profile) { + % my $cid = $u->forwarded_exist($name); + % if ($cid) { +
Domain <%= $name %> already exists
+ % } + + % unless ($cid) { + % my $res = $u->forwarded_update($forwarded_id, name => $name); + % if ($res) { +
Domain <%= $name %> has been updated.
+ % } + + % unless ($res) { +
Domain <%= $name %> was not updated.
+ % } + % } +% } + +% unless ($profile) { +
Domain with id <%= $forwarded_id %> not exist
+% } + +%#EOF + + + + diff --git a/templs/layouts/default.html.ep b/templs/layouts/default.html.ep index a5897bf..5c14e2c 100644 --- a/templs/layouts/default.html.ep +++ b/templs/layouts/default.html.ep @@ -31,7 +31,9 @@
  • Domain
  • User
  • Alias
  • -
  • Forward
  • +
  • Forwarded
  • +
  • Unwanted
  • +
  • Trusted
  • Log
  • diff --git a/templs/trusted-add-form.html.ep b/templs/trusted-add-form.html.ep new file mode 100644 index 0000000..9c95177 --- /dev/null +++ b/templs/trusted-add-form.html.ep @@ -0,0 +1,30 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +
    +
    +
    + +
    +
    Add trusteded host
    + +
    + + Escape +
    +
    + +
    +
    +
    +%#EOF diff --git a/templs/trusted-add-handler.html.ep b/templs/trusted-add-handler.html.ep new file mode 100644 index 0000000..3364797 --- /dev/null +++ b/templs/trusted-add-handler.html.ep @@ -0,0 +1,32 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; +% my $name = $c->req->param('trusted_name'); +% my $id = $u->trusted_exist($name); + +% if ($id) { +
    Host <%= $name %> already exists
    +% } + +% unless ($id) { + % my $res = $u->trusted_add($name); + % if ($res) { +
    Host <%= $name %> has been added.
    + % } + + % unless ($res) { +
    Host <%= $name %> was not added.
    + % } +% } + +%#EOF + + + + diff --git a/templs/trusted-delete-form.html.ep b/templs/trusted-delete-form.html.ep new file mode 100644 index 0000000..2a86c03 --- /dev/null +++ b/templs/trusted-delete-form.html.ep @@ -0,0 +1,39 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $trusted_id = $c->req->param('trusted_id') || 0; +% my $profile = $u->trusted_profile($trusted_id); + +% if ($profile) { + % my $trusted_name = $profile->{name}; + +
    +
    +
    + +
    +
    Delete host <%= $trusted_name %>
    + +
    + + Escape +
    +
    + +
    +
    +
    +% } + +% unless ($profile) { +
    Host with id <%= $trusted_id %> not exist
    +% } + +%#EOF diff --git a/templs/trusted-delete-handler.html.ep b/templs/trusted-delete-handler.html.ep new file mode 100644 index 0000000..b29bbd8 --- /dev/null +++ b/templs/trusted-delete-handler.html.ep @@ -0,0 +1,32 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $trusted_id = $c->req->param('trusted_id') || 0; +% my $profile = $u->trusted_profile($trusted_id); + +% if ($profile) { + % my $name = $profile->{name}; + % my $res = $u->trusted_delete($trusted_id); + + % if ($res) { +
    Host <%= $name %> has been deleted
    + % } + + % unless ($res) { +
    Host <%= $name %> was not deleted
    + % } +% } + +% unless ($profile) { +
    Host with id <%= $trusted_id %> not exist
    +% } + +%#EOF + diff --git a/templs/trusted-list.html.ep b/templs/trusted-list.html.ep new file mode 100644 index 0000000..e61f0e8 --- /dev/null +++ b/templs/trusted-list.html.ep @@ -0,0 +1,74 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +
    + Hosts + + + +
    + + +% my $list = $u->trusted_list; + +% unless ($list) { +
    + Cannot list hosts. May be wrong database? +
    +% } + + + + + + + + + + + +% my $n = 0; + +% if ($list) { + % foreach my $row (@$list) { + % $n += 1; + % my $id = $row->{id}; + % my $name = $row->{name}; + % my $size = $row->{size}; + + + + + + + % } +% } + +
    #host
    <%= $n %><%= $name %>
    + + + +%# EOF diff --git a/templs/trusted-update-form.html.ep b/templs/trusted-update-form.html.ep new file mode 100644 index 0000000..0d5c4f7 --- /dev/null +++ b/templs/trusted-update-form.html.ep @@ -0,0 +1,44 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $trusted_id = $c->req->param('trusted_id') || 0; +% my $profile = $u->trusted_profile($trusted_id); + +% if ($profile) { + % my $trusted_name = $profile->{name}; + +
    +
    +
    + +
    +
    Edit host
    + + +
    + + Escape +
    +
    + +
    +
    +
    +% } + +% unless ($profile) { +
    Host with id <%= $trusted_id %> not exist
    +% } + + +%#EOF diff --git a/templs/trusted-update-handler.html.ep b/templs/trusted-update-handler.html.ep new file mode 100644 index 0000000..eee4293 --- /dev/null +++ b/templs/trusted-update-handler.html.ep @@ -0,0 +1,41 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $name = $c->req->param('trusted_name'); +% my $trusted_id = $c->req->param('trusted_id') || 0; +% my $profile = $u->trusted_profile($trusted_id); + +% if ($profile) { + % my $cid = $u->trusted_exist($name); + % if ($cid) { +
    Host <%= $name %> already exists
    + % } + + % unless ($cid) { + % my $res = $u->trusted_update($trusted_id, name => $name); + % if ($res) { +
    Host <%= $name %> has been updated.
    + % } + + % unless ($res) { +
    Host <%= $name %> was not updated.
    + % } + % } +% } + +% unless ($profile) { +
    Host with id <%= $trusted_id %> not exist
    +% } + +%#EOF + + + + diff --git a/templs/unwanted-add-form.html.ep b/templs/unwanted-add-form.html.ep new file mode 100644 index 0000000..2823fc5 --- /dev/null +++ b/templs/unwanted-add-form.html.ep @@ -0,0 +1,30 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +
    +
    +
    + +
    +
    Add unwanted host
    + +
    + + Escape +
    +
    + +
    +
    +
    +%#EOF diff --git a/templs/unwanted-add-handler.html.ep b/templs/unwanted-add-handler.html.ep new file mode 100644 index 0000000..c5b9ddc --- /dev/null +++ b/templs/unwanted-add-handler.html.ep @@ -0,0 +1,32 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; +% my $name = $c->req->param('unwanted_name'); +% my $id = $u->unwanted_exist($name); + +% if ($id) { +
    Host <%= $name %> already exists
    +% } + +% unless ($id) { + % my $res = $u->unwanted_add($name); + % if ($res) { +
    Host <%= $name %> has been added.
    + % } + + % unless ($res) { +
    Host <%= $name %> was not added.
    + % } +% } + +%#EOF + + + + diff --git a/templs/unwanted-delete-form.html.ep b/templs/unwanted-delete-form.html.ep new file mode 100644 index 0000000..05a1728 --- /dev/null +++ b/templs/unwanted-delete-form.html.ep @@ -0,0 +1,39 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $unwanted_id = $c->req->param('unwanted_id') || 0; +% my $profile = $u->unwanted_profile($unwanted_id); + +% if ($profile) { + % my $unwanted_name = $profile->{name}; + +
    +
    +
    + +
    +
    Delete host <%= $unwanted_name %>
    + +
    + + Escape +
    +
    + +
    +
    +
    +% } + +% unless ($profile) { +
    Host with id <%= $unwanted_id %> not exist
    +% } + +%#EOF diff --git a/templs/unwanted-delete-handler.html.ep b/templs/unwanted-delete-handler.html.ep new file mode 100644 index 0000000..b3a584f --- /dev/null +++ b/templs/unwanted-delete-handler.html.ep @@ -0,0 +1,32 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $unwanted_id = $c->req->param('unwanted_id') || 0; +% my $profile = $u->unwanted_profile($unwanted_id); + +% if ($profile) { + % my $name = $profile->{name}; + % my $res = $u->unwanted_delete($unwanted_id); + + % if ($res) { +
    Host <%= $name %> has been deleted
    + % } + + % unless ($res) { +
    Host <%= $name %> was not deleted
    + % } +% } + +% unless ($profile) { +
    Host with id <%= $unwanted_id %> not exist
    +% } + +%#EOF + diff --git a/templs/unwanted-list.html.ep b/templs/unwanted-list.html.ep new file mode 100644 index 0000000..9777069 --- /dev/null +++ b/templs/unwanted-list.html.ep @@ -0,0 +1,74 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +
    + Hosts + + + +
    + + +% my $list = $u->unwanted_list; + +% unless ($list) { +
    + Cannot list hosts. May be wrong database? +
    +% } + + + + + + + + + + + +% my $n = 0; + +% if ($list) { + % foreach my $row (@$list) { + % $n += 1; + % my $id = $row->{id}; + % my $name = $row->{name}; + % my $size = $row->{size}; + + + + + + + % } +% } + +
    #host
    <%= $n %><%= $name %>
    + + + +%# EOF diff --git a/templs/unwanted-update-form.html.ep b/templs/unwanted-update-form.html.ep new file mode 100644 index 0000000..9121fd5 --- /dev/null +++ b/templs/unwanted-update-form.html.ep @@ -0,0 +1,44 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $unwanted_id = $c->req->param('unwanted_id') || 0; +% my $profile = $u->unwanted_profile($unwanted_id); + +% if ($profile) { + % my $unwanted_name = $profile->{name}; + +
    +
    +
    + +
    +
    Edit host
    + + +
    + + Escape +
    +
    + +
    +
    +
    +% } + +% unless ($profile) { +
    Host with id <%= $unwanted_id %> not exist
    +% } + + +%#EOF diff --git a/templs/unwanted-update-handler.html.ep b/templs/unwanted-update-handler.html.ep new file mode 100644 index 0000000..dd91ec9 --- /dev/null +++ b/templs/unwanted-update-handler.html.ep @@ -0,0 +1,41 @@ +%# +%# $Id$ +%# +% layout 'default'; +% title 'Maacom'; + +% use Mojo::Util qw(dumper); + +% my $u = $c->app->user; + +% my $name = $c->req->param('unwanted_name'); +% my $unwanted_id = $c->req->param('unwanted_id') || 0; +% my $profile = $u->unwanted_profile($unwanted_id); + +% if ($profile) { + % my $cid = $u->unwanted_exist($name); + % if ($cid) { +
    Host <%= $name %> already exists
    + % } + + % unless ($cid) { + % my $res = $u->unwanted_update($unwanted_id, name => $name); + % if ($res) { +
    Host <%= $name %> has been updated.
    + % } + + % unless ($res) { +
    Host <%= $name %> was not updated.
    + % } + % } +% } + +% unless ($profile) { +
    Host with id <%= $unwanted_id %> not exist
    +% } + +%#EOF + + + +