Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[PHP] License script help.

Newbie Spellweaver
Joined
Mar 31, 2007
Messages
75
Reaction score
1
Apparently this thing crashed a server 6 times and got two of my hosting accounts deleted. So, I asked the host owner person to help me make it so it can work on a shared server. I have no clue how to do so. Can someone help me?

PHP:
<?php
require ("/home/joe/FileLibrary/configuration.inc.php");
$lang['license_key_notfound'] = 'The key you have entered was not found.';
$lang['license_invalid_domain'] = 'The domain in which the script is hosted on is invalid.';
$lang['license_invalid_ip'] = 'The server IP address is not allowed to execute this script.';
$lang['license_expired'] = 'The license in use for this script has expired.';

$domain = $db->protect($_GET['domain']);
$ip = $db->protect($_GET['ip']);
$key = $db->protect($_GET['key']);
$getQuery = $db->dbQuery("SELECT * FROM `" . DB_PREFIX .
    "licenses` WHERE `key` = '$key';");
switch ($_GET['act']) {
    default:
    case 'verify_license':
        if ($db->dbCount($getQuery) == 0) {
            die($lang['license_key_notfound']);
        } else {
            $arrData = $db->dbFetch($getQuery);
            $domainArr = explode(",", $arrData->allowed_domains);
            $ipArr = explode(",", $arrData->allowed_ips);
            if ((!in_array($domain, $domainArr) && $arrData->allowed_domains != '*')) {
                die($lang['license_invalid_domain']);
            } else {
                if ((!in_array($ip, $ipArr) && $arrData->allowed_ips != '*') || (!is_array($ipArr) &&
                    $arrData->allowed_ips != '*')) {
                    die($lang['license_invalid_ip']);
                } else {
                    if ($arrData->expirey_date < date("Ymd") && $arrData->expirey_date != 'never') {
                        die($lang['license_expired']);
                    }else{
                        die("Okay!");
                    }
                }
            }
        }
        break;
    case 'script_info':
        if ($db->dbCount($getQuery) == 0) {
            die($lang['license_key_notfound']);
        } else {
            $arrData = $db->dbFetch($getQuery);
            $domainArr = explode(",", $arrData->allowed_domains);
            $ipArr = explode(",", $arrData->allowed_ips);
            if ((!in_array($domain, $domainArr) && $arrData->allowed_domains != '*')) {
                die($lang['license_invalid_domain']);
            } else {
                if ((!in_array($ip, $ipArr) && $arrData->allowed_ips != '*') || (!is_array($ipArr) &&
                    $arrData->allowed_ips != '*')) {
                    die($lang['license_invalid_ip']);
                } else {
                    if ($arrData->expirey_date < date("Ymd") && $arrData->expirey_date != 'never') {
                        die($lang['license_expired']);
                    }else{
                        if ($arrData->show_info == 1) {
                            die("yes");
                        }else{
                            die("no");
                        }
                    }
                }
            }
        }
        break;
    case 'license_info':
        if ($db->dbCount($getQuery) == 0) {
            die($lang['license_key_notfound']);
        } else {
            $arrData = $db->dbFetch($getQuery);
            $domainArr = explode(",", $arrData->allowed_domains);
            $ipArr = explode(",", $arrData->allowed_ips);
            if ((!in_array($domain, $domainArr) && $arrData->allowed_domains != '*')) {
                die($lang['license_invalid_domain']);
            } else {
                if ((!in_array($ip, $ipArr) && $arrData->allowed_ips != '*') || (!is_array($ipArr) &&
                    $arrData->allowed_ips != '*')) {
                    die($lang['license_invalid_ip']);
                } else {
                    if ($arrData->expirey_date < date("Ymd") && $arrData->expirey_date != 'never') {
                        die($lang['license_expired']);
                    }else{
                        die("Script created by ".$arrData->script_author." at <a href=\"".$arrData->script_com_link."\">".$arrData->script_company."</a>");
                    }
                }
            }
        }
        break;
}
?>

This is the licensing thing that lets a script to connect back.
PHP:
<?php
define("LICENSE_KEY","4T7P-M1U-9B1-717F");
function get_license($action = null)
{
	$url = "http://licensing.codingdev.net/serv.php?act=$action&key=".LICENSE_KEY."&domain=".$_SERVER['HTTP_HOST']."&ip=".$_SERVER['SERVER_ADDR'];
	$options = array(
		CURLOPT_USERAGENT => $domain . "(" . $ip . ") LICENSE CHECK",
		CURLOPT_CONNECTTIMEOUT => 60,
        CURLOPT_RETURNTRANSFER => 1,
		CURLOPT_TIMEOUT => 60,
		);
	$ch = curl_init($url);
	curl_setopt_array($ch, $options);
	$content = curl_exec($ch);
	curl_close($ch);
	return $content;
}
#Get general license information
$license_check = get_license('verify_license');
switch($license_check)
{
    default:
        die($license_check);
        break;
    case 'Okay!':
        //Do Nothing
        break;
}
print "Hello World!";
$info_check = get_license("script_info");
if($info_check == 'yes'){
    $license_info = get_license('license_info');
    print "<br /><br /><code>".$license_info."</code>";
}
?>
 
Infraction Baɴɴed
Loyal Member
Joined
Apr 9, 2008
Messages
1,416
Reaction score
169
i dont not quite understand what you are asking here.
 
Newbie Spellweaver
Joined
Oct 4, 2010
Messages
7
Reaction score
8
PHP:
function get_license($action = null) 
{ 
    $url = "http://licensing.codingdev.net/serv.php?act=$action&key=".LICENSE_KEY."&domain=".$_SERVER['HTTP_HOST']."&ip=".$_SERVER['SERVER_ADDR']; 
    $options = array( 
        CURLOPT_USERAGENT => $domain . "(" . $ip . ") LICENSE CHECK", 
        CURLOPT_CONNECTTIMEOUT => 60, 
        CURLOPT_RETURNTRANSFER => 1, 
        CURLOPT_TIMEOUT => 60, 
        ); 
    $ch = curl_init($url); 
    curl_setopt_array($ch, $options); 
    $content = curl_exec($ch); 
    curl_close($ch); 
    return $content; 
}

That is possibly one of the most unsecure thing done in PHP. That is free for cookie stealing and XSS attacks.
 
Newbie Spellweaver
Joined
Mar 31, 2007
Messages
75
Reaction score
1
@above Did I mention I encode that portion of the script? If no one knows what the encoded part is, then they can't do anything. Not to mention, everything passed to the serv.php is then made safe.

Now,
@holthelper
I was told by my host that the serv.php is not safe for shared servers. I want to be able to use this script on shared servers. I had a couple ideas. Switching it to Javascript and encode that, add a cache script and cache the results to call back later, or make a .php js file and encode the entire thing and use Javascript.

This post may sound harsh but I'm getting right to the point I'm trying to make. The cURL thing will likely be changed after I can get it safe for shared servers. Although, if I can't be bothered to change it out, could you tell me how to fix it?
 
Back
Top