Changeset 1853453
- Timestamp:
- 04/05/2018 03:05:37 PM (8 years ago)
- Location:
- mediapost-extensao-para-contact-form-7/trunk
- Files:
-
- 4 edited
-
cf7-mediapost.php (modified) (1 diff)
-
includes/client/Request/Request.php (modified) (18 diffs)
-
includes/client/oauth/OAuth.php (modified) (17 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mediapost-extensao-para-contact-form-7/trunk/cf7-mediapost.php
r1799101 r1853453 4 4 Description: Com este plugin você poderá integrar seus formulários do Contact Form 7 com sua conta @MediaPost. 5 5 Author: @MediaPost 6 Version: 1.0 6 Version: 1.0.1 7 7 Author URI: https://www.mediapost.com.br/ 8 8 Text Domain: cf7_mediapost_extensao -
mediapost-extensao-para-contact-form-7/trunk/includes/client/Request/Request.php
r1799101 r1853453 25 25 */ 26 26 const METHOD_GET = 'GET'; 27 27 28 28 /** 29 29 * Método POST … … 32 32 */ 33 33 const METHOD_POST = 'POST'; 34 34 35 35 /** 36 36 * Método PUT … … 39 39 */ 40 40 const METHOD_PUT = 'PUT'; 41 41 42 42 /** 43 43 * Método DELETE … … 46 46 */ 47 47 const METHOD_DELETE = 'DELETE'; 48 48 49 49 /** 50 50 * Cliente da API … … 53 53 */ 54 54 protected $client = null; 55 55 56 56 /** 57 57 * Construtor … … 66 66 $this->client = $client; 67 67 } 68 68 69 69 /** 70 70 * Método que executa uma requisição HTTP GET … … 86 86 $params = []; 87 87 } 88 88 89 89 return $this->build($path, self::METHOD_GET, [ 90 90 CURLOPT_HTTPGET => true 91 91 ], $params, $config); 92 92 } 93 93 94 94 /** 95 95 * Método que executa uma requisição HTTP POST … … 111 111 $params = []; 112 112 } 113 113 114 114 return $this->build($path, self::METHOD_POST, [ 115 115 CURLOPT_POST => true, … … 117 117 ], $params, $config); 118 118 } 119 119 120 120 /** 121 121 * Método que executa uma requisição HTTP PUT … … 148 148 CURLOPT_INFILESIZE => \strlen($putString) 149 149 ], $config); 150 150 151 151 \fclose($putFile); 152 152 153 153 return $response; 154 154 } 155 155 156 156 /** 157 157 * Método que excuta uma requisição HTTP DELETE … … 172 172 ], [], $config); 173 173 } 174 174 175 175 /** 176 176 * Método que encoda recursivamente um array para utf8 … … 195 195 return $arrData; 196 196 } 197 197 198 198 /** 199 199 * Método que faz o request de uma url … … 223 223 $arrCurl[CURLOPT_POSTFIELDS] = \http_build_query($arrCurl[CURLOPT_POSTFIELDS]); 224 224 } 225 225 226 226 // Cabeçalhos padrões 227 227 $headers = [ … … 230 230 $this->buildOauthRequestHeaders($this->client, $method, $url, $params) 231 231 ]; 232 232 233 233 // Configuraçõs extras 234 234 if ($config !== null) { … … 240 240 $headers = \array_merge($headers, $config->toArray()); 241 241 } 242 242 243 243 // Parâmetros 244 244 $arrCurl[CURLOPT_URL] = $url; … … 247 247 $arrCurl[CURLOPT_HEADER] = true; 248 248 $arrCurl[CURLOPT_SSL_VERIFYPEER] = false; 249 249 250 250 // Inicializa o cURL 251 251 $ch = \curl_init(); 252 252 \curl_setopt_array($ch, $arrCurl); 253 253 254 254 return Response::fromCurlResource($ch); 255 255 } 256 256 257 257 /** 258 258 * Gera o cabeçalho de autenticação do oAuth … … 267 267 protected function buildOauthRequestHeaders(Client $client, $method, $url, array $params = []) 268 268 { 269 if (!\class_exists('\ OAuthConsumer')) {269 if (!\class_exists('\Mapi\OAuthConsumer')) { 270 270 require __DIR__ . '/../oauth/OAuth.php'; 271 271 } 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); 277 277 278 278 // Seta os parâmetros da requisição … … 281 281 } 282 282 283 $request->sign_request(new \ OAuthSignatureMethod_HMAC_SHA1(), $consumer, $token);284 283 $request->sign_request(new \Mapi\OAuthSignatureMethod_HMAC_SHA1(), $consumer, $token); 284 285 285 return $request->to_header(); 286 286 } -
mediapost-extensao-para-contact-form-7/trunk/includes/client/oauth/OAuth.php
r1799101 r1853453 2 2 // vim: foldmethod=marker 3 3 4 /* Generic exception class 4 namespace Mapi; 5 6 /* 7 * Generic exception class 5 8 */ 6 class OAuthException extends Exception { 9 10 class OAuthException extends \Exception { 7 11 // pass 8 12 } 13 14 namespace Mapi; 9 15 10 16 class OAuthConsumer { … … 22 28 } 23 29 } 30 31 namespace Mapi; 24 32 25 33 class OAuthToken { … … 57 65 * See section 9 ("Signing Requests") in the spec 58 66 */ 67 68 namespace Mapi; 69 59 70 abstract class OAuthSignatureMethod { 60 71 /** … … 107 118 108 119 /** 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 '&' 112 123 * character (ASCII code 38) even if empty. 113 124 * - Chapter 9.2 ("HMAC-SHA1") 114 125 */ 126 127 namespace Mapi; 128 115 129 class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod { 116 130 function get_name() { … … 122 136 123 137 $request->base_string = $base_string; 124 138 125 139 $key_parts = array( 126 140 $consumer->secret, … … 136 150 137 151 /** 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 139 153 * over a secure channel such as HTTPS. It does not use the Signature Base String. 140 154 * - Chapter 9.4 ("PLAINTEXT") 141 155 */ 156 157 namespace Mapi; 158 142 159 class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod { 143 160 public function get_name() { … … 146 163 147 164 /** 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 150 167 * empty. The result MUST be encoded again. 151 168 * - Chapter 9.4.1 ("Generating Signatures") … … 169 186 170 187 /** 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 175 192 * specification. 176 193 * - Chapter 9.3 ("RSA-SHA1") 177 194 */ 195 196 namespace Mapi; 197 178 198 abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod { 179 199 public function get_name() { … … 234 254 } 235 255 } 256 257 namespace Mapi; 236 258 237 259 class OAuthRequest { … … 379 401 $this->get_signable_parameters() 380 402 ); 381 403 382 404 $parts = OAuthUtil::urlencode_rfc3986($parts); 383 405 384 406 return implode('&', $parts); 385 407 } … … 495 517 } 496 518 519 namespace Mapi; 520 497 521 class OAuthServer { 498 522 protected $timestamp_threshold = 300; // in seconds, five minutes … … 573 597 $version = $request->get_parameter("oauth_version"); 574 598 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. 576 600 // Chapter 7.0 ("Accessing Protected Ressources") 577 601 $version = '1.0'; … … 587 611 */ 588 612 private function get_signature_method($request) { 589 $signature_method = $request instanceof OAuthRequest 613 $signature_method = $request instanceof OAuthRequest 590 614 ? $request->get_parameter("oauth_signature_method") 591 615 : NULL; … … 612 636 */ 613 637 private function get_consumer($request) { 614 $consumer_key = $request instanceof OAuthRequest 638 $consumer_key = $request instanceof OAuthRequest 615 639 ? $request->get_parameter("oauth_consumer_key") 616 640 : NULL; … … 684 708 'Missing timestamp parameter. The parameter is required' 685 709 ); 686 710 687 711 // verify that timestamp is recentish 688 712 $now = time(); … … 717 741 } 718 742 743 namespace Mapi; 744 719 745 class OAuthDataStore { 720 746 function lookup_consumer($consumer_key) { … … 743 769 } 744 770 771 namespace Mapi; 772 745 773 class OAuthUtil { 746 774 public static function urlencode_rfc3986($input) { 747 775 if (is_array($input)) { 748 return array_map(array(' OAuthUtil', 'urlencode_rfc3986'), $input);776 return array_map(array('\Mapi\OAuthUtil', 'urlencode_rfc3986'), $input); 749 777 } else if (is_scalar($input)) { 750 778 return str_replace( -
mediapost-extensao-para-contact-form-7/trunk/readme.txt
r1799113 r1853453 3 3 Tags: @mediapost, mediapost, Contact Form 7, Contact Form 7 Extension, Extensão Contact Form 7, Formulario 4 4 Requires at least: 3.0.1 5 Tested up to: 4.9. 16 Stable tag: 1.0 5 Tested up to: 4.9.5 6 Stable tag: 1.0.1 7 7 8 8 == Description ==
Note: See TracChangeset
for help on using the changeset viewer.