Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@author Madrix
@description Displays some statistics about ASNs, IPs, and clones.
@contact armyndev@outlook.com
@version 1.14
@version 1.16
@tested 0.9
@minver 0.9
@maxver *
Expand All @@ -21,7 +21,7 @@ class IPCloneDetectorAndASNAnalyzer
*/
public $name = "IPCloneDetectorAndASNAnalyzer"; // Name of your plugin
public $author = "Madrix"; // Name or handle of your lovely self
public $version = "1.14"; // Version of this plugin
public $version = "1.16"; // Version of this plugin
public $description = "Displays some statistics about ASNs, IPs, and clones."; // Description of your beautiful plugin
public $email = "armyndev@outlook.com"; // An email people can contact you with in case of problems

Expand Down
141 changes: 88 additions & 53 deletions IPCloneDetectorAndASNAnalyzer/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function ipFromAsn($v, $asn)
<button id="SearchinUsers" type="button" class="btn btn-primary" data-toggle="modal" data-target="#searchModal">Search in Users</button>
</div>

<div class="container d-flex justify-content-center align-items-center container-center">
<div class="container-xxl d-flex justify-content-center align-items-center container-center">
<div class="row">
<div class="col-md-6 div-item">
<h4>Number of ASN duplicates sorted from largest to smallest</h4>
Expand Down Expand Up @@ -413,13 +413,13 @@ function ipFromAsn($v, $asn)
});


echo "<table class='table-striped' border='1'>";
echo "<tr><th>ASN</th><th>ASName</th><th>Country Code</th><th>Count</th><th>IPv4</th><th>IPv6</th>" . ($asnIsGood ? "<th>Good ASN</th>" : "") . "</tr>";
echo "<table class='table table-hover table-striped mb-0' border='1'>";
echo "<thead class='thead-dark'><tr><th>ASN</th><th>ASName</th><th>Country Code</th><th>Count</th><th>IPv4</th><th>IPv6</th>" . ($asnIsGood ? "<th>Good ASN</th>" : "") . "</tr></head><tbody>";

foreach ($asnCounts as $info) {
echo "<tr>";
echo "<td>" . (empty($info['asn']) ? '-' : '<a class="btn btn-outline-primary" href="' . get_config("base_url") . 'tools/ip-whois.php?ip=AS' . $info['asn'] . '">' . $info['asn'] . '</a>') . "</td>";
echo "<td>" . (empty($info['asname']) ? 'Localhost ?' : '<a href="https://www.peeringdb.com/asn/' . $info['asn'] . '" target="_blank">' . $info['asname']) . '</a>' . "</td>";
echo "<td>" . (empty($info['asname']) ? 'Localhost ?' : '<a href="https://www.peeringdb.com/asn/' . $info['asn'] . '" target="_blank" class="text-decoration-none">' . $info['asname']) . '</a>' . "</td>";
echo "<td>" . (empty($info['country_code']) ? '-' : "{$info['country_code']} <img src=\"https://flagcdn.com/48x36/" . strtolower($info['country_code']) . ".png\" width=\"20\" height=\"15\">") . "</td>";
echo "<td>" . (empty($info['asn']) ? $info['count'] : '<button type="button" class="btn btn-outline-primary" onclick="showCustomModal(this)" data-asn="' . $info['asn'] . '">' . $info['count'] . '</button>') . "</td>";
echo "<td>" . (empty($info['asn']) ? '-' : ipFromAsn(4, $info['asn'])) . "</td>";
Expand All @@ -429,7 +429,7 @@ function ipFromAsn($v, $asn)
echo "</tr>";
}

echo "</table>";
echo "</tbody></table>";
echo "$asnCount different ASNs found";

if ($asnIsGood)
Expand All @@ -438,7 +438,7 @@ function ipFromAsn($v, $asn)


</div>
<div class="col-md-6 div-item">
<div class="col-md-5 div-item">
<canvas id="Chart" width="400" height="400" class="mb-5"></canvas>

<script>
Expand Down Expand Up @@ -586,12 +586,13 @@ function ipFromAsn($v, $asn)
</script>
<?php
$totalUsers = array_sum($countryCounts);
echo "<table class='country table-striped m-auto mb-5' border='1'>
echo "<table class='country table table-hover table-striped mb-0' border='1'>
<thead class='thead-dark'>
<tr>
<th>Country</th>
<th>Online number</th>
<th>Percentage</th>
</tr>";
</tr></thead><tbody>";

foreach ($countryCounts as $countryCode => $count) {
$percentage = $totalUsers > 0 ? ($count / $totalUsers) * 100 : 0;
Expand All @@ -612,7 +613,7 @@ function ipFromAsn($v, $asn)
<td></td>
</tr>";

echo "</table>";
echo "</tbody></table>";

?>

Expand Down Expand Up @@ -646,12 +647,15 @@ function ipFromAsn($v, $asn)
}
}

echo "<table class='table-striped' border='1'>
echo "<table class='table table-hover table-striped mb-0' border='1'>
<thead class='thead-dark'>
<tr>
<th>IP</th>
<th>Number<br>of<br>duplicates</th>
<th>List of names</th>
</tr>";
</tr>
</thead>
<tbody>";

foreach ($duplicateList as $entry) {
echo "<tr>
Expand All @@ -661,7 +665,7 @@ function ipFromAsn($v, $asn)
</tr>";
}

echo "</table>";
echo "</tbody></table>";
?>
<hr>
<h4>Show clones based on the first 4 segments of IPv6 addresses</h4>
Expand Down Expand Up @@ -696,12 +700,15 @@ function ipFromAsn($v, $asn)
}
}

echo "<table class='table-striped' border='1'>
echo "<table class='table table-hover table-striped mb-0' border='1'>
<thead class='thead-dark'>
<tr>
<th>IP</th>
<th>Number<br>of<br>duplicates</th>
<th>List of names</th>
</tr>";
</tr>
</thead>
<tbody>";

foreach ($duplicateList as $entry) {
echo "<tr>
Expand All @@ -711,7 +718,7 @@ function ipFromAsn($v, $asn)
</tr>";
}

echo "</table>";
echo "</tbody></table>";
?>

<hr>
Expand All @@ -732,6 +739,7 @@ function ipFromAsn($v, $asn)
$ipv6Count++;
}
}

if (isset($obj->user)) {
if (isset($obj->user->account)) {
$accountCount++;
Expand All @@ -741,101 +749,128 @@ function ipFromAsn($v, $asn)
}
}

echo "<table class='table-striped' border='1'>
<tr>
<th>Type</th>
<th>Online number</th>
</tr>
<tr>
<td>Number of total users</td>
<td>{$usersCount}</td>
</tr>
<tr>
<td>Number of IPv4</td>
<td>{$ipv4Count}</td>
</tr>
<tr>
<td>Number of IPv6</td>
<td>{$ipv6Count}</td>
</tr>
<tr>
<td>Number of account</td>
<td>{$accountCount}</td>
</tr>
<tr>
<td>Number of no account</td>
<td>{$noAccountCount}</td>
</tr>
</table>";
// éviter division par zéro
if ($usersCount > 0) {
$ipv4CountPercentage = round(($ipv4Count / $usersCount) * 100, 2) . '%';
$ipv6CountPercentage = round(($ipv6Count / $usersCount) * 100, 2) . '%';
$accountCountPercentage = round(($accountCount / $usersCount) * 100, 2) . '%';
$noAccountCountPercentage = round(($noAccountCount / $usersCount) * 100, 2) . '%';
} else {
$ipv4CountPercentage = $ipv6CountPercentage = $accountCountPercentage = $noAccountCountPercentage = '-';
}

echo "<table class='table table-hover table-striped mb-0' border='1'>
<thead class='thead-dark'>
<tr>
<th>Type</th>
<th>Online number</th>
<th>Percentage</th>
</tr>
</thead>
<tbody>
<tr>
<td>Number of total users</td>
<td>{$usersCount}</td>
<td>-</td>
</tr>
<tr style=\"border-top:solid 3px #000;\">
<td>Number of IPv4</td>
<td>{$ipv4Count}</td>
<td>{$ipv4CountPercentage}</td>
</tr>
<tr>
<td>Number of IPv6</td>
<td>{$ipv6Count}</td>
<td>{$ipv6CountPercentage}</td>
</tr>
<tr style=\"border-top:solid 3px #000;\">
<td>Number of account</td>
<td>{$accountCount}</td>
<td>{$accountCountPercentage}</td>
</tr>
<tr>
<td>Number of no account</td>
<td>{$noAccountCount}</td>
<td>{$noAccountCountPercentage}</td>
</tr>
</tbody>
</table>";
?>



<h4 class="mt-4">Bans server corresponding to '~asn:'</h4>
<?php
echo "<table class='table-striped' border='1'>
echo "<table class='table table-hover table-striped mb-0' border='1'>
<thead class='thead-dark'>
<tr>
<th>Type ban</th>
<th>Found</th>
<th>Affected users</th>
<th>duration</th>
</tr>
</thead>
<tbody>
";
foreach ($server_ban as $obj) {
$usersCount++;
if (isset($obj->name)) {
if (strpos($obj->name, "~asn:") !== false && preg_match('/^\%/', $obj->name, $matches) === 1) {
echo "<tr>
<td>{$obj->type}</td>
<td>{$obj->name}</td>
<td><span class='badge badge-danger'>{$obj->type}</span></td>
<td><code>{$obj->name}</code></td>
<td><a href=\"https://www.unrealircd.org/docs/Soft_ban\" target=\"_blank\">unregistered</a></td>
<td>{$obj->duration_string}</td>
</tr>";
} else if (strpos($obj->name, "~asn:") !== false) {
echo "<tr>
<td>{$obj->type}</td>
<td>{$obj->name}</td>
<td><span class='badge badge-danger'>{$obj->type}</span></td>
<td><code>{$obj->name}</code></td>
<td>all</td>
<td>{$obj->duration_string}</td>
</tr>";
}
}
}
echo "</table>";
echo "</tbody></table>";
?>


<h4 class="mt-4">Bans server corresponding to other type of '~'</h4>
<?php

echo "<table class='table-striped' border='1'>
echo "<table class='table table-hover table-striped mb-0' border='1'>
<thead class='thead-dark'>
<tr>
<th>Type ban</th>
<th>Found</th>
<th>Affected users</th>
<th>duration</th>
</tr>
</thead>
<tbody>
";
foreach ($server_ban as $obj) {
$usersCount++;
if (isset($obj->name)) {
if (strpos($obj->name, "~asn:") === false && strpos($obj->name, "~") !== false && preg_match('/^\%/', $obj->name, $matches) === 1) {
echo "<tr>
<td>{$obj->type}</td>
<td>{$obj->name}</td>
<td><span class='badge badge-danger'>{$obj->type}</span></td>
<td><code>{$obj->name}</code></td>
<td><a href=\"https://www.unrealircd.org/docs/Soft_ban\" target=\"_blank\">unregistered</a></td>
<td>{$obj->duration_string}</td>
</tr>";
} else if (strpos($obj->name, "~asn:") === false && strpos($obj->name, "~") !== false) {
echo "<tr>
<td>{$obj->type}</td>
<td>{$obj->name}</td>
<td><span class='badge badge-danger'>{$obj->type}</span></td>
<td><code>{$obj->name}</code></td>
<td>all</td>
<td>{$obj->duration_string}</td>
</tr>";
}
}
}
echo "</table>";
echo "</tbody></table>";
?>
</div>
</div>
Expand Down