Completed
Push — develop ( 48618a )
by Peter
02:03
created

DDNS   A

Complexity

Total Complexity 30

Size/Duplication

Total Lines 202
Duplicated Lines 71.29 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 144
loc 202
rs 10
c 0
b 0
f 0
wmc 30
lcom 1
cbo 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 15 and the first side effect is on line 13.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Affenrakete;
4
5
/**
6
 * INWX DDNS Manager
7
 *
8
 * @author Peter Siemer <[email protected]>
9
 * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
10
 * @link https://affenrakete.de
11
 *
12
 */
13
header('Content-type: text/plain; charset=utf-8'); // Set UFT-8 Header
14
15
define("DEBUG", true);
16
define("OUTPUT", true);
17
18
if (DEBUG) {
19
    error_reporting(-1);
20
    ini_set("display_errors", 1);
21
}
22
23
require_once('./includes/ddns.php');
24
require_once('./libraries/domrobot.php');
25
26
$input['domain'] = filter_has_var(INPUT_GET, 'domain') ? filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/(?!.{253})((?!-)[A-Za-z0-9-]{1,63}(?<!-)\.){1,126}+[A-Za-z]{2,6}/']]) : null;
27
$input['password'] = filter_has_var(INPUT_GET, 'password') ? filter_input(INPUT_GET, 'password') : null;
28
$input['ipv4'] = filter_has_var(INPUT_GET, 'ipv4') ? filter_input(INPUT_GET, 'ipv4', FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) : null;
29
$input['ipv6'] = filter_has_var(INPUT_GET, 'ipv6') ? filter_input(INPUT_GET, 'ipv6', FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) : null;
30
31
if (DEBUG)
32
    print_r($input);
33
34
$ddns = new DDNS($input['domain'], $input['password']);
35
$ddns->updateIP($input['ipv4'], $input['ipv6']);
36