<?php
    
// Ragray.net XML Reader 1.2
    //            by Ancyker
    //
    //   License: http://creativecommons.org/licenses/by-sa/3.0/us/
    //
    // You shouldn't have to change any of this unless you want better error handling, 
    //   text formatting is at the very bottom if you want to change that.
    //
    // Follow us on twitter to make sure you keep up to date with the XML Reader
    //
    // Changelog
    //  1.2
    //     "<rapidshare.." tag is now "<premium.."
    //     "Sakray" is now "Renewal"
    //  1.1
    //     Initial version

    
$contents file_get_contents("http://ragray.net/download/xml");
    
$parser xml_parser_create('');
    if(!
$parser) exit();

    
xml_parser_set_option($parserXML_OPTION_TARGET_ENCODING'UTF-8');
    
xml_parser_set_option($parserXML_OPTION_CASE_FOLDING0);
    
xml_parser_set_option($parserXML_OPTION_SKIP_WHITE1);
    
xml_parse_into_struct($parsertrim($contents), $xml_values);
    
xml_parser_free($parser); 

    if (!
$xml_values) exit();

    
$urls = array();

    foreach (
$xml_values as $values) {
        if (
$values["tag"] == "release") {
            
$date $values["attributes"]["date"];
        }
        if ((
$values["tag"] == "rapidshare") || ($values["tag"] == "premium")) {
            
$urls[$date][$values["attributes"]["type"]] = $values["value"];
        }
        if (
$values["tag"] == "torrent") {
            
$urls[$date]['torrent'] = $values["value"];
        }
        if (
$values["tag"] == "jdownloader") {
            
$urls[$date]['jdownloader'] = $values["value"];
        }
    }

    
// Below are some examples on how to use the data gathered above. Uncomment the PRE lines if you want to try the var_dump lines.
    //echo "<PRE>\n";

    // This is the variables as it stands, since the default order in the XML is to display oldest first we have to...
    //var_dump($urls);

    // Put the newest ones first
    
krsort($urls);

    
// This will output the variables as they are now, with newest first
    //var_dump($urls);

    // This figures out the latest version
    
$dates array_keys($urls);
    
$latest $urls[$dates[0]];

    
// This contains only the newest ones
    //var_dump($latest);

    //echo "</PRE>\n";

    
echo "<div style=\"text-align:center;\" class=\"ragray\">\n\t<b>Latest Ragray Download</b><br />\n";
    foreach (
$latest as $part => $url) {
        if (
$url == "" || $url == "NULL") echo "\t".str_replace("part","Part ",$part)." (Uploading...)<br />\n";
        else if (
$part == "jdownloader") echo "\t<a href=\"{$url}\">Download all</a> with <a href=\"http://jdownloader.org/home/index?s=lng_en\">JDownloader</a><br />\n";
        else if (
$part == "torrent") echo "\t<a href=\"{$url}\">BitTorrent</a><br />\n";
        else echo 
"\t<a href=\"{$url}\">FileServe ".str_replace("part","Part ",$part)."</a><br />\n";
    }

// Please do not remove this!
    
echo "\t<a href=\"http://ragray.net/\" style=\"font-size:9px;color:gray;\">Korean Ragnarok Online Renewal Client Installer provided by Ragray.net</a>\n</div>\n";
// Please do not remove this!

?>