mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 15:10:54 +00:00
29 lines
638 B
PHP
29 lines
638 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Components\IP;
|
|
use App\Models\Node;
|
|
|
|
class NodeService
|
|
{
|
|
public function getNodeGeo($id = false): int
|
|
{
|
|
if ($id) {
|
|
$nodes = Node::whereStatus(1)->whereId($id)->get();
|
|
} else {
|
|
$nodes = Node::whereStatus(1)->get();
|
|
}
|
|
|
|
$result = 0;
|
|
foreach ($nodes as $node) {
|
|
$data = IP::IPSB($node->is_ddns ? gethostbyname($node->server) : $node->ip);
|
|
if ($data && $node->update(['geo' => $data['latitude'].','.$data['longitude']])) {
|
|
$result++;
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|