Author Topic: Time bomb  (Read 6556 times)

0 Members and 1 Guest are viewing this topic.

matrix2005in

  • Guest
Time bomb
« on: June 30, 2006, 01:54:08 PM »
hi i need to set current date + 30 for expiry date how can i do that?? i tried to add +30 to start date but it gives error..
Code: [Select]
(defun bomb ()
(setq bombif (getvar "cdate"));;getsthe current date
(if (> 20010829.00000000 bombif);i need to set expiry date as start date+30
(alert "you are in")
(princ "\Version Expired!")
)
)

Bob Wahr

  • Guest
Re: Time bomb
« Reply #1 on: June 30, 2006, 02:00:11 PM »
add 100

matrix2005in

  • Guest
Re: Time bomb
« Reply #2 on: June 30, 2006, 02:06:43 PM »
thanks

but where and how that will work

if you dont mind can you explain little...


Bob Wahr

  • Guest
Re: Time bomb
« Reply #3 on: June 30, 2006, 02:11:24 PM »
You should actually check the 3rd and 4th digits to the left of the decimal.  If they are 2 and 1 respectively then instead of adding 100, you need to add 8900.


The number CDATE gives you isn't actually a number, it just looks like one.  it is YYYYMMDD.HHMMSSSS

You're probably better off using DATE instead of CDATE.  There's a thread around here somewhere, I'll try to turn it up.

Bob Wahr

  • Guest
Re: Time bomb
« Reply #4 on: June 30, 2006, 02:12:25 PM »

matrix2005in

  • Guest
Re: Time bomb
« Reply #5 on: July 01, 2006, 12:55:42 PM »
hi CAB code is good but little change is required...i would like to get final date instead of number of days between two dates...and that would be start date + 30 is there anyway to do that???

Code: [Select]
(defun c:test ()
  ;;    Month Day Year
  (print (DaysBetween 1 1 2006 1 2 2006))
  (print (DayOfYear 12 31 2006))
  (princ)
)

(defun DaysBetween (m1 d1 y1 m2 d2 y2)
  (fix (- (ctoj y2 m2 d2 0 0 0) (ctoj y1 m1 d1 0 0 0)))
)

(defun dayOfYear (m d y / year)
  (if (= y (setq year (fix(/(getvar "CDATE") 10000))))
     (1+ (fix (- (ctoj y m d 0 0 0) (ctoj year 1 1 0 0 0)))))
)

thanks

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Time bomb
« Reply #6 on: July 01, 2006, 04:27:12 PM »
Can you use this?
Code: [Select]
(load "julian")
(setq cdate (getvar "date"))
(princ "\nStart date: ")
(princ (jtoc cdate))
(setq futuredate (+ cdate 30))
(princ "\nEnding date: ")
(princ (jtoc futuredate))

matrix2005in

  • Guest
Re: Time bomb
« Reply #7 on: July 01, 2006, 05:30:23 PM »
Jeff thanks very much...

one more help if you can...is there any other code available same like jtoc....... many of my machines are not loaded with express tools........

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Time bomb
« Reply #8 on: July 01, 2006, 07:24:20 PM »
Have a look at the JULIAN.lsp code. There's nothing magic in there, in fact it does a VERY thorough job of describing HOW it works along with references. It wouldn't be too difficult to duplicate what it does.......especially since you only really need a small bit of it.

On second thought, here's one I put together a few years ago that will handle another type of date (that which MS File System Objects use).....
Code: [Select]
;;function to convert a computer standard serial date,
;; such as what TDCREATE returns, to a calendar date.
;; If FSO? is not nil then the input date is treated as
;; a MS date as returned by the FileScriptingObject
;; Jeff Mishler c. 2003
(defun ser2cal (serdate FSO?)
  (if FSO?
    (setq serdate (+ serdate 2415019))
    )
  (menucmd
    (strcat "M=$(edtime,"
    (rtos serdate 2 8)
    ",DDD\",\" DD MON YYYY hh:mm)"));;change as desired, see ACAD help for syntax
  )
Then in use similarly to my previous post:
Code: [Select]
(setq cdate (getvar "date"))
(princ "\nStart date: ")
(princ (ser2cal cdate nil))
(setq futuredate (+ cdate 30))
(princ "\nEnding date: ")
(princ (ser2cal futuredate nil))
This returns:

Start date: Sat, 01 Jul 2006 16:19
Ending date: Mon, 31 Jul 2006 16:19

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Time bomb
« Reply #9 on: July 01, 2006, 08:57:29 PM »
... or
Code: [Select]
;; set hardcoded timeStamp plus 1 month.
;; (setq tmp (rtos (+ (getvar "CDATE") 100.00) 2 2))
;; => "20060802.11"

(setq expiryDate 20060802.11)

(COND ((= (GETVAR "CDATE") expiryDate)
       (ALERT "The end of the world is nigh ... ")
      )
      ((> (GETVAR "CDATE") expiryDate)
       (ALERT "beware the ninja in the night ... bye ")
       (EXIT)
      )
      (T (PROMPT "\n Don't worry, be happy. "))
)



edit:
Just don't issue this in December  :-)
« Last Edit: July 01, 2006, 09:03:28 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Time bomb
« Reply #10 on: July 02, 2006, 12:57:09 AM »
Or.....this can be used anytime during the year :-)
Code: [Select]
;;when installing......
(setq installDate (fix (getvar "date")))
(vl-registry-write "HKEY_CURRENT_USER\\Software\\JMM-Utils\\Install" "Date" installdate)


;;when validating date
(defun runproduct ()
  ;;this is the code you will run if the time period is OK
  (princ "...it's running")
  (princ)
  )
(setq installDate (vl-registry-read "HKEY_CURRENT_USER\\Software\\JMM-Utils\\Install" "Date")
      curDate (fix (getvar "date"))
      diff (- curdate installDate)
      )
(cond ((> diff 30)
       (alert "Your evaluation period has EXPIRED! Please purchase a copy now.")
       )
      ((= diff 30)
       (alert "Your evaluation period Expires TODAY! Please purchase a copy now.")
       )
      (t
       (alert (strcat "You have " (itoa (- 30 diff)) " days left to try this product."))
       (runproduct);;;
       )
      )
This is how I adjusted the starting date to check if it works, re-running the appropriate lines for each test.....
Code: [Select]
;;when installing......
(setq installDate (fix (getvar "date")))
;;;test over 30
(setq installDate (- installdate 45))
;;;test exactly 30
(setq installDate (- installdate 30))
;;;test less than 30
(setq installDate (- installdate 10))

;;visual check
(ser2cal installDate nil)
(vl-registry-write "HKEY_CURRENT_USER\\Software\\JMM-Utils\\Install" "Date" installdate)

matrix2005in

  • Guest
Re: Time bomb
« Reply #11 on: July 02, 2006, 03:06:23 PM »
hi jeff

your code is absolutely fantastic....i really really appreciate that...
thanks man

mathew

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Time bomb
« Reply #12 on: July 02, 2006, 07:43:09 PM »
Matrix...

I have tried and study many thing to get a demo version of my software..
Also, I have tried to make a code with "date".

But this method is easy to bypass by changing the current date of your PC.
BEFORE and AFTER any installation.

I suggest many other method...more secure.

You can use
Password to activate the trial,
generated by the curren MACadress or PC USERNAME ...

ex:
Code: [Select]
(setq w (vl-string->list (getvar "username")))
(setq str1 "N")
(while w
  (setq car1 (rtos (car w)))
  (setq str1 (strcat str1 car1 ))
  (setq w (cdr w))
)
(alert (strcat "Your activation code is :\n\n" str1))

and use something like...

Code: [Select]
(setq trial_time (vl-registry-write "HKEY_CURRENT_USER\\Software\\blahblah" "blah_TRIAL_TIME" "30"))
(defun c:trythis () 
(if (or (< (atoi trial_time) 1)
(> (atoi trial_time) 30))
   (alert "Your time is expired !")
    (progn
      (setq trial_time2 (- (atoi trial_time) 1))
      (setq trial_time (vl-registry-write "HKEY_CURRENT_USER\\Software\\blahblah" "blah_TRIAL_TIME" (itoa trial_time2)))
      (alert (strcat "Software activated for " trial_time " more times."))
)))

but this is my suggestion.... 8-)
« Last Edit: July 03, 2006, 09:09:00 AM by Andrea »
Keep smile...

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Time bomb
« Reply #13 on: July 03, 2006, 11:48:11 AM »
Andrea, I agree that a user changing the computer's date could lead ti mis-use of the software. However,with so many other things on the computer requiring valid dates I don't think that a relatively small lisp wouyld be worth the effort. And if that user that DOES wish to muck around with date, they are probably also savvy enough to muck around in the registry and change the "bla-TRIAL-TIME" to whatever they desire.......

By using the DATE variable, not many users are going to know that the number 2345234 is referencing a date. More likely, they will think that it is a random number and changing it could render the program useless....especially if the Data Key is not named "Date" or "Expiry", etc. (I know, my example used Date, but it was just an example)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Time bomb
« Reply #14 on: July 03, 2006, 05:54:08 PM »
Jeff, I agree with you.

a simple little lisp don't require to much effort for protect it...
but some lisp yes.

The code i have posted is a exemple only to show what it'S possible to do.
he can make many other thing if he want....I just put the post to help him to have some idea by himself.

sure you can use something like...
Code: [Select]
(setq cdate (+ 113877 (read (vl-list->string (reverse (vl-string->list (rtos (getvar "cdate") 2 0)))))))
(vl-registry-write "HKEY_CURRENT_USER\\Software\\WinSpec00" "Data" cdate)

no one never know... :angel:
Keep smile...

matrix2005in

  • Guest
Re: Time bomb
« Reply #15 on: July 04, 2006, 02:49:32 PM »
HI andrea

thats a gr8 idea...but how this will work...i mean how i can read the date from this??

thanks

mathew

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Time bomb
« Reply #16 on: July 04, 2006, 05:31:59 PM »
Mathew, like so....just reverse the process he used.
Code: [Select]
;; I would still use "date" in lieu of "cdate" since you can easily
;; add/subtract days from it without worrying about spanning months & years

(setq cdate (+ 113877 (read (vl-list->string (reverse (vl-string->list (rtos (getvar "date") 2 0)))))))
(vl-registry-write "HKEY_CURRENT_USER\\Software\\WinSpec00" "Data" cdate)

(setq regdate (vl-registry-read "HKEY_CURRENT_USER\\Software\\WinSpec00" "Data"))
(setq regdate (read (vl-list->string (reverse (vl-string->list (rtos (- regdate 113877) 2 0))))))

matrix2005in

  • Guest
Re: Time bomb
« Reply #17 on: July 04, 2006, 05:35:06 PM »
thanks jeff

you are right better to use date..that's very good to easy substraction....yo yo its more better

thanks

mathew

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Time bomb
« Reply #18 on: July 04, 2006, 05:59:08 PM »
it called "reverse enginering".... :wink:
Keep smile...