/var/www/html_fr/wp-content/plugins/fluent-smtp/app/Http/Controllers/Controller.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php

namespace FluentMail\App\Http\Controllers;

use 
FluentMail\App\App;

abstract class 
Controller
{
    
/**
     * @var \FluentMail\App\Plugin
     */
    
protected $app null;

    
/**
     * @var \FluentMail\Includes\Request\Request
     */
    
protected $request null;

    
/**
     * @var \FluentMail\Includes\Response\Response
     */
    
protected $response null;

    public function 
__construct()
    {
        
$this->app App::getInstance();
        
$this->request $this->app['request'];
        
$this->response $this->app['response'];
    }

    public function 
send($data null$code 200)
    {
        return 
$this->response->send($data$code);
    }

    public function 
sendSuccess($data null$code 200)
    {
        return 
$this->response->sendSuccess($data$code);
    }

    public function 
sendError($data null$code 422)
    {
        return 
$this->response->sendError($data$code);
    }

    public function 
verify()
    {
        
$permission 'manage_options';
        if(!
current_user_can($permission)) {
            
wp_send_json_error([
                
'message' => __('You do not have permission to do this action''fluent-smtp')
            ]);
            die();
        }

        
$nonce $this->request->get('nonce');
        if(!
wp_verify_nonce($nonceFLUENTMAIL)) {
            
wp_send_json_error([
                
'message' => __('Security Failed. Please reload the page''fluent-smtp')
            ]);
            die();
        }

        return 
true;
    }
}