...

View Full Version : questions on ob_start() and folder permission.



abduraooft
11-16-2007, 02:11 PM
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.

aedrin
11-16-2007, 04:18 PM
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

abduraooft
11-17-2007, 09:47 AM
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 ?

GJay
11-17-2007, 11:21 AM
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)

abduraooft
11-17-2007, 12:02 PM
Sorry, let me explain in detail.
I've created a directory "test" through my ftp program, and I've a script named

##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?

jlhaslip
11-17-2007, 04:46 PM
"not closing" the ob_start is poor programming form.

abduraooft
11-17-2007, 06:48 PM
"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


{
ob_start();
$objSess=new Session();
/*blah... blah...
...........*/
// from external file
}
if(!$objSess->IsLoggedIn())
{
header("location:login.php");
return 0;
}
//continue till end
......

aedrin
11-19-2007, 04:15 PM
"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.

abduraooft
11-22-2007, 02:33 PM
OK, so who are the owner,group,other in a webserver? How do support-team at our host get authenticated?

abduraooft
11-27-2007, 02:00 PM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum