34 lines
646 B
PHP
Executable File
34 lines
646 B
PHP
Executable File
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
require_once __DIR__.'/../../include/php/const';
|
|
|
|
|
|
function mfrc522_read(){
|
|
|
|
/* [1] Read card code
|
|
=========================================================*/
|
|
/* (1) Fetch card file */
|
|
$code = @file_get_contents(TMP_DIR.'/card');
|
|
|
|
/* (2) Manage error */
|
|
if( !is_string($code) || !preg_match("/^\s*([A-F0-9]{2}(?:-[A-F0-9]{2}){3,5})\s*$/m", $code, $match) )
|
|
return 127;
|
|
|
|
/* (3) Extract only code */
|
|
$code = $match[1];
|
|
|
|
|
|
/* [2] Return card code
|
|
=========================================================*/
|
|
slog("read $code code", 'mfrc522:read');
|
|
return $code;
|
|
|
|
}
|
|
|
|
|
|
echo mfrc522_read();
|
|
?>
|
|
|