Advertisement
terorama

YandBlogs

Oct 13th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.27 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_GET["rep3"])) {
  4.    send_cap();
  5. }
  6.  
  7. function send_cap() {
  8.  
  9.    $url='http://blogs.yandex.ru/checkcaptcha?rep='.$_GET["rep3"];
  10.  
  11.    $ch = curl_init();
  12.    curl_setopt($ch, CURLOPT_HEADER,1);
  13.    //curl_setopt($ch, CURLOPT_POST,1)
  14.    curl_setopt($ch, CURLOPT_URL, $url);
  15.    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  16.    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
  17.    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)");
  18.  
  19.    $result = curl_exec($ch);
  20.  
  21.    $result = mb_convert_encoding($result,'windows-1251');
  22.  
  23.    echo $result;
  24. }
  25.  
  26. //-------------------------------------------------------
  27. function load_page_alt($url) {
  28.    
  29.    $ch = curl_init();
  30.  
  31.    curl_setopt($ch, CURLOPT_HEADER, 1);
  32.    curl_setopt($ch, CURLOPT_URL, $url);
  33.    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  34.    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  35.    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)");
  36.  
  37.    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  38.  
  39.    $result = curl_exec($ch);
  40.    curl_close($ch);
  41.  
  42.    $ftg = mb_detect_encoding($result);
  43.    echo 'encoding:'.$ftg.'<br/>';
  44.    $result = mb_convert_encoding($result, 'windows-1251', $ftg);
  45.  
  46.    $zzuu = '"'.$_SERVER["PHP_SELF"].'"';
  47.  
  48.    $zzstr = <<<INF
  49.  
  50.    <script type="text/javascript">
  51.       function submuu(f) {
  52.         var zwin =  open ( {$zzuu}+"?rep3="+encodeURIComponent(f.rep3.value));
  53.       }
  54.    </script>
  55.  
  56.    <form action="#" onsubmit="submuu(this);return false;" method="GET">
  57.    <input type="TEXT" name="rep3" />
  58.    <input type="SUBMIT" name="subm3" value="send" />
  59.    </form>
  60.  
  61. INF;
  62.    echo $zzstr;
  63.    
  64.    echo '<pre>'.htmlentities(print_r($result)).'</pre>';
  65.  
  66.    
  67.    
  68. }
  69.  
  70. //-------------------------------------------------------
  71. function load_page($url) {
  72.  
  73.   $opts = array (
  74.             'http' => array(
  75.                 'method'=>'GET',
  76.                 'header'=>''
  77.              ));
  78.  
  79.    $context = stream_context_create($opts);  
  80.  
  81.    $m = get_meta_tags($url);  
  82.    echo '<pre>'.print_r($m,true).'</pre>';
  83.    $s = file_get_contents($url,false, $context);
  84.  
  85.    $s3 = preg_match_all('/<meta[^>]*(name|http-equiv)\s*=\s*"([^">]*?)".*?content=[^"]*?"([^">]*?)"[^>]*>/ims',
  86.     $s, $matches, PREG_SET_ORDER);
  87.  
  88.  
  89.    //echo '<pre>'.htmlentities(print_r($matches,true)).'</pre>';
  90.  
  91.    $teststr = $matches[1][0];
  92.    for ($i=0; $i<strlen($teststr); $i++) {
  93.  
  94.       //echo sprintf (' %s - %d <br>',$teststr{$i}, ord($teststr{$i}));
  95.    }
  96.    
  97.    $metas = array();
  98.    for ($i=0; $i<count($matches); $i++) {
  99.       $metas[$matches[$i][2]]=$matches[$i][3];
  100.    }
  101.    
  102.    $metas = array_change_key_case($metas, CASE_UPPER);
  103.  
  104.    if (array_key_exists('CONTENT-TYPE',$metas))
  105.       if (stripos($metas['CONTENT-TYPE'],'utf')!=-1)
  106.          $s= iconv( 'utf-8','windows-1251', $s);
  107.  
  108.    echo '<pre>'.htmlentities(print_r($metas,true)).'</pre>';
  109.  
  110.    echo $s;
  111.    
  112. }
  113.  
  114.  
  115. //-------------------------------------------------------
  116.    $db = new mysqli('localhost','','','');
  117.  
  118.    if (mysqli_connect_errno()) {
  119.       echo mysql_connect_error();
  120.       exit();
  121.    }
  122.  
  123.    $sql = 'create table words ( id int(11) not null auto_increment,
  124.            word varchar(50), primary key (`id`))';
  125.  
  126.    if (!$db->query($sql)) {
  127.       echo $db->error;
  128.  
  129.       $sql =  'delete from words';
  130.       if (!$db->query($sql)) {
  131.          echo $db->error.'<br>';
  132.       }
  133.    }
  134.  
  135.    $urlbase = 'http://blogs.yandex.ru/search.xml?';
  136.    $qs = http_build_query (array('text'=>'концерт'));
  137.    $url= $urlbase.$qs;
  138.    echo $url;
  139.  
  140.      
  141.  
  142.    $headers =get_headers($url);
  143.  
  144.  
  145.    //-----------------------------------------------
  146.    function zsplit($el) {
  147.      
  148.      
  149.       $z = explode(':',$el);
  150.       $lpart = array_shift($z);
  151.      
  152.       return $lpart;
  153.    }
  154.  //-----------------------------------------------
  155.    function zsplit4($el) {
  156.  
  157.       $z = explode(':',$el);
  158.       $rpart = array_pop($z);
  159.    
  160.  
  161.       return $rpart;
  162.    }
  163. //-----------------------------------------------
  164.  
  165.    $headers3 = array_map('zsplit',$headers);
  166.    $headers4 = array_map('zsplit4',$headers);
  167.    $headers = array_combine($headers3, $headers4);
  168.  
  169.    echo '<pre>'.print_r($headers, true).'</pre>';
  170.  
  171.    load_page_alt($url);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement