Jump to content
  • 0

Send an email if suspension fails


Lampard

Question

Hello,

As Blesta doesn't have WHMPHP module, i use normal cPanel module of Blesta and upgrade the account to reseller after the order is activated.
Now whenever i try to suspend the order, i get an error "Permission Denied", so on renewal too, it will miss the date and an account will not be suspended which can be a very big problem.

However Paul told me to create a thread in this section so people and soon he will be able to help out about modification of built-in cPanel module to send an email to specific address whenever suspension of cPanel account is failed.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

In /components/modules/cpanel/cpanel.php look for the suspend method. It'll look like this:

    public function suspendService($package, $service, $parent_package = null, $parent_service = null)
    {
        // suspendacct / suspendreseller ($package->meta->type == "reseller")

        $row = $this->getModuleRow();

        if ($row) {
            $api = $this->getApi($row->meta->host_name, $row->meta->user_name, $row->meta->key, $row->meta->use_ssl);

            $service_fields = $this->serviceFieldsToObject($service->fields);

            if ($package->meta->type == 'reseller') {
                $this->log(
                    $row->meta->host_name . '|suspendreseller',
                    serialize($service_fields->cpanel_username),
                    'input',
                    true
                );
                $this->parseResponse($api->suspendreseller($service_fields->cpanel_username));
            } else {
                $this->log(
                    $row->meta->host_name . '|suspendacct',
                    serialize($service_fields->cpanel_username),
                    'input',
                    true
                );
                $this->parseResponse($api->suspendacct($service_fields->cpanel_username));
            }
        }

        return null;
    }

Change this so it doesn't try to suspend with cpanel 

public function suspendService($package, $service, $parent_package = null, $parent_service = null)
    {
            return;
    }

Now, if you want to send an email to yourself, send the email before returning. Here's a very  dirty way of doing it. I have not tested it.

public function suspendService($package, $service, $parent_package = null, $parent_service = null)
    {
            $service_fields = $this->serviceFieldsToObject($service->fields);
            
            $to = 'nobody@example.com';
            $subject = 'the subject';
            $message = $service_fields->cpanel_username;
            $headers = 'From: webmaster@example.com' . "\r\n" .
                       'Reply-To: webmaster@example.com' . "\r\n";
            mail($to, $subject, $message, $headers);
            return;
    }

 

Link to comment
Share on other sites

  • 0
public function suspendService($package, $service, $parent_package = null, $parent_service = null)
    {
        // suspendacct / suspendreseller ($package->meta->type == "reseller")

        $row = $this->getModuleRow();

        if ($row) {
            $api = $this->getApi($row->meta->host_name, $row->meta->user_name, $row->meta->key, $row->meta->use_ssl);

            $service_fields = $this->serviceFieldsToObject($service->fields);

            if ($package->meta->type == 'reseller') {
                $this->log(
                    $row->meta->host_name . '|suspendreseller',
                    serialize($service_fields->cpanel_username),
                    'input',
                    true
                );
                $this->parseResponse($api->suspendreseller($service_fields->cpanel_username));
            } else {
                $this->log(
                    $row->meta->host_name . '|suspendacct',
                    serialize($service_fields->cpanel_username),
                    'input',
                    true
                );
                 $to = 'nobody@example.com';
                 $subject = 'the subject';
                 $message = $service_fields->cpanel_username;
                 $headers = 'From: webmaster@example.com' . "\r\n" .
                       'Reply-To: webmaster@example.com' . "\r\n";
                 mail($to, $subject, $message, $headers);
                 return;
            }
        }

        return null;
    }

maybe

Link to comment
Share on other sites

  • 0
 public function unsuspendService($package, $service, $parent_package = null, $parent_service = null)
    {
        // unsuspendacct / unsuspendreseller ($package->meta->type == "reseller")

        if (($row = $this->getModuleRow())) {
            $api = $this->getApi($row->meta->host_name, $row->meta->user_name, $row->meta->key, $row->meta->use_ssl);

            $service_fields = $this->serviceFieldsToObject($service->fields);

            if ($package->meta->type == 'reseller') {
                $this->log(
                    $row->meta->host_name . '|unsuspendreseller',
                    serialize($service_fields->cpanel_username),
                    'input',
                    true
                );
                $this->parseResponse($api->unsuspendreseller($service_fields->cpanel_username));
            } else {
                $this->log(
                    $row->meta->host_name . '|unsuspendacct',
                    serialize($service_fields->cpanel_username),
                    'input',
                    true
                );
                 $to = 'nobody@example.com';
                 $subject = 'the subject';
                 $message = $service_fields->cpanel_username;
                 $headers = 'From: webmaster@example.com' . "\r\n" .
                       'Reply-To: webmaster@example.com' . "\r\n";
                 mail($to, $subject, $message, $headers);
                 return;
            }
        }
        return null;
    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...