Support us by sharing our WebSite with your Friends Support

How to create License in Blogger Template using Google Sheet

As we all know, the premium templates that we often come across are licensed, of course the purpose is that the templates are created not to be abused by irresponsibly people, such as sharing... 

How to add License Encryption in Blogger using Google Sheet

For those of you who are developing blogger templates and plan to sell them, it would be good if you should install a license for the template you created before selling it to avoid unwanted things...

What is Google Sheets?

  • Google Sheets is one of the features of Google Drive (unlimited online storage service) developed by technology company Google.
  • Most workers and students are probably quite familiar with the Google Sheets services.
  • The actual spreadsheet form or format is similar to Microsoft Excel, in that it includes columns and rows.
  • Generally the spreadsheet can be operated online and allows users to edit documents/files in the spreadsheet anytime and anywhere.

How to create Google Sheets

You must have a Gmail account. If you haven't already, create a Gmail account before using the spreadsheet.

If you already have a Gmail account, you can also start using the spreadsheet online via the url: https://docs.google.com/spreadsheets. In your browser, 'Start a new computer table' will appear.

Add-on 'Bass' at the end statement to create a new computer table.e.

You can edit Google Spreadsheets anytime and anywhere. Any data changes after each typing will be automatically saved.

How the license works

Before we get started with the tutorial, I'll discuss a little bit about how the licenses we'll be creating later, and in general, templates are licensed using unique code provided by perUsers.  

In most licensed templates use "base64 code" like this: bGlzZW5zaXRlbXBsYXRla29kZWJh= and the license is valid forever, the developer has no access to remove the licensed license

And the method that I am going to share here is actually the same as how it works, but the only difference is that we have access to delete the user's license because we use a database. 

The Google Sheet will contain the user's license so when we delete the user's data in our spreadsheet, the website/blog user will be redirected to our website.

Okay, that's all the difference is ok, let's start with how to make it below.

How to create license for Blogger template with Google sheets

Step 1: Go to: https://drive.google.com

And create a new google spreadsheet by clicking the New button > Google Sheets > Blank Spreadsheet.

Sheet1 (Sheet1) at the bottom left is renamed: users.

And create the name in column A1 as: no, B1 as: id, C1 as: code.

On the menu bar you click on Extensions > Apps script.

You will be taken to a new tab Untitled Projects Google will appear, and title it whatever you like.

Select on Code.gs remove the default script from google script and replace it with the script below.

function doGet(e){
var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/..../edit#gid=0");
var sheet = ss.getSheetByName("users");
return getUsers(sheet);
}
function getUsers(sheet){
var jo = {};
var dataArray = [];
var rows = sheet.getRange(2,1,sheet.getLastRow()-1, sheet.getLastColumn()).getValues();
for(var i = 0, l= rows.length; i<l ; i++){
var dataRow = rows[i];
var record = {};
record['id'] = dataRow[1];
record['code'] = dataRow[2];
dataArray.push(record);
}
jo.user = dataArray;
var result = JSON.stringify(jo);
return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.JSON);
}

Replace link:
https://docs.google.com/spreadsheets/d/..../edit#gid=0 with the google sheet link you created earlier.

Save script.google by clicking the Save project icon and writing the name of the sheet, it's up to you.

Anands.xyz

Automatic Share Posts to Social Media

Read More about WebSite...

Then select Deployment button > New Deployment Options > Select Type > Web Application.

Description (insert number 1), Execute as Me (email@gmail.com), Person with Access (Anyone) and finally click Deploy.

Then there will be an Access Authorization popup whose purpose is to allow our project to read, create and delete files on Google Drive.

So we just need to click on the google account, click continue clicking on the words Go to Untitled (unsafe) Project below click allow.

Finally, copy the link you just created, which will later be used to get JOSN data in our Google Sheets.

Second stage of license creation on Blogger

At this stage, you must make sure that in the template that will create the license, there is already a jQuery script.

Since the data will be retrieved using ajax, here are two ajax that we have to create, ajax from feed/article/summary to retrieve blog ID and ajax from the google webapp link we just created to validate and match the data in the google sheet with the blog ID and license key.

AnandNawal.com

jQuery and Blogger Integration LazyLoad and Normal Load.

Read More about WebSite...

If the blog does not have jQuery installed, please paste the above code in: </head>

<script async='async' src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>

Login your blogger account and go to Themes > Edit HTML, copy and paste the code below and combine it with the javascript in your template.

var urlBlog = 'https://padho.me/';
var license = $('#license-code').text();
var informasibatas = '<style>body{background:#fff}#peringatan span{font-size:50px}#peringatan{z-index:99999;position:fixed;top:0;right:0;left:0;height:30%;text-align:center;background:rgba(235, 0, 0, 1);border:5px solid #444;color:#fff;padding:20px;font-family:monospace;border-radius:10px}#peringatan h4{font-size:20px}</style><div id="peringatan"><h4>License activation</h4><p>Để có mã License bạn vui lòng liên hệ Admin ngoviminhhieublog.blogspot.com | 0385593525</p><span id="nvmh">20</span></div>';
var input = 20;

$(document).ready(function() {
var dataLicense = license.split('-');
var codeLicense = dataLicense[0];
var arrayLicense = dataLicense[1];
console.log(codeLicense);
console.log(arrayLicense);
if (arrayLicense == undefined) {
$(document.body).html(informasibatas);
setInterval(function() {
input <= 1 ? (window.location.href = urlBlog) : (document.getElementById("giahuy_dot_net").innerHTML = --input);
}, 1e3);
}
str = [arrayLicense];
$.ajax({
url: "https://script.google.com/macros/s/..../exec",
type: "GET",
data: "users",
crossDomain: true,
dataType: "",
success: function(data) {
var json = data.user;
var sheetLicense = json[str];
console.log(sheetLicense)
if (sheetLicense == undefined) {
$(document.body).html(informasibatas);
setInterval(function() {
input <= 1 ? (window.location.href = urlBlog) : (document.getElementById("nvmh").innerHTML = --input);
}, 1e3);
}
var ID = sheetLicense.id;
var code = sheetLicense.code;
$.ajax({
url: "/feeds/posts/summary/?alt=json",
type: "get",
dataType: "jsonp",
success: function(data) {
var dataID = data.feed.id.$t;
console.log(dataID)
var IDblog = dataID.split('-');
var blogID = IDblog[1];
try {
var input = 20,
dataInBlog = blogID + codeLicense,
dataInSheet = ID + code;
if (dataInBlog == dataInSheet) {
return;
}
$(document.body).html(informasibatas);
setInterval(function() {
; input <= 1 ? (window.location.href = urlBlog) : (document.getElementById("nvmh").innerHTML = --input);
}, 1e3);
} catch (input) {
window.location.href = urlBlog;}
},
});
},
});
});

To prevent the license code from appearing on our blog, use the CSS below.

#license-code{display:none!important}

Note: You need to change the following positions for them to work properly.

- Replace  https://padho.me/ change to your blog URL.

- The goal is that if the user doesn't enter the license, they will be redirected to that url. crangsten@gmail.com replace it with your email, this appears as a notif before redirecting to the main blog.
https://script.google.com/macros/s/..../exec replace it with the Google Script link you created earlier in the first step.

AdcancedCoder.net

How to Add a Star Rating Widget With Review Snippets on Blogger for Free with Google Rich Snippets Feature

Read More about WebSite...

How to activate the license for the user

If everything is done now we are going to create the license for the user, here you need to know the Blog ID in the template where the license will be installed. You can use Ctrl + U or type view-source: https://www.domain.com and find code as after: {'blogId': '3275552660345497887', start Copy the Blog ID code.

Then go to your spreadsheet.

* Enter the previously copied Blog ID in the id section column

* And enter the license in the code column.

* no leaves the column blank.

Example: I have 3 users and each has a different license key:

No. Code License
1 LicenseWeb-1 License-1
2 LicenseWeb-2 License-2
3 LicenseWeb-3 License-3

Attention!
So when you license the user, it must be added -0, -1, -2, -3, etc. After the license key you created. And ask user to enter license in layout section called license.

Conclusion

Above is a guide on how to create a License for Blogger template with Google Sheet. If you have any questions, feel free to comment below.
Good luck and have a great day!
Hello, I am Anand Nawal creating helpful tutorials on blogger and WordPress.

إرسال تعليق

© Padho. All rights reserved. Distributed by ASThemesWorld