commit a2305eb794d3f56d67f950dcd85416ec83e84dfe from: Tracey Emery date: Fri May 13 21:22:20 2022 UTC add ability to add domains to block commit - 5aa69adf3856792313061ad34bd0b5e53f2c2d40 commit + a2305eb794d3f56d67f950dcd85416ec83e84dfe blob - f0a7a31c4f00823625bb0dd9bea18d74851fbf7e blob + 5914f9633318bcda0449817c28d065b4d0e48120 --- module/Securitx/config/module.config.php +++ module/Securitx/config/module.config.php @@ -57,6 +57,7 @@ return [ 'securitx/securitx/user' => __DIR__ . '/../view/securitx/user/user.phtml', 'securitx/securitx/twofa' => __DIR__ . '/../view/securitx/twofa/twofa.phtml', 'securitx/securitx/forgot' => __DIR__ . '/../view/securitx/forgot/forgot.phtml', + 'securitx/securitx/blockdomain' => __DIR__ . '/../view/securitx/blockdomain/blockdomain.phtml', ], 'template_path_stack' => [ __DIR__ . '/../view/securitx', blob - 8a9f5248e0a114e6eb764d6df993b180c855b7aa blob + 02dea4aff9e78d05134b78436235f0a944d09e53 --- module/Securitx/src/Controller/SecuritxController.php +++ module/Securitx/src/Controller/SecuritxController.php @@ -19,6 +19,7 @@ use Securitx\Form\CompanyDeleteForm; use Securitx\Form\ForgotForm; use Securitx\Form\SendForm; use Securitx\Form\TwofaForm; +use Securitx\Form\BlockDomainForm; use Laminas\Mvc\InjectApplicationEventInterface; use Laminas\Mvc\Controller\AbstractActionController; @@ -101,6 +102,64 @@ class SecuritxController extends AbstractActionControl } return 0; } + public function blockdomainAction() { + if (!$this->checkAnyAdmin()) + return $this->redirect()->toRoute('securitx'); + $member = $this->getMember(); + if (!$member->is_admin) { + return $this->redirect()->toRoute('securitx', + array( + 'action' => 'home', + 'id' => $admin->u_key, + ) + ); + } + $form = new BlockDomainForm(); + $request = $this->getRequest(); + + if (!$request->isPost()) { + return new ViewModel([ + 'form' => $form, + 'completed' => false, + 'first' => $member->first, + 'id' => $member->u_key, + 'valid' => '', + ]); + } + $form->setData($request->getPost()); + if (!$form->isValid()) { + return new ViewModel([ + 'form' => $form, + 'completed' => false, + 'first' => $member->first, + 'id' => $member->u_key, + 'valid' => '', + ]); + } + + $domain = new BlockedDomains(); + $domain->exchangeArray($form->getData()); + $domains = $this->blockeddomains_table->fetchAll(); + foreach ($domains as $tdomain) { + if ($tdomain->domain == $domain->domain) { + return new ViewModel([ + 'form' => $form, + 'completed' => false, + 'first' => $member->first, + 'id' => $member->u_key, + 'valid' => 'That domain is already blocked', + ]); + } + } + + $this->blockeddomains_table->saveDomain($domain); + return new ViewModel([ + 'form' => $form, + 'completed' => true, + 'first' => $member->first, + 'valid' => '', + ]); + } public function authempAction() { if (!$this->checkAnyAdmin()) return $this->redirect()->toRoute('securitx'); blob - /dev/null blob + 568b67e7c7e2b8366694e7b55396fa47dccdf150 (mode 644) --- /dev/null +++ module/Securitx/src/Form/BlockDomainForm.php @@ -0,0 +1,26 @@ +add([ + 'name' => 'domain', + 'type' => 'text', + 'options' => [ + 'label' => 'Domain Name', + ], + ]); + $this->add([ + 'name' => 'submit', + 'type' => 'submit', + 'attributes' => [ + 'value' => 'Block This Domain', + 'id' => 'submitbutton', + ], + ]); + } +} blob - a83a9c1f043ec3a668abafded708752203dd698e blob + 08ab9d222b3c87d1b98e0b32e44bf9f4736fd3d7 --- module/Securitx/src/Model/BlockedDomainsTable.php +++ module/Securitx/src/Model/BlockedDomainsTable.php @@ -15,7 +15,7 @@ class BlockedDomainsTable { } public function saveDomain(BlockedDomains $domain) { $data = [ - 'domain' => $download->domain, + 'domain' => $domain->domain, ]; $this->tableGateway->insert($data); blob - /dev/null blob + adf8117a86f97c6cf18c6ad910d03589353658f8 (mode 644) --- /dev/null +++ module/Securitx/view/securitx/blockdomain/blockdomain.phtml @@ -0,0 +1,42 @@ +headTitle('SecuritX: Block A Domain'); +?> +
+ +

Domain Blocked

+

Thanks you, .
+ Thanks domain is now blocked.

+ +

Block A Domain

+

Hello, .
You can block a domain here.

+ + +
+get('domain'); + $domain->setAttribute('class', 'form-control'); + $domain->setAttribute('placeholder', 'Domain Name'); + + $submit = $form->get('submit'); + $submit->setAttribute('class', 'btn btn-primary'); + + $form->setAttribute('action', $this->url('securitx', + ['action' => 'blockdomain', 'id'=> $id])); + $form->prepare(); + + echo $this->form()->openTag($form); +?> + +
+ formLabel($domain) ?> + formElement($domain) ?> + formElementErrors()->render($domain, + ['class' => 'help-block']) ?> +
+

+formSubmit($form->get('submit')); + echo $this->form()->closeTag(); +?> +

Go home

+
blob - 2358cf3647372e5347bc2749044c62b0ac099c9d blob + 8d2546413c98228f0ab4d9ba86b2e941a4fd22f4 --- module/Securitx/view/securitx/home/home.phtml +++ module/Securitx/view/securitx/home/home.phtml @@ -13,6 +13,10 @@ 1) { ?>

Delete a company »

"; +?> +

Block a domain »

+"; } if ($member->is_admin == 1 || $member->is_editor == 1) { ?>