PHP help needed, please.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acctman
    Confirmed User
    • Oct 2003
    • 2840

    #1

    PHP help needed, please.

    hi can someone help me with what i would assume small php code fix. i'm trying to add a CHMOD & CHOWN function to my upload.php file. right now all images that are uploaded by the script is being set to CHMOD 600 with a GRP and USER of "99".

    I can't ftp in to edit or delete images since it says i don't have permission. so can someone the chmod to 0644 with a GRP and USER of 'missbot'

    thanks in advance.

    file is here www.nemxproject.com/upload.txt
  • JSA Matt
    So Fucking Banned
    • Aug 2003
    • 5464

    #2
    http://us2.php.net/manual/en/function.chgrp.php
    http://us2.php.net/manual/en/function.chmod.php
    http://us2.php.net/manual/en/function.chown.php

    php.net should be your next best friend.

    Comment

    • acctman
      Confirmed User
      • Oct 2003
      • 2840

      #3
      yeah php.net is good. i just came from there. I guess i'm placing the function in the wrong place or somethign cause it was working. no errors were displayed yet the files still uploaded with a restricted chmod/grp/owner

      Comment

      • JDog
        Confirmed User
        • Feb 2003
        • 7453

        #4
        Originally posted by acctman
        yeah php.net is good. i just came from there. I guess i'm placing the function in the wrong place or somethign cause it was working. no errors were displayed yet the files still uploaded with a restricted chmod/grp/owner
        Sometimes the CHMOD doesn't work on some servers, you'll need to use the

        PHP Code:
        exec("chmod 666 /path/to/file/"); 
        
        see if that works

        jDoG
        NSCash now powering ReelProfits.com
        ALSO FEATURING: NSCash.com :: SoloDollars.com :: ReelProfits.com :: BiminiBucks.com :: VOD
        PROGRAMS COMING SOON: Greedy Bucks :: Vengeance Cash
        NOW OFFERING OVER 60 SITES
        CONTACT :: JAMES SMITH :: CHIEF TECHNOLOGY OFFICER :: ICQ (711385133)

        Comment

        • fuzebox
          making it rain
          • Oct 2003
          • 22353

          #5
          An uprivileged user cannot chown a file to another user.

          As for deleting files, you have permission to delete them if they are in a directory you have write access to, regardless of the permission on the file itself.

          Comment

          • EZRhino
            Confirmed User
            • Jul 2003
            • 6258

            #6
            After that learn ssh, life is easier once you get the basics down

            Comment

            • acctman
              Confirmed User
              • Oct 2003
              • 2840

              #7
              hmm i still can't get the script to use the chmod i'm not receiving any errors. files are still being uploaded with 0600 chmod. anyone have any insight into why this is happening

              Comment

              • Alky
                Confirmed User
                • Apr 2002
                • 5651

                #8
                Originally posted by acctman
                hmm i still can't get the script to use the chmod i'm not receiving any errors. files are still being uploaded with 0600 chmod. anyone have any insight into why this is happening
                is your error reporting off?

                Comment

                • acctman
                  Confirmed User
                  • Oct 2003
                  • 2840

                  #9
                  error reporting seems to be working cause I left out a semi-colon and the script displayed the line error

                  Comment

                  • Alky
                    Confirmed User
                    • Apr 2002
                    • 5651

                    #10
                    Originally posted by acctman
                    error reporting seems to be working cause I left out a semi-colon and the script displayed the line error
                    hmm no not necessarily... leaving out a semi colon is a parse error, and that will always be reported.. if your error reporting is off, it will hide the warnings, which would probably explain your chmod problems.

                    Comment

                    • acctman
                      Confirmed User
                      • Oct 2003
                      • 2840

                      #11
                      how would i go about checking to see if my error reporting is on

                      Comment

                      • notjoe
                        Confirmed User
                        • May 2002
                        • 5599

                        #12
                        Originally posted by acctman
                        how would i go about checking to see if my error reporting is on
                        Your Webserver is running under a non-root userspace. Files which get uploaded will be owned by this user.

                        Since this isnt a _root_ user you cannot chown the file to another user on the machine using the php script, about the best you could do is chmod 755, so that only the webserver user can write to the file but everyone else on the system can read/execute it.

                        Right from Php.net/chown
                        "Attempts to change the owner of the file filename to user user (specified by name or number). Only the superuser may change the owner of a file. "

                        Comment

                        • acctman
                          Confirmed User
                          • Oct 2003
                          • 2840

                          #13
                          Originally posted by notjoe


                          Your Webserver is running under a non-root userspace. Files which get uploaded will be owned by this user.

                          Since this isnt a _root_ user you cannot chown the file to another user on the machine using the php script, about the best you could do is chmod 755, so that only the webserver user can write to the file but everyone else on the system can read/execute it.

                          Right from Php.net/chown
                          "Attempts to change the owner of the file filename to user user (specified by name or number). Only the superuser may change the owner of a file. "
                          what if i had a separate script that would scan the /image folder and chmod all 600 files to 755, would something like that work?

                          Comment

                          Working...