make a folder in php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alex79
    Confirmed User
    • Jun 2002
    • 996

    #1

    make a folder in php?

    anybody know what is the php code/function to make a folder and chmod to 777?

    thx
  • - Jesus Christ -
    Confirmed User
    • Mar 2003
    • 7197

    #2
    You can try using the PHP ftp manipulation commands.

    Thats one of the only wayts to make an CHMOD folders with PHP running is safe mode (at least that I know of)

    Amen

    Comment

    • Nathan
      Confirmed User
      • Jul 2003
      • 3108

      #3
      http://php.net/mkdir
      "Think about it a little more and you'll agree with me, because you're smart and I'm right."
      - Charlie Munger

      Comment

      • roly
        Confirmed User
        • Aug 2002
        • 1844

        #4
        Originally posted by alex79
        anybody know what is the php code/function to make a folder and chmod to 777?

        thx
        this may help you http://uk2.php.net/mkdir

        Comment

        • pornanza
          Confirmed User
          • Jul 2003
          • 238

          #5
          mkdir('this/folder', 0777);

          ryan
          Eskimo Hoe
          QuickWank
          Pornanza!

          Comment

          • roly
            Confirmed User
            • Aug 2002
            • 1844

            #6
            Originally posted by Nathan
            http://php.net/mkdir
            beat me to it

            Comment

            • - Jesus Christ -
              Confirmed User
              • Mar 2003
              • 7197

              #7
              Originally posted by Nathan
              http://php.net/mkdir

              Yea but your username wont own those dirs.
              its not a good solution, You wont be able to del files or folders once you amke them.


              If you're on a shared *nix server, a directory created through mkdir() will not be assigned to you, but to the user that your host's server or php process is running under, usually 'nobody', 'apache' or 'httpd'.

              In practice, this means that you can create directories, even add files to them, but you can't delete the directory or its contents nor change permissions.

              PwN3d

              Amen

              Comment

              • pornanza
                Confirmed User
                • Jul 2003
                • 238

                #8
                not quite true

                if you created it with a script, you can modify it with a script

                ryan
                Eskimo Hoe
                QuickWank
                Pornanza!

                Comment

                • - Jesus Christ -
                  Confirmed User
                  • Mar 2003
                  • 7197

                  #9
                  Originally posted by pornanza
                  not quite true

                  if you created it with a script, you can modify it with a script

                  ryan
                  wrong. And you certainly can't CHMOD...

                  Amen

                  Comment

                  • buran
                    Confirmed User
                    • Mar 2002
                    • 264

                    #10
                    No, he's right, if you create the directory in PHP running under apache, it'll be created with whatever usename Apache is running as. This means you'll be able to chmod or remove files from that directory in other scripts, since they will also be running as the same user.

                    If PHP's "safe_mode" is enabled all bets are off though.

                    b.
                    [this signature intentionally left blank]

                    Comment

                    • pornanza
                      Confirmed User
                      • Jul 2003
                      • 238

                      #11


                      ryan
                      Eskimo Hoe
                      QuickWank
                      Pornanza!

                      Comment

                      • myneid
                        Confirmed User
                        • Jan 2003
                        • 738

                        #12
                        Originally posted by - Jesus Christ -
                        wrong. And you certainly can't CHMOD...

                        before you try to flame, make sure you got the experience and knowledge under yer belt like buran.

                        a knowledge of the way permissions works on unix systems is really easy to grasp once you read about it.

                        if you do a mkdir through the web browser with a script it will be owned and have the same group as what apache is running on that server. that means that that user and group can do wahtaver it wants. which means that if you wrote another script to modify or delete that directory and you ran it throught he web browser it would run as user apache and would do waht you expect.
                        Tanguy 0x7a69 inc. Programmer/President/CEO
                        http://www.0x7a69.com
                        A Leader in Programming since 1996
                        PHP, Ruby on Rails, MySQL, PCI DSS, and any Technical Consulting

                        Comment

                        • - Jesus Christ -
                          Confirmed User
                          • Mar 2003
                          • 7197

                          #13
                          Originally posted by myneid



                          before you try to flame, make sure you got the experience and knowledge under yer belt like buran.

                          a knowledge of the way permissions works on unix systems is really easy to grasp once you read about it.

                          if you do a mkdir through the web browser with a script it will be owned and have the same group as what apache is running on that server. that means that that user and group can do wahtaver it wants. which means that if you wrote another script to modify or delete that directory and you ran it throught he web browser it would run as user apache and would do waht you expect.
                          heh
                          You try it..... I have. It doesnt work. But maybe I'm running safe mode.

                          I'm not flaming you fucking pile of stink.
                          Your mother wears combat boots.

                          PWNED.

                          Amen

                          Comment

                          • JDog
                            Confirmed User
                            • Feb 2003
                            • 7453

                            #14
                            Originally posted by myneid



                            before you try to flame, make sure you got the experience and knowledge under yer belt like buran.

                            a knowledge of the way permissions works on unix systems is really easy to grasp once you read about it.

                            if you do a mkdir through the web browser with a script it will be owned and have the same group as what apache is running on that server. that means that that user and group can do wahtaver it wants. which means that if you wrote another script to modify or delete that directory and you ran it throught he web browser it would run as user apache and would do waht you expect.
                            This is correct. And the fact that alex wants to chmod it to 777, it will allow the user to write in this directory as anybody! What isn't possible is a CHOWN, unless the user running apache is a superuser! Just my

                            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

                            • buran
                              Confirmed User
                              • Mar 2002
                              • 264

                              #15
                              This is correct. And the fact that alex wants to chmod it to 777, it will allow the user to write in this directory as anybody! What isn't possible is a CHOWN, unless the user running apache is a superuser!
                              Not quite, if the directory in question is owned by the same user that apache is running as (user web, www, etc) then you can chmod it. It could even rmdir that directory, if it's empty.
                              [this signature intentionally left blank]

                              Comment

                              • JDog
                                Confirmed User
                                • Feb 2003
                                • 7453

                                #16
                                Originally posted by buran


                                Not quite, if the directory in question is owned by the same user that apache is running as (user web, www, etc) then you can chmod it. It could even rmdir that directory, if it's empty.
                                Yea the apache user can chmod it to 777, then it will be writable by other users as well. I don't think I was clear in the earilier post! And you are correct the apache user can do a rmdir if it's empty!

                                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

                                • ZakAttack
                                  Confirmed User
                                  • Sep 2003
                                  • 350

                                  #17
                                  Can't you just use shell_exec http://www.php.net/manual/en/function.shell-exec.php

                                  and commands to change what needs to be changed?

                                  Comment

                                  • JDog
                                    Confirmed User
                                    • Feb 2003
                                    • 7453

                                    #18
                                    Originally posted by ZakAttack
                                    Can't you just use shell_exec http://www.php.net/manual/en/function.shell-exec.php

                                    and commands to change what needs to be changed?

                                    It will do the same thing and create the directory with the same user apache is running as!

                                    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

                                    • swedguy
                                      Confirmed User
                                      • Jan 2002
                                      • 7981

                                      #19
                                      If you really need to run scripts as another user than the default Apache user.

                                      Install suexec.
                                      Set User and Group in httpd.conf to the correct user.
                                      Install the CGI version of PHP, make sure it's NOT the CLI version.
                                      Rename your php scripts to .cgi
                                      Add " #!/usr/local/bin/php-cgi " or what ever you named the cgi version, at the top of your scripts.

                                      Voila!

                                      Comment

                                      Working...