Ir para conteúdo
Fórum Script Brasil

alanps

Membros
  • Total de itens

    8
  • Registro em

  • Última visita

Sobre alanps

alanps's Achievements

0

Reputação

  1. alanps

    Torrent seeds em PHP

    Oi, estou com o script pronto e rodando em localhost, mas quando jogo no servidor (tentei uns 3 servidores, hostinger, hostgator(pago) e outros...) e não funciona, alguém sabe o que precisa habilitar para esse script funcionar ? estou usando o xampp... <?php /* Torrent UDP Scraper v1.2 2010 by Johannes Zinnau johannes@johnimedia.de Licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License http://creativecommons.org/licenses/by-sa/3.0/ It would be very nice if you send me your changes on this class, so that i can include them if they are improve it. Thanks! Usage: try{ $timeout = 2; $scraper = new udptscraper($timeout); $ret = $scraper->scrape('udp://tracker.tld:port',array('0000000000000000000000000000000000000000')); print_r($ret); }catch(ScraperException $e){ echo('Error: ' . $e->getMessage() . "<br />\n"); echo('Connection error: ' . ($e->isConnectionError() ? 'yes' : 'no') . "<br />\n"); } */ include "tscraper.php"; class udptscraper extends tscraper{ /* $url: Tracker url like: udp://tracker.tld:port or udp://tracker.tld:port/announce $infohash: Infohash string or array (max 74 items). 40 char long infohash. */ public function scrape($url,$infohash){ if(!is_array($infohash)){ $infohash = array($infohash); } foreach($infohash as $hash){ if(!preg_match('#^[a-f0-9]{40}$#i',$hash)){ throw new ScraperException('Invalid infohash: ' . $hash . '.'); } } if(count($infohash) > 74){ throw new ScraperException('Too many infohashes provided.'); } if(!preg_match(' p://([^:/]*)(?::([0-9]*))?(?:/)?%si', $url, $m)){ throw new ScraperException('Invalid tracker url.'); } $tracker = 'udp://' . $m[1]; $port = isset($m[2]) ? $m[2] : 80; $transaction_id = mt_rand(0,65535); $fp = fsockopen($tracker, $port, $errno, $errstr); if(!$fp){ throw new ScraperException('Could not open UDP connection: ' . $errno . ' - ' . $errstr,0,true); } stream_set_timeout($fp, $this->timeout); $current_connid = "\x00\x00\x04\x17\x27\x10\x19\x80"; //Connection request $packet = $current_connid . pack("N", 0) . pack("N", $transaction_id); fwrite($fp,$packet); //Connection response $ret = fread($fp, 16); if(strlen($ret) < 1){ throw new ScraperException('No connection response.',0,true); } if(strlen($ret) < 16){ throw new ScraperException('Too short connection response.'); } $retd = unpack("Naction/Ntransid",$ret); if($retd['action'] != 0 || $retd['transid'] != $transaction_id){ throw new ScraperException('Invalid connection response.'); } $current_connid = substr($ret,8,8); //Scrape request $hashes = ''; foreach($infohash as $hash){ $hashes .= pack('H*', $hash); } $packet = $current_connid . pack("N", 2) . pack("N", $transaction_id) . $hashes; fwrite($fp,$packet); //Scrape response $readlength = 8 + (12 * count($infohash)); $ret = fread($fp, $readlength); if(strlen($ret) < 1){ throw new ScraperException('No scrape response.',0,true); } if(strlen($ret) < 8){ throw new ScraperException('Too short scrape response.'); } $retd = unpack("Naction/Ntransid",$ret); // Todo check for error string if response = 3 if($retd['action'] != 2 || $retd['transid'] != $transaction_id){ throw new ScraperException('Invalid scrape response.'); } if(strlen($ret) < $readlength){ throw new ScraperException('Too short scrape response.'); } $torrents = array(); $index = 8; foreach($infohash as $hash){ $retd = unpack("Nseeders/Ncompleted/Nleechers",substr($ret,$index,12)); $retd['infohash'] = $hash; $torrents[$hash] = $retd; $index = $index + 12; } return($torrents); } } ?>
  2. é o internet explorer, tente usar outro navegaro!!!
  3. $pasta = 'fotos/'; // (em Bytes) $tamanho = 20000000; $extensoes = array('jpg', 'jpeg', 'png', 'gif'); $renomeia = false; /////////////////////////////// if ($_FILES['arquivo2']['error'] != 0) { echo "Erro!"; } if ($_FILES['arquivo2']['name']) { echo $_FILES['arquivo2']['name']; /////////////////////////////// $extensao = strtolower(end(explode('.', $_FILES['arquivo2']['name']))); if (array_search($extensao, $extensoes) === false) { echo "Erro!"; } else if ($tamanho < $_FILES['arquivo2']['size']) { echo "Erro!"; } // movendo para a pasta else { // novo nome do arquivo if ($renomeia == true) { $nome_final = $data.'.jpg'; } else { // nome original $nome_final = $_FILES['arquivo2']['name']; } // movendo arquivo if (move_uploaded_file($_FILES['arquivo2']['tmp_name'], $pasta . $nome_final)) { // Upload efetuado com sucesso (caso arquivo não apareça no painel provavelmente é o mysql) $query = mysql_query("INSERT INTO agenda (foto1, evento, hora, dia, mes, ano, inscricao, preco, descricao) VALUES ('$pasta/$nome_final', '$evento', '$hora', '$dia', '$mes', '$ano', '$inscricao', '$valor', '$descricao')") or die(mysql_error()); echo "<meta http-equiv=\"refresh\" content=\"0; url=arealider.php?abrir=agenda\">"; } else { // Não foi possível fazer o upload, provavelmente a pasta está incorreta echo "<meta http-equiv=\"refresh\" content=\"0; url=arealider.php?abrir=agenda\">"; } } } else { $query = mysql_query("INSERT INTO agenda (evento, hora, dia, mes, ano, inscricao, preco, descricao) VALUES ('$evento', '$hora', '$dia', '$mes', '$ano', '$inscricao', '$valor', '$descricao')") or die(mysql_error()); echo "<meta http-equiv=\"refresh\" content=\"0; url=arealider.php?abrir=agenda\">"; } cara meu script de upload é esse, não sei o erro, mas arquivos pequenos múltiplos também tá dando erro...
  4. Oi, estou criando um sistema de upload em php e não consigo carregar arquivos grandes no servidor, via localhost vai, mas no servidor aparece página não encontrada, com arquivos pequenos vai de boa...alguém pode me ajudar ?
  5. Umas screens da animação...o que vocês acham ? http://www.alanps.com.br/enquete.php
  6. alanps

    Busca simples em php

    Oi, fiz uma busca simples em php e estou com problemas, quando busca dependendo do resultado bagunça o layout da página.. o problema tá no "str_ireplace", se alguém puder me ajudar... o código abaixo: echo "<span style=\"position: absolute; top:128px;width:420px;\">"; while ($row = mysql_fetch_array($query)) { $busca = strtoupper($busca); $row[Pergunta] = str_ireplace("$busca","<font style=\"background-color:#FFFFCC;\">$busca</font>",$row[Pergunta]); $row[Resposta] = str_ireplace("$busca","<font style=\"background-color:#FFFFCC;\">$busca</font>",$row[Resposta]); echo "<a href=\"perguntas.php?msg=1&id=$row[Id]\" style=\"font-family:courier; font-size:11px; text-decoration:none; color:#0000FF; font-weight:bold;\"> $row[Pergunta]</a><br>"; echo "<span style=\"font-family:courier; font-size:11px; text-decoration:none; color:#000000; font-weight:bold;\">"; echo substr($row[Resposta], 0, 50); if (strlen($row[Resposta]) > 50) { echo "...<br><br>"; } if (strlen($row[Resposta]) <= 50) { echo "<br><br>"; } echo "</span>"; } echo "</span>";
  7. sei mysql e php, ajax eu não sei nada...
  8. Oi, estou fazendo um chat em php e queria um script simples para atualizar os resultados sem refresh pode ser ajax ou alguma outra linguagem windows... Obrigado
×
×
  • Criar Novo...