librenms-librenms/html/includes/table/as-selection.inc.php
TheGreatDoc 4bb9ac7797 Fixed PeeringDB module (#9158)
DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [X] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`

Fixed "Show connected IXes" that I broke in my past PR (Sorry for that)
Changed remote_as in pdb_ix_peers from varchar to unsigned int for correct ordering.
Also I've corrected a typo in the "Show connected IXes" button
2018-09-05 19:26:18 +01:00

52 lines
1.4 KiB
PHP

<?php
// Exclude Private and reserved ASN ranges
// 64512 - 65535
// 4200000000 - 4294967295
$sql = " FROM `devices` WHERE `disabled` = 0 AND `ignore` = 0 AND `bgpLocalAs` > 0 AND (`bgpLocalAs` < 64512 OR `bgpLocalAs` > 65535) AND `bgpLocalAs` < 4200000000 ";
if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`bgpLocalAs` LIKE '%$searchPhrase%')";
}
$count_sql = "SELECT COUNT(*) $sql";
$total = dbFetchCell($count_sql);
if (empty($total)) {
$total = 0;
}
if (!isset($sort) || empty($sort)) {
$sort = 'bgpLocalAs ASC';
}
$sql .= " GROUP BY `bgpLocalAs` ORDER BY $sort";
if (isset($current)) {
$limit_low = (($current * $rowCount) - ($rowCount));
$limit_high = $rowCount;
}
if ($rowCount != -1) {
$sql .= " LIMIT $limit_low,$limit_high";
}
$sql = "SELECT `bgpLocalAs` $sql";
foreach (dbFetchRows($sql) as $asn) {
$astext = get_astext($asn['bgpLocalAs']);
$response[] = array(
'bgpLocalAs' => $asn['bgpLocalAs'],
'asname' => $astext,
'action' => "<a class='btn btn-sm btn-primary' href='" . generate_url(array('page' => 'peering', 'section' => 'ix-list', 'bgpLocalAs' => $asn['bgpLocalAs'])) . "' role='button'>Show connected IXes</a>",
);
}
$output = array(
'current' => $current,
'rowCount' => $rowCount,
'rows' => $response,
'total' => $total,
);
echo _json_encode($output);