Subversion Repositories vgwhois

Rev

Rev 65 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 65 Rev 97
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * IPv4 functions for PHP
4
 * IPv4 functions for PHP
5
 * Copyright 2012-2021 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2012-2022 Daniel Marschall, ViaThinkSoft
6
 * Version 2021-05-21
6
 * Version 2022-09-22
7
 *
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
10
 * You may obtain a copy of the License at
11
 *
11
 *
Line 399... Line 399...
399
 
399
 
400
        if (strpos($line, '/') !== false) {
400
        if (strpos($line, '/') !== false) {
401
                $rng = ipv4_cidr2range($line);
401
                $rng = ipv4_cidr2range($line);
402
        } else {
402
        } else {
403
                $rng = explode('-', $line);
403
                $rng = explode('-', $line);
404
                $rng[0] = trim($rng[0]);
-
 
405
                $rng[1] = trim($rng[1]);
-
 
406
                $rng[0] = ipv4_normalize($rng[0]);
404
                $rng[0] = ipv4_normalize(trim($rng[0]));
407
                if (!isset($rng[1])) $rng[1] = $rng[0];
405
                $rng[1] = isset($rng[1]) ? ipv4_normalize(trim($rng[1])) : $rng[0];
408
                $rng[1] = ipv4_normalize($rng[1]);
-
 
409
        }
406
        }
410
 
407
 
411
        return $rng;
408
        return $rng;
412
}
409
}
413
 
410
 
Line 563... Line 560...
563
                        return long2ip(intval($iplong));
560
                        return long2ip(intval($iplong));
564
                }
561
                }
565
                if (strlen($bin) != 128) {
562
                if (strlen($bin) != 128) {
566
                        return false;
563
                        return false;
567
                }
564
                }
568
                $pad = 128 - strlen($bin);
565
                //$bin = str_pad($bin, 128, '0', STR_PAD_LEFT);
569
                for ($i = 1; $i <= $pad; $i++) {
-
 
570
                        $bin = '0'.$bin;
-
 
571
                }
-
 
572
                $bits = 0;
566
                $bits = 0;
573
                $ipv6 = ''; # added by vts to avoid warning
567
                $ipv6 = ''; # added by vts to avoid warning
574
                while ($bits <= 7) {
568
                while ($bits <= 7) {
575
                        $bin_part = substr($bin,($bits*16),16);
569
                        $bin_part = substr($bin,($bits*16),16);
576
                        $ipv6 .= dechex(bindec($bin_part)) . ':';
570
                        $ipv6 .= dechex(bindec($bin_part)) . ':';