@@ 101-124 (lines=24) @@ | ||
98 | $hdrSize = isset($_SESSION[$sKeyHdrSize]) |
|
99 | ? unserialize($_SESSION[$sKeyHdrSize]) |
|
100 | : 0; |
|
101 | } elseif (preg_match('/^200 OK/', $status)) { |
|
102 | // ok - request new info |
|
103 | $hdrs = array(); //reset the header array for new curl op |
|
104 | $curl = curl_init($serviceUrl); |
|
105 | curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, |
|
106 | CURLOPT_HEADER => true, |
|
107 | CURLOPT_VERBOSE => true, |
|
108 | CURLOPT_TIMEOUT => 5, |
|
109 | CURLOPT_HTTPGET => true, |
|
110 | CURLOPT_USERAGENT => "XOOPS-{$moduleDirName}", |
|
111 | CURLOPT_HTTPHEADER => array('Content-type:application/json'), |
|
112 | CURLOPT_HEADERFUNCTION => 'xoopspartnersHandleHeaderLine') |
|
113 | ); |
|
114 | // execute the session |
|
115 | $curl_response = curl_exec($curl); |
|
116 | // get the header size and finish off the session |
|
117 | $hdrSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); |
|
118 | curl_close($curl); |
|
119 | ||
120 | $hdrEtag = xoopspartnersGetHeaderFromArray('Etag: ', $hdrs); |
|
121 | $_SESSION[$sKeyEtag] = serialize(base64_encode($hdrEtag)); |
|
122 | $_SESSION[$sKeyHdrSize] = serialize((int)$hdrSize); |
|
123 | $_SESSION[$sKeyResponse] = serialize(base64_encode($curl_response)); |
|
124 | } elseif (preg_match('/^403 Forbidden/', $status)) { |
|
125 | // probably exceeded rate limit |
|
126 | $responseArray = explode('\n', $curl_response); |
|
127 | $msgEle = array_search('message: ', $responseArray); |
|
@@ 149-173 (lines=25) @@ | ||
146 | } |
|
147 | $err = _AM_XOOPSPARTNERS_ISSUES_STATUS_UNKNOWN; |
|
148 | } |
|
149 | } else { |
|
150 | // nothing in session so request new info |
|
151 | $hdrs = array(); |
|
152 | $curl = curl_init($serviceUrl); |
|
153 | curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, |
|
154 | CURLOPT_HEADER => true, |
|
155 | CURLOPT_VERBOSE => true, |
|
156 | CURLOPT_TIMEOUT => 5, |
|
157 | CURLOPT_HTTPGET => true, |
|
158 | CURLOPT_USERAGENT => "XOOPS-{$moduleDirName}", |
|
159 | CURLOPT_HTTPHEADER => array('Content-type:application/json'), |
|
160 | CURLOPT_HEADERFUNCTION => 'xoopspartnersHandleHeaderLine') |
|
161 | ); |
|
162 | // execute the session |
|
163 | $curl_response = curl_exec($curl); |
|
164 | // get the header size and finish off the session |
|
165 | $hdrSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); |
|
166 | curl_close($curl); |
|
167 | ||
168 | $hdrEtag = xoopspartnersGetHeaderFromArray('Etag: ', $hdrs); |
|
169 | $_SESSION[$sKeyEtag] = serialize(base64_encode($hdrEtag)); |
|
170 | $_SESSION[$sKeyHdrSize] = serialize((int)$hdrSize); |
|
171 | $_SESSION[$sKeyResponse] = serialize(base64_encode($curl_response)); |
|
172 | ||
173 | } |
|
174 | $hdr = substr($curl_response, 0, $hdrSize); |
|
175 | $rspSize = strlen($curl_response) - $hdrSize; |
|
176 | $response = substr($curl_response, - $rspSize); |