| 12694 |
anikendra |
1 |
<?php
|
|
|
2 |
if (!defined('BASEPATH'))
|
|
|
3 |
exit('No direct script access allowed');
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
/*
|
|
|
7 |
* Model for home
|
|
|
8 |
*/
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
Class Oauth_model extends CI_Model {
|
|
|
12 |
|
|
|
13 |
var $url = '';
|
|
|
14 |
var $parser_model;
|
|
|
15 |
var $parser;
|
|
|
16 |
var $current_client;
|
|
|
17 |
|
|
|
18 |
function __construct() {
|
|
|
19 |
|
|
|
20 |
// Call the Model constructor
|
|
|
21 |
parent::__construct();
|
|
|
22 |
//load appropriate parser
|
|
|
23 |
$current_client =$this -> config -> item('current_client');
|
|
|
24 |
$model = $current_client.'_model';
|
|
|
25 |
$this->load->model($model);
|
|
|
26 |
$this->parser = $this-> $model;
|
|
|
27 |
$this->current_client=$this -> config -> item('current_client');
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
function getLogin($get=array(),$post=array(),$module=array())
|
|
|
34 |
{
|
|
|
35 |
$output =array();
|
|
|
36 |
if(isset($module) and !empty($module))
|
|
|
37 |
{
|
|
|
38 |
if(isset($module['header']) and !empty($module['header']))
|
|
|
39 |
{
|
|
|
40 |
foreach($module['header'] as $header)
|
|
|
41 |
{
|
|
|
42 |
$this->curlURL($header,'get');
|
|
|
43 |
|
|
|
44 |
}
|
|
|
45 |
}
|
|
|
46 |
if(isset($module['footer']) and !empty($module['footer']))
|
|
|
47 |
{
|
|
|
48 |
foreach($module['footer'] as $footer)
|
|
|
49 |
{
|
|
|
50 |
|
|
|
51 |
$this->curlURL($footer,'get');
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
if(isset($module['response']) and !empty($module['response']))
|
|
|
55 |
{
|
|
|
56 |
error_log(print_r($module,1));
|
|
|
57 |
foreach($module['response'] as $response)
|
|
|
58 |
{
|
|
|
59 |
if(isset($post) and !empty($post))
|
|
|
60 |
{
|
|
|
61 |
if($this->current_client=='prestashop' || $this->current_client=='magento' )
|
|
|
62 |
$this->curlURL($response,'post',$post);
|
|
|
63 |
else
|
|
|
64 |
$this->curlURL($response,'post',$post);
|
|
|
65 |
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
|
|
|
74 |
//$this->curlURL('products','get',$get);
|
|
|
75 |
$responses = $this->mcurl->execute();
|
|
|
76 |
if(isset($responses) and !empty($responses))
|
|
|
77 |
$responses = $this->parser->parse_response($responses,$module);
|
|
|
78 |
// if(isset($head) && !empty($head)){
|
|
|
79 |
// foreach($head['header'] as $key=>$value){
|
|
|
80 |
// $responses['header'][$key] = $value;
|
|
|
81 |
// }
|
|
|
82 |
// }
|
|
|
83 |
// if(isset($foot) && !empty($foot)){
|
|
|
84 |
// foreach($foot['footer'] as $key=>$value){
|
|
|
85 |
// $responses['footer'][$key] = $value;
|
|
|
86 |
// }
|
|
|
87 |
// }
|
|
|
88 |
return $responses;
|
|
|
89 |
}
|
|
|
90 |
function getSignup($get=array(),$post=array(),$module=array())
|
|
|
91 |
{
|
|
|
92 |
$output =array();
|
|
|
93 |
if(isset($module) and !empty($module))
|
|
|
94 |
{
|
|
|
95 |
if(isset($module['header']) and !empty($module['header']))
|
|
|
96 |
{
|
|
|
97 |
foreach($module['header'] as $header)
|
|
|
98 |
{
|
|
|
99 |
$this->curlURL($header,'get');
|
|
|
100 |
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
if(isset($module['footer']) and !empty($module['footer']))
|
|
|
104 |
{
|
|
|
105 |
foreach($module['footer'] as $footer)
|
|
|
106 |
{
|
|
|
107 |
|
|
|
108 |
$this->curlURL($footer,'get');
|
|
|
109 |
|
|
|
110 |
}
|
|
|
111 |
}
|
|
|
112 |
if(isset($module['response']) and !empty($module['response']))
|
|
|
113 |
{
|
|
|
114 |
foreach($module['response'] as $response)
|
|
|
115 |
{
|
|
|
116 |
if(isset($post) and !empty($post))
|
|
|
117 |
{
|
|
|
118 |
if($this->current_client=='prestashop' || $this->current_client=='magento' )
|
|
|
119 |
$this->curlURL($response,'post',$post);
|
|
|
120 |
else
|
|
|
121 |
$this->curlURL($response,'post',$post);
|
|
|
122 |
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
|
|
|
131 |
//$this->curlURL('products','get',$get);
|
|
|
132 |
$responses = $this->mcurl->execute();
|
|
|
133 |
if(isset($responses) and !empty($responses))
|
|
|
134 |
$responses = $this->parser->parse_response($responses,$module);
|
|
|
135 |
// if(isset($head) && !empty($head)){
|
|
|
136 |
// foreach($head['header'] as $key=>$value){
|
|
|
137 |
// $responses['header'][$key] = $value;
|
|
|
138 |
// }
|
|
|
139 |
// }
|
|
|
140 |
// if(isset($foot) && !empty($foot)){
|
|
|
141 |
// foreach($foot['footer'] as $key=>$value){
|
|
|
142 |
// $responses['footer'][$key] = $value;
|
|
|
143 |
// }
|
|
|
144 |
// }
|
|
|
145 |
return $responses;
|
|
|
146 |
}
|
|
|
147 |
function curlURL($configurl=null,$methodtype='get',$parameter=array())
|
|
|
148 |
{
|
|
|
149 |
|
|
|
150 |
$params ='';
|
|
|
151 |
$display='';
|
|
|
152 |
$url = $this->config->item('curl_base_url');
|
|
|
153 |
$productsurl =$this->config->item($configurl);
|
|
|
154 |
if(isset($productsurl['url']) and !empty($productsurl['url']))
|
|
|
155 |
{
|
|
|
156 |
$url .=$productsurl['url'];
|
|
|
157 |
if($productsurl['display'])
|
|
|
158 |
{$display=$productsurl['display'];}
|
|
|
159 |
if(empty($parameter)){$parameter=$productsurl['params'];}
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
if(isset($parameter) and !empty($parameter) and $methodtype=='get')
|
|
|
163 |
{
|
|
|
164 |
$params = $this->parser->prepareParams($parameter,$display,$configurl);
|
|
|
165 |
|
|
|
166 |
}
|
|
|
167 |
if(isset($parameter) and !empty($parameter) and $methodtype=='post')
|
|
|
168 |
{
|
|
|
169 |
$params = $this->parser->prepareParams($parameter,$display,$configurl);
|
|
|
170 |
$methodtype ='post';
|
|
|
171 |
}
|
|
|
172 |
if(!isset($parameter) || empty($parameter))
|
|
|
173 |
{$params =$this->parser->prepareParams('',$display,$configurl);}
|
|
|
174 |
//$methodtype = 'post';
|
|
|
175 |
return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
|
|
|
176 |
}
|
|
|
177 |
else
|
|
|
178 |
{return '';}
|
|
|
179 |
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
}
|