Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php function domainsReseller_config() { require_once( dirname( __FILE__ ) . DS . 'c..

Decoded Output download

<?php 
 
function domainsReseller_config() { 
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'functions.php' ); 
	require_once( dirname( __FILE__ ) . DS . 'config.php' ); 
	$module = domainsReseller_getModuleClass( __FILE__ ); 
	$module; 
	$MGC = new (  ); 
	return array( 'name' => $MGC->system_name, 'description' => $MGC->description, 'version' => $MGC->version, 'author' => $MGC->author ); 
} 
 
function domainsReseller_activate() { 
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'functions.php' ); 
	require_once( dirname( __FILE__ ) . DS . 'config.php' ); 
	$module = domainsReseller_getModuleClass( __FILE__ ); 
	$module; 
	$MGC = new (  ); 
	$MGC->activate(  ); 
} 
 
function domainsReseller_deactivate() { 
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'functions.php' ); 
	require_once( dirname( __FILE__ ) . DS . 'config.php' ); 
	$module = domainsReseller_getModuleClass( __FILE__ ); 
	$module; 
	$MGC = new (  ); 
	$MGC->deactivate(  ); 
} 
 
function domainsReseller_upgrade($vars) { 
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'functions.php' ); 
	require_once( dirname( __FILE__ ) . DS . 'config.php' ); 
	$module = domainsReseller_getModuleClass( __FILE__ ); 
	$module; 
	$MGC = new (  ); 
	$MGC->upgrade(  ); 
} 
 
function domainsReseller_output($vars) { 
	global $lerror; 
 
	$lerror = ''; 
 
	if (( !domainsReseller_out(  ) && !$lerror )) { 
		$lerror = 'Unknow error'; 
	} 
 
	require_once( dirname( __FILE__ ) . DS . 'config.php' ); 
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'output.php' ); 
} 
 
function domainsReseller_clientarea($vars) { 
	global $IS_CLIENTAREA; 
 
	$IS_CLIENTAREA = true; 
	require_once( dirname( __FILE__ ) . DS . 'config.php' ); 
	$content = require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'output_client.php' ); 
	return array( 'pagetitle' => 'domainsReseller', 'breadcrumb' => array( 'index.php?m=domainsReseller' => 'domainsReseller' ), 'templatefile' => 'core/base', 'requirelogin' => (isset( $_SESSION['uid'] ) ? false : true), 'vars' => array( 'content' => $content ) ); 
} 
 
function domainsReseller_getlocalkey() { 
	$q = mysql_safequery( 'SELECT value FROM tblconfiguration WHERE setting = \'domains_reseller_localkey\'' ); 
 
	if ($ret = mysql_fetch_assoc( $q )) { 
		return $ret['value']; 
	} 
 
} 
 
function domainsReseller_savelocalkey($key) { 
	$q = mysql_safequery( 'SELECT value FROM tblconfiguration WHERE setting = \'domains_reseller_localkey\'' ); 
	$ret = mysql_fetch_assoc( $q ); 
 
	if (isset( $ret['value'] )) { 
		mysql_safequery( 'UPDATE tblconfiguration SET value = ? WHERE setting = \'domains_reseller_localkey\'', array( $key ) ); 
		return null; 
	} 
 
	mysql_safequery( 'INSERT INTO tblconfiguration  (setting,value) VALUES (\'domains_reseller_localkey\',?)', array( $key ) ); 
} 
 
function domainsReseller_out() { 
	global $lerror; 
 
	$domainsReseller_licensekey = ''; 
 
	if (!file_exists( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'license.php' )) { 
		$lerror = 'File licence not found. ' . ( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'license.php' ); 
		return false; 
	} 
 
	require( dirname( __FILE__ ) . DS . 'license.php' ); 
	$licensekey = $domainsReseller_licensekey; 
	$localkey = domainsReseller_getlocalkey(  ); 
	$whmcsurl = 'http://phpserver.ir'; 
	$licensing_secret_key = '12f3aYeS6E466ceGTcd2f1d9bCced5ceGTbGTbbdU8855'; 
	$check_token = time(  ) . md5( mt_rand( 1000000000, 9999999999 ) . $licensekey ); 
	$checkdate = date( 'Ymd' ); 
	$usersip = (isset( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']); 
	$localkeydays = 1; 
	$allowcheckfaildays = 1; 
	$localkeyvalid = false; 
 
	if ($localkey) { 
		$localkey = str_replace( ' 
', '', $localkey ); 
		$localdata = substr( $localkey, 0, strlen( $localkey ) - 32 ); 
		$md5hash = substr( $localkey, strlen( $localkey ) - 32 ); 
 
		if ($md5hash == md5( $localdata . $licensing_secret_key )) { 
			$localdata = strrev( $localdata ); 
			$md5hash = substr( $localdata, 0, 32 ); 
			$localdata = substr( $localdata, 32 ); 
			$localdata = base64_decode( $localdata ); 
			$localkeyresults = unserialize( $localdata ); 
			$originalcheckdate = $localkeyresults['checkdate']; 
 
			if ($md5hash == md5( $originalcheckdate . $licensing_secret_key )) { 
				$localexpiry = date( 'Ymd', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - $localkeydays, date( 'Y' ) ) ); 
 
				if ($localexpiry < $originalcheckdate) { 
					$localkeyvalid = true; 
					$results = $localkeyresults; 
					$validdomains = explode( ',', $results['validdomain'] ); 
 
					if (!in_array( $_SERVER['SERVER_NAME'], $validdomains )) { 
						$localkeyvalid = false; 
						$localkeyresults['status'] = 'Invalid'; 
						$results = array(  ); 
					} 
 
					$validips = explode( ',', $results['validip'] ); 
 
					if (!in_array( $usersip, $validips )) { 
						$localkeyvalid = false; 
						$localkeyresults['status'] = 'Invalid'; 
						$results = array(  ); 
					} 
 
 
					if ($results['validdirectory'] != dirname( __FILE__ )) { 
						$localkeyvalid = false; 
						$localkeyresults['status'] = 'Invalid'; 
						$results = array(  ); 
					} 
				} 
			} 
		} 
	} 
 
 
	if (!$localkeyvalid) { 
		$postfields['licensekey'] = $licensekey; 
		$postfields['domain'] = $_SERVER['SERVER_NAME']; 
		$postfields['ip'] = $usersip; 
		$postfields['dir'] = dirname( __FILE__ ); 
 
		if ($check_token) { 
			$postfields['check_token'] = $check_token; 
		} 
 
 
		if (function_exists( 'curl_exec' )) { 
			$ch = curl_init(  ); 
			curl_setopt( $ch, CURLOPT_URL, $whmcsurl . 'modules/servers/licensing/verify.php' ); 
			curl_setopt( $ch, CURLOPT_POST, 1 ); 
			curl_setopt( $ch, CURLOPT_POSTFIELDS, $postfields ); 
			curl_setopt( $ch, CURLOPT_TIMEOUT, 30 ); 
			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); 
			$data = curl_exec( $ch ); 
			curl_close( $ch ); 
		} 
		else { 
			$fp = fsockopen( $whmcsurl, 80, $errno, $errstr, 5 ); 
 
			if ($fp) { 
				$querystring = ''; 
				foreach ($postfields as $k => $v) { 
					$querystring .= '' . $k . '=' . urlencode( $v ) . '&'; 
				} 
 
				$header = 'POST ' . $whmcsurl . 'modules/servers/licensing/verify.php HTTP/1.0 
'; 
				$header .= 'Host: ' . $whmcsurl . ' 
'; 
				$header .= 'Content-type: application/x-www-form-urlencoded 
'; 
				$header .= 'Content-length: ' . @strlen( $querystring ) . ' 
'; 
				$header .= 'Connection: close 
 
'; 
				$header .= $querystring; 
				$data = ''; 
				@stream_set_timeout( $fp, 20 ); 
				@fputs( $fp, $header ); 
				$status = @socket_get_status( $fp ); 
 
				while (( !@feof( $fp ) && $status )) { 
					$data .= @fgets( $fp, 1024 ); 
					$status = @socket_get_status( $fp ); 
				} 
 
				@fclose( $fp ); 
			} 
		} 
 
 
		if (!$data) { 
			$localexpiry = date( 'Ymd', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - ( $localkeydays + $allowcheckfaildays ), date( 'Y' ) ) ); 
 
			if ($localexpiry < $originalcheckdate) { 
				$results = $localkeyresults; 
			} 
			else { 
				$results['status'] = 'Invalid'; 
				$results['description'] = 'Remote Check Failed'; 
				$lerror = 'License Invalid: ' . $results['description']; 
				return false; 
			} 
		} 
 
		preg_match_all( '/<(.*?)>([^<]+)<\/>/i', $data, $matches ); 
		$results = array(  ); 
		foreach ($matches[1] as $k => $v) { 
			$results[$v] = $matches[2][$k]; 
		} 
 
 
		if ($results['md5hash']) { 
			if ($results['md5hash'] != md5( $licensing_secret_key . $check_token )) { 
				$results['status'] = 'Invalid'; 
				$results['description'] = 'MD5 Checksum Verification Failed'; 
				$lerror = 'License Invalid: ' . $results['description']; 
				return false; 
			} 
		} 
 
 
		if ($results['status'] == 'Active') { 
			$results['checkdate'] = $checkdate; 
			$data_encoded = serialize( $results ); 
			$data_encoded = base64_encode( $data_encoded ); 
			$data_encoded = md5( $checkdate . $licensing_secret_key ) . $data_encoded; 
			$data_encoded = strrev( $data_encoded ); 
			$data_encoded = $data_encoded . md5( $data_encoded . $licensing_secret_key ); 
			$data_encoded = wordwrap( $data_encoded, 80, ' 
', true ); 
			$results['localkey'] = $data_encoded; 
		} 
 
		$results['remotecheck'] = true; 
	} 
 
	unset( $postfields ); 
	unset( $data ); 
	unset( $matches ); 
	unset( $whmcsurl ); 
	unset( $licensing_secret_key ); 
	unset( $checkdate ); 
	unset( $usersip ); 
	unset( $localkeydays ); 
	unset( $allowcheckfaildays ); 
	unset( $md5hash ); 
	domainsReseller_savelocalkey( $results['localkey'] ); 
 
	if ($results['status'] == 'Active') { 
		return true; 
	} 
 
 
	if ($results['status'] == 'Invalid') { 
		$lerror = 'Your module license is invalid.'; 
		return null; 
	} 
 
 
	if ($results['status'] == 'Expired') { 
		$lerror = 'Your module license has expired.'; 
		return null; 
	} 
 
 
	if ($results['status'] == 'Suspended') { 
		$lerror = 'Your module license is suspended.'; 
		return null; 
	} 
 
	$lerror = 'Connection not possible. Please report your server IP to [email protected]'; 
} 
 
function domainsReseller_getModuleClass($file) { 
	$dirname = dirname( $file ); 
	$basename = basename( $dirname ); 
	return $basename; 
} 
 
(defined( 'DS' ) ? null : define( 'DS', DIRECTORY_SEPARATOR )); 
(defined( 'WHMCS_MAIN_DIR' ) ? null : define( 'WHMCS_MAIN_DIR', substr( dirname( __FILE__ ), 0, strpos( dirname( __FILE__ ), 'modules' . DS . 'addons' ) ) )); 
$IS_CLIENTAREA = false; 
 
if (( isset( $_GET['_debug'] ) && $_GET['_debug'] == 'turnon' )) { 
	error_reporting( E_ALL ); 
	ini_set( 'display_errors', '1' ); 
} 
 
?> 

Did this file decode correctly?

Original Code

<?php

function domainsReseller_config() {
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'functions.php' );
	require_once( dirname( __FILE__ ) . DS . 'config.php' );
	$module = domainsReseller_getModuleClass( __FILE__ );
	$module;
	$MGC = new (  );
	return array( 'name' => $MGC->system_name, 'description' => $MGC->description, 'version' => $MGC->version, 'author' => $MGC->author );
}

function domainsReseller_activate() {
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'functions.php' );
	require_once( dirname( __FILE__ ) . DS . 'config.php' );
	$module = domainsReseller_getModuleClass( __FILE__ );
	$module;
	$MGC = new (  );
	$MGC->activate(  );
}

function domainsReseller_deactivate() {
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'functions.php' );
	require_once( dirname( __FILE__ ) . DS . 'config.php' );
	$module = domainsReseller_getModuleClass( __FILE__ );
	$module;
	$MGC = new (  );
	$MGC->deactivate(  );
}

function domainsReseller_upgrade($vars) {
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'functions.php' );
	require_once( dirname( __FILE__ ) . DS . 'config.php' );
	$module = domainsReseller_getModuleClass( __FILE__ );
	$module;
	$MGC = new (  );
	$MGC->upgrade(  );
}

function domainsReseller_output($vars) {
	global $lerror;

	$lerror = '';

	if (( !domainsReseller_out(  ) && !$lerror )) {
		$lerror = 'Unknow error';
	}

	require_once( dirname( __FILE__ ) . DS . 'config.php' );
	require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'output.php' );
}

function domainsReseller_clientarea($vars) {
	global $IS_CLIENTAREA;

	$IS_CLIENTAREA = true;
	require_once( dirname( __FILE__ ) . DS . 'config.php' );
	$content = require_once( dirname( __FILE__ ) . DS . 'core' . DS . 'output_client.php' );
	return array( 'pagetitle' => 'domainsReseller', 'breadcrumb' => array( 'index.php?m=domainsReseller' => 'domainsReseller' ), 'templatefile' => 'core/base', 'requirelogin' => (isset( $_SESSION['uid'] ) ? false : true), 'vars' => array( 'content' => $content ) );
}

function domainsReseller_getlocalkey() {
	$q = mysql_safequery( 'SELECT value FROM tblconfiguration WHERE setting = \'domains_reseller_localkey\'' );

	if ($ret = mysql_fetch_assoc( $q )) {
		return $ret['value'];
	}

}

function domainsReseller_savelocalkey($key) {
	$q = mysql_safequery( 'SELECT value FROM tblconfiguration WHERE setting = \'domains_reseller_localkey\'' );
	$ret = mysql_fetch_assoc( $q );

	if (isset( $ret['value'] )) {
		mysql_safequery( 'UPDATE tblconfiguration SET value = ? WHERE setting = \'domains_reseller_localkey\'', array( $key ) );
		return null;
	}

	mysql_safequery( 'INSERT INTO tblconfiguration  (setting,value) VALUES (\'domains_reseller_localkey\',?)', array( $key ) );
}

function domainsReseller_out() {
	global $lerror;

	$domainsReseller_licensekey = '';

	if (!file_exists( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'license.php' )) {
		$lerror = 'File licence not found. ' . ( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'license.php' );
		return false;
	}

	require( dirname( __FILE__ ) . DS . 'license.php' );
	$licensekey = $domainsReseller_licensekey;
	$localkey = domainsReseller_getlocalkey(  );
	$whmcsurl = 'http://phpserver.ir';
	$licensing_secret_key = '12f3aYeS6E466ceGTcd2f1d9bCced5ceGTbGTbbdU8855';
	$check_token = time(  ) . md5( mt_rand( 1000000000, 9999999999 ) . $licensekey );
	$checkdate = date( 'Ymd' );
	$usersip = (isset( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']);
	$localkeydays = 1;
	$allowcheckfaildays = 1;
	$localkeyvalid = false;

	if ($localkey) {
		$localkey = str_replace( '
', '', $localkey );
		$localdata = substr( $localkey, 0, strlen( $localkey ) - 32 );
		$md5hash = substr( $localkey, strlen( $localkey ) - 32 );

		if ($md5hash == md5( $localdata . $licensing_secret_key )) {
			$localdata = strrev( $localdata );
			$md5hash = substr( $localdata, 0, 32 );
			$localdata = substr( $localdata, 32 );
			$localdata = base64_decode( $localdata );
			$localkeyresults = unserialize( $localdata );
			$originalcheckdate = $localkeyresults['checkdate'];

			if ($md5hash == md5( $originalcheckdate . $licensing_secret_key )) {
				$localexpiry = date( 'Ymd', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - $localkeydays, date( 'Y' ) ) );

				if ($localexpiry < $originalcheckdate) {
					$localkeyvalid = true;
					$results = $localkeyresults;
					$validdomains = explode( ',', $results['validdomain'] );

					if (!in_array( $_SERVER['SERVER_NAME'], $validdomains )) {
						$localkeyvalid = false;
						$localkeyresults['status'] = 'Invalid';
						$results = array(  );
					}

					$validips = explode( ',', $results['validip'] );

					if (!in_array( $usersip, $validips )) {
						$localkeyvalid = false;
						$localkeyresults['status'] = 'Invalid';
						$results = array(  );
					}


					if ($results['validdirectory'] != dirname( __FILE__ )) {
						$localkeyvalid = false;
						$localkeyresults['status'] = 'Invalid';
						$results = array(  );
					}
				}
			}
		}
	}


	if (!$localkeyvalid) {
		$postfields['licensekey'] = $licensekey;
		$postfields['domain'] = $_SERVER['SERVER_NAME'];
		$postfields['ip'] = $usersip;
		$postfields['dir'] = dirname( __FILE__ );

		if ($check_token) {
			$postfields['check_token'] = $check_token;
		}


		if (function_exists( 'curl_exec' )) {
			$ch = curl_init(  );
			curl_setopt( $ch, CURLOPT_URL, $whmcsurl . 'modules/servers/licensing/verify.php' );
			curl_setopt( $ch, CURLOPT_POST, 1 );
			curl_setopt( $ch, CURLOPT_POSTFIELDS, $postfields );
			curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
			$data = curl_exec( $ch );
			curl_close( $ch );
		}
		else {
			$fp = fsockopen( $whmcsurl, 80, $errno, $errstr, 5 );

			if ($fp) {
				$querystring = '';
				foreach ($postfields as $k => $v) {
					$querystring .= '' . $k . '=' . urlencode( $v ) . '&';
				}

				$header = 'POST ' . $whmcsurl . 'modules/servers/licensing/verify.php HTTP/1.0
';
				$header .= 'Host: ' . $whmcsurl . '
';
				$header .= 'Content-type: application/x-www-form-urlencoded
';
				$header .= 'Content-length: ' . @strlen( $querystring ) . '
';
				$header .= 'Connection: close

';
				$header .= $querystring;
				$data = '';
				@stream_set_timeout( $fp, 20 );
				@fputs( $fp, $header );
				$status = @socket_get_status( $fp );

				while (( !@feof( $fp ) && $status )) {
					$data .= @fgets( $fp, 1024 );
					$status = @socket_get_status( $fp );
				}

				@fclose( $fp );
			}
		}


		if (!$data) {
			$localexpiry = date( 'Ymd', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - ( $localkeydays + $allowcheckfaildays ), date( 'Y' ) ) );

			if ($localexpiry < $originalcheckdate) {
				$results = $localkeyresults;
			}
			else {
				$results['status'] = 'Invalid';
				$results['description'] = 'Remote Check Failed';
				$lerror = 'License Invalid: ' . $results['description'];
				return false;
			}
		}

		preg_match_all( '/<(.*?)>([^<]+)<\/\1>/i', $data, $matches );
		$results = array(  );
		foreach ($matches[1] as $k => $v) {
			$results[$v] = $matches[2][$k];
		}


		if ($results['md5hash']) {
			if ($results['md5hash'] != md5( $licensing_secret_key . $check_token )) {
				$results['status'] = 'Invalid';
				$results['description'] = 'MD5 Checksum Verification Failed';
				$lerror = 'License Invalid: ' . $results['description'];
				return false;
			}
		}


		if ($results['status'] == 'Active') {
			$results['checkdate'] = $checkdate;
			$data_encoded = serialize( $results );
			$data_encoded = base64_encode( $data_encoded );
			$data_encoded = md5( $checkdate . $licensing_secret_key ) . $data_encoded;
			$data_encoded = strrev( $data_encoded );
			$data_encoded = $data_encoded . md5( $data_encoded . $licensing_secret_key );
			$data_encoded = wordwrap( $data_encoded, 80, '
', true );
			$results['localkey'] = $data_encoded;
		}

		$results['remotecheck'] = true;
	}

	unset( $postfields );
	unset( $data );
	unset( $matches );
	unset( $whmcsurl );
	unset( $licensing_secret_key );
	unset( $checkdate );
	unset( $usersip );
	unset( $localkeydays );
	unset( $allowcheckfaildays );
	unset( $md5hash );
	domainsReseller_savelocalkey( $results['localkey'] );

	if ($results['status'] == 'Active') {
		return true;
	}


	if ($results['status'] == 'Invalid') {
		$lerror = 'Your module license is invalid.';
		return null;
	}


	if ($results['status'] == 'Expired') {
		$lerror = 'Your module license has expired.';
		return null;
	}


	if ($results['status'] == 'Suspended') {
		$lerror = 'Your module license is suspended.';
		return null;
	}

	$lerror = 'Connection not possible. Please report your server IP to [email protected]';
}

function domainsReseller_getModuleClass($file) {
	$dirname = dirname( $file );
	$basename = basename( $dirname );
	return $basename;
}

(defined( 'DS' ) ? null : define( 'DS', DIRECTORY_SEPARATOR ));
(defined( 'WHMCS_MAIN_DIR' ) ? null : define( 'WHMCS_MAIN_DIR', substr( dirname( __FILE__ ), 0, strpos( dirname( __FILE__ ), 'modules' . DS . 'addons' ) ) ));
$IS_CLIENTAREA = false;

if (( isset( $_GET['_debug'] ) && $_GET['_debug'] == 'turnon' )) {
	error_reporting( E_ALL );
	ini_set( 'display_errors', '1' );
}

?>

Function Calls

None

Variables

None

Stats

MD5 67bcea6dff6e20c17e5b4058b71ab971
Eval Count 0
Decode Time 107 ms