ionCube Logo
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


 
Post new topic   Reply to topic    ionCube Forum Index -> ionCube PHP Encoder

Trial Expiration Date Display

Author Message
ckh



Joined: 27 Mar 2005
Posts: 49

PostPosted: Fri May 27, 2005 4:08 pm    Post subject: Trial Expiration Date Display Reply with quote

I'm providing a trial that uses a specific expiration date (about 30 days) I'll encode it for each trial request and pick out the expiration date at the time of encoding.

I'd like to include a "You have X Days Left on Your Free Trial" or "Your Trial Will Expire on "XX June XXXX". Is there a variable we can use to compute this so it will automatically be correct in our php that we can used that is based on the ioncube expiration date we use at encoding time??
Back to top
View user's profile Send private message
liaison
ionCube Support


Joined: 16 Dec 2004
Posts: 2788

PostPosted: Tue May 31, 2005 10:54 am    Post subject: Reply with quote

Hi

This is possible by calling the Loader API function ioncube_file_info(). The function is documented as follows:

Array/Bool ioncube_file_info()

Returns information as an array about the calling encoded file.
The array elements are:

FILE_EXPIRY - Unix time_t value for file expiry as an int or 0
ENCODING_TIME - Unix time_t value for when file encoded
DEMO - TRUE if file is encoded by an evaluation Encoder otherwise FALSE

This function returns FALSE is the calling file is not encoded.


This function is currently available only to code compiled with the standalone Encoder, and not to online encoded files.[/b]
_________________
Community Admin
Back to top
View user's profile Send private message
ckh



Joined: 27 Mar 2005
Posts: 49

PostPosted: Tue May 31, 2005 8:31 pm    Post subject: Reply with quote

Thanks.

I note in the user guide that there is a separate document for the loader api. I can't find the document in my ioncube folder nor find it online.

Where could I find it??

Chris
Back to top
View user's profile Send private message
liaison
ionCube Support


Joined: 16 Dec 2004
Posts: 2788

PostPosted: Tue May 31, 2005 9:09 pm    Post subject: Reply with quote

Hi

This is currently available upon request, so we'll email this to you.
_________________
Community Admin
Back to top
View user's profile Send private message
ckh



Joined: 27 Mar 2005
Posts: 49

PostPosted: Tue May 31, 2005 10:33 pm    Post subject: Reply with quote

Looking forward to it. ckh AT cox.net is my registered email address.
Back to top
View user's profile Send private message
ckh



Joined: 27 Mar 2005
Posts: 49

PostPosted: Tue May 31, 2005 10:56 pm    Post subject: Reply with quote

Been playing with it and couldn't get it to work. Could you post a simple example that would print those elements??

Thanks.

Chris
Back to top
View user's profile Send private message
liaison
ionCube Support


Joined: 16 Dec 2004
Posts: 2788

PostPosted: Wed Jun 01, 2005 9:23 am    Post subject: Reply with quote

Code:
<?php

var_dump(ioncube_file_info());

?>


Doing this just now, encoding with

Code:

ioncube_encoder /tmp/fileinfo.php -o /tmp/fileinfo-enc.php --expire-in 100s


and running PHP on the file gives

Code:

php /tmp/fileinfo-enc.php
array(3) {
  ["FILE_EXPIRY"]=>
  int(1117613879)
  ["DEMO"]=>
  bool(false)
  ["ENCODING_TIME"]=>
  int(1117613779)
}


The expiry time here is the encoding time + 100 as the file had an expiry in 100 seconds. If called by an unencoded file, the result is false. Note that due to design faults in Zend Optimiser, if ZO is installed (which is unlikely, but possible), it may not be possible to use the API function after a non-encoded file has been included. This problem is worked around in the next main Loader release, along with an enhanced API being introduced.
_________________
Community Admin
Back to top
View user's profile Send private message
ckh



Joined: 27 Mar 2005
Posts: 49

PostPosted: Fri Jun 03, 2005 12:29 am    Post subject: Reply with quote

I admit, array's haven't been my thing. While I've been able to duplicate what you have here, I can't isolate the file_expiry so I can use the number to display an expiration date in my file.

I can get the:

array(3) {
["FILE_EXPIRY"]=>
int(1117613879)
["DEMO"]=>
bool(false)
["ENCODING_TIME"]=>
int(1117613779)
}

to display fine. I just need to put the file_expiry in a variable so I can use the date() to show the expiration date of the file.

My use. I have 3 files that have an expiration date. config.php, header.php, header2.php, none of them have any variables in it to change so it's all php/html. Since it's a demo, I want to extract the file_expiry timestamp so when they go to their login screen, it will display the expiration date of the 30 day file.
Back to top
View user's profile Send private message
liaison
ionCube Support


Joined: 16 Dec 2004
Posts: 2788

PostPosted: Tue Jun 07, 2005 8:14 am    Post subject: PHP Language Reply with quote

Hi

There's plenty of help in books and online about PHP syntax, and of course, there's the PHP manual. You'll also find an endless supply of code littered around the web that you can look at for tips on how to do things, although not always how to do things well.

Here's a section in the PHP manual that shows the array syntax.

http://uk.php.net/manual/en/language.types.array.php
_________________
Community Admin
Back to top
View user's profile Send private message
ckh



Joined: 27 Mar 2005
Posts: 49

PostPosted: Fri Jun 10, 2005 12:04 pm    Post subject: Reply with quote

I've been playing with this for quite a while now trying to extract the FILE_EXPIRY from the array with no success.

The best I can do is display the whole array and it comes out as:

array(3) { ["FILE_EXPIRY"]=> int(1120262400) ["DEMO"]=> bool(false) ["ENCODING_TIME"]=> int(1118400212) }

For example, I set:

$a=var_dump(ioncube_file_info());

I then try to 'echo' the file_expiry as:

echo $a["FILE_EXPIRY"];

and still get the whole content of the array instead of just the file expiry.

Either I'm doing something wrong or the dump isn't in the correct format. Looking at the PHP documentation, each element in the array is suppose to be separated by a comma (should be one before ["DEMO"] and one before ["ENCODING_TIME"].

Modifying the output for experimentation, the only way I've gotten it to display is with:

$a=array("FILE_EXPIRY"=> 1120176000, "DEMO"=> false, "ENCODING_TIME"=> 1117651377);
echo $a["FILE_EXPIRY"];

I had to remove the curly brackets, the []'s, int & bool functions, and add comma's.
Back to top
View user's profile Send private message
liaison
ionCube Support


Joined: 16 Dec 2004
Posts: 2788

PostPosted: Fri Jun 10, 2005 1:06 pm    Post subject: Reply with quote

Hi

Have you tried posting into the PHP forums, or starting with some PHP tutorials to learn about the basics of PHP? There are plenty of resources on the web to explain and help with basic PHP syntax, getting started with learning about programming in general, and about programming specifically with PHP. Things will be easier for you once you've learnt the basics.

Good luck!
_________________
Community Admin
Back to top
View user's profile Send private message
ckh



Joined: 27 Mar 2005
Posts: 49

PostPosted: Fri Jun 10, 2005 6:41 pm    Post subject: Reply with quote

For those wondering, I finally figured it out.

Code:
<?
$a = ioncube_file_info();
if ($a['demo']==1) $b="Demo";
else $b="Not Demo";

echo "<br>Encoding Time:  ".date("F j, Y",$a['ENCODING_TIME']);
echo "<br>Expiry Time  :  ".date("F j, Y",$a['FILE_EXPIRY']);
echo "<br>Demo         :  ".$b;

?>


Will output something like:

Code:
Encoding Time: June 10, 2005
Expiry Time : July 9, 2005
Demo : Not Demo


This is now hardcoded into my brain.... Laughing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ionCube Forum Index -> ionCube PHP Encoder All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum