Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

How to find out your PC Mac address (Windows 10/11Ubuntu and Other Linux Distros) → https://wwwitsfoss.howtogeek.com/761481/how-to-find-your-mac-address-on-windows-10-or-11linux/

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

...

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:
Image Removed

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

...

Requirement:

  • Computer with Ubuntu 
  • Php 7.4, apache
  • Must login by root user 

Login by root user

  1. In Ubuntu Application folder to find "Terminal" 
    Logo as ::Image Added

  2. Enter command : 

    Code Block
    sudo -i
  3. Enter password
  4. After login root user account will be same as tis :: Image Added

Install Apache2 and php7.4

  1. Update repository 
  2. install apache 

    Code Block
    apt install apache2 -y
  3. Install php7.4 version 
     

    Steps to install PHP 7.2 on Ubuntu 22.04 LTS server or desktop

    The steps given here can also be used for other Linux distros based on Ubuntu 22.04 LTS such as POP OS Linux, Linux Mint, Elementary OS, and more…

    1. Run system update

    Our system must be in its latest state to avoid any package conflict. Hence, before going further, let’s first run the system update command to ensure all the available security updates are on our Ubuntu. 

    Code Block
    sudo apt update && sudo apt upgrade

    2. Add Ondrej PPA Repository on Ubuntu 22.04

    We cannot install the PHP7.4 packages using the default system repository of Ubuntu 22.04 because the default version of PHP present to install in this Ubuntu version is PHP 8.1. Hence, to get the older version, add the PPA repository called Ondrej

    Code Block
    sudo apt install software-properties-common
    Code Block
    sudo add-apt-repository ppa:ondrej/php -y

    Add Ondrej PPA Repository on Ubuntu 22.04Image Added


    3. Install PHP 7.4 on Ubuntu 22.04

    Now, we can install PHP7.4 on our Ubuntu 22.04 Linux, however, we need to mention the version number with the command otherwise the system will install the php8.1 on our system. Here are the commands to follow: 

    Code Block
    sudo apt install php7.4


    For Common Extensions you can use: 

    Code Block
    sudo apt install php7.4-{cli,common,curl,zip,gd,mysql,xml,mbstring,json,intl}

    install PHP 7.4 on Ubuntu 22.04 1Image Added


    4. Set PHP7.4 as the default version

    Note: This step is only needed by those who are using two versions of PHP. For example, on Ubuntu 22.04 you are using PHP 7.4 and PHP 8.1 both. Hence, to make one of them as system’s default version we can use the update-alternatives command: 

    Code Block
    sudo update-alternatives --config php

    Enter one of the “Selection” numbers of the listed PHP version that you want to make the system’s default one. For example, here 7.4 is at 1 number, hence we have typed the same followed by pressing of the “Enter” key.

    Set PHP 7.4 as default version on UbuntuImage Added



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

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

    Image Removed
  2. Right-click in the opened windows explorer and create a new "text" file in the folder as follows: 
    Image Removed
  3. Highlight the whole file name when creating a new text file as follows, including the file extension
    Image Removed
  4. Give it the name "getmac.php", and click away to save the file name
    Image Removed

  5. Now right-click on the file name "getmac.php" and edit with notepad.exe
    Image Removed
    Code Block
    cd /var/www/html/
  6. Command to generate the php file 


    Code Block
    nano /var/www/html/getmac.php
  7. Once you have the file open, copy the following code into the "getmac.php"

    Code Block
    languagephp
    linenumberstrue
    <?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);
    Note

    Copy from here and right click to paste in terminal

  8. Save the file  

    Note

    Press keyboard: Ctrl + X             >>>>>   enter : Y      >>>>>>>>>>> Press : Enter 

  9. Now chekc the MAC address for this computer first , and you can follow command 

    Code Block
    ip addr show

    Example: after command will show this:: (Green colour line is MAC Address of this computer) Image Added

  10. Select the mac address (select and mark is copy in ubuntu function): 08:00:27:ef:a5:70 
  11. Now create another file called "StationMacAddress.txt"

    , using the

    and method

    in

    same point

    13

    Image RemovedImage Removed
  12. Click away to save the file name
  13. Open the file "StationMacAddress.txt" with notepad.exe as point 16
  14. Code Block
    nano /var/www/html/StationMacAddress.txt
    Note

    a. 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

    b. Right click the mouse for paste the MAc Address to StationMacAddress.txt

  15. Save and exist : 

    Note

    Press keyboard: Ctrl + X             >>>>>   enter : Y      >>>>>>>>>>> Press : Enter 

  16. Open the file "StationMacAddress.txt" with cat function (This step is double check the MAX A)
  17. Save this text file.
  18. 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.

...