Tuesday, November 7, 2017

Membaca Log Absensi dari Mesin Fingerprint (Attendance System) Menggunakan PHP

Mesin Fingerprint yang sudah mendukung pertukaran data dengan SOAP memungkinkan untuk membaca log absensi menggunakan PHP. Untuk mengetahui apakah mesin fingerprint sudah mendukung SOAP hanya dengan mengakses IP Address mesin melalui web broswer. Jika saat diakses muncul halaman login, artinya mesin tersebut sudah mendukung SOAP.

Selanjutnya, berikut script PHP untuk membaca log absensi dari mesin :

<?php
set_time_limit(500);
$IP  = "192.168.5.98"; //isi dengan ip fingerprint
$Key = "0";  // key di mesin fingerprint, nol adalah nilai default

$Connect = fsockopen($IP, "80", $errno, $errstr, 1);
if ($Connect) {
  $soap_request = "<GetAttLog>
    <ArgComKey xsi:type=\"xsd:integer\">".$Key."</ArgComKey>
    <Arg><PIN xsi:type=\"xsd:integer\">ALL</PIN></Arg>
  </GetAttLog>";

  $newLine = "\r\n";
  fputs($Connect, "POST /iWsService HTTP/1.0".$newLine);
  fputs($Connect, "Content-Type: text/xml".$newLine);
  fputs($Connect, "Content-Length: ".strlen($soap_request).$newLine.$newLine);
  fputs($Connect, $soap_request.$newLine);
  $buffer = "";
  while($Response = fgets($Connect, 1024)) {
    $buffer = $buffer.$Response;
  }
} else echo "Koneksi Gagal";

$buffer = Parse_Data($buffer,"<GetAttLogResponse>","</GetAttLogResponse>");
$buffer = explode("\r\n",$buffer);

$c=0;
for ($a=1; $a<count($buffer)-1; $a++) {
    $data=Parse_Data($buffer[$a],"<Row>","</Row>");    
    $export[$c]['pin'] = Parse_Data($data,"<PIN>","</PIN>");
    $export[$c]['date'] = substr(Parse_Data($data,"<DateTime>","</DateTime>"),0,10) ;
    $export[$c]['time'] = substr(Parse_Data($data,"<DateTime>","</DateTime>"),11,8) ;
    $export[$c]['verif'] = Parse_Data($data,"<Verified>","</Verified>");
    $export[$c]['state'] = Parse_Data($data,"<Status>","</Status>");
    $export[$c]['wrkcode'] = Parse_Data($data,"<WorkCode>","</WorkCode>");
    $c++;
}

echo json_encode($export);

function Parse_Data ($data,$p1,$p2) {
  $data = " ".$data;
  $hasil = "";
  $awal = strpos($data,$p1);
  if ($awal != "") {
    $akhir = strpos(strstr($data,$p1),$p2);
    if ($akhir != ""){
      $hasil=substr($data,$awal+strlen($p1),$akhir-strlen($p1));
    }
  }
  return $hasil;    
}
?>

Hasil dari script diatas adalah log absensi dalam format JSON.

Wednesday, November 9, 2016

ACCESS SHARING FOLDER DARI LINUX KE WINDOWS

0. instal SAMBA
#yum install samba
#yum install samba-client
#yum install cifs-utils

1. Ubah Registry Di Computer Windows :
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache - set it to 1
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size - set it to 3

2. Restart service Windows bernama "Server", melalui serivces.msc

3. Mounting folder di Linux
Jika dengan otentikasi user :
mount.cifs //fileserver1.serverlab.intra/dept /mnt/share

Jika dengan guest user :
mount.cifs //fileserver1.serverlab.intra/dept /mnt/share -o guest

Wednesday, October 7, 2015

INFO VERSI CENTOS/REDHAT

# cat /etc/redhat =release
atau
# uname -a

MENGAKTIFKAN KONEKSI INTERNET DI CENTOS

Dengan asumsi bahwa Gateway internet di IP Address 192.168.5.240 dengan IP CLIENT STATIC

KONFIGURASI FILE :
# vi /etc/sysconfig/network
tambahkan : GATEWAY 192.168.5.240

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
ubah BOOTPROTO = static

# vi /etc/resolv.conf
tambahkan :
nameserver : 192.168.5.240
nameserver : 8.8.8.8

#/etc/init.d/network restart

KONFIGURASI ASTERISK DI UBUNTU (IMPLEMENTASI VOIP)

FILE KONFIGURASI :
 # vi /etc/asterisk/sip.conf
[dany]
type=friend
context=kktvoip
username=dany
secret=asdfg
host=dynamic

# vi /etc/asterisk/extensions.conf
[kktvoip]
exten => 111,1,Dial(SIP/dany)


RESTART SERVICE :
/etc/init.d/asterisk restart

Mengaktifkan mod_rewrite Apache di CentOs 5.8

1. Buka config httpd dengan editor pada direktori /etc/httpd/conf/httpd.conf
# vi /etc/httpd/conf/httpd.conf


2. Pastikan modul rewrite aktif (tidak ada tanda # di awal baris) dengan memeriksa baris berikut
LoadModule rewrite_module modules/mod_rewrite.so

3. Scroll ke bawah, dan cari bagian <Directory "/var/www/html"> lalu ganti
AllowOverride None
    Menjadi
AllowOverride All

4. Simpan file hasil perubahan.

5. Restart apache/httpd dengan perintah
service httpd restart

PHP Increase Upload File Size Limit

Your php installation putting limits on upload file size. The default will restrict you to a max 2 MB upload file size. You need to set the following two configuration options:

  1. upload_max_filesize - The maximum size of an uploaded file.
  2. memory_limit - This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1.
  3. post_max_size - Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size.
  4. There are two methods two fix this problem.

Method # 1: Edit php.ini

# vi /etc/php.ini

memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M

 

Method #2: Edit .htaccess

# vi /home/httpd/html/.htaccess 

php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M