Not allowed to access???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
skylavelle
Forum Newbie
Posts: 18
Joined: Sun May 04, 2003 11:33 pm
Location: Brisbane, Australia

Not allowed to access???

Post by skylavelle »

What is with this, the damn thing won't work. Just UPLOAD @#$!

Warning: SAFE MODE Restriction in effect. The script whose uid is 549 is not allowed to access /var/www/html/images owned by uid 0 in /home/virtual/site47/fst/var/www/html/modify/imageuploader.php on line 23
upload failed!

Code: Select all

<?
$path = "../images/used/";
$max_size = 200000;
if (!isset($_FILES['file'])) {
    exit;
}
if (is_uploaded_file ($_FILES['file']['tmp_name'])) {
    if ($_FILES['file']['size']>$max_size) {
        echo "The file is too big<br>\n";
        exit;
    }
    if (($_FILES['file']['type']== "image/gif") || ($_FILES['file']['type']== "image/pjpeg") || ($_FILES['file']['type']== "image/jpeg")) {
        if (file_exists($path.$_FILES['file']['name'])) {
            echo "The file already exists";
            exit;
        }
        $res = copy($_FILES['file']['tmp_name'], $path.$_FILES['file']['name']);
        if (!$res) {
            echo "upload failed!";
            exit;
        } else {
            echo "upload sucessful";
        }
    } else {
        echo "Wrong file type";
        exit;
    }
}
?>
Do I need to connect (user, password) to the site, if so how??????
Last edited by skylavelle on Tue May 06, 2003 10:20 pm, edited 2 times in total.
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Try turning Safe Mode off, if you can.
Image Image
User avatar
skylavelle
Forum Newbie
Posts: 18
Joined: Sun May 04, 2003 11:33 pm
Location: Brisbane, Australia

Post by skylavelle »

8O
Should I be able to turn safe mode off through my admin area? I've never noticed it before, I didn't even know there was such a thing
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

It's configured in the php.ini
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

But since uid 0 is root one might assume you can change php.ini-settings ;)
http://www.php.net/manual/en/features.s ... .safe-mode
If you want to stay with safe mode (or must) make the account with uid 549 the owner of that directory.
User avatar
skylavelle
Forum Newbie
Posts: 18
Joined: Sun May 04, 2003 11:33 pm
Location: Brisbane, Australia

Post by skylavelle »

Thanks, I've been in contact with my host and he says that he will turn off safe-mode. Do you think this will solve my problem?

Thanks for the link volka!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Safe mode being turned off will get rid of the safe mode warnings about uid's and whatnot.

Mac
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I hope php's safe-mode is something that will happen only to other people :twisted:
Although security is something one should care about, safe-mode is a pain in the ass and did me more harm than good.
If the admin is concerned about security he/she/it might be interested in the new "perchild" mpm-module introduced with apache 2. It's still experimental
This MPM does not currently work on most platforms. Work is ongoing to make it functional.
but once it is working (and stable for production systems) I'm sure it will help admins keeping their hair and getting healthy amounts of sleep each day ;)
I -for sure- will mark the day the experimental-note is removed with reason :D
User avatar
skylavelle
Forum Newbie
Posts: 18
Joined: Sun May 04, 2003 11:33 pm
Location: Brisbane, Australia

Post by skylavelle »

Arrrrrgh!

Ok, I have rid my server of safe-mode. However, I am now getting an error message, which I think is in relation to my code.

Warning: Unable to create '../images/used/car.jpg': Permission denied in /home/virtual/site47/fst/var/www/html/modify/imageuploader.php on line 22
upload failed!


Permission denied - what is with that? :cry:
Last edited by skylavelle on Wed May 07, 2003 1:29 am, edited 1 time in total.
User avatar
r337ard
Forum Commoner
Posts: 29
Joined: Tue Apr 15, 2003 6:14 am
Contact:

Post by r337ard »

doesn't look like you have write permissions to the directory
User avatar
skylavelle
Forum Newbie
Posts: 18
Joined: Sun May 04, 2003 11:33 pm
Location: Brisbane, Australia

Post by skylavelle »

That is what I think is the problem. I can uplaod files, by using an FTP program though I can not through PHP.

Does anyone know if there is PHP script for connecting to a site?

Maybe similar to connecting to that, which I use to connect to the MySQL database?

I haven't a clue, as to how it should be written so any imput would be great :wink:
User avatar
r337ard
Forum Commoner
Posts: 29
Joined: Tue Apr 15, 2003 6:14 am
Contact:

Post by r337ard »

i should rephrase. whatever uid/gid the php script is run as, doesn't have write permissions to the directory. your ftp account presumably has different privledges.
User avatar
skylavelle
Forum Newbie
Posts: 18
Joined: Sun May 04, 2003 11:33 pm
Location: Brisbane, Australia

Post by skylavelle »

I am confussed :(

Firstly, is there such a script for connecting to sites or is it not necessary?

So how do I change the uid/gid which the php script is run as, in order for it to have the same privileges as the ftp account, thus having write permission?
Post Reply