Hey,
How would you make a script that if the scipt on the users server cant find anything (Eg Licence Key) it will lock the domain or script (like a license system)
Danny
Printable View
Hey,
How would you make a script that if the scipt on the users server cant find anything (Eg Licence Key) it will lock the domain or script (like a license system)
Danny
Yeah i know i was just wondering so i can try myself XD not to relece or anything im lerning php
Im just looking for the locking site of thins as help
You could do a *simple* script with file_get_contents to get a file on your server that checks the server, ip, and or folder and returns something.
PHP Code:<?php
$server = "bob.com";
$get_l = file_get_contents("http://www.myserver.com/license/check.php?server=$server");
if ($get_l == "expired")
{
echo "Your licence has expired.";
exit;
}
if ($get_l == "none")
{
echo "Thats no license!";
exit;
}
?>
Yeah i see that that will echo it but i dont think it will stop the user from doing anything =S
If you take and make that into a script, and include it into the configuration file.. then Zend Encode it, it will stop the script from ever running using exit; ;)
Oh, one last think what would the server end look like :S (as in my end)
Soz for dubble post cant edit other 1
Can anyone help me wid this?
Server end, do you know how to use MySQL?
Yes i do =D i just need some guidance
Make a new table that has,
license, domain
and then on the server end just check that the license and domain is right.
I will write a script later, I am on my laptop. No phpDesigner.
I am not going to encode it :P Just showing him how its done.
Yeah I use phpDesigner 2008 Professional and Zend Studio for SVN.
ok, i know how to make it check but i dont know the bit where my server replys to the other server :S like the true and false thing =S
also is there any programs that encode php?
Thanks, Yeah i think i will wait for some more guidance when hes on his PC :D
I would write you one, but im trying to find someone to code the new dePanel layout & im finishing dePanel off
Bump this post as still need help XD
okay well i think your still needing the server bit this is only to show to it will or may not work.
Code:$server = $_GET[server];
$license = mysql_query("SELECT * FROM license WHERE server= '$server'");
$license = mysql_fetch_array($license);
if($license == "0")
{
die('No license at this url.');
}
elseif($license[stats] == "suspended")
{
die('Your license has been suspended.');
}
Well.... heres a little insight....
The Script
Your ServerPHP Code:<?php
$d = $_SERVER['HTTP_HOST']; //Get current domain
$d1 = str_replace('www.', '', $d); //Remove unwanted stuff
$domain = str_replace('w3.', '', $d1); //And removing more...
$result = mysql_query("SELECT license FROM settings"); //Get license
$row = mysql_fetch_array($result);
$license = $row['license'];
if($file = @file_get_contents("http://licensing.yoursite.com?d=$domain&l=$license")){
echo $file;
}else{
echo 'Could not connect to licensing server.';
?>
Don't use that exact code but its something to build on :) Hope it helps!PHP Code:<?php
//Connect To Your License DB Here
$d = $_GET['domain'];
$l = $_GET['license'];
if($domain != ""&&$license != ""){
//Get Licenses From Your DB
$ls = mysql_query("SELECT * FROM licenses WHERE license = '$l'"); //Check db for license
$i = mysql_fetch_array($ls);
$count = mysql_query("SELECT COUNT(id) FROM licenses WHERE license = '$l'"); //Count instances found
$total = mysql_num_rows($count);
if($total == "1"&&$d = $i['domain']){ //What happens if the license is valid
echo 'Yay! Your license is valid.';
}else{ //What happens if it can't verify license
echo 'Could not validate license. Please contact us.';
echo '<meta http-equiv="refresh" content="2;url=http://licensing.yoursite.com/error.php">';
}
}
?>
Note: The domains should be listed as "yoursite.com" not "www.yoursite.com" or "http://yoursite.com" for the above to work properly.
(Refer to code commenting for help as to what does what)
Thanks Scriptz +rep if i can XD and vistaboy