mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
create implicit Curl property for GeoIP ctor
This commit is contained in:
@@ -8,7 +8,7 @@ class Error403 extends Error {
|
||||
public static function error(string $message = ''): never {
|
||||
$who = static::$requestContext->viewer()->label();
|
||||
$ipaddr = static::$requestContext->viewer()->ipaddr();
|
||||
$geoip = new Util\GeoIP(new Util\Curl());
|
||||
$geoip = new Util\GeoIP();
|
||||
Util\Irc::sendMessage(
|
||||
IRC_CHAN_STATUS,
|
||||
"$who ($ipaddr [{$geoip->countryISO($ipaddr)}]) on {$_SERVER['REQUEST_METHOD']} {$_SERVER['REQUEST_URI']}"
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace Gazelle\Manager;
|
||||
|
||||
use Gazelle\User as User;
|
||||
use Gazelle\User as User;
|
||||
use Gazelle\Util\GeoIP as GeoIP;
|
||||
|
||||
/**
|
||||
* This class handles both the user IP site history as well as
|
||||
@@ -44,7 +45,7 @@ class IPv4 extends \Gazelle\Base {
|
||||
);
|
||||
$affected = self::$db->affected_rows();
|
||||
$user->setField('IP', $ipv4)
|
||||
->setField('ipcc', new \Gazelle\Util\GeoIP(new \Gazelle\Util\Curl())->countryISO($ipv4))
|
||||
->setField('ipcc', new GeoIP()->countryISO($ipv4))
|
||||
->modify();
|
||||
self::$cache->delete_value(sprintf('ipv4_dup_' . str_replace('-', '_', $ipv4)));
|
||||
$this->flush();
|
||||
|
||||
@@ -118,8 +118,7 @@ class UserCreator extends Base {
|
||||
? UserStatus::enabled->value
|
||||
: UserStatus::unconfirmed->value,
|
||||
STARTING_INVITES,
|
||||
new \Gazelle\Util\GeoIP(new \Gazelle\Util\Curl())
|
||||
->countryISO($ipaddr),
|
||||
new Util\GeoIP()->countryISO($ipaddr),
|
||||
authKey()
|
||||
];
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ declare(strict_types=1);
|
||||
namespace Gazelle\Util;
|
||||
|
||||
class GeoIP {
|
||||
public function __construct(protected Curl $curl) {
|
||||
public function __construct(
|
||||
protected Curl $curl = new Curl(),
|
||||
) {
|
||||
// server is running on the local network
|
||||
if (defined('HTTP_PROXY')) {
|
||||
$this->curl->setUseProxy(false);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#! /usr/bin/env php
|
||||
<?php
|
||||
|
||||
namespace Gazelle;
|
||||
|
||||
require_once(__DIR__ . '/../lib/bootstrap.php');
|
||||
|
||||
$db = Gazelle\DB::DB();
|
||||
$geoip = new Gazelle\Util\GeoIP(new Gazelle\Util\Curl());
|
||||
$userMan = new Gazelle\Manager\User();
|
||||
$db = DB::DB();
|
||||
$geoip = new Util\GeoIP();
|
||||
$userMan = new Manager\User();
|
||||
|
||||
$db->prepared_query("
|
||||
SELECT ID FROM users_main
|
||||
|
||||
@@ -16,8 +16,4 @@ if (isset($_SERVER['http_if_modified_since'])) {
|
||||
|
||||
header('Expires: ' . date('D, d-M-Y H:i:s \U\T\C', time() + 3600 * 24 * 120)); //120 days
|
||||
header('Last-Modified: ' . date('D, d-M-Y H:i:s \U\T\C', time()));
|
||||
|
||||
die(
|
||||
new \Gazelle\Util\GeoIP(new \Gazelle\Util\Curl())
|
||||
->countryISO($_GET['ip'])
|
||||
);
|
||||
echo new Util\GeoIP()->countryISO($_GET['ip']);
|
||||
|
||||
Reference in New Issue
Block a user