File manager - Edit - /home/wwwroot/camplus.hk/master.camplus.hk/public_html/application/modules/access_control/models/Device_model.php
Back
<?php Class Device_model extends CI_Model{ function save($device){ $return = $this->db->update('ac_devices',array('venue_id'=>$device['venue_id']),array('devID'=>$device['device_id'])); return $return; } function getReceiver($device) { $this->db->select('ac_devices.*, ac_receiver.ip'); $this->db->join('ac_receiver', 'ac_receiver.dev_id=ac_devices.receiver'); return $this->db->get_where('ac_devices',array('devID'=>$device))->row_array(); } function getWL($device) { $this->db->select('at_user_card.uid, ac_whitelist.*'); $this->db->join('at_user_card', 'at_user_card.card=ac_whitelist.card'); return $this->db->get_where('ac_whitelist',array('dev_id'=>$device))->result_array(); } function queueCmd($device,$cmd) { return $this->db->insert('ac_cmd', array('devID'=>$device,'cmd'=>str_replace(',','%2C',$cmd),'ttl'=>3)); } function getQueue() { $cmd = $this->db->get_where('ac_cmd', array('ttl >'=>0))->row_array(); $this->db->update('ac_cmd',array('ttl'=>$cmd['ttl']-1),array('id'=>$cmd['id'])); return $cmd; } function addWL($devID,$card) { $exist = $this->db->get_where('ac_whitelist',array('dev_id'=>$devID,'card'=>$card))->row_array(); if(empty($exist)) { return $this->db->insert('ac_whitelist',array('dev_id'=>$devID,'card'=>$card)); } else { return false; } } function delWL($devID,$card) { return $this->db->delete('ac_whitelist',array('dev_id'=>$devID,'card'=>$card)); } function storeRecord($receiver) { $ip = $this->db->get_where('ac_receiver',array('dev_id'=>$receiver))->row_array(); $url = 'http://' . $ip['ip'] . '/index.php?start_id=' . $ip['max_cardRecordID']; // echo $url; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_HEADER, false); $data= curl_exec($ch); curl_close($ch); //echo $data; $results = json_decode($data,true); $last_cardRecordID=0; foreach ($results as $key=>$result) { $card = $result['cardNo']; $this->db->select('users.username,users.id'); $this->db->from('at_user_card'); $this->db->join('users','at_user_card.uid = users.id'); $this->db->where('at_user_card.card=' . $card); $user = $this->db->get()->row_array(); if(empty($user)){ $user['username'] = 0; $user['id'] = 0; } $this->db->insert('ac_record',array('cardRecordID'=>$result['cardRecordID'],'card'=>$card,'uid'=>$user['id'],'username'=>$user['username'],'cardTime'=>$result['cardTime'],'cardResult'=>$result['cardResult'],'devID'=>$result['deviceID'])); $last_cardRecordID = $result['cardRecordID']; } if($last_cardRecordID!=0) $results = $this->db->update('ac_receiver',array('max_cardRecordID'=>$last_cardRecordID),array('dev_id'=>$receiver)); return true; } function getRecord($device) { return $this->db->get_where('ac_record',array('devID'=>$device))->result_array(); } /* function readRecord($device) { $data = $this->db->get_where('ac_devices',array('devID'=>$device))->row_array(); $ip = $this->db->get_where('ac_receiver',array('dev_id'=>$data['receiver']))->row_array(); $url = 'http://' . $ip['ip'] . '/index.php?reader=' . $device; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_HEADER, false); $data= curl_exec($ch); curl_close($ch); // echo $data; $results = json_decode($data,true); foreach ($results as $key=>$result) { // print_r($result); $card = $result['cardNo']; $this->db->select('users.username,users.id'); $this->db->from('at_user_card'); $this->db->join('users','at_user_card.uid = users.id'); $user = $this->db->get()->row_array(); $results[$key]['user'] = $user['username']; $results[$key]['uid'] = $user['id']; } return $results; }*/ } ?>
| ver. 1.4 |
Github
|
.
| PHP 7.2.34 | Generation time: 0.16 |
proxy
|
phpinfo
|
Settings