| 10582 |
lgm |
1 |
<?php
|
|
|
2 |
if (!defined('BASEPATH'))
|
|
|
3 |
exit('No direct script access allowed');
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
Class MY_Controller extends CI_Controller {
|
|
|
7 |
|
|
|
8 |
function __construct() {
|
|
|
9 |
// Call the CI_controller constructor
|
|
|
10 |
parent::__construct();
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
//load everything needed
|
|
|
14 |
/*$currentclient =$this -> config -> item('current_client');
|
|
|
15 |
if(!isset($currentclient))
|
|
|
16 |
{$currentclient = $this -> session -> userdata('current_client');}*/
|
|
|
17 |
|
| 11103 |
lgm |
18 |
$currentclient = $this -> config -> item('current_client');
|
| 10582 |
lgm |
19 |
$this -> load -> config($currentclient);
|
| 11103 |
lgm |
20 |
$model = $currentclient.'_model';
|
|
|
21 |
$this->load->model($model);
|
|
|
22 |
$url = $this->config->item('curl_base_url').'tracking';
|
|
|
23 |
$params = array();
|
|
|
24 |
if (isset($_SERVER['HTTP_REFERER'])){
|
|
|
25 |
$params['referer'] = $_SERVER['HTTP_REFERER'];
|
|
|
26 |
}else{
|
|
|
27 |
$params['referer'] = '';
|
|
|
28 |
}
|
|
|
29 |
if(isset($_GET['afid']) && !empty($_GET['afid'])){
|
|
|
30 |
$params['afid'] = $_GET['afid'];
|
|
|
31 |
}else{
|
|
|
32 |
$params['afid'] = '';
|
|
|
33 |
}
|
|
|
34 |
if(isset($_GET['utm_source']) && !empty($_GET['utm_source'])){
|
|
|
35 |
$params['utm_source'] = $_GET['utm_source'];
|
|
|
36 |
}else{
|
|
|
37 |
$params['utm_source'] = '';
|
|
|
38 |
}
|
|
|
39 |
$this->mcurl->add_call('tracking','post',$url,$params);
|
|
|
40 |
$response = $this->mcurl->execute($url);
|
|
|
41 |
$data['response'] = $response['tracking']['response'];
|
|
|
42 |
$response = $this->magento_model->product_list($data);
|
|
|
43 |
if(isset($response[0]->response) && !empty($response[0]->response)){
|
|
|
44 |
foreach ($response[0]->response as $key => $value) {
|
|
|
45 |
if($value->maxAge != -1){
|
|
|
46 |
$expires = time()+$value->maxAge;
|
|
|
47 |
$newdata = (object) array( "name" => $value->name, "value" => $value->value, "expires"=>$expires,"path"=>$value->path,"secure"=>$value->secure);
|
|
|
48 |
$cookieData = (object) array( "data" => $newdata);
|
|
|
49 |
setcookie( "$value->name", json_encode( $cookieData ), $expires , "$value->path",'',$value->secure);
|
|
|
50 |
}else{
|
|
|
51 |
$newdata = (object) array( "name" => $value->name, "value" => $value->value, "expires"=>$value->maxAge,"path"=>$value->path,"secure"=>$value->secure);
|
|
|
52 |
$cookieData = (object) array( "data" => $newdata);
|
|
|
53 |
setcookie( "$value->name", json_encode( $cookieData ), $value->maxAge , "$value->path",'',$value->secure);
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
| 10582 |
lgm |
58 |
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
}
|