<?php
	global $license_key_code, $legal_licensee_name, $admin_user_name, $admin_password;
	global $auth_timeout_minutes, $max_login_attempts, $login_lockout_minutes;
	global $multi_server_global_settings, $cli_auth_key_code;
	$admin_password_repeat = "";
?>
	<div class="toolcontainer">
		<div class="licensebox">
<?php
		if(!file_exists(get_base_dir() . "lib/php/datagrid.php"))
		{
?>
			<h3>License Code</h3>
			<div class="dotline"></div>
			<p>You will receive a valid license code after you purchase the standard edition.</p>
			<p>You can contact us if you are using the evaluation edition and want to extend your evaluation. We will
			then send you an extension license code.</p>
			<p>If you have a license code, please copy and paste it into the box below and click 'Save'.</p> 
			<input type="password" id="license_key_code" name="license_key_code" value="" style="width:510px;">
			<p>Please don't enter random text as the license code. The application will stop working if you do so.</p>
			<div class="dotline"></div>
			<button id="ui_set_license">Save License Code</button>
			<br>
			<p></p>
<?php
		}
		else
		{
?>
			<h3>Licensed To</h3>
			<div class="dotline"></div>
			<p>Enter the entity name the application is licensed to. If this entry is already filled, you may
			not be able to change it.</p> 
			<input type="text" id="legal_licensee_name" name="legal_licensee_name" value="<?php echo $legal_licensee_name; ?>" style="width:510px;"><br><br>
			<button id="ui_set_licensee_name">Save Licensee Name</button>
			<br><br>
			<div class="dotline"></div>
			<input type="checkbox" id="multi_server_global_settings" <?php echo ($multi_server_global_settings ? "checked" : ""); ?>><b>Save Settings Globally</b>. 
			Uncheck this box if you have multiple installations and you want each installation
			to have it's own seperate settings.<br>
			<p></p>
<?php
		}
?>
		<br>
		
		<h3>CLI Authorization Key</h3>
		<div class="dotline"></div>
		<p>The <b>CLI Authorization Key</b> is used to
		run various reports and other scripts as a cronjob. The report generation scripts will run only
		if you are logged in (assuming you have enabled the built-in password protection). This will
		be a problem when you try to run scripts as a cronjob. The CLI authorization key allows you to specify
		<b>key=xxx</b> as a command-line parameter (when running the script as PHP CLI) or
		as a GET variable (when running as a web script) so that the script will execute without loggin in.</p>
		<input type="text" id="cli_auth_key_code" name="cli_auth_key_code" value="<?php echo $cli_auth_key_code; ?>" style="width:510px;">
		<p>You can change the key by typing into the above box and clicking 'Save Authorization Key'. Please use only alphabets 
		and digits (<b>no punctuations and symbols</b>)</p>
		<button id="ui_set_cliauthkey">Save Authorization Key</button>
			
		</div>
		
		<div class="userauthbox">
			<h3>Password Protection</h3>		
<?php
global $admin_user_name_in_config, $admin_user_password_in_config;
			if($admin_user_password_in_config || $admin_user_name_in_config)
				echo "<p>You have specified a username and/ or password in the &quot;config.php&quot;. The username and/or password below <b>will not take effect</b> until you remove those entries.</p>";
			else if($admin_user_name == "" || $admin_password == "")
				echo '<p>Enter a username and password to enable password protection. The password must be at least 6 characters long.</p>';
			else
				echo '<p>You can change your admin username and password below. The password must be at least 6 characters long. Remove the admin username to completely stop the password protection.</p>';
?>
			<p><b>User Name</b> (Super Admin)<br>
			<input type="text" id="admin_user_name" name="admin_user_name" value="<?php echo $admin_user_name; ?>" style="width:280px;"><br>
			<b>New Password</b><br>
			<input type="password" id="admin_password" name="admin_password" value="" style="width:280px;"><br>
			<b>Confirm Password</b><br>
			<input type="password" id="admin_password_repeat" name="admin_password_repeat" value="" style="width:280px;"><br><br>
			<button id="ui_set_user_info">Save Username &amp; Password</button></p><br>
			
			<p><b>Session Timeout</b> (Min)<br>
			<input type="text" id="auth_timeout_minutes" name="auth_timeout_minutes" value="<?php echo $auth_timeout_minutes; ?>" style="width:280px;"><br>
			<b>Max Login Attempts</b> (0 = unlimited)<br>
			<input type="text" id="max_login_attempts" name="max_login_attempts" value="<?php echo $max_login_attempts; ?>" style="width:280px;"><br>
			<b>Lockout After Max Attempts</b> (Min)<br>
			<input type="text" id="login_lockout_minutes" name="login_lockout_minutes" value="<?php echo $login_lockout_minutes; ?>" style="width:280px;"><br>
		</div>
		<div style="clear:both;"></div>
	</div>
