Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Suspend account page

Discussion in 'cPanel Developers' started by deviantlinux, Feb 26, 2008.

  1. deviantlinux

    deviantlinux Member

    Feb 26, 2008
    Likes Received:
    Trophy Points:
    I wrote this script a while ago, thought I would post it here for anyone who needs something similar. This will take input for the domain to suspend ( and will get XML output and suspend the domain. It needs PHP 5.0 or later.

    *   This code written by deviantlinux.
    * -------------------------------------------------------
    *   Description:
    *   This was written so a user can enter a domain they need to suspend,
    *   and using the XML api that cPanel provides, it will get info on that
    *   particular domain, grab the user name, and suspend the domain using
    *   a URL.
    * -------------------------------------------------------
    *   Requirements:
    *   This code requires PHP 5.0 or later, because
    *   of the simplexml_load_file function.
    //                  You MUST edit the following!
    // ------------------------------------------------------------
    $mySite = ""; // Your domain name
    $myCpanelLoc = ""; // Your cPanel WHM website
    $cPanelUser = "root"; // Your cPanel username (usually root)
    $cPanelPass = "mypass321"; // Your cPanel Password
    $myEmail = "";
    $acctdomain = $_POST['domain'];
    $reason = $_POST['reason'];
    if (!isset($_POST['submit'])) { 
    // Show main page before submit is hit.
    <title>Suspend a domain</title>
    <body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
    <div align="center">
    <h2>Suspend a domain</h2>
    <b><? echo $mySite; ?></b>
    <table width="100%" height="18" cellpadding="0" cellspacing="0" border="0">
    <td align="center"></td>
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <form  method="post" action="<? echo $PHP_SELF; ?>">
        <td width="35%"><b><font color="red">*</font>&nbsp;Domain to suspend:</b></td>
        <td><input type="text" name="domain" style="border:2px solid black;width:200px;"></td>
        <td width="35%"><b>Reason:</b></td>
        <td><input type="text" name="reason" style="border:2px solid black;width:200px;"></td>
    <div align="center">
    <input type="submit" value="Send" name="submit">&nbsp;&nbsp;
    <input type="reset" value="Reset">
    } else 
    $acctdomain = $_POST['domain'];
    $reason = $_POST['reason'];
        echo "<div align='center'>";
          echo "You didn't fill in a required field!<br>";
          echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
        echo "</div>";
    // Action to grab raw XML data from cPanel XML api, and get user name from inputted domain.
    $request_url = "http://$cPanelUser:$cPanelPass@$myCpanelLoc/xml-api/listaccts?searchtype=domain&search=$acctdomain";
    $xml = simplexml_load_file($request_url) or die("Error: XML feed not loading.  Please notify a system administrator!");
    // Now exchange XML data for individual strings.
    $user = $xml->acct->user;
    $domain = $xml->acct->domain;
    $disklimit = $xml->acct->disklimit;
    $diskused = $xml->acct->diskused;
    $email = $xml->acct->email;
    $ip = $xml->acct->ip;
    $owner = $xml->acct->owner;
    $partition = $xml->acct->partition;
    $plan = $xml->acct->plan;
    $startdate = $xml->acct->startdate;
    $theme = $xml->acct->theme;
    $unix_startdate = $xml->acct->unix_startdate;
    echo "<h2>Account Suspension</h2>";
    echo "User data obtained.<br>";
    // Email our suspendee to let him know
    $subject = "Account suspended at $mySite";
    $message = "Hello,\n\n
    This email is to let you know that your site $domain, hosted at 
    $mySite has been suspended.  Please contact us as soon as possible 
    so we can discuss your options.
    Username: $user
    Domain: $domain
    Account Plan: $plan
    Account Start Date: $startdate
    $headers = "From: $myEmail";
    // Show info...
    echo "Email sent to <b>$user</b> at address <b>$email</b>.<br><br>";
    echo "Suspending domain <b>$domain</b>...<br><br>";
    // Replace spaces with %20 for successful URL load
    $reason = ereg_replace(" ","%20",$reason2);
    $script = "http://$cPanelUser:$cPanelPass@$myCpanelLoc/scripts2/suspendacct?domain=$user&user=$user&reason=$reason2&suspend-domain=Suspend";
    $result = file_get_contents($script);
    echo "<font color='green'><b>Account has been suspended!</b></font>";
    echo "<br><br>";
    // Show close window button
    echo "<div align='center'>";
    echo "<form>";
    echo "<input type='button' value='Close Window' onClick='window.close()'>";
    echo "</form>";
    #1 deviantlinux, Feb 26, 2008
    Last edited: Mar 26, 2009
  2. inverter

    inverter Registered

    Nov 24, 2009
    Likes Received:
    Trophy Points:
    Can you do this without logging in. I would love to use but...

    So what if your website in hacked? Now they have your WHM user name and password.


Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice