Last active
October 2, 2015 10:11
-
-
Save zhiephie/7b27408a8005c82a2031 to your computer and use it in GitHub Desktop.
revisi code mu, di PHP 5.6 parent::__construct di hapus. Dan bagian config/hooks.php rubah bagian ini 'class' => 'Usertracking',
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* Usertracking Class | |
* | |
* @package CodeIgniter | |
* @subpackage Hook | |
* @category Usertracking | |
* @author zhiephie | |
*/ | |
class Usertracking { | |
private $CI = null; | |
public function __construct() | |
{ | |
// parent::__construct(); //Remove in php5.6 + | |
$this->CI =& get_instance(); | |
$this->CI->load->library('form_validation', 'session'); | |
$this->CI->load->helper('date'); | |
$this->CI->output->get_output(); | |
} | |
public function idNum() | |
{ | |
$CI =& get_instance(); | |
$CI->db->select_max('id'); | |
$CI->db->order_by('id', 'DESC'); | |
$query = $CI->db->get('usertracking'); | |
$row = $query->result_array(); | |
$data['query'] = 1 + $row[0]['id']; | |
return $data['query']; | |
} | |
public function log_activity() | |
{ | |
// We need an instance of CI as we will be using some CI classes | |
$CI =& get_instance(); | |
$id_id = $this->idNum(); | |
$data['id'] = $id_id; | |
$data['userID'] = $CI->session->userdata('userID'); | |
// Next up, we want to know what page we're on, use the router class | |
$data['section'] = $CI->router->class; | |
$data['action'] = $CI->router->method; | |
// We don't need it, but we'll log the URI just in case | |
$data['activities'] = uri_string(); | |
// Lastly, we need to know when this is happening | |
$data['times'] = date('Y-m-d H:i:s'); | |
// And write it to the database | |
$CI->db->insert('usertracking', $data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment