Example #1
0
 protected function actionProxy($params)
 {
     $feed = $params['feed'];
     if ($feed != '' && strpos($feed, 'http') === 0) {
         header('Content-Type: text/xml');
         if (function_exists('curl_init')) {
             $httpclient = new \GO\Base\Util\HttpClient();
             $xml = $httpclient->request($feed);
         } else {
             if (!\GO\Base\Fs\File::checkPathInput($feed)) {
                 throw new \Exception("Invalid request");
             }
             $xml = @file_get_contents($feed);
         }
         if ($xml) {
             //fix relative images
             preg_match('/(.*:\\/\\/[^\\/]+)\\//', $feed, $matches);
             $baseUrl = $matches[1];
             $xml = str_replace('src="/', 'src="' . $baseUrl . '/', $xml);
             $xml = str_replace('src="/', 'src="' . $baseUrl . '/', $xml);
             $xml = str_replace('href="/', 'href="' . $baseUrl . '/', $xml);
             $xml = str_replace('href="/', 'href="' . $baseUrl . '/', $xml);
             $xml = str_replace('<content:encoded>', '<content>', $xml);
             $xml = str_replace('</content:encoded>', '</content>', $xml);
             $xml = str_replace('</dc:creator>', '</author>', $xml);
             echo str_replace('<dc:creator', '<author', $xml);
         }
     }
 }