Version Description
New and shiny mail logger.
Download this release
Release Info
| Developer | yehudah |
| Plugin | |
| Version | 1.2 |
| Comparing to | |
| See all releases | |
Code changes from version 1.1.11 to 1.2
- assets/css/table.css +21 -0
- assets/images/details_close.png +0 -0
- assets/images/details_open.png +0 -0
- assets/js/table.js +127 -0
- composer.json +7 -0
- inc/Admin.php +128 -0
- inc/Config.php +39 -0
- inc/Db.php +134 -0
- inc/Logger/Process.php +46 -0
- inc/Logger/Table.php +61 -0
- readme.txt +12 -12
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- vendor/autoload.php +7 -0
- vendor/composer/ClassLoader.php +445 -0
- vendor/composer/LICENSE +21 -0
- vendor/composer/autoload_classmap.php +12 -0
- vendor/composer/autoload_namespaces.php +9 -0
- vendor/composer/autoload_psr4.php +10 -0
- vendor/composer/autoload_real.php +52 -0
- vendor/composer/autoload_static.php +38 -0
- wp-smtp.php +24 -18
- wp_smtp_admin.php +1 -1
assets/css/table.css
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
td.details-control {
|
| 2 |
+
background: url('../images/details_open.png') no-repeat center center;
|
| 3 |
+
cursor: pointer;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
tr.details td.details-control {
|
| 7 |
+
background: url('../images/details_close.png') no-repeat center center;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
#example_wrapper {
|
| 11 |
+
padding-top: 20px;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
#example_wrapper .dataTables_length {
|
| 15 |
+
padding-right: 10px;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
#example_wrapper .select-info {
|
| 19 |
+
padding-left: 5px;
|
| 20 |
+
font-weight: bold;
|
| 21 |
+
}
|
assets/images/details_close.png
ADDED
|
Binary file
|
assets/images/details_open.png
ADDED
|
Binary file
|
assets/js/table.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function format ( d ) {
|
| 2 |
+
return d.message;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
jQuery(document).ready(function($) {
|
| 6 |
+
var selectedIds = [];
|
| 7 |
+
var security = $('#md-security').data('security');
|
| 8 |
+
var dt = $('#example').DataTable( {
|
| 9 |
+
"idSrc": "mail_id",
|
| 10 |
+
rowId: 'mail_id',
|
| 11 |
+
select: true,
|
| 12 |
+
paging: true,
|
| 13 |
+
"pagingType": "full_numbers",
|
| 14 |
+
"processing": true,
|
| 15 |
+
"serverSide": true,
|
| 16 |
+
"ajax": wpsmtp.ajaxurl + '?action=wpsmtp_get_logs&security=' + security,
|
| 17 |
+
"columns": [
|
| 18 |
+
{
|
| 19 |
+
"class": "details-control",
|
| 20 |
+
"orderable": true,
|
| 21 |
+
"data": null,
|
| 22 |
+
"defaultContent": ""
|
| 23 |
+
},
|
| 24 |
+
{ "data": "to" },
|
| 25 |
+
{ "data": "timestamp" },
|
| 26 |
+
{ "data": "subject" },
|
| 27 |
+
{ "data": "error" },
|
| 28 |
+
],
|
| 29 |
+
"order": [[2, 'desc']],
|
| 30 |
+
dom: 'lBfrtip',
|
| 31 |
+
buttons: [
|
| 32 |
+
{ extend: 'copy', className: 'button' },
|
| 33 |
+
{ extend: 'csv', className: 'button' },
|
| 34 |
+
{
|
| 35 |
+
text: 'Delete Selected Rows',
|
| 36 |
+
className: 'button',
|
| 37 |
+
action: function ( e, dt, node, config ) {
|
| 38 |
+
var count = dt.rows( { selected: true } ).ids().toArray();
|
| 39 |
+
|
| 40 |
+
console.log( count.join(',') );
|
| 41 |
+
|
| 42 |
+
var button = $(e.target);
|
| 43 |
+
var security = $('#md-security').data('security');
|
| 44 |
+
|
| 45 |
+
$.ajax({
|
| 46 |
+
url: wpsmtp.ajaxurl + '?action=wpsmtp_delete_rows&ids=' + count.join(',') + '&security=' + security,
|
| 47 |
+
success : function(data){
|
| 48 |
+
//delete the row
|
| 49 |
+
dt.row('.selected').remove().draw( false );
|
| 50 |
+
},
|
| 51 |
+
error: function(xhr){
|
| 52 |
+
alert( 'There was an error delete the row' );
|
| 53 |
+
}
|
| 54 |
+
});
|
| 55 |
+
}
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
text: 'Delete All Rows',
|
| 59 |
+
className: 'button',
|
| 60 |
+
action: function ( e, dt, node, config ) {
|
| 61 |
+
|
| 62 |
+
var r = confirm( 'Are you sure you want to delete all log records?' );
|
| 63 |
+
|
| 64 |
+
if ( r === false ) {
|
| 65 |
+
return;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
var button = $(e.target);
|
| 69 |
+
var security = $('#md-security').data('security');
|
| 70 |
+
|
| 71 |
+
$.ajax({
|
| 72 |
+
url: wpsmtp.ajaxurl + '?action=wpsmtp_delete_all_rows&security=' + security,
|
| 73 |
+
success : function(data){
|
| 74 |
+
location.reload();
|
| 75 |
+
},
|
| 76 |
+
error: function(xhr){
|
| 77 |
+
alert( 'There was an error delete the row' );
|
| 78 |
+
}
|
| 79 |
+
});
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
]
|
| 83 |
+
} );
|
| 84 |
+
|
| 85 |
+
dt.on('select.dt', function(e, dt, type, indexes) {
|
| 86 |
+
selectedIds.push(indexes[0]);
|
| 87 |
+
})
|
| 88 |
+
|
| 89 |
+
dt.on('deselect.dt', function(e, dt, type, indexes) {
|
| 90 |
+
selectedIds.splice(selectedIds.indexOf(indexes[0]), 1);
|
| 91 |
+
})
|
| 92 |
+
|
| 93 |
+
// Array to track the ids of the details displayed rows
|
| 94 |
+
var detailRows = [];
|
| 95 |
+
|
| 96 |
+
$('#example tbody').on( 'click', 'tr td.details-control', function () {
|
| 97 |
+
var tr = $(this).closest('tr');
|
| 98 |
+
var row = dt.row( tr );
|
| 99 |
+
var idx = $.inArray( tr.attr('id'), detailRows );
|
| 100 |
+
|
| 101 |
+
if ( row.child.isShown() ) {
|
| 102 |
+
tr.removeClass( 'details' );
|
| 103 |
+
row.child.hide();
|
| 104 |
+
|
| 105 |
+
// Remove from the 'open' array
|
| 106 |
+
detailRows.splice( idx, 1 );
|
| 107 |
+
}
|
| 108 |
+
else {
|
| 109 |
+
tr.addClass( 'details' );
|
| 110 |
+
row.child( format( row.data() ) ).show();
|
| 111 |
+
|
| 112 |
+
// Add to the 'open' array
|
| 113 |
+
if ( idx === -1 ) {
|
| 114 |
+
detailRows.push( tr.attr('id') );
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
} );
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
// On each draw, loop over the `detailRows` array and show any child rows
|
| 121 |
+
dt.on( 'draw', function () {
|
| 122 |
+
$.each( detailRows, function ( i, id ) {
|
| 123 |
+
$('#'+id+' td.details-control').trigger( 'click' );
|
| 124 |
+
} );
|
| 125 |
+
} );
|
| 126 |
+
|
| 127 |
+
} );
|
composer.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"autoload": {
|
| 3 |
+
"psr-4": {
|
| 4 |
+
"WPSMTP\\":"inc/"
|
| 5 |
+
}
|
| 6 |
+
}
|
| 7 |
+
}
|
inc/Admin.php
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
namespace WPSMTP;
|
| 3 |
+
|
| 4 |
+
class Admin {
|
| 5 |
+
|
| 6 |
+
private $wsOptions;
|
| 7 |
+
|
| 8 |
+
public static $phpmailer_error;
|
| 9 |
+
|
| 10 |
+
public function __construct() {
|
| 11 |
+
$this->wsOptions = get_option( 'wp_smtp_options' );
|
| 12 |
+
|
| 13 |
+
add_action( 'admin_menu', array( $this, 'add_menu' ) );
|
| 14 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
| 15 |
+
add_action( 'wp_ajax_wpsmtp_get_logs', array( $this, 'wpsmtp_get_logs' ) );
|
| 16 |
+
add_action( 'wp_ajax_wpsmtp_delete_rows', array( $this, 'wpsmtp_delete_rows' ) );
|
| 17 |
+
add_action( 'wp_ajax_wpsmtp_delete_all_rows', array( $this, 'wpsmtp_delete_all_rows' ) );
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function add_menu() {
|
| 21 |
+
add_menu_page( __( 'WP SMTP'), __( 'WP SMTP'), 'manage_options', 'wp-smtp/wp-smtp.php', array( $this, 'render_setup_menu' ) );
|
| 22 |
+
add_submenu_page( 'wp-smtp/wp-smtp.php', __( 'Mail Logs'), __( 'Mail Logs'), 'manage_options','wpsmtp_logs', array( $this, 'render_log_menu' ) );
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
function enqueue_scripts() {
|
| 26 |
+
|
| 27 |
+
$screen = get_current_screen();
|
| 28 |
+
|
| 29 |
+
if ( ! $screen ) {
|
| 30 |
+
return;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
if ( $screen->id !== 'wp-smtp_page_wpsmtp_logs' ) {
|
| 34 |
+
return;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
wp_enqueue_style( 'wpsmtp-table', WPSMTP_ASSETS_URL . 'css/table.css' );
|
| 38 |
+
wp_enqueue_style( 'datatable', 'https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css' );
|
| 39 |
+
|
| 40 |
+
wp_register_script( 'datatable', 'https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js', array( 'jquery' ), false, true );
|
| 41 |
+
wp_register_script( 'dataTables.buttons', 'https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js', array( 'datatable' ), false, true );
|
| 42 |
+
wp_register_script( 'buttons.html5', 'https://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js', array( 'datatable', 'dataTables.buttons' ), false, true );
|
| 43 |
+
wp_register_script( 'dataTables.select', 'https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js', array( 'datatable', 'buttons.html5' ), false, true );
|
| 44 |
+
|
| 45 |
+
wp_register_script( 'wpsmtp-table', WPSMTP_ASSETS_URL . 'js/table.js', array('jquery', 'dataTables.select'),false, true );
|
| 46 |
+
wp_localize_script( 'wpsmtp-table', 'wpsmtp', array(
|
| 47 |
+
'ajaxurl' => admin_url('admin-ajax.php'),
|
| 48 |
+
) );
|
| 49 |
+
|
| 50 |
+
wp_enqueue_script('wpsmtp-table');
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function render_setup_menu() {
|
| 54 |
+
require_once WPSMTP_PATH . '/wp_smtp_admin.php';
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
public function render_log_menu() {
|
| 58 |
+
?>
|
| 59 |
+
<div class="wrap">
|
| 60 |
+
<h1>WPSMTP Email Logs</h1>
|
| 61 |
+
<?php Table::view(); ?>
|
| 62 |
+
</div>
|
| 63 |
+
<?php
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
public function wpsmtp_get_logs() {
|
| 67 |
+
|
| 68 |
+
check_ajax_referer('wpsmtp', 'security' );
|
| 69 |
+
|
| 70 |
+
$result = Db::get_instance()->get();
|
| 71 |
+
$records_count = Db::get_instance()->records_count();
|
| 72 |
+
|
| 73 |
+
foreach ( $result as $key => $value ) {
|
| 74 |
+
foreach ( $value as $index => $data ) {
|
| 75 |
+
if ( $index == 'message' ) {
|
| 76 |
+
|
| 77 |
+
if ( ! preg_match ('/<br>/', $data, $matches ) && ! preg_match ('/<p>/', $data, $matches ) ) {
|
| 78 |
+
$data = nl2br( $data );
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
$result[$key][$index] = wp_kses_post( $data );
|
| 82 |
+
} elseif ( is_serialized( $data ) ) {
|
| 83 |
+
$result[ $key ][ $index ] = implode( ',', array_map( 'esc_html', maybe_unserialize( $data ) ) );
|
| 84 |
+
} else {
|
| 85 |
+
$result[ $key ][ $index ] = esc_html( $data );
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
$response = array(
|
| 92 |
+
"draw" => isset( $_GET['draw'] ) ? absint( $_GET['draw'] ) : 1,
|
| 93 |
+
"recordsTotal" => $records_count,
|
| 94 |
+
"recordsFiltered" => $records_count,
|
| 95 |
+
'data' => $result
|
| 96 |
+
);
|
| 97 |
+
|
| 98 |
+
if ( isset($_GET['search']['value'] ) && ! empty( $_GET['search']['value'] ) ) {
|
| 99 |
+
$response['recordsFiltered'] = count( $result );
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
wp_send_json( $response );
|
| 103 |
+
die();
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function wpsmtp_delete_rows() {
|
| 107 |
+
check_admin_referer('wpsmtp', 'security' );
|
| 108 |
+
|
| 109 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
| 110 |
+
wp_die( 'Permissions Error.' );
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
$data = explode( ',', $_GET['ids'] );
|
| 114 |
+
wp_send_json_success( Db::get_instance()->delete_items( array_map( 'absint', $data ) ) );
|
| 115 |
+
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
function wpsmtp_delete_all_rows() {
|
| 119 |
+
check_admin_referer('wpsmtp', 'security' );
|
| 120 |
+
|
| 121 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
| 122 |
+
wp_die( 'Permissions Error.' );
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
wp_send_json_success( Db::get_instance()->delete_all_items() );
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
}
|
inc/Config.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
namespace WPSMTP;
|
| 3 |
+
|
| 4 |
+
class Config {
|
| 5 |
+
|
| 6 |
+
public static function get_setup() {
|
| 7 |
+
return array(
|
| 8 |
+
'gmail' => array(
|
| 9 |
+
'host' => 'smtp.gmail.com',
|
| 10 |
+
'security' => array(
|
| 11 |
+
'ssl' => 465,
|
| 12 |
+
'tls' => 587,
|
| 13 |
+
),
|
| 14 |
+
),
|
| 15 |
+
'sendgrid' => array(
|
| 16 |
+
'host' => 'smtp.sendgrid.net',
|
| 17 |
+
'security' => array(
|
| 18 |
+
'ssl' => 465,
|
| 19 |
+
'tls' => 587,
|
| 20 |
+
),
|
| 21 |
+
'username' => 'api'
|
| 22 |
+
),
|
| 23 |
+
'mailgun' => array(
|
| 24 |
+
'host' => 'smtp.mailgun.org',
|
| 25 |
+
'security' => array(
|
| 26 |
+
'ssl' => 465,
|
| 27 |
+
'tls' => 587,
|
| 28 |
+
),
|
| 29 |
+
),
|
| 30 |
+
'sendinblue' => array(
|
| 31 |
+
'host' => 'smtp-relay.sendinblue.com',
|
| 32 |
+
'security' => array(
|
| 33 |
+
'tls' => 587,
|
| 34 |
+
),
|
| 35 |
+
)
|
| 36 |
+
);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
}
|
inc/Db.php
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
namespace WPSMTP;
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class Db {
|
| 6 |
+
|
| 7 |
+
private $db;
|
| 8 |
+
|
| 9 |
+
private $table;
|
| 10 |
+
|
| 11 |
+
private static $instance;
|
| 12 |
+
|
| 13 |
+
public static function get_instance() {
|
| 14 |
+
|
| 15 |
+
if ( ! self::$instance ) {
|
| 16 |
+
self::$instance = new static();
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
return self::$instance;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
private function __construct() {
|
| 23 |
+
global $wpdb;
|
| 24 |
+
|
| 25 |
+
$this->db = $wpdb;
|
| 26 |
+
$this->table = $wpdb->prefix . 'wpsmtp_logs';
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public function insert( $data ) {
|
| 30 |
+
|
| 31 |
+
array_walk( $data, function ( &$value, $key ) {
|
| 32 |
+
if ( is_array( $value ) ) {
|
| 33 |
+
$value = maybe_serialize( $value );
|
| 34 |
+
}
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
$result_set = $this->db->insert(
|
| 38 |
+
$this->table,
|
| 39 |
+
$data,
|
| 40 |
+
array_fill( 0, count( $data ), '%s' )
|
| 41 |
+
);
|
| 42 |
+
|
| 43 |
+
if ( ! $result_set ) {
|
| 44 |
+
error_log( 'WP SMTP Log insert error: ' . $this->db->last_error );
|
| 45 |
+
|
| 46 |
+
return false;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
return $this->db->insert_id;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
public function update( $data, $where = array() ) {
|
| 53 |
+
array_walk( $data, function ( &$value, $key ) {
|
| 54 |
+
if ( is_array( $value ) ) {
|
| 55 |
+
$value = maybe_serialize( $value );
|
| 56 |
+
}
|
| 57 |
+
});
|
| 58 |
+
|
| 59 |
+
$this->db->update(
|
| 60 |
+
$this->table,
|
| 61 |
+
$data,
|
| 62 |
+
$where,
|
| 63 |
+
array_fill( 0, count( $data ), '%s' ),
|
| 64 |
+
array( '%d' )
|
| 65 |
+
);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
public function get_item( $id ) {
|
| 69 |
+
$sql = sprintf( "SELECT * from {$this->table} WHERE `id` = '%d';", $id );
|
| 70 |
+
|
| 71 |
+
return $this->db->get_results( $sql, ARRAY_A );
|
| 72 |
+
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
public function get() {
|
| 76 |
+
$where = '';
|
| 77 |
+
$where_cols = array();
|
| 78 |
+
if ( isset($_GET['search']['value'] ) && ! empty( $_GET['search']['value'] ) ) {
|
| 79 |
+
$search = sanitize_text_field( $_GET['search']['value'] );
|
| 80 |
+
|
| 81 |
+
foreach ( $_GET['columns'] as $key => $col ) {
|
| 82 |
+
if ( $col['searchable'] && ! empty( $col['data'] ) && $col['data'] !== 'timestamp' ) {
|
| 83 |
+
$where_cols[] = "`{$col['data']}` LIKE '%$search%'";
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
if ( ! empty( $where_cols ) ) {
|
| 88 |
+
$where .= ' WHERE ' . implode( ' OR ', $where_cols );
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
$limit = array();
|
| 94 |
+
if ( isset( $_GET['start'] ) ) {
|
| 95 |
+
$limit[] = absint( $_GET['start'] );
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
if ( isset( $_GET['length'] ) ) {
|
| 99 |
+
$limit[] = absint( $_GET['length'] );
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
$limit_query = '';
|
| 103 |
+
if ( ! empty( $limit ) ) {
|
| 104 |
+
$limit_query = ' LIMIT ' . implode( ',', $limit );
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
$order = ' ORDER BY `timestamp` desc';
|
| 108 |
+
if ( ! empty( $_GET['order'][0] ) ) {
|
| 109 |
+
$col_num = $_GET['order'][0]['column'];
|
| 110 |
+
$col_name = $_GET['columns'][$col_num]['data'];
|
| 111 |
+
$order_dir = $_GET['order'][0]['dir'];
|
| 112 |
+
$order = " ORDER BY `{$col_name}` {$order_dir}";
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
$sql = "SELECT * from {$this->table}{$where}{$order}{$limit_query};";
|
| 116 |
+
|
| 117 |
+
error_log( $sql );
|
| 118 |
+
|
| 119 |
+
return $this->db->get_results( $sql, ARRAY_A );
|
| 120 |
+
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
public function delete_items( $ids ) {
|
| 124 |
+
return $this->db->query( "DELETE FROM {$this->table} WHERE mail_id IN(" . implode(',', $ids) . ")" );
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
public function delete_all_items() {
|
| 128 |
+
return $this->db->query( "TRUNCATE {$this->table};" );
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
public function records_count() {
|
| 132 |
+
return $this->db->get_var( "SELECT COUNT(*) FROM {$this->table};" );
|
| 133 |
+
}
|
| 134 |
+
}
|
inc/Logger/Process.php
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
namespace WPSMTP;
|
| 4 |
+
|
| 5 |
+
use WP_Error;
|
| 6 |
+
|
| 7 |
+
class Process {
|
| 8 |
+
|
| 9 |
+
private $mail_id;
|
| 10 |
+
|
| 11 |
+
public function __construct() {
|
| 12 |
+
global $wpdb;
|
| 13 |
+
|
| 14 |
+
add_filter( 'wp_mail', array( $this, 'log_mails' ), PHP_INT_MAX );
|
| 15 |
+
add_action( 'wp_mail_failed', array( $this, 'update_failed_status' ), PHP_INT_MAX );
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function log_mails( $data ) {
|
| 19 |
+
global $wpdb;
|
| 20 |
+
|
| 21 |
+
unset( $data['attachments'] );
|
| 22 |
+
|
| 23 |
+
$this->mail_id = Db::get_instance()->insert( $data );
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @param WP_Error $wp_error
|
| 28 |
+
*/
|
| 29 |
+
function update_failed_status( $wp_error ) {
|
| 30 |
+
global $wpdb;
|
| 31 |
+
|
| 32 |
+
Admin::$phpmailer_error = $wp_error;
|
| 33 |
+
$data = $wp_error->get_error_data('wp_mail_failed' );
|
| 34 |
+
|
| 35 |
+
unset( $data['phpmailer_exception_code'] );
|
| 36 |
+
unset( $data['attachments'] );
|
| 37 |
+
|
| 38 |
+
$data['error'] = $wp_error->get_error_message();
|
| 39 |
+
|
| 40 |
+
if ( ! is_numeric( $this->mail_id ) ) {
|
| 41 |
+
Db::get_instance()->insert( $data );
|
| 42 |
+
} else {
|
| 43 |
+
Db::get_instance()->update( $data, array( 'mail_id' => $this->mail_id ) );
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
}
|
inc/Logger/Table.php
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
namespace WPSMTP;
|
| 3 |
+
|
| 4 |
+
class Table {
|
| 5 |
+
|
| 6 |
+
public static $name;
|
| 7 |
+
|
| 8 |
+
public function __construct() {
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
public static function install() {
|
| 14 |
+
|
| 15 |
+
global $wpdb;
|
| 16 |
+
|
| 17 |
+
self::$name = $wpdb->prefix . 'wpsmtp_logs';
|
| 18 |
+
|
| 19 |
+
$sql = "CREATE TABLE IF NOT EXISTS `" . self::$name . "` (
|
| 20 |
+
`mail_id` INT NOT NULL AUTO_INCREMENT,
|
| 21 |
+
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
| 22 |
+
`to` VARCHAR(200) NOT NULL DEFAULT '0',
|
| 23 |
+
`subject` VARCHAR(200) NOT NULL DEFAULT '0',
|
| 24 |
+
`message` TEXT NULL,
|
| 25 |
+
`headers` TEXT NULL,
|
| 26 |
+
`error` TEXT NULL,
|
| 27 |
+
PRIMARY KEY (`mail_id`)
|
| 28 |
+
) DEFAULT CHARACTER SET = utf8 DEFAULT COLLATE utf8_general_ci;";
|
| 29 |
+
|
| 30 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
| 31 |
+
dbDelta( $sql );
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
public static function view() {
|
| 35 |
+
?>
|
| 36 |
+
<div id="md-security" data-security="<?php echo wp_create_nonce('wpsmtp' ); ?>"></div>
|
| 37 |
+
<table id="example" class="display widefat" style="width:100%">
|
| 38 |
+
<thead>
|
| 39 |
+
<tr>
|
| 40 |
+
<th></th>
|
| 41 |
+
<th>To</th>
|
| 42 |
+
<th>Timestamp</th>
|
| 43 |
+
<th>Subject</th>
|
| 44 |
+
<th>Error</th>
|
| 45 |
+
</tr>
|
| 46 |
+
</thead>
|
| 47 |
+
<tbody></tbody>
|
| 48 |
+
<tfoot>
|
| 49 |
+
<tr>
|
| 50 |
+
<th></th>
|
| 51 |
+
<th>To</th>
|
| 52 |
+
<th>Timestamp</th>
|
| 53 |
+
<th>Subject</th>
|
| 54 |
+
<th>Error</th>
|
| 55 |
+
</tr>
|
| 56 |
+
</tfoot>
|
| 57 |
+
</table>
|
| 58 |
+
<?php
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
}
|
readme.txt
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
=== WP SMTP ===
|
| 2 |
Contributors: yehudah
|
| 3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+WPSMTP
|
| 4 |
-
Tags: wp smtp,smtp,mail,email,
|
| 5 |
License: GPLv2
|
| 6 |
Requires at least: 2.7
|
| 7 |
-
Tested up to: 5.
|
| 8 |
-
Stable tag: 1.
|
| 9 |
|
| 10 |
WP SMTP can help us to send emails via SMTP instead of the PHP mail() function.
|
| 11 |
|
|
@@ -51,6 +51,9 @@ WP SMTP plugin was originally created by BoLiQuan. It is now owned and maintaine
|
|
| 51 |
|
| 52 |
== Changelog ==
|
| 53 |
|
|
|
|
|
|
|
|
|
|
| 54 |
= 1.1.11 =
|
| 55 |
All good, still maintained, just update some info
|
| 56 |
|
|
@@ -95,18 +98,15 @@ https://wpsmtpmail.com/v1-1-10-wp-smtp-is-back/
|
|
| 95 |
|
| 96 |
== Screenshots ==
|
| 97 |
|
| 98 |
-
1.
|
| 99 |
-
2.
|
| 100 |
-
3.
|
| 101 |
-
4.
|
| 102 |
-
5.
|
| 103 |
|
| 104 |
|
| 105 |
== Frequently Asked Questions ==
|
| 106 |
|
| 107 |
-
You can
|
| 108 |
-
|
| 109 |
|
| 110 |
-
== Upgrade Notice ==
|
| 111 |
|
| 112 |
-
Please visit http://boliquan.com/wp-smtp/
|
| 1 |
=== WP SMTP ===
|
| 2 |
Contributors: yehudah
|
| 3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+WPSMTP
|
| 4 |
+
Tags: wp smtp,smtp,mail,email,logs,mailer,wp mail,gmail,yahoo,mail smtp,ssl,tls
|
| 5 |
License: GPLv2
|
| 6 |
Requires at least: 2.7
|
| 7 |
+
Tested up to: 5.5
|
| 8 |
+
Stable tag: 1.2
|
| 9 |
|
| 10 |
WP SMTP can help us to send emails via SMTP instead of the PHP mail() function.
|
| 11 |
|
| 51 |
|
| 52 |
== Changelog ==
|
| 53 |
|
| 54 |
+
= 1.2 =
|
| 55 |
+
New and shiny mail logger.
|
| 56 |
+
|
| 57 |
= 1.1.11 =
|
| 58 |
All good, still maintained, just update some info
|
| 59 |
|
| 98 |
|
| 99 |
== Screenshots ==
|
| 100 |
|
| 101 |
+
1. Main settings
|
| 102 |
+
2. Test settings
|
| 103 |
+
3. Mail Logs
|
| 104 |
+
4. Collapse to show mail body
|
| 105 |
+
5. Select rows to delete
|
| 106 |
|
| 107 |
|
| 108 |
== Frequently Asked Questions ==
|
| 109 |
|
| 110 |
+
You can submit it in https://wordpress.org/support/plugin/wp-smtp, if It's urgent like a bug submit it here: https://wpsmtpmail.com/contact/
|
|
|
|
| 111 |
|
|
|
|
| 112 |
|
|
|
screenshot-1.png
DELETED
|
Binary file
|
screenshot-2.png
DELETED
|
Binary file
|
screenshot-3.png
DELETED
|
Binary file
|
screenshot-4.png
DELETED
|
Binary file
|
screenshot-5.png
DELETED
|
Binary file
|
vendor/autoload.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
// autoload.php @generated by Composer
|
| 4 |
+
|
| 5 |
+
require_once __DIR__ . '/composer/autoload_real.php';
|
| 6 |
+
|
| 7 |
+
return ComposerAutoloaderInit9799005e6bc7e1043be402f070604920::getLoader();
|
vendor/composer/ClassLoader.php
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This file is part of Composer.
|
| 5 |
+
*
|
| 6 |
+
* (c) Nils Adermann <naderman@naderman.de>
|
| 7 |
+
* Jordi Boggiano <j.boggiano@seld.be>
|
| 8 |
+
*
|
| 9 |
+
* For the full copyright and license information, please view the LICENSE
|
| 10 |
+
* file that was distributed with this source code.
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Composer\Autoload;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
| 17 |
+
*
|
| 18 |
+
* $loader = new \Composer\Autoload\ClassLoader();
|
| 19 |
+
*
|
| 20 |
+
* // register classes with namespaces
|
| 21 |
+
* $loader->add('Symfony\Component', __DIR__.'/component');
|
| 22 |
+
* $loader->add('Symfony', __DIR__.'/framework');
|
| 23 |
+
*
|
| 24 |
+
* // activate the autoloader
|
| 25 |
+
* $loader->register();
|
| 26 |
+
*
|
| 27 |
+
* // to enable searching the include path (eg. for PEAR packages)
|
| 28 |
+
* $loader->setUseIncludePath(true);
|
| 29 |
+
*
|
| 30 |
+
* In this example, if you try to use a class in the Symfony\Component
|
| 31 |
+
* namespace or one of its children (Symfony\Component\Console for instance),
|
| 32 |
+
* the autoloader will first look for the class under the component/
|
| 33 |
+
* directory, and it will then fallback to the framework/ directory if not
|
| 34 |
+
* found before giving up.
|
| 35 |
+
*
|
| 36 |
+
* This class is loosely based on the Symfony UniversalClassLoader.
|
| 37 |
+
*
|
| 38 |
+
* @author Fabien Potencier <fabien@symfony.com>
|
| 39 |
+
* @author Jordi Boggiano <j.boggiano@seld.be>
|
| 40 |
+
* @see http://www.php-fig.org/psr/psr-0/
|
| 41 |
+
* @see http://www.php-fig.org/psr/psr-4/
|
| 42 |
+
*/
|
| 43 |
+
class ClassLoader
|
| 44 |
+
{
|
| 45 |
+
// PSR-4
|
| 46 |
+
private $prefixLengthsPsr4 = array();
|
| 47 |
+
private $prefixDirsPsr4 = array();
|
| 48 |
+
private $fallbackDirsPsr4 = array();
|
| 49 |
+
|
| 50 |
+
// PSR-0
|
| 51 |
+
private $prefixesPsr0 = array();
|
| 52 |
+
private $fallbackDirsPsr0 = array();
|
| 53 |
+
|
| 54 |
+
private $useIncludePath = false;
|
| 55 |
+
private $classMap = array();
|
| 56 |
+
private $classMapAuthoritative = false;
|
| 57 |
+
private $missingClasses = array();
|
| 58 |
+
private $apcuPrefix;
|
| 59 |
+
|
| 60 |
+
public function getPrefixes()
|
| 61 |
+
{
|
| 62 |
+
if (!empty($this->prefixesPsr0)) {
|
| 63 |
+
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
return array();
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
public function getPrefixesPsr4()
|
| 70 |
+
{
|
| 71 |
+
return $this->prefixDirsPsr4;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
public function getFallbackDirs()
|
| 75 |
+
{
|
| 76 |
+
return $this->fallbackDirsPsr0;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
public function getFallbackDirsPsr4()
|
| 80 |
+
{
|
| 81 |
+
return $this->fallbackDirsPsr4;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
public function getClassMap()
|
| 85 |
+
{
|
| 86 |
+
return $this->classMap;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* @param array $classMap Class to filename map
|
| 91 |
+
*/
|
| 92 |
+
public function addClassMap(array $classMap)
|
| 93 |
+
{
|
| 94 |
+
if ($this->classMap) {
|
| 95 |
+
$this->classMap = array_merge($this->classMap, $classMap);
|
| 96 |
+
} else {
|
| 97 |
+
$this->classMap = $classMap;
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Registers a set of PSR-0 directories for a given prefix, either
|
| 103 |
+
* appending or prepending to the ones previously set for this prefix.
|
| 104 |
+
*
|
| 105 |
+
* @param string $prefix The prefix
|
| 106 |
+
* @param array|string $paths The PSR-0 root directories
|
| 107 |
+
* @param bool $prepend Whether to prepend the directories
|
| 108 |
+
*/
|
| 109 |
+
public function add($prefix, $paths, $prepend = false)
|
| 110 |
+
{
|
| 111 |
+
if (!$prefix) {
|
| 112 |
+
if ($prepend) {
|
| 113 |
+
$this->fallbackDirsPsr0 = array_merge(
|
| 114 |
+
(array) $paths,
|
| 115 |
+
$this->fallbackDirsPsr0
|
| 116 |
+
);
|
| 117 |
+
} else {
|
| 118 |
+
$this->fallbackDirsPsr0 = array_merge(
|
| 119 |
+
$this->fallbackDirsPsr0,
|
| 120 |
+
(array) $paths
|
| 121 |
+
);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
return;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
$first = $prefix[0];
|
| 128 |
+
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
| 129 |
+
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
| 130 |
+
|
| 131 |
+
return;
|
| 132 |
+
}
|
| 133 |
+
if ($prepend) {
|
| 134 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
| 135 |
+
(array) $paths,
|
| 136 |
+
$this->prefixesPsr0[$first][$prefix]
|
| 137 |
+
);
|
| 138 |
+
} else {
|
| 139 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
| 140 |
+
$this->prefixesPsr0[$first][$prefix],
|
| 141 |
+
(array) $paths
|
| 142 |
+
);
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* Registers a set of PSR-4 directories for a given namespace, either
|
| 148 |
+
* appending or prepending to the ones previously set for this namespace.
|
| 149 |
+
*
|
| 150 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
| 151 |
+
* @param array|string $paths The PSR-4 base directories
|
| 152 |
+
* @param bool $prepend Whether to prepend the directories
|
| 153 |
+
*
|
| 154 |
+
* @throws \InvalidArgumentException
|
| 155 |
+
*/
|
| 156 |
+
public function addPsr4($prefix, $paths, $prepend = false)
|
| 157 |
+
{
|
| 158 |
+
if (!$prefix) {
|
| 159 |
+
// Register directories for the root namespace.
|
| 160 |
+
if ($prepend) {
|
| 161 |
+
$this->fallbackDirsPsr4 = array_merge(
|
| 162 |
+
(array) $paths,
|
| 163 |
+
$this->fallbackDirsPsr4
|
| 164 |
+
);
|
| 165 |
+
} else {
|
| 166 |
+
$this->fallbackDirsPsr4 = array_merge(
|
| 167 |
+
$this->fallbackDirsPsr4,
|
| 168 |
+
(array) $paths
|
| 169 |
+
);
|
| 170 |
+
}
|
| 171 |
+
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
| 172 |
+
// Register directories for a new namespace.
|
| 173 |
+
$length = strlen($prefix);
|
| 174 |
+
if ('\\' !== $prefix[$length - 1]) {
|
| 175 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
| 176 |
+
}
|
| 177 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
| 178 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
| 179 |
+
} elseif ($prepend) {
|
| 180 |
+
// Prepend directories for an already registered namespace.
|
| 181 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
| 182 |
+
(array) $paths,
|
| 183 |
+
$this->prefixDirsPsr4[$prefix]
|
| 184 |
+
);
|
| 185 |
+
} else {
|
| 186 |
+
// Append directories for an already registered namespace.
|
| 187 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
| 188 |
+
$this->prefixDirsPsr4[$prefix],
|
| 189 |
+
(array) $paths
|
| 190 |
+
);
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* Registers a set of PSR-0 directories for a given prefix,
|
| 196 |
+
* replacing any others previously set for this prefix.
|
| 197 |
+
*
|
| 198 |
+
* @param string $prefix The prefix
|
| 199 |
+
* @param array|string $paths The PSR-0 base directories
|
| 200 |
+
*/
|
| 201 |
+
public function set($prefix, $paths)
|
| 202 |
+
{
|
| 203 |
+
if (!$prefix) {
|
| 204 |
+
$this->fallbackDirsPsr0 = (array) $paths;
|
| 205 |
+
} else {
|
| 206 |
+
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* Registers a set of PSR-4 directories for a given namespace,
|
| 212 |
+
* replacing any others previously set for this namespace.
|
| 213 |
+
*
|
| 214 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
| 215 |
+
* @param array|string $paths The PSR-4 base directories
|
| 216 |
+
*
|
| 217 |
+
* @throws \InvalidArgumentException
|
| 218 |
+
*/
|
| 219 |
+
public function setPsr4($prefix, $paths)
|
| 220 |
+
{
|
| 221 |
+
if (!$prefix) {
|
| 222 |
+
$this->fallbackDirsPsr4 = (array) $paths;
|
| 223 |
+
} else {
|
| 224 |
+
$length = strlen($prefix);
|
| 225 |
+
if ('\\' !== $prefix[$length - 1]) {
|
| 226 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
| 227 |
+
}
|
| 228 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
| 229 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
/**
|
| 234 |
+
* Turns on searching the include path for class files.
|
| 235 |
+
*
|
| 236 |
+
* @param bool $useIncludePath
|
| 237 |
+
*/
|
| 238 |
+
public function setUseIncludePath($useIncludePath)
|
| 239 |
+
{
|
| 240 |
+
$this->useIncludePath = $useIncludePath;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
/**
|
| 244 |
+
* Can be used to check if the autoloader uses the include path to check
|
| 245 |
+
* for classes.
|
| 246 |
+
*
|
| 247 |
+
* @return bool
|
| 248 |
+
*/
|
| 249 |
+
public function getUseIncludePath()
|
| 250 |
+
{
|
| 251 |
+
return $this->useIncludePath;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Turns off searching the prefix and fallback directories for classes
|
| 256 |
+
* that have not been registered with the class map.
|
| 257 |
+
*
|
| 258 |
+
* @param bool $classMapAuthoritative
|
| 259 |
+
*/
|
| 260 |
+
public function setClassMapAuthoritative($classMapAuthoritative)
|
| 261 |
+
{
|
| 262 |
+
$this->classMapAuthoritative = $classMapAuthoritative;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/**
|
| 266 |
+
* Should class lookup fail if not found in the current class map?
|
| 267 |
+
*
|
| 268 |
+
* @return bool
|
| 269 |
+
*/
|
| 270 |
+
public function isClassMapAuthoritative()
|
| 271 |
+
{
|
| 272 |
+
return $this->classMapAuthoritative;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
| 277 |
+
*
|
| 278 |
+
* @param string|null $apcuPrefix
|
| 279 |
+
*/
|
| 280 |
+
public function setApcuPrefix($apcuPrefix)
|
| 281 |
+
{
|
| 282 |
+
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
/**
|
| 286 |
+
* The APCu prefix in use, or null if APCu caching is not enabled.
|
| 287 |
+
*
|
| 288 |
+
* @return string|null
|
| 289 |
+
*/
|
| 290 |
+
public function getApcuPrefix()
|
| 291 |
+
{
|
| 292 |
+
return $this->apcuPrefix;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* Registers this instance as an autoloader.
|
| 297 |
+
*
|
| 298 |
+
* @param bool $prepend Whether to prepend the autoloader or not
|
| 299 |
+
*/
|
| 300 |
+
public function register($prepend = false)
|
| 301 |
+
{
|
| 302 |
+
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
* Unregisters this instance as an autoloader.
|
| 307 |
+
*/
|
| 308 |
+
public function unregister()
|
| 309 |
+
{
|
| 310 |
+
spl_autoload_unregister(array($this, 'loadClass'));
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* Loads the given class or interface.
|
| 315 |
+
*
|
| 316 |
+
* @param string $class The name of the class
|
| 317 |
+
* @return bool|null True if loaded, null otherwise
|
| 318 |
+
*/
|
| 319 |
+
public function loadClass($class)
|
| 320 |
+
{
|
| 321 |
+
if ($file = $this->findFile($class)) {
|
| 322 |
+
includeFile($file);
|
| 323 |
+
|
| 324 |
+
return true;
|
| 325 |
+
}
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
/**
|
| 329 |
+
* Finds the path to the file where the class is defined.
|
| 330 |
+
*
|
| 331 |
+
* @param string $class The name of the class
|
| 332 |
+
*
|
| 333 |
+
* @return string|false The path if found, false otherwise
|
| 334 |
+
*/
|
| 335 |
+
public function findFile($class)
|
| 336 |
+
{
|
| 337 |
+
// class map lookup
|
| 338 |
+
if (isset($this->classMap[$class])) {
|
| 339 |
+
return $this->classMap[$class];
|
| 340 |
+
}
|
| 341 |
+
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
| 342 |
+
return false;
|
| 343 |
+
}
|
| 344 |
+
if (null !== $this->apcuPrefix) {
|
| 345 |
+
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
| 346 |
+
if ($hit) {
|
| 347 |
+
return $file;
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
$file = $this->findFileWithExtension($class, '.php');
|
| 352 |
+
|
| 353 |
+
// Search for Hack files if we are running on HHVM
|
| 354 |
+
if (false === $file && defined('HHVM_VERSION')) {
|
| 355 |
+
$file = $this->findFileWithExtension($class, '.hh');
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
if (null !== $this->apcuPrefix) {
|
| 359 |
+
apcu_add($this->apcuPrefix.$class, $file);
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
if (false === $file) {
|
| 363 |
+
// Remember that this class does not exist.
|
| 364 |
+
$this->missingClasses[$class] = true;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
return $file;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
private function findFileWithExtension($class, $ext)
|
| 371 |
+
{
|
| 372 |
+
// PSR-4 lookup
|
| 373 |
+
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
| 374 |
+
|
| 375 |
+
$first = $class[0];
|
| 376 |
+
if (isset($this->prefixLengthsPsr4[$first])) {
|
| 377 |
+
$subPath = $class;
|
| 378 |
+
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
| 379 |
+
$subPath = substr($subPath, 0, $lastPos);
|
| 380 |
+
$search = $subPath . '\\';
|
| 381 |
+
if (isset($this->prefixDirsPsr4[$search])) {
|
| 382 |
+
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
| 383 |
+
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
| 384 |
+
if (file_exists($file = $dir . $pathEnd)) {
|
| 385 |
+
return $file;
|
| 386 |
+
}
|
| 387 |
+
}
|
| 388 |
+
}
|
| 389 |
+
}
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
// PSR-4 fallback dirs
|
| 393 |
+
foreach ($this->fallbackDirsPsr4 as $dir) {
|
| 394 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
| 395 |
+
return $file;
|
| 396 |
+
}
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
// PSR-0 lookup
|
| 400 |
+
if (false !== $pos = strrpos($class, '\\')) {
|
| 401 |
+
// namespaced class name
|
| 402 |
+
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
| 403 |
+
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
| 404 |
+
} else {
|
| 405 |
+
// PEAR-like class name
|
| 406 |
+
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
if (isset($this->prefixesPsr0[$first])) {
|
| 410 |
+
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
| 411 |
+
if (0 === strpos($class, $prefix)) {
|
| 412 |
+
foreach ($dirs as $dir) {
|
| 413 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
| 414 |
+
return $file;
|
| 415 |
+
}
|
| 416 |
+
}
|
| 417 |
+
}
|
| 418 |
+
}
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
// PSR-0 fallback dirs
|
| 422 |
+
foreach ($this->fallbackDirsPsr0 as $dir) {
|
| 423 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
| 424 |
+
return $file;
|
| 425 |
+
}
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
// PSR-0 include paths.
|
| 429 |
+
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
| 430 |
+
return $file;
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
return false;
|
| 434 |
+
}
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
/**
|
| 438 |
+
* Scope isolated include.
|
| 439 |
+
*
|
| 440 |
+
* Prevents access to $this/self from included files.
|
| 441 |
+
*/
|
| 442 |
+
function includeFile($file)
|
| 443 |
+
{
|
| 444 |
+
include $file;
|
| 445 |
+
}
|
vendor/composer/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Copyright (c) Nils Adermann, Jordi Boggiano
|
| 3 |
+
|
| 4 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 5 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 6 |
+
in the Software without restriction, including without limitation the rights
|
| 7 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 8 |
+
copies of the Software, and to permit persons to whom the Software is furnished
|
| 9 |
+
to do so, subject to the following conditions:
|
| 10 |
+
|
| 11 |
+
The above copyright notice and this permission notice shall be included in all
|
| 12 |
+
copies or substantial portions of the Software.
|
| 13 |
+
|
| 14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 15 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 16 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 17 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 18 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 19 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 20 |
+
THE SOFTWARE.
|
| 21 |
+
|
vendor/composer/autoload_classmap.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
// autoload_classmap.php @generated by Composer
|
| 4 |
+
|
| 5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
| 6 |
+
$baseDir = dirname($vendorDir);
|
| 7 |
+
|
| 8 |
+
return array(
|
| 9 |
+
'WPSMTP\\Config' => $baseDir . '/inc/Config.php',
|
| 10 |
+
'WPSMTP\\Process' => $baseDir . '/inc/Logger/Process.php',
|
| 11 |
+
'WPSMTP\\Table' => $baseDir . '/inc/Logger/Table.php',
|
| 12 |
+
);
|
vendor/composer/autoload_namespaces.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
// autoload_namespaces.php @generated by Composer
|
| 4 |
+
|
| 5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
| 6 |
+
$baseDir = dirname($vendorDir);
|
| 7 |
+
|
| 8 |
+
return array(
|
| 9 |
+
);
|
vendor/composer/autoload_psr4.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
// autoload_psr4.php @generated by Composer
|
| 4 |
+
|
| 5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
| 6 |
+
$baseDir = dirname($vendorDir);
|
| 7 |
+
|
| 8 |
+
return array(
|
| 9 |
+
'WPSMTP\\' => array($baseDir . '/inc'),
|
| 10 |
+
);
|
vendor/composer/autoload_real.php
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
// autoload_real.php @generated by Composer
|
| 4 |
+
|
| 5 |
+
class ComposerAutoloaderInit9799005e6bc7e1043be402f070604920
|
| 6 |
+
{
|
| 7 |
+
private static $loader;
|
| 8 |
+
|
| 9 |
+
public static function loadClassLoader($class)
|
| 10 |
+
{
|
| 11 |
+
if ('Composer\Autoload\ClassLoader' === $class) {
|
| 12 |
+
require __DIR__ . '/ClassLoader.php';
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
public static function getLoader()
|
| 17 |
+
{
|
| 18 |
+
if (null !== self::$loader) {
|
| 19 |
+
return self::$loader;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
spl_autoload_register(array('ComposerAutoloaderInit9799005e6bc7e1043be402f070604920', 'loadClassLoader'), true, true);
|
| 23 |
+
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
| 24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit9799005e6bc7e1043be402f070604920', 'loadClassLoader'));
|
| 25 |
+
|
| 26 |
+
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
| 27 |
+
if ($useStaticLoader) {
|
| 28 |
+
require_once __DIR__ . '/autoload_static.php';
|
| 29 |
+
|
| 30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit9799005e6bc7e1043be402f070604920::getInitializer($loader));
|
| 31 |
+
} else {
|
| 32 |
+
$map = require __DIR__ . '/autoload_namespaces.php';
|
| 33 |
+
foreach ($map as $namespace => $path) {
|
| 34 |
+
$loader->set($namespace, $path);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
$map = require __DIR__ . '/autoload_psr4.php';
|
| 38 |
+
foreach ($map as $namespace => $path) {
|
| 39 |
+
$loader->setPsr4($namespace, $path);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
$classMap = require __DIR__ . '/autoload_classmap.php';
|
| 43 |
+
if ($classMap) {
|
| 44 |
+
$loader->addClassMap($classMap);
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
$loader->register(true);
|
| 49 |
+
|
| 50 |
+
return $loader;
|
| 51 |
+
}
|
| 52 |
+
}
|
vendor/composer/autoload_static.php
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
// autoload_static.php @generated by Composer
|
| 4 |
+
|
| 5 |
+
namespace Composer\Autoload;
|
| 6 |
+
|
| 7 |
+
class ComposerStaticInit9799005e6bc7e1043be402f070604920
|
| 8 |
+
{
|
| 9 |
+
public static $prefixLengthsPsr4 = array (
|
| 10 |
+
'W' =>
|
| 11 |
+
array (
|
| 12 |
+
'WPSMTP\\' => 7,
|
| 13 |
+
),
|
| 14 |
+
);
|
| 15 |
+
|
| 16 |
+
public static $prefixDirsPsr4 = array (
|
| 17 |
+
'WPSMTP\\' =>
|
| 18 |
+
array (
|
| 19 |
+
0 => __DIR__ . '/../..' . '/inc',
|
| 20 |
+
),
|
| 21 |
+
);
|
| 22 |
+
|
| 23 |
+
public static $classMap = array (
|
| 24 |
+
'WPSMTP\\Config' => __DIR__ . '/../..' . '/inc/Config.php',
|
| 25 |
+
'WPSMTP\\Process' => __DIR__ . '/../..' . '/inc/Logger/Process.php',
|
| 26 |
+
'WPSMTP\\Table' => __DIR__ . '/../..' . '/inc/Logger/Table.php',
|
| 27 |
+
);
|
| 28 |
+
|
| 29 |
+
public static function getInitializer(ClassLoader $loader)
|
| 30 |
+
{
|
| 31 |
+
return \Closure::bind(function () use ($loader) {
|
| 32 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit9799005e6bc7e1043be402f070604920::$prefixLengthsPsr4;
|
| 33 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit9799005e6bc7e1043be402f070604920::$prefixDirsPsr4;
|
| 34 |
+
$loader->classMap = ComposerStaticInit9799005e6bc7e1043be402f070604920::$classMap;
|
| 35 |
+
|
| 36 |
+
}, null, ClassLoader::class);
|
| 37 |
+
}
|
| 38 |
+
}
|
wp-smtp.php
CHANGED
|
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
| 4 |
/*
|
| 5 |
Plugin Name: WP SMTP
|
| 6 |
Description: WP SMTP can help us to send emails via SMTP instead of the PHP mail() function.
|
| 7 |
-
Version: 1.
|
| 8 |
Author: Yehuda Hassine
|
| 9 |
Text Domain: wp-smtp
|
| 10 |
Domain Path: /lang
|
|
@@ -16,9 +16,18 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
| 16 |
* The plugin was originally created by BoLiQuan
|
| 17 |
*/
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
class WP_SMTP {
|
| 20 |
|
| 21 |
-
private $wsOptions
|
| 22 |
|
| 23 |
public function __construct() {
|
| 24 |
$this->setup_vars();
|
|
@@ -36,8 +45,9 @@ class WP_SMTP {
|
|
| 36 |
add_filter( 'plugin_action_links', array( $this, 'wp_smtp_settings_link' ), 10, 2 );
|
| 37 |
add_action( 'init', array( $this,'load_textdomain' ) );
|
| 38 |
add_action( 'phpmailer_init', array( $this,'wp_smtp' ) );
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
function wp_smtp_activate(){
|
|
@@ -53,6 +63,9 @@ class WP_SMTP {
|
|
| 53 |
$wsOptions["deactivate"] = "";
|
| 54 |
|
| 55 |
add_option( 'wp_smtp_options', $wsOptions );
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
|
| 58 |
function wp_smtp_deactivate() {
|
|
@@ -74,8 +87,8 @@ class WP_SMTP {
|
|
| 74 |
$phpmailer->Mailer = "smtp";
|
| 75 |
$phpmailer->From = $this->wsOptions["from"];
|
| 76 |
$phpmailer->FromName = $this->wsOptions["fromname"];
|
| 77 |
-
$phpmailer->Sender = $phpmailer->From;
|
| 78 |
-
$phpmailer->AddReplyTo($phpmailer->From,$phpmailer->FromName);
|
| 79 |
$phpmailer->Host = $this->wsOptions["host"];
|
| 80 |
$phpmailer->SMTPSecure = $this->wsOptions["smtpsecure"];
|
| 81 |
$phpmailer->Port = $this->wsOptions["port"];
|
|
@@ -87,26 +100,19 @@ class WP_SMTP {
|
|
| 87 |
}
|
| 88 |
}
|
| 89 |
|
| 90 |
-
function catch_phpmailer_error( $error ) {
|
| 91 |
-
$this->phpmailer_error = $error;
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
function wp_smtp_settings_link($action_links,$plugin_file) {
|
| 95 |
if( $plugin_file == plugin_basename( __FILE__ ) ) {
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
array_unshift($action_links,$ws_settings_link);
|
| 98 |
}
|
| 99 |
|
| 100 |
return $action_links;
|
| 101 |
}
|
| 102 |
|
| 103 |
-
function wp_smtp_admin(){
|
| 104 |
-
add_options_page('WP SMTP Options', 'WP SMTP','manage_options', __FILE__, array( $this, 'wp_smtp_page') );
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
function wp_smtp_page(){
|
| 108 |
-
require_once __DIR__ . '/wp_smtp_admin.php';
|
| 109 |
-
}
|
| 110 |
}
|
| 111 |
|
| 112 |
new WP_SMTP();
|
| 4 |
/*
|
| 5 |
Plugin Name: WP SMTP
|
| 6 |
Description: WP SMTP can help us to send emails via SMTP instead of the PHP mail() function.
|
| 7 |
+
Version: 1.2
|
| 8 |
Author: Yehuda Hassine
|
| 9 |
Text Domain: wp-smtp
|
| 10 |
Domain Path: /lang
|
| 16 |
* The plugin was originally created by BoLiQuan
|
| 17 |
*/
|
| 18 |
|
| 19 |
+
define( 'WPSMTP__FILE__', __FILE__ );
|
| 20 |
+
define( 'WPSMTP_PLUGIN_BASE', plugin_basename( WPSMTP__FILE__ ) );
|
| 21 |
+
define( 'WPSMTP_PATH', plugin_dir_path( WPSMTP__FILE__ ) );
|
| 22 |
+
define( 'WPSMTP_URL', plugins_url( '/', WPSMTP__FILE__ ) );
|
| 23 |
+
define( 'WPSMTP_ASSETS_PATH', WPSMTP_PATH . 'assets/' );
|
| 24 |
+
define( 'WPSMTP_ASSETS_URL', WPSMTP_URL . 'assets/' );
|
| 25 |
+
|
| 26 |
+
require_once 'vendor/autoload.php';
|
| 27 |
+
|
| 28 |
class WP_SMTP {
|
| 29 |
|
| 30 |
+
private $wsOptions;
|
| 31 |
|
| 32 |
public function __construct() {
|
| 33 |
$this->setup_vars();
|
| 45 |
add_filter( 'plugin_action_links', array( $this, 'wp_smtp_settings_link' ), 10, 2 );
|
| 46 |
add_action( 'init', array( $this,'load_textdomain' ) );
|
| 47 |
add_action( 'phpmailer_init', array( $this,'wp_smtp' ) );
|
| 48 |
+
|
| 49 |
+
new WPSMTP\Admin();
|
| 50 |
+
new WPSMTP\Process();
|
| 51 |
}
|
| 52 |
|
| 53 |
function wp_smtp_activate(){
|
| 63 |
$wsOptions["deactivate"] = "";
|
| 64 |
|
| 65 |
add_option( 'wp_smtp_options', $wsOptions );
|
| 66 |
+
|
| 67 |
+
\WPSMTP\Table::install();
|
| 68 |
+
|
| 69 |
}
|
| 70 |
|
| 71 |
function wp_smtp_deactivate() {
|
| 87 |
$phpmailer->Mailer = "smtp";
|
| 88 |
$phpmailer->From = $this->wsOptions["from"];
|
| 89 |
$phpmailer->FromName = $this->wsOptions["fromname"];
|
| 90 |
+
$phpmailer->Sender = $phpmailer->From;
|
| 91 |
+
$phpmailer->AddReplyTo($phpmailer->From,$phpmailer->FromName);
|
| 92 |
$phpmailer->Host = $this->wsOptions["host"];
|
| 93 |
$phpmailer->SMTPSecure = $this->wsOptions["smtpsecure"];
|
| 94 |
$phpmailer->Port = $this->wsOptions["port"];
|
| 100 |
}
|
| 101 |
}
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
function wp_smtp_settings_link($action_links,$plugin_file) {
|
| 104 |
if( $plugin_file == plugin_basename( __FILE__ ) ) {
|
| 105 |
+
|
| 106 |
+
$ws_settings_link = '<a href="admin.php?page=wpsmtp_logs">' . __("Logs") . '</a>';
|
| 107 |
+
array_unshift($action_links,$ws_settings_link);
|
| 108 |
+
|
| 109 |
+
$ws_settings_link = '<a href="admin.php?page=' . dirname( plugin_basename(__FILE__) ) . '/wp-smtp.php">' . __("Settings") . '</a>';
|
| 110 |
array_unshift($action_links,$ws_settings_link);
|
| 111 |
}
|
| 112 |
|
| 113 |
return $action_links;
|
| 114 |
}
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
}
|
| 117 |
|
| 118 |
new WP_SMTP();
|
wp_smtp_admin.php
CHANGED
|
@@ -56,7 +56,7 @@ if ( isset( $_POST['wp_smtp_test'] ) && isset( $_POST['wp_smtp_nonce_test'] ) )
|
|
| 56 |
$status = __( 'Message sent!', 'wp-smtp' );
|
| 57 |
$class = 'success';
|
| 58 |
} else {
|
| 59 |
-
$status =
|
| 60 |
}
|
| 61 |
}
|
| 62 |
|
| 56 |
$status = __( 'Message sent!', 'wp-smtp' );
|
| 57 |
$class = 'success';
|
| 58 |
} else {
|
| 59 |
+
$status = \WPSMTP\Admin::$phpmailer_error->get_error_message();
|
| 60 |
}
|
| 61 |
}
|
| 62 |
|
