Last change
on this file since 7797 was 7773, checked in by Pieter Naber, 15 years ago |
Created interlinks!
Fixed LogHandler to output at the end (so we have a valid KML file)
|
File size:
1.4 KB
|
Line | |
---|
1 | <?php
|
---|
2 | /*
|
---|
3 | * Project: NodeMap2.0
|
---|
4 | * File: NetworkList.class.php
|
---|
5 | * Purpose: Contains a list of Network objects
|
---|
6 | */
|
---|
7 |
|
---|
8 | class NetworkList {
|
---|
9 | private $networks; // Array of Network objects
|
---|
10 |
|
---|
11 | /*
|
---|
12 | * Function: __construct (constructor)
|
---|
13 | * Description: Creating a new NetworkList object
|
---|
14 | * Parameters: -
|
---|
15 | * Returns: -
|
---|
16 | */
|
---|
17 | public function __construct() {
|
---|
18 | // Create an empty network array
|
---|
19 | $this->networks = array();
|
---|
20 | }
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * Function: add
|
---|
24 | * Description: Adds a network to our list
|
---|
25 | * Parameters: Network $newNetwork
|
---|
26 | * Returns: -
|
---|
27 | */
|
---|
28 | function add(Network $newNetwork) {
|
---|
29 | // Add Network $newNetwork to the array
|
---|
30 | $this->networks[] = $newNetwork;
|
---|
31 | }
|
---|
32 |
|
---|
33 | /*
|
---|
34 | * Function: get
|
---|
35 | * Description: Gets the network on a specific number
|
---|
36 | * Parameters: int $i
|
---|
37 | * Returns: Network if $i is in the range of the array, otherwise false
|
---|
38 | */
|
---|
39 | function get($i) {
|
---|
40 | if (($i >= 0) && ($i < count($this->networks))) {
|
---|
41 | return $this->networks[$i];
|
---|
42 | } else {
|
---|
43 | return false;
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | /*
|
---|
48 | * Function: find
|
---|
49 | * Description: Find the position of a network using a IP within the range of network
|
---|
50 | * Parameters: string $ip
|
---|
51 | * Returns: Position of the network if found, otherwise false
|
---|
52 | */
|
---|
53 | function find($ipAddress) {
|
---|
54 | $networkCount = count($this->networks);
|
---|
55 | for ($i = 0; $i < $networkCount; $i++) {
|
---|
56 | if ($this->networks[$i]->inNetwork($ipAddress)) {
|
---|
57 | return $i;
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | // Not found
|
---|
62 | return false;
|
---|
63 | }
|
---|
64 | }
|
---|
65 | ?>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.