Subversion Repositories uuid_mac_utils

Rev

Rev 36 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 daniel-mar 1
<?php
2 daniel-mar 2
 
26 daniel-mar 3
/*
4
 * MAC interpreter for PHP
5
 * Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft
41 daniel-mar 6
 * Version 2023-07-13
26 daniel-mar 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.
10
 * You may obtain a copy of the License at
11
 *
12
 *     http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
 
14 daniel-mar 21
header('Content-Type:text/html; charset=utf-8');
22
 
41 daniel-mar 23
include_once __DIR__ . '/includes/mac_utils.inc.php';
32 daniel-mar 24
 
41 daniel-mar 25
if ($gen_aai = (($_REQUEST['aai_gen'] ?? '0') == '1')) {
26
        $bits = $_REQUEST['aai_gen_bits'] ?? 48;
27
        $multicast = $_REQUEST['aai_gen_multicast'] ?? '0';
28
        if (!is_numeric($bits)) die();
29
        $mac = gen_aai((int)$bits, $multicast=='1');
30
        $title = 'Generate a MAC address (AAI)';
31
} else {
32
        $mac = isset($_REQUEST['mac']) ? trim($_REQUEST['mac']) : '';
33
        $title = 'Interprete a MAC address';
34
}
35
 
14 daniel-mar 36
?><html>
37
 
2 daniel-mar 38
<head>
14 daniel-mar 39
        <meta charset="UTF-8">
2 daniel-mar 40
        <link rel="stylesheet" type="text/css" href="style.css">
41 daniel-mar 41
        <title><?php echo htmlentities($title); ?></title>
35 daniel-mar 42
        <meta name=viewport content="width=device-width, initial-scale=1">
2 daniel-mar 43
</head>
44
 
45
<body>
46
 
41 daniel-mar 47
<h1><?php echo htmlentities($title); ?></h1>
2 daniel-mar 48
 
49
<p><a href="index.php">Back</a></p>
50
 
32 daniel-mar 51
<?php
2 daniel-mar 52
 
41 daniel-mar 53
if ($gen_aai) {
54
        echo '<p><i>Reload the page to receive another AAI.</i></p>';
55
} else {
56
        echo '<form method="GET" action="interprete_mac.php">';
57
        echo '  MAC: <input type="text" name="mac" value="'.htmlentities($mac).'" style="width:250px"> <input type="submit" value="Interprete">';
58
        echo '</form>';
59
}
32 daniel-mar 60
 
61
echo '<pre>';
62
 
2 daniel-mar 63
if (!mac_valid($mac)) {
64
        echo 'This is not a valid MAC address.';
65
} else {
15 daniel-mar 66
        decode_mac($mac);
2 daniel-mar 67
}
68
 
69
?></pre>
70
 
25 daniel-mar 71
<br>
72
 
2 daniel-mar 73
</body>
74
 
75
</html>