2011-12-13 16:57:24 +00:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
* Don't use this! this is a raw and dirty written class just for testing some
|
|
|
|
|
* stuff... Johannes
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class PCSC {
|
|
|
|
|
|
|
|
|
|
public $context;
|
|
|
|
|
public $card;
|
|
|
|
|
public $readers;
|
|
|
|
|
public $connection;
|
|
|
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
|
$this->context = scard_establish_context();
|
|
|
|
|
}
|
2021-02-21 06:19:50 +01:00
|
|
|
|
|
|
|
|
/*function __destruct() {
|
2011-12-13 16:57:24 +00:00
|
|
|
$this->context = scard_release_context($this->context);
|
2021-02-21 06:19:50 +01:00
|
|
|
}*/
|
2011-12-13 16:57:24 +00:00
|
|
|
|
|
|
|
|
function connect($reader) {
|
|
|
|
|
return $this->connection = scard_connect($this->context, $reader);
|
|
|
|
|
}
|
2021-02-21 06:19:50 +01:00
|
|
|
|
2011-12-13 16:57:24 +00:00
|
|
|
/*function reconnect() {
|
|
|
|
|
return $this->connection = scard_reconnect($this->connection);
|
|
|
|
|
}*/
|
2021-02-21 06:19:50 +01:00
|
|
|
|
2011-12-13 16:57:24 +00:00
|
|
|
function disconnect() {
|
|
|
|
|
return scard_disconnect($this->connection);
|
|
|
|
|
}
|
2021-02-21 06:19:50 +01:00
|
|
|
|
2011-12-13 16:57:24 +00:00
|
|
|
function listreaders() {
|
|
|
|
|
return $this->readers = scard_list_readers($this->context);
|
|
|
|
|
}
|
2021-02-21 06:19:50 +01:00
|
|
|
|
2011-12-13 16:57:24 +00:00
|
|
|
function transmit($apdu) {
|
|
|
|
|
return scard_transmit($this->connection, $apdu);
|
|
|
|
|
}
|
2021-02-21 06:19:50 +01:00
|
|
|
|
2011-12-13 16:57:24 +00:00
|
|
|
function isvalidcontext() {
|
|
|
|
|
return scard_is_valid_context($this->context);
|
|
|
|
|
}
|
2021-02-21 06:19:50 +01:00
|
|
|
|
2011-12-13 16:57:24 +00:00
|
|
|
function releasecontext() {
|
|
|
|
|
return scard_release_context($this->context);
|
|
|
|
|
}
|
2021-02-21 06:19:50 +01:00
|
|
|
|
2011-12-13 16:57:24 +00:00
|
|
|
function status() {
|
|
|
|
|
return scard_status($this->connection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|