Page tree
Skip to end of metadata
Go to start of metadata

MIN registration number based on POS Station's MAC address

What is MAC Address? → MAC address - Wikipedia

How to find out your PC Mac address (Windows 10/11) → https://www.howtogeek.com/761481/how-to-find-your-mac-address-on-windows-10-or-11/

Advised MAC Address format in TEXT file: AA:BB:CC:DD:EE:FF

The MIN Registration number and permit number will be fetched by Ehors based on POS Stations' MAC Addresses.

And the MAC address is from the computer's network interface hardware ID. This means if you have the network interface changed/repaired, you'll get a new MAC address for the computer.

Due to web browsers aren't allowed to read the MAC address from the computer directly, we need an interface in between to read the MAC address and send it back to the WINX system.

E-HORS Archived WAMP software → https://www.ehors.com/downloads/laragon-wamp.exe

Kindly advise NOT to use RANDOM MAC Address:

Requirement:

  • Computer with Windows Operating System
  • Can install WAMP (Windows Apache Management Protocol)

Install lightweight PHP service on the computer to handle MAC Address reading

  1. Download "Laragon" from this LINK or our fixed archived HERE


  2. Execute the installer downloaded, first option ONLY chose "Run Laragon when Windows Starts", rest uncheck.
  3. Once installation is complete, it should start Larafon in your "Taskbar"
  4. Double-click to open the interface, if the service started, chose "Stop", we'll need to do some quick configuration to Laragon


  5. One-Stop, select the gear icon on the top right of the windows to configure the Laragon
  6. In "General" you should have the setting as follow, except for the "Document Root" and "Data Directory", rest should follow as highlighted
  7. Under Service & Ports, make sure have following service also. Important is the Apache port with "8888"
  8. Mail Catcher and Mail Sender shall disable as we do not need such service as follow:
  9. Once configured, just save by closing this "Preferences" window with the "x" icon on the top right.
    Then you shall "Start All"
  10. If all is correct, you should have this in the Laragon window.
  11. Now we'll put a "getmac.php" file into the "Root" Directory. Open the WWW root directory by clicking the "Root" Icons. 

  12. It will open your directory root folder windows and should only have 1 file called "index.php". 

  13. Right-click in the opened windows explorer and create a new "text" file in the folder as follows: 

  14. Highlight the whole file name when creating a new text file as follows, including the file extension

  15. Give it the name "getmac.php", and click away to save the file name

  16. Now right-click on the file name "getmac.php" and edit with notepad.exe

  17. Once you have the file open, copy the following code into the "getmac.php"

    <?php
    header('Access-Control-Allow-Origin: *');
    $Result = array("STATUS" => "", "MAC_ADDR" => "");
    function ReadMacAddressWinCommand()
    {
        global $Result;
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $GetMacResult = exec('getmac /fo csv /nh | findstr /V /R /C:"disconnected"') or die("UNABLE_EXEC_GETMAC_CMD");
            if ($GetMacResult != "") {
                // First see if can explode out \n and or \r\n
                $ConnectionResults = explode("\n", $GetMacResult);
                // ONLY USe first connection;
                $ActiveConnectionFirst = $ConnectionResults[0];
                // Get Only MAC Address;
                $ConnectionInfo = explode(",", $ActiveConnectionFirst);
                // MAC ADDRESS TAKE OUT "
                $ActiveMacAddress = str_replace('"', '', $ConnectionInfo[0]);
                //
                if ($ActiveMacAddress != "") {
                    $Result["STATUS"] = "OK";
                    $Result["MAC_ADDR"] = $ActiveMacAddress;
                }
            } else {
                $Result["STATUS"] = "CANNOT_GET_MAC_ADDRESS";
            }
        } else {
            $Result["STATUS"] = "NOTN_WIN_SYSTEM";
        }
    }
    if (isset($_REQUEST["CMD"]) && $_REQUEST["CMD"] == "GETMAC") {
        // First test read a fixed txt file
        $FixMacAddressFile = "./StationMacAddress.txt";
        $MacAddressFile = fopen($FixMacAddressFile, "r");
        if ($MacAddressFile) {
            $MacAddressFixed = rtrim(fread($MacAddressFile, filesize($FixMacAddressFile)));
            fclose($MacAddressFile);
            if (preg_match('/^(?:(?:[0-9a-f]{2}[\:]{1}){5}|(?:[0-9a-f]{2}[-]{1}){5}|(?:[0-9a-f]{2}){5})[0-9a-f]{2}$/i', $MacAddressFixed) == 1) {
                $Result["STATUS"] = "OK";
                $Result["MAC_ADDR"] = $MacAddressFixed;
            } else {
                ReadMacAddressWinCommand();
            }
        } else {
            ReadMacAddressWinCommand();
        }
    }
    echo json_encode($Result);
  18. Save the file
  19. Now create another file called "StationMacAddress.txt", using the method in point 13
  20. Click away to save the file name
  21. Open the file "StationMacAddress.txt" with notepad.exe as point 16
  22. Put in your mac address of the POS station as registered in MIN into the file (Example), make sure no "new line" after the mac address
  23. Save this text file.
  24. Save it and that all, you can "test" it by calling from browser: localhost:8888/getmac.php?CMD=GETMAC and should have the following screen.


  • For IT personnel test and checking, if the MAC address is correctly fetch by WINX system, you can find the "MACADDRESS" variable from browser debugger:


Double-check the following programs before using the POS terminals. You should see MIN & PTU details and the MAC Address






  • No labels