Rev 36 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 36 | Rev 41 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * MAC interpreter for PHP |
4 | * MAC interpreter for PHP |
5 | * Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft |
6 | * Version 2023-07-11 |
6 | * Version 2023-07-13 |
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 18... | Line 18... | ||
18 | * limitations under the License. |
18 | * limitations under the License. |
19 | */ |
19 | */ |
20 | 20 | ||
21 | header('Content-Type:text/html; charset=utf-8'); |
21 | header('Content-Type:text/html; charset=utf-8'); |
22 | 22 | ||
- | 23 | include_once __DIR__ . '/includes/mac_utils.inc.php'; |
|
- | 24 | ||
- | 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 { |
|
23 | $mac = isset($_GET['mac']) ? trim($_GET['mac']) : ''; |
32 | $mac = isset($_REQUEST['mac']) ? trim($_REQUEST['mac']) : ''; |
- | 33 | $title = 'Interprete a MAC address'; |
|
- | 34 | } |
|
24 | 35 | ||
25 | ?><html> |
36 | ?><html> |
26 | 37 | ||
27 | <head> |
38 | <head> |
28 | <meta charset="UTF-8"> |
39 | <meta charset="UTF-8"> |
29 | <link rel="stylesheet" type="text/css" href="style.css"> |
40 | <link rel="stylesheet" type="text/css" href="style.css"> |
30 | <title>Interprete a MAC address</title> |
41 | <title><?php echo htmlentities($title); ?></title> |
31 | <meta name=viewport content="width=device-width, initial-scale=1"> |
42 | <meta name=viewport content="width=device-width, initial-scale=1"> |
32 | </head> |
43 | </head> |
33 | 44 | ||
34 | <body> |
45 | <body> |
35 | 46 | ||
36 | <h1>Interprete a MAC address</h1> |
47 | <h1><?php echo htmlentities($title); ?></h1> |
37 | 48 | ||
38 | <p><a href="index.php">Back</a></p> |
49 | <p><a href="index.php">Back</a></p> |
39 | 50 | ||
40 | <?php |
51 | <?php |
41 | 52 | ||
- | 53 | if ($gen_aai) { |
|
- | 54 | echo '<p><i>Reload the page to receive another AAI.</i></p>'; |
|
- | 55 | } else { |
|
42 | echo '<form method="GET" action="interprete_mac.php">'; |
56 | echo '<form method="GET" action="interprete_mac.php">'; |
43 | echo ' MAC: <input type="text" name="mac" value="'.htmlentities($mac).'" style="width:250px"> <input type="submit" value="Interprete">'; |
57 | echo ' MAC: <input type="text" name="mac" value="'.htmlentities($mac).'" style="width:250px"> <input type="submit" value="Interprete">'; |
44 | echo '</form>'; |
58 | echo '</form>'; |
- | 59 | } |
|
45 | 60 | ||
46 | echo '<pre>'; |
61 | echo '<pre>'; |
47 | 62 | ||
48 | include_once __DIR__ . '/includes/mac_utils.inc.php'; |
- | |
49 | - | ||
50 | if (!mac_valid($mac)) { |
63 | if (!mac_valid($mac)) { |
51 | echo 'This is not a valid MAC address.'; |
64 | echo 'This is not a valid MAC address.'; |
52 | } else { |
65 | } else { |
53 | decode_mac($mac); |
66 | decode_mac($mac); |
54 | } |
67 | } |