Exemplo n.º 1
0
function get_rss_news($feed_url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $feed_url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5000);
    $data = curl_exec($ch);
    curl_close($ch);
    //define class
    $pxml = new ParseXML();
    //parse xml array data
    $xml_array = $pxml->GetXMLTree($data);
    //define variable for array data
    $array_news = $xml_array;
    return $array_news;
}
function parseXML($data, $lastDownloadSeason = NULL, $lastDownloadEpisode = NULL)
{
    $ParseXML = new ParseXML();
    //Init the ParseXML class
    $xmlarray = $ParseXML->GetXMLTree($data);
    //Parse the XML passed through to $data
    $result = false;
    $xmlURL = $xmlarray['RSS'][0]['CHANNEL'][0]['LINK'][0]['VALUE'];
    //Get the URL from the RSS file
    $parsedURL = parse_url($xmlURL);
    parse_str($parsedURL['query'], $parsedQuery);
    $showName = $parsedQuery['show_name'];
    $epguide = fetchURLContents("http://epguides.com/" . str_replace(" ", "", $showName) . "/");
    $epguide = explode("\n", $epguide);
    $itemsInFeed = count($xmlarray['RSS'][0]['CHANNEL'][0]['ITEM']);
    $entryNumber = 0;
    $endwhile = true;
    while ($entryNumber < $itemsInFeed && $endwhile) {
        $url = $xmlarray['RSS'][0]['CHANNEL'][0]['ITEM'][$entryNumber]['ENCLOSURE'][0]['ATTRIBUTES']['URL'];
        $pubDate = $xmlarray['RSS'][0]['CHANNEL'][0]['ITEM'][$entryNumber]['PUBDATE'][0]['VALUE'];
        $description = explode(';', $xmlarray['RSS'][0]['CHANNEL'][0]['ITEM'][$entryNumber]['DESCRIPTION'][0]['VALUE']);
        $showTitle = explode(': ', $description[1]);
        $showTitle = $showTitle[1];
        $season = explode(': ', $description[2]);
        $season = $season[1];
        if (!isset($lastDownloadSeason) || !is_numeric($lastDownloadSeason) || !is_numeric($lastDownloadEpisode)) {
            $lastDownloadSeason = $season;
            $lastDownloadEpisode = "00";
        }
        $episode = explode(': ', $description[3]);
        $episode = $episode[1];
        if (strlen($episode) < 2) {
            $episodeSpaced = " " . $episode;
        } else {
            $episodeSpaced = $episode;
        }
        if ($showTitle === NULL || ($showTitle = "n/a")) {
            $showTitle = array_keys(preg_grep("/{$season}-{$episodeSpaced}/i", $epguide));
            $showTitle = $epguide[$showTitle[0]];
            $showTitle = explode(">", $showTitle);
            $showTitle = explode("<", $showTitle[1]);
            $showTitle = $showTitle[0];
        }
        $seasonPadded = $season;
        $episodePadded = $episode;
        if (strlen($season) < 2) {
            $seasonPadded = "0" . $season;
        }
        if (strlen($episode) < 2) {
            $episodePadded = "0" . $episode;
        }
        if ($seasonPadded <= $lastDownloadSeason && $episodePadded <= $lastDownloadEpisode) {
            $endwhile = false;
        }
        if ($season == $lastDownloadSeason && $endwhile == true) {
            $result[$entryNumber]['url'] = $url;
            $result[$entryNumber]['showName'] = $showName;
            $result[$entryNumber]['season'] = $season;
            $result[$entryNumber]['episode'] = $episode;
            if (strlen($season) < 2) {
                $result[$entryNumber]['season'] = "0" . $season;
            }
            if (strlen($episode) < 2) {
                $result[$entryNumber]['episode'] = "0" . $episode;
            }
            $result[$entryNumber]['showTitle'] = $showTitle;
        }
        //echo $showName." - ".$season.$episode." - ".$showTitle."\n";
        $entryNumber++;
    }
    //print_r($xmlarray);
    return $result;
}
Exemplo n.º 3
0
<?
require_once('includes/config.php');
$ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'http://www.viethconsulting.com/members/mem_xml/'.$org_id.'_business_cats.xml');
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
            $data = array('org_code' => $org_id,
            'username' => $username,
            'password' => $password
            );
        $data = curl_exec($ch);
        curl_close($ch);  
        //define class 
        $pxml = new ParseXML;
        //parse xml array data
        $xml_array = $pxml->GetXMLTree($data);
        //define variable for array data
        $array_new=$xml_array;
?>
function parseXML($data)
{
    $ParseXML = new ParseXML();
    $xmlarray = $ParseXML->GetXMLTree($data);
    $latestFile = count($xmlarray['PSYN'][0]['PROJECT'][0]['FILES'][0]['FILE']) - 1;
    $addonName = $xmlarray['PSYN'][0]['PROJECT'][0]['NAME'][0]['VALUE'];
    $addonURL = $xmlarray['PSYN'][0]['PROJECT'][0]['URL'][0]['VALUE'];
    $currentDownloadID = $xmlarray['PSYN'][0]['PROJECT'][0]['FILES'][0]['FILE'][$latestFile]['ATTRIBUTES']['ID'];
    $currentVersion = $xmlarray['PSYN'][0]['PROJECT'][0]['FILES'][0]['FILE'][$latestFile]['NAME'][0]['VALUE'];
    $zipURL = $xmlarray['PSYN'][0]['PROJECT'][0]['FILES'][0]['FILE'][$latestFile]['URL'][0]['VALUE'];
    $result = array($addonName, $addonURL, $currentDownloadID, $currentVersion, $zipURL);
    return $result;
}