按照以下步骤在 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 项目在试用期完全安全.....