Zubrag.com
October 23, 2019, 03:25:42 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: All in One script to do the opposite!!  (Read 30074 times)
smithster
Web Trade Pro
Newbie
*
Posts: 27


WWW
« 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'");

Logged

S
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #1 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.
Logged
smithster
Web Trade Pro
Newbie
*
Posts: 27


WWW
« Reply #2 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.
Logged

S
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #3 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.
Logged
smithster
Web Trade Pro
Newbie
*
Posts: 27


WWW
« Reply #4 on: September 11, 2007, 06:47:04 AM »

ok no probs, thanks for the update.  I will keep a lookout.
Logged

S
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #5 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.
Logged
smithster
Web Trade Pro
Newbie
*
Posts: 27


WWW
« Reply #6 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?
Logged

S
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #7 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.
Logged
smithster
Web Trade Pro
Newbie
*
Posts: 27


WWW
« Reply #8 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.
Logged

S
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #9 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.
Logged
smithster
Web Trade Pro
Newbie
*
Posts: 27


WWW
« Reply #10 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.
Logged

S
smithster
Web Trade Pro
Newbie
*
Posts: 27


WWW
« Reply #11 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!
Logged

S
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #12 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();
}

?>
Logged
smithster
Web Trade Pro
Newbie
*
Posts: 27


WWW
« Reply #13 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.
Logged

S
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC