• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

HOW TO SET A JAVA FILE EXPIRY DATE ?

Participant ,
Oct 17, 2024 Oct 17, 2024

Copy link to clipboard

Copied

 

I already have a java script, I want to add expiry date in it, how to do it. Please give me the code. and how to do it

 

TOPICS
Windows

Views

868

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Oct 17, 2024 Oct 17, 2024

Copy link to clipboard

Copied

This makes no sense. Javascript files don't have expiration dates. Can you give a better explanation?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2024 Oct 17, 2024

Copy link to clipboard

Copied

@Lumigraphics 

 

I’m guessing that this is an attempt at some sort of "licensing" or "time-limited working demo" for a script (not an extension/panel). But guess is just that, a guess. 

 

@MJ ST - Can you expand on your post?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

Sir, I have a script which I have to give to the client. but i want it to end
In less than three months. so please enter some code
This should end in 3 months. What can happen; what can be done?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

Sure it can be done, in it's simplest form:

 

var today = new Date();
alert(today);

 

However you will likely need to research how to work with date stamps in JavaScript, then create a simple conditional if/else block to wrap around your code to compare if today's date is less than a target expiry date.

 

You will need to obfuscate the code and or create an encrypted .jsxbin version of the .jsx code, which isn't bulletproof. This doesn't stop the system clock being changed to extend the expiry of the script. So you could script the writing of the date of the first run of the script to a "hidden" text file and then validate the date by reading the text file. But this isn't bulletproof either as the new text file could be logged or found etc. There will always be ways to cheat this, so it comes down to how hard you want to make this.

 

https://www.davidebarranca.com/2016/07/html-panel-tips-22-protecting-your-code/

 

https://www.davidebarranca.com/2017/02/html-panel-tips-23-javascriptobfuscator-api-gulp-js-plugin/

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

Yes, I understand. But I am not able to use the code. I am giving you the script. Can you enter the code please?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

quote

Yes, I understand. But I am not able to use the code.


By @MJ ST

 

I understand, yes, I intentionally didn't hand you the code on a platter, these were just my initial thoughts on the topic.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

please help me sir.I request You.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

quote

please help me sir.I request You.


By @MJ ST

 

Where are you stuck? What have you done to help yourself?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

var today = new Date();
alert(today);

How to add this code??

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

quote
var today = new Date();
alert(today);

How to add this code??

 


By @MJ ST

 

You would research how to work with dates with JavaScript, among a few other things.

 

Here is a working demo for you. It is not guaranteed to be fit for purpose or covered by warranty. Use at your own risk!

 

/*
Today's date: 2024-10-18
Expires tomorrow: 2024-10-19
*/

// Get today's date
var today = new Date();
var year = today.getFullYear().toString();
// Extract the month... Months are zero indexed, so add one!
var month = ("0" + (today.getMonth() + 1)).slice(-2);
var date = ("0" + today.getDate()).slice(-2);
var yyyymmdd = year.toString() + month.toString() + date.toString();
// Convert the string back to a number
yyyymmdd = parseInt(yyyymmdd);

// Conditional
if (yyyymmdd < 20241019) {
    // Add your code below. Remove the following alert...
    alert("Pass");
} else {
    // Do nothing on fail. Remove the following alert...
    alert("Fail");
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

Can I add this code to my file? Will this work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

I'm getting the impression that you have little to no knowledge or understanding of the task. Test it. Play with the expiry date target, test on different days to see how this works before and after the target expiry etc.

 

Add your code into the if block where indicated.

 

Look into obfuscation and how to create an encrypted jsxbin etc.

 

It's up to you now, good luck!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

yes, but you know you can

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

This is not the "I need you to write code for free" website. We can help, but its up to you to do the work or pay someone to do it for you. I don't think this whole endeavor is going to work the way you think it will.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

Is there a way to set an expiration date on a JSX. file?
So that it cannot be opened after a certain time?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

- You can't use jsx files in Acrobat.

- You can't prevent a file from being opened after a certain date.

- You can limit the script itself to only run up to a certain date, but that's easily overcome, if someone wants to do so.

Here's an example using today's date as the cut-off time (note the month parameter is zero-based!):

 

var cutoffDate = new Date(2024, 9, 18);
if (new Date().getTime()<cutoffDate.getTime()) {
	app.alert("run code");
	// put code here
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

Ok, I am putting this code in my script. You tell me if this is right. I don't know much.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 18, 2024 Oct 18, 2024

Copy link to clipboard

Copied

..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2024 Oct 19, 2024

Copy link to clipboard

Copied

You can't use this script in Adobe Acrobat.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2024 Oct 19, 2024

Copy link to clipboard

Copied

You must move all the code inside the curly brackets, next to the "put code here" comment.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 19, 2024 Oct 19, 2024

Copy link to clipboard

Copied

..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 19, 2024 Oct 19, 2024

Copy link to clipboard

Copied

Screenshot 2024-10-20 103801.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

Hi @MJ ST ,

 

Instead of using "alert" define the alert popup messaging function with the appropriate Acrobat JavaScript syntax: "app.alert":

 

 

app.alert("You must have a document open to add the filename!\nVous devez ouvrir un fichier image pour y jouter son nom de fichier." );

 

 

That should work now.

 

REFERENCE: 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

this is not useful

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines