Any PHP experts??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marcjacob
    Confirmed User
    • Jun 2003
    • 1063

    #1

    Any PHP experts??

    Is it correct that PHP can only delete files or folders owned by apache (or created using php)? If that is correct, is there a way around it?

    I want a script Im writing to auto delete some files that were uploaded by ftp. I tried getting php to chmod the files to 777 but it wont do that even?
    Free Site Express GFY Launch Offer
    Gay Demo Video - Straight Demo Video
    Icq: 191127710 Email: [email protected]
  • applebee
    Confirmed User
    • Aug 2006
    • 167

    #2
    http://www.php.net/manual/en/function.chmod.php
    HeatSeek: The iTunes of Porn !
    $30 PPS, conversion ratios 10x better than content sites.

    Comment

    • beta-tester
      Rock 'n Roll Baby!
      • Sep 2004
      • 22562

      #3
      yes it is correct. File with 7 for everybody should be read, modified and deleted by nobody (apache) without problems.

      Sig for sale. Affordable prices. Contact me and get a great deal ;)

      My contact:
      ICQ: 944-320-46
      e-mail: manca {AT} HotFreeSex4All.com

      Comment

      • camgirlshide
        Confirmed User
        • Jan 2005
        • 1558

        #4
        can you give us a little more details and I'm sure there is a solution.
        Why are you using a php script to do this that is being run by user apache?
        Useful adult webmaster links -
        Alphabetical list of solo models with webcam
        Stats on my best converting affiliate programs - camgirlshide webmaster blog
        complete list of affiliate programs I use.

        Comment

        • marcjacob
          Confirmed User
          • Jun 2003
          • 1063

          #5
          Its a cms of sorts, and Im uploading the big pics, then php crops the thumbs and copies the thumbs and the bigger photos to where they are meant to be. So apache is taking ownership of those files. Im wanting to then delete the source files.

          Ive actually managaged to get the files deleted, now its not deleting the folder and is saying operation not permitted.

          Ill work on it some more today, Its something im doing wrong in my code

          Thanks for your help!
          Free Site Express GFY Launch Offer
          Gay Demo Video - Straight Demo Video
          Icq: 191127710 Email: [email protected]

          Comment

          • marcjacob
            Confirmed User
            • Jun 2003
            • 1063

            #6
            Actually I havent managed to delete the files either. It worked as I set permissions on that folder in ftp.

            The issue is that it wont let me chmod files that apache doesnt own with php.
            Free Site Express GFY Launch Offer
            Gay Demo Video - Straight Demo Video
            Icq: 191127710 Email: [email protected]

            Comment

            • ladida
              Confirmed User
              • Nov 2005
              • 2179

              #7
              You can't do anything apache can't.

              You can't delete files if they are not owned by apache and dir permissions are not set properly. If you want to delete files/folders, apache has to be the owner corresponding file and directory. This all doesn't have anything to do with php per se, but how your server is setup. You'll have to read up on unix permissions to see what you can and can't do. You can't delete the folder again, if the upper folder doesn't give you permissions to do so, or you're not the owner of the folder. Then there's various other security settings that might be preventing you to do things that normally you could. Ask your host for help since you don't know it.

              To actually delete and do whatever the fuck you want, you'd need to suid yourself in php environment. This is ofcourse a big big no no and if you actually chose this route, you can expect to have alot bigger problems on your hands. Rather work with host and figure out what/where you want to modify with apache perms and set permissions accordingly.
              agentGFY *at* gmail.com

              Comment

              • leek
                Confirmed User
                • May 2008
                • 342

                #8
                This isn't a PHP limitation, but rather a *nix "limitation" - and with good reason. A user that doesn't have permissions to delete a file shouldn't be allowed to delete that file!

                You could try creating a new FTP user that is a member of the same group as Apache, and only using that user to upload the images.

                You could also just change the permissions of your source files after you have uploaded them.

                Or you could look into the dangerous exec() and system() functions, which you could probably use to temporarily elevate permissions while you delete the files.

                Comment

                • marcjacob
                  Confirmed User
                  • Jun 2003
                  • 1063

                  #9
                  What about chown() which php.net says will attempt to change ownership of the file. Is that considered dangerous to use?

                  Thanks for your help btw, I really apreciate the answers
                  Free Site Express GFY Launch Offer
                  Gay Demo Video - Straight Demo Video
                  Icq: 191127710 Email: [email protected]

                  Comment

                  • leek
                    Confirmed User
                    • May 2008
                    • 342

                    #10
                    Originally posted by marcjacob
                    What about chown() which php.net says will attempt to change ownership of the file. Is that considered dangerous to use?

                    Thanks for your help btw, I really apreciate the answers
                    This will still execute chown as the current user (apache). You should talk to your server administrator about the various options you have without compromising server security.

                    Comment

                    • nation-x
                      Confirmed User
                      • Mar 2004
                      • 5370

                      #11
                      Your issue is umask. It changes the ownership of the files that were chmod via php. You can try using the shell to chmod the files... when I started doing that it fixed my permissions issues.

                      PHP Code:
                      exec('chmod 0777 /<path>/file.txt'); 
                      

                      Comment

                      Working...