Subversion Repositories uuid_mac_utils

Rev

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

  1. <?php
  2.  
  3. /*
  4.  * MAC interpreter for PHP
  5.  * Copyright 2017 - 2023 Daniel Marschall, ViaThinkSoft
  6.  * Version 2023-07-13
  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.  
  21. header('Content-Type:text/html; charset=utf-8');
  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 {
  32.         $mac = isset($_REQUEST['mac']) ? trim($_REQUEST['mac']) : '';
  33.         $title = 'Interprete a MAC address';
  34. }
  35.  
  36. ?><html>
  37.  
  38. <head>
  39.         <meta charset="UTF-8">
  40.         <link rel="stylesheet" type="text/css" href="style.css">
  41.         <title><?php echo htmlentities($title); ?></title>
  42.         <meta name=viewport content="width=device-width, initial-scale=1">
  43. </head>
  44.  
  45. <body>
  46.  
  47. <h1><?php echo htmlentities($title); ?></h1>
  48.  
  49. <p><a href="index.php">Back</a></p>
  50.  
  51. <?php
  52.  
  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. }
  60.  
  61. echo '<pre>';
  62.  
  63. if (!mac_valid($mac)) {
  64.         echo 'This is not a valid MAC address.';
  65. } else {
  66.         decode_mac($mac);
  67. }
  68.  
  69. ?></pre>
  70.  
  71. <br>
  72.  
  73. </body>
  74.  
  75. </html>
  76.