<?php


/*
***
****


	Hello and welcome to Kopage!
	----------------------------------
	
	Thank you for choosing our SiteBuilder!
	


****
***
*/

// List of your servers (IP addresses, separated by comma character),
// only installations to these servers will be allowed.
define('kopageAllowedServers','1.1.1.1,2.2.2.2,3.3.3.3,etc');

//define('preLocation','pre-unlock.php');
//define('kopageAllowedServers_PRO','1.1.1.1,2.2.2.2,3.3.3.3,etc');

// Database settings.
// installation process will work even if this is not configured,
// but installations will not be tracked anywhere,
// you may want to have your own database in use, 
// to see which users have installed Kopage websites.
// Look for database structure in kopage.sql file.

define('kopageMySQL_hostname','localhost');
define('kopageMySQL_username','sql_USERNAME');
define('kopageMySQL_password','sql_PASSWORD');
define('kopageMySQL_database','sql_DATABASE');

//define('kopageDemoWebsite','http://demo-website.YOUR-COMPANY.com');

// username and password for your personal admin,
// where - if MySQL is set, you can view installation statistics.

define('kopageAdmin_username','admin');
define('kopageAdmin_password','pass');
define('kopageAdmin_email','hello@your-company.com');
 
// Trial Websitebuilder Definitions. Don't use them (leave commented),
// unless you're setting up Kopage in standalone (not in WHMCS) "Free Trials" mode, 
// with subdomain's wildcard available.

//define('kopageTrialURL','http://[USER].'.$_SERVER['HTTP_HOST']);
//define('kopageTrialURL_Prefix','www.');
//define('kopageTrialURL_Postfix','.'.$_SERVER['HTTP_HOST']);
//define('kopageTrialURL_SampleDomain','my-website');
//define('kopageTrialFolder','kopage_trials'); 
//define('kopageFilesPath','../../../kopage_files/');
//define('kopageTrialExpire','0'); // websites will expire in predefined number of days.

// ---End of Trial Websitebuilder Definitions:

define('_Continue','Continue');
define('_LiveDemo','Live Demo');
define('_ftpUsernameLabel','Your FTP Username'); // this is just a phrase, don't enter real username
define('_ftpPasswordLabel','Your FTP Password'); // this is just a phrase, don't enter real password

// We recommend using Mailgun or Sendgrid to send email (it's free)
//define('mailgunInUse',1);
//define('mailgunKey','key-12345');

//define("smtpInUse","1");
//define("_smtpServer","your-server.com");
//define("_smtpPort","587");
//define("_smtpUser","username@your-server.com");
//define("_smtpPass","password");

// default language for sitebuilding process.
define("LANG","en");


// if FTP method is used to install, by default it's "passive" mode,
// if for some reason it's not supported on your server, or you experience installation issues
// after username/password is entered, but before installation starts, try "active" mode instead

//define("ftpMode","active");		

// Installation PROGRESS BAR.
// By default, switched OFF - in case of any problems, 
// there would be no errors visible, but as soon as you're sure that technically all is fine,
// unload this defintion (comment it), so it's not read by system,
// and installation progress bar will show installation progress.

define("UseOldInstallation","1");

// in many servers, files and folders has to be "writable", 
// what usually means 777 chmod for folders and 666 for files.
// Set this value to "1" if your server doesn't require chmod.
define("NOCHMODS",1);

function kopageVerifyDomain($domain){
	
	$_AlwaysAllowedServers=',127.*,10.*,192.168.*,172.16.*,'.$_SERVER['SERVER_ADDR'];
	$_AllowedServers=explode(',',str_replace(array(" ","\n"),'',kopageAllowedServers.$_AlwaysAllowedServers));
	$_AllowedServers_PRO=explode(',',str_replace(array(" ","\n"),'',kopageAllowedServers_PRO));
	
	$domain=gethostbyname(trim($domain));

			
	if(stristr(kopageAllowedServers,'*')){
		
		// there's IP range in use
		
		if(!function_exists('kopageIPmatch')) {
			function kopageIPmatch($pattern, $string) {
				return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
			}
		}
		
		foreach($_AllowedServers as $ip){
		
			if(kopageIPmatch($ip,$domain)){
				
				if(defined('preLocation') && in_array($domain,$_AllowedServers_PRO))
					$_SESSION['kopage']['add-pre']=1;
				else
					$_SESSION['kopage']['add-pre']=0;
				
				return true;				
			}
				
		}
			
		
	} else {
			
		if(in_array($domain,$_AllowedServers)){
			
			if(defined('preLocation') && in_array($domain,$_AllowedServers_PRO))
				$_SESSION['kopage']['add-pre']=1;
			else
				$_SESSION['kopage']['add-pre']=0;
					
			return TRUE;
		} else
			return FALSE;
	
	}
	
	
	
	// alternatively, if you have a MySQL table with allowed domains data,
	// remove proevious condition and customize sample function below:
	
	// set your MySQL database information
	$mySqlAccess = array(
		
		'host' 		=> 'host',
		'user' 		=> 'user',
		'password' 	=> 'pass',
		'table' 	=> 'table'
	
	);
	
	$link = mysql_connect($mySqlAccess['host'], $mySqlAccess['user'], $mySqlAccess['password'])
			or die ('cant connect to database');
			
			mysql_select_db ($mySqlAccess['table'])
			or die ('cant select database, table "'.$mySqlAccess['table'].'"');
			
	// customize your query if required.
	$result = mysql_fetch_array(mysql_query ("SELECT * FROM customer_domain WHERE domain = '$domain'"));
	if($result) return TRUE;
	else return FALSE;
		
}
		

?>