Login | ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/vgwhois/trunk/shared/php_includes/ipv6_functions.inc.php
(Generate patch)

Comparing trunk/shared/php_includes/ipv6_functions.inc.php (file contents):
Revision 44 by daniel-marschall, Mon Apr 29 20:59:18 2019 UTC vs.
Revision 45 by daniel-marschall, Sat Mar 28 23:50:01 2020 UTC

# Line 2 | Line 2
2  
3   /*
4   * IPv6 functions for PHP
5 < * Copyright 2012-2014 Daniel Marschall, ViaThinkSoft
6 < * Version 2014-12-12
5 > * Copyright 2012-2020 Daniel Marschall, ViaThinkSoft
6 > * Version 2020-02-28
7   *
8   * Licensed under the Apache License, Version 2.0 (the "License");
9   * you may not use this file except in compliance with the License.
# Line 18 | Line 18
18   * limitations under the License.
19   */
20  
21 < # This library needs gmp! aptitude install php5-gmp
21 > # This library requires either the GMP extension (or BCMath if gmp_supplement.inc.php is present)
22  
23   // TODO: oop, exceptions?
24   // TODO: variant without gmp ?
25   // TODO: IPv6 auflösung 'ffff::192.168.69.1' -> 'ffff:0000:0000:0000:0000:0000:c0a8:4501' geht nicht!!!
26  
27 + if (file_exists(__DIR__ . '/gmp_supplement.inc.php')) include_once __DIR__ . '/gmp_supplement.inc.php';
28 +
29   define('GMP_ONE', gmp_init('1'));
30  
31   // Very small self-test:
# Line 388 | Line 390 | function ipv6_line2range($line) {
390  
391   # ---
392  
393 < function gmp_shiftl($x, $n) { // shift left
394 <        // http://www.php.net/manual/en/ref.gmp.php#99788
395 <        return gmp_mul($x, gmp_pow('2', $n));
393 > if (!function_exists('gmp_shiftl')) {
394 >        function gmp_shiftl($x, $n) { // shift left
395 >                // http://www.php.net/manual/en/ref.gmp.php#99788
396 >                return gmp_mul($x, gmp_pow('2', $n));
397 >        }
398   }
399  
400 < function gmp_shiftr($x, $n) { // shift right
401 <        // http://www.php.net/manual/en/ref.gmp.php#99788
402 <        return gmp_div($x, gmp_pow('2', $n));
400 > if (!function_exists('gmp_shiftr')) {
401 >        function gmp_shiftr($x, $n) { // shift right
402 >                // http://www.php.net/manual/en/ref.gmp.php#99788
403 >                return gmp_div($x, gmp_pow('2', $n));
404 >        }
405   }
406  
407   $cache_ip2long6 = array();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines