Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Download, Dodaje sie kod html
marcio
post
Post #1





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Witam mam taki link:
Kod
<td align="right" style="background-color: #000000;"><a href="?action=download&cid='.$_GET['cid'].'"><img src="./img/down2.jpeg" alt="dowload"></a></td>


I kod php:
  1. <?php
  2. else if(isset($_GET['action']) && $_GET['action'] == 'download') {
  3.  
  4.  header("Content-Type: application/force-download");
  5.  header('Content-Type: application/x-unknown');;
  6.  header("Content-Type: application/download");
  7.  header('Content-Disposition: attachment; filename=file_'.$_GET['cid'].'.php');
  8.  header("Content-Length: ".filesize('./url/file/file_'.$_GET['cid'].'.php'));
  9.  readfile('./url/file/file_'.$_GET['cid'].'.php');
  10.  
  11.  }
  12. ?>

Wszystko ladnie dziala tylko do sciaganego pliku dodaje sie wygenerowany przez php kod html od strony z ktorej plik jest sciagany czy ktos moze powiedziec co jest zle??
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
marcio
post
Post #2





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


No to albo zrobie w osobnym pliku albo jeszcze jak mozna te buforowanie nie chce dzialac (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Tylko ze w osobnym pliku bedzie troche problem mam taki kod dla download:
  1. <?php
  2. else if(isset($_GET['action']) && $_GET['action'] == 'download') {
  3.  
  4.  
  5. $code = mysql_query('select * from paste_bin where gen_cid = "'.mysql_real_escape_string($_GET['cid']).'" limit 1', $db);
  6. $tab = mysql_fetch_assoc($code);
  7.  
  8.  
  9. if($tab['stan_pass'] == 2 && $tab['upload'] == 2) {
  10.  
  11.  
  12. echo('<Br>
  13. <form method="post">
  14. <center><input type="password" name="code_pass" size="40" style="background-color:#ECECEC; color:#000000; border: 1px solid red;">
  15. <Br>
  16. <input type="submit" name="idz" value="Idz" style="background-color:#ECECEC; color:#000000; border: 1px solid black;">
  17. </center>
  18. </form><Br>');
  19.  
  20. if(!empty($_POST['code_pass']) && isset($_POST['idz'])) {
  21.  
  22. $code_pass = md5($_POST['code_pass']);
  23.  
  24. if($code_pass == $tab['password']) {
  25.  
  26.  
  27. header("Content-Type: application/force-download");
  28. header('Content-Type: application/x-unknown');;
  29. header("Content-Type: application/download");
  30. header('Content-Transfer-Encoding: binary');
  31. header('Content-Disposition: attachment; filename=file_'.$_GET['cid'].'.php');
  32. header("Content-Length: ".filesize('./url/file/file_'.$_GET['cid'].'.php'));
  33. readfile('./url/file/file_'.$_GET['cid'].'.php');
  34.  
  35.  }
  36. else echo('<script>alert("Podales zle haslo");</script>');
  37.  }
  38. }
  39.  
  40.  
  41. else if($tab['stan_ip'] == 2 && $tab['upload'] == 2) {
  42.  
  43. if($_SERVER['REMOTE_ADDR'] == $tab['ip']) {
  44.  
  45.  
  46. header("Content-Type: application/force-download");
  47. header('Content-Type: application/x-unknown');;
  48. header("Content-Type: application/download");
  49. header('Content-Transfer-Encoding: binary');
  50. header('Content-Disposition: attachment; filename=file_'.$_GET['cid'].'.php');
  51. header("Content-Length: ".filesize('./url/file/file_'.$_GET['cid'].'.php'));
  52. readfile('./url/file/file_'.$_GET['cid'].'.php');
  53.  
  54.  }
  55. else echo('<center><b>Ten adres moze ogladac tylko ip podane w formularzu</b><center>');
  56. }
  57.  
  58. else {
  59.  
  60.  
  61. header("Content-Type: application/force-download");
  62. header('Content-Type: application/x-unknown');;
  63. header("Content-Type: application/download");
  64. header('Content-Transfer-Encoding: binary');
  65. header('Content-Disposition: attachment; filename=file_'.$_GET['cid'].'.php');
  66. header("Content-Length: ".filesize('./url/file/file_'.$_GET['cid'].'.php'));
  67. readfile('./url/file/file_'.$_GET['cid'].'.php');
  68.  
  69. }
  70. }
  71. ?>

I jak narazie wszystko tak dziala zeby dodac url kod albo cos sciagnac trzeba byc zalogowanym w cms'ie i potem klika sie na ten link do download:
Kod
<td align="right" style="background-color: #000000;"><a href="?action=download&cid='.$_GET['cid'].'"><img src="./img/down2.jpeg" alt="dowload"></a></td>


I wtedy uruchamia sie kod ktory podalem wyzej i dziala to tak jesli ktos jest zalogowany i code z zalacznikiem jest bez hasla/ip sciaga sie odrazu jak nie prosi o haslo a jak nie sprawdza ip i dopiero wtedy pobierai jest jedno ale tak tego nie mozna oszukac przynajmniej mi sie nie udaje

Wiec jesli dam osobny plik to bede musial kombinowac myslalem zrobic to tak

Klikan na ten link wyzej i tam robie sprawdzenie jesli jest na haslo to wpisuje i musialbym przekierowac to no do takiego linku
Cytat

ALe jest jeden problem jako ze nie ma zadnych cookie do tego ani nic to myslalem to tak rozwiazac zamiast linku wyzej to takie cos:
Cytat

I potem w pliku przed pobraniem lacze sie z baza i sprawdzam czy dane z get'a sie zgadzaja z tymi z bazy i wtedy sciagam

Ale czy to nie okrezna droga?

TO jak jaks wskazowka zande ob_clean() i ob_flush() nie pomagaja chyba zrobie tak jak napisalem (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 02:13