繁体   English   中英

本地PHP申请实施试用期

[英]Implementing trial period for local PHP application

我最近完成了我的 PHP 应用程序,我想知道是否有可能有一种试用期。 因此,当达到该时间段时,屏幕上会出现错误。

感谢您的时间和答复。 我最欣赏他们。

您可以使用 Zend Encoder 或 Ioncube 加密您的源代码,或混淆它们。

但事实是,上面的一切都可以修补。 因此,如果目标用户有足够的经验 - 他们可以删除您的试用期检查。

是的,您可以:前段时间出现需要时,我也这样做了。 它很简单,你可以改进它。 遵循这个算法;

  1. 获取今天的日期
  2. 设置试用期
  3. 将试用期添加到今天(作为开始日期)以获得到期日期
  4. 查看上面的代码之前是否执行过
    如果不是,则将开始日期和 expierydate 发送到 mysql 中的表中
    否则获取开始日期并与今天进行比较
    如果匹配displ

这是代码。

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();

一种解决方案是使用应用程序的某些编译(或字节编译)形式而不是源文件。 查看此链接。 http://php.net/manual/en/book.bcompiler.php , http://www.phpcompiler.org

请按照以下步骤在 php 项目中获得完全安全的试用期...

1 . 在您的数据库中为试用期创建一个表

ex. trial(id,reg_date,days_of_trial).

2 . 在您的索引页面或登录页面中,无论是什么,添加如下代码逻辑

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 . 在 expired/index.php 文件中删除你的项目主目录作为.. <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 . 现在替换您原来的主页代码以重定向到过期页面..

ex.
    $file = fopen("../index.php","w");<br/>
fwrite($file,"<?php header('Location: http://localhost/proj_dir/expired/');?>");<br/>
fclose($file);<br/>
  • 不要忘记备份项目目录和数据库。
  • 您的 php 项目在试用期内完全安全......

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM