Plugin Directory

Changeset 1853453


Ignore:
Timestamp:
04/05/2018 03:05:37 PM (8 years ago)
Author:
ademirdiniz
Message:

Correção do namespace do OAuth pra evitar conflito

Location:
mediapost-extensao-para-contact-form-7/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mediapost-extensao-para-contact-form-7/trunk/cf7-mediapost.php

    r1799101 r1853453  
    44Description: Com este plugin você poderá integrar seus formulários do Contact Form 7 com sua conta @MediaPost.
    55Author: @MediaPost
    6 Version: 1.0
     6Version: 1.0.1
    77Author URI: https://www.mediapost.com.br/
    88Text Domain: cf7_mediapost_extensao
  • mediapost-extensao-para-contact-form-7/trunk/includes/client/Request/Request.php

    r1799101 r1853453  
    2525     */
    2626    const METHOD_GET    = 'GET';
    27    
     27
    2828    /**
    2929     * Método POST
     
    3232     */
    3333    const METHOD_POST   = 'POST';
    34    
     34
    3535    /**
    3636     * Método PUT
     
    3939     */
    4040    const METHOD_PUT    = 'PUT';
    41    
     41
    4242    /**
    4343     * Método DELETE
     
    4646     */
    4747    const METHOD_DELETE = 'DELETE';
    48    
     48
    4949    /**
    5050     * Cliente da API
     
    5353     */
    5454    protected $client = null;
    55    
     55
    5656    /**
    5757     * Construtor
     
    6666        $this->client = $client;
    6767    }
    68    
     68
    6969    /**
    7070     * Método que executa uma requisição HTTP GET
     
    8686            $params = [];
    8787        }
    88        
     88
    8989        return $this->build($path, self::METHOD_GET, [
    9090            CURLOPT_HTTPGET => true
    9191        ], $params, $config);
    9292    }
    93    
     93
    9494    /**
    9595     * Método que executa uma requisição HTTP POST
     
    111111            $params = [];
    112112        }
    113        
     113
    114114        return $this->build($path, self::METHOD_POST, [
    115115            CURLOPT_POST => true,
     
    117117        ], $params, $config);
    118118    }
    119    
     119
    120120    /**
    121121     * Método que executa uma requisição HTTP PUT
     
    148148            CURLOPT_INFILESIZE => \strlen($putString)
    149149        ], $config);
    150        
     150
    151151        \fclose($putFile);
    152        
     152
    153153        return $response;
    154154    }
    155    
     155
    156156    /**
    157157     * Método que excuta uma requisição HTTP DELETE
     
    172172        ], [], $config);
    173173    }
    174    
     174
    175175    /**
    176176     * Método que encoda recursivamente um array para utf8
     
    195195        return $arrData;
    196196    }
    197    
     197
    198198    /**
    199199     * Método que faz o request de uma url
     
    223223            $arrCurl[CURLOPT_POSTFIELDS] = \http_build_query($arrCurl[CURLOPT_POSTFIELDS]);
    224224        }
    225        
     225
    226226        // Cabeçalhos padrões
    227227        $headers = [
     
    230230            $this->buildOauthRequestHeaders($this->client, $method, $url, $params)
    231231        ];
    232        
     232
    233233        // Configuraçõs extras
    234234        if ($config !== null) {
     
    240240            $headers = \array_merge($headers, $config->toArray());
    241241        }
    242        
     242
    243243        // Parâmetros
    244244        $arrCurl[CURLOPT_URL]            = $url;
     
    247247        $arrCurl[CURLOPT_HEADER]         = true;
    248248        $arrCurl[CURLOPT_SSL_VERIFYPEER] = false;
    249        
     249
    250250        // Inicializa o cURL
    251251        $ch = \curl_init();
    252252        \curl_setopt_array($ch, $arrCurl);
    253        
     253
    254254        return Response::fromCurlResource($ch);
    255255    }
    256    
     256
    257257    /**
    258258     * Gera o cabeçalho de autenticação do oAuth
     
    267267    protected function buildOauthRequestHeaders(Client $client, $method, $url, array $params = [])
    268268    {
    269         if (!\class_exists('\OAuthConsumer')) {
     269        if (!\class_exists('\Mapi\OAuthConsumer')) {
    270270            require __DIR__ . '/../oauth/OAuth.php';
    271271        }
    272        
    273         $consumer = new \OAuthConsumer($client->getConsumerKey(), $client->getConsumerSecret());
    274         $token = new \OAuthToken($client->getToken(), $client->getTokenSecret());
    275 
    276         $request = \OAuthRequest::from_consumer_and_token($consumer, $token, $method, $url);
     272
     273        $consumer = new \Mapi\OAuthConsumer($client->getConsumerKey(), $client->getConsumerSecret());
     274        $token = new \Mapi\OAuthToken($client->getToken(), $client->getTokenSecret());
     275
     276        $request = \Mapi\OAuthRequest::from_consumer_and_token($consumer, $token, $method, $url);
    277277
    278278        // Seta os parâmetros da requisição
     
    281281        }
    282282
    283         $request->sign_request(new \OAuthSignatureMethod_HMAC_SHA1(), $consumer, $token);
    284        
     283        $request->sign_request(new \Mapi\OAuthSignatureMethod_HMAC_SHA1(), $consumer, $token);
     284
    285285        return $request->to_header();
    286286    }
  • mediapost-extensao-para-contact-form-7/trunk/includes/client/oauth/OAuth.php

    r1799101 r1853453  
    22// vim: foldmethod=marker
    33
    4 /* Generic exception class
     4namespace Mapi;
     5
     6/*
     7 * Generic exception class
    58 */
    6 class OAuthException extends Exception {
     9
     10class OAuthException extends \Exception {
    711  // pass
    812}
     13
     14namespace Mapi;
    915
    1016class OAuthConsumer {
     
    2228  }
    2329}
     30
     31namespace Mapi;
    2432
    2533class OAuthToken {
     
    5765 * See section 9 ("Signing Requests") in the spec
    5866 */
     67
     68namespace Mapi;
     69
    5970abstract class OAuthSignatureMethod {
    6071  /**
     
    107118
    108119/**
    109  * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104] 
    110  * where the Signature Base String is the text and the key is the concatenated values (each first 
    111  * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&' 
     120 * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
     121 * where the Signature Base String is the text and the key is the concatenated values (each first
     122 * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
    112123 * character (ASCII code 38) even if empty.
    113124 *   - Chapter 9.2 ("HMAC-SHA1")
    114125 */
     126
     127namespace Mapi;
     128
    115129class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
    116130  function get_name() {
     
    122136
    123137    $request->base_string = $base_string;
    124    
     138
    125139    $key_parts = array(
    126140      $consumer->secret,
     
    136150
    137151/**
    138  * The PLAINTEXT method does not provide any security protection and SHOULD only be used 
     152 * The PLAINTEXT method does not provide any security protection and SHOULD only be used
    139153 * over a secure channel such as HTTPS. It does not use the Signature Base String.
    140154 *   - Chapter 9.4 ("PLAINTEXT")
    141155 */
     156
     157namespace Mapi;
     158
    142159class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
    143160  public function get_name() {
     
    146163
    147164  /**
    148    * oauth_signature is set to the concatenated encoded values of the Consumer Secret and 
    149    * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is 
     165   * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
     166   * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
    150167   * empty. The result MUST be encoded again.
    151168   *   - Chapter 9.4.1 ("Generating Signatures")
     
    169186
    170187/**
    171  * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in 
    172  * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for 
    173  * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a 
    174  * verified way to the Service Provider, in a manner which is beyond the scope of this 
     188 * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
     189 * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
     190 * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
     191 * verified way to the Service Provider, in a manner which is beyond the scope of this
    175192 * specification.
    176193 *   - Chapter 9.3 ("RSA-SHA1")
    177194 */
     195
     196namespace Mapi;
     197
    178198abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
    179199  public function get_name() {
     
    234254  }
    235255}
     256
     257namespace Mapi;
    236258
    237259class OAuthRequest {
     
    379401      $this->get_signable_parameters()
    380402    );
    381    
     403
    382404    $parts = OAuthUtil::urlencode_rfc3986($parts);
    383    
     405
    384406    return implode('&', $parts);
    385407  }
     
    495517}
    496518
     519namespace Mapi;
     520
    497521class OAuthServer {
    498522  protected $timestamp_threshold = 300; // in seconds, five minutes
     
    573597    $version = $request->get_parameter("oauth_version");
    574598    if (!$version) {
    575       // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present. 
     599      // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
    576600      // Chapter 7.0 ("Accessing Protected Ressources")
    577601      $version = '1.0';
     
    587611   */
    588612  private function get_signature_method($request) {
    589     $signature_method = $request instanceof OAuthRequest 
     613    $signature_method = $request instanceof OAuthRequest
    590614        ? $request->get_parameter("oauth_signature_method")
    591615        : NULL;
     
    612636   */
    613637  private function get_consumer($request) {
    614     $consumer_key = $request instanceof OAuthRequest 
     638    $consumer_key = $request instanceof OAuthRequest
    615639        ? $request->get_parameter("oauth_consumer_key")
    616640        : NULL;
     
    684708        'Missing timestamp parameter. The parameter is required'
    685709      );
    686    
     710
    687711    // verify that timestamp is recentish
    688712    $now = time();
     
    717741}
    718742
     743namespace Mapi;
     744
    719745class OAuthDataStore {
    720746  function lookup_consumer($consumer_key) {
     
    743769}
    744770
     771namespace Mapi;
     772
    745773class OAuthUtil {
    746774  public static function urlencode_rfc3986($input) {
    747775  if (is_array($input)) {
    748     return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
     776    return array_map(array('\Mapi\OAuthUtil', 'urlencode_rfc3986'), $input);
    749777  } else if (is_scalar($input)) {
    750778    return str_replace(
  • mediapost-extensao-para-contact-form-7/trunk/readme.txt

    r1799113 r1853453  
    33Tags: @mediapost, mediapost, Contact Form 7, Contact Form 7 Extension, Extensão Contact Form 7, Formulario
    44Requires at least: 3.0.1
    5 Tested up to: 4.9.1
    6 Stable tag: 1.0
     5Tested up to: 4.9.5
     6Stable tag: 1.0.1
    77
    88== Description ==
Note: See TracChangeset for help on using the changeset viewer.