PHP License Script need help.

Shadow121

Member
Messages
901
Reaction score
0
Points
16
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>";
}
?>
 
Last edited:

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
What does the file "configuration.inc.php" contain / do?
 

Shadow121

Member
Messages
901
Reaction score
0
Points
16
The configuration.inc.php file contains all the calls to connect to the database, initialize the language system, PHP IP Filters and blacklist checks.
 

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
The configuration.inc.php file contains all the calls to connect to the database, initialize the language system, PHP IP Filters and blacklist checks.


If the script is downing the server this is where I would start looking for answers in the abscence of any meaningful error codes from the server.

Split the config file into seperate chunks and check each one in turn starting with the basic connections to the database and include the others one at a time.

Just a thought why cannot IP filtering and blacklist be handled by htaccess file?
 

Shadow121

Member
Messages
901
Reaction score
0
Points
16
I'm using Xip which is a class from PHP-Classes. The lacklist checker goes out to SpamCop and SpamHaus since simple IP blocking won't make sure they aren't spammers etc. yeah htaccess can handle IP blocking but I'm not the type of person to log into cPanel or an equivalent just to ban someone every time its needed. For example, I'm helping run a site with a contact form with Captcha. The bots, or person running them have adapted to the captcha. At times there are ~30+ messages of spam. A php script may prove helpful, especially if you don't have cPanel access.

How do you propose checking? Add a die with the execution time after each part?
 
Top