Version Description
To upgrade User Submitted Posts, remove the old version and replace with the new version. Or just click "Update" from the Plugins screen and let WordPress do it for you automatically.
Important! The /custom/
directory is deprecated. If you are using a custom form template, please move it to /wp-content/your-theme/usp/
. For more information, check out the "Custom Submission Form" section under Installation.
Note: uninstalling the plugin from the WP Plugins screen results in the removal of all settings from the WP database. Submitted posts are NOT removed if you deactivate the plugin, reset default options, or uninstall the plugins; that is, all submitted posts must be removed manually.
Download this release
Release Info
Developer | specialk |
Plugin | User Submitted Posts |
Version | 20171105 |
Comparing to | |
See all releases |
Code changes from version 20171104 to 20171105
- readme.txt +6 -2
- recaptcha/connect-new.php +67 -0
- recaptcha/connect-old.php +62 -0
- recaptcha/recaptcha-old.php +143 -0
- user-submitted-posts.php +6 -32
readme.txt
CHANGED
@@ -10,8 +10,8 @@ Donate link: https://m0n.co/donate
|
|
10 |
Contributors: specialk
|
11 |
Requires at least: 4.1
|
12 |
Tested up to: 4.9
|
13 |
-
Stable tag:
|
14 |
-
Version:
|
15 |
Requires PHP: 5.2
|
16 |
Text Domain: usp
|
17 |
Domain Path: /languages
|
@@ -591,6 +591,10 @@ Links, tweets and likes also appreciated. Thanks! :)
|
|
591 |
|
592 |
*Thank you to everyone who shares feedback for User Submitted Posts!*
|
593 |
|
|
|
|
|
|
|
|
|
594 |
**20171104**
|
595 |
|
596 |
* Fixes bug involving jQuery cookie functionality
|
10 |
Contributors: specialk
|
11 |
Requires at least: 4.1
|
12 |
Tested up to: 4.9
|
13 |
+
Stable tag: 20171105
|
14 |
+
Version: 20171105
|
15 |
Requires PHP: 5.2
|
16 |
Text Domain: usp
|
17 |
Domain Path: /languages
|
591 |
|
592 |
*Thank you to everyone who shares feedback for User Submitted Posts!*
|
593 |
|
594 |
+
**20171105**
|
595 |
+
|
596 |
+
- Provides Google reCAPTCHA support for older PHP versions (less than 5.3)
|
597 |
+
|
598 |
**20171104**
|
599 |
|
600 |
* Fixes bug involving jQuery cookie functionality
|
recaptcha/connect-new.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php // Google reCAPTCHA for PHP >= 5.3.0
|
2 |
+
|
3 |
+
// PHP Global space backslash class requires >= 5.3.0
|
4 |
+
|
5 |
+
// Google reCAPTCHA 1.1.3 @ https://github.com/google/recaptcha
|
6 |
+
|
7 |
+
// Supports allow_url_fopen/file_get_contents and cURL
|
8 |
+
|
9 |
+
if (!defined('ABSPATH')) die();
|
10 |
+
|
11 |
+
require_once('autoload.php');
|
12 |
+
|
13 |
+
if (ini_get('allow_url_fopen')) {
|
14 |
+
|
15 |
+
// file_get_contents: allow_url_fopen = on
|
16 |
+
$recaptcha = new \ReCaptcha\ReCaptcha($private);
|
17 |
+
|
18 |
+
} elseif (extension_loaded('curl')) {
|
19 |
+
|
20 |
+
// cURL: allow_url_fopen = off
|
21 |
+
$recaptcha = new \ReCaptcha\ReCaptcha($private, new \ReCaptcha\RequestMethod\CurlPost());
|
22 |
+
|
23 |
+
} else {
|
24 |
+
|
25 |
+
$recaptcha = null;
|
26 |
+
|
27 |
+
error_log('WP Plugin USP: Google reCAPTCHA: allow_url_fopen and curl both disabled!', 0);
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
if (isset($recaptcha)) {
|
32 |
+
|
33 |
+
$response = $recaptcha->verify($_POST['g-recaptcha-response'], usp_get_ip_address());
|
34 |
+
|
35 |
+
} else {
|
36 |
+
|
37 |
+
$response = null;
|
38 |
+
|
39 |
+
error_log('WP Plugin USP: Google reCAPTCHA: $recaptcha variable not set!', 0);
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
if ($response->isSuccess()) {
|
44 |
+
|
45 |
+
return true;
|
46 |
+
|
47 |
+
} else {
|
48 |
+
|
49 |
+
$errors = $response->getErrorCodes();
|
50 |
+
|
51 |
+
if (!empty($errors) && is_array($errors)) {
|
52 |
+
|
53 |
+
foreach ($errors as $error) {
|
54 |
+
|
55 |
+
error_log('WP Plugin USP: Google reCAPTCHA: '. $error, 0);
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
} else {
|
60 |
+
|
61 |
+
error_log('WP Plugin USP: Google reCAPTCHA: '. $errors, 0);
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
return false;
|
recaptcha/connect-old.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php // Google reCAPTCHA for PHP < 5.3.0
|
2 |
+
|
3 |
+
// PHP Global space backslash class requires >= 5.3.0
|
4 |
+
|
5 |
+
// Google reCAPTCHA 2014 version
|
6 |
+
|
7 |
+
// Requires allow_url_fopen/file_get_contents
|
8 |
+
|
9 |
+
if (!defined('ABSPATH')) die();
|
10 |
+
|
11 |
+
require_once('recaptcha-old.php');
|
12 |
+
|
13 |
+
if (ini_get('allow_url_fopen')) {
|
14 |
+
|
15 |
+
// allow_url_fopen = on
|
16 |
+
$recaptcha = new ReCaptcha($private);
|
17 |
+
|
18 |
+
} else {
|
19 |
+
|
20 |
+
$recaptcha = null;
|
21 |
+
|
22 |
+
error_log('WP Plugin USP: Google reCAPTCHA: PHP less than 5.3 and allow_url_fopen disabled!', 0);
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
if (isset($recaptcha)) {
|
27 |
+
|
28 |
+
$response = $recaptcha->verifyResponse(usp_get_ip_address(), $_POST['g-recaptcha-response']);
|
29 |
+
|
30 |
+
} else {
|
31 |
+
|
32 |
+
$response = null;
|
33 |
+
|
34 |
+
error_log('WP Plugin USP: Google reCAPTCHA: $recaptcha variable not set!', 0);
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
if ($response->success) {
|
39 |
+
|
40 |
+
return true;
|
41 |
+
|
42 |
+
} else {
|
43 |
+
|
44 |
+
$errors = $response->errorCodes;
|
45 |
+
|
46 |
+
if (!empty($errors) && is_array($errors)) {
|
47 |
+
|
48 |
+
foreach ($errors as $error) {
|
49 |
+
|
50 |
+
error_log('WP Plugin USP: Google reCAPTCHA: '. $error, 0);
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
} else {
|
55 |
+
|
56 |
+
error_log('WP Plugin USP: Google reCAPTCHA: '. $errors, 0);
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
return false;
|
recaptcha/recaptcha-old.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This is a PHP library that handles calling reCAPTCHA.
|
4 |
+
* - Documentation and latest version
|
5 |
+
* https://developers.google.com/recaptcha/docs/php
|
6 |
+
* - Get a reCAPTCHA API Key
|
7 |
+
* https://www.google.com/recaptcha/admin/create
|
8 |
+
* - Discussion group
|
9 |
+
* http://groups.google.com/group/recaptcha
|
10 |
+
*
|
11 |
+
* @copyright Copyright (c) 2014, Google Inc.
|
12 |
+
* @link http://www.google.com/recaptcha
|
13 |
+
*
|
14 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 |
+
* of this software and associated documentation files (the "Software"), to deal
|
16 |
+
* in the Software without restriction, including without limitation the rights
|
17 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
18 |
+
* copies of the Software, and to permit persons to whom the Software is
|
19 |
+
* furnished to do so, subject to the following conditions:
|
20 |
+
*
|
21 |
+
* The above copyright notice and this permission notice shall be included in
|
22 |
+
* all copies or substantial portions of the Software.
|
23 |
+
*
|
24 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
25 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
26 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
27 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
28 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
29 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
30 |
+
* THE SOFTWARE.
|
31 |
+
*/
|
32 |
+
|
33 |
+
/*
|
34 |
+
|
35 |
+
Note: changed constructor name from ReCaptcha to __construct.
|
36 |
+
|
37 |
+
*/
|
38 |
+
|
39 |
+
/**
|
40 |
+
* A ReCaptchaResponse is returned from checkAnswer().
|
41 |
+
*/
|
42 |
+
class ReCaptchaResponse
|
43 |
+
{
|
44 |
+
public $success;
|
45 |
+
public $errorCodes;
|
46 |
+
}
|
47 |
+
|
48 |
+
class ReCaptcha
|
49 |
+
{
|
50 |
+
private static $_signupUrl = "https://www.google.com/recaptcha/admin";
|
51 |
+
private static $_siteVerifyUrl = "https://www.google.com/recaptcha/api/siteverify?";
|
52 |
+
private $_secret;
|
53 |
+
private static $_version = "php_1.0";
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Constructor.
|
57 |
+
*
|
58 |
+
* @param string $secret shared secret between site and ReCAPTCHA server.
|
59 |
+
*/
|
60 |
+
function __construct($secret)
|
61 |
+
{
|
62 |
+
if ($secret == null || $secret == "") {
|
63 |
+
die("To use reCAPTCHA you must get an API key from <a href='"
|
64 |
+
. self::$_signupUrl . "'>" . self::$_signupUrl . "</a>");
|
65 |
+
}
|
66 |
+
$this->_secret=$secret;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Encodes the given data into a query string format.
|
71 |
+
*
|
72 |
+
* @param array $data array of string elements to be encoded.
|
73 |
+
*
|
74 |
+
* @return string - encoded request.
|
75 |
+
*/
|
76 |
+
private function _encodeQS($data)
|
77 |
+
{
|
78 |
+
$req = "";
|
79 |
+
foreach ($data as $key => $value) {
|
80 |
+
$req .= $key . '=' . urlencode(stripslashes($value)) . '&';
|
81 |
+
}
|
82 |
+
|
83 |
+
// Cut the last '&'
|
84 |
+
$req=substr($req, 0, strlen($req)-1);
|
85 |
+
return $req;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Submits an HTTP GET to a reCAPTCHA server.
|
90 |
+
*
|
91 |
+
* @param string $path url path to recaptcha server.
|
92 |
+
* @param array $data array of parameters to be sent.
|
93 |
+
*
|
94 |
+
* @return array response
|
95 |
+
*/
|
96 |
+
private function _submitHTTPGet($path, $data)
|
97 |
+
{
|
98 |
+
$req = $this->_encodeQS($data);
|
99 |
+
$response = file_get_contents($path . $req);
|
100 |
+
return $response;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Calls the reCAPTCHA siteverify API to verify whether the user passes
|
105 |
+
* CAPTCHA test.
|
106 |
+
*
|
107 |
+
* @param string $remoteIp IP address of end user.
|
108 |
+
* @param string $response response string from recaptcha verification.
|
109 |
+
*
|
110 |
+
* @return ReCaptchaResponse
|
111 |
+
*/
|
112 |
+
public function verifyResponse($remoteIp, $response)
|
113 |
+
{
|
114 |
+
// Discard empty solution submissions
|
115 |
+
if ($response == null || strlen($response) == 0) {
|
116 |
+
$recaptchaResponse = new ReCaptchaResponse();
|
117 |
+
$recaptchaResponse->success = false;
|
118 |
+
$recaptchaResponse->errorCodes = 'missing-input';
|
119 |
+
return $recaptchaResponse;
|
120 |
+
}
|
121 |
+
|
122 |
+
$getResponse = $this->_submitHttpGet(
|
123 |
+
self::$_siteVerifyUrl,
|
124 |
+
array (
|
125 |
+
'secret' => $this->_secret,
|
126 |
+
'remoteip' => $remoteIp,
|
127 |
+
'v' => self::$_version,
|
128 |
+
'response' => $response
|
129 |
+
)
|
130 |
+
);
|
131 |
+
$answers = json_decode($getResponse, true);
|
132 |
+
$recaptchaResponse = new ReCaptchaResponse();
|
133 |
+
|
134 |
+
if (trim($answers ['success']) == true) {
|
135 |
+
$recaptchaResponse->success = true;
|
136 |
+
} else {
|
137 |
+
$recaptchaResponse->success = false;
|
138 |
+
$recaptchaResponse->errorCodes = $answers [error-codes];
|
139 |
+
}
|
140 |
+
|
141 |
+
return $recaptchaResponse;
|
142 |
+
}
|
143 |
+
}
|
user-submitted-posts.php
CHANGED
@@ -10,8 +10,8 @@
|
|
10 |
Contributors: specialk
|
11 |
Requires at least: 4.1
|
12 |
Tested up to: 4.9
|
13 |
-
Stable tag:
|
14 |
-
Version:
|
15 |
Requires PHP: 5.2
|
16 |
Text Domain: usp
|
17 |
Domain Path: /languages
|
@@ -40,7 +40,7 @@ if (!defined('ABSPATH')) die();
|
|
40 |
|
41 |
|
42 |
define('USP_WP_VERSION', '4.1');
|
43 |
-
define('USP_VERSION', '
|
44 |
define('USP_PLUGIN', esc_html__('User Submitted Posts', 'usp'));
|
45 |
define('USP_PATH', plugin_basename(__FILE__));
|
46 |
|
@@ -311,39 +311,13 @@ function usp_verify_recaptcha() {
|
|
311 |
|
312 |
if (isset($_POST['g-recaptcha-response'])) {
|
313 |
|
314 |
-
|
315 |
-
require_once(plugin_dir_path(__FILE__) .'recaptcha/autoload.php');
|
316 |
-
|
317 |
-
if (ini_get('allow_url_fopen')) {
|
318 |
-
|
319 |
-
// allow_url_fopen = on
|
320 |
-
$recaptcha = new \ReCaptcha\ReCaptcha($private);
|
321 |
|
322 |
-
|
323 |
-
|
324 |
-
$recaptcha = new \ReCaptcha\ReCaptcha($private, new \ReCaptcha\RequestMethod\CurlPost());
|
325 |
|
326 |
} else {
|
327 |
|
328 |
-
|
329 |
-
|
330 |
-
}
|
331 |
-
|
332 |
-
$response = $recaptcha->verify($_POST['g-recaptcha-response'], usp_get_ip_address());
|
333 |
-
|
334 |
-
if ($response->isSuccess()) {
|
335 |
-
|
336 |
-
return true;
|
337 |
-
|
338 |
-
} else {
|
339 |
-
|
340 |
-
$errors = $response->getErrorCodes();
|
341 |
-
|
342 |
-
foreach ($errors as $error) {
|
343 |
-
|
344 |
-
error_log('WP Plugin USP: Google reCAPTCHA: '. $error, 0);
|
345 |
-
|
346 |
-
}
|
347 |
|
348 |
}
|
349 |
|
10 |
Contributors: specialk
|
11 |
Requires at least: 4.1
|
12 |
Tested up to: 4.9
|
13 |
+
Stable tag: 20171105
|
14 |
+
Version: 20171105
|
15 |
Requires PHP: 5.2
|
16 |
Text Domain: usp
|
17 |
Domain Path: /languages
|
40 |
|
41 |
|
42 |
define('USP_WP_VERSION', '4.1');
|
43 |
+
define('USP_VERSION', '20171105');
|
44 |
define('USP_PLUGIN', esc_html__('User Submitted Posts', 'usp'));
|
45 |
define('USP_PATH', plugin_basename(__FILE__));
|
46 |
|
311 |
|
312 |
if (isset($_POST['g-recaptcha-response'])) {
|
313 |
|
314 |
+
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
|
316 |
+
return require_once(plugin_dir_path(__FILE__) .'recaptcha/connect-new.php');
|
|
|
|
|
317 |
|
318 |
} else {
|
319 |
|
320 |
+
return require_once(plugin_dir_path(__FILE__) .'recaptcha/connect-old.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
|
322 |
}
|
323 |
|