Subversion Repositories SmartDukaan

Rev

Rev 10582 | Rev 11107 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
if (!defined('BASEPATH'))
        exit('No direct script access allowed');


Class MY_Controller extends CI_Controller {

        function __construct() {
                // Call the CI_controller constructor
                parent::__construct();


                //load everything needed
                /*$currentclient =$this -> config -> item('current_client');
                if(!isset($currentclient))
                {$currentclient = $this -> session -> userdata('current_client');}*/

                $currentclient = $this -> config -> item('current_client');
                $this -> load -> config($currentclient);
                $model = $currentclient.'_model';
                $this->load->model($model);
                $url = $this->config->item('curl_base_url').'tracking'; 
        $params = array();      
        if (isset($_SERVER['HTTP_REFERER'])){
                $params['referer'] = $_SERVER['HTTP_REFERER'];
        }else{
                $params['referer'] = '';
        }
        if(isset($_GET['afid']) && !empty($_GET['afid'])){
                $params['afid'] = $_GET['afid'];
        }else{
                $params['afid'] = '';
        }
        if(isset($_GET['utm_source']) && !empty($_GET['utm_source'])){
                $params['utm_source'] = $_GET['utm_source'];
        }else{
                $params['utm_source'] = '';
        }
        $this->mcurl->add_call('tracking','post',$url,$params);
        $response = $this->mcurl->execute($url);
        $data['response'] = $response['tracking']['response'];
        $response = $this->magento_model->product_list($data);
                if(isset($response[0]->response) && !empty($response[0]->response)){
                        foreach ($response[0]->response as $key => $value) {
                                if($value->maxAge != -1){
                                        $expires = time()+$value->maxAge;
                                        $newdata = (object) array( "name" => $value->name, "value" => $value->value, "expires"=>$expires,"path"=>$value->path,"secure"=>$value->secure);
                                        $cookieData = (object) array( "data" => $newdata);
                                        setcookie( "$value->name", json_encode( $cookieData ), $expires , "$value->path",'',$value->secure);
                                }else{
                                        $newdata = (object) array( "name" => $value->name, "value" => $value->value, "expires"=>$value->maxAge,"path"=>$value->path,"secure"=>$value->secure);
                                        $cookieData = (object) array( "data" => $newdata);
                                        setcookie( "$value->name", json_encode( $cookieData ), $value->maxAge , "$value->path",'',$value->secure);
                                }
                        }
                }

                
        }





}