From 9f26e9d49afd1f69d7423b895c24c466ab88af6b Mon Sep 17 00:00:00 2001 From: Seersco Date: Tue, 19 Apr 2022 12:36:53 +0500 Subject: [PATCH] =?UTF-8?q?=C3=8Fnitial=20Commit=20module=20v4.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 1 + .../en-GB.plg_system_seerscookieconsent.ini | 22 ++ ...n-GB.plg_system_seerscookieconsent.sys.ini | 7 + seerscookieconsent.php | 244 ++++++++++++++++++ seerscookieconsent.xml | 75 ++++++ sql/index.html | 0 sql/install.mysql.utf8.sql | 8 + sql/uninstall.mysql.utf8.sql | 1 + 8 files changed, 358 insertions(+) create mode 100644 index.html create mode 100644 language/en-GB/en-GB.plg_system_seerscookieconsent.ini create mode 100644 language/en-GB/en-GB.plg_system_seerscookieconsent.sys.ini create mode 100644 seerscookieconsent.php create mode 100644 seerscookieconsent.xml create mode 100644 sql/index.html create mode 100644 sql/install.mysql.utf8.sql create mode 100644 sql/uninstall.mysql.utf8.sql diff --git a/index.html b/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_system_seerscookieconsent.ini b/language/en-GB/en-GB.plg_system_seerscookieconsent.ini new file mode 100644 index 0000000..45fe8f5 --- /dev/null +++ b/language/en-GB/en-GB.plg_system_seerscookieconsent.ini @@ -0,0 +1,22 @@ +; Joomla! Project +; Copyright (C) 2009 - 2020 SCHRIJEVRS123/M:. All rights reserved. +; Note : All ini files need to be saved as UTF-8 + + + +PLG_SEERSCOOKIECONSENT_FIELD_URL_LABEL = "URL"; +PLG_SEERSCOOKIECONSENT_FIELD_URL_DESC = "URL of your joomla site"; +PLG_SEERSCOOKIECONSENT_FIELD_EMAIL_LABEL = "Email"; +PLG_SEERSCOOKIECONSENT_FIELD_EMAIL_DESC = "Email of your joomla site"; +PLG_SEERSCOOKIECONSENT_FIELD_DOMAIN_GROUP_ID_LABEL = "Domain Group ID"; +PLG_SEERSCOOKIECONSENT_FIELD_DOMAIN_GROUP_ID_DESC = "Enter here the Domain Group ID of Seers Cookie Consent. See the Seersco.com admin area of Cookie Consent or ask your developer/seller for the code"; +PLG_SEERSCOOKIECONSENT_FIELD_NOTE_LABEL = "CONSENT"; +PLG_SEERSCOOKIECONSENT_FIELD_NOTE_DESC = "By using this plugin, you agree to the terms and condition and privacy policy,
and also agree Seers to use my email and url to create an account and power the cookie banner."; +PLG_SEERSCOOKIECONSENT_FIELD_CONSENT_LABEL="Agreement"; +PLG_SEERSCOOKIECONSENT_FIELD_CONSENT_DESC = "You must gave consent to get your Domain Group ID to show banner" +;PLG_SEERSCOOKIECONSENT_FIELD_SCRIPT_CHANGE_LABEL = "Scripts to change" +;PLG_SEERSCOOKIECONSENT_FIELD_SCRIPT_CHANGE_PLACEHOLDER="myscript1.js|marketing\nmyscript2.js|statistics" +;PLG_SEERSCOOKIECONSENT_FIELD_ENABLE_CD_LABEL="Enable Cookie Declaration" +;PLG_SEERSCOOKIECONSENT_FIELD_ENABLE_CD_DESC="

Enable the Cookie Declaration script. On the place where you want to add the Cookie Declaration, enter {SEERSCOOKIECONSENT DECLARATION}

" +;PLG_SEERSCOOKIECONSENT_FIELD_CD_CHANGE_LABEL="Phrase tag" +;PLG_SEERSCOOKIECONSENT_FIELD_CD_CHANGE_DESC="

Enter the phrase that will be replaced by the Seers Cookie Consent Script. Normal is the defaul value enough.

Default: SEERSCOOKIECONSENT DECLARATION

Where ever the Cookie Declaration needs to be showed, use {[phrase tag]}.
E.g. {SEERSCOOKIECONSENT DECLARATION}

" \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_system_seerscookieconsent.sys.ini b/language/en-GB/en-GB.plg_system_seerscookieconsent.sys.ini new file mode 100644 index 0000000..9b2bac3 --- /dev/null +++ b/language/en-GB/en-GB.plg_system_seerscookieconsent.sys.ini @@ -0,0 +1,7 @@ +; Joomla! Project +; Copyright (C) 2009 - 2020 Open Source Matters. All rights reserved. +; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php +; Note : All ini files need to be saved as UTF-8 + +PLG_SEERSCOOKIECONSENT_XML_DESCRIPTION="

Seers Cookie Consent is a cloud based Consent Management Platform (CMP) for compliance with GDPR, ePrivacy Regulation, PECR and CCPA.

Enter your website URL(auto picked) and valid email(to create an accound on Seers) then click on Save Button to get your Domain Group ID.

Don't forget to enable the plugin.

" +PLG_SYSTEM_SEERSCOOKIECONSENT="System - Seers | Cookie Consent Banner and Privacy Policy" \ No newline at end of file diff --git a/seerscookieconsent.php b/seerscookieconsent.php new file mode 100644 index 0000000..27f3dc4 --- /dev/null +++ b/seerscookieconsent.php @@ -0,0 +1,244 @@ +. +*/ + +defined('_JEXEC') or die; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Http\HttpFactory; +use Joomla\CMS\Factory; + +/** + * Joomla! SeersCookieConsent plugin. + * + * @since 1.5 + */ +class PlgSystemSeersCookieConsent extends JPlugin +{ + private $cookieid; + private $seers_email; + private $seers_url; + private $langTag; + + + public function onAfterRender() + { + $app =jFactory::getApplication(); + if ($app->isClient('site') == false) + { + return; + } + + $db= JFactory::getDbo(); + $query = "SELECT id,url,email,apikey,hitcount + FROM #__seers_cookie_consent order by id desc"; + $db->setQuery($query); + $last_row = $db->loadObject(); + if($last_row && $last_row->id){ + $this->seers_url = $last_row->url; + $this->seers_email = $last_row->email; + $this->cookieid = $last_row->apikey; + } + + $my_url = $this->params->get('my_url'); + $my_email = $this->params->get('my_email'); + + + + $body = $app->getBody(); + $cookie_script = sprintf('', $this->cookieid); + $body = str_replace('', $cookie_script , $body); + $app->setBody($body); + } + + function onContentPrepareForm($form, $data) + { + + $db= JFactory::getDbo(); + $query = "SELECT id,url,email,apikey,hitcount + FROM #__seers_cookie_consent order by id desc"; + $db->setQuery($query); + $last_row = $db->loadObject(); + if($last_row && $last_row->id){ + $this->seers_url = $last_row->url; + $this->seers_email = $last_row->email; + $this->cookieid = $last_row->apikey; + } + if($this->cookieid){ + $form->setFieldAttribute('domain_group_id', 'default' , $this->cookieid , 'params'); + } + if($this->seers_url){ + $form->setFieldAttribute('my_url', 'default' , $this->seers_url , 'params'); + } + if($this->seers_email){ + $form->setFieldAttribute('my_email', 'default' , $this->seers_email , 'params'); + } + if ($this->params->get('domain_group_id') == ''){ + + $uri = JUri::getInstance(); + $my_url = $uri->root(); + + $user = Factory::getUser('admin'); + $my_email = $user->get('email'); + + + $form->setFieldAttribute('my_url', 'default' , $my_url , 'params'); + $form->setFieldAttribute('my_email', 'default' , $my_email , 'params'); + + + $my_url = $this->params->get('my_url'); + $my_email = $this->params->get('my_email'); + $form->setFieldAttribute('domain_group_id', 'default' , $this->cookieid , 'params'); + + } + + } + + private function Seers_API ($my_url, $my_email){ + $this->langTag = JComponentHelper::getParams('com_languages')->get('site'); + $postData = array( + 'domain'=>$my_url, + 'email'=>$my_email, + 'secret'=>'$2y$10$9ygTfodVBVM0XVCdyzEUK.0FIuLnJT0D42sIE6dIu9r/KY3XaXXyS', + 'platform'=>'joomla', + 'lang' => str_replace("-","_",$this->langTag), + ); + + $request_headers = array( + 'Content-Type: application/json', + 'Referer: '.$my_url + ); + $url = "https://seersco.com/api/get-key-for-joomla"; + $postdata = json_encode($postData); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers); + $result = curl_exec($ch); + curl_close($ch); + + $response = json_decode($result,true); + + + //$this->cookieid = ''; + if ($response){ + //counter for api start + + $profile = new stdClass(); + + $db= JFactory::getDbo(); + $query = "SELECT id,url,email,apikey,hitcount + FROM #__seers_cookie_consent order by id desc"; + $db->setQuery($query); + $last_row = $db->loadObject(); + if(isset($last_row) && isset($last_row->id)){ + $profile->id = $last_row->id; + $profile->hitcount = intval($last_row->hitcount) + 1; + $result = JFactory::getDbo()->updateObject('#__seers_cookie_consent', $profile,'id'); + } + + + //counter for api end + + + return( $response['key']); + }else{ + return ''; + } + } + public function onExtensionAfterSave(){ + + } + + public function onExtensionBeforeSave($context, $item, $isNew){ + + if ($context !== "com_plugins.plugin" || $item->type !== "plugin") + { + return true; + } + + //read the xml file of this plugin and use this xml to get the plugin name + $xmlfile = simplexml_load_file(__DIR__ . "/" . $item->element . ".xml"); + + $params = new JRegistry($item->params); + $my_url = $params["my_url"]; + $my_email = $params["my_email"]; + $this->cookieid = $this->Seers_API($my_url, $my_email); + + $this->Seers_Plugin_API($my_url, $item->enabled, ((!empty($xmlfile->name)) ? (string)$xmlfile->name : '' )); + + $profile = new stdClass(); + $profile->url=$my_url; + $profile->email=$my_email; + $profile->apikey=$this->cookieid; + + + $db= JFactory::getDbo(); + $query = "SELECT id,url,email,apikey,hitcount + FROM #__seers_cookie_consent order by id desc"; + $db->setQuery($query); + $last_row = $db->loadObject(); + if(isset($last_row) && isset($last_row->id)){ + $profile->id = $last_row->id; + $result = JFactory::getDbo()->updateObject('#__seers_cookie_consent', $profile,'id'); + } + else{ + $result = JFactory::getDbo()->insertObject('#__seers_cookie_consent', $profile); + } + + } + + private function Seers_Plugin_API ($my_url, $enabled, $pluginname){ + $postData = array( + 'domain'=>$my_url, + 'isactive'=>$enabled, + 'secret'=>'$2y$10$9ygTfodVBVM0XVCdyzEUK.0FIuLnJT0D42sIE6dIu9r/KY3XaXXyS', + 'platform'=>'joomla', + 'pluginname' => $pluginname + ); + + $request_headers = array( + 'Content-Type: application/json', + 'Referer: '.$my_url + ); + $url = "https://cmp.seersco.com/api/plugin-domain"; + $postdata = json_encode($postData); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers); + $result = curl_exec($ch); + curl_close($ch); + + $response = json_decode($result,true); +} + +} diff --git a/seerscookieconsent.xml b/seerscookieconsent.xml new file mode 100644 index 0000000..8349edd --- /dev/null +++ b/seerscookieconsent.xml @@ -0,0 +1,75 @@ + + + System - Seers | Cookie Consent Banner and Privacy Policy + + NICK.SPENCER + Nov 2019 + Copyright (C) 2009 - 2020 NICK.SPENCER All rights reserved. + GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html + nick.spencer@seersco.com + www.seersco.com + 4.0.0 + PLG_SEERSCOOKIECONSENT_XML_DESCRIPTION + + + sql/install.mysql.utf8.sql + + + + + sql/uninstall.mysql.utf8.sql + + + + seerscookieconsent.php + index.html + sql + + + + language/en-GB/en-GB.plg_system_seerscookieconsent.ini + language/en-GB/en-GB.plg_system_seerscookieconsent.sys.ini + + + + + +
+ + + + + + + +
+
+
+ + + +
diff --git a/sql/index.html b/sql/index.html new file mode 100644 index 0000000..e69de29 diff --git a/sql/install.mysql.utf8.sql b/sql/install.mysql.utf8.sql new file mode 100644 index 0000000..7f1ce47 --- /dev/null +++ b/sql/install.mysql.utf8.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS `#__seers_cookie_consent` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `url` varchar(255) NULL, + `email` varchar(255) NULL, + `apikey` varchar(255) NULL, + `hitcount` int(11) NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; \ No newline at end of file diff --git a/sql/uninstall.mysql.utf8.sql b/sql/uninstall.mysql.utf8.sql new file mode 100644 index 0000000..1b65bd9 --- /dev/null +++ b/sql/uninstall.mysql.utf8.sql @@ -0,0 +1 @@ +DROP TABLE `#__seers_cookie_consent`; \ No newline at end of file