Subversion Repositories php_utils

Rev

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

Rev 46 Rev 51
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-2022 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2012-2022 Daniel Marschall, ViaThinkSoft
6
 * Version 2022-09-18
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
                if (isset($rng[1])) $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