get data fingerprint dari mesin

Halo saya sedang mengerjakan task mengambil data dari mesin fingerprint untuk ditampilkan ke halaman browser menggunakan php. Saya menggunakan mesin MB160 dari ZKTeco atau Magic. Saya menemukan ada beberapa SDK library di google untuk melakukan task tersebut tetapi belum ada yang berhasil saat di run, Salah satu SDK yang saya run mengeluarkan pesan error seperti berikut.

Fatal error: Call to undefined function socket_create() in C:\xampp\htdocs\php_zklib-master\zklib\zklib.php on line 16

saya menggunakan PHP Version 5.6.30 dan mendapatkan sdk tersebut dari https://github.com/dnaextrim/php_zklib.git

berikut adalah codingan nya dengan nama file zktest.php

<html>
    <head>
        <title>ZK Test</title>
    </head>

    <body>
<?php
    include("zklib/zklib.php");

    $zk = new ZKLib("192.168.1.201", 4370);

    $ret = $zk->connect();
    sleep(1);
    if ( $ret ):
        $zk->disableDevice();
        sleep(1);
    ?>

        <table border="1" cellpadding="5" cellspacing="2">
            <tr>
                <td><b>Status</b></td>
                <td>Connected</td>
                <td><b>Version</b></td>
                <td><?php echo $zk->version() ?></td>
                <td><b>OS Version</b></td>
                <td><?php echo $zk->osversion() ?></td>
                <td><b>Platform</b></td>
                <td><?php echo $zk->platform() ?></td>
            </tr>
            <tr>
                <td><b>Firmware Version</b></td>
                <td><?php echo $zk->fmVersion() ?></td>
                <td><b>WorkCode</b></td>
                <td><?php echo $zk->workCode() ?></td>
                <td><b>SSR</b></td>
                <td><?php echo $zk->ssr() ?></td>
                <td><b>Pin Width</b></td>
                <td><?php echo $zk->pinWidth() ?></td>
            </tr>
            <tr>
                <td><b>Face Function On</b></td>
                <td><?php echo $zk->faceFunctionOn() ?></td>
                <td><b>Serial Number</b></td>
                <td><?php echo $zk->serialNumber() ?></td>
                <td><b>Device Name</b></td>
                <td><?php echo $zk->deviceName(); ?></td>
                <td><b>Get Time</b></td>
                <td><?php echo $zk->getTime() ?></td>
            </tr>
        </table>
        <hr />
        <table border="1" cellpadding="5" cellspacing="2" style="float: left; margin-right: 10px;">
            <tr>
                <th colspan="5">Data User</th>
            </tr>
            <tr>
                <th>UID</th>
                <th>ID</th>
                <th>Name</th>
                <th>Role</th>
                <th>Password</th>
            </tr>
            <?php
            try {

                //$zk->setUser(1, '1', 'Admin', '', LEVEL_ADMIN);
                $user = $zk->getUser();
                sleep(1);
                while(list($uid, $userdata) = each($user)):
                    if ($userdata[2] == LEVEL_ADMIN)
                        $role = 'ADMIN';
                    elseif ($userdata[2] == LEVEL_USER)
                        $role = 'USER';
                    else
                        $role = 'Unknown';
                ?>
                <tr>
                    <td><?php echo $uid ?></td>
                    <td><?php echo $userdata[0] ?></td>
                    <td><?php echo $userdata[1] ?></td>
                    <td><?php echo $role ?></td>
                    <td><?php echo $userdata[3] ?>&nbsp;</td>
                </tr>
                <?php
                endwhile;
            } catch (Exception $e) {
                header("HTTP/1.0 404 Not Found");
                header('HTTP', true, 500); // 500 internal server error
            }
            //$zk->clearAdmin();
            ?>
        </table>

        <table border="1" cellpadding="5" cellspacing="2">
            <tr>
                <th colspan="6">Data Attendance</th>
            </tr>
            <tr>
                <th>Index</th>
                <th>UID</th>
                <th>ID</th>
                <th>Status</th>
                <th>Date</th>
                <th>Time</th>
            </tr>
            <?php
            $attendance = $zk->getAttendance();
            sleep(1);
            while(list($idx, $attendancedata) = each($attendance)):
                if ( $attendancedata[2] == 14 )
                    $status = 'Check Out';
                else
                    $status = 'Check In';
            ?>
            <tr>
                <td><?php echo $idx ?></td>
                <td><?php echo $attendancedata[0] ?></td>
                <td><?php echo $attendancedata[1] ?></td>
                <td><?php echo $status ?></td>
                <td><?php echo date( "d-m-Y", strtotime( $attendancedata[3] ) ) ?></td>
                <td><?php echo date( "H:i:s", strtotime( $attendancedata[3] ) ) ?></td>
            </tr>
            <?php
            endwhile
            ?>
        </table>

        <fieldset>
            <legend><b>Example Using: </b></legend>

<pre style='color:#000000;background:#ffffff;'><pre>
<span style='color:#5f5035;'>&lt;?php</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>include</span><span style='color:#808030;'>(</span><span style='color:#0000e6;'>"zklib/zklib.php"</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#800000;font-weight:bold; '>new</span><span> ZKLib</span><span style='color:#808030;'>(</span><span style='color:#0000e6;'>"192.168.1.201"</span><span style='color:#808030;'>,</span><span> </span><span style='color:#008c00;'>4370</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$ret</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>connect</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>disableDevice</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>version</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>osversion</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>platform</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>fmVersion</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>workCode</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>ssr</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>pinWidth</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>faceFunctionOn</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>serialNumber</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>deviceName</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$user</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>getUser</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>while</span><span style='color:#808030;'>(</span><span> </span><span style='color:#800000;font-weight:bold; '>list</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$uid</span><span style='color:#808030;'>,</span><span> </span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>)</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#400000;'>each</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$user</span><span style='color:#808030;'>)</span><span> </span><span style='color:#808030;'>)</span><span> </span><span style='color:#800080;'>{</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>if</span><span> </span><span style='color:#808030;'>(</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>2</span><span style='color:#808030;'>]</span><span> </span><span style='color:#808030;'>=</span><span style='color:#808030;'>=</span><span> LEVEL_ADMIN</span><span style='color:#808030;'>)</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$role</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#0000e6;'>'ADMIN'</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>elseif</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>2</span><span style='color:#808030;'>]</span><span> </span><span style='color:#808030;'>=</span><span style='color:#808030;'>=</span><span> LEVEL_USER</span><span style='color:#808030;'>)</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$role</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#0000e6;'>'USER'</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>else</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$role</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#0000e6;'>'Unknown'</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'UID: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$uid</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'ID: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>0</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Name: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>1</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Role: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$role</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Password: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>3</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800080;'>}</span><span></span>
<span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$attendance</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>getAttendance</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>while</span><span style='color:#808030;'>(</span><span> </span><span style='color:#800000;font-weight:bold; '>list</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$idx</span><span style='color:#808030;'>,</span><span> </span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>)</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#400000;'>each</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$attendance</span><span style='color:#808030;'>)</span><span> </span><span style='color:#808030;'>)</span><span> </span><span style='color:#800080;'>{</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Index: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$idx</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'ID: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>0</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Status: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>1</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Date: '</span><span style='color:#808030;'>.</span><span style='color:#400000;'>date</span><span style='color:#808030;'>(</span><span style='color:#0000e6;'>"d-m-Y"</span><span style='color:#808030;'>,</span><span> </span><span style='color:#400000;'>strtotime</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>2</span><span style='color:#808030;'>]</span><span style='color:#808030;'>)</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Time: '</span><span style='color:#808030;'>.</span><span style='color:#400000;'>date</span><span style='color:#808030;'>(</span><span style='color:#0000e6;'>"H:i:s"</span><span style='color:#808030;'>,</span><span> </span><span style='color:#400000;'>strtotime</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>2</span><span style='color:#808030;'>]</span><span style='color:#808030;'>)</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800080;'>}</span><span></span>
<span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>getTime</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>enableDevice</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>disconnect</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span style='color:#5f5035;'>?></span>
</pre>

        </fieldset>
    <?php
        $zk->enrollUser('123');
        $zk->setUser(123, '123', 'Shubhamoy Chakrabarty', '', LEVEL_USER);
        $zk->enableDevice();
        sleep(1);
        $zk->disconnect();
    endif
?>
    </body>
</html>

dan berikut adalah codingan dengan nama file zklib.php

<?php
    class ZKLib {
        public $ip;
        public $port;
        public $zkclient;

        public $data_recv = '';
        public $session_id = 0;
        public $userdata = array();
        public $attendancedata = array();

        public function __construct($ip, $port) {
            $this->ip = $ip;
            $this->port = $port;

            $this->zkclient = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
            //$this->zkclient = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

            // socket_bind($this->zkclient, $ip, $port);

            $timeout = array('sec'=>60,'usec'=>500000);
            socket_set_option($this->zkclient,SOL_SOCKET,SO_RCVTIMEO,$timeout);

            include_once("zkconst.php");
            include_once("zkconnect.php");
            include_once("zkversion.php");
            include_once("zkos.php");
            include_once("zkplatform.php");
            include_once("zkworkcode.php");
            include_once("zkssr.php");
            include_once("zkpin.php");
            include_once("zkface.php");
            include_once("zkserialnumber.php");
            include_once("zkdevice.php");
            include_once("zkuser.php");
            include_once("zkattendance.php");
            include_once("zktime.php");
        }


        function createChkSum($p) {
            /*This function calculates the chksum of the packet to be sent to the
            time clock

            Copied from zkemsdk.c*/

            $l = count($p);
            $chksum = 0;
            $i = $l;
            $j = 1;
            while ($i > 1) {
                $u = unpack('S', pack('C2', $p['c'.$j], $p['c'.($j+1)] ) );

                $chksum += $u[1];

                if ( $chksum > USHRT_MAX )
                    $chksum -= USHRT_MAX;
                $i-=2;
                $j+=2;
            }

            if ($i)
                $chksum = $chksum + $p['c'.strval(count($p))];

            while ($chksum > USHRT_MAX)
                $chksum -= USHRT_MAX;

            if ( $chksum > 0 )
                $chksum = -($chksum);
            else
                $chksum = abs($chksum);

            $chksum -= 1;
            while ($chksum < 0)
                $chksum += USHRT_MAX;

            return pack('S', $chksum);
        }

        function createHeader($command, $chksum, $session_id, $reply_id, $command_string) {
            /*This function puts a the parts that make up a packet together and
            packs them into a byte string*/
            $buf = pack('SSSS', $command, $chksum, $session_id, $reply_id).$command_string;

            $buf = unpack('C'.(8+strlen($command_string)).'c', $buf);

            $u = unpack('S', $this->createChkSum($buf));

            if ( is_array( $u ) ) {
                while( list( $key ) = each( $u ) ) {
                    $u = $u[$key];
                    break;
                }
            }
            $chksum = $u;

            $reply_id += 1;

            if ($reply_id >= USHRT_MAX)
                $reply_id -= USHRT_MAX;

            $buf = pack('SSSS', $command, $chksum, $session_id, $reply_id);

            return $buf.$command_string;

        }

        function checkValid($reply) {
            /*Checks a returned packet to see if it returned CMD_ACK_OK,
            indicating success*/
            $u = unpack('H2h1/H2h2', substr($reply, 0, 8) );

            $command = hexdec( $u['h2'].$u['h1'] );
            if ($command == CMD_ACK_OK)
                return TRUE;
            else
                return FALSE;
        }

        public function connect() {
            return zkconnect($this);
        }

        public function disconnect() {
            return zkdisconnect($this);
        }

        public function version() {
            return zkversion($this);
        }


        public function osversion() {
            return zkos($this);
        }
        /*
        public function extendFormat() {
            return zkextendfmt($this);
        }

        public function extendOPLog(index=0) {
            return zkextendoplog($this, index);
        }
        */

        public function platform() {
            return zkplatform($this);
        }

        public function fmVersion() {
            return zkplatformVersion($this);
        }

        public function workCode() {
            return zkworkcode($this);
        }

        public function ssr() {
            return zkssr($this);
        }

        public function pinWidth() {
            return zkpinwidth($this);
        }

        public function faceFunctionOn() {
            return zkfaceon($this);
        }

        public function serialNumber() {
            return zkserialnumber($this);
        }

        public function deviceName() {
            return zkdevicename($this);
        }

        public function disableDevice() {
            return zkdisabledevice($this);
        }

        public function enableDevice() {
            return zkenabledevice($this);
        }

        public function getUser() {
            return zkgetuser($this);
        }

        public function setUser($uid, $userid, $name, $password, $role) {
            return zksetuser($this, $uid, $userid, $name, $password, $role);
        }

        public function getFP() {
            return zkgetfp($this);
        }

        public function clearUser() {
            return zkclearuser($this);
        }

        public function clearAdmin() {
            return zkclearadmin($this);
        }

        public function getAttendance() {
            return zkgetattendance($this);
        }

        public function clearAttendance() {
            return zkclearattendance($this);
        }

        public function setTime($t) {
            return zksettime($this, $t);
        }

        public function getTime() {
            return zkgettime($this);
        }

        public function enrollUser($userid) {
            return zkenrolluser($this, $userid);
        }

    }
?>

Mohon bantuan nya gan

avatar barkah03
@barkah03

33 Kontribusi 9 Poin

Dipost 3 tahun yang lalu

1 Jawaban:

<div>saat saya sudah melakukan perubahan di zklib.php pada<br><br></div><pre>//$this-&gt;zkclient = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); $this-&gt;zkclient = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);</pre><div><br>malah pesan berikut yang muncul,<br><strong>Fatal error</strong>: Call to undefined function socket_create() in <strong>C:\xampp\htdocs\php_zklib-master\zklib\zklib.php</strong> on line <strong>17</strong></div>

avatar barkah03
@barkah03

33 Kontribusi 9 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban