<?php
############################################################
# \-\-\-\-\-\-\     AzDG  - S C R I P T S    /-/-/-/-/-/-/ #
############################################################
# AzDGDatingMedium        Version 1.9.3                    #
# Written by              AzDG (support@azdg.com)          #
# Created 03/01/03        Last Modified 05/01/03           #
# Scripts Home:           http://www.azdg.com              #
############################################################
# File name               install.php                      #
# File purpose            Installation script              #
# File created by         AzDG <support@azdg.com>          #
############################################################
/*
Using Old HTTP_POST for detect variables
*/
if (isset($_POST)) {while(list($name,$value) = each($_POST)){$$name = $value;};};
if (isset($_GET)) {while(list($name,$value) = each($_GET)){$$name = $value;};};

/*
Detecting user language. Installation will continue with user
language or default language
*/
if(!isset($l)) $l = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
if(!file_exists('languages/'.$l.'/inst.php')) $l='default';
if(!file_exists('languages/'.$l.'/inst.php')) {echo "<h3>Install Error:<br>Please upload inst.php from AzDGDating package into languages/default/ directory</h1>";die;};
include_once 'languages/'.$l.'/inst.php';

/*
We like to work with short tags.
And we chaking that this parameter must be enable
*/
if(!(ini_get("short_open_tag"))) {echo $y[0];die;}

/*
Several variables for design and script name
*/
if(defined("C_SNAME")) define('C_SNAME_',C_SNAME);
else define('C_SNAME_','AzDGDatingMedium v 1.9.6');
define('COLOR1','#A0C0F0');
define('COLOR2','#73AED2');
define('COLOR3','#84B8D7');
define('COLOR4','#92C0DC');
define('COLORH','#73AED2');

$error='0';
if(!isset($step)) $step='1';

function check($var) {
	global $error,$y;
	if($var) {
		echo '<span class="ok">'.$y[1].'<span>';
	} else {
		echo '<span class="false">'.$y[2].'<span>';
		$error='1';
	}
}

if ($step != '1') include 'include/config.inc.php';

?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<html dir=<?=C_HTML_DIR?>>
<head>
<title><?=C_SNAME_?> <?=$y[3]?></title>
<meta http-equiv=Content-Type content="text/html; charset=<?=C_CHARSET?>">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<style>
<!--
a:link{text-decoration:none;font-size:11px;color:blue}
a:visited{text-decoration:none;font-size:11px;color:blue}
a:hover{text-decoration:none;font-size:11px;color:black}
body{font-family:"Verdana";font-size:12px;scrollbar-face-color: #73AED2;scrollbar-highlight-color:#BDD3F4;scrollbar-shadow-color: #73AED2;scrollbar-3dlight-color:#73AED2;scrollbar-arrow-color: #BDD3F4;scrollbar-track-color:#A0D8F8;scrollbar-darkshadow-color: black;}
.pass{font-family:"Verdana";font-size:12px;color: red;}
.mes{font-family:Verdana,tahoma;font-size:11px;color:black;font-weight:bold;test-align:justify;}
sup{font-family:Verdana,tahoma;font-size:12px;color:white;font-weight:normal;}
.desc{font-family:Verdana,tahoma;font-size:10px;color:black;font-weight:bold;}
.dat{font-family:Verdana,tahoma;font-size:12px;color:red;font-weight:bold;}
.ok{font-family:Verdana,tahoma;font-size:12px;color:lime;font-weight:bold;}
.false{font-family:Verdana,tahoma;font-size:12px;color:red;font-weight:bold;}
.head{font-family:Arial Black, Arial;font-size:20px;color:black;}
.error{font-family:Verdana,Helvetica;font-size:16px;color:red;font-weight:bold;}
.button{font-family:Verdana;font-weight:bold;font-size:11px;color:black;background:#A0C0F0;border: black 1px solid; width:140px;cursor:hand;}
.input,.textarea,.select{font-family:Verdana;font-size:12px;color:black;background:#C2FBFE;border: black;border-style: solid;border-top-width: 1px;border-right-width: 1px;border-bottom-width: 1px;border-left-width: 1px;width:250px}
.binput{font-family:Verdana;font-size:12px;color:black;background:#C2FBFE;border: black 1px solid;width:500px}
.sinput{font-family:Verdana;font-size:12px;color:black;background:#C2FBFE;border: black 1px solid;width:60px}
.msinput{font-family:Verdana;font-size:12px;color:black;background:#C2FBFE;border: black 1px solid;width:90px}
.minput{font-family:Verdana;font-size:12px;color:black;background:#A0D8F8;border: black 1px solid;width:120px}
-->
</style>

<script language="JavaScript">
<!--
function bc(b,bg){b.style.backgroundColor = bg;}
function open_win(win_file, win_title) {
	window.open(win_file, win_title, 'resizable=yes,width=400,height=300,toolbar=no,scrollbars=yes,location=no,menubar=no,status=no');
}
//-->
</script>
</head>
<body bgcolor="#C2FBFE">
<center><table width="80%"><tr><td>
<basefont size="4" color="navy" face="Verdana,Tahoma">
<center><span class=head><?=C_SNAME_?> <?=$y[3]?></span>
<hr color=navy size=2>
<?php 

function vars_write($file,$data,$real)
{
	$cnt = file($file);$fp = fopen($file,"w");flock($fp, LOCK_EX);
	for ($i=0;$i<count($cnt);$i++)
	{
		if (strpos($cnt[$i],"','"))
		{
			list($param,$value) = split("','",$cnt[$i]);
			if (trim($param) == "define('".$data) $cnt[$i] = "define('".$data."','".$real."');\n";
		}
	}
	fwrite($fp, implode("",$cnt));fflush($fp);flock($fp, LOCK_UN);
	fclose($fp);
}

function file_write($file,$data)
{
	$fp = fopen($file,"w");flock($fp, LOCK_EX);
	fwrite($fp, $data);fflush($fp);flock($fp, LOCK_UN);fclose($fp);
}



function error($er) {
?>
<br>
<center><Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td><Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes><Tr bgcolor="<?=COLOR3?>"><Td align=center class=error><?=$er?></td></tr></table></td></tr></table>
</center><br>
<?php
exit();
}
switch($step) {
	######################################
	#   S T E P - 1 [Checking for requirement values]
	######################################
	default:
		@include 'include/options.inc.php';
?>
<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=4>
:: <?=$y[13]?> 1 :: <?=$y[14]?>
</td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td>
<?=$y[15]?></td><td><?=$y[16]?></td><td><?=$y[17]?></td><td><?=$y[18]?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center><td>
<?=$y[19]?></td><td>v 4.1.0</td><td>v <?=phpversion();?></td><td><?php check(phpversion() >= '4.1.0');?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td>
<?=$y[20]?></td><td>v 3.22</td><td>v <?=mysql_get_client_info();?></td><td><?php check(mysql_get_client_info() >= '3.23');?></td></tr>
</table></td></tr></table>
<br>

<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=3>
<?=$y[21]?>
</td></tr>
<?php
umask(0);
if(file_exists("include/config.inc.php")) @chmod("include/config.inc.php",0666);
if(file_exists("members/uploads")) @chmod("members/uploads",0777);
for($x=0;$x<100;$x++)
{
	if(file_exists('members/uploads/0/'.$x)) @chmod('members/uploads/0/'.$x,0777);
}

if(file_exists("include/options.inc.php")) @chmod("include/options.inc.php",0666);
if(file_exists("include/vars.inc.php")) @chmod("include/vars.inc.php",0666);


?>
<Tr bgcolor="<?=COLOR4?>" align=center><td>members/uploads/</td><td><?=$y[22]?></td><td><?php check((file_exists("members/uploads") && @is_writable("members/uploads")));?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center><td>
include/config.inc.php</td><td><?=$y[22]?></td><td><?php check((file_exists("include/config.inc.php") && @is_writable("include/config.inc.php")));?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td>
include/options.inc.php</td><td><?=$y[22]?></td><td><?php check((file_exists("include/options.inc.php") && @is_writable("include/options.inc.php")));?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td>
include/vars.inc.php</td><td><?=$y[22]?></td><td><?php check((file_exists("include/vars.inc.php") && @is_writable("include/vars.inc.php")));?></td></tr>
</table></td></tr></table>
<br><br>
<?= ($error) ? '<span class=error>'.$y[9].'</span><br><br><input type="button" class=button id=but1 onmouseover=bc(this,"'.COLOR2.'") onmouseout=bc(this,"'.COLOR1.'") href="javascript:;" OnClick="location.reload()" value="'.$y[10].'">' : '<input type="button" class=button id=but1 onmouseover=bc(this,"'.COLOR2.'") onmouseout=bc(this,"'.COLOR1.'") href="javascript:;" OnClick="location.href=\'install.php?step=4&no_check=1\'" value="'.$y[72].'"> &nbsp; &nbsp; &nbsp; <input type="button" class=button id=but2 onmouseover=bc(this,"'.COLOR2.'") onmouseout=bc(this,"'.COLOR1.'") href="javascript:;" OnClick="location.href=\'install.php?step=2\'" value="'.$y[24].' 2">';?>

<? 
break;
######################################
#   S T E P - 2 [Creating configuration]
######################################

	case '2':

		$int_path = realpath(".");
		$int_path=str_replace("\\","/",$int_path);
		$ext_path='http://'.getenv('SERVER_NAME').dirname(getenv('REQUEST_URI'));
		$ext_path=str_replace("\\","/",$ext_path);

		// Default values:
		$c_url = $ext_path;
		$c_path = $int_path;
		$c_sname = (substr(C_SNAME,0,10) != 'AzDGDating') ? C_SNAME : C_SNAME_;
		$c_host = (C_HOST != 'localhost') ? C_HOST : 'localhost';
		$c_user = (C_USER != 'user') ? C_USER : '';
		$c_pass = ''; // :)
		$c_base = (C_BASE != 'database') ? C_BASE : '';
		$c_adminl = (C_ADMINL != '') ? C_ADMINL : '';
		$c_adminp = ''; // :)
		$c_adminm = (C_ADMINM != 'admin@yoursite.com') ? C_ADMINM : 'admin@yoursite.com';
		$c_adminlang = (C_ADMINLANG != 'default') ? C_ADMINLANG : 'default';
		$c_userlang = (defined("C_USERLANG") && C_USERLANG != 'default') ? C_USERLANG : 'default';
		$temp=explode("_",C_MYSQL_MEMBERS);
		$pref=$temp[0];

?>
<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=2>
:: <?=$y[13]?> 2 :: <?=$y[25]?>
</td></tr>
<script language="JavaScript">
<!--
function formCheck(form) {

	if (form.c_url.value == "")
	{alert("<?=$y[26]?>");return false;}
	//if (form.c_path.value == "")	{alert("<?=$y[27]?>");return false;}
	if (form.c_sname.value == "")
	{alert("<?=$y[28]?>");return false;}
	if (form.c_host.value == "")
	{alert("<?=$y[29]?>");return false;}
	if (form.c_user.value == "")
	{alert("<?=$y[30]?>");return false;}
	if (form.c_pass.value == "")
	{alert("<?=$y[31]?>");return false;}
	if (form.c_base.value == "")
	{alert("<?=$y[32]?>");return false;}

	if (form.c_adminl.value == "")
	{alert("<?=$y[33]?>");return false;}
	if (form.c_adminp.value == "")
	{alert("<?=$y[34]?>");return false;}
	if (form.c_adminm.value == "")
	{alert("<?=$y[35]?>");return false;}



	if (document.form.submit.action != "") {
		document.form.submit.disabled=1;}
}
// -->
</script>
<form method="Post" action="install.php?step=3" OnSubmit="return formCheck(this)" name="form">

<Tr bgcolor="<?=COLORH?>" align=center><Td colspan=2>
<?=$y[36]?>
</td></tr>
<Tr bgcolor="<?=COLOR4?>"><td>
<?=$y[37]?></td><td><input type="text" name="c_url" value="<?=$c_url?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR4?>"><Td colspan=2>
<sup><?=$y[38]?></sup>
</td></tr>
<Tr bgcolor="<?=COLOR1?>"><td>
<?=$y[39]?></td><td><input type="text" name="c_path" value="<?=$c_path?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR1?>"><Td colspan=2>
<sup><?=$y[40]?></sup>
</td></tr>
<Tr bgcolor="<?=COLOR4?>"><td>
<?=$y[41]?></td><td><input type="text" name="c_sname" value="<?=$c_sname?>" class=input></td></tr>
</table></td></tr></table>
<br>

<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLORH?>" align=center><Td colspan=2>
<?=$y[42]?>
</td></tr>
<Tr bgcolor="<?=COLOR4?>"><td>
<?=$y[43]?></td><td><input type="text" name="c_host" value="<?=$c_host?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR4?>"><Td colspan=2>
<sup><?=$y[44]?>:localhost</sup>
</td></tr>
<Tr bgcolor="<?=COLOR1?>"><td>
<?=$y[45]?></td><td><input type="text" name="c_base" value="<?=$c_base?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR1?>"><Td colspan=2>
<sup><?=$y[46]?></sup>
</td></tr>
<Tr bgcolor="<?=COLOR4?>"><td>
<?=$y[47]?></td><td><input type="text" name="c_user" value="<?=$c_user?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR1?>"><td>
<?=$y[48]?></td><td><input type="password" name="c_pass" value="<?=$c_pass?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR1?>"><td>
<?=$y[49]?></td><td><input type="text" name="c_pref" value="<?=$pref?>" class=input></td></tr>
</table></td></tr></table>
<br>

<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLORH?>" align=center><Td colspan=2>
<?=$y[50]?>
</td></tr>
<Tr bgcolor="<?=COLOR4?>"><td>
<?=$y[51]?></td><td><input type="text" name="c_adminl" value="<?=$c_adminl?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR1?>"><td>
<?=$y[52]?></td><td><input type="password" name="c_adminp" value="<?=$c_adminp?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR4?>"><td>
<?=$y[53]?></td><td><input type="text" name="c_adminm" value="<?=$c_adminm?>" class=input></td></tr>
<Tr bgcolor="<?=COLOR1?>"><td><?=$y[54]?></td><td><?php
$handle=opendir('languages/');
$fnm = 0;while (false!==($file = readdir($handle))) {	if ($file != "." && $file != "..") {$langfile[$fnm] = $file;
$fnm++;	}}closedir($handle);
if ($fnm == 0) echo $y[6];elseif ($fnm > 0) {?>
<select name="c_adminlang" class="input"><?
for ($i = 0; $i < $fnm; $i++) {
	if(isset($langfile[$i]) && ($langfile[$i] == $c_adminlang)) echo '<option value="'.$langfile[$i].'" selected>'.$langfile[$i];
	else echo '<option value="'.$langfile[$i].'">'.$langfile[$i];}}?></select></td></tr>
	<Tr bgcolor="<?=COLOR1?>"><Td colspan=2><sup><?=$y[55]?></sup></td></tr>
<Tr bgcolor="<?=COLOR1?>"><td><?=$y[73]?></td><td><?php
$handle=opendir('languages/');
if ($fnm == 0) echo $y[6];elseif ($fnm > 0) {?>
<select name="c_userlang" class="input"><?
for ($i = 0; $i < $fnm; $i++) {
	if(isset($langfile[$i]) && ($langfile[$i] == $c_userlang)) echo '<option value="'.$langfile[$i].'" selected>'.$langfile[$i];
	else echo '<option value="'.$langfile[$i].'">'.$langfile[$i];}}?></select></td></tr>	
<Tr bgcolor="<?=COLOR1?>"><Td colspan=2><sup><?=$y[74]?></sup></td></tr>
<Tr bgcolor="<?=COLOR4?>"><td>
Installation Type</td><td>
<select name="insttype" class=input>  
   <option value=0>Upgrade from Lite version
   <option value=2>Upgrade from Medium 1.8.x
   <option selected value=1>New Installation
</select></td></tr>
</table></td></tr></table>
<br>
<?php echo '<input type="submit" class=button id=but2 onmouseover=bc(this,"'.COLOR2.'") onmouseout=bc(this,"'.COLOR1.'") href="javascript:;" value="'.$y[24].' 3" name="submit">';?>
</form>
<? 
break;

######################################
#   S T E P - 3 [Checking for Step 2]
######################################

	case '3':
		function check_last_slash($file) {
			if (ereg("./$", $file)) return false;
			else return true;
		}

		function cb($ss) {
			//$ss = htmlspecialchars(stripslashes($ss));
			//$ss = str_replace("\r\n"," <br>","$ss");
			//$ss = str_replace("\\","","$ss");
			$ss = str_replace("'","&rsquo;","$ss");
			$ss = str_replace('"',"&quot;","$ss");
			$ss = trim($ss);
			return $ss;
		}



		if (!((isset($no_check)) && ($no_check == '1'))) {

			if(!check_last_slash($c_url)) error($y[56]);
			if(!check_last_slash($c_path)) error($y[57]);
			if(!file_exists($c_path.'/install.php')) error($y[58]);
			$c_url=cb($c_url);
			$c_path=cb($c_path);
			$c_sname=cb($c_sname);
			$c_host=cb($c_host);
			$insttype=cb($insttype);
			$c_base=cb($c_base);
			$c_pass=cb($c_pass);
			$c_user=cb($c_user);
			$c_pref=cb($c_pref);
			$c_adminl=cb($c_adminl);
			$c_adminp=cb($c_adminp);
			$c_adminm=cb($c_adminm);
			$c_userlang=cb($c_userlang);
			$c_adminlang=cb($c_adminlang);

			if(!is_numeric($insttype)) $insttype=0;



			$str="<?php\n";
			$str.="############################################################\n";
			$str.="# \-\-\-\-\-\-\     AzDG  - S C R I P T S    /-/-/-/-/-/-/ #\n";
			$str.="############################################################\n";
			$str.="# AzDGDatingMedium        Version 1.9.6                    #\n";
			$str.="# Written by              AzDG (support@azdg.com)          #\n";
			$str.="# Created 03/01/03        Last Modified 21/05/10           #\n";
			$str.="# Scripts Home:           http://www.azdg.com              #\n";
			$str.="############################################################\n";
			$str.="# File name               config.inc.php                   #\n";
			$str.="# File purpose            Main configuration file          #\n";
			$str.="# File created by         AzDG <support@azdg.com>          #\n";
			$str.="############################################################\n";
			$str.='$m1 = explode(" ", microtime());$stime = $m1[1] + $m1[0];';
			$str.="\n";
			$str.="\n";
			$str.="### Url were AzDGDatingMedium has been installed, not '/' in end!\n";
			$str.="define('C_URL','".$c_url."');\n";
			$str.="\n";
			$str.="### Internal path to AzDGDatingMedium directory\n";
			$str.="define('C_PATH','".$c_path."');\n";
			$str.="\n";
			$str.="### Site Name\n";
			$str.="define('C_SNAME','".$c_sname."');\n";
			$str.="\n";
			$str.="### Authorization type\n";
			$str.="define('C_AUTH','1'); // Work on sessions '1' or cookie '0'\n";
			$str.="if(C_AUTH){session_start();unset(\$s,\$m,\$g,\$o);}\n";
			$str.="\n";
			$str.="### Admin Data\n";
			$str.="define('C_ADMINL','".$c_adminl."');// Admin login\n";
			$str.="define('C_ADMINP','".$c_adminp."');// Admin password\n";
			$str.="define('C_ADMINM','".$c_adminm."');//Admin email\n";
			$str.="define('C_ADMINLANG','".$c_adminlang."');//Admin language (By lang dir example: en)\n";
			$str.="define('C_USERLANG','".$c_userlang."');//User language\n";
			$str.="\n";
			$str.="### MySQL data\n";
			$str.="define('C_HOST','".$c_host."');// MySQL host name (usually:localhost)\n";
			$str.="define('C_USER','".$c_user."');// MySQL username\n";
			$str.="define('C_PASS','".$c_pass."');// MySQL password\n";
			$str.="define('C_BASE','".$c_base."');// MySQL database\n";
			$str.="\n";
			$str .= (defined("C_MYSQL_MEMBERS") && ($insttype != 1)) ? "define('C_MYSQL_MEMBERS','".C_MYSQL_MEMBERS."');// Table for members info\n" : "define('C_MYSQL_MEMBERS','".$c_pref."_membersu');// Table for members info\n";
			$str .= (defined("C_MYSQL_MEMBERS_MAIN") && ($insttype != 1)) ? "define('C_MYSQL_MEMBERS_MAIN','".C_MYSQL_MEMBERS_MAIN."');// Table for main members info\n" : "define('C_MYSQL_MEMBERS_MAIN','".$c_pref."_membersu_main');// Table for main members info\n";
			$str .= (defined("C_MYSQL_MEMBERS_EXT") && ($insttype != 1)) ? "define('C_MYSQL_MEMBERS_EXT','".C_MYSQL_MEMBERS_EXT."');// Table for extended members info\n" : "define('C_MYSQL_MEMBERS_EXT','".$c_pref."_membersu_ext');// Table for extended members info\n";
			$str .= (defined("C_MYSQL_MEMBERS_SEC") && ($insttype != 1)) ? "define('C_MYSQL_MEMBERS_SEC','".C_MYSQL_MEMBERS_SEC."');// Table for security members info\n" : "define('C_MYSQL_MEMBERS_SEC','".$c_pref."_membersu_sec');// Table for security members info\n";
			$str .= (defined("C_MYSQL_MEMBERS_RESTRICTS") && ($insttype != 1)) ? "define('C_MYSQL_MEMBERS_RESTRICTS','".C_MYSQL_MEMBERS_RESTRICTS."');// Table for restricts\n" : "define('C_MYSQL_MEMBERS_RESTRICTS','".$c_pref."_membersu_restricts');// Table for restricts\n";
			$str .= (defined("C_MYSQL_ONLINE_USERS") && ($insttype != 1)) ? "define('C_MYSQL_ONLINE_USERS','".C_MYSQL_ONLINE_USERS."');// Table for online users info\n" : "define('C_MYSQL_ONLINE_USERS','".$c_pref."_onlineu');// Table for online users info\n";
			$str .= (defined("C_MYSQL_TEMP") && ($insttype != 1)) ? "define('C_MYSQL_TEMP','".C_MYSQL_TEMP."');// Table for temporary info\n" : "define('C_MYSQL_TEMP','".$c_pref."_temp');// Table for temporary info\n";
			$str .= (defined("C_MYSQL_PMEMBERS") && ($insttype != 1)) ? "define('C_MYSQL_PMEMBERS','".C_MYSQL_PMEMBERS."');// Table for privilegied members info\n" : "define('C_MYSQL_PMEMBERS','".$c_pref."_pmembersu');// Table for privilegied members info\n";
			$str .= (defined("C_MYSQL_MESSAGES") && ($insttype != 1)) ? "define('C_MYSQL_MESSAGES','".C_MYSQL_MESSAGES."');// Table for messages\n" : "define('C_MYSQL_MESSAGES','".$c_pref."_messages');// Table for messages\n";
			$str .= (defined("C_MYSQL_MESSAGES_ARCHIVE") && ($insttype != 1)) ? "define('C_MYSQL_MESSAGES_ARCHIVE','".C_MYSQL_MESSAGES_ARCHIVE."');// Table for messages archive\n" : "define('C_MYSQL_MESSAGES_ARCHIVE','".$c_pref."_messages_archive');// Table for messages archive\n";
			$str .= (defined("C_MYSQL_CARDS") && ($insttype != 1)) ? "define('C_MYSQL_CARDS','".C_MYSQL_CARDS."');// Table for cards\n" : "define('C_MYSQL_CARDS','".$c_pref."_cards');// Table for cards\n";
			$str .= (defined("C_MYSQL_HITS") && ($insttype != 1)) ? "define('C_MYSQL_HITS','".C_MYSQL_HITS."');// Table for hits\n" : "define('C_MYSQL_HITS','".$c_pref."_hits');// Table for hits\n";
			$str .= (defined("C_MYSQL_FAQCAT") && ($insttype != 1)) ? "define('C_MYSQL_FAQCAT','".C_MYSQL_FAQCAT."');// Table for faq categories\n" : "define('C_MYSQL_FAQCAT','".$c_pref."_faq_cat');// Table for faq categories\n";
			$str .= (defined("C_MYSQL_FAQ") && ($insttype != 1)) ? "define('C_MYSQL_FAQ','".C_MYSQL_FAQ."');// Table for faq\n" : "define('C_MYSQL_FAQ','".$c_pref."_faq');// Table for faq\n";
			$str .= (defined("C_MYSQL_FORUMCAT") && ($insttype != 1)) ? "define('C_MYSQL_FORUMCAT','".C_MYSQL_FORUMCAT."');// Table for forum categories\n" : "define('C_MYSQL_FORUMCAT','".$c_pref."_forum_cat');// Table for forum categories\n";
			$str .= (defined("C_MYSQL_FORUM") && ($insttype != 1)) ? "define('C_MYSQL_FORUM','".C_MYSQL_FORUM."');// Table for forum\n" : "define('C_MYSQL_FORUM','".$c_pref."_forum');// Table for forum\n";
			$str .= (defined("C_MYSQL_FORUM_MESSAGES") && ($insttype != 1)) ? "define('C_MYSQL_FORUM_MESSAGES','".C_MYSQL_FORUM_MESSAGES."');// Table for forum messages\n" : "define('C_MYSQL_FORUM_MESSAGES','".$c_pref."_forum_messages');// Table for forum messages\n";
			$str .= (defined("C_MYSQL_FORUM_THREADS") && ($insttype != 1)) ? "define('C_MYSQL_FORUM_THREADS','".C_MYSQL_FORUM_THREADS."');// Table for forum threads\n" : "define('C_MYSQL_FORUM_THREADS','".$c_pref."_forum_threads');// Table for forum threads\n";
			$str .= (defined("C_MYSQL_BAD_PROFILES") && ($insttype != 1)) ? "define('C_MYSQL_BAD_PROFILES','".C_MYSQL_BAD_PROFILES."');// Table for bad profiles\n" : "define('C_MYSQL_BAD_PROFILES','".$c_pref."_bad');// Table for bad profiles\n";
			$str .= (defined("C_MYSQL_BEDROOM") && ($insttype != 1)) ? "define('C_MYSQL_BEDROOM','".C_MYSQL_BEDROOM."');// Table for bedroom\n" : "define('C_MYSQL_BEDROOM','".$c_pref."_room');// Table for bedroom\n";
			$str .= (defined("C_MYSQL_MAILLIST") && ($insttype != 1)) ? "define('C_MYSQL_MAILLIST','".C_MYSQL_MAILLIST."');// Table for maillist\n" : "define('C_MYSQL_MAILLIST','".$c_pref."_mail');// Table for maillist\n";
			$str .= (defined("C_MYSQL_RECOMMEND") && ($insttype != 1)) ? "define('C_MYSQL_RECOMMEND','".C_MYSQL_RECOMMEND."');// Table for recommend statistic\n" : "define('C_MYSQL_RECOMMEND','".$c_pref."_recommend');// Table for recommend statistic\n";
			$str .= (defined("C_MYSQL_AFFILIATES") && ($insttype != 1)) ? "define('C_MYSQL_AFFILIATES','".C_MYSQL_AFFILIATES."');// Table for affiliates\n" : "define('C_MYSQL_AFFILIATES','".$c_pref."_affiliates');// Table for affiliates\n";
			$str .= (defined("C_MYSQL_BANLIST") && ($insttype != 1)) ? "define('C_MYSQL_BANLIST','".C_MYSQL_BANLIST."');// Table for banlist\n" : "define('C_MYSQL_BANLIST','".$c_pref."_banlist');// Table for banlist\n";
			$str .= (defined("C_MYSQL_NEWS") && ($insttype != 1)) ? "define('C_MYSQL_NEWS','".C_MYSQL_NEWS."');// Table for news\n" : "define('C_MYSQL_NEWS','".$c_pref."_news');// Table for news\n";
			$str .= (defined("C_MYSQL_LINKSCAT") && ($insttype != 1)) ? "define('C_MYSQL_LINKSCAT','".C_MYSQL_LINKSCAT."');// Table for LINKS categories\n" : "define('C_MYSQL_LINKSCAT','".$c_pref."_links_cat');// Table for links categories\n";
			$str .= (defined("C_MYSQL_LINKS") && ($insttype != 1)) ? "define('C_MYSQL_LINKS','".C_MYSQL_LINKS."');// Table for links\n" : "define('C_MYSQL_LINKS','".$c_pref."_links');// Table for links\n";
			$str .= (defined("C_MYSQL_OPTIONS") && ($insttype != 1)) ? "define('C_MYSQL_OPTIONS','".C_MYSQL_OPTIONS."');// Table for member options\n" : "define('C_MYSQL_OPTIONS','".$c_pref."_options');// Table for options\n";
			$str .= (defined("C_MYSQL_SUBSCRIBE") && ($insttype != 1)) ? "define('C_MYSQL_SUBSCRIBE','".C_MYSQL_SUBSCRIBE."');// Table for subscribe\n" : "define('C_MYSQL_SUBSCRIBE','".$c_pref."_subscribe');// Table for profile views info\n";
			$str .= (defined("C_MYSQL_PROFILEVIEW") && ($insttype != 1)) ? "define('C_MYSQL_PROFILEVIEW','".C_MYSQL_PROFILEVIEW."');// Table for profile views info\n" : "define('C_MYSQL_PROFILEVIEW','".$c_pref."_profileview');// Table for profile views info\n";
			$str .= (defined("C_MYSQL_VOTES") && ($insttype != 1)) ? "define('C_MYSQL_VOTES','".C_MYSQL_VOTES."');// Table for votes\n" : "define('C_MYSQL_VOTES','".$c_pref."_votes');// Table for votes\n";
			$str .= (defined("C_MYSQL_VOTE_IPS") && ($insttype != 1)) ? "define('C_MYSQL_VOTE_IPS','".C_MYSQL_VOTE_IPS."');// Table for vote IPs\n" : "define('C_MYSQL_VOTE_IPS','".$c_pref."_vote_ips');// Table for vote IPs\n";
			$str .= (defined("C_MYSQL_VOTE_QUESTIONS") && ($insttype != 1)) ? "define('C_MYSQL_VOTE_QUESTIONS','".C_MYSQL_VOTE_QUESTIONS."');// Table for Vote questions\n" : "define('C_MYSQL_VOTE_QUESTIONS','".$c_pref."_vote_questions');// Table for Vote questions\n";
			$str .= (defined("C_MYSQL_BLACKLIST") && ($insttype != 1)) ? "define('C_MYSQL_BLACKLIST','".C_MYSQL_BLACKLIST."');// Table for blacklist\n" : "define('C_MYSQL_BLACKLIST','".$c_pref."_blacklist');// Table for blacklist\n";
			$str .= (defined("C_MYSQL_COMMENTS") && ($insttype != 1)) ? "define('C_MYSQL_COMMENTS','".C_MYSQL_COMMENTS."');// Table for comments\n" : "define('C_MYSQL_COMMENTS','".$c_pref."_comments');// Table for comments\n";
			$str .= (defined("C_MYSQL_NEW_PHOTOS") && ($insttype != 1)) ? "define('C_MYSQL_NEW_PHOTOS','".C_MYSQL_NEW_PHOTOS."');// Table for new photos\n" : "define('C_MYSQL_NEW_PHOTOS','".$c_pref."_new_photos');// Table for new photos\n";
			$str .= (defined("C_MYSQL_SEARCH") && ($insttype != 1)) ? "define('C_MYSQL_SEARCH','".C_MYSQL_SEARCH."');// Table for search\n" : "define('C_MYSQL_SEARCH','".$c_pref."_search');// Table for search\n";
			$str .= (defined("C_MYSQL_COUPONS") && ($insttype != 1)) ? "define('C_MYSQL_COUPONS','".C_MYSQL_COUPONS."');// Table for coupons\n" : "define('C_MYSQL_COUPONS','".$c_pref."_coupons');// Table for coupons\n";
			$str .= (defined("C_MYSQL_ADDRESSBOOK") && ($insttype != 1)) ? "define('C_MYSQL_ADDRESSBOOK','".C_MYSQL_ADDRESSBOOK."');// Address book\n" : "define('C_MYSQL_ADDRESSBOOK','".$c_pref."_addressbook');// Address book\n";
			$str .= (defined("C_MYSQL_MEMBERS_FORUM") && ($insttype != 1)) ? "define('C_MYSQL_MEMBERS_FORUM','".C_MYSQL_MEMBERS_FORUM."');// Members forum info\n" : "define('C_MYSQL_MEMBERS_FORUM','".$c_pref."_membersu_forum');// Members forum info\n";
			$str .= (defined("C_MYSQL_FORUM_SEARCH") && ($insttype != 1)) ? "define('C_MYSQL_FORUM_SEARCH','".C_MYSQL_FORUM_SEARCH."');// Forum search\n" : "define('C_MYSQL_FORUM_SEARCH','".$c_pref."_forum_search');// Forum search\n";
			$str .= (defined("C_MYSQL_TESTIMONIALS") && ($insttype != 1)) ? "define('C_MYSQL_TESTIMONIALS','".C_MYSQL_TESTIMONIALS."');// Testimonials\n" : "define('C_MYSQL_TESTIMONIALS','".$c_pref."_testimonials');// Testimonials\n";
			$str .= (defined("C_MYSQL_ARTCAT") && ($insttype != 1)) ? "define('C_MYSQL_ARTCAT','".C_MYSQL_ARTCAT."');// Table for articles categories\n" : "define('C_MYSQL_ARTCAT','".$c_pref."_art_cat');// Table for articles categories\n";
			$str .= (defined("C_MYSQL_ART") && ($insttype != 1)) ? "define('C_MYSQL_ART','".C_MYSQL_ART."');// Table for articles\n" : "define('C_MYSQL_ART','".$c_pref."_art');// Table for articles\n";
			$str .= (defined("C_MYSQL_BLOGS") && ($insttype != 1)) ? "define('C_MYSQL_BLOGS','".C_MYSQL_BLOGS."');// Table for blogs\n" : "define('C_MYSQL_BLOGS','".$c_pref."_blogs');// Table for blogs\n";
			$str .= (defined("C_MYSQL_PRIVATE_PHOTOS") && ($insttype != 1)) ? "define('C_MYSQL_PRIVATE_PHOTOS','".C_MYSQL_PRIVATE_PHOTOS."');// Table for private photos\n" : "define('C_MYSQL_PRIVATE_PHOTOS','".$c_pref."_private_photos');// Table for private photos\n";
			$str .= (defined("C_MYSQL_ZIP_DATA") && ($insttype != 1)) ? "define('C_MYSQL_ZIP_DATA','".C_MYSQL_ZIP_DATA."');// Table for zip data\n" : "define('C_MYSQL_ZIP_DATA','".$c_pref."_zip_data');// Table for zip data\n";
			$str .= (defined("C_MYSQL_NOTES") && ($insttype != 1)) ? "define('C_MYSQL_NOTES','".C_MYSQL_NOTES."');// Table for notes\n" : "define('C_MYSQL_NOTES','".$c_pref."_notes');// Table for notes\n";
			$str .= (defined("C_MYSQL_IP2COUNTRY") && ($insttype != 1)) ? "define('C_MYSQL_IP2COUNTRY','".C_MYSQL_IP2COUNTRY."');// Table for ip2country\n" : "define('C_MYSQL_IP2COUNTRY','".$c_pref."_ip2country');// Table for ip2country\n";
			$str .= (defined("C_MYSQL_HOTORNOT") && ($insttype != 1)) ? "define('C_MYSQL_HOTORNOT','".C_MYSQL_HOTORNOT."');// Table for hot_or_not\n" : "define('C_MYSQL_HOTORNOT','".$c_pref."_hotornot');// Table for hot_or_not\n";
			$str .= (defined("C_MYSQL_BLOGS_CAT") && ($insttype != 1)) ? "define('C_MYSQL_BLOGS_CAT','".C_MYSQL_BLOGS_CAT."');// Table for blogs categories\n" : "define('C_MYSQL_BLOGS_CAT','".$c_pref."_blogs_cat');// Table for blogs categories\n";
			$str .= (defined("C_MYSQL_BLOGS_COM") && ($insttype != 1)) ? "define('C_MYSQL_BLOGS_COM','".C_MYSQL_BLOGS_COM."');// Table for blogs comments\n" : "define('C_MYSQL_BLOGS_COM','".$c_pref."_blogs_com');// Table for blogs comments\n";
			$str .= (defined("C_MYSQL_BLOGS_VOTE") && ($insttype != 1)) ? "define('C_MYSQL_BLOGS_VOTE','".C_MYSQL_BLOGS_VOTE."');// Table for blogs rate\n" : "define('C_MYSQL_BLOGS_VOTE','".$c_pref."_blogs_vote');// Table for blogs rate\n";
			$str .= (defined("C_MYSQL_ALLHITS") && ($insttype != 1)) ? "define('C_MYSQL_ALLHITS','".C_MYSQL_ALLHITS."');// Table for all hits\n" : "define('C_MYSQL_ALLHITS','".$c_pref."_allhits');// Table for all hits\n";
			$str .= (defined("C_MYSQL_ADDRESSBOOK_ARCHIVE") && ($insttype != 1)) ? "define('C_MYSQL_ADDRESSBOOK_ARCHIVE','".C_MYSQL_ADDRESSBOOK_ARCHIVE."');// Address book archive\n" : "define('C_MYSQL_ADDRESSBOOK_ARCHIVE','".$c_pref."_addressbook_archive');// Address book archive\n";
			$str.="?>";

			file_write("include/config.inc.php",$str);
			if(ini_get('safe_mode')) vars_write("include/options.inc.php","C_IMG_ERR","1");
			if(file_exists("chat/inc_common.php")) vars_write("chat/inc_common.php","AZDG_ROOT",$c_path);
			vars_write("include/options.inc.php","C_MAINTENANCE_MODE","1");

			function SearchInFile($file,$str)
			{
				$bool = False;
				$cnt = file($file);$fp = fopen($file,"r");@flock($fp, LOCK_EX);
				for ($i=0;$i<count($cnt);$i++)
				{
					if (strstr ($cnt[$i],$str))
					{
						$bool = True;
						break;
					}
				}
				@flock($fp, LOCK_UN);
				fclose($fp);
				Return $bool;
			}

			function InsertInFile($file,$find,$str,$times)
			{
				$cnt = file($file);$fp = fopen($file,"w");flock($fp, LOCK_EX);
				for ($i=0;$i<count($cnt);$i++)
				{
					if (strstr($cnt[$i],$find) && $times)
					{
						$tmp = $cnt[$i];
						$cnt[$i] = $str.$tmp;
						if($times) $times--;
					}
				}
				fwrite($fp, implode("",$cnt));fflush($fp);flock($fp, LOCK_UN);
				fclose($fp);
			}

			if($insttype == '2')
			{

				# Version 1.9.x
				$str='';
				if(!SearchInFile('include/options.inc.php',"############## New constants in version 1.9.x")) {
					$str.=" \n";
					$str.="############## New constants in version 1.9.x ############## \n";
					$str.="define('C_CONTACT_SAME_GENDER','0'); \n";
					$str.="define('C_OWN_COPYRIGHTS','Powered by <a href=\"http://www.azdg.com\" target=\"_blank\" class=\"desc\">AzDG</a>'); \n";
					$str.="define('C_UPDPROF_PER','0'); \n";
					$str.="define('C_ONLINE_COUNTRY','-1'); \n";
					$str.="define('C_ONLINE_CITY','-1'); \n";
					$str.="define('C_ONLINE_AGE','-1'); \n";
					$str.="define('C_ONLINE_USERS_NUM','10'); \n";
					$str.="define('C_LOGOUT','1'); \n";
					$str.="define('C_LOGIN_SECURE','1'); \n";
					$str.="define('C_CHECK_ALL','1'); \n";
					$str.="define('C_LASTREG_BG','1'); \n";
					$str.="define('C_LOGIN_URL',''); \n";
					$str.="define('C_DATE2PHRASE','1'); \n";
					$str.="define('C_FORUM_STARS','20,50,100,250,500,1000'); \n";
					$str.="define('C_FORUM_STARN','0'); \n";
					$str.="define('C_PH_REQ_GEN','0'); \n";
					$str.="define('C_HIDE_VIEWPROF','1'); \n";
					$str.="define('C_HIDE_WHOSEEN','1'); \n";
					$str.="define('C_MY_TEMP','1'); \n";
					$str.="define('C_OPT_NOMAIL','0'); \n";
					$str.="define('C_FORUM_USERSHERE','0'); \n";
					$str.="define('C_FORUM_STATS','0'); \n";
					$str.="define('C_FORUMC_TITLE','{FORUM} > {FORUM_TITLE} - {SNAME}'); \n";
					$str.="define('C_FORUMT_TITLE','{THREAD_TITLE}'); \n";
					$str.="define('C_FORUMT_DESC','{DESCRIPTION}'); \n";
					$str.="define('C_FORUMT_DESCS','500'); \n";
					$str.="define('C_AJAX_MSGINF','0'); \n";
					$str.="define('C_MSGINF_SEC','60'); \n";
					$str.="define('C_NOTES','0'); \n";
					$str.="define('C_NOTESPAGES','10'); \n";
					$str.="define('LAST_ID','0'); \n";
					$str.="define('LAST_DATE','0928'); \n";
					$str.="define('C_NOT_PRIV','0'); \n";
					$str.="define('C_NOT_PRIV_G','0'); \n";
					$str.="define('C_NOT_PRIV_A','1'); \n";
					$str.="define('C_VERIFY_ALG','1'); \n";
					$str.="define('C_VERIMG_SM','0'); \n";
					$str.="define('C_VERIMG_FORUM','1'); \n";
					$str.="define('C_VERIMG_COMMENT','0'); \n";
					$str.="define('C_VERIMG_FDBK','0'); \n";
					$str.="define('C_VERIMG_BCOM','0'); \n";
					$str.="define('C_THUMB_SIDE','10'); \n";
					$str.="define('C_GD2_QUAL','1'); \n";
					$str.="define('C_PP_ACS','1'); \n";
					$str.="define('C_PAYMENT_WM_ID','0000000000000'); \n";
					$str.="define('C_PAYMENT_WM_PURSE','Z3333333333333'); \n";
					$str.="define('C_PAYMENT_WM_MODE','0'); \n";
					$str.="define('C_PAYMENT_WM','0'); \n";
					$str.="define('C_PAYMENT_SECRET','secret_word'); \n";
					$str.="define('C_PP_PROC_ALLOW','0'); \n";
					$str.="define('C_PP_PROC','40,20,20,20'); \n";
					$str.="define('C_VP_STAT','1'); \n";
					$str.="define('C_SEF','0'); \n";
					$str.="define('C_SEF_ENCODE','1'); \n";
					$str.="define('C_SEF_VP','users/{LANGUAGE}/{ID}.htm'); \n";
					$str.="define('C_SEF_ST','stat/{LANGUAGE}'); \n";
					$str.="define('C_SEF_LAST','lastest/{LANGUAGE}/{FROM}/{GENDER}'); \n";
					$str.="define('C_SEF_TOP','best/{LANGUAGE}/{FROM}/{GENDER}/{PIC}'); \n";
					$str.="define('C_SEF_HOTTOP','hotornot/{LANGUAGE}/{FROM}/{GENDER}'); \n";
					$str.="define('C_SEF_BLOGS','usersblogs/{LANGUAGE}/{FROM}/{CAT}'); \n";
					$str.="define('C_SEF_BLOG','myblog/{LANGUAGE}/{ID}'); \n";
					$str.="define('C_SEF_LINKS','site/{LANGUAGE}/{ID}/{TITLE}'); \n";
					$str.="define('C_SEF_LINKS_CAT','sites/{LANGUAGE}/{FROM}/{ID}/{TITLE}'); \n";
					$str.="define('C_SEF_LINKS_CATN','20'); \n";
					$str.="define('C_SEF_FORUM_INDEX','forum/{LANGUAGE}'); \n";
					$str.="define('C_SEF_FORUM_FORUM','forum/{LANGUAGE}/{FORUM}/{TITLE}'); \n";
					$str.="define('C_SEF_FORUM_THREAD','forum_thread/{LANGUAGE}/{PARAM}/{THREAD}/{TITLE}'); \n";
					$str.="define('C_MYSQL_CHARSET',''); \n";
					$str.="define('C_AUTOSUBS','0'); \n";
					$str.="define('C_AUTOSUBS_GENDER','1'); \n";
					$str.="define('C_AUTOSUBS_PHOTO','1'); \n";
					$str.="define('C_AUTOSUBS_REM','0'); \n";
					$str.="define('C_NO_KISS','0'); \n";
					$str.="define('C_SUPER_KISS','256'); \n";
					$str.="define('C_LINK_WHO','-1'); \n";
					$str.="define('C_LINK_DESCR_LIMIT','500'); \n";
					$str.="define('C_VERIMG_LINKS','1'); \n";
					$str.="define('C_REC_LINK','1'); \n";
					$str.="define('C_REC_SHOW','1'); \n";
					$str.="define('C_REC_VAL','<a href=\"{C_URL}\">{C_SNAME}</a>'); \n";
					$str.="define('C_REC_EXACT','1'); \n";
					$str.="define('C_LINK_ADD','3'); \n";
					$str.="define('C_VPRATE','3'); \n";
					$str.="define('C_PRATE','0'); \n";
					$str.="define('C_PRATE_ACL','0'); \n";
					$str.="define('C_PRATE_LINK','0'); \n";
					$str.="define('C_PRATE_KEY','Key'); \n";
					$str.="define('C_HON_LIMIT','3'); \n";
					$str.="define('C_HON_NUM','3'); \n";
					$str.="define('C_HON_MORE','0'); \n";
					$str.="define('C_STATES_FULL','0'); \n";
					$str.="define('C_BLOG_TEXTSIZE','500'); \n";
					$str.="define('C_BLOG_LASTDAYS','0'); \n";
					$str.="define('C_BLOG_HOWADD','1'); \n";
					$str.="define('C_BLOG_CATREQ','0'); \n";
					$str.="define('C_BLOG_VOTEMIN','3'); \n";
					$str.="define('C_BLOG_COMMENTS','0'); \n";
					$str.="define('C_BLOG_COMMENTS_SEE','-1'); \n";
					$str.="define('C_BLOG_IGNOR','1'); \n";
					$str.="define('C_BLOG_CONTACT','0'); \n";
					$str.="define('C_BLOG_BADWORDS','1'); \n";
					$str.="define('C_BLOG_BADWORDSW','*@*,fuck*,bitch'); \n";
					$str.="define('C_BLOG_BADWORDS_ERR','1'); \n";
					$str.="define('C_BLOG_BADWORDS_COM','1'); \n";
					$str.="define('C_BLOG_BADWORDS_COMW','*@*,fuck*,bitch'); \n";
					$str.="define('C_BLOG_BADWORDS_COM_ERR','1'); \n";
					$str.="define('C_BLOG_RATE','0'); \n";
					$str.="define('C_BLOG_TITLE','{BLOG_TITLE}'); \n";
					$str.="define('C_BLOG_DESC','{DESCRIPTION}'); \n";
					$str.="define('C_BLOG_DESCS','500'); \n";
					$str.="define('C_COMMENT_STEP','10'); \n";
					$str.="define('C_REPLY_BCOMMENTS','0'); \n";
					$str.="define('C_BB_IMG_WIDTHMAX','200'); \n";
					$str.="define('C_BB_IMG_NEWWIN','1'); \n";
					$str.="define('C_BB_IMG_MAX','20'); \n";
					$str.="define('C_BB_IMG_EXT','jpg,jpeg,gif,png,bmp'); \n";
					$str.="define('C_BB_VIDEO_MAX','5'); \n";
					$str.="define('C_BB_VIDEO_WIDTH','320'); \n";
					$str.="define('C_BB_VIDEO_HEIGHT','240'); \n";
					$str.="define('C_PROF_LNK','0'); \n";
					$str.="define('C_PROF_LNKSH','0'); \n";
					$str.="define('C_PAYMENT_POINTS','1'); \n";
					$str.="define('C_PAYMENT_POINTS_MAIL','1'); \n";
					$str.="define('C_SR_BANNER','0'); \n";
					$str.="define('C_BB_DESC_ACL','-1,-1,-1,-1,-1,-1,256,2,3'); \n";
					$str.="define('C_BB_PCOM_ACL','-1,-1,-1,-1,-1,-1,256,2,3'); \n";
					$str.="define('C_BB_BLOG_ACL','-1,-1,-1,-1,-1,-1,0,0,0'); \n";
					$str.="define('C_BB_BCOM_ACL','-1,0,0,0,0,0,256,3,3'); \n";
					$str.="define('C_BB_FORUM_ACL','-1,-1,-1,-1,-1,-1,256,1,1'); \n";
					$str.="define('C_BB_FSIGN_ACL','0,0,0,0,0,0,3,3,256'); \n";
					$str.="define('C_BB_SM_ACL','0,0,0,0,0,0,256,3,256'); \n";
					$str.="define('C_BB_PN_ACL','-1,-1,-1,-1,-1,-1,0,0,0'); \n";
					$str.="define('C_BB_TM_ACL','0,0,0,0,0,0,256,256,256'); \n";
					$str.="define('C_PLANS_VIS','-1'); \n";
					$str.="define('C_LINKS_DAYS','7'); \n";
					InsertInFile('include/options.inc.php','?>',$str,1);$str='';
				}
			}
		}
?>

<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=2>
:: <?=$y[13]?> 3 :: <?=$y[61]?>
</td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td>
<form method="Post" action="install.php?step=4" name="form">
<input type="hidden" name="insttype" value="<?=$insttype?>" size="0" maxlength="0">
<?='<input type="submit" class=button id=but2 onmouseover=bc(this,"'.COLOR2.'") onmouseout=bc(this,"'.COLOR1.'") href="javascript:;" value="'.$y[24].' 4" name="submit">';?>

</form>
</td></tr></Table>
</td></tr></Table>
<?
break;
######################################
#   S T E P - 4 [Tables installing]
######################################

	case '4':


		if(!is_numeric($insttype)) $insttype=0;

		include_once 'include/options.inc.php';
		include_once 'include/functions.inc.php';

		#@mysql_connect(C_HOST, C_USER, C_PASS) or error($y[59]);
		#@mysql_select_db(C_BASE) or error($y[60]);

		$ine = (mysql_get_client_info() >= '3.23') ? 'IF NOT EXISTS ' : '';
?>

<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=2>
:: <?=$y[13]?> 4 :: <?=$y[61]?>
</td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td>
<?=$y[62]?></td><td><?=$y[63]?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_TEMP?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_TEMP." (
  id int unsigned NOT NULL,
  date DATE NOT NULL default '0000-00-00',
  code char(32) NOT NULL default ''
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_MEMBERS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MEMBERS." (
  id int unsigned ZEROFILL NOT NULL auto_increment primary key,
  username varchar(16) NOT NULL default '',
  fname varchar(16) NOT NULL default '',
  lname varchar(30) NOT NULL default '',
  password char(16) NOT NULL default '',
  birthday DATE NOT NULL default '0000-00-00',
  gender tinyint unsigned NOT NULL default '0',
  purposes tinyint unsigned NOT NULL default '0',
  country smallint unsigned NOT NULL default '0',
  email varchar(64) NOT NULL default '',
  url varchar(64) NOT NULL default '',
  icq int unsigned NOT NULL default '0',
  aim varchar(16) NOT NULL default '',
  phone varchar(20) NOT NULL default '',
  zip varchar(16) NOT NULL default '',
  city varchar(32) NOT NULL default '',
  address varchar(64) NOT NULL default '',
  marstat tinyint unsigned NOT NULL default '0',
  child tinyint unsigned NOT NULL default '0',
  height tinyint unsigned NOT NULL default '0',
  weight tinyint unsigned NOT NULL default '0',
  hcolor tinyint unsigned NOT NULL default '0',
  ecolor tinyint unsigned NOT NULL default '0',
  etnicity tinyint unsigned NOT NULL default '0',
  religion tinyint unsigned NOT NULL default '0',
  smoke tinyint unsigned NOT NULL default '0',
  drink tinyint unsigned NOT NULL default '0',
  education tinyint unsigned NOT NULL default '0',
	languages set('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63') NOT NULL default '',
  mylang varchar(5) NOT NULL default '',
  job varchar(30) NOT NULL default '',
  hobby tinytext NOT NULL,
  descr text NOT NULL,
  scountry smallint unsigned NOT NULL default '0',
  smarstat tinyint unsigned NOT NULL default '0',
  schild tinyint unsigned NOT NULL default '0',
  shcolor tinyint unsigned NOT NULL default '0',
  secolor tinyint unsigned NOT NULL default '0',
  ssmoke tinyint unsigned NOT NULL default '0',
  sdrink tinyint unsigned NOT NULL default '0',
  seducation tinyint unsigned NOT NULL default '0',
  sgender tinyint unsigned NOT NULL default '0',
  setnicity tinyint unsigned NOT NULL default '0',
  sreligion tinyint unsigned NOT NULL default '0',
  agef tinyint unsigned NOT NULL default '0',
  aget tinyint unsigned NOT NULL default '0',
  heightf tinyint unsigned NOT NULL default '0',
  heightt tinyint unsigned NOT NULL default '0',
  weightf tinyint unsigned NOT NULL default '0',
  weightt tinyint unsigned NOT NULL default '0',
  hdyfu tinyint unsigned NOT NULL default '0',
  pic1 varchar(24) NOT NULL default '',
  pic2 varchar(24) NOT NULL default '',
  pic3 varchar(24) NOT NULL default '',
  audio varchar(24) NOT NULL default '',
  horo tinyint unsigned NOT NULL default '0',
  regdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  editdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  ip int unsigned NOT NULL default '0',
  prv int unsigned NOT NULL default '0',
  hits int unsigned NOT NULL default '0',
  hits_count int unsigned NOT NULL default '0',
  status tinyint unsigned NOT NULL default '0',
  req tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<?php if($insttype != '1') { ?>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_MEMBERS?></td>
<td><?php
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD username VARCHAR(16)  NOT NULL AFTER id";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD zip varchar(16) NOT NULL default '' AFTER phone";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." CHANGE `zip` `zip` varchar(16) NOT NULL default ''";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD prv int unsigned NOT NULL default '0' AFTER ip";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD hits float NOT NULL default '0' AFTER prv";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." CHANGE `hits` `hits` int unsigned NOT NULL default '0' AFTER prv";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD address varchar(64) NOT NULL default '' AFTER city";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD `languages` set('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63') NOT NULL AFTER `education`";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD audio VARCHAR(24)  NOT NULL AFTER pic3";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." DROP INDEX id, ADD INDEX id (id)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." DROP INDEX username";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BAD_PROFILES." CHANGE ip fromip INT(10) UNSIGNED DEFAULT '0' NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BAD_PROFILES." CHANGE fromid fromid INT UNSIGNED DEFAULT '0' NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BAD_PROFILES." CHANGE user user INT UNSIGNED DEFAULT '0' NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BAD_PROFILES." ADD reason TINYTEXT NOT NULL AFTER user";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_HITS." CHANGE id id INT UNSIGNED DEFAULT '0' NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MAILLIST." ADD unact smallint unsigned NOT NULL default '0' AFTER regin";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MAILLIST." CHANGE uid uid INT UNSIGNED DEFAULT '0' NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MAILLIST." CHANGE lastid lastid INT UNSIGNED DEFAULT '0' NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD mylang CHAR(5) NOT NULL AFTER languages";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." CHANGE `country` `country` smallint unsigned NOT NULL default '0'";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD hits_count int unsigned NOT NULL default '0' AFTER hits";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_NEWS." ADD lang varchar(7) NOT NULL default '' AFTER id";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FAQCAT." ADD lang varchar(7) NOT NULL default '' AFTER id";
mysql_query($sql);
#$sql = "ALTER TABLE ".C_MYSQL_FAQ." ADD lang varchar(7) NOT NULL default '' AFTER cid";
#mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD scountry smallint unsigned NOT NULL default '0' AFTER descr";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD smarstat tinyint unsigned NOT NULL default '0' AFTER scountry";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD schild tinyint unsigned NOT NULL default '0' AFTER smarstat";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD shcolor tinyint unsigned NOT NULL default '0' AFTER schild";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD secolor tinyint unsigned NOT NULL default '0' AFTER shcolor";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD ssmoke tinyint unsigned NOT NULL default '0' AFTER secolor";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD sdrink tinyint unsigned NOT NULL default '0' AFTER ssmoke";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS." ADD seducation tinyint unsigned NOT NULL default '0' AFTER sdrink";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MESSAGES." DROP INDEX toid";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MESSAGES." DROP INDEX readed";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MESSAGES." ADD INDEX ids (toid,fromid)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_CARDS." ADD INDEX toid (toid)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_CARDS." ADD INDEX readed (readed)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BEDROOM." ADD INDEX myid (myid)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BEDROOM." ADD INDEX user (user)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BANLIST." ADD INDEX myid (myid)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BANLIST." ADD INDEX user (user)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_HITS." ADD PRIMARY KEY (id,ip)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_AFFILIATES." ADD INDEX affid (affid)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_AFFILIATES." ADD INDEX recid (recid)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD replycount INT UNSIGNED NOT NULL DEFAULT '0' AFTER descr";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD lastpost DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL AFTER replycount";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD lastposter VARCHAR(50) NOT NULL DEFAULT '' AFTER lastpost";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD lastpostid INT UNSIGNED NOT NULL DEFAULT '0' AFTER lastposter";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD lastthread VARCHAR(250) NOT NULL DEFAULT '' AFTER lastpostid";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD lastthreadid INT UNSIGNED NOT NULL DEFAULT '0' AFTER lastthread";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD threadcount int UNSIGNED NOT NULL DEFAULT '0' AFTER lastthreadid";
mysql_query($sql);
echo "<span class=ok>Upgraded</span>";
?></td></tr>
<?php } ?>
<?php if($insttype == '0') { ?>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_HITS?></td>
<td><?php
$sql = "ALTER TABLE ".C_MYSQL_HITS." DROP `hits`";
mysql_query($sql);
echo "<span class=ok>Upgraded</span>";
?></td></tr>
<?php } ?>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_ONLINE_USERS?></td>
<td><?php
@mysql_query("DROP TABLE ".C_MYSQL_ONLINE_USERS);
$sql = "CREATE TABLE ".$ine.C_MYSQL_ONLINE_USERS." (
  utime datetime NOT NULL default '0000-00-00 00:00:00',   
  user int unsigned NOT NULL default '0',
  usertype tinyint NOT NULL default '0',
  ip int(8) unsigned NOT NULL default '0',
	upage varchar(50) NOT NULL default ''
) TYPE = HEAP";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_PROFILEVIEW?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_PROFILEVIEW." (
myid INT (8) UNSIGNED DEFAULT '0' NOT NULL, 
visid INT (8) UNSIGNED DEFAULT '0' NOT NULL, 
visdate DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, 
PRIMARY KEY (myid,visid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_PMEMBERS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_PMEMBERS." (
  id int unsigned ZEROFILL NOT NULL primary key,
  user_type tinyint unsigned NOT NULL default '0',
  enddate DATETIME NOT NULL default '0000-00-00 00:00:00'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_MESSAGES?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MESSAGES." (
  id int unsigned NOT NULL auto_increment primary key,
  fromid int unsigned NOT NULL default '0',
  toid int unsigned NOT NULL default '0',
  subject varchar(100) NOT NULL default '',
  message text NOT NULL,
  sendtime DATETIME NOT NULL default '0000-00-00 00:00:00',
  ip int unsigned NOT NULL DEFAULT '0',
  readed tinyint unsigned NOT NULL DEFAULT '0',
	KEY ids (toid,fromid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_MESSAGES_ARCHIVE?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MESSAGES_ARCHIVE." (
  id int unsigned NOT NULL primary key,
  fromid int unsigned NOT NULL default '0',
  toid int unsigned NOT NULL default '0',
  subject varchar(100) NOT NULL default '',
  message text NOT NULL,
  sendtime DATETIME NOT NULL default '0000-00-00 00:00:00',
  ip int unsigned NOT NULL DEFAULT '0',
  readed tinyint unsigned NOT NULL DEFAULT '0',
	KEY ids (toid,fromid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_BAD_PROFILES?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_BAD_PROFILES." (
  id smallint unsigned NOT NULL auto_increment primary key,
  date DATE NOT NULL default '0000-00-00',
  ip int unsigned NOT NULL default '0',
  fromid int unsigned NOT NULL default '0',
  user int unsigned NOT NULL default '0',
  reason tinytext NOT NULL
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_BEDROOM?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_BEDROOM." (
  id int unsigned NOT NULL auto_increment primary key,
  myid int unsigned NOT NULL default '0',
  date DATE NOT NULL default '0000-00-00',
  user int unsigned NOT NULL default '0',
  reason tinytext NOT NULL,
	KEY myid (myid),
	KEY user (user)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_HITS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_HITS." (
  id int unsigned NOT NULL default '0',
  ip int unsigned NOT NULL default '0',
  votedate DATETIME NOT NULL default '0000-00-00 00:00:00',
	PRIMARY KEY (id, ip)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_FAQ?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_FAQ." (
  id SMALLINT UNSIGNED NOT NULL auto_increment primary key,
  cid smallint unsigned NOT NULL default '0',
  question text NOT NULL,
  answer text NOT NULL
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_FAQCAT?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_FAQCAT." (
  id SMALLINT UNSIGNED NOT NULL auto_increment primary key,
  lang varchar(7) NOT NULL default '',
  catname tinytext NOT NULL
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_MAILLIST?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MAILLIST." (
  id SMALLINT UNSIGNED NOT NULL auto_increment primary key,
  uid INT UNSIGNED NOT NULL default '0',
  horo tinyint unsigned NOT NULL default '0',
  agef tinyint unsigned NOT NULL default '0',
  aget tinyint unsigned NOT NULL default '0',
  gender tinyint unsigned NOT NULL default '0',
  purposes tinyint unsigned NOT NULL default '0',
  country tinyint unsigned NOT NULL default '0',
  regin tinyint unsigned NOT NULL default '0',
  unact smallint unsigned NOT NULL default '0',
  status tinyint unsigned NOT NULL default '0',
  usertype text NOT NULL,
  send_op tinyint unsigned NOT NULL default '0',
  mtype tinyint unsigned NOT NULL default '0',
  frommail varchar(40) NOT NULL default '',
  subject tinytext NOT NULL,
  message text NOT NULL,
  confirm tinyint unsigned NOT NULL default '0',
  lastid INT UNSIGNED NOT NULL default '0',
  maildate DATETIME NOT NULL default '0000-00-00 00:00:00'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_RECOMMEND?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_RECOMMEND." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  email varchar(64) NOT NULL default '',
  ip int unsigned NOT NULL default '0',
  email2 varchar(64) NOT NULL default '',
  maildate DATETIME NOT NULL default '0000-00-00 00:00:00'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_CARDS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_CARDS." (
  id int unsigned NOT NULL auto_increment primary key,
  code char(32) NOT NULL default '',
  fromid int unsigned NOT NULL default '0',
  toid int unsigned NOT NULL default '0',
  image varchar(50) NOT NULL default '',
  subject text NOT NULL,
  message text NOT NULL,
  sendtime DATETIME NOT NULL default '0000-00-00 00:00:00',
  ip int unsigned NOT NULL DEFAULT '0',
  readed tinyint unsigned NOT NULL DEFAULT '0',
	KEY toid (toid),
	KEY readed (readed)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_AFFILIATES?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_AFFILIATES." (
  id int unsigned NOT NULL auto_increment primary key,
  affid int unsigned NOT NULL default '0',
  recid int unsigned NOT NULL default '0',
  point float NOT NULL default '0',
  regdate DATETIME NOT NULL default '0000-00-00 00:00:00',
	KEY affid (affid),
	KEY recid (recid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_BANLIST?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_BANLIST." (
  id int unsigned NOT NULL auto_increment primary key,
  myid int unsigned NOT NULL default '0',
  date DATE NOT NULL default '0000-00-00',
  user int unsigned NOT NULL default '0',
  reason tinytext NOT NULL,
	KEY myid (myid),
	KEY user (user)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_NEWS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_NEWS." (
  id int unsigned NOT NULL auto_increment primary key,
  lang varchar(7) NOT NULL default '',
  subject tinytext NOT NULL,
  news text NOT NULL,
  date DATETIME NOT NULL default '0000-00-00 00:00:00',
  priority tinyint NOT NULL default '0',
  type tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_FORUM_MESSAGES?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_FORUM_MESSAGES." (
  id int UNSIGNED NOT NULL auto_increment primary key,
  cid smallint unsigned NOT NULL default '0',
  fid smallint unsigned NOT NULL default '0',
  tid int unsigned NOT NULL default '0',
  uid int unsigned NOT NULL default '0',
  status tinyint NOT NULL default '0',
  subject tinytext NOT NULL,
  message text NOT NULL,
  createdby tinytext NOT NULL,
  cdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  ip int unsigned NOT NULL DEFAULT '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_FORUM_THREADS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_FORUM_THREADS." (
  id int UNSIGNED NOT NULL auto_increment primary key,
  fid smallint unsigned NOT NULL default '0',
  title tinytext NOT NULL,
  message text NOT NULL,
  uid int unsigned NOT NULL default '0',
  createdby tinytext NOT NULL,
  sticky tinyint unsigned NOT NULL default '0',
  views int unsigned NOT NULL default '0',
  reply int unsigned NOT NULL default '0',
  cdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  ldate DATETIME NOT NULL default '0000-00-00 00:00:00',
  luser varchar(16) NOT NULL default '',
  open tinyint unsigned NOT NULL default '0',
  bbcode tinyint unsigned NOT NULL default '0',
  ip int unsigned NOT NULL DEFAULT '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_FORUM?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_FORUM." (
  id smallint UNSIGNED NOT NULL auto_increment primary key,
  cid smallint unsigned NOT NULL default '0',
  title tinytext NOT NULL,
  descr text NOT NULL,
	replycount INT UNSIGNED NOT NULL DEFAULT '0',
	lastpost DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
	lastposter VARCHAR(50) NOT NULL DEFAULT '',
	lastpostid INT UNSIGNED NOT NULL DEFAULT '0',
	lastthread VARCHAR(250) NOT NULL DEFAULT '',
	lastthreadid INT UNSIGNED NOT NULL DEFAULT '0',
	threadcount int UNSIGNED NOT NULL DEFAULT '0',
  access tinyint NOT NULL default '-1',
  smile_access smallint NOT NULL default '-1',
  create_thread_access smallint NOT NULL default '-1',
  reply_access smallint NOT NULL default '-1',
  moders text NOT NULL,
  status tinyint unsigned NOT NULL default '0',
  req tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65]."</span>".mysql_error();
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_FORUMCAT?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_FORUMCAT." (
  id smallint UNSIGNED NOT NULL auto_increment primary key,
  catname tinytext NOT NULL
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_LINKS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_LINKS." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  cid smallint unsigned NOT NULL default '0',
  url text NOT NULL,
  title tinytext NOT NULL,
  descr text NOT NULL,
  mkeywords text NOT NULL,
  uname tinytext NOT NULL,
  email tinytext NOT NULL,
  reclink text NOT NULL,
  regdate DATETIME NOT NULL default '2008-08-08 00:00:00',
	code varchar(32) NOT NULL default '',
  status tinyint unsigned NOT NULL default '7',
  req tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_LINKSCAT?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_LINKSCAT." (
  id SMALLINT UNSIGNED NOT NULL auto_increment primary key,
  catname tinytext NOT NULL
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_OPTIONS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_OPTIONS." (
  id INT UNSIGNED NOT NULL primary key,
  freem smallint unsigned NOT NULL default '0',
  mnum smallint unsigned NOT NULL default '0',
  mday DATETIME NOT NULL default '0000-00-00 00:00:00',
  timediff tinyint NOT NULL default '0',
  upddate DATETIME NOT NULL default '0000-00-00 00:00:00',
  imsound tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_COMMENTS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_COMMENTS." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  toid int unsigned NOT NULL default '0',
  fromid int unsigned NOT NULL default '0',
  subject tinytext NOT NULL,
  comment text NOT NULL,
  reply text NOT NULL,
  cdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  rdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  status tinyint unsigned NOT NULL default '0',
	KEY toid (toid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_SUBSCRIBE?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_SUBSCRIBE." (
  id int unsigned ZEROFILL NOT NULL auto_increment primary key,
  uid int unsigned NOT NULL default '0',
  email varchar(64) NOT NULL default '',
  code char(32) NOT NULL default '',
  gender tinyint unsigned NOT NULL default '0',
  sgender tinyint unsigned NOT NULL default '0',
  country smallint unsigned NOT NULL default '0',
  purposes tinyint unsigned NOT NULL default '0',
  horo tinyint unsigned NOT NULL default '0',
  agef tinyint unsigned NOT NULL default '0',
  aget tinyint unsigned NOT NULL default '0',
  zip varchar(16) NOT NULL default '',
  photo tinyint unsigned NOT NULL default '0',
  url tinyint unsigned NOT NULL default '0',
  icq tinyint unsigned NOT NULL default '0',
  aim tinyint unsigned NOT NULL default '0',
  phone tinyint unsigned NOT NULL default '0',
  regdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  editdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  lang char(5) NOT NULL default '',
  ip int unsigned NOT NULL default '0',
  status tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>

<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_VOTES?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_VOTES." (
  id smallint(5) UNSIGNED NOT NULL auto_increment primary key,
  num tinyint(3) UNSIGNED NOT NULL default '0',
  q1 mediumint(8) UNSIGNED NOT NULL default '0',
  q2 mediumint(8) UNSIGNED NOT NULL default '0',
  q3 mediumint(8) UNSIGNED NOT NULL default '0',
  q4 mediumint(8) UNSIGNED NOT NULL default '0',
  q5 mediumint(8) UNSIGNED NOT NULL default '0',
  q6 mediumint(8) UNSIGNED NOT NULL default '0',
  q7 mediumint(8) UNSIGNED NOT NULL default '0',
  q8 mediumint(8) UNSIGNED NOT NULL default '0',
  q9 mediumint(8) UNSIGNED NOT NULL default '0',
  q10 mediumint(8) UNSIGNED NOT NULL default '0',
  q11 mediumint(8) UNSIGNED NOT NULL default '0',
  q12 mediumint(8) UNSIGNED NOT NULL default '0',
  q13 mediumint(8) UNSIGNED NOT NULL default '0',
  q14 mediumint(8) UNSIGNED NOT NULL default '0',
  q15 mediumint(8) UNSIGNED NOT NULL default '0',
  q16 mediumint(8) UNSIGNED NOT NULL default '0',
  q17 mediumint(8) UNSIGNED NOT NULL default '0',
  q18 mediumint(8) UNSIGNED NOT NULL default '0',
  q19 mediumint(8) UNSIGNED NOT NULL default '0',
  q20 mediumint(8) UNSIGNED NOT NULL default '0',
  stype tinyint(3) UNSIGNED NOT NULL default '0',
	actual tinyint(3) UNSIGNED NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_VOTE_IPS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_VOTE_IPS." (
  vid smallint(5) UNSIGNED NOT NULL,
  ip int(10) UNSIGNED NOT NULL default '0',
  time timestamp(10),
  KEY vid (vid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_VOTE_QUESTIONS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_VOTE_QUESTIONS." (
  id smallint(5) UNSIGNED NOT NULL default '0',
  question tinytext NOT NULL,
  lang varchar(7) NOT NULL default '',
  qtext1 varchar(63) NOT NULL default '',
  qtext2 varchar(63) NOT NULL default '',
  qtext3 varchar(63) NOT NULL default '',
  qtext4 varchar(63) NOT NULL default '',
  qtext5 varchar(63) NOT NULL default '',
  qtext6 varchar(63) NOT NULL default '',
  qtext7 varchar(63) NOT NULL default '',
  qtext8 varchar(63) NOT NULL default '',
  qtext9 varchar(63) NOT NULL default '',
  qtext10 varchar(63) NOT NULL default '',
  qtext11 varchar(63) NOT NULL default '',
  qtext12 varchar(63) NOT NULL default '',
  qtext13 varchar(63) NOT NULL default '',
  qtext14 varchar(63) NOT NULL default '',
  qtext15 varchar(63) NOT NULL default '',
  qtext16 varchar(63) NOT NULL default '',
  qtext17 varchar(63) NOT NULL default '',
  qtext18 varchar(63) NOT NULL default '',
  qtext19 varchar(63) NOT NULL default '',
  qtext20 varchar(63) NOT NULL default '',
	KEY id (id)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_MEMBERS_MAIN?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MEMBERS_MAIN." (
  id int unsigned ZEROFILL NOT NULL auto_increment primary key,
  username char(16) NOT NULL default '',
  fname char(16) NOT NULL default '',
  lname char(30) NOT NULL default '',
  birthday DATE NOT NULL default '0000-00-00',
  gender tinyint unsigned NOT NULL default '0',
  bodytype tinyint unsigned NOT NULL default '0',
  orientation tinyint unsigned NOT NULL default '0',
  purposes set('1','2','3','4','5','6','7','8') NOT NULL,
  country smallint unsigned NOT NULL default '0',
  city char(32) NOT NULL default '',
  zip char(16) NOT NULL default '',
  height tinyint unsigned NOT NULL default '0',
  weight tinyint unsigned NOT NULL default '0',
  sgender set('1','2','3','4','5','6','7','8') NOT NULL,
	files set('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63') NOT NULL default '',
  horo tinyint unsigned NOT NULL default '0',
  regdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  editdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  rate tinyint unsigned NOT NULL default '1',
  hits int unsigned NOT NULL default '0',
  hits_count int unsigned NOT NULL default '0',
  status tinyint unsigned NOT NULL default '0',
  points smallint unsigned NOT NULL default '0',
  pointm tinyint unsigned NOT NULL default '1',
  hide tinyint unsigned NOT NULL default '0',
  req tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65]." ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_MEMBERS_EXT?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MEMBERS_EXT." (
  id int unsigned ZEROFILL NOT NULL primary key,
  url varchar(64) NOT NULL default '',
  icq int unsigned NOT NULL default '0',
  aim varchar(16) NOT NULL default '',
  phone varchar(20) NOT NULL default '',
  state varchar(32) NOT NULL default '',
  address varchar(64) NOT NULL default '',
  marstat tinyint unsigned NOT NULL default '0',
  child tinyint unsigned NOT NULL default '0',
  hcolor tinyint unsigned NOT NULL default '0',
  ecolor tinyint unsigned NOT NULL default '0',
  etnicity tinyint unsigned NOT NULL default '0',
  religion tinyint unsigned NOT NULL default '0',
  smoke tinyint unsigned NOT NULL default '0',
  drink tinyint unsigned NOT NULL default '0',
  education tinyint unsigned NOT NULL default '0',
	languages set('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63') NOT NULL default '',
	interests set('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63') NOT NULL default '',
  mylang varchar(5) NOT NULL default '',
  job varchar(30) NOT NULL default '',
  hobby tinytext NOT NULL,
  descr text NOT NULL,
  mytemp tinytext NOT NULL,
  scountry text NOT NULL,
  smarstat set('1','2','3','4','5','6','7','8') NOT NULL,
  schild set('1','2','3','4','5','6','7','8') NOT NULL,
  shcolor set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16') NOT NULL,
  secolor set('1','2','3','4','5','6','7','8') NOT NULL,
  ssmoke set('1','2','3','4','5','6','7','8') NOT NULL,
  sdrink set('1','2','3','4','5','6','7','8') NOT NULL,
  seducation set('1','2','3','4','5','6','7','8') NOT NULL,
  setnicity set('1','2','3','4','5','6','7','8') NOT NULL,
  sreligion set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32') NOT NULL,
  agef tinyint unsigned NOT NULL default '0',
  aget tinyint unsigned NOT NULL default '0',
  heightf tinyint unsigned NOT NULL default '0',
  heightt tinyint unsigned NOT NULL default '0',
  weightf tinyint unsigned NOT NULL default '0',
  weightt tinyint unsigned NOT NULL default '0',
  hdyfu tinyint unsigned NOT NULL default '0',
  audio varchar(4) NOT NULL default '',
  status tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_MEMBERS_SEC?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MEMBERS_SEC." (
  id int unsigned ZEROFILL NOT NULL primary key,
  password varchar(32) NOT NULL default '',
  email varchar(255) NOT NULL default '',
  nomail tinyint unsigned NOT NULL default '0',
  nokiss tinyint unsigned NOT NULL default '0',
  ip int unsigned NOT NULL default '0',
  prv int unsigned NOT NULL default '0',
  wantpriv tinyint unsigned NOT NULL default '0',
  link int unsigned NOT NULL default '0',
  link_txt varchar(255) NOT NULL default '',
  status tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_MEMBERS_RESTRICTS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MEMBERS_RESTRICTS." (
  id int unsigned ZEROFILL NOT NULL primary key,
  photo tinyint unsigned NOT NULL default '0',
  audio tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_BLACKLIST?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_BLACKLIST." (
	id int unsigned NOT NULL auto_increment primary key,
  bid tinyint unsigned NOT NULL,
  word varchar(100) NOT NULL default '',
	UNIQUE KEY (bid,word)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_SEARCH?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_SEARCH." (
  id int UNSIGNED NOT NULL auto_increment primary key,
  uid int unsigned NOT NULL default '0',
  utype smallint NOT NULL default '0',
  cache char(32) NOT NULL default '',
  cdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  result int unsigned NOT NULL default '0',
  returnid text NOT NULL,
  search_data text NOT NULL,
  search_name varchar(64) NOT NULL default ''
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_COUPONS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_COUPONS." (
  id int UNSIGNED NOT NULL auto_increment primary key,
  name varchar(32) NOT NULL default '',
  coupon tinytext NOT NULL,
  utype int(10) unsigned NOT NULL default '0',
  ctype tinyint(3) unsigned NOT NULL default '0',
  points int(10) unsigned NOT NULL default '0',
  period tinyint(3) unsigned NOT NULL default '0',
  activity tinyint(3) unsigned NOT NULL default '0',
  KEY name (name)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_ADDRESSBOOK?></td>
<td><?php
#mysql_query("DROP TABLE ".C_MYSQL_ADDRESSBOOK);
$sql = "CREATE TABLE ".$ine.C_MYSQL_ADDRESSBOOK." (
	myid int unsigned NOT NULL default '0',
  user int unsigned NOT NULL default '0',
  new_mes smallint unsigned NOT NULL default '0',
  total_mes mediumint unsigned NOT NULL default '0',
  lastdate datetime NOT NULL default '0000-00-00 00:00:00',
  status tinyint unsigned NOT NULL default '0',
  UNIQUE ids (myid,user)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_NEW_PHOTOS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_NEW_PHOTOS." (
	uid int(10) unsigned NOT NULL default '0' primary key,
  photonum set('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63') NOT NULL default ''
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_TESTIMONIALS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_TESTIMONIALS." (
	id int unsigned NOT NULL auto_increment primary key,
	uid int unsigned NOT NULL default '0',
	message text NOT NULL,
	reply text NOT NULL,
  mdate datetime NOT NULL default '0000-00-00 00:00:00',
  rdate datetime NOT NULL default '0000-00-00 00:00:00',
	status tinyint unsigned NOT NULL default '0'
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_ART?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_ART." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  cid int unsigned NOT NULL default '0',
  subject tinytext NOT NULL,
  body longtext NOT NULL,
  status tinyint unsigned NOT NULL default '0',
  access smallint NOT NULL default '-1',
  cdate datetime NOT NULL default '0000-00-00 00:00:00'  
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_ARTCAT?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_ARTCAT." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  lang varchar(7) NOT NULL default '',
  catname tinytext NOT NULL
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_BLOGS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_BLOGS." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  cid smallint unsigned NOT NULL default '0',
  uid int unsigned NOT NULL default '0',
  subject tinytext NOT NULL,
  body text NOT NULL,
  status tinyint unsigned NOT NULL default '0',
  shows tinyint unsigned NOT NULL default '0',
  cdate datetime NOT NULL default '0000-00-00 00:00:00',  
  udate datetime NOT NULL default '0000-00-00 00:00:00'  
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_NOTES?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_NOTES." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  uid int unsigned NOT NULL default '0',
  subject tinytext NOT NULL,
  body text NOT NULL,
  status tinyint unsigned NOT NULL default '0',
  cdate datetime NOT NULL default '0000-00-00 00:00:00',  
  udate datetime NOT NULL default '0000-00-00 00:00:00'  
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_HOTORNOT?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_HOTORNOT." (
  uid INT UNSIGNED NOT NULL default '0',
  pid tinyint unsigned NOT NULL default '0',
  vid INT UNSIGNED NOT NULL default '0',
  rate tinyint unsigned NOT NULL default '0',
  cdate datetime NOT NULL default '0000-00-00 00:00:00',  
  PRIMARY KEY (uid,pid,vid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_PRIVATE_PHOTOS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_PRIVATE_PHOTOS." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  uid int unsigned NOT NULL default '0',
  type tinyint unsigned NOT NULL default '0',
  access smallint NOT NULL default '-1',
  descr tinytext NOT NULL,
  pass varchar(32) NOT NULL default '',
  cdate datetime NOT NULL default '0000-00-00 00:00:00',  
  status tinyint unsigned NOT NULL default '0',
  INDEX ids (uid)  
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_FORUM_SEARCH?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_FORUM_SEARCH." (
  id int UNSIGNED NOT NULL auto_increment primary key,
  uid int unsigned NOT NULL default '0',
  utype smallint NOT NULL default '0',
  cache char(32) NOT NULL default '',
  cdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  result int unsigned NOT NULL default '0',
  returnid text NOT NULL,
  search_data text NOT NULL,
  search_name varchar(64) NOT NULL default ''
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65]." ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_MEMBERS_FORUM?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_MEMBERS_FORUM." (
  id int unsigned NOT NULL primary key,
  avatar tinyint unsigned NOT NULL default '0',
  posts mediumint unsigned NOT NULL default '0',
  last_thread int unsigned NOT NULL default '0',
  last_post int unsigned NOT NULL default '0',
  signature text NOT NULL,
  bans text NOT NULL
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65]." ".mysql_error()."</span>";
# Inserting 1 row for guests
@mysql_query("INSERT INTO ".C_MYSQL_MEMBERS_FORUM." VALUES ('0','0','0','0','0','','')");
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_IP2COUNTRY?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_IP2COUNTRY." (
  ipf int(10) unsigned NOT NULL default '0',
  ipt int(10) unsigned NOT NULL default '0',
  country smallint(5) unsigned default '0',
  PRIMARY KEY  (ipf,ipt)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center>
<td><?=C_MYSQL_ZIP_DATA?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_ZIP_DATA." (
  zipcode char(6) NOT NULL default '',
  lon char(8) NOT NULL default '',
  lat char(8) NOT NULL default '',
  UNIQUE KEY zipcode (zipcode)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_BLOGS_CAT?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_BLOGS_CAT." (
  id smallint UNSIGNED NOT NULL auto_increment primary key,
  catname tinytext NOT NULL
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_BLOGS_COM?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_BLOGS_COM." (
  id INT UNSIGNED NOT NULL auto_increment primary key,
  bid int unsigned NOT NULL default '0',
  uid int unsigned NOT NULL default '0',
  subject tinytext NOT NULL,
  comment text NOT NULL,
  reply text NOT NULL,
  cdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  rdate DATETIME NOT NULL default '0000-00-00 00:00:00',
  status tinyint unsigned NOT NULL default '0',
	KEY bid (bid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_BLOGS_VOTE?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_BLOGS_VOTE." (
  bid int unsigned NOT NULL  primary key,
  viewnum int unsigned NOT NULL default '0',
  rate int unsigned NOT NULL default '0',
  ratenum int unsigned NOT NULL default '0',
  KEY bid (bid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_ALLHITS?></td>
<td><?php
$sql = "CREATE TABLE ".$ine.C_MYSQL_ALLHITS." (
  id int unsigned NOT NULL default '0',
  type tinyint unsigned NOT NULL default '0',
  tid int unsigned NOT NULL default '0',
	PRIMARY KEY (id, type, tid)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td><?=C_MYSQL_ADDRESSBOOK_ARCHIVE?></td>
<td><?php
#mysql_query("DROP TABLE ".C_MYSQL_ADDRESSBOOK);
$sql = "CREATE TABLE ".$ine.C_MYSQL_ADDRESSBOOK_ARCHIVE." (
	myid int unsigned NOT NULL default '0',
  user int unsigned NOT NULL default '0',
  new_mes smallint unsigned NOT NULL default '0',
  total_mes mediumint unsigned NOT NULL default '0',
  lastdate datetime NOT NULL default '0000-00-00 00:00:00',
  UNIQUE ids (myid,user)
)";
if(mysql_query($sql)) echo "<span class=ok>".$y[64]."</span>";
else echo "<span class=false>".$y[65].": ".mysql_error()."</span>";
?></td></tr>

<?php if($insttype != '1') { ?>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td>Upgrades in tables from 1.6.x</td>
<td><?php
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." ADD bodytype tinyint unsigned NOT NULL default '0' AFTER gender";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." ADD orientation tinyint unsigned NOT NULL default '0' AFTER bodytype";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." ADD rate tinyint unsigned NOT NULL default '1' AFTER editdate";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." ADD state varchar(32) NOT NULL default '' AFTER phone";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_SEC." ADD wantpriv tinyint unsigned NOT NULL default '0' AFTER prv";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." ADD `interests` set('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63') NOT NULL AFTER `languages`";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." change `purposes` `purposes` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." change `sgender` `sgender` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `smarstat` `smarstat` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `schild` `schild` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `shcolor` `shcolor` set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `secolor` `secolor` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `ssmoke` `ssmoke` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `sdrink` `sdrink` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `seducation` `seducation` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `setnicity` `setnicity` set('1','2','3','4','5','6','7','8') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `sreligion` `sreligion` set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32') NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." change `scountry` `scountry` text NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BEDROOM." ADD reason TINYtext NOT NULL AFTER user";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BANLIST." ADD reason TINYtext NOT NULL AFTER user";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_OPTIONS." ADD timediff tinyint unsigned NOT NULL default '0' AFTER mday";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_OPTIONS." ADD imsound tinyint unsigned NOT NULL default '0' AFTER timediff";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FAQ." DROP lang";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD smile_access smallint NOT NULL default '-1' AFTER access";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD create_thread_access smallint NOT NULL default '-1' AFTER smile_access";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM." ADD reply_access smallint NOT NULL default '-1' AFTER create_thread_access";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_ADDRESSBOOK." DROP PRIMARY KEY";
mysql_query($sql);
#$sql = "ALTER TABLE ".C_MYSQL_ADDRESSBOOK." DROP INDEX ids";
#mysql_query($sql) or die(mysql_error());
$sql = "ALTER TABLE ".C_MYSQL_ADDRESSBOOK." ADD total_mes mediumint NOT NULL default '0' AFTER new_mes";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_ADDRESSBOOK." ADD INDEX ids (user,myid)";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MESSAGES." DROP INDEX toid";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MESSAGES." DROP INDEX readed";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MESSAGES." ADD INDEX ids (toid,fromid)";
mysql_query($sql);

# Upgrade from 1.7.x
$sql = "ALTER TABLE ".C_MYSQL_MAILLIST." ADD send_op tinyint unsigned NOT NULL default '0' AFTER status";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_CARDS." change `subject` `subject` text NOT NULL";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." ADD points smallint unsigned NOT NULL default '0' AFTER status";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." ADD pointm tinyint unsigned NOT NULL default '1' AFTER points";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." ADD hide tinyint unsigned NOT NULL default '0' AFTER pointm";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_FORUM." ADD bans text NOT NULL AFTER signature";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_FORUM_THREADS." ADD bbcode tinyint unsigned NOT NULL default '0' AFTER open";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_OPTIONS." CHANGE `timediff` `timediff` tinyint NOT NULL default '0'";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_MAIN." ADD zip char(16) NOT NULL default '' AFTER city";
mysql_query($sql);


# transfer zip field to main members table:
$tmp_ = mysql_query("SHOW COLUMNS FROM ".C_MYSQL_MEMBERS_EXT);
while($fld=mysql_fetch_array($tmp_))
{
	if($fld['Field'] == 'zip')
	{
		if(mysql_get_server_info() > '4.0.4') @mysql_query("UPDATE ".C_MYSQL_MEMBERS_MAIN.",".C_MYSQL_MEMBERS_EXT." SET ".C_MYSQL_MEMBERS_MAIN.".zip=".C_MYSQL_MEMBERS_EXT.".zip WHERE ".C_MYSQL_MEMBERS_MAIN.".id=".C_MYSQL_MEMBERS_EXT.".id");
		else
		{
			$tmp = mysql_query("SELECT id,zip FROM ".C_MYSQL_MEMBERS_EXT." WHERE zip != ''");
			$count = mysql_num_rows($tmp);
			if ($count)
			{
				while($i=mysql_fetch_array($tmp))
				{
					mysql_query("UPDATE ".C_MYSQL_MEMBERS_MAIN." SET zip = '".$i['zip']."' WHERE id = '".$i['id']."'");
				}
			}
		}
		$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." DROP zip";
		mysql_query($sql);

	}
}

echo "<span class=ok>Upgraded</span>";
?></td></tr>
<?php } ?>
<?php if($insttype != '1') { ?>
<Tr bgcolor="<?=COLOR1?>" align=center>
<td>Upgrades in tables from 1.8.x</td>
<td><?php

# Upgrade from 1.8.x
$sql = "ALTER TABLE ".C_MYSQL_OPTIONS." ADD upddate DATETIME NOT NULL default '0000-00-00 00:00:00' AFTER timediff";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MAILLIST." ADD usertype text NOT NULL AFTER status";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_COUPONS." ADD ctype tinyint(3) unsigned NOT NULL default '0' AFTER utype";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_COUPONS." ADD points int(10) unsigned NOT NULL default '0' AFTER ctype";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_PRIVATE_PHOTOS." ADD access smallint NOT NULL default '-1' AFTER type";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_SEC." ADD nomail tinyint unsigned NOT NULL default '0' AFTER email";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_SEC." ADD nokiss tinyint unsigned NOT NULL default '0' AFTER nomail";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_SEC." ADD link int unsigned NOT NULL default '0' AFTER wantpriv";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_SEC." ADD link_txt varchar(255) NOT NULL default '' AFTER link";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_FORUM." ADD last_thread int unsigned NOT NULL default '0' AFTER posts";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_MEMBERS_EXT." ADD mytemp tinytext NOT NULL AFTER descr";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." ADD title tinytext NOT NULL AFTER url";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." ADD mkeywords text NOT NULL AFTER descr";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." ADD uname tinytext NOT NULL AFTER mkeywords";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." ADD email tinytext NOT NULL AFTER uname";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." ADD reclink text NOT NULL AFTER email";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." ADD regdate DATETIME NOT NULL default '2008-08-08 00:00:00' AFTER reclink";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." ADD code varchar(32) NOT NULL default '' AFTER regdate";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." ADD status tinyint unsigned NOT NULL default '7' AFTER code";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_LINKS." CHANGE `id` `id` INT UNSIGNED NOT NULL auto_increment";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BLOGS." ADD shows tinyint(3) unsigned NOT NULL default '0' AFTER status";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_BLOGS." ADD cid smallint unsigned NOT NULL default '0' AFTER id";
mysql_query($sql);
$sql = "ALTER TABLE ".C_MYSQL_ADDRESSBOOK." ADD status tinyint unsigned NOT NULL default '7' AFTER lastdate";
mysql_query($sql);
echo "<span class=ok>Upgraded</span>";
?></td></tr>
<?php } ?>
</table></td></tr></table>
<br>
<?php if($insttype == '0') { ?>
<font color="#FF0000" face="Arial" size="2"> Next step Transfer users and files to newest tables and places<br><br>
PLEASE WAIT - this page may reload many times, because transfer users by portion!!!</font><br>
<?}?>
<form method="Post" action="install.php?step=5" name="form">
<input type="hidden" name="insttype" value="<?=$insttype?>" size="0" maxlength="0">
<?='<input type="submit" class=button id=but2 onmouseover=bc(this,"'.COLOR2.'") onmouseout=bc(this,"'.COLOR1.'") href="javascript:;" value="'.$y[24].' 5" name="submit">';?>

</form>

<?break;

######################################
#   S T E P - 5 [Tables installing]
######################################

	case '5':
		@set_time_limit(0);
		@ini_set("memory_limit", "32M");

		if(!is_numeric($insttype)) $insttype=0;
		if(!isset($from) || !is_numeric($from)) $from = '0';

		include_once 'include/options.inc.php';
		include_once 'include/functions.inc.php';


		if($insttype != '1') CreateAddressBook();

		$ine = (mysql_get_client_info() >= '3.23') ? 'IF NOT EXISTS ' : '';
		
		$tmp = mysql_query("SELECT count(*) FROM ".C_MYSQL_MEMBERS);
		$row = mysql_fetch_row($tmp);
		$total = $row[0];
		if($total != 0)
		{
?>
<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=2>
:: <?=$y[13]?> 5 :: <?=$y[61]?>
</td></tr>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=2>
Transfer users and files to newest tables and places<br><br>
PLEASE WAIT - this page may reload many times, because transfer users by portion!!!
</td></tr>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=2>
<?
$str = '';$note='PHP is working in safe_mode, I can`t create directories and give chmod...<br>These directories don`t exist or don`t writeble:<br><br>';
if($from == '0') {
	if(ini_get('safe_mode'))
	{
		for($d1=0;$d1 <= $total; $d1+=10000)
		{
			$dir1 = intval($d1 / 10000);
			$dir = "members/uploads/" .  $dir1;
			if(!file_exists($dir) || !is_writable($dir) || !is_dir($dir))	$str .= ($str == '') ? $note.$dir . "<br>\n" : $dir . "<br>\n";
			for($d2=0;$d2 < 10000; $d2+=100)
			{
				$dir2 = intval($d2 / 100);
				$dir = "members/uploads/" .  $dir1 . "/" .  $dir2;
				if(!file_exists($dir) || !@is_writable($dir))	$str .= ($str == '') ? $note.$dir . "<br>\n" : $dir . "<br>\n";
			}
		}
		echo $str;
	}
	else {
		for($d1=0;$d1 <= $total; $d1+=10000)
		{
			$dir1 = intval($d1 / 10000);
			$dir = "members/uploads/" .  $dir1;
			if(!file_exists($dir) || !is_writable($dir) || !is_dir($dir))
			{
				umask(0);
				mkdir (C_PATH."/".$dir, 0777);
				echo "Created directory: ".$dir. "<br>\n";
			}
			for($d2=0;$d2 < 10000; $d2+=100)
			{
				$dir2 = intval($d2 / 100);
				$dir = "members/uploads/" .  $dir1 . "/" .  $dir2;
				if(!file_exists($dir) || !is_writable($dir) || !is_dir($dir))
				{
					umask(0);
					mkdir (C_PATH."/".$dir, 0777);
					echo "Created directory: ".$dir. "<br>\n";
				}
			}
		}
	}
	if($str != '') error('<br>Please correct all errors and refresh this page</td></tr></table></td></tr></table>');
	else {
		$cnt = 0;
		$tmp = mysql_query("SELECT id, pic1, pic2, pic3, audio FROM ".C_MYSQL_MEMBERS);
		$count = mysql_num_rows($tmp);
		while ($i = mysql_fetch_array($tmp))
		{
			$k = '';
			if (!empty($i['pic1']))
			{
				if (!file_exists(C_PATH.'/members/uploads/'.$i['pic1']))
				{
					$k .= "pic1 = '',";
					$cnt++;
				}
			}
			if (!empty($i['pic2']))
			{
				if (!file_exists(C_PATH.'/members/uploads/'.$i['pic2']))
				{
					$k .= "pic2 = '',";
					$cnt++;
				}
			}
			if (!empty($i['pic3']))
			{
				if (!file_exists(C_PATH.'/members/uploads/'.$i['pic3']))
				{
					$k .= "pic3 = '',";
					$cnt++;
				}
			}
			if (!empty($i['audio']))
			{
				if (!file_exists(C_PATH.'/members/uploads/'.$i['audio']))
				{
					$k .= "audio = '',";
					$cnt++;
				}
			}
			if (!empty($k))
			{
				mysql_query("UPDATE ".C_MYSQL_MEMBERS." SET ".substr($k,0,-1)." WHERE id='".$i['id']."'");
			}
		}
		print(C_MYSQL_MEMBERS.' with '.$count.' rows has been processed.<br><br>'.$cnt.' file fields have been cleaned from '.($count*4).' available<br><br>');

		### Remove unnedded thumbnails and files
		$cnt = 0;$files=array();$real=array();$remove=array();
		$tmp = mysql_query("SELECT pic1, pic2, pic3, audio FROM ".C_MYSQL_MEMBERS);
		$count = mysql_num_rows($tmp);
		while ($i = mysql_fetch_array($tmp))
		{
			$k = '';
			if (!empty($i['pic1']))
			{
				$files[]=$i['pic1'];
			}
			if (!empty($i['pic2']))
			{
				$files[]=$i['pic2'];
			}
			if (!empty($i['pic3']))
			{
				$files[]=$i['pic3'];
			}
			if (!empty($i['audio']))
			{
				$files[]=$i['audio'];
			}
		}
		$handle=opendir(C_PATH.'/members/uploads/');
		while (false!==($file = readdir($handle)))
		{
			if ($file != "." && $file != "..")
			{
				if(is_dir(C_PATH.'/members/uploads/'.$file))
				{
					$thandle=opendir(C_PATH.'/members/uploads/'.$file);
					while (false!==($tfile = readdir($thandle)))
					{
						if ($tfile != "." && $tfile != "..")
						{
							$real[]=$file.'/'.$tfile;
						}
					}
					closedir($thandle);
				}
				else
				{
					$real[]=$file;
				}
			}
		}
		closedir($handle);
		$remove = array_diff ($real, $files);
		$remove=array_values($remove);$str='';
		$p=0;$rfl=0;
		while(isset($remove[$p]))
		{
			$str .= $remove[$p].'<br>';
			if(!is_dir(C_PATH.'/members/uploads/'.$remove[$p]))
			{
				@unlink(C_PATH.'/members/uploads/'.$remove[$p]);
				$rfl++;
			}
			$p++;
		}
		print($rfl." unneeded files and thumbnails have been removed from server.");


	}
}
function getpics($pic,$id)
{
	$newpath = intval($id / 10000).'/'.intval(($id % 10000) / 100).'/'.intval($id).'_';
	$ret='';
	$p=0;while(isset($pic[$p])) {
		if($pic[$p] != '' && file_exists(C_PATH.'/members/uploads/'.$pic[$p])) {
			@copy(realpath(C_PATH.'/members/uploads/'.$pic[$p]),C_PATH.'/members/uploads/'.$newpath.$p);
			$ret.=$p.',';
		}
		$p++;}
		return substr($ret,0,-1);
}
function getaudio($audio,$id)
{
	$newpath = intval($id / 10000).'/'.intval(($id % 10000) / 100).'/'.intval($id);
	$ret='';
	if(trim($audio) != '' && file_exists(C_PATH.'/members/uploads/'.$audio) && is_file(C_PATH.'/members/uploads/'.$audio)) {
		@copy(C_PATH.'/members/uploads/'.$audio,C_PATH.'/members/uploads/'.$newpath.strstr($audio, '.'));
		$ret = substr(strstr($audio, '.'),1);
	}
	return $ret;
}
$tmp = mysql_query("SELECT * FROM ".C_MYSQL_MEMBERS." ORDER BY id ASC limit ".$from.",1000") or die(mysql_error());
$count = mysql_num_rows($tmp);
if($count != '0')
{
	$query1 = $query2 = $query3 = '';
	while($i=mysql_fetch_array($tmp))
	{
		$query1 .= "('".$i['id']."','".$i['username']."','".$i['fname']."','".$i['lname']."','".$i['birthday']."','".$i['gender']."', '0','0','".$i['purposes']."','".$i['country']."','".$i['city']."','".$i['zip']."','".$i['height']."','".$i['weight']."','".$i['sgender']."','".getpics(array($i['pic1'],$i['pic2'],$i['pic3']),$i['id'])."','".$i['horo']."','".$i['regdate']."','".$i['editdate']."','1','".$i['hits']."','".$i['hits_count']."','".$i['status']."','0','1','0','".$i['req']."'),";
		$query2 .= "('".$i['id']."','".$i['url']."','".$i['icq']."','".$i['aim']."','".$i['phone']."','','".$i['address']."','".$i['marstat']."','".$i['child']."','".$i['hcolor']."','".$i['ecolor']."','".$i['etnicity']."','".$i['religion']."','".$i['smoke']."','".$i['drink']."','".$i['education']."','".$i['languages']."','','".$i['mylang']."','".$i['job']."','".$i['hobby']."','".$i['descr']."','','".$i['scountry']."','".$i['smarstat']."','".$i['schild']."','".$i['shcolor']."','".$i['secolor']."','".$i['ssmoke']."','".$i['sdrink']."','".$i['seducation']."','".$i['setnicity']."','".$i['sreligion']."','".$i['agef']."','".$i['aget']."','".$i['heightf']."','".$i['heightt']."','".$i['weightf']."','".$i['weightt']."','".$i['hdyfu']."','".getaudio($i['audio'],$i['id'])."','".$i['status']."'),";
		$query3 .= "('".$i['id']."','".$i['password']."','".$i['email']."','0','0','".$i['ip']."','".$i['prv']."','','0','','".$i['status']."'),";
?>


<?
	}
	echo 'Data transfer - please be patience...<br><br>';
	@mysql_query("LOCK TABLES ".C_MYSQL_MEMBERS_MAIN.",".C_MYSQL_MEMBERS_EXT.",".C_MYSQL_MEMBERS_SEC." WRITE");
	@mysql_query("INSERT INTO ".C_MYSQL_MEMBERS_MAIN." VALUES ".substr($query1,0,-1));
	@mysql_query("INSERT INTO ".C_MYSQL_MEMBERS_EXT." VALUES ".substr($query2,0,-1));
	@mysql_query("INSERT INTO ".C_MYSQL_MEMBERS_SEC." VALUES ".substr($query3,0,-1));
	@mysql_query("UNLOCK TABLES");
	echo 'Page reloading for load next data portion - please be patience...';
	GoToURL(C_URL.'/install.php?step=5&insttype='.$insttype.'&from='.($from+1000).'&PLEASE_WAIT!');
} else {
?>

<form method="Post" action="install.php?step=6" name="form">
<input type="hidden" name="insttype" value="<?=$insttype?>" size="0" maxlength="0">
<?='<input type="submit" class=button id=but2 onmouseover=bc(this,"'.COLOR2.'") onmouseout=bc(this,"'.COLOR1.'") href="javascript:;" value="'.$y[24].' 6" name="submit">';?>
<?
}
?>
</td></tr></table>

<?} else {?>
<form method="Post" action="install.php?step=6" name="form">
<input type="hidden" name="insttype" value="<?=$insttype?>" size="0" maxlength="0">
<?='<input type="submit" class=button id=but2 onmouseover=bc(this,"'.COLOR2.'") onmouseout=bc(this,"'.COLOR1.'") href="javascript:;" value="'.$y[24].' 6" name="submit">';?>
<?
}
break;
######################################
#   S T E P - 6 [Last info]
######################################

	case '6':


		if(!is_numeric($insttype)) $insttype=0;

		include_once 'include/options.inc.php';
		include_once 'include/functions.inc.php';

		$ine = (mysql_get_client_info() >= '3.23') ? 'IF NOT EXISTS ' : '';
?>

<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td>
<Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes>
<Tr bgcolor="<?=COLOR3?>"><Td colspan=2>
:: <?=$y[13]?> 6 :: Installation results
</td></tr></Table></td></tr></Table>

<br>
<br>
<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td><Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes><Tr bgcolor="<?=COLOR3?>" align=center><Td colspan=2><?=$y[66]?></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td><?=$y[66]?></td><td><span class=ok><?=$y[67]?></span></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center><td><?=$y[68]?></td><td><a href="<?php echo C_URL.'/admin.php';?>" target="_blank"><?php echo C_URL.'/admin.php';?></a></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td><?=$y[69]?></td><td><a href="<?php echo C_URL.'/index.php';?>" target="_blank"><?php echo C_URL.'/index.php';?></a></td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center><td><?=$y[70]?></td><td><span class=false><?=$y[71]?></span></td></tr></Table></td></tr></Table>
<br>
<br>
<Table CellSpacing="1" CellPadding="0" width="600" bgcolor="black"><Tr><Td><Table Border=0 CellSpacing="1" CellPadding="4" width="600" class=mes><Tr bgcolor="<?=COLOR3?>" align=center><Td colspan=2>Documentation and FAQ</td></tr>
<Tr bgcolor="<?=COLOR1?>" align=center><td>Documentation</td><td><a href="http://www.azdg.com/help/?script=AzDGDatingMedium" target="_blank">http://www.azdg.com/help/?script=AzDGDatingMedium</a></td></tr>
<Tr bgcolor="<?=COLOR4?>" align=center><td>FAQ</td><td><a href="http://www.azdg.com/faq/?script=AzDGDatingMedium" target="_blank">http://www.azdg.com/faq/?script=AzDGDatingMedium</a></td></tr>
<?
vars_write("include/options.inc.php","C_MAINTENANCE_MODE","0");
break;
}?>
</td></tr></Table>
<?die;?>
