Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
# secound db here
SECOND_DB_CONNECTION=mysql
SECOND_DB_HOST=127.0.0.1
SECOND_DB_PORT=3306
SECOND_DB_DATABASE=lorra
SECOND_DB_USERNAME=root
SECOND_DB_PASSWORD=

MAIL_MAILER=smtp
MAIL_HOST=mailhog
Expand All @@ -50,3 +57,4 @@ PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
APP_TIMEZONE=Mounatin/US
61 changes: 61 additions & 0 deletions .env1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
APP_NAME=AMS
APP_ENV=local
APP_KEY=base64:yhgKpmw2xVQ+SNgVgFnBNFFc8WYhYPCaByR/9jg4HYY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tty
DB_USERNAME=root
DB_PASSWORD=


SECOND_DB_CONNECTION=mysql
SECOND_DB_HOST=127.0.0.1
SECOND_DB_PORT=3306
SECOND_DB_DATABASE=lorra
SECOND_DB_USERNAME=root
SECOND_DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
APP_TIMEZONE=Mounatin/US
Binary file not shown.
Binary file added .vs/Attendance_Management_System/v17/.wsuo
Binary file not shown.
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Attendance Management System is a web application based on Laravel which keeps t
- LARAVEL

## Demo
<a href="http://ams.alihost.co">Demo link</a>


### Admin credential
username:ali@aliatayee.com
Expand Down
72 changes: 72 additions & 0 deletions Rats/Zkteco/Lib/Helper/Attendance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Rats\Zkteco\Lib\Helper;

use Rats\Zkteco\Lib\ZKTeco;

class Attendance
{
/**
* @param ZKTeco $self
* @return array [uid, id, state, timestamp]
*/
static public function get(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_ATT_LOG_RRQ;
$command_string = '';

$session = $self->_command($command, $command_string, Util::COMMAND_TYPE_DATA);
if ($session === false) {
return [];
}

$attData = Util::recData($self);

$attendance = [];
if (!empty($attData)) {
$attData = substr($attData, 10);

while (strlen($attData) > 40) {
$u = unpack('H78', substr($attData, 0, 39));

$u1 = hexdec(substr($u[1], 4, 2));
$u2 = hexdec(substr($u[1], 6, 2));
$uid = $u1 + ($u2 * 256);
$id = hex2bin(substr($u[1], 8, 18));
$id = str_replace(chr(0), '', $id);
$state = hexdec(substr($u[1], 56, 2));
$timestamp = Util::decodeTime(hexdec(Util::reverseHex(substr($u[1], 58, 8))));
$type = hexdec(Util::reverseHex(substr($u[1], 66, 2 )));

$attendance[] = [
'uid' => $uid,
'id' => $id,
'state' => $state,
'timestamp' => $timestamp,
'type' => $type
];

$attData = substr($attData, 40);
}

}

return $attendance;
}

/**
* @param ZKTeco $self
* @return bool|mixed
*/
static public function clear(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_CLEAR_ATT_LOG;
$command_string = '';

return $self->_command($command, $command_string);
}
}
83 changes: 83 additions & 0 deletions Rats/Zkteco/Lib/Helper/Connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace Rats\Zkteco\Lib\Helper;

use Rats\Zkteco\Lib\Helper\Util;
use Rats\Zkteco\Lib\ZKTeco;
use ErrorException;
use Exception;

class Connect
{
/**
* @param ZKTeco $self
* @return bool
*/
static public function connect(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_CONNECT;
$command_string = '';
$chksum = 0;
$session_id = 0;
$reply_id = -1 + Util::USHRT_MAX;

$buf = Util::createHeader($command, $chksum, $session_id, $reply_id, $command_string);

socket_sendto($self->_zkclient, $buf, strlen($buf), 0, $self->_ip, $self->_port);

try {
@socket_recvfrom($self->_zkclient, $self->_data_recv, 1024, 0, $self->_ip, $self->_port);
if (strlen($self->_data_recv) > 0) {
$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr($self->_data_recv, 0, 8));

$session = hexdec($u['h6'] . $u['h5']);
if (empty($session)) {
return false;
}

$self->_session_id = $session;
return Util::checkValid($self->_data_recv);
} else {
return false;
}
} catch (ErrorException $e) {
return false;
} catch (Exception $e) {
return false;
}
}

/**
* @param ZKTeco $self
* @return bool
*/
static public function disconnect(ZKTeco $self)
{
$self->_section = __METHOD__;

$command = Util::CMD_EXIT;
$command_string = '';
$chksum = 0;
$session_id = $self->_session_id;

$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6/H2h7/H2h8', substr($self->_data_recv, 0, 8));
$reply_id = hexdec($u['h8'] . $u['h7']);

$buf = Util::createHeader($command, $chksum, $session_id, $reply_id, $command_string);


socket_sendto($self->_zkclient, $buf, strlen($buf), 0, $self->_ip, $self->_port);
try {
@socket_recvfrom($self->_zkclient, $self->_data_recv, 1024, 0, $self->_ip, $self->_port);

$self->_session_id = 0;
return Util::checkValid($self->_data_recv);
} catch (ErrorException $e) {
return false;
} catch (Exception $e) {
return false;
}
}
}
Loading