This is to write to a friend of the script, is to do the CDN aspect, often meet the attack, but can not meet the attack on the domain name to block, we can have a choice to judge.
This is the PHP value Alexa is worth:
Copy Code code as follows:
<?php
$yuming = $argv [1];
Get Alaxe Rankings
function Getalexarank ($domain = www.jb51.net)
{
$line = "";
$data = "";
$url = "http://data.alexa.com/data/?cli=10&dat=snba&ver=7.0&url=". $domain;
$fp = fopen ($url, "R");
if ($FP)
{
while (!feof ($FP))
{
$line = fgets ($FP);
$data. = $line;
}
$p = Xml_parser_create ();
Xml_parse_into_struct ($p, $data, $vals);
Xml_parser_free ($p);
for ($i = 0; $i <count ($vals); $i + +)
{
if ($vals [$i] ["tag"]== "popularity")
{
return $vals [$i] ["Attributes"] ["TEXT"];
}
}
}
}
echo Getalexarank ($yuming);
?>
This is used to take the PV value.
Copy Code code as follows:
<?php
//
Parameter passing the specified address
//
if (Empty ($argv [1])) {
Die (' parameter error ');
}else{
$domain = $argv [1];
}
//
Curl Request
//
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://alexa.cn/api0523.php"); //?
curl_setopt ($ch, Curlopt_post, 1);
$data [' url '] = $domain;
$data [' sig '] = ' D665053D27996BC7C72EFF5F70D4FACC ';
$data [' keyt '] = ' 1350970374 ';
curl_setopt ($ch, Curlopt_cookie, ' checkdom= '. $domain);
curl_setopt ($ch, Curlopt_postfields, $data);
curl_setopt ($ch, Curlopt_returntransfer, 1);
$resp = curl_exec ($ch);
Curl_close ($ch);
$array _div = Explode (' * ', $RESP);
$c = count ($array _div);
//
Parse output
//
for ($i =0; $i < $c; $i + +) {
if ($i = = | | $i = = | | $i ==14) {
$m = $i + 1;
if ($array _div[$i]!= "-") {
$as = Intval (Str_replace (', ', ', $array _div[$i]));
$ax = Intval (Str_replace (', ', ', $array _div[$m]));
echo $as *3000* $ax;
echo "\ n";
}else{
echo "-"; echo "\ n";
}
}
}
Make Shell judgments:
Copy Code code as follows:
#!/bin/bash
Digstatus= ' Dig $ ns|grep in.*ns.*.$|grep-e ns1.appleidc.com|ns2.appleidc.com ' |wc-l '
[$digstatus-eq 0] && exit
paiming= ' php alexa $ '
If [$paiming-lt 1000]
Then
Echo High
Else
Echo No high
Fi
pv= ' PHP PV $ '
echo "PV num is $PV"
After judging, what to do, we can write their own. Friend there is to execute a post form, in the database the domain name plus a state value.