Zubrag.com :: Forum

zubrag.com => cPanel Scripts => Topic started by: smithster on July 29, 2007, 06:55:17 AM



Title: All in One script to do the opposite!!
Post by: smithster on July 29, 2007, 06:55:17 AM
I've come up with an all in one script that works perfect.  I'll post here for all incase anyone wants it.  But I wondered if someone could do something for me in return?

Basically, I want to use 1 script that will reverse the whole lot of what this script does.  So, delete the subdomain, delete the database user, delete the database, delete the mail account and delete the ftp account.  If someone could come up with this, I would be so grateful.

Thanks in advance.

Here's the all in one script to set everything up.  Remember, cURL does need to be installed.
// cPanel username
$cpanel_user = "*****";

// cPanel password
$cpanel_password = "*****";

// cPanel host
$cpanel_host = "*****";

// cPanel theme/skin, usually "x"

$cpanel_skin = "x";

// Path to cURL on your server
$curl_path = "/usr/bin/curl";

// Set Up The Customer's Web Hosting Account
$database = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$user_name'");
$adduser = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adduser.html?user=$user_name&pass=$password'");
$asignuser = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/addusertodb.html?user=$cpanel_user_$user_name&db=$cpanel_user_$user_name&SELECT=SELECT&CREATE=CREATE&INSERT=INSERT&ALTER=ALTER&UPDATE=UPDATE&DROP=DROP&LOCKTABLES=LOCK&INDEX=INDEX&REFERENCES=REFERENCES&CREATETEMPORARYTABLES=TEMPORARY'");
$subdm = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/subdomain/doadddomain.html?domain=$subdomain1&rootdomain=arenasmithster.co.uk'");
$email = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/mail/doaddpop.html?email=$user_name&domain=$user_name.arenasmithster.co.uk&password=$password&quota=20'");
$ftp = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/ftp/doaddftp.html?login=$user_name&password=$password&homedir=$subdomain1&quota=2000'");


Title: Re: All in One script to do the opposite!!
Post by: zubrag on July 30, 2007, 07:25:04 AM
Hi. Thanks for sharing.

We are working on the "delete" items (as a part of cPanel Toolbox script which would combine adding/deleting a lot of cPanel stuff). Should be complete next week or two.


Title: Re: All in One script to do the opposite!!
Post by: smithster on September 05, 2007, 05:09:37 PM
Just wondering how far you've gotten with the "cPanel Toolbox script"?  If you need anyone to test out any scripts you make to work with cPanel, feel free to give me a shout.

Cheers

Smithster.


Title: Re: All in One script to do the opposite!!
Post by: zubrag on September 10, 2007, 09:32:28 AM
Hi Smithster. It is taking longer than expected as i had not enough time for this tool.
1) Trying to make it modular (i.e. uploading new file would extend functionality, including interface).
2) Will implement a kind of scripting, so you could create a list of actions. Like CREATE ACCOUNT .... ADD FTP .... CREATE EMAIL ACCOUNT ... etc.
Most likely will finish #1 this weekend and post on Monday. #2 maybe next weekend.


Title: Re: All in One script to do the opposite!!
Post by: smithster on September 11, 2007, 06:47:04 AM
ok no probs, thanks for the update.  I will keep a lookout.


Title: Re: All in One script to do the opposite!!
Post by: zubrag on September 17, 2007, 07:16:36 AM
Update. It appears #2 must be implemented along with #1, as these things are closely connected. Will try to finish by the end of this week.


Title: Re: All in One script to do the opposite!!
Post by: smithster on September 17, 2007, 03:55:52 PM
Thought that may be the case but didn't say because any work you do with these scripts is much appreciated anyway.  I haven't had any further a look at them to be honest as I've been too busy lately!!  But thanks for the update.  I'll check back in a week to see how you have got on.

One question though, if for some reason, an account needed to be suspended, what do you think would be the best method for this?  The only thing I could think of was to temperarily delete the subdomain in cpanel?


Title: Re: All in One script to do the opposite!!
Post by: zubrag on September 18, 2007, 02:59:22 AM
Smithster, i could not find info on how subdomains are suspended. Looks like only whole account can be suspended via cPanel WHM (admin for cPanel accounts). I believe deleting subdomain is not good as it may delete all the data from subdomain folder. I would suggest adding password protection on subdomain (i.e. protect subdomain folder with password in cPanel), and maybe change subdomain access password so that user could not log in.


Title: Re: All in One script to do the opposite!!
Post by: smithster on September 20, 2007, 04:41:34 AM
Yep, I could do that.  Just password the subdomain folder, giving no access.  That's good enough for me!  Thanks for that.


Title: cPanel Accounts Manager (cPanel Toolbox)
Post by: zubrag on September 25, 2007, 05:47:57 AM
cPanel Accounts Manager (Toolbox) (http://www.zubrag.com/downloads/cpanel_toolbox.zip) available for download. Archive consists of three files and plugins folder:
cpanel_toolbox.php - class (functions) for internal use
cpanel_help.php - open this in browser to see the list of available plugins as well as list of fields for each plugin. You'll need this info for creating your own configurations
cpanel.php - sample cPanel Toolbox usage. I tried to be as descriptive as I could, read comments.

Unfortunately did not have time to write help for the Toolbox yet. Hope to have time for this soon.

Comments/suggestions are welcome.


Title: Re: All in One script to do the opposite!!
Post by: smithster on September 26, 2007, 02:38:02 PM
Thank you very much.  Nice work.  I'll take a look at that over weekend.  And I will report my feedback to you after.

Thanks again.

Smithster.


Title: Re: All in One script to do the opposite!!
Post by: smithster on October 11, 2007, 12:57:50 PM
Do you plan to work some more on this "Cpanel Toolbox"??  I tried it, but got some errors.  Took a look at the scripts but didn't really understand much about them.  I noticed that you were using something completely different to mine.  I use Curl to do all the work.  I'm still working on a script to reverse it all though.  Like delete a whole account at the click of a single button!


Title: Re: All in One script to do the opposite!!
Post by: zubrag on October 12, 2007, 10:51:32 AM
Hi. Yes, i'll continue this weekend. Current script is tuned more for accepting user input and creating different things (but it has some delete modules yet, like ftp, subdomain, forwarder, email, etc.).

It currently can work with cPanel via sockets and via url. cURL is not yet supported. Will add later.

The things you need will look similar to following (depends on how you name users, databases, subdomains, etc.). When you save as php file, and open this in browser it would show you few forms requesting data (to be deleted in this case)

<?php

// Include cPanel toolbox functions
include("cpanel_toolbox.php");

// Using these plugins. Each plugin has its own set of fields.
// Combine plugins here according to what you want to achieve
$PROMPT = array(
  'DELETE-SUBDOMAIN',
  'DELETE-DATABASE',
  'DELETE-DATABASE-USER',
  'DELETE-USER-FROM-DATABASE',
  'DELETE-FTP',
  'DELETE-EMAIL',
);

// Initialize cpanel functions (username, password, domain, skin /default x/, port /default 2082/)
$cp = new cPanelToolbox("user","12345","example.com");
$cp->setMethod("url"); // cPanel requiest method. Try "socket" if "url" does not work
$cp->setPromptFor($PROMPT); // List of plugins to use

// show form
if (!isset($_REQUEST['submit'])) {
  $cp->generateHTML();
}
// or process data
else {
  $cp->processFormData();
}

?>


Title: Re: All in One script to do the opposite!!
Post by: smithster on October 25, 2007, 03:15:35 PM
Thanks for your reply there.  I'll definately have another go with the scripts you have made.  Just now though I am still using the script I posted here first to create accounts based on user input.  I'm having one problem I wonder if you might be able to fix?

Somestimes accounts are setup correctly.  I'd say more than 50% of the time, email is not setup.  The only reason for this I can think of is maybe the script is struggling to keep up!  When that script is executed, it generally takes around 20-30 seconds for it to complete.  Is there something I can do to maybe split each "exec" function with a delay in between.  Like an interval which tells the server to hold for a second before moving on to the next stage.  Database and FTP all works perfectly but these do not rely on the subdomain to be created for them to work.  However the email does.

I hope you know what I mean!

Thanks.

Smithster.


Title: Re: All in One script to do the opposite!!
Post by: zubrag on October 26, 2007, 02:25:27 AM
Try putting sleep(NNN); where the script should wait. NNN - number of seconds.


Title: Re: All in One script to do the opposite!!
Post by: teamcoltra on January 20, 2008, 03:13:02 PM
The setup is slightly confusing, it put in all my correct info that i use for all your scripts but when i put in everything and load the page it comes up blank. I think its because i am using the new cpanel


Title: Re: All in One script to do the opposite!!
Post by: zubrag on January 21, 2008, 08:07:43 AM
Setup is confusing indeed. Will need to create user interface for cPanel toolbox.


Title: Re: All in One script to do the opposite!!
Post by: Akim13 on October 28, 2008, 06:52:03 AM
   
Hello,
I'm not very good in English

I download this script
http://www.zubrag.com/downloads/cpanel_toolbox.zip

I get an error when creating a database with user.

The database has been set up correctly, but also the user without the password.

while the default password is pas123

I have this error message

Sorry, the password you selected cannot be used because it is too weak and would be too easy to crack. Please select a password with strength rating of 5 or higher.


Can you help me please

(http://img122.imageshack.us/img122/606/errorzt5.jpg) (http://imageshack.us)
(http://img122.imageshack.us/img122/errorzt5.jpg/1/w666.png) (http://g.imageshack.us/img122/errorzt5.jpg/1/)

Thanks,