Javascript time limit(trial)

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Memetaltin
Posts: 3
Joined: Tue Jul 25, 2017 5:04 pm

Javascript time limit(trial)

Post by Memetaltin »

Hello,
i have a problem. how to make trial version.meybe 30 days trial script.
Thank you
User avatar
jaydoubleyou80
Posts: 20
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Re: Javascript time limit(trial)

Post by jaydoubleyou80 »

There's a way to encrypt your script after this that I don't recall as I've never done it, but if you use this code, you can determine the system date and then run your script if it is within your predefined date range.

Code: Select all

var endDate=new Date();
endDate.setFullYear(2017,6,26);//note that the month is 6, not seven because January is zero
var today = new Date();

if (endDate>today)
{
alert("insert your script where this alert is")
}
else
{
alert("Your trial has expired, please contact the developer to purchase the script");
}
xbytor
Posts: 22
Joined: Thu Jan 01, 1970 12:00 am

Re: Javascript time limit(trial)

Post by xbytor »

There's a way to encrypt your script
Not quite. You can convert it into a jsxbin file which is a binary encoded form of your PSJS but it is not encrypted. Somebody wrote a jsxbin to jsx converter that didn't involve decryption, more like decompiling.
Memetaltin
Posts: 3
Joined: Tue Jul 25, 2017 5:04 pm

Re: Javascript time limit(trial)

Post by Memetaltin »

Ok. thank you so much. but script continues. it must stop.


var endDate=new Date();
endDate.setFullYear(2017,7,26);//note that the month is 6, not seven because January is zero
var today = new Date();

if (endDate>today)
{
alert("insert your script where this alert is")
}
else
{
alert("Your trial has expired, please contact the developer to purchase the script");
}

#target photoshop
function main(){function setup_doc(){var idslct=charIDToTypeID("slct");.....
......
Memetaltin
Posts: 3
Joined: Tue Jul 25, 2017 5:04 pm

Re: Javascript time limit(trial)

Post by Memetaltin »

Code: Select all

var endDate=new Date();
endDate.setFullYear(2017,7,26);//note that the month is 6, not seven because January is zero
var today = new Date();

if (endDate>today)
{
alert("insert your script where this alert is")
}
else
{
alert("Your trial has expired, please contact the developer to purchase the script");
}

#target photoshop
function main(){function setup_doc(){var idslct=charIDToTypeID("slct"); ......
User avatar
jaydoubleyou80
Posts: 20
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Re: Javascript time limit(trial)

Post by jaydoubleyou80 »

Ahh, right. Thanks for the clarification :D
User avatar
jaydoubleyou80
Posts: 20
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Re: Javascript time limit(trial)

Post by jaydoubleyou80 »

Memetaltin, If you only call on that function with the if, the else will take care of anything out of the date range. So for instance, if you set the end date to 8/31/2017, once that date hits, the else will alert them the script can't be used. During the time period that the date is prior to 8/31, it will run the function. It shouldn't continue unless you are somehow calling on the function outside of the if statement.

Code: Select all

#target photoshop
var endDate=new Date();
endDate.setFullYear(2017,7,31);//note that August is seven, not eight, because January is zero
var today = new Date();

if (endDate>today) {
yourFunction ()
}
else {
alert("Your trial has expired, please contact the developer to purchase the script");
}

function yourFunction() {
function setup_doc(){var idslct=charIDToTypeID("slct"); ......
}
User avatar
Jaroslav Bereza
Posts: 38
Joined: Tue Dec 27, 2016 7:22 pm

Re: Javascript time limit(trial)

Post by Jaroslav Bereza »

Could you use "Socket" class and comunicate with server? It should be able create TCP/IP connection. So you could send data and return value and verify valid licence.
luis miguel
Posts: 16
Joined: Thu Oct 27, 2016 9:56 am

Re: Javascript time limit(trial)

Post by luis miguel »

I found a problem
If you put your computer's date before expiration
The trial continues to work

Can you overcome this problem?
User avatar
jaydoubleyou80
Posts: 20
Joined: Mon Oct 17, 2016 1:41 pm
Location: USA

Re: Javascript time limit(trial)

Post by jaydoubleyou80 »

luis miguel wrote:I found a problem
If you put your computer's date before expiration
The trial continues to work

Can you overcome this problem?

Well, probably. But you'd only ever know to do that if you also knew how the script was identifying the date. I'm not sure how you might be able to work around it, but possibly following Jaroslav Bereza's suggestion. I'm pretty sure you'd need to verify off the user's computer to be absolutely sure, but I'm not sure how that's achievable.