From 601e6e995a7a0ce52ec6b87651b2687dd2f14b91 Mon Sep 17 00:00:00 2001 From: Joseph Snyder Date: Mon, 12 Dec 2016 10:34:10 -0500 Subject: [PATCH] Add Google RECAPTCHA to the OTJ Download Add the RECAPTCHA framework to the download page to eliminate bot downloads of the software. Add configuration for the administrators to add the RECAPTCHA secret key on the configuration page for the Journal module For more information or to acquire a secret key for a site, see https://www.google.com/recaptcha/intro/index.html --- controllers/ConfigController.php | 3 ++ layouts/osehra.phtml | 1 + public/js/view/view.download.js | 1 - views/config/index.phtml | 4 ++ views/view/download.phtml | 77 +++++++++++++++++++++++--------- 5 files changed, 64 insertions(+), 22 deletions(-) diff --git a/controllers/ConfigController.php b/controllers/ConfigController.php index 3801fa5..f4aee65 100755 --- a/controllers/ConfigController.php +++ b/controllers/ConfigController.php @@ -29,6 +29,7 @@ function indexAction() $this->view->baseHandle = MidasLoader::loadModel("Setting")->getValueByName('baseHandle', "journal"); $this->view->oldWebsiteUrl = MidasLoader::loadModel("Setting")->getValueByName('oldWebsiteUrl', "journal"); $this->view->licenseDisclaimer = MidasLoader::loadModel("Setting")->getValueByName('licenseDisclaimer', "journal"); + $this->view->captchaSecret = MidasLoader::loadModel("Setting")->getValueByName('captchaSecret', "journal"); $this->view->json['isConfigSaved'] = 0; if($this->_request->isPost() && is_numeric($_POST['defaultJournal'])) @@ -40,12 +41,14 @@ function indexAction() $this->view->adminEmail = $_POST['adminEmail']; $this->view->oldWebsiteUrl = $_POST['oldWebsiteUrl']; $this->view->licenseDisclaimer = $_POST['licenseDisclaimer']; + $this->view->captchaSecret = $_POST['captchaSecret']; MidasLoader::loadModel("Setting")->setConfig('adminEmail', $this->view->adminEmail, "journal"); MidasLoader::loadModel("Setting")->setConfig('defaultJournal', $this->view->defaultJournal, "journal"); MidasLoader::loadModel("Setting")->setConfig('defaultLayout', $this->view->defaultLayout, "journal"); MidasLoader::loadModel("Setting")->setConfig('baseHandle', $this->view->baseHandle, "journal"); MidasLoader::loadModel("Setting")->setConfig('oldWebsiteUrl', $this->view->oldWebsiteUrl, "journal"); MidasLoader::loadModel("Setting")->setConfig('licenseDisclaimer', $this->view->licenseDisclaimer, "journal"); + MidasLoader::loadModel("Setting")->setConfig('captchaSecret', $this->view->captchaSecret, "journal"); if(is_numeric($this->view->baseHandle)) { // This is a hack allowing us to use the Zend dispatch mechanisum to resolve the handles diff --git a/layouts/osehra.phtml b/layouts/osehra.phtml index 99e0bdf..714610c 100755 --- a/layouts/osehra.phtml +++ b/layouts/osehra.phtml @@ -67,6 +67,7 @@ echo $this->doctype() headLink(); // import the css ?> headStyle(); // import the css ?> + diff --git a/public/js/view/view.download.js b/public/js/view/view.download.js index 817f745..d3cd4ab 100644 --- a/public/js/view/view.download.js +++ b/public/js/view/view.download.js @@ -1,6 +1,5 @@ // When page ready $(document).ready(function(){ - if($('#disclaimerWrapperLicense').length != 0) { $.fancybox.open([ diff --git a/views/config/index.phtml b/views/config/index.phtml index 9bb5b01..83d6dff 100755 --- a/views/config/index.phtml +++ b/views/config/index.phtml @@ -52,6 +52,10 @@ $this->headScript()->appendFile($this->webroot."/privateModules/journal/public/j +
+ + +
diff --git a/views/view/download.phtml b/views/view/download.phtml index c90ea11..d458ce6 100644 --- a/views/view/download.phtml +++ b/views/view/download.phtml @@ -28,33 +28,68 @@ $this->headScript()->appendFile($this->webroot . '/privateModules/journal/public Back to article

- +}; + ?> getValueByName('licenseDisclaimer', "journal"); $disclaimer = MidasLoader::loadModel("Disclaimer", "journal")->load($disclaimerIndex); - if($disclaimer) + if($disclaimer && $_POST['g-recaptcha-response'] ) { echo '"; } -if($this->resource->getDisclaimer() != -1) +if(($this->resource->getDisclaimer() != -1) && $_POST['g-recaptcha-response']) { $disclaimer = MidasLoader::loadModel("Disclaimer", "journal")->load($this->resource->getDisclaimer()); if($disclaimer)