The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Create directory's and files in a user account

Discussion in 'cPanel Developers' started by LindyH, Dec 26, 2007.

  1. LindyH

    LindyH Registered

    Joined:
    Nov 23, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Gent Belgium
    Hi there.
    I am writing a plug in for hosting shoutcast servers. This is designed in 2 parts, the module that let customers start stop the server and start an auto DJ when they don't play music life. But I also am making a module named shoutadmin for our resellers. This last one gives me some problems.

    When I add a customer to the database I use for central management the resellers plugin also need to create some directory's and a few files in the user account. But when I try that from PHP it gives an access denied error when I use normal PHP file and directory functions.

    How can I do this?

    I suppose I need to use xmlapi and api2 calls to do this what wont be a problem.
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Have you considered using a skeleton directory to create the files/folders in the new accounts?
     
  3. LindyH

    LindyH Registered

    Joined:
    Nov 23, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Gent Belgium
    The idea is to use the shoutadmin module to add shoutcast servers also to existing accounts. But maybe I can use Cpanel::Fileman::fileop function to move the files/folders to the user account. If I can use that function to move around folders.
    Developing these plug ins is a lot of fun, when you know perl or PHP its not even that difficult. A little bit more information about some of the functions wood help a lot I think.

    What I still don't know is this. Are the api2 functions the only one I can use? When I was reading the examples of xmlapi there is an example about using api1 functions. But I don't find a list of those?

    While I am working on this, I am making my own class for using xmlapi and work in every function I can find if it is possible to use api1 functions a list of those wood be very useful.
     
  4. LindyH

    LindyH Registered

    Joined:
    Nov 23, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Gent Belgium
    Hi David.
    I figured it out, in fact it is so logical I am deep ashamed I did not see it before. :(
    I broke my head about the fact the normal shoucast module was working but the administrative module went completely crazy. Knowing what I know now it is so logical.
    When my shoutcast plug in runs it works from the user account and then it is able to do what ever it wants. But the administrative works from a reseller and then everything is turned because of the privilege system. I add the why and how I overcome the problem here so when people have the same problem they don't need to look for it so long!

    When I told everything changes when you want to run your plug in from a reseller. And you need to use low level file management from PHP, the first problem you run into is this. When cPanel creates an account it gives it 711 privilege. This makes it so the reseller cant write files to the account from the plug in.
    For my plug in I overcome this by adding a skeleton folder. (Thank you for that sollution David!) While the reseller creates the account. This folder I give 771 privilege and I make the reseller part of the group. The plug in can now use this folder to do the work.
    This is an easy solution for my work, but its not the only one! You can use owner and group name for example. Playing around with the privilege system you can do a lot of things, even make it so the owner cant change anything in the folder you use for your work. :D

    I hope people find this useful!
     
Loading...

Share This Page