Minor fixes

This commit is contained in:
Roman Kelesidis 2023-04-06 23:45:07 +07:00
commit 9281ba84cf
4 changed files with 128 additions and 90 deletions

View file

@ -143,12 +143,10 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
// Reg users
if (count($onlinerow_reg)) {
$reg_userid_ary = array();
$users_count = 0;
for ($i = 0, $iMax = count($onlinerow_reg); $i < $iMax; $i++) {
if (!in_array($onlinerow_reg[$i]['user_id'], $reg_userid_ary)) {
if ($onlinerow_reg[$i]['user_id'] == $userdata['user_id'] || !bf($onlinerow_reg[$i]['user_opt'], 'user_opt', 'user_viewonline')) {
$reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
$users_count++;
$row_class = 'row1';
$reg_ip = \TorrentPier\Helpers\IPHelper::decodeIP($onlinerow_reg[$i]['session_ip']);
@ -162,15 +160,12 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
));
}
}
}
}
// Guest users
if (count($onlinerow_guest)) {
$guest_users = 0;
for ($i = 0, $iMax = count($onlinerow_guest); $i < $iMax; $i++) {
$guest_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
$guest_users++;
$row_class = 'row2';
$guest_ip = \TorrentPier\Helpers\IPHelper::decodeIP($onlinerow_guest[$i]['session_ip']);

View file

@ -38,9 +38,9 @@
"google/recaptcha": "^1.2",
"guzzlehttp/guzzle": "^7.5",
"guzzlehttp/psr7": "^2.4",
"longman/ip-tools": "1.2.1",
"monolog/monolog": "^2.9",
"rych/bencode": "v1.0.0",
"s1lentium/iptools": "v1.1.1",
"samdark/sitemap": "2.4.0",
"symfony/mailer": "^5.4",
"symfony/polyfill": "v1.27.0",

135
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f76b0749814071fa08e34466d6606682",
"content-hash": "652417f60effdbc419391b0ff25d14b4",
"packages": [
{
"name": "bugsnag/bugsnag",
@ -904,6 +904,66 @@
],
"time": "2023-03-09T13:19:02+00:00"
},
{
"name": "longman/ip-tools",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/akalongman/php-ip-tools.git",
"reference": "6c050dfbf91811d14b9b3aa31fb7116eac0f0a18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/akalongman/php-ip-tools/zipball/6c050dfbf91811d14b9b3aa31fb7116eac0f0a18",
"reference": "6c050dfbf91811d14b9b3aa31fb7116eac0f0a18",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
"php": ">=5.5"
},
"require-dev": {
"phpspec/phpspec": "~2.1",
"phpunit/phpunit": "~4.1",
"squizlabs/php_codesniffer": "~2.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Longman\\IPTools\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Avtandil Kikabidze aka LONGMAN",
"email": "akalongman@gmail.com",
"homepage": "https://longman.me",
"role": "Developer"
}
],
"description": "PHP IP Tools for manipulation with IPv4 and IPv6",
"homepage": "https://github.com/akalongman/php-ip-tools",
"keywords": [
"IP",
"Match",
"compare",
"ipv4",
"ipv6",
"mask",
"subnet",
"tools",
"utilities"
],
"support": {
"issues": "https://github.com/akalongman/php-ip-tools/issues",
"source": "https://github.com/akalongman/php-ip-tools"
},
"time": "2016-10-23T20:08:46+00:00"
},
{
"name": "monolog/monolog",
"version": "2.9.1",
@ -1288,25 +1348,25 @@
},
{
"name": "psr/http-message",
"version": "1.0.1",
"version": "1.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "1.1.x-dev"
}
},
"autoload": {
@ -1335,9 +1395,9 @@
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/master"
"source": "https://github.com/php-fig/http-message/tree/1.1"
},
"time": "2016-08-06T14:39:51+00:00"
"time": "2023-04-04T09:50:52+00:00"
},
{
"name": "psr/log",
@ -1488,61 +1548,6 @@
},
"time": "2014-01-13T00:34:03+00:00"
},
{
"name": "s1lentium/iptools",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/S1lentium/IPTools.git",
"reference": "f6f8ab6132ca7443bd7cced1681f5066d725fd5f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/S1lentium/IPTools/zipball/f6f8ab6132ca7443bd7cced1681f5066d725fd5f",
"reference": "f6f8ab6132ca7443bd7cced1681f5066d725fd5f",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"IPTools\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Safarov Alisher",
"email": "alisher.safarov@outlook.com",
"homepage": "https://github.com/S1lentium"
}
],
"description": "PHP Library for manipulating network addresses (IPv4 and IPv6)",
"keywords": [
"IP",
"IP-Tools",
"cidr",
"ipv4",
"ipv6",
"network",
"subnet"
],
"support": {
"issues": "https://github.com/S1lentium/IPTools/issues",
"source": "https://github.com/S1lentium/IPTools/tree/master"
},
"time": "2018-09-19T06:15:53+00:00"
},
{
"name": "samdark/sitemap",
"version": "2.4.0",
@ -2378,5 +2383,5 @@
"php": "^7.4 || ^8.0"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.2.0"
}

View file

@ -9,7 +9,7 @@
namespace TorrentPier\Helpers;
use IPTools\IP;
use Longman\IPTools\Ip;
use function strlen;
@ -28,7 +28,7 @@ class IPHelper
*/
public static function encodeIP(string $ip): string
{
return IP::parse($ip)->toLong();
return Ip::ip2long($ip);
}
/**
@ -40,18 +40,56 @@ class IPHelper
*/
public static function decodeIP($ip): string
{
return (string)IP::parseLong((int)$ip);
return Ip::long2ip((int)$ip);
}
/**
* Get IP version
* Checking IP for validity
*
* @param string $ip
* @return string
*
* @return bool
*/
public static function getVersion(string $ip): string
public static function isValid(string $ip): bool
{
return IP::parse($ip)->getVersion();
return Ip::isValid($ip);
}
/**
* Checking if it is a local IP
*
* @param string $ip
*
* @return bool
*/
public static function isLocal(string $ip): bool
{
return IP::isLocal($ip);
}
/**
* Checking if it is a remote IP
*
* @param string $ip
*
* @return bool
*/
public static function isRemote(string $ip): bool
{
return IP::isRemote($ip);
}
/**
* Compare IP
*
* @param string $ip
* @param string $range
*
* @return bool
*/
public static function compareIP(string $ip, string $range): bool
{
return Ip::compare($ip, $range);
}
/**