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.

Looking for some ideas

Discussion in 'General Discussion' started by butch, Jan 2, 2004.

  1. butch

    butch Active Member

    Joined:
    Jun 23, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    On all of my servers, we manually turn on Userdir for new clients for 2 weeks then disable it to protect us from bandwidth leeching. I am trying to get the new signup procedure more automated and want any ideas on how to automated the userdir issue.

    The httpd currently looks like this:

    <IfModule mod_userdir.c>
    UserDir disabled
    UserDir enabled username1 username2
    #userdir1
    </IfModule>

    I originally thought to use the reverse (UserDir enabled, and manually disabling) but that would make the disabled line very long.

    Does anyone have any suggestion on this?

    Thanks and happy new year to all!
     
  2. dgbaker

    dgbaker Well-Known Member
    PartnerNOC

    Joined:
    Sep 20, 2002
    Messages:
    2,578
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Toronto, Ontario Canada
    cPanel Access Level:
    DataCenter Provider
    You can use /scripts/postwwwacct

    This will allow it to be added when then user signs up.
     
  3. butch

    butch Active Member

    Joined:
    Jun 23, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Thanks for the suggestion.

    Would you or anyone else know how to add the code to postwwwacct to accomplish what I am looking for?
     
  4. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    The postwwwacct file doesn't exist until you create one. It's a script that gets called during account creation if it exists. To do what you want, you would need to write a cgi script (postwwwacct) that will add the user to the "UserDir enabled" line.

    You could even go one step farther and have the postwwwacct script write the usernames and dates to a txt file and when the line is changed, it only includes usernames less than 2 weeks old. That would automatically remove older ones each time a new account is created.
     
  5. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    I decided to throw together a simple script. Copy and paste this into a simple text editor and save it as postwwwacct with no extensions. Then upload it to the /scripts directory and chmod to 700.

    Rather than using this script, go to our "scripts club" at http://www.premierwebsitesolutions.com/scripts/ for the current version.

    Next time you create an account, the user will be added to the enabled line automatically. The original httpd.conf file will now be httpd.conf.prescript, just in case it's needed.

    If anyone else decides to use this script, make sure the httpd.conf file currently has the line starting with "UserDir enabled" or it won't do anything.
     
    #5 PWSowner, Jan 2, 2004
    Last edited: Mar 1, 2004
  6. butch

    butch Active Member

    Joined:
    Jun 23, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Mike, thanks for the script!

    I have sent you a PM regarding the script.
     
  7. butch

    butch Active Member

    Joined:
    Jun 23, 2003
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Mike,

    I added your code to my postwwwacct file. When I tried creating a test account from WHM, I got the following errors:

    PHP:
    Unquoted string "datafile" may clash with future reserved word at /scripts/postwwwacct line 175.
    Unquoted string 
    "datafile" may clash with future reserved word at /scripts/postwwwacct line 177.
    Unquoted string 
    "datafile" may clash with future reserved word at /scripts/postwwwacct line 183.
    Unquoted string 
    "datafile" may clash with future reserved word at /scripts/postwwwacct line 184.
    Unquoted string 
    "datafile" may clash with future reserved word at /scripts/postwwwacct line 185.
    Scalar value 
    @ARGV[1better written as $ARGV[1at /scripts/postwwwacct line 189.
    Unquoted string 
    "datafile" may clash with future reserved word at /scripts/postwwwacct line 192.
    Unquoted string 
    "datafile" may clash with future reserved word at /scripts/postwwwacct line 194.
    Global symbol "@lines" requires explicit package name at /scripts/postwwwacct line 176.
    Global symbol "$lrequires explicit package name at /scripts/postwwwacct line 179.
    Global symbol "@lines" requires explicit package name at /scripts/postwwwacct line 179.
    Global symbol "$lrequires explicit package name at /scripts/postwwwacct line 180.
    Global symbol "$lrequires explicit package name at /scripts/postwwwacct line 186.
    Global symbol "@lines" requires explicit package name at /scripts/postwwwacct line 186.
    Global symbol "$lrequires explicit package name at /scripts/postwwwacct line 188.
    Global symbol "$lrequires explicit package name at /scripts/postwwwacct line 189.
    Global symbol "$lrequires explicit package name at /scripts/postwwwacct line 189.
    Global symbol "$lrequires explicit package name at /scripts/postwwwacct line 192.
    Execution of 
    /scripts/postwwwacct aborted due to compilation errors.
    line 175 in my postwwwacct file is:

    open(datafile,"/usr/local/apache/conf/httpd.conf");

    Just thought you would like to know.
     
  8. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Sounds like you already had a postwwwacct file which is using PHP instead of perl. The code I wrote uses perl. PHP is different and not something I know well yet.
     
    #8 PWSowner, Jan 2, 2004
    Last edited: Jan 2, 2004
  9. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    I looked at the script you are using. Your current one is using "strict" which means variables need to be declared first. I kept mine short and simple, but it is easy to adjust. I'll do that now.
     
  10. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    The script I posted above will work fine by itself. If added to an existing one, it may need modifications. For yours, you are using the one from http://html.conclase.net/cp/scripts/. I made adjustments and added mine to his but the new file is too big to post here so I uploaded it to my site. You can get the modified version at link removed. Just save it and rename it without the .txt and it will now work for you.

    See post #
    97473 for URL.
     
    #10 PWSowner, Jan 3, 2004
    Last edited: Mar 1, 2004
  11. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    The changes I made were:

    - line 69: declared my variables
    - line 129: call my subroutine
    - lines 131 to 134: print that job was done
    - lines 138 to 163: my subroutine
     
  12. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    I've gone the next step. The new version even removes users whose accounts were created more than 14 days ago. It's easy to change the number of days. The more advanced script does require a slight modification to the httpd.conf file. Instructions are in the modified script which can be found at:
    link removed
    Rename it to postwwwacct and add 1 line to the httpd.conf file as instructed.

    That is Juanra's postwwwacct script modified. If you aren't using his script, or aren't using any script, my script by itself which can be used as is, or added to your current one, can be found at link removed which of course would be renamed to postwwwacct.

    See post #
    97473 for URL.
     
    #12 PWSowner, Jan 3, 2004
    Last edited: Mar 1, 2004
  13. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
Loading...

Share This Page