Subversion Repositories SmartDukaan

Rev

Rev 10802 | Rev 11104 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10802 Rev 11103
Line 102... Line 102...
102
 
102
 
103
			default:
103
			default:
104
				log_message('error', 'Mcurl Class - Provided http method is not supported. Only POST and GET are currently supported.');
104
				log_message('error', 'Mcurl Class - Provided http method is not supported. Only POST and GET are currently supported.');
105
				break;
105
				break;
106
		}
106
		}
107
 
-
 
108
		curl_setopt($this->calls[$key]["curl"], CURLOPT_RETURNTRANSFER, TRUE);
107
		curl_setopt($this->calls[$key]["curl"], CURLOPT_RETURNTRANSFER, TRUE);
109
		curl_setopt($this->calls[$key]["curl"], CURLOPT_FOLLOWLOCATION, TRUE);
108
		curl_setopt($this->calls[$key]["curl"], CURLOPT_FOLLOWLOCATION, TRUE);
-
 
109
		if($key == 'tracking'){
-
 
110
			$cookiesStringToPass="";
-
 
111
			foreach($_COOKIE as $cookie) {
-
 
112
				if ($cookiesStringToPass) {
-
 
113
	     			$cookiesStringToPass  .= ';';
-
 
114
	    		}
-
 
115
	    		if(is_object(json_decode($cookie))){
-
 
116
	    			$cookieInfo = json_decode($cookie);
-
 
117
	    			foreach ($cookieInfo as $info) {
-
 
118
	    				$cookiesStringToPass .= $info->name . '=' . addslashes($info->value);
-
 
119
	    			}
-
 
120
	    		}
-
 
121
			}
-
 
122
			curl_setopt($this->calls[$key]["curl"], CURLOPT_COOKIE, $cookiesStringToPass);
110
 
123
		}
111
		curl_setopt_array($this->calls[$key]["curl"], $options);
124
		curl_setopt_array($this->calls[$key]["curl"], $options);
112
 
-
 
113
		curl_multi_add_handle($this->curl_parent,$this->calls[$key]["curl"]);		 
125
		curl_multi_add_handle($this->curl_parent,$this->calls[$key]["curl"]);		 
114
	}
126
	}
115
 
127
 
116
	// run the calls in the curl requests in $this->calls
128
	// run the calls in the curl requests in $this->calls
117
	function execute()
129
	function execute()
Line 126... Line 138...
126
 
138
 
127
			// after all requests finish, set errors and repsonses in $this->calls
139
			// after all requests finish, set errors and repsonses in $this->calls
128
			foreach ($this->calls as $key => $call)
140
			foreach ($this->calls as $key => $call)
129
			{
141
			{
130
				$error = curl_error($this->calls[$key]["curl"]);
142
				$error = curl_error($this->calls[$key]["curl"]);
131
				//print_r($key);
-
 
132
				//print_r($error);
-
 
133
				if (!empty($error))
143
				if (!empty($error))
134
				{
144
				{
135
					if($key != 'recommended_accessories'){
145
					if($key != 'recommended_accessories'){
136
					$this->calls[$key]["error"] = $error;
146
					$this->calls[$key]["error"] = $error;
137
					$errmsg ='<h3>OH SNAP!!!! :</h3><p>Something is not right. <br/><h1>But Relax</h1> <br/>We are working hard on it. </p>';
147
					$errmsg ='<h3>OH SNAP!!!! :</h3><p>Something is not right. <br/><h1>But Relax</h1> <br/>We are working hard on it. </p>';
Line 140... Line 150...
140
					//redirect(base_url().'error_page/index');
150
					//redirect(base_url().'error_page/index');
141
					//exit();
151
					//exit();
142
					}
152
					}
143
				}
153
				}
144
				$this->calls[$key]["response"] = curl_multi_getcontent($this->calls[$key]["curl"]);
154
				$this->calls[$key]["response"] = curl_multi_getcontent($this->calls[$key]["curl"]);
-
 
155
				//print_r($this->calls[$key]['response']);
145
				$http_status = curl_getinfo($this->calls[$key]["curl"], CURLINFO_HTTP_CODE);
156
				$http_status = curl_getinfo($this->calls[$key]["curl"], CURLINFO_HTTP_CODE);
146
				if($key != 'recommended_accessories'){
157
				if($key != 'recommended_accessories'){
147
					if($http_status != 200) {
158
					if($http_status != 200) {
148
        				redirect(base_url().'error_page/index');
159
        				redirect(base_url().'error_page/index');
149
        				exit();
160
        				exit();
Line 164... Line 175...
164
				// }
175
				// }
165
			}
176
			}
166
 
177
 
167
			curl_multi_close($this->curl_parent);
178
			curl_multi_close($this->curl_parent);
168
		}
179
		}
169
 
-
 
-
 
180
		//print_r($this->calls);
170
		return $this->calls;
181
		return $this->calls;
171
	}
182
	}
172
	
183
	
173
	function debug()
184
	function debug()
174
	{
185
	{