Autor Zpráva
Wroxman
Profil
Zdravim. Mam skript ktery REQUESTem ziska nazev souboru a ma overit jestli se na serveru nachazi. Bohuzel nefunguje. Prosim, poradte kde je chyba. Adresar 123456789 je adresar ve kterem ty soubory jsou:
<?php
$file = $_REQUEST["file"];
if (file_exists("./123456789/" . $file)) {
echo "
<html>
  <head>
  <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
  <meta name=\"generator\" content=\"PSPad editor, www.pspad.com\">;
  <title>Downloading</title>
  </head>
  <body>
    <div align=\"center\">
    <h1>License</h1>
     <br>You want to download Wroxman´s work, what is published under CC-BY-NC license.<br>
     Please read the license below before download.<br><br>
     <textarea cols=\"50\" rows=\"30\">
     CC-BY-NC 3.0 UNPORTED LICENSE
      You are free:

      * to Share — to copy, distribute and transmit the work
      * to Remix — to adapt the work
      
      Under the following conditions:

      Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

      Attribute this work:
      Information
      What does \"Attribute this work\" mean?
      The page you came from contained embedded licensing metadata, including how the creator wishes to be attributed for re-use. You can use the HTML here to cite the work. Doing so will also include metadata on your page so that others can find the original work as well.
       

      Noncommercial. You may not use this work for commercial purposes.
    * For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
    * Any of the above conditions can be waived if you get permission from the copyright holder.
    * Nothing in this license impairs or restricts the author's moral rights.

     </textarea>
     <form action=\"download.php\" method=\"post\">
     <input type=\"hidden\" name=\"file\" value\"" . $file . "\">
     <input type=\"checkbox\" name=\"agree\" value=\"yes\"> I agree with license<br>
     <div align=\"right\"><input type=\"submit\" value=\"Download\"></form></div>
    </div>
  </body>
</html>";
}
else {
echo "Requested file not found on server.<br>Server answer: 404 - Not found.";
}
?>
yFang
Profil
Wroxman
A jak se projevuje nefunkčnost? Vypisuje to nějakou chybu?
Wroxman
Profil
Ne. Živě: http://ds.teeworlds.cz/index.php?file=plakat-sloh.pdf
[EDIT]
Samozřejmě že v mé "skryté složce" se soubor plakat-sloh.pdf nachází :)
[/EDIT]
bohyn
Profil
Co vypise
echo "./123456789/" . $file;
? Neni mozny ze mas v cookies ulozeno jine jmeno souboru? A misto $_REQUEST bych doporucil pouzivat $_POST a $_GET
Wroxman
Profil
V cookies? Ani nahodou, zadne nenastavuju. Request pouzivam proto ze se to bude pouzivat jako odkaz napriklad pro stahnuti souboru plakat-sloh.pdf použiju <a href="http://ds.teeworlds.cz/index.php?file=plakat-sloh.pdf">Klikni!</ a>
Wroxman
Profil
Co to vypise? Zkus to ;-)
bohyn
Profil
Wroxman
Tohle sem nasel v PHP manualu:
I'm not sure if this is a bug or some kind of caching but with PHP 5.1.6 on Linux file_exists returns false positives. The file in question was (before I deleted it) on a samba mounted file system, it seems to work alright with a local file system.

Using the following function seems to be a workaround:
<?
function is_file_there($filename) {
return realpath($filename) !== false;
}
?>


Ja pouzivam na zjisteni existence souboru is_file(). Zkus jedno z toho vyzkouset.
Wroxman
Profil
.( Nefunguje. Stale :(
bohyn
Profil
A jeste prispevek pod zminovanym naznacuje ze file_exists nema rada spojovani retezce primo v parametru.
Wroxman
Profil
Dobře tedy. Index.php obsahuje nyní tohle:
<?php
$file = "../123456789/";
$file .= $_REQUEST["file"];
if(!file_exists($file)) {
echo "Neexistuje";
}
else {
echo "Existuje";
}
?>

A schválně se koukněte co to vyvádí.. Zase to prý neexistuje.
bohyn
Profil
Wroxman
Ty dve tecky na zacatku maji byt? Pokud ano tak jak mas nastavenou basedir direktivu v PHP?
Wroxman
Profil
bohyn:
Ano, je to tím. Díky moc..
Čekal jsem že to bude nějaká blbost ale tohle....
Nemaj am být dvě tečky ale jedna :)
Toto téma je uzamčeno. Odpověď nelze zaslat.

0