Jump to content

ajuda no download por favor


fernas

Recommended Posts

<?


if (!empty($_POST['link'])) {

$con = mysql_connect("localhost", "XXXX", "XXXX");
mysql_select_db("XXXXr", $con);

$link = mysql_real_escape_string($_POST['link']);

$extensao = substr(strrchr( $link, '.' ), 1 );

$mimetypes = array(
		"ez" => "application/andrew-inset",
		"rar" => "application/archive-rar",
		"atom" => "application/atom+xml",
		"ccad" => "application/clariscad",
		"drw" => "application/drafting",
		"tsp" => "application/dsptype",
		"dxf" => "application/dxf",
		"unv" => "application/i-deas",
		"hqx" => "application/mac-binhex40",
		"cpt" => "application/mac-compactpro",
		"pps" => "application/mspowerpoint",
		"doc" => "application/msword",
		"bin" => "application/octet-stream",
		"oda" => "application/oda",
		"pdf" => "application/pdf",
		"ps" => "application/postscript",
		"prt" => "application/pro_eng",
		"set" => "application/set",
		"smil" => "application/smil",
		"sol" => "application/solids",
		"vda" => "application/vda",
		"mif" => "application/vnd.mif",
		"xlw" => "application/vnd.ms-excel",
		"ppt" => "application/vnd.ms-powerpoint",
		"wbxml" => "application/vnd.wap.wbxml",
		"wmlc" => "application/vnd.wap.wmlc",
		"wmlsc" => "application/vnd.wap.wmlscriptc",
		"bcpio" => "application/x-bcpio",
		"vcd" => "application/x-cdlink",
		"pgn" => "application/x-chess-pgn",
		"cpio" => "application/x-cpio",
		"csh" => "application/x-csh",
		"dxr" => "application/x-director",
		"dvi" => "application/x-dvi",
		"pre" => "application/x-freelance",
		"spl" => "application/x-futuresplash",
		"gtar" => "application/x-gtar",
		"gz" => "application/x-gzip",
		"hdf" => "application/x-hdf",
		"php" => "application/x-httpd-php",
		"phps" => "application/x-httpd-php-source",
		"ipx" => "application/x-ipix",
		"ips" => "application/x-ipscript",
		"js" => "application/x-javascript",
		"skp" => "application/x-koan",
		"latex" => "application/x-latex",
		"lsp" => "application/x-lisp",
		"scm" => "application/x-lotusscreencam",
		"cdf" => "application/x-netcdf",
		"sh" => "application/x-sh",
		"shar" => "application/x-shar",
		"flv" => "application/x-shockwave-flash",
		"sit" => "application/x-stuffit",
		"sv4cpio" => "application/x-sv4cpio",
		"sv4crc" => "application/x-sv4crc",
		"tar" => "application/x-tar",
		"tcl" => "application/x-tcl",
		"tex" => "application/x-tex",
		"texinfo" => "application/x-texinfo",
		"t" => "application/x-troff",
		"man" => "application/x-troff-man",
		"me" => "application/x-troff-me",
		"ms" => "application/x-troff-ms",
		"ustar" => "application/x-ustar",
		"src" => "application/x-wais-source",
		"xhtml" => "application/xhtml+xml",
		"zip" => "application/zip",
		"tsi" => "audio/TSP-audio",
		"au" => "audio/basic",
		"mid" => "audio/midi",
		"mpga" => "audio/mpeg",
		"aiff" => "audio/x-aiff",
		"m3u" => "audio/x-mpegurl",
		"ram" => "audio/x-pn-realaudio",
		"rpm" => "application/x-rpm",
		"ra" => "audio/x-realaudio",
		"wav" => "audio/x-wav",
		"wma" => "audio/x-wma",
		"pdb" => "chemical/x-pdb",
		"xyz" => "chemical/x-xyz",
		"bmp" => "image/bmp",
		"gif" => "image/gif",
		"ief" => "image/ief",
		"jpg" => "image/jpeg",
		"png" => "image/png",
		"tiff" => "image/tiff",
		"djv" => "image/vnd.djvu",
		"wbmp" => "image/vnd.wap.wbmp",
		"ras" => "image/x-cmu-raster",
		"pnm" => "image/x-portable-anymap",
		"pbm" => "image/x-portable-bitmap",
		"pgm" => "image/x-portable-graymap",
		"ppm" => "image/x-portable-pixmap",
		"rgb" => "image/x-rgb",
		"xbm" => "image/x-xbitmap",
		"xpm" => "image/x-xpixmap",
		"xwd" => "image/x-xwindowdump",
		"igs" => "model/iges",
		"silo" => "model/mesh",
		"wrl" => "model/vrml",
		"css" => "text/css",
		"htm" => "text/html",
		"c" => "text/plain",
		"rtx" => "text/richtext",
		"rtf" => "text/rtf",
		"sgml" => "text/sgml",
		"tsv" => "text/tab-separated-values",
		"wml" => "text/vnd.wap.wml",
		"wmls" => "text/vnd.wap.wmlscript",
		"etx" => "text/x-setext",
		"xml" => "text/xml",
		"mpg" => "video/mpeg",
		"qt" => "video/quicktime",
		"mxu" => "video/vnd.mpegurl",
		"fli" => "video/x-fli",
		"wmv" => "video/x-msvideo",
		"movie" => "video/x-sgi-movie",
		"ice" => "x-conference/x-cooltalk"
		);

$content_type = $mimetypes[$extensao];




$query = mysql_query("INSERT INTO links (id, link, ctype) VALUES (NULL, '$link', '$content_type')",$con);

if ($query) {
$idq = @mysql_query("SELECT id FROM links ORDER BY id DESC LIMIT 1",$con);
$id = @mysql_result($idq,0, "id");
echo "Link inserido com sucesso!", "<br />Clique aqui para o testar: <a href=\"link.php?id=$id\">link.php?id=$id</a>";
}
else
{
echo "Ocorreu um erro!";
}
}
else
{
echo '
<form method="POST" action="">
<input type="text" name="link">
<br />
<input type="submit">
</form>
';
}
?>

-------------------------------------------------------------------

<?

$id = $_GET['id'];

if(!is_numeric($id)) {
die("erro");
}

$con = mysql_connect("localhost", "XXXXX", "XXXX");
mysql_select_db("XXXXX", $con);

$query = mysql_query("SELECT * FROM links WHERE id = '$id' LIMIT 1", $con);

if (mysql_num_rows($query) == 1) {
$ctype = mysql_result($query, 0, "ctype");
$link = mysql_result($query, 0, "link");
if (eregi("Flashget", $_SERVER['HTTP_USER_AGENT'])) {
Header("Content-type: $ctype");
echo file_get_contents($path);
}
else
{
echo "Tem que fazer download com o FlashGet!";
}
}
else
{
echo "Link não existente!";
}
?>

o primeiro code e do addlink o segundo e do link

os codigos estao alterados para o servidor

so que quando meto o link no flashget ele saka a pagina e nao o ficehiro

o que esta a XXXX foi a unica coisa que alterei

alguem me podia dar uma ajuda

um grande obrigado ao karva e ao djthyrax ajudarame muito

Link to comment
Share on other sites

http://img520.imageshack.us/img520/9021/chaticewo2.jpg

ele saka a pagina que diz para sakar, e saka o file em php

nao tera nada haver com o protocolo do flahget no user define

ele neste falhget esta none

Boas!

Atenção que ele está definido como none, mas repara no código:

if (eregi("Flashget", $_SERVER['HTTP_USER_AGENT'])) {

Estás a dizer que se o user-agent tiver "Flashget", faz o download... mas não dá, porque o useragent do teu flashget está para none..

Nick antigo: softclean | Tens um projeto? | Wiki P@P

Ajuda a comunidade! Se encontrares algo de errado, usa a opção "Denunciar" por baixo de cada post.

Link to comment
Share on other sites

A questão dele era no seguimento deste post

http://www.portugal-a-programar.pt/index.php?showtopic=13744

A intenção era "ocultar" o endereço real de onde se estava a fazer download do ficheiro, mas penso que o file_get_contents não estava a funcionar, por isso se optou pelo flashget para difcultar um pouco de onde veio o download.

Nick antigo: softclean | Tens um projeto? | Wiki P@P

Ajuda a comunidade! Se encontrares algo de errado, usa a opção "Denunciar" por baixo de cada post.

Link to comment
Share on other sites

porque no flashget saka muito mais rapido

if (eregi("Flashget", $_SERVER['HTTP_USER_AGENT'])) {

existe alguma soluçao tem que haver

o exemplo do wareztuga eles tem isto a trabalhar

estou a colocar este link no campo do addlinks http://downloads.exameinformatica.clix.pt/varios/downloads/broken4.zip

e sem sucesso ele saka sempre a mesma pagina

Link to comment
Share on other sites

nao sei se e do codigo

utilizei o codigo que o karva deu me

e queria por a trablhar tal como o wareztuga tem

senao de outra maneira o que interessa que eu ou outro pegue num link normal de download

va ao script que na pagina ele converta o link e diga so pode sakar no flahsget e entao ele vai la

nao sei se aqui entre a parte do portocolo

ele coloca o link e saka nao pelo link original mas pelo o que dei

Link to comment
Share on other sites

Vamos por partes, neste momento o .php já percebe que está a ser utilizado o FlashGete ele já está e entrar no if correcto, qual é o objetivo agora ? é sacar o conteudo do ficheiro do link ??

Desculpa mas não li a dúvida toda, portanto ainda não percebi muito bem, mas é algo tipo isto

Se eu tiver www.portugal-a-programar.org/tiago.zip

ele saca o .zip o o FlashGet ??

nao sei se e do codigo

utilizei o codigo que o karva deu me

e queria por a trablhar tal como o wareztuga tem

senao de outra maneira o que interessa que eu ou outro pegue num link normal de download

va ao script que na pagina ele converta o link e diga so pode sakar no flahsget e entao ele vai la

nao sei se aqui entre a parte do portocolo

ele coloca o link e saka nao pelo link original mas pelo o que dei

Link to comment
Share on other sites

sim tenho www.portugal-a-programar.org/tiago.zip

vou ao script converto  para

http://www.teuservidor.com/download.php?id=56

quando cliko nele ele diz me para sakr e preciso flashget

vou ao flahsget meto

http://www.teuservidor.com/download.php?id=56

e ele começa a sakar o teu www.portugal-a-programar.org/tiago.zip

sem que o user se apercebe-se

Link to comment
Share on other sites

Eu tenho um script para fazer o que queres mas nao limito ao ao browser, experimenta colocar todos estes headers:

		header("Pragma: public");
		header("Expires: 0");
		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header("Cache-Control: public");
		header("Content-Description: File Transfer");
		header("Content-Type: audio/mpeg");
		header("Content-Disposition: attachment; filename=\"".date("dmY") . "_-_" . $artistas . "_-_" . $track_name . "_" . $remixer . ".mp3\"");
		header("Content-Transfer-Encoding: binary");
		header("Content-Length: " . $fsize);

Atenção que estas a utilizar o flash_get_contents($path); mas o $path nao esta definido em lado algum.

Cumps!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.