/var/www/hkosl.com/nick/codeigniter/application/models/Email_tracking_model.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
30
31
32
33
34
35
36
37
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Email_tracking_model extends BaseModel
{
    protected 
$table 'email_tracking';

    public static function 
create_email_tracking($email$table_name$table_id$type null$code null$remark null)
    {
        if (empty(
$code)) {
            
//random code
            
$code sha256_hash(time() . uniqid(mt_rand(), true));
        }

        
$result Email_tracking_model::create(array(
            
'created_at' => date("Y-m-d H:i:s"),
            
'created_by' => $_SESSION["sys_user_id"],
            
'updated_at' => date("Y-m-d H:i:s"),
            
'updated_by' => $_SESSION["sys_user_id"],
            
'email' => $email,
            
'table_name' => $table_name,
            
'table_id' => $table_id,
            
'type' => $type,
            
'code' => $code,
            
'remark' => $remark,
        ));

        
$email urlencode($email);

        if (
$result->id) {
            return array(
'code' => $code'html' => '<img src="'.front_url('email_tracking/open/'.$email.'/'.$code).'" style="display:none !important;" />');
        } else {
            return 
null;
        }
    }

}