-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SMTP-TLS Report processing #4
Conversation
public function index(): Response | ||
{ | ||
$pages=array("page"=>1,"next" => false,"prev" => false); | ||
|
||
if(isset($_GET["page"]) && $_GET["page"] > 0) | ||
{ | ||
$pages["page"] = intval($_GET["page"]); | ||
} else { | ||
$pages["page"] = 1; | ||
} | ||
|
||
if(isset($_GET["perpage"]) && $_GET["perpage"] > 0) | ||
{ | ||
$pages['perpage'] = intval($_GET["perpage"]); | ||
} else { | ||
$pages['perpage'] = 17; | ||
} | ||
|
||
$repository = $this->em->getRepository(Domains::class); | ||
$domains = $repository->findBy(array('id' => $this->getUser()->getRoles())); | ||
|
||
$repository = $this->em->getRepository(DMARC_Reports::class); | ||
if(in_array("ROLE_ADMIN", $this->getUser()->getRoles())) { | ||
$reports = $repository->findBy(array(),array('id' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
} else { | ||
$reports = $repository->findBy(array('domain' => $domains),array('id' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
} | ||
$totalreports = $repository->getTotalRows($domains); | ||
|
||
$repository = $this->em->getRepository(DMARC_Seen::class); | ||
$reportsseen = $repository->getSeen($reports, $this->getUser()->getId()); | ||
|
||
if(count($reports) == 0 && $totalreports != 0 && $pages["page"] != 1) { return $this->redirectToRoute('app_dmarc_reports'); } | ||
|
||
if($totalreports/$pages['perpage'] > $pages["page"]) { $pages["next"] = true; } | ||
if($pages["page"]-1 > 0) { $pages["prev"] = true; } | ||
|
||
return $this->render('dmarc_reports/index.html.twig', [ | ||
'reports' => $reports, | ||
'pages' => $pages, | ||
'reportsseen' => $reportsseen, | ||
'menuactive' => 'reports', | ||
'breadcrumbs' => array( | ||
array('name' => $this->translator->trans("Reports"), 'url' => $this->router->generate('app_reports')), | ||
array('name' => $this->translator->trans("DMARC"), 'url' => $this->router->generate('app_dmarc_reports')) | ||
), | ||
]); | ||
} |
Check warning
Code scanning / PHPMD
Code Size Rules: CyclomaticComplexity Warning
public function index(): Response | ||
{ | ||
$pages=array("page"=>1,"next" => false,"prev" => false); | ||
|
||
if(isset($_GET["page"]) && $_GET["page"] > 0) | ||
{ | ||
$pages["page"] = intval($_GET["page"]); | ||
} else { | ||
$pages["page"] = 1; | ||
} | ||
|
||
if(isset($_GET["perpage"]) && $_GET["perpage"] > 0) | ||
{ | ||
$pages['perpage'] = intval($_GET["perpage"]); | ||
} else { | ||
$pages['perpage'] = 17; | ||
} | ||
|
||
$repository = $this->em->getRepository(Domains::class); | ||
$domains = $repository->findBy(array('id' => $this->getUser()->getRoles())); | ||
|
||
$repository = $this->em->getRepository(DMARC_Reports::class); | ||
if(in_array("ROLE_ADMIN", $this->getUser()->getRoles())) { | ||
$reports = $repository->findBy(array(),array('id' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
} else { | ||
$reports = $repository->findBy(array('domain' => $domains),array('id' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
} | ||
$totalreports = $repository->getTotalRows($domains); | ||
|
||
$repository = $this->em->getRepository(DMARC_Seen::class); | ||
$reportsseen = $repository->getSeen($reports, $this->getUser()->getId()); | ||
|
||
if(count($reports) == 0 && $totalreports != 0 && $pages["page"] != 1) { return $this->redirectToRoute('app_dmarc_reports'); } | ||
|
||
if($totalreports/$pages['perpage'] > $pages["page"]) { $pages["next"] = true; } | ||
if($pages["page"]-1 > 0) { $pages["prev"] = true; } | ||
|
||
return $this->render('dmarc_reports/index.html.twig', [ | ||
'reports' => $reports, | ||
'pages' => $pages, | ||
'reportsseen' => $reportsseen, | ||
'menuactive' => 'reports', | ||
'breadcrumbs' => array( | ||
array('name' => $this->translator->trans("Reports"), 'url' => $this->router->generate('app_reports')), | ||
array('name' => $this->translator->trans("DMARC"), 'url' => $this->router->generate('app_dmarc_reports')) | ||
), | ||
]); | ||
} |
Check warning
Code scanning / PHPMD
Code Size Rules: NPathComplexity Warning
public function index(): Response | ||
{ | ||
$pages=array("page"=>1,"next" => false,"prev" => false); | ||
|
||
if(isset($_GET["page"]) && $_GET["page"] > 0) | ||
{ | ||
$pages["page"] = intval($_GET["page"]); | ||
} else { | ||
$pages["page"] = 1; | ||
} | ||
|
||
if(isset($_GET["perpage"]) && $_GET["perpage"] > 0) | ||
{ | ||
$pages['perpage'] = intval($_GET["perpage"]); | ||
} else { | ||
$pages['perpage'] = 17; | ||
} | ||
|
||
$repository = $this->em->getRepository(Domains::class); | ||
$domains = $repository->findBy(array('id' => $this->getUser()->getRoles())); | ||
|
||
$repository = $this->em->getRepository(SMTPTLS_Reports::class); | ||
if(in_array("ROLE_ADMIN", $this->getUser()->getRoles())) { | ||
$reports = $repository->findBy(array(),array('id' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
} else { | ||
$reports = $repository->findOwnedBy(array('domain' => $domains),array('id' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
} | ||
$totalreports = $repository->getTotalRows($domains, $this->getUser()->getRoles()); | ||
|
||
$repository = $this->em->getRepository(SMTPTLS_Seen::class); | ||
$reportsseen = $repository->getSeen($reports, $this->getUser()->getId()); | ||
|
||
if(count($reports) == 0 && $totalreports != 0 && $pages["page"] != 1) { return $this->redirectToRoute('app_smtptls_reports'); } | ||
|
||
if($totalreports/$pages['perpage'] > $pages["page"]) { $pages["next"] = true; } | ||
if($pages["page"]-1 > 0) { $pages["prev"] = true; } | ||
|
||
return $this->render('smtptls_reports/index.html.twig', [ | ||
'reports' => $reports, | ||
'pages' => $pages, | ||
'reportsseen' => $reportsseen, | ||
'menuactive' => 'reports', | ||
'breadcrumbs' => array( | ||
array('name' => $this->translator->trans("Reports"), 'url' => $this->router->generate('app_reports')), | ||
array('name' => $this->translator->trans("SMTPTLS"), 'url' => $this->router->generate('app_smtptls_reports')) | ||
), | ||
]); | ||
} |
Check warning
Code scanning / PHPMD
Code Size Rules: CyclomaticComplexity Warning
public function index(): Response | ||
{ | ||
$pages=array("page"=>1,"next" => false,"prev" => false); | ||
|
||
if(isset($_GET["page"]) && $_GET["page"] > 0) | ||
{ | ||
$pages["page"] = intval($_GET["page"]); | ||
} else { | ||
$pages["page"] = 1; | ||
} | ||
|
||
if(isset($_GET["perpage"]) && $_GET["perpage"] > 0) | ||
{ | ||
$pages['perpage'] = intval($_GET["perpage"]); | ||
} else { | ||
$pages['perpage'] = 17; | ||
} | ||
|
||
$repository = $this->em->getRepository(Domains::class); | ||
$domains = $repository->findBy(array('id' => $this->getUser()->getRoles())); | ||
|
||
$repository = $this->em->getRepository(SMTPTLS_Reports::class); | ||
if(in_array("ROLE_ADMIN", $this->getUser()->getRoles())) { | ||
$reports = $repository->findBy(array(),array('id' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
} else { | ||
$reports = $repository->findOwnedBy(array('domain' => $domains),array('id' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
} | ||
$totalreports = $repository->getTotalRows($domains, $this->getUser()->getRoles()); | ||
|
||
$repository = $this->em->getRepository(SMTPTLS_Seen::class); | ||
$reportsseen = $repository->getSeen($reports, $this->getUser()->getId()); | ||
|
||
if(count($reports) == 0 && $totalreports != 0 && $pages["page"] != 1) { return $this->redirectToRoute('app_smtptls_reports'); } | ||
|
||
if($totalreports/$pages['perpage'] > $pages["page"]) { $pages["next"] = true; } | ||
if($pages["page"]-1 > 0) { $pages["prev"] = true; } | ||
|
||
return $this->render('smtptls_reports/index.html.twig', [ | ||
'reports' => $reports, | ||
'pages' => $pages, | ||
'reportsseen' => $reportsseen, | ||
'menuactive' => 'reports', | ||
'breadcrumbs' => array( | ||
array('name' => $this->translator->trans("Reports"), 'url' => $this->router->generate('app_reports')), | ||
array('name' => $this->translator->trans("SMTPTLS"), 'url' => $this->router->generate('app_smtptls_reports')) | ||
), | ||
]); | ||
} |
Check warning
Code scanning / PHPMD
Code Size Rules: NPathComplexity Warning
Enable processing of SMTP-TLS Reports