예제 #1
0
function getFeed()
{
    /*
    Types of alerts:
    RSS Library: http://www.nws.noaa.gov/rss/
    	Severe Weather:
    		-Watch/Warnings/Advisories: http://alerts.weather.gov/cap/us.php?x=1
    */
    $acceptedTypes = array("FloodWarning", "FloodAdvisory", "FlashFloodWatch", "SpecialWeatherStatement", "SevereThunderstormWarning", "TornadoWarning");
    $url = "http://alerts.weather.gov/cap/us.php?x=1";
    $rawxml = curlPage($url);
    $xml = new SimpleXMLElement($rawxml);
    http:
    //alerts.weather.gov/cap/wwacapget.php?x=AL1253B4A2F0D4.HeatAdvisory.1253B4AFB6C0AL.MOBNPWMOB.37dd2dbeec77dcbd81e72718a99b8b2f
    // ALL ENTRIES:
    //$entry = $xml->xpath("/*/*[local-name()='entry']/*[local-name()='id']/text()");
    // MOST RECENT 10:
    $entry = $xml->xpath("/*/*[local-name()='entry'][position() >= 0 and position() < 12]/*[local-name()='id']/text()");
    $newxml = new SimpleXMLElement('<xml/>');
    foreach ($entry as $id) {
        $type = substr($id, 61, -58);
        $link = $id;
        if (in_array($type, $acceptedTypes)) {
            $xmlitem = $newxml->addChild('entry');
            $xmlitem->addChild('type', "" . $type . "");
            $xmlitem->addChild('link', "" . $link . "");
            //echo $link."<br />";
        }
    }
    Header('Content-type: text/xml');
    print $newxml->asXML();
}
예제 #2
0
파일: home.php 프로젝트: sweldon/stormplot
function getRecentAlerts()
{
    $html = curlPage("http://alerts.weather.gov/cap/us.php?x=1");
    $xml = new SimpleXMLElement($html);
    $test = $xml->xpath("/*/*[local-name()='entry'][1]");
    $mostrecent = (string) $test[0]->id;
    //print_r($mostrecent);
    return $mostrecent;
}
예제 #3
0
function getArea($alert)
{
    $html = curlPage($alert);
    $xml = new SimpleXMLElement($html);
    #print_r($xml);
    // IDEA: RETURN WHOLE XML AND PARSE WITH JAVASCRIPT
    //FIRST 2 DIGITS OF <geocode> GIVE STATE
    $geocode = $xml->xpath("/*/*/*/*[local-name()='geocode'][last()]/text()");
    $stateString = $geocode[0];
    $state = (string) $stateString->value;
    $state = substr($state, 0, 2);
    $areaDesc = $xml->xpath("/*/*/*/*[local-name()='areaDesc']/text()");
    $areaString = (string) $areaDesc[0];
    if (strpos($areaString, ";") !== false) {
        $areas = explode(";", $areaString);
        //RIGHT NOW ONLY USES 1 OF THE LISTED COUNTIES
        $county = $areas[0] . ", " . $state;
    } else {
        $county = $areaString . ", " . $state;
    }
    return $county;
}
예제 #4
0
function locateIP($ip)
{
    $html = curlPage("http://freegeoip.net/xml/" . $ip);
    $xml = new SimpleXMLElement($html);
    $lat = $xml->xpath('/*');
    $latVal = (string) $lat[0]->Latitude;
    $lngVal = (string) $lat[0]->Longitude;
    return [$latVal, $lngVal];
}
예제 #5
0
/* Назначение: Получение рабочих прокси серверов по списку URl сайтов с прокси-листами. Проверка прокси многопоточная.
 * Автор:         phpdreamer
 * Дата:           14.05.2010
*/
set_time_limit(0);

$filename = 'sitesproxy.txt'; //файл с списком URL сайтов с прокси листами

$n = 15; //количество потоков при проверке проксей
$regular = '#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{2,5}#'; 
$ban = array();
$proxy = array();
foreach(file($filename) as $url)
{
	$url = trim($url);
	$page = curlPage($url);
	preg_match_all($regular,$page,$p);
	//если на сайте нет проксей, заносим его в бан - там наверно есть защита от парсинга на javascript'е
	if(!count($p[0]))
		$ban[] = $url ;
	else
		$proxy = $proxy +$p[0];
}
$proxies = array_values( array_unique($proxy) );
$countProxy = count ($proxies);
if($countProxy<=$n)
{
	chk($proxies);
}
else
{