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, $replay = '', $file = '' ) { global $settings; $base = dirname( dirname( dirname( __DIR__ ) ) ); if ( file_exists( $base . '/libraries/phpmailer/class.phpmailer.php' ) ) require_once $base . '/libraries/phpmailer/class.phpmailer.php'; if ( file_exists( $base . '/libraries/phpmailer/class.smtp.php' ) ) require_once $base . '/libraries/phpmailer/class.smtp.php'; $text = $this->text; $regex = "-(]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i"; $text = preg_replace( $regex, "$1https://" . $_SERVER['SERVER_NAME'] . "$2$4", $text ); $regex = "-(]+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 ) ); if ( $this->email_check( $replay ) ) { $mail->AddReplyTo( $replay, $replay ); $mail->SetFrom( $settings['contact_email'], $settings['contact_email'] ); } else { $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; } }