mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 12:31:06 -05:00
hits counter was broken
This commit is contained in:
parent
c516cbf37f
commit
79e3d7193a
@ -292,26 +292,28 @@ class Pastes extends CI_Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hits
|
/*
|
||||||
$hits_data = array(
|
* Hits
|
||||||
'paste_id' => $pid,
|
* First check if record already exists. If it does, do not insert.
|
||||||
'ip_address' => $this->input->ip_address() ,
|
* INSERT IGNORE INTO does not work for postgres.
|
||||||
'created' => mktime() ,
|
*/
|
||||||
);
|
$this->db->select('count(paste_id) as count');
|
||||||
$hits_where = array(
|
$this->db->where('paste_id', $pid);
|
||||||
'paste_id' => $pid,
|
$this->db->where('ip_address', $this->input->ip_address());
|
||||||
'ip_address' => $this->input->ip_address() ,
|
$query = $this->db->get('trending');
|
||||||
);
|
$hits_count = $query->result_array();
|
||||||
|
$hits_count = $hits_count[0]['count'];
|
||||||
// First check if record already exists. If it does, do not insert.
|
|
||||||
// INSERT IGNORE INTO does not work for postgres.
|
|
||||||
|
|
||||||
$query = $this->db->get('trending', $hits_where);
|
|
||||||
|
|
||||||
if ($query->num_rows == 0)
|
if ($hits_count == 0)
|
||||||
{
|
{
|
||||||
$this->db->insert('trending', $hits_data);
|
$this->db->insert('trending', array(
|
||||||
|
'paste_id' => $pid,
|
||||||
|
'ip_address' => $this->input->ip_address() ,
|
||||||
|
'created' => mktime() ,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//update hits counter every minute
|
||||||
|
|
||||||
if (mktime() > (60 + $data['hits_updated']))
|
if (mktime() > (60 + $data['hits_updated']))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user