[英]Implementing trial period for local PHP application
我最近完成了我的 PHP 应用程序,我想知道是否有可能有一种试用期。 因此,当达到该时间段时,屏幕上会出现错误。
感谢您的时间和答复。 我最欣赏他们。
您可以使用 Zend Encoder 或 Ioncube 加密您的源代码,或混淆它们。
但事实是,上面的一切都可以修补。 因此,如果目标用户有足够的经验 - 他们可以删除您的试用期检查。
是的,您可以:前段时间出现需要时,我也这样做了。 它很简单,你可以改进它。 遵循这个算法;
这是代码。
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/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.