<?php
ob_start();
date_default_timezone_set('Asia/Ho_Chi_Minh');
error_reporting (E_ALL);
ob_implicit_flush (TRUE);
ignore_user_abort (0);
if( !ini_get('safe_mode') ){
            set_time_limit(60);
} 
#################################################

$password = 'keink@';

#################################################


$self = isset($_SERVER['REQUEST_URI'])? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
$Deny = true;
$rand = '6e5be952b';
if(isset($_POST['logout'])) setcookie("cpwd",'',time());
elseif(isset($_POST['secure']) && $_POST['secure'] == $password) {	
	setcookie("cpwd",md5(md5($password).$rand),time()+24*60*60*7);
	$Deny = false;
}
if(isset($_COOKIE["cpwd"]) && $_COOKIE["cpwd"] == md5(md5($password).$rand)) {
	$Deny = false;
}

if ($Deny == true){
?>

	<html>
	<head>
		<meta http-equiv="Content-Language" content="en-us">
		<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
		<title>Password</title>
	</head>

	<body>
		<form method="POST" action="<?php echo $self;?>">
		<div align="center">


			<font face="Arial" color=red><b>Please enter password to login.</b></font>
			
			<table border="0" width="500" height="32">
			<tr>
				<td height="28" width="108">
				<font face="Bookman Old Style" color="#000000"><b>Password</b></font></td>
				<td height="28" width="316"><input type="password" name="secure" size="44"></td>
				<td height="28" width="56">
				<input type="submit" value="Submit" name="submit"></td>
			</tr>
		</table>
		<center><b></b></center>
		</div>
		</form>


</body>
</html>
<?php
	exit;
}
?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
	<head>
		<title>Control Pancel</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<META NAME="ROBOTS" CONTENT="NOINDEX,FOLLOW" />
		<META NAME="GOOGLEBOT" CONTENT="NOINDEX,FOLLOW" />
		<META NAME="SLURP" CONTENT="NOINDEX,FOLLOW" />
		<link rel="shortcut icon" href="./../images/manager.ico"/>
		<style>
			body {
				margin: 0;
			}
			A {
				COLOR: #0066cc; TEXT-DECORATION: none
			}
			A:visited {
				COLOR: #0066cc; TEXT-DECORATION: none
			}
			A:active {
				COLOR: #0066cc; TEXT-DECORATION: none
			}
			A:hover {
				COLOR: #ff6600; TEXT-DECORATION: blink
			}

			.redlink {
				FONT-WEIGHT: bold; COLOR: #dd1611; TEXT-DECORATION: none
			}
			.redlink:hover {
				FONT-WEIGHT: bold; COLOR: #5b0b0b; TEXT-DECORATION: none
			}
			.testimon1 {
				FONT-SIZE: 10px; COLOR: #af181f; FONT-STYLE: italic
			}
			.td1 {
				text-align:center;
			}
			.do {
				border: 1px solid #FF6633;
			}
			.xanh {
				border: 1px solid #33cc00;
			}
			.td11 {
				text-align:center;
				width: 80%;
			}
			.td12 {
				text-align:center;
			}
			.table1 { 
				width: 80%;
			}


		</style>
		<div style="overflow: auto; height: auto; width-min: 800px; margin-left: 100px;" align="left">

<?php
		echo '<BR>';
		$data = '';
		if($_GET['edit'] == 'group2') $file = './data/group2.php';
		elseif($_GET['edit'] == 'limit2') $file = './data/limit2.php';
		
		if($_GET['edit'] == 'group2') {
					if (file_exists ($file))  $data = file_get_contents($file);
					else $data = "<?php\r\n	\$group[] = 'vip1'; //bổ sung nhóm vip1\r\n	\$group[] = 'vip2'; //bổ sung nhóm vip2\r\n\r\n?>";
		}
		elseif($_GET['edit'] == 'limit2') {
					if (file_exists ($file))  $data = file_get_contents($file);
					else $data = "<?php
	\$limit2MBIP = 0;	# (đơn vị MB) băng thông mở rộng cho riêng một tài khoản(premium sẽ reset theo ngày)
#Note limit2: giá trị bandwidth để mở rộng băng thông nhóm host riêng cho riêng một tài khoản (đơn vị MB)
	\$this->hosts2 = array(


		'fshare1.vn'			=> array('bandwidth'	=> 10*1024),
		'4share2.vn'			=> array('bandwidth'	=> 10*1024),


	);
?>
";

		}
		else die("<SCRIPT language='Javascript'>document.location.href ='./';</SCRIPT>");
		if (isset($_POST['datagroup'])){

			$data = urldecode($_POST['datagroup']);
			#-----------------------------------------------
			$handle = fopen($file, "w+")
			or die('<CENTER><font color=red size=3>could not open file! Try to chmod the file "<B>'.$file.'</B>" to 666</font></CENTER>');
			fwrite($handle, $data)
			or die('<CENTER><font color=red size=3>could not write file! Try to chmod the file "<B>'.$file.'</B>" to 666</font></CENTER>');
			fclose($handle);
			@chmod($file, 0666);
			#-----------------------------------------------
			echo '<font color="red" size="+1">saved!</font>';
		}
		echo '
		<BR>
		<form method="POST" action="'.$self.'"><BR>
		<BR><textarea style="height: 500px; width: 1000px;" name="datagroup">'.$data.'</textarea><BR>
			<input type="submit" value="SAVE" name="save">
		</form>
		<BR>
		
		';
?>

 <!-- logout -->
	<BR><BR>
	<div align="right" id='logout'>
		<form method="POST" action="<?php echo $self;?>">
			<input type="submit" value="logout" name="logout">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
		</form>
	</div>
<!-- /logout -->
</body>
</html>