Subversion Repositories SmartDukaan

Rev

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

Rev 11109 Rev 11170
Line 42... Line 42...
42
	}
42
	}
43
 
43
 
44
	// method to add curl requests to the multi request queue
44
	// method to add curl requests to the multi request queue
45
	function add_call($key=null, $method, $url, $params = array(), $options = array())
45
	function add_call($key=null, $method, $url, $params = array(), $options = array())
46
	{
46
	{
-
 
47
		//echo 'hello';
47
		if (is_null($key))
48
		if (is_null($key))
48
		{
49
		{
49
			$key = count($this->calls);
50
			$key = count($this->calls);
50
		}
51
		}
51
		
52
		
Line 126... Line 127...
126
	}
127
	}
127
 
128
 
128
	// run the calls in the curl requests in $this->calls
129
	// run the calls in the curl requests in $this->calls
129
	function execute()
130
	function execute()
130
	{
131
	{
-
 
132
		if (count($this->calls) <= 0)
-
 
133
			return False;
131
		if (count($this->calls))
134
		if (count($this->calls))
132
		{
135
		{
133
			// kick off the requests
136
			// kick off the requests
134
			do
137
			do
135
			{
138
			{
-
 
139
				//print_r($this->calls);
136
				$multi_exec_handle = curl_multi_exec($this->curl_parent,$active);
140
				$multi_exec_handle = curl_multi_exec($this->curl_parent,$active);
137
			} while ($active>0);
141
			} while ($active>0);
138
 
142
 
139
			// after all requests finish, set errors and repsonses in $this->calls
143
			// after all requests finish, set errors and repsonses in $this->calls
140
			foreach ($this->calls as $key => $call)
144
			foreach ($this->calls as $key => $call)
Line 150... Line 154...
150
					//redirect(base_url().'error_page/index');
154
					//redirect(base_url().'error_page/index');
151
					//exit();
155
					//exit();
152
					}
156
					}
153
				}
157
				}
154
				$this->calls[$key]["response"] = curl_multi_getcontent($this->calls[$key]["curl"]);
158
				$this->calls[$key]["response"] = curl_multi_getcontent($this->calls[$key]["curl"]);
155
				//print_r($this->calls[$key]['response']);
159
				//print_r($this->calls[$key]["response"]);
156
				$http_status = curl_getinfo($this->calls[$key]["curl"], CURLINFO_HTTP_CODE);
160
				$http_status = curl_getinfo($this->calls[$key]["curl"], CURLINFO_HTTP_CODE);
157
				if($key != 'recommended_accessories'){
161
				if($key != 'tracking'){
158
					if($http_status != 200) {
162
					if($http_status != 200) {
159
        				redirect(base_url().'error_page/index');
163
        				redirect(base_url().'error_page/index');
160
        				exit();
164
        				exit();
161
					}
165
					}
162
				}
166
				}
163
				curl_multi_remove_handle($this->curl_parent,$this->calls[$key]["curl"]);
167
				curl_multi_remove_handle($this->curl_parent,$this->calls[$key]["curl"]);
164
				// if($key != 'recommended_accessories'){
-
 
165
				// if(isset($this->calls[$key]["response"]) && !empty($this->calls[$key]["response"])){
-
 
166
				// 	curl_multi_remove_handle($this->curl_parent,$this->calls[$key]["curl"]);	
-
 
167
				// }else{
-
 
168
				// 	$this->calls[$key]["error"] = $error;
-
 
169
				// 	$errmsg ='<h3>OH SNAP!!!! :</h3><p>Something is not right. <br/><h1>But Relax</h1> <br/>We are working hard on it. </p>';
-
 
170
				// 	//$this->write_log_send_mail('error',$msg);
-
 
171
				// 	//$this->session->set_flashdata('errormsg',$errmsg);
-
 
172
				// 	redirect(base_url().'error_page/index',$data);
-
 
173
				// 	exit();
-
 
174
				// }
-
 
175
				// }
-
 
176
			}
168
			}
177
 
169
 
178
			curl_multi_close($this->curl_parent);
170
			curl_multi_close($this->curl_parent);
179
		}
171
		}
180
		//print_r($this->calls);
172
		//print_r($this->calls);