Shell Script Federated PHP script collection website pv and Alexa rank _linux shell

Source: Internet
Author: User
Tags php script

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.