[iOS] <select> picker value committed to incorrect element after programmatic focus...
[WebKit-https.git] / Websites / perf.webkit.org / public / admin / fetch-from-remote.php
1 <?php
2
3 require('../include/db.php');
4
5 function main($path)
6 {
7     $remote_server = config('remoteServer');
8
9     $remote_url = $remote_server['url'] . $path;
10     $cache_path = config_path('cacheDirectory', hash("sha256", $remote_url));
11
12     $content = @file_get_contents($cache_path);
13     if ($content === FALSE) {
14         $content = fetch_remote($remote_server, $remote_url);
15         if ($content === FALSE) {
16             header('HTTP/1.0 404 Not Found');
17             echo 'NotFound';
18             exit(1);
19         }
20         file_put_contents($cache_path, $content);
21     }
22
23     header('Content-Type: application/json');
24     header('Content-Length: ' . strlen($content));
25     echo $content;
26 }
27
28 function fetch_remote($remote_server, $remote_url)
29 {
30     $auth = array_get($remote_server, 'basicAuth');
31
32     $header = '';
33     if ($auth)
34         $header = 'Authorization: Basic ' . base64_encode($auth['username'] . ':' . $auth['password']);
35
36     $channel = curl_init();
37     curl_setopt($channel, CURLOPT_URL, $remote_url);
38     if ($auth) {
39         curl_setopt($channel, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
40         curl_setopt($channel, CURLOPT_USERPWD, $auth['username'] . ':' . $auth['password']);
41     }
42     curl_setopt($channel, CURLOPT_HEADER, FALSE);
43     curl_setopt($channel, CURLOPT_RETURNTRANSFER, TRUE);
44     $content = curl_exec($channel);
45     curl_close($channel);
46
47     return $content;
48 }
49
50 main(array_get($_SERVER, 'REQUEST_URI', ''));
51
52 ?>