Question

I recently finished my PHP app and i would like to know if there's a possibility to have a kind of trial period. So that when that period is reached an error appears on the screen.

Thanks for your time and answers. I most appreciate them.

Was it helpful?

Solution

You can encrypt your sources using Zend Encoder or Ioncube, or obfuscate them.

But the fact is that everything from above can be patched. So if target user is experienced enough - they could remove your trial period checks.

OTHER TIPS

Yes you can: I did the same when the need arose some time ago. Its simple and you can improve it. Follow this algorithm;

  1. Get today's date
  2. Set the trial period
  3. Add the trial period to today( as start date) to get the expiry date
  4. Check to see if the above code have been executed before
    If not then send startdate and `expierydate` into a table in mysql
    Else get the start date and compare with today
    If it matches displ

Here is the code.

function timebomb(){
  $today = date("d-M-Y",time());
  $trialPeriod = 1;
  $startDate = date("d-M-Y", time());
  $getExpiryDate = strtotime('+'.$trialPeriod."days", strtotime($startDate));
  $expiryDate = date("d-M-Y", $getExpiryDate);
  $checkStatus = mysql_num_rows(mysql_query("SELECT * FROM timebomb"));
    if($checkStatus == 0){
    mysql_query("INSERT INTO timebomb(StartDate,ExpiryDate) values   
         ('$startDate','$expiryDate')") or die(mysql_error());
   }else{
   $getPeriod = mysql_query("SELECT * FROM timebomb");
    WHILE($period = mysql_fetch_object($getPeriod)){
    $endOfTrial = $period->ExpiryDate;
    }
    IF($endOfTrial == $today){`enter code here`
    echo 

    <center><font size='5' color='red'>
 PLEASE YOUR TRIAL PERIOD IS OVER. 
 IF YOU ENJOYED USING THIS PRODUCT, <br/>
 CONTACT ALBERT (0205173224) FOR THE FULL VERSION. 
  THANK YOU."

;
    exit();
            }

        }

    }
timebomb();

One solution can be the using some compiled (or byte compiled ) form of your application instead of source files. checkout this links. http://php.net/manual/en/book.bcompiler.php, http://www.phpcompiler.org

Follow below steps for fully secured trial period in php projects...

1. create a table in your database for trial period

ex. trial(id,reg_date,days_of_trial).

2. In your index page or login page whatever it is,add code logic as below

i.get 'reg_date','days_of_trial' from 'trial' table.<br/>
   ii.get today's date.<br/>
   iii.calculate difference using as $dDiff= date_diff($reg_date,$today); <br/>
   iv.now compare difference with 'days_of_trial'.<br/><br/>
      ex. <br/>
          if($dDiff->days>=$row['days_of_trial'])<br/>
            {    <br/>
                 v.update trial table set days_of_trial=0.<br/><br/>
                 //redirect to expired page..<br/><br/>
              ex.
              header("Location:http://localhost/project_dir/expired/index.php");}.

3. in expired/index.php file remove your projects main directories as..<br/><br/>

    ex.
<br/>
          if(file_exists("../folder1"))<br/>
          rmdir("../folder1");  
   redirect to expired page wherein you can display "Trial expired  message"<br/>
    ex.
<br/>
           header("Location: http://localhost/proj_dir/expired/expired.html");<br/><br/>

4. now replace your original home page code to redirect to expired page..

ex.
    $file = fopen("../index.php","w");<br/>
fwrite($file,"<?php header('Location: http://localhost/proj_dir/expired/');?>");<br/>
fclose($file);<br/>
  • Don't forget to take backups of project directory and database..
  • Your php project is fully secured as in trial period .....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top