Skip to content

Commit

Permalink
Merge pull request #3 from wopsononock/master
Browse files Browse the repository at this point in the history
Update for OJS 3.3
  • Loading branch information
wopsononock authored Feb 7, 2022
2 parents a86792b + b1c5232 commit 83f0d45
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 24 deletions.
36 changes: 14 additions & 22 deletions AkismetPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,33 +413,25 @@ function _sendPayload($data, $flag = false) {
return false;
}
// build the Akismet HTTP request
$requestBody = '';
foreach ($data as $k => $v) {
if (!empty($v)) {
$requestBody .= '&'.$k.'='.urlencode($v);
}
}
$requestBody = ltrim($requestBody, '&');
$host = $akismetKey.'.rest.akismet.com';
$port = 443;
$path = '/1.1/' . ($flag ? 'submit-spam' : 'comment-check');
$versionDao =& DAORegistry::getDAO('VersionDAO');
$dbVersion =& $versionDao->getCurrentVersion();
$ua = $dbVersion->getProduct().' '.$dbVersion->getVersionString().' | Akismet/3.1.7';
$httpRequest = "POST {$path} HTTP/1.0\r\n";
$httpRequest .= "Host: {$host}\r\n";
$httpRequest .= "Content-Type: application/x-www-form-urlencoded\r\n";
$httpRequest .= "Content-Length: ".strlen($requestBody)."\r\n";
$httpRequest .= "User-Agent: {$ua}\r\n";
$httpRequest .= "\r\n{$requestBody}";
$response = $errno = $errstr = $headers = $content = '';
if (false != ($socket = fsockopen('ssl://'.$host, $port, $errno, $errstr))) {
fwrite($socket, $httpRequest);
while (!feof($socket)) {
$response .= fgets($socket);
}
fclose($socket);
list($headers, $content) = explode("\r\n\r\n", $response, 2);
$httpClient = Application::get()->getHttpClient();
try {$response = $httpClient->request(
'POST',
'https://'.$host.$path,
[
'User-Agent'=>$ua,
'form_params' => $data
]
);
$content = (string) $response->getBody();
}
catch (Exception $e){
$content='';
error_log($e->getMessage());
}
return ((!$flag && $content === 'true') || ($flag && $content === 'Thanks for making the web a better place.'));
}
Expand Down
51 changes: 51 additions & 0 deletions locale/en_US/locale.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2022-02-02T11:39:21-05:00\n"
"PO-Revision-Date: 2022-02-02T11:39:21-05:00\n"
"Language: \n"

msgid "plugins.generic.akismet.displayName"
msgstr "Akismet Anti-Spam Plugin"

msgid "plugins.generic.akismet.description"
msgstr "Integrate OJS with Akismet for new user registrations. Through this plugin, OJS can submit each new user registration to Akismet, and will reject those Akismet identifies as spam."

msgid "plugins.generic.akismet.spamDetected"
msgstr "This entry has been flagged as spam."

msgid "plugins.generic.akismet.spamFailed"
msgstr "Flagging this entry as spam failed."

msgid "plugins.generic.akismet.privacyNotice"
msgstr "All information collected via this form (except for the password) may be submitted to a third party (Akismet) for spam filtering. Please review <a href=\"https://automattic.com/privacy-notice/\" target=\"_blank\">the Akismet service's privacy notice</a>."

msgid "plugins.generic.akismet.manager.akismetSettings"
msgstr "Akismet Settings"

msgid "plugins.generic.akismet.manager.settings.description"
msgstr "<p>Please provide the Akismet API key. You must already have registered with <a href=\"https://akismet.com/\">Akismet</a> for the service.</p>"

msgid "plugins.generic.akismet.manager.settings.akismetKey"
msgstr "Akismet API key"

msgid "plugins.generic.akismet.manager.settings.akismetKeyRequired"
msgstr "The Akismet API key is required."

msgid "plugins.generic.akismet.manager.settings.akismetPrivacyNotice"
msgstr "Display a privacy notice on the registration page."

msgid "plugins.generic.akismet.actions.flagAsSpam"
msgstr "Report as spam"

msgid "plugins.generic.akismet.grid.action.flagAsSpam"
msgstr "Report as spam to Akismet"

msgid "plugins.generic.akismet.actions.confirmFlagAsSpam"
msgstr "Do you want to report this user's registration to Akismet as spam?"
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<version>
<application>akismet</application>
<type>plugins.generic</type>
<release>1.2.2.2</release>
<date>2021-07-23</date>
<release>1.2.3.0</release>
<date>2022-02-03</date>
<lazy-load>1</lazy-load>
<class>AkismetPlugin</class>
</version>

0 comments on commit 83f0d45

Please sign in to comment.