Ïnitial Commit module v4.0.0

This commit is contained in:
Seersco 2022-04-19 12:36:53 +05:00
parent 16db8c2930
commit 9f26e9d49a
8 changed files with 358 additions and 0 deletions

1
index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -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 <a href='https://seersco.com/terms-and-conditions.html' target='_blank'>terms and condition</a> and <a href='https://seersco.com/privacy-policy.html' target='_blank'>privacy policy</a>,<br>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="<p>Enable the Cookie Declaration script. On the place where you want to add the Cookie Declaration, enter <strong>{SEERSCOOKIECONSENT DECLARATION}</strong></p>"
;PLG_SEERSCOOKIECONSENT_FIELD_CD_CHANGE_LABEL="Phrase tag"
;PLG_SEERSCOOKIECONSENT_FIELD_CD_CHANGE_DESC="<p>Enter the phrase that will be replaced by the Seers Cookie Consent Script. Normal is the defaul value enough.</p><p>Default: <strong>SEERSCOOKIECONSENT DECLARATION</strong></p><p>Where ever the Cookie Declaration needs to be showed, use {<i>[phrase tag]</i>}.<br/>E.g. {SEERSCOOKIECONSENT DECLARATION}</p>"

View File

@ -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="<p>Seers Cookie Consent is a cloud based Consent Management Platform (CMP) for compliance with GDPR, ePrivacy Regulation, PECR and CCPA.</p><p>Enter your website <strong>URL(auto picked)</strong> and valid <strong>email(to create an accound on Seers)</strong> then click on Save Button to get your Domain Group ID.</p><p><strong>Don't forget to enable the plugin.</strong></p>"
PLG_SYSTEM_SEERSCOOKIECONSENT="System - Seers | Cookie Consent Banner and Privacy Policy"

244
seerscookieconsent.php Normal file
View File

@ -0,0 +1,244 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.SeersCookieConsent
*
* @copyright Copyright (C) 2009 - 2020 NICK.SPENCER All rights reserved.
* @license GNU GPL v3 or later
**/
/*This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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('<head><script id="SeersCookieConcent" data-key="%s" data-name="CookieXray" src="https://seersco.com/script/cb.js" type="text/javascript"></script>', $this->cookieid);
$body = str_replace('<head>', $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);
}
}

75
seerscookieconsent.xml Normal file
View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="4.0" type="plugin" group="system" method="upgrade">
<name>System - Seers | Cookie Consent Banner and Privacy Policy
</name>
<author>NICK.SPENCER</author>
<creationDate>Nov 2019</creationDate>
<copyright>Copyright (C) 2009 - 2020 NICK.SPENCER All rights reserved.</copyright>
<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
<authorEmail>nick.spencer@seersco.com</authorEmail>
<authorUrl>www.seersco.com</authorUrl>
<version>4.0.0</version>
<description>PLG_SEERSCOOKIECONSENT_XML_DESCRIPTION</description>
<install>
<sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
</sql>
</install>
<uninstall>
<sql>
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
</sql>
</uninstall>
<files>
<filename plugin="seerscookieconsent">seerscookieconsent.php</filename>
<filename>index.html</filename>
<folder>sql</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_system_seerscookieconsent.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_system_seerscookieconsent.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="my_url"
type="url"
label="PLG_SEERSCOOKIECONSENT_FIELD_URL_LABEL"
description="PLG_SEERSCOOKIECONSENT_FIELD_URL_DESC"
size="100"
default=""
required="true"
/>
<field
name="my_email"
type="text"
label="PLG_SEERSCOOKIECONSENT_FIELD_EMAIL_LABEL"
description="PLG_SEERSCOOKIECONSENT_FIELD_EMAIL_DESC"
size="100"
validate="email"
required="true"
/>
<field
name="domain_group_id"
type="text"
label="PLG_SEERSCOOKIECONSENT_FIELD_DOMAIN_GROUP_ID_LABEL"
description="PLG_SEERSCOOKIECONSENT_FIELD_DOMAIN_GROUP_ID_DESC"
size="100"
default=""
hint="Press Save to get Domain Group ID"
/>
<field name="note1" type="note" class="alert" label="PLG_SEERSCOOKIECONSENT_FIELD_NOTE_LABEL" description="PLG_SEERSCOOKIECONSENT_FIELD_NOTE_DESC" />
</fieldset>
</fields>
</config>
<updateservers>
<server type="extension" priority="1" name="SeersCookieConsent for Joomla!"><![CDATA[https://seersco.com/extensions/joomla/extension.xml]]></server>
</updateservers>
</extension>

0
sql/index.html Normal file
View File

View File

@ -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 ;

View File

@ -0,0 +1 @@
DROP TABLE `#__seers_cookie_consent`;