Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Feb 2008
    Posts
    7

    Wink Suspend account page

    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 (subdomain.yourhosting.com) and will get XML output and suspend the domain. It needs PHP 5.0 or later.

    Code:
    <?php
    /* 
    *   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 = "Mysite.com"; // Your domain name
    $myCpanelLoc = "mysitehosting.com:2086"; // Your cPanel WHM website
    $cPanelUser = "root"; // Your cPanel username (usually root)
    $cPanelPass = "mypass321"; // Your cPanel Password
    $myEmail = "billing@mysite.com";
    
    $acctdomain = $_POST['domain'];
    $reason = $_POST['reason'];
    
    if (!isset($_POST['submit'])) { 
    // Show main page before submit is hit.
    ?>
    
    <html>
    <head>
    <title>Suspend a domain</title>
    </head>
    
    <body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
    
    <div align="center">
    <h2>Suspend a domain</h2>
    <b><? echo $mySite; ?></b>
    </div>
    
    <table width="100%" height="18" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td align="center"></td>
    </tr>
    </table>
    
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <form  method="post" action="<? echo $PHP_SELF; ?>">
      <tr>
        <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>
      </tr>
      <tr>
        <td width="35%"><b>Reason:</b></td>
        <td><input type="text" name="reason" style="border:2px solid black;width:200px;"></td>
      </tr>
    </table>
    
    <br>
    
    <div align="center">
    <input type="submit" value="Send" name="submit">&nbsp;&nbsp;
    <input type="reset" value="Reset">
    </form>
    </div>
    
    <? 
    } else 
    {
    $acctdomain = $_POST['domain'];
    $reason = $_POST['reason'];
    
    if($acctdomain=="")
      {
        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>";
      }
    
    elseif($acctdomain!="")
      {
    // 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
    
    
    Regards,
    $mySite";
    $headers = "From: $myEmail";
    mail($email,$subject,$message,$headers);
    
    // 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>";
      }
    
    }
    ?>
    
    </body>
    </html>
    Last edited by deviantlinux; 03-26-2009 at 02:04 PM. Reason: Took out problematic line

  2. #2
    Registered User
    Join Date
    Nov 2009
    Posts
    1

    Default

    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.


    Quote Originally Posted by deviantlinux View Post
    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 (subdomain.yourhosting.com) and will get XML output and suspend the domain. It needs PHP 5.0 or later.

    Code:
    <?php
    /* 
    *   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 = "Mysite.com"; // Your domain name
    $myCpanelLoc = "mysitehosting.com:2086"; // Your cPanel WHM website
    $cPanelUser = "root"; // Your cPanel username (usually root)
    $cPanelPass = "mypass321"; // Your cPanel Password
    $myEmail = "billing@mysite.com";
    
    $acctdomain = $_POST['domain'];
    $reason = $_POST['reason'];
    
    if (!isset($_POST['submit'])) { 
    // Show main page before submit is hit.
    ?>
    
    <html>
    <head>
    <title>Suspend a domain</title>
    </head>
    
    <body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
    
    <div align="center">
    <h2>Suspend a domain</h2>
    <b><? echo $mySite; ?></b>
    </div>
    
    <table width="100%" height="18" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td align="center"></td>
    </tr>
    </table>
    
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <form  method="post" action="<? echo $PHP_SELF; ?>">
      <tr>
        <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>
      </tr>
      <tr>
        <td width="35%"><b>Reason:</b></td>
        <td><input type="text" name="reason" style="border:2px solid black;width:200px;"></td>
      </tr>
    </table>
    
    <br>
    
    <div align="center">
    <input type="submit" value="Send" name="submit">&nbsp;&nbsp;
    <input type="reset" value="Reset">
    </form>
    </div>
    
    <? 
    } else 
    {
    $acctdomain = $_POST['domain'];
    $reason = $_POST['reason'];
    
    if($acctdomain=="")
      {
        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>";
      }
    
    elseif($acctdomain!="")
      {
    // 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
    
    
    Regards,
    $mySite";
    $headers = "From: $myEmail";
    mail($email,$subject,$message,$headers);
    
    // 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>";
      }
    
    }
    ?>
    
    </body>
    </html>

Similar Threads & Tags
Similar threads

  1. suspendacct to suspend account, what command to suspend reseller?
    By sodapopinski in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 04-06-2009, 10:06 AM
  2. default suspend page
    By ntwaddel in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 11-08-2005, 05:13 PM
  3. Suspend Page Problem
    By goldshop in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 10-27-2003, 02:37 PM
  4. suspend page stopped working
    By simplybe in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 10-26-2003, 01:44 AM
  5. suspend page no longer works
    By simplybe in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 10-05-2003, 07:59 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube