Index: trunk/wap/hawpedia.php |
— | — | @@ -202,6 +202,7 @@ |
203 | 203 | curl_setopt($ch, CURLOPT_URL, $url); |
204 | 204 | curl_setopt($ch, CURLOPT_HEADER, 0); |
205 | 205 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 206 | + curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT); |
206 | 207 | |
207 | 208 | // WP otherwise says: "Please provide a User-Agent header" |
208 | 209 | curl_setopt($ch, CURLOPT_USERAGENT, "hawpedia"); |
— | — | @@ -245,6 +246,7 @@ |
246 | 247 | curl_setopt($ch, CURLOPT_NOBODY, TRUE); |
247 | 248 | curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); |
248 | 249 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 250 | + curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT ); |
249 | 251 | curl_exec($ch); |
250 | 252 | $status = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); |
251 | 253 | curl_close($ch); |
— | — | @@ -273,6 +275,7 @@ |
274 | 276 | curl_setopt($ch, CURLOPT_URL, $url); |
275 | 277 | curl_setopt($ch, CURLOPT_HEADER, 0); |
276 | 278 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 279 | + curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT); |
277 | 280 | $curlResultString = curl_exec($ch); |
278 | 281 | if (!is_string($curlResultString)) |
279 | 282 | hawpedia_error(hawtra("Wikipedia currently not available")); // exits internally |
Index: trunk/wap/image.php |
— | — | @@ -3,6 +3,8 @@ |
4 | 4 | # echo($_SERVER['QUERY_STRING']); |
5 | 5 | # echo($_SERVER['HTTP_ACCEPT']); |
6 | 6 | |
| 7 | +require( dirname( __FILE__ ) . "/config.php" ); |
| 8 | + |
7 | 9 | function fatalError($msg) { |
8 | 10 | header("HTTP/1.0 500 Internal Server Error"); |
9 | 11 | echo "$msg\n"; |
— | — | @@ -41,6 +43,7 @@ |
42 | 44 | curl_setopt($ch, CURLOPT_URL, $url); |
43 | 45 | curl_setopt($ch, CURLOPT_HEADER, 0); |
44 | 46 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 47 | + curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT); |
45 | 48 | |
46 | 49 | // WP otherwise says: "Please provide a User-Agent header" |
47 | 50 | curl_setopt($ch, CURLOPT_USERAGENT, "hawpedia"); |
Index: trunk/wap/config.php |
— | — | @@ -23,6 +23,9 @@ |
24 | 24 | define("SEGLENGTH_HTML", 2000); |
25 | 25 | define("SEGLENGTH_VXML", 10000000); |
26 | 26 | |
| 27 | +// Timeout for HTTP fetches, in seconds |
| 28 | +define("HAWPEDIA_TIMEOUT", 5 ); |
| 29 | + |
27 | 30 | // comment out next line to disable vxml dispatcher |
28 | 31 | //define("HAWPEDIA_VXML_TMP_FILE", "/tmp/hawpedia_vxml_dispatcher.tmp"); |
29 | 32 | |