Simpan script dibawah ini dengan nama scan.php :
<?php
function cek_dir($path,$app)
{
//$year=date('m-Y');
if (!is_dir($path))
{
mkdir($path, 0777);
}
$app_path=$path.'/';
if (!is_dir($app_path.$app))
{
mkdir($app_path.$app, 0777);
}
}
$barcode = $_REQUEST['barcode'];
//check dir untuk menyimpan log
$upload_path='/var/www/trunk/scan/log_scan/';
cek_dir($upload_path,'');
$log_name='scan.txt';
//insert data
$open = fopen("$upload_path/$log_name","a");
fputs($open, $barcode."\n");
fclose($open);
?>
<html>
<head><title>Production and Manufacturing</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript">
function setFocus()
{
document.getElementById("fname").focus();
}
function setStyle(x)
{
document.getElementById(x).style.background='#000000';
document.getElementById(x).style.color='#FFFFFF';
}
function openw(namafilecontact)
{
window.open(namafilecontact,'windows1','scrollbars=yes, fullscreen=yes');
}
function closed()
{
window.close();
}
function reload()
{
document.scan_barcode.barcode.value='';
}
</script>
</head>
<body onload="setFocus();">
<div align="center"> <b style="font-size: 15px;">SCAN BARCODE</b>
<form name="scan_barcode" method="post" action="scan.php" >
<input type="text" id="fname" name="barcode" class="scan_input" autocomplete="off" size="30" onfocus="setStyle(this.id)" />
</form>
</div>
<div class="title">
Last Scan Barcode
</div>
<div class="list_data">
<?php
//show data if not click send email
//view max 5 line
$file = file("$upload_path$log_name");
for ($i = count($file)-10; $i < count($file); $i++) {
echo $file[$i] . "<br />";
}
?>
</div>
</body>
</html>
untuk pengaturan path nyafunction cek_dir($path,$app)
{
//$year=date('m-Y');
if (!is_dir($path))
{
mkdir($path, 0777);
}
$app_path=$path.'/';
if (!is_dir($app_path.$app))
{
mkdir($app_path.$app, 0777);
}
}
$barcode = $_REQUEST['barcode'];
//check dir untuk menyimpan log
$upload_path='/var/www/trunk/scan/log_scan/';
cek_dir($upload_path,'');
$log_name='scan.txt';
//insert data
$open = fopen("$upload_path/$log_name","a");
fputs($open, $barcode."\n");
fclose($open);
?>
<html>
<head><title>Production and Manufacturing</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript">
function setFocus()
{
document.getElementById("fname").focus();
}
function setStyle(x)
{
document.getElementById(x).style.background='#000000';
document.getElementById(x).style.color='#FFFFFF';
}
function openw(namafilecontact)
{
window.open(namafilecontact,'windows1','scrollbars=yes, fullscreen=yes');
}
function closed()
{
window.close();
}
function reload()
{
document.scan_barcode.barcode.value='';
}
</script>
</head>
<body onload="setFocus();">
<div align="center"> <b style="font-size: 15px;">SCAN BARCODE</b>
<form name="scan_barcode" method="post" action="scan.php" >
<input type="text" id="fname" name="barcode" class="scan_input" autocomplete="off" size="30" onfocus="setStyle(this.id)" />
</form>
</div>
<div class="title">
Last Scan Barcode
</div>
<div class="list_data">
<?php
//show data if not click send email
//view max 5 line
$file = file("$upload_path$log_name");
for ($i = count($file)-10; $i < count($file); $i++) {
echo $file[$i] . "<br />";
}
?>
</div>
</body>
</html>
$upload_path='/var/www/trunk/scan/log_scan/';
anda sesuaikan sendiri tapi jangan lupa pastikan aksesnya 777 ya (R W X)
Selamat Mencoba.
No comments:
Post a Comment