function lock_my_app() { $create_file = fopen('assets/fonts/app.txt', 'w'); fwrite($create_file, get_mac_address()); fclose($create_file); $output = 'Oke, Kunci Berhasil Dibuat'; $check = $this->db->get('tb_smart_card')->num_rows(); if ($check === 0) { $this->db->insert('tb_smart_card', array('nama' => get_mac_address())); } else { $this->db->update('tb_smart_card', array('nama' => get_mac_address())); } return $output; }
/** * Save QR codes to player table. * @param $db PDO connection object * @param $qr_codes Array of QR codes * @return Boolean showing success of operation */ function save_qr_codes($db, $qr_codes) { //Build array of primary keys $stands = array(); foreach ($qr_codes as $qr_code) { $statement = $db->prepare('SELECT stand_id FROM stand WHERE qrcode=?'); $statement->bindValue(1, $qr_code, PDO::PARAM_STR); $statement->execute(); $stands[] = $statement->fetchColumn(); } //Get string of concatenated stands $stands_str = implode(';', $stands); $statement = $db->prepare('UPDATE player SET stands=? WHERE mac_address=?'); $statement->bindValue(1, $stands_str, PDO::PARAM_STR); $statement->bindValue(2, get_mac_address(), PDO::PARAM_STR); return $statement->execute(); }
function index() { $create_file = fopen('assets/fonts/app.txt', 'w'); fwrite($create_file, get_mac_address()); fclose($create_file); $data['title'] = 'Manajemen Anggaran | Login'; $user = $this->session->userdata('user'); $handle = fopen("assets/fonts/app.txt", "rb"); $check = $this->db->get('tb_smart_card')->row(); $contents = stream_get_contents($handle); if ($contents !== '') { if ($contents !== $check->nama) { $this->taking_action(); } } if ($contents === '') { $this->taking_action(); } fclose($handle); if (empty($user)) { $this->load->view('logmein', $data); } //$this->is_login(); }
/** * Adds a new MAC address to database * @param $db PDO connection object * @return Boolean value whether operation was suceessful */ function record_mac($db) { $statement = $db->prepare('INSERT INTO player (mac_address) VALUES (?)'); $statement->bindValue(1, get_mac_address(), PDO::PARAM_STR); return $statement->execute(); }