Arkiv

Arkiv för ‘PHP’ Kategori

Lista över WHOIS för några toppdomäner

september 25th, 2009 John Pålsson Inga kommentarer

Någon frågade efter andra whois adresser för andra toppdomäner.

<?php
$ext = array(
'.com' => array('whois.crsnic.net','No match for'),
'.net' => array('whois.crsnic.net','No match for'),
'.biz' => array('whois.biz','Not found'),
'.mobi' => array('whois.dotmobiregistry.net', 'NOT FOUND'),
'.tv' => array('whois.nic.tv', 'No match for'),
'.in' => array('whois.inregistry.net', 'NOT FOUND'),
'.info' => array('whois.afilias.net','NOT FOUND'),
'.co.uk' => array('whois.nic.uk','No match'),
'.co.ug' => array('wawa.eahd.or.ug','No entries found'),
'.or.ug' => array('wawa.eahd.or.ug','No entries found'),
'.nl' => array('whois.domain-registry.nl','not a registered domain'),
'.ro' => array('whois.rotld.ro','No entries found for the selected'),
'.com.au' => array('whois.ausregistry.net.au','No data Found'),
'.ca' => array('whois.cira.ca', 'AVAIL'),
'.org.uk' => array('whois.nic.uk','No match'),
'.name' => array('whois.nic.name','No match'),
'.us' => array('whois.nic.us','Not Found'),
'.ac.ug' => array('wawa.eahd.or.ug','No entries found'),
'.ne.ug' => array('wawa.eahd.or.ug','No entries found'),
'.sc.ug' => array('wawa.eahd.or.ug','No entries found'),
'.ws' => array('whois.website.ws','No Match'),
'.be' => array('whois.ripe.net','No entries'),
'.com.cn' => array('whois.cnnic.cn','no matching record'),
'.net.cn' => array('whois.cnnic.cn','no matching record'),
'.org.cn' => array('whois.cnnic.cn','no matching record'),
'.no' => array('whois.norid.no','no matches'),
'.se' => array('whois.iis.se','Not Found'),
'.nu' => array('whois.nic.nu','NO MATCH for'),
'.com.tw' => array('whois.twnic.net','No such Domain Name'),
'.net.tw' => array('whois.twnic.net','No such Domain Name'),
'.org.tw' => array('whois.twnic.net','No such Domain Name'),
'.cc' => array('whois.nic.cc','No match'),
'.nl' => array('whois.domain-registry.nl','is free'),
'.pl' => array('whois.dns.pl','No information about'),
'.pt' => array('whois.dns.pt','No match')
);
?>
Categories: Domäner, PHP Taggar:

Hämta Alexa Ranking Med PHP Samt Domän Information

augusti 12th, 2009 John Pålsson 2 kommentarer

EDIT Fredrik Nas kommentera precis angående Alexa ranking, som han skriver så kostar det att hämta ut information från Alexa vilket jag inte hade någon aning om.

http://aws.amazon.com/awis/

Tack Fredrik

Satt och lekte lite idag mest för att kolla hur saker och ting fungerar för framtida projekt.

Det första är hur man hämtar utt alexa ranking med php vilket var väldigt enkelt som allt annat i PHP :) .

function getAlexaRank($url)
{
     $url = ‘http://data.alexa.com/data?cli=10&dat=s&url=’.$url;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_URL, $url);
     $html = curl_exec($ch);
     curl_close($ch);
     preg_match(‘/<POPULARITY URL=”(.*?)” TEXT=”([0-9]+){1,}”\/>/’, $html, $matches);
     $value = ($matches[2]) ? number_format($matches[2]) : 0;
     return $value;
}

 

Det andra jag satt o lekte med var hur man hämtar ut information om en domän så som expire date, registrerings datum och så vidare.

$urlToFetch = 'wn.se';

$sock = fsockopen("whois.nic-se.se", 43) or die('Error Connecting To Server:');

fputs($sock, "$urlToFetch\r\n");while( !feof($sock) )
{
      $buffer .= fgets($sock,128);
}

fclose($sock);

preg_match("/state: (.+)/", $buffer, $state);
preg_match("/holder: (.+)/", $buffer, $holder);
preg_match("/admin-c: (.+)/", $buffer, $admin);
preg_match("/tech-c: (.+)/", $buffer, $tech);
preg_match("/billing-c: (.+)/", $buffer, $billing);
preg_match_all("/nserver: (.+)/", $buffer, $nserver);
preg_match("/dnssec: (.+)/", $buffer, $dnssec);
preg_match("/status: (.+)/", $buffer, $status);
preg_match("/created: ([0-9-]+)/", $buffer, $created);
preg_match("/modified: ([0-9-]+)/", $buffer, $modified);
preg_match("/expires: ([0-9-]+)/", $buffer, $expires);
preg_match("/registrar: (.+)/", $buffer, $registrar);

echo 'State: ' . $state[1] . '<br />';
echo 'Holder: ' . $holder[1] . '<br />';
echo 'Admin-c: ' . $admin[1] . '<br />';
echo 'Tech-c: ' . $tech[1] . '<br />';
echo 'Billing-c: ' . $billing[1] . '<br />';
echo 'DNSsec: ' . $dnssec[1] . '<br />';

$count = 1;
foreach($nserver[1] as $value)
{
     echo "NS$count: " . $value . '<br />';
     $count++;
}

echo 'Created: ' . $created[1] . '<br />';
echo 'Modified: ' . $modified[1] . '<br />';
echo 'Expires: ' . $expires[1] . '<br />';
echo 'Registrar: ' . $registrar[1] . '<br />';
echo 'Status: ' . $status[1] . '<br />';

Kanske blir användbart för någon annan?

Categories: PHP, Projekt Taggar:

Google Väder API Med PHP

augusti 1st, 2009 John Pålsson 1 kommentar

Tänkte tipsa er om Google Väder API som är mycket enkelt att använda, slängde ihop lite kod i PHP som plockar ut nuvarande prognos.

$url = <a href="http://www.google.se/ig/api?weather=paris">http://www.google.se/ig/api?weather=paris</a>;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$html = curl_exec($ch);
curl_close($ch);

$xml = new SimpleXMLElement(utf8_encode($html));
$return_array = array();

$weather_array['prognos_info']['city'] = $xml->weather->forecast_information->city['data'];
$weather_array['prognos_info']['zip'] = $xml->weather->forecast_information->postal_code['data'];
$weather_array['prognos_info']['date'] = $xml->weather->forecast_information->forecast_date['data'];
$weather_array['prognos_info']['date_time'] = $xml->weather->forecast_information->current_date_time['data'];
$weather_array['current_cond']['condition'] = $xml->weather->current_conditions->condition['data'];
$weather_array['current_cond']['temp_f'] = $xml->weather->current_conditions->temp_f['data'];
$weather_array['current_cond']['temp_c'] = $xml->weather->current_conditions->temp_c['data'];
$weather_array['current_cond']['humidity'] = $xml->weather->current_conditions->humidity['data'];
$weather_array['current_cond']['icon'] = 'http://www.google.com' . $xml->weather->current_conditions->icon['data'];
$weather_array['current_cond']['wind'] = $xml->weather->current_conditions->wind_condition['data'];
 

Nu när man håller på med resedomäner så är det alltid användbart

Categories: PHP Taggar: