falon /
RBL
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | require_once('config.php'); |
||
| 3 | require('function.php'); |
||
| 4 | require_once 'vendor/autoload.php'; |
||
| 5 | $net = new \dautkom\ipv4\IPv4(); |
||
| 6 | |||
| 7 | $_ = $_POST['genere']; |
||
| 8 | View Code Duplication | if ( ($tables["$_"]['field']=='email') AND ($_POST['Value']!='ALL') ) |
|
| 9 | if (!(filter_var($_POST['Value'], FILTER_VALIDATE_EMAIL))) |
||
| 10 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid email address.</pre>'); |
||
| 11 | |||
| 12 | View Code Duplication | if ( ($tables["$_"]['field']=='domain') AND ($_POST['Value']!='ALL') ) |
|
| 13 | if (!(filter_var(gethostbyname($_POST['Value']), FILTER_VALIDATE_IP))) |
||
| 14 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid domain.</pre>'); |
||
| 15 | |||
| 16 | View Code Duplication | if ( ($tables["$_"]['field']=='ip') AND ($_POST['Value']!='ALL') ) |
|
| 17 | if (!(filter_var($_POST['Value'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))) |
||
| 18 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid IP address.</pre>'); |
||
| 19 | |||
| 20 | if ( ($tables["$_"]['field']=='network') AND ($_POST['Value']!='ALL') ) { |
||
| 21 | $value = explode('/',$_POST['Value']); |
||
| 22 | if (count($value) != 2) |
||
| 23 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask pair.</pre>'); |
||
| 24 | if (!$net->address($value[0])->mask($value[1])->isValid(1)) |
||
| 25 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask.</pre>'); |
||
| 26 | $_POST['Value'] = $value[0].'/'.$net->mask($value[1])->convertTo('dec'); |
||
| 27 | } |
||
| 28 | |||
| 29 | if ( ($tables["$_"]['field']=='username') AND ($_POST['Value']!='ALL') ) { |
||
| 30 | if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) ) |
||
| 31 | exit('<pre><'.$_POST['Value'].'> contains NON ASCII chars.</pre>'); |
||
| 32 | if ( preg_match( '/[$~=#*+%,{}()\/\\<>;:\"`\[\]&?\s]/', $_POST['Value']) ) |
||
| 33 | exit('<pre><'.$_POST['Value'].'> contains invalid ASCII chars.</pre>'); |
||
| 34 | switch ( $_POST['Value'] ) { |
||
| 35 | case 'anonymous': |
||
| 36 | case 'anybody': |
||
| 37 | case 'anyone': |
||
| 38 | case ( preg_match( '/^anyone@/',$_POST['Value']) == TRUE ): |
||
| 39 | exit('<pre><'.$_POST['Value'].'> is not allowed.</pre>'); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | if (empty($_GET)) { |
||
| 44 | if ($tables["$_"]['milter']) print "<p><i>$_</i> is a miltermap of ".$tables["$_"]['field'].'.</p>'; |
||
| 45 | else { |
||
| 46 | if ($tables["$_"]['bl']) print "<p><i>$_</i> is a blocklist of ".$tables["$_"]['field'].'.</p>'; |
||
| 47 | else print "<p><i>$_</i> is a whitelist of ".$tables["$_"]['field'].'.</p>'; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | openlog($tag, LOG_PID, $fac); |
||
| 52 | $user = username(); |
||
| 53 | |||
| 54 | View Code Duplication | if ( ($mysqli = myConnect($dbhost, $userdb, $pwd, $db, $dbport, $tables, $_, $user)) === FALSE ) |
|
|
0 ignored issues
–
show
|
|||
| 55 | exit ('Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error); |
||
| 56 | |||
| 57 | rlookup($mysqli,username(),$admins,$_POST['Value'],$_POST['genere'],$tables); |
||
| 58 | $mysqli->close(); |
||
| 59 | closelog(); |
||
| 60 | ?> |
||
| 61 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.