Ejemplo n.º 1
0
    if ('https' == substr($uri, 0, 5)) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $uri);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $response = curl_exec($ch);
        curl_close($ch);
        $json = json_decode($response, true);
    } else {
        session_start();
        $opts = array('http' => array('header' => 'Cookie: ' . $_SERVER['HTTP_COOKIE'] . "\r\n"));
        // Send cookies for session_start of target
        $context = stream_context_create($opts);
        session_write_close();
        $json = json_decode(json_clean_line_breaks(file_get_contents($uri, false, $context)), true);
    }
    $xml = jsonToXML($json);
    $xml = stripInvalidXml($xml);
} else {
    $xml = file_get_contents($uri);
}
if (false === $xml) {
    echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"></rdf:RDF>';
    exit;
}
if (empty($xsl)) {
    echo $xml;
    exit;
}
$is_html = false !== stripos(substr(trim($xml), 0, 200), '<html') ? true : false;
Ejemplo n.º 2
0
            }
            $return .= '<![CDATA[' . trim($value) . ']]>';
        }
        $return .= '</' . $field . '>';
    }
    return $return;
}
function json_clean_line_breaks($str)
{
    $str = str_replace("\r\n", "\n", $str);
    $str = str_replace("\r", "\n", $str);
    $str = str_replace("\n", "\\n", $str);
    return $str;
}
if ('json' == $format) {
    $json = json_decode(json_clean_line_breaks(file_get_contents($uri)), true);
    $xml = jsonToXML($json);
} else {
    $xml = file_get_contents($uri);
}
if (false === $xml) {
    echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"></rdf:RDF>';
    exit;
}
if (empty($xsl)) {
    echo $xml;
    exit;
}
$is_html = false !== stripos(substr(trim($xml), 0, 200), '<html') ? true : false;
$XML = new DOMDocument();
if ($is_html) {