10000 [HttpFoundation] Move IP check methods to a HttpUtils class for reuse by vicb · Pull Request #6005 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Move IP check methods to a HttpUtils class for reuse #6005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading 10000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[HttpUtils] stof review(tm)
  • Loading branch information
vicb committed Dec 6, 2012
commit d78114226f6daa16fe1458a5c2bd1557bf8f2a0d
10 changes: 5 additions & 5 deletions src/Symfony/Component/HttpFoundation/HttpUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ private function __construct() {}
*
* @return boolean True valid, false if not.
*/
public function checkIp($requestIp, $ip)
public static function checkIp($requestIp, $ip)
{
if (false !== strpos($requestIp, ':')) {
return self::checkIp6($requestIp, $ip);
} else {
return self::checkIp4($requestIp, $ip);
}

return self::checkIp4($requestIp, $ip);
}

/**
Expand All @@ -48,7 +48,7 @@ public function checkIp($requestIp, $ip)
*
* @return boolean True valid, false if not.
*/
public function checkIp4($requestIp, $ip)
public static function checkIp4($requestIp, $ip)
{
if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2);
Expand Down Expand Up @@ -77,7 +77,7 @@ public function checkIp4($requestIp, $ip)
*
* @throws RuntimeException When IPV6 support is not enabled
*/
public function checkIp6($requestIp, $ip)
public static function checkIp6($requestIp, $ip)
{
if (!((extension_loaded('sockets') && defined('AF_INET6')) || @inet_pton('::1'))) {
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled w 4064 ith option "disable-ipv6".');
Expand Down
0