View file audio.php

File size: 6.31Kb
<?php
/**************************************
Vk Audio downloader (mini)
Coded by EnoT_PoToSkUn (forum.antichat)
modified by inlanger (towap.info)

Внимание! Данный скрипт представлен
только в целях ознакомления.
Скачивая файлы, вы нарушаете закон об
авторских и смежных правах!
***************************************/
error_reporting(E_ALL);

###############################
//Аккаунт, с которого идёт парсинг
$user['id'] = ''; //ID
$user['mail'] = ''; // Email (Пример: [email protected])
$user['pass'] = ''; //Пароль
$self = 'audio.php';  //Имя скрипта
################################

$mail = str_replace('@', '%40', $user['mail']);
$bg=1;
$cookies = 'remixchk=5; remixmid='.$user['id'].'; remixemail='.$mail.'; remixpass='.md5($user['pass']);
$page = !empty($_GET['page']) && is_numeric($_GET['page']) ? intval($_GET['page']) : '';
$q = !empty($_GET['q']) ? $_GET['q'] : '';
function conn($q, $page){
    global $cookies;
    if(empty($page) || $page <= 1) $page = 0;
    else $page = ($page.'00' - 100);
    $q = 'act=search&q='.urlencode($q).'&add=1&st='.$page;
    $send = 'GET /audio.php?'.$q." HTTP/1.1\r\n";
    $send .= "Host: vkontakte.ru\r\n";
    $send .= "User-Agent: Mozilla/5.0\r\n";
	$send .= "Pragma: no-cache\r\n";
	$send .= 'Cookie: '.$cookies."\r\n";
	$send .= "Connection: Close\r\n\r\n";
	$socket = @fsockopen('vkontakte.ru', 80, $errno, $errstr, 30);
	fputs($socket, $send);
	$line = '';
	while(!feof($socket)){
	  $line .= fgets($socket, 4096);
	}
	eregi('<div class="summary">(.*)<div id="boxHolder">', $line, $matches);
	return stripos($matches[1], 'не найдено') ? false : $matches[1];
}
function pages($str, $page, $q){
	global $self;
	if(preg_match("/<ul class='pageList'>(.+)<li/is", $str)){
       $total = 50; //Сколько выводить страниц
       $page = empty($page) || $page <= 1 || $page > $total ? 1 : $page;
       $back1 = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.($page - 1).'">'.($page - 1).'</a></span>';
       $back2 = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.($page - 2).'">'.($page - 2).'</a></span>';
       $back3 = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.($page - 3).'">'.($page - 3).'</a></span>';
       $forw1 = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.($page + 1).'">'.($page + 1).'</a></span>';
       $forw2 = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.($page + 2).'">'.($page + 2).'</a></span>';
       $forw3 = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.($page + 3).'">'.($page + 3).'</a></span>';
       if(empty($page) || $page <= 1){
          $minus = '';
          $first = '';
       }else{
      	  $minus = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.($page - 1).'" title="Предыдущая">&laquo;</a></span>';
          $first = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page=1" title="Первая страница">&laquo;&laquo;</a></span>';
       }
       if($page == $total){
          $plus = '';
          $last = '';
       }else{
          $plus = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.($page + 1).'" title="Следующая">&raquo;</a></span>';
          $last = '<span class="pages"><a href="'.$self.'?q='.$q.'&amp;page='.$total.'" title="Последняя страница">&raquo;&raquo;</a></span>';
       }
       if(($page + 1) > $total) $forw1 = '';
       if(($page + 2) > $total) $forw2 = '';
       if(($page + 3) > $total) $forw3 = '';
       if(($page - 1) <= 0) $back1 = '';
       if(($page - 2) <= 0) $back2 = '';
       if(($page - 3) <= 0) $back3 = '';
       $all_pages = 'Страницы: '.$first.$minus.$back3.$back2.$back1.'<span class="pages"><b>'.$page.'</b></span>'.$forw1.$forw2.$forw3.$plus.$last;
       return $all_pages;
	}
	else return '';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>вКонтакте audio downloader</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<meta name="Copyright" content="EnoT_PoToSkUn" />
<style><!--
body{
	font-family:Verdana,Tahoma;
	font-size:12px;
	color:black;
}
.bg1
{
background-color: #B5B5B5;
}
.bg2
{
background-color: #E8E8E8;
}
.input{
    padding: 1px;
    font-size: 11px;
    color: black;
    border-bottom: 1px solid #587286;
	border-top: 1px solid #587286;
	border-left: 1px solid #587286;
	border-right: 1px solid #587286;
}
.submit{
    background-color:#bec0c4;
    vertical-align: middle;
    text-align: center;
    width: 60px;
    height: 20px;
    font-size:11px;
    color: black;
}
a:link, a:visited, a:active{
    color: #0066cc;
    text-decoration: none;
}
a:hover, pages:hover{
    color: #0099FF;
    text-decoration:underline;
}
.pages{
	vertical-align: middle;
	letter-spacing: 1pt;
	padding: 1px;
	font-size: 11px;
}
-->
</style>
</head><body>
<img src=img/audio-logo.jpg>
<form action="<?=$self?>" method="get">
<input type="text" class="input" style="height:15px;" name="q" value="<?=$q?>" style="width:200px%;"/>
<input type="submit" class="submit" value="Поиск" /></form><!--created by inlanger. http://towap.info-->
<?php
if($q){
    $conn = conn($q, $page);
    if(!$conn){
      echo '<br />По вашему запросу ничего не найдено<br/>';
    }else{
      preg_match("/Найдено (\d+) (\w+).<\/div>(.+)<div>/iUs", $conn, $all);
      preg_match_all('/<td style="width: 18px; vertical-align:top">(.+)<td style="width: 40px;">/siU', $conn, $music);
      foreach($music[0] as $muz){
        if(($bg==1))
        {
      	echo "<div class=bg".$bg.">";
      	$bg=2;
      	}
      	else
      	{
      	echo "<div class=bg".$bg.">";
      	$bg=1;
      	}
         preg_match('/operate\((\d+)[^0-9]+(\d+)[^0-9]+(\d+)[^0-9a-zA-Z]+([0-9a-zA-Z]+)[^0-9]+(\d+)/', $muz, $arr);
         preg_match('/<b id="performer(\d+)">(.+)<\/b> - <span id="title(\d+)">(.+)<\/span>/i', $muz, $names);
         preg_match('/<div class="duration">(\d{1,2}\:\d{1,2})<\/div>/s',$muz, $time);
         @$get_time = $time[1] ? $time[1].' min&nbsp;': '';
         echo '<b>'.@strip_tags($names[2]).'</b> - '.@strip_tags($names[4]).'<br>'.$get_time.' <a href="http://cs'.$arr[2].'.vkontakte.ru/u'.$arr[3].'/audio/'.$arr[4].'.mp3">Скачать</a></div>';
      }
    }
}
?>
</body></html>