php chmod?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yawnmoth

    php chmod?

    say i have a php script that i access via the web and that creates a
    file whose permissions are changed to 600 (ie. only the owner can read
    or write the file). when i try to download the file with the
    webbrowser... i can. what i want is to not be able to download the
    file, itself. i only want the php script i wrote to download the
    file... how could i do this? is it simply a matter of changing the
    permissions?

    anyways, here's my code:

    <?
    system("ls -l > test.txt");
    chmod("test.txt ", 0600);
    ?>
  • KAH

    #2
    Re: php chmod?

    yawnmoth <terra1024@yaho o.com> wrote in
    news:2sfqnv4k65 4p4a3g58oab980i qttbi3af1@4ax.c om:
    [color=blue]
    > say i have a php script that i access via the web and that creates a
    > file whose permissions are changed to 600 (ie. only the owner can read
    > or write the file). when i try to download the file with the
    > webbrowser... i can. what i want is to not be able to download the
    > file, itself. i only want the php script i wrote to download the
    > file... how could i do this? is it simply a matter of changing the
    > permissions?[/color]

    To answer to this is simple: PHP is being run by the same user as the
    webserver.

    KAH

    Comment

    • Alexander Grümmer

      #3
      Re: php chmod?

      Hi,
      yawnmoth wrote:
      [color=blue]
      > say i have a php script that i access via the web and that creates a
      > file whose permissions are changed to 600 (ie. only the owner can read
      > or write the file). when i try to download the file with the
      > webbrowser... i can. what i want is to not be able to download the
      > file, itself. i only want the php script i wrote to download the
      > file... how could i do this? is it simply a matter of changing the
      > permissions?[/color]
      Nop, here we need to do some tricky stuff.
      You can place the file on a other location like /home/foo (the
      permissions must be so that php can read an write here.
      You webserver looks in the /var/www/htdocs (or something like thist) or
      maybe in /home/foo/public_html. So you can have php read an write the
      file, but you can not make an URL that point to that file.[color=blue]
      >
      > anyways, here's my code:
      >
      > <?
      > system("ls -l > test.txt");
      > chmod("test.txt ", 0600);
      > ?>[/color]
      So long Alexander

      Comment

      Working...