php程序版权问题,php+c实现网络版权验证

客户端(C):

/*

Copyright check frame

written by Radish.ghost Jan.2015

*/

#include

#include

#include

#ifdef C

#define bool int //C hesn't bool type

#endif

#pragma comment(lib, "urlmon.lib")

#ifndef USETIMES

#define USETIMES 50 //How many times can use

#endif

char*getinf();//Get the disk information

bool check1();//Connect server

int check2();//Check the file

int main()

{

check1();

check2();

if(check2())printf("You can use it!(%d times)\n",check2());

else {printf("You can't use it!\n");exit(0);}

/*

Your code here!

*/

return 0;

}

char*getinf()

{

char buf[MAX_PATH];

DWORD Ser;

DWORD Length;

char tmp[100];

int flag=0;

GetVolumeInformation("C:\\",NULL,MAX_PATH,&Ser,&Length,NULL,NULL,MAX_PATH);

//Ser为long 要转换成一个能用的字符串

while(Ser)//Convert long to char*

{

tmp[flag++]=(char)(Ser%10+'0');

Ser/=10;

}

tmp[flag]='\0';

return tmp;

}

bool check1()

{

char *ur=getinf();

char url[100]="http://localhost/bq.php?M=";

strcat(url,ur);

if(URLDownloadToFile(0,url,"c:\\a",0,NULL))return 1;

else return 0;

}

int check2()

{

int times;

freopen("c:\\a","r",stdin);

scanf("%d",×);

if(times>(-1*USETIMES+50))return times;

else return 0;

}

服务器端(php):

/*在线版权验证*/

Header("Content-type: text/plain");

$M=$_GET['M'];//获取硬盘序列号

if(!file_exists($M))

{

file_put_contents($M,"50");

echo '50';

}

else

{

$times=file_get_contents($M);

unlink($M);

file_put_contents($M,$times-1);

echo $times;

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值