Current File : //etc/zpanel/panel/modules/ssl/code/SSL_Mail.php
<?php
require('/etc/sentora/panel/cnf/db.php');
include('/etc/sentora/panel/dryden/db/driver.class.php');
include('/etc/sentora/panel/dryden/debug/logger.class.php');
include('/etc/sentora/panel/dryden/runtime/dataobject.class.php');
include('/etc/sentora/panel/dryden/runtime/hook.class.php');
include('/etc/sentora/panel/dryden/runtime/hash.class.php');
include('/etc/sentora/panel/dryden/sys/versions.class.php');
include('/etc/sentora/panel/dryden/ctrl/options.class.php');
include('/etc/sentora/panel/dryden/ctrl/users.class.php');
include('/etc/sentora/panel/dryden/ctrl/auth.class.php');
include('/etc/sentora/panel/dryden/fs/director.class.php');
include('/etc/sentora/panel/dryden/fs/filehandler.class.php');
include('/etc/sentora/panel/inc/dbc.inc.php');

try
{
    $zdbh = new db_driver("mysql:host=" . $host . ";dbname=" . $dbname . "", $user, $pass);
        $mysqli=mysqli_connect($host,$user, $pass);
} catch (PDOException $e) {
exit();
}

$domain = $argv[1];
$to_email_id = $argv[2];
shell_exec(" /usr/local/letsencrypt/./certbot-auto certificates > /var/log/letsencrypt/sslrenew.log");
$domain_certbot = shell_exec("grep -ni 'Domains' /var/log/letsencrypt/sslrenew.log");
$line_cerbot = explode("\n",$domain_certbot);
$line=array();
$domain_list=array();
foreach($line_cerbot as $key=>$value)
        {
                if(trim($value)!="")
                {
                        $line_num = explode(":", $value);
                        $line[] = trim($line_num[0]) + 3;
                        $domain_list_temp=explode(":",$value);
                        $domain_list_temp1=explode(",",$domain_list_temp[2]);
                        $domain_list[]=trim($domain_list_temp1[0]);
                }
        }
        foreach($domain_list as $key=>$value)
        {
                if(trim($value)!="")
                {
                        $domain_lists_temp=explode(" ",$value);
                        $domain_lists[]=trim($domain_lists_temp[0]);
                }
        }
        if((in_array(trim($domain) ,$domain_lists)))
        {
			shell_exec("echo 'completed' > /var/log/letsencrypt/$domain.log");
            $res = "success";
        }
        else
        {
            global $zdbh;
            echo $domain."\n";
            echo "UPDATE x_ssl SET ssl_status='-1' WHERE ssl_doamin=$domain AND ssl_delete IS NULL \n";
            $numrows = $zdbh->prepare("UPDATE x_ssl SET ssl_status='-1' WHERE ssl_doamin=:domain AND ssl_status=0 AND ssl_delete IS NULL");
            $numrows->bindParam(':domain', $domain);
            $ret = $numrows->execute();
            echo $ret."\n";
			shell_exec("echo 'failed' > /var/log/letsencrypt/$domain.log");
            $res = "failed";
        }
        $email_id = "support@hostingraja.in";
        $cc = "aisa.hostingraja@gmail.com";
        $headers = "From: $email_id" . "\r\n" ;
        $headers .= "CC: $cc" . "\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
        $subject = "HostingRaja - SSL status for $domain";
        if($res == "success")
        {
            $body = "Dear Client,<br><br> SSL successfully installed for your  domain $domain . Kindly Check it, If its not working contact our HostingRaja support team. <br><br><br><br> Thank You.";
        }
        else
        {
            $body = "Dear Client,<br><br> We are not able to install SSL for your  domain $domain . For more details check log on /var/log/letsencrypt/letsencrypt.log Kindly contact our HostingRaja support team. <br><br><br><br> Thank You.";
        }
        if (mail($to_email_id,$subject,$body,$headers))
        {
            echo "mail sent with email body $body to $to_email_id \n" ;
        }
        else
            echo "mail not sent with email body $body to $to_email_id \n" ;

?>