-
Notifications
You must be signed in to change notification settings - Fork 3
/
functions.php
29 lines (26 loc) · 936 Bytes
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
function saveLogData($data = array()){
global $deviceId;
writeLog(json_encode($data));
$records = $data["record"];
$sql = 'Insert INTO tblt_timesheet(punchingcode,date,time,Tid) values';
$sqlArray = array();
foreach($records as $record){
$sqlArray[] = '("'.$record["enrollid"].'","'.date("Y-m-d",strtotime($record["time"])).'","'.date("H:i:s",strtotime($record["time"])).'","'.$deviceId.'")';
}
$exec = mysql_query($sql.implode(",",$sqlArray)) or writeLog(mysql_error()." :: ".$sql.implode(",",$sqlArray));
if($exec){
$result = '{"ret":"sendlog","result":true,"cloudtime":"2016-03-25 13:49:30"}';
}else{
$result = '{"ret":"sendlog","result":false,"reason":1}';
}
return $result;
}
function writeLog($msg , $rec = ""){
error_log(date("Y-m-d H:i:s")." :: ".$msg.PHP_EOL,3,"./logs/error".$rec.".log");
}
function setDeviceId($data){
global $deviceId;
$deviceId = $data['sn'];
}
?>