PHP - reading data from a magnetic card

I need to make an application in which a card reader will be connected to the system, and I have to read the data of the magnetic card reader if someone changes the card on the supplied card reader.

The magnetic card mainly contains user data for registration. Thus, the user will receive a card at the reception. the registrar will change the card, and the system will read the data from the card and register this user in the application to manage my side.

No, I know how to do this? Is it possible with php?

Please share an idea on how to do this.

+4
source share
3 answers

I need to make an application in which a card reader will be connected to the system, and I have to read the data of the magnetic card reader if someone changes the card on the supplied card reader.

Since you want to do this in PHP, I assume that this is a web application and that the map is flashed on the client machine where the browser is running.

You may have a keyboard skin emulator (usually you get text such as “123456”), in which case you need to intercept the keyboard / focus and load the data into the form field or AJAX. This can be difficult if the field or browser loses focus and you need to launch the browser in kiosk mode.

Or you can use swiper using other technologies such as serial (RS232 [C]) , which I find is pretty outdated or have a custom interface (which means that usually USB-swiper and a set of APIs). If so, it all depends on which APIs are implemented; some devices come with ActiveX applets that force you to use Internet Explorer technologies on the Windows platform. Some others use Java applets, and you will have to integrate them on a web page.

Finally, some of them have a fully customizable application that can interact with the system in several ways (the case of “custom LIBRARY” is the same, except that you also have to develop your own application!):

  • By sending a custom HTTP request to a programmable server. If so, you're in luck; you can program a request for each terminal, for example. "HTTP: // yourserver / gotcard terminal = HOUSE & card = $$ $$ CODE". The user application will be hiding in the background, capture the verification code, send it to the server; and you should poll the server to know when each terminal received the code. You will need to handle false and duplicate codes. Such applications come with several placeholders, such as $$ CODE $$, $$ TIMESTAMP $$, and sometimes $$ SWIPEDIRECTION $$; they are used for staff time-out (swipe the screen from left to right when entering work, from right to left when leaving home).
  • By loading code into MySQL or SQL Server, again with programmable placeholders. Here you may be forced to use a VPN / SSH connection to intercept the request, and the provided DB drivers may limit your architectural options.
  • By running your own application or script with regular placeholders. In this case, your best options, IMHO, write a script call to lynx (either Linux or Windows), and dovetail in case # 1, "custom HTTP request."

Unfortunately, various vendors are either prone to the “hacked” side (that is, they provide you with hardware and a minimum of software, an MFC application library and sample, or the source code, and you yourself) or “all-inclusive and non-negotiable” (t .e. you get your reader with a fully configured POS software or application for working with timelogger, and there is no easy way to do anything else with it).

If you use the server side , that is, the PHP script (and not its HTML / text output) and the icon reader are on the same machine, then again it depends on what software you were equipped with something. For servers, keyboard emulation is best (if you have a headless server for no reason to ever connect to the keyboard) or asking for problems (if the magnetic reader and the real keyboard are in competition). RS232 [C] is also very easy to use, on Linux you can ttytail or perhaps even tail -f device in the log file and poll the log file. YOU MAY HAVE PRIVACY QUESTIONS WITH THIS (think "write down all the credit card numbers of all customers in plain text"). Or you can attach the device to PHP using fopen() , no problem.

User API libraries can be complex. You may have to resort to the trick of creating a socket or the name server channel, which opens the device and provides its results for PHP via fsockopen() . Unix sockets and knowledge of programming on a client / server server are required.

UPDATE

In the comment, I saw that you have a library for reading barcodes. I still assume that you are in a web application script (say, three POSs with readers, one server).

A way to do this could be:

 // PHP "server" application running as CLI on POS #1 // (will read some data from an INI file) * application initialization for(;;) { /* Hypothesis 1: blocking library */ $code = read_barcode(); /* Hypothesis 2: nonblocking, but buffering library */ if (!barcode_available()) { sleep(1); continue; } /* Hypothesis 3 is left as an exercise ;-) - remember to reinit the buffer */ if (!checks_if_valid_barcode($code)) continue; // Unless there some reason of using cURL, we keep it simple // We might want to use mcrypt() function to encrypt the code, though. $response = file_get_contents( $CONFIG['server_url'].'?terminal='.$CONFIG['terminal'] .'&code='.$code ); // Do something with the response - maybe just an OK or an ERROR // (eg play a sound, just for kicks). // The server, which generates the error, knows all about the error itself // and the webapp will poll details from the server, not from this app. } 

The web application will periodically request a server; We have two parallel workflows:

  • (1) AJAX checks for a swipe
  • (2) CLI listens to scroll
  • (1) Server is not responding yet
  • (2) CLI application sends shortcut
  • (1) AJAX checks for a swipe
  • (1) Server is not responding yet
  • (2) Server checks for wipes
  • (1) AJAX checks for a swipe
  • (1) The server replies "I received it"
  • (2) returns to listening
  • (1) the client displays the form and starts processing
  • ...
+5
source

By creating a modular system using a barcode reader, you can do this with langauge, such as VB or C #, to create a simple web browser (C # has a component for you to do this in about 5 minutes), C # can then interact with the browser by sending data to the site?

+2
source

On a unix system, I would use a named pipe and have something like python processing a magnetic card. IAV uses RS232, which python handles well. and can then connect to PHP. PHP can also send information back to this channel, for example, request a second read, etc.

+2
source

Source: https://habr.com/ru/post/1438377/


All Articles