Total Complexity | 9 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
4 | class Remote |
||
5 | { |
||
6 | public function getFileContents($filename) |
||
7 | { |
||
8 | if (ini_get('allow_url_fopen') && extension_loaded('openssl')) { |
||
9 | |||
10 | return $this->getFileContFopen($filename); |
||
11 | |||
12 | } elseif (extension_loaded('curl')) { |
||
13 | |||
14 | return $this->getFileContCurl($filename); |
||
15 | |||
16 | } else { |
||
17 | |||
18 | return false; |
||
19 | |||
20 | } |
||
21 | } |
||
22 | |||
23 | public function getFileContFopen($filename) |
||
24 | { |
||
25 | $scheme = $this->getUriScheme($filename); |
||
26 | $context = stream_context_create(array($scheme => array('header' => 'Connection: close\r\n'))); |
||
27 | return file_get_contents($filename, false, $context); |
||
28 | } |
||
29 | |||
30 | public function getUriScheme($filename) |
||
31 | { |
||
32 | if (substr($filename, 0, 6) == 'https:') { |
||
33 | |||
34 | return 'https'; |
||
35 | |||
36 | } elseif (substr($filename, 0, 5) == 'http:') { |
||
37 | |||
38 | return 'http'; |
||
39 | |||
40 | } else { |
||
41 | |||
42 | return false; |
||
43 | |||
44 | } |
||
45 | } |
||
46 | |||
47 | public function getFileContCurl($filename) |
||
57 | } |
||
58 | } |
||
59 |