Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1

    questions on ob_start() and folder permission.

    Hi all,

    I've two non related questions , but asking in the same thread as I assume they are very simple.

    1) Can I use ob_start() in my page without using any ob_end_flush() at the end?. (It's working for me without any problem, but just asking to know experts' comments)

    2) What should be the permission value of a folder, in to which users can upload and access some files.
    Last edited by abduraooft; 11-16-2007 at 02:14 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    1) Correct, PHP automatically flushes at the end.

    2) The user that is running PHP (depends on your host) needs to have write access to the folder. What the CHMOD number is depends on whether it is done by the user or the group. But you'll want to use a 7 (755 or 775 for example). If you have real access to the host just do: chmod g+w or chmod o+w

  • Users who have thanked aedrin for this post:

    abduraooft (11-17-2007)

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote Originally Posted by aedrin View Post
    1)
    2) The user that is running PHP (depends on your host) needs to have write access to the folder. What the CHMOD number is depends on whether it is done by the user or the group. But you'll want to use a 7 (755 or 775 for example). If you have real access to the host just do: chmod g+w or chmod o+w
    Thanks aedrin, but how about "755 or 775"? xx5 means 101=>r _ x for public. isn't it?

    Should it be 766 ? (rwx rw_ rw_)
    I'm totally confused about this owner-group-user concept on a webserver. (it's OK for me on a local computer.)
    I assume all user who access my page through http: are considered to be 'public' and I need to care the last bit in permission key for them. And through this, if someone create a directory/file, then its owner would be 'public'.

    What is the relevance of 'group' here ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    the person browsing the page never actually writes to the filesystem, that's done for them by the user that the web-server runs as (for apache, this is often www-data, www, nobody or apache but on shared hosting might be the same username that you use to login)
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • Users who have thanked GJay for this post:

    abduraooft (11-17-2007)

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Sorry, let me explain in detail.
    I've created a directory "test" through my ftp program, and I've a script named
    PHP Code:
    ##chmode_test.php
    mkdir("test/sub_test",0777); 
    When I try to execute this from my root directory through browser, it say permission denied.
    To enable this, I've to give at least 757 for the directory "test". (755(which was the initial value) didn't work for me, so I assume the user who runs the code is termed as public).

    When I create a directory through my ftp-program/ CP, it's owner will be my username. But when a directory is created by a browser, it's owner name is displayed as httpd(? ). Even though 0777 is in my mkdir(), it's 0755 when I checked the resultant directory's properties through my ftp program.

    And sometimes my ftp user fails to delete such directories, and then I've to execute an rmdir() script through browser.
    Am I missing anything?
    Last edited by abduraooft; 11-17-2007 at 02:13 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    Regular Coder
    Join Date
    Feb 2007
    Location
    Canada
    Posts
    924
    Thanks
    10
    Thanked 56 Times in 55 Posts
    "not closing" the ob_start is poor programming form.

  • #7
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote Originally Posted by jlhaslip View Post
    "not closing" the ob_start is poor programming form.
    Actually i need it to redirect users to the login page if their session is not valid. But there are some other stuffs before this (due to a poor method of one who wrote it initially ). Anyway I managed like
    PHP Code:
    {
    ob_start();
    $objSess=new Session();
    /*blah... blah...
    ...........*/
    // from external file
    }
    if(!
    $objSess->IsLoggedIn())
    {
    header("location:login.php");
    return 
    0;
    }
    //continue till end
    ...... 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #8
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Quote Originally Posted by jlhaslip View Post
    "not closing" the ob_start is poor programming form.
    In other languages, I would agree. In PHP, I would say it's redundant to call the extra flush as PHP already does one.

    It's the same 'issue' with database connections.

  • Users who have thanked aedrin for this post:

    abduraooft (11-22-2007)

  • #9
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    OK, so who are the owner,group,other in a webserver? How do support-team at our host get authenticated?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #10
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote Originally Posted by GJay View Post
    the person browsing the page never actually writes to the filesystem, that's done for them by the user that the web-server runs as (for apache, this is often www-data, www, nobody or apache but on shared hosting might be the same username that you use to login)
    Then a permission bit of 600 would be enough, but does it permit to upload something in to the directory?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •