- Created `Articles` class for rendering article views including full articles, miniature lists, and news sections. - Added `Banners` class for handling banner displays. - Introduced `Languages` class for rendering language options. - Implemented `Menu` class for rendering page and menu structures. - Developed `Newsletter` class for newsletter rendering. - Created `Scontainers` class for rendering specific containers. - Added `ShopCategory` class for managing shop category views and pagination. - Implemented `ShopClient` class for client-related views including address management and login forms. - Created `ShopPaymentMethod` class for displaying payment methods in the basket. - Added `ShopProduct` class for generating product URLs. - Introduced `ShopSearch` class for rendering a simple search form. - Added `.htaccess` file in the plugins directory to enhance security by restricting access to sensitive files and directories.
82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
namespace Shared\Email;
|
|
|
|
class Email
|
|
{
|
|
public $table = 'pp_newsletter_templates';
|
|
|
|
public function load_by_name( string $name )
|
|
{
|
|
global $mdb;
|
|
|
|
$result = $mdb -> get( $this -> table, '*', [ 'name' => $name ] );
|
|
if ( is_array( $result ) ) foreach ( $result as $key => $val )
|
|
$this -> $key = $val;
|
|
}
|
|
|
|
public function email_check( $email )
|
|
{
|
|
return filter_var( $email, FILTER_VALIDATE_EMAIL );
|
|
}
|
|
|
|
public function send( string $email, string $subject, bool $newsletter_headers = false, string $file = null )
|
|
{
|
|
global $settings;
|
|
|
|
if ( $newsletter_headers )
|
|
{
|
|
$text = $settings['newsletter_header'];
|
|
$text .= $this -> text;
|
|
$text .= $settings['newsletter_footer'];
|
|
}
|
|
else
|
|
$text = $this -> text;
|
|
|
|
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
|
$text = preg_replace( $regex, "$1https://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
|
|
|
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
|
$text = preg_replace( $regex, "$1https://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
|
|
|
if ( $this -> email_check( $email ) and $subject )
|
|
{
|
|
$mail = new \PHPMailer();
|
|
$mail -> IsSMTP();
|
|
$mail -> SMTPAuth = true;
|
|
$mail -> Host = $settings['email_host'];
|
|
$mail -> Port = $settings['email_port'];
|
|
$mail -> Username = $settings['email_login'];
|
|
$mail -> Password = $settings['email_password'];
|
|
$mail -> CharSet = "UTF-8";
|
|
$mail -> SMTPOptions = array(
|
|
'ssl' => array(
|
|
'verify_peer' => false,
|
|
'verify_peer_name' => false,
|
|
'allow_self_signed' => true
|
|
)
|
|
);
|
|
$mail -> AddReplyTo( $settings['contact_email'], $settings['firm_name'] );
|
|
$mail -> SetFrom( $settings['contact_email'], $settings['firm_name'] );
|
|
$mail -> AddAddress( $email, '' );
|
|
$mail -> Subject = $subject;
|
|
$mail -> Body = $text;
|
|
if ( is_array( $file ) )
|
|
{
|
|
foreach ( $file as $file_tmp )
|
|
{
|
|
if ( file_exists( $file_tmp ) )
|
|
$mail -> AddAttachment( $file_tmp );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( file_exists( $file ) )
|
|
$mail -> AddAttachment( $file );
|
|
}
|
|
$mail -> IsHTML( true );
|
|
return $mail -> Send();
|
|
}
|
|
return false;
|
|
}
|
|
}
|