Kod
<?PHP
error_reporting(E_ALL);
@include 'init/php/funkcje_main.php';
$baza = polacz(); //połączenie z bazą danych
$cookie = 'cookie.txt';
$loginUrl = 'http://torrent-polska.info/login.php';
$login = 'xxx';
$password = 'xxx';
$useragent = 'Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3';
$ch = curl_init( $loginUrl );
curl_setopt( $ch, CURLOPT_COOKIEFILE, $cookie );
curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );
curl_setopt( $ch, CURLOPT_COOKIE, $cookie);
curl_setopt( $ch, CURLOPT_USERAGENT, $useragent );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, 'uid='.$login.'&pwd='.$password );
curl_setopt( $ch, CURLOPT_REFERER, 'http://torrent-polska.info' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
$afterLogin = curl_exec($ch);
curl_close($ch);
$kategorie = array('14|7','15|7','17|47','18|47','19|47','22|5','23|6','24|6','25|2','26|100','27|9','28|4','30|19','31|19','32|23','35|15','36|16','37|16','38|16','40|63','41|58','42|55','43|54','44|62','46|24','48|24','55|70','56|72','57|73','60|12','62|11','63|13');
$kategorie = array('14|7');
foreach ($kategorie as $jaka) {
$x = explode('|',$jaka);
echo $x[0].' '.$x[1].'<br/>';
$ch = curl_init('http://torrent-polska.info/torrents.php?category='.$jaka.'');
curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt( $ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt( $ch, CURLOPT_COOKIE, $cookie);
curl_setopt( $ch, CURLOPT_USERAGENT, $useragent );
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_REFERER, 'http://torrent-polska.info/' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
$profile = curl_exec($ch);
curl_close($ch);
//ttuaj jest cała zawartość
$start = strpos($profile,'<div><tr><td class="block" height=20 colspan="2" align="center">');
$profile = substr($profile,$start);
$koniec = strpos($profile,'<TR><TD COLSPAN=2 align=center> <p align="center"><b>');
$zawartosc = substr($profile,0,$koniec);
$początek = strpos($profile,'<div><tr><td class="block" height=20 colspan="2" align="center">');
$koniec = strpos($profile,'<div><tr><td class="block" height=20 colspan="2" align="center">');
preg_match_all('/<div><tr><td class="block" height=20 colspan="2" align="center"><a href=(.+)><b><font color=royalblue>(.+)<\/b><\/font><\/a><\/td><\/tr><div style="padding-left: 6px"><TR>(.+)<p><A HREF=(.+)>Plik torrent<\/A>/Us',$zawartosc,$matches);
preg_match_all('/<p><A HREF=download.php?id=(.+)>Plik torrent<\/A>/Us',$zawartosc,$matches);
//poniżej pętla wyświetlająca pobrane rekordy
for($i=0; $i<count($matches[1]); $i++) {
echo '<img src="http://torrent-polska.info/torrentimg/'.substr($matches[4][$i],16,40).'.jpg" alt="" style="float:left;" />'; //img
echo '<strong>Nazwa: '.$matches[2][$i].'</strong><br/>'; //nazwa pliku
echo 'Link:'.$matches[1][$i].'<br/>'; //link do pliku (bez HTTP)
echo 'Torrent:'.$matches[4][$i].'<br/>'; //link do torrenta
echo '<div style="clear:both;" />';
echo 'TorLin: '.substr($matches[4][$i],
//$plik = $matches[4][$i];
//$jp = 'http://torrent-polska.info/torrentimg/'.substr($matches[4][$i],16,40).'.jpg';
$ch = curl_init('http://torrent-polska.info/'.$plik), //pobieranie torrta
curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie),
curl_setopt( $ch, CURLOPT_COOKIEFILE, $cookie),
curl_setopt( $ch, CURLOPT_COOKIE, $cookie),
curl_setopt( $ch, CURLOPT_USERAGENT, $useragent ),
curl_setopt( $ch, CURLOPT_HEADER, 0),
curl_setopt( $ch, CURLOPT_REFERER, 'http://torrent-polska.info/' ),
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ),
$fh = fopen($plik, 'w'),
curl_setopt($ch, CURLOPT_FILE,$fh),
curl_exec($ch),
fclose($fh),
curl_close($ch),
//poniżej przenoszenie torrta
if (file_exists('torrent/file/'.md5($plik).'.torrent'))
{ echo '<strong>jest przeniesiony</strong>';
unlink($plik);}
else
rename($plik, 'torrent/file/'.md5($plik).'.torrent'),
echo 'plik przeniesiony',
//tutaj pobranie opisu
$ch = curl_init('http://torrent-polska.info/'.$matches[1][$i]), //pobieranie torrta
curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie),
curl_setopt( $ch, CURLOPT_COOKIEFILE, $cookie),
curl_setopt( $ch, CURLOPT_COOKIE, $cookie),
curl_setopt( $ch, CURLOPT_USERAGENT, $useragent ),
curl_setopt( $ch, CURLOPT_HEADER, 0),
curl_setopt( $ch, CURLOPT_REFERER, 'http://torrent-polska.info/' ),
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ),
curl_setopt($ch, CURLOPT_FILE,$fh),
$opis = curl_exec($ch),
curl_close($ch),
$start = strpos($opis,'<div style=\'padding-left:5px; padding-right:12px; padding-top: 10px; padding-bottom: 10px;\' align="left">
')+106,
$opis = substr($opis,$start),
$koniec = strpos($opis,'</div>'),
$opis = substr($opis,0,$koniec),
$opis = str_replace("<img border=0 src=\"http://torrent-polska.eu/torrentimg/6abe970f204d632679f091b3122e1ef3d9162d71.gif\">", " ", $opis),
echo $opis.'<br/>';
echo '<hr/>',
}
}
$plik = 'download.php*.torrent';
$zap = mysql_query("SELECT * FROM `torrent` WHERE `kategoria` = '".$jaka[1]."' ORDER BY `id` DESC LIMIT 10");
while ($odp = mysql_fetch_array($zap)) {
echo $odp['tytul'].'<br/>';
}
?>
jak mam średnikami to mi już wcześniej wyskakują błędy
Parse error: syntax error, unexpected ';' in /home/radeon92/domains/torrentosy.pl/public_html/test.php on line 67