~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to api/lib/Net/Proxy.php

Modified back-end directory structure and naming conventions. Now using PEAR's naming convention for classes. Tests should be created in mirror sub-directory within the "tests" folder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
class Net_Proxy {
 
3
    private $url;
 
4
    
 
5
    /**
 
6
     * @param string url Base URL to query
 
7
     */
 
8
    public function __construct($baseURL, $queryString) {
 
9
        $this->url = $baseURL . $queryString;
 
10
    }
 
11
        
 
12
        public function query($curl = false) {
 
13
        
 
14
                if ($curl) {
 
15
                    // Fetch Results
 
16
                    $curl_handle=curl_init();
 
17
                    curl_setopt($curl_handle, CURLOPT_URL, $this->url);
 
18
                    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 30);
 
19
                    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); 
 
20
                
 
21
                    $results = curl_exec($curl_handle);
 
22
                    curl_close($curl_handle);
 
23
            return $results;
 
24
                }
 
25
                else {
 
26
                        return file_get_contents($this->url);
 
27
                }
 
28
        }
 
29
}
 
30
?>
 
 
b'\\ No newline at end of file'