<?php
error_reporting(1);
ini_set('display_errors', 1);
session_start();
$get["step"] = isset($_GET["step"]) ? strtolower($_GET["step"]) : FALSE; 
$get["action"] = isset($_GET["action"]) ? strtolower($_GET["action"]) : FALSE;
$blocked["names"] = array('Js', 'Css', 'Core', 'Media', 'Install', 'Images');

if(is_numeric($get["step"]) == false)
{
	echo '<script>window.location.href = "site/install.php?step=1";</script>';
}

function updateWeb($wName, $wUrl)
{
	include("../core/config/mysql.config.php");
	$sql = @mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD);
	$db = @mysql_select_db(DB_NAME);
	if($sql && $db)
	{
		$_SESSION['link'] = $wUrl;
		$web_query = mysql_query("INSERT INTO site_config (website_name, website_domain) VALUES ('$wName', '$wUrl')");	
		if($web_query)
		{
			echo '<script>window.location.href = "install.php?step=5";</script>';
		}
		else
		{
			$web_query = mysql_query("DELETE FROM site_config WHERE 1=1");
			if($web_query)
			{
				updateWeb($wName, $wUrl);
			}
			else
			{
				echo "Clear database from previous installation!";
			}
		}
	}
}

function getstructure()
{
	include("../core/config/mysql.config.php");
	$c = 0;
	$sql = @mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD);
	$db = @mysql_select_db(DB_NAME);
	if($sql && $db)
	{
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `comments` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `post_id` int(50) NOT NULL, `comment` text NOT NULL, `anonymous` set('0','1') NOT NULL, `to_user` varchar(50) NOT NULL, `from_user` varchar(50) NOT NULL, `post_user` varchar(25) NOT NULL, `time` int(20) NOT NULL, `viewed` set('0','1') NOT NULL, PRIMARY KEY (`id`), KEY `id` (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `gifts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `to_user` varchar(50) NOT NULL, `from_user` varchar(50) NOT NULL, `gift_id` int(11) NOT NULL, `type` enum('0','1','2') NOT NULL COMMENT '0-anonym 1-public only for user 2-public', `text` varchar(50) NOT NULL, `time` varchar(30) NOT NULL, `position_x` int(11) NOT NULL, `position_y` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `id` (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `giftstype` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(25) NOT NULL, `image` varchar(80) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `likes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `post_id` int(11) NOT NULL, `user` varchar(25) NOT NULL, `to_user` varchar(25) NOT NULL, `post_user` varchar(25) NOT NULL, `viewed` int(11) NOT NULL, `time` int(20) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `payments` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` varchar(40) NOT NULL, `transaction_id` varchar(80) NOT NULL, `payer_email` varchar(80) NOT NULL, `user` varchar(80) NOT NULL, `quantity` int(11) NOT NULL, `date` varchar(30) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `paypal_settings` ( `pay_mode` varchar(30) NOT NULL COMMENT 'sandbox or live', `apiusername` varchar(80) NOT NULL, `apipassword` varchar(80) NOT NULL, `apisignature` varchar(80) NOT NULL, `currencycode` varchar(10) NOT NULL, `price` float NOT NULL, `enabled` enum('0','1') NOT NULL DEFAULT '0') ENGINE=InnoDB DEFAULT CHARSET=utf8;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `posts` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `to_user` varchar(400) NOT NULL, `post` text NOT NULL, `image` varchar(80) NOT NULL, `from_user` varchar(100) NOT NULL, `status` set('0','1') NOT NULL, `viewed` set('0','1') NOT NULL, `anonymous` set('0','1') NOT NULL, `ip` varchar(30) NOT NULL, `time` varchar(30) NOT NULL, PRIMARY KEY (`id`), KEY `id` (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `site_config` ( `website_name` varchar(500) NOT NULL, `website_domain` text NOT NULL, `website_keywords` text NOT NULL, `website_description` text NOT NULL, `website_free_points` set('0','1') NOT NULL DEFAULT '1', `website_gift_price` int(11) NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(100) NOT NULL, `password` text NOT NULL, `real_name` varchar(400) NOT NULL, `real_surname` varchar(400) NOT NULL, `points` int(11) NOT NULL, `rank` enum('0','1','2') NOT NULL, `verified` enum('0','1') NOT NULL DEFAULT '0', `email` varchar(200) NOT NULL, `website` varchar(300) NOT NULL, `localization` varchar(300) NOT NULL, `bio` text NOT NULL, `user_status` varchar(400) NOT NULL, `theme` enum('default','background','agenda','birch','birds','blackcross','blackromb','bluebulles','bluemettal','cyanmettal','greenlines','greenmettal','greymettal','ice','isumrudic','lined_paper','mosaic','noisygrid','notes','orangelines','paper','pink','pinkmettal','pinstripe','redcircle','redmettal','vintage','whitemosaic','whitestripped','wood','yellowmettal','photo') NOT NULL, `background` text NOT NULL, `photo` text NOT NULL, `cover` varchar(80) NOT NULL, `status` enum('0','1') NOT NULL, `ip` varchar(50) NOT NULL, `anonymous_view` enum('0','1') NOT NULL, `reg_date` varchar(20) NOT NULL, `lang` varchar(2) NOT NULL DEFAULT 'en', `visit` int(20) NOT NULL, `facebook` varchar(500) NOT NULL, `vkontakte` varchar(500) NOT NULL, `twitter` varchar(500) NOT NULL, `googleplus` varchar(500) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`), KEY `id` (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `users_blocked` (`id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(400) NOT NULL, `blocked` varchar(400) NOT NULL, `status` enum('0','1') NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4;");
		if($query) $c++;
		$query = mysql_query("CREATE TABLE IF NOT EXISTS `users_friends` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(400) NOT NULL COMMENT 'User name', `friend` varchar(400) NOT NULL COMMENT 'Friend user name', `status` enum('0','1') NOT NULL COMMENT '1 - is friend, 0 - deleted from friend list', `time` int(20) NOT NULL, PRIMARY KEY (`id`), KEY `username` (`username`(255))) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
		if($query) $c++;
		$query = mysql_query("INSERT INTO `paypal_settings` (`pay_mode`, `apiusername`, `apipassword`, `apisignature`, `currencycode`, `price`, `enabled`) VALUES ('sandbox', ' ', ' ', ' ', 'USD', 0.5, '0');");
		if($query) $c++;
		if($c==12)
		{
			return 1;
		}
		else return 0;
	}
}

function crypts($encrypt_val, $mode, $brute_pass)
	{
		if(strlen($encrypt_val) < 0)
		{
			return;
		}
		if($brute_pass != 0 && strlen($encrypt_val) > 0 || strlen($encrypt_val) < 800)
		{
			switch($mode)
			{
				case 1:		
				case "MD5":		return md5($encrypt_val);
								break;
				case 2:
				case "BASE_64":	return base64_encode($encrypt_val);
								break;
				case 3:
				case "SHA1":	return sha1($encrypt_val);
								break;
				default:		return 0;
								break;
			}
		}
		else if($brute_pass != 1)
		{
			return sha1(base64_encode(md5($encrypt_val)));
		}
	}

function addgifts()
{
	include("../core/config/mysql.config.php");
	$c = 0;
	$sql = @mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD);
	$db = @mysql_select_db(DB_NAME);
	if($sql && $db)
	{
		for($i=1;$i<103;$i++)
		{
			if($i>0 && $i<10) $counts = "00".$i;
			if($i>9 && $i<100) $counts = "0".$i;
			if($i>99) $counts = $i;
			$query = mysql_query("INSERT INTO giftstype (name, image) VALUES ('gift_".$counts."', '".$counts.".png')");
			if($query) $c++;
		}
		if($c=="102")
		{
			echo '<script>window.location.href = "install.php?step=5&gifts=done";</script>';
		}
		echo '<script>window.location.href = "install.php?step=5&total='.$c.'";</script>';
	}
}

function createMyAdmin($username, $password, $name, $email)
{
	include("../core/config/mysql.config.php");
	$sql = @mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD);
	$db = @mysql_select_db(DB_NAME);
	if($sql && $db)
	{
		$username = ucfirst(strtolower($username));
		$pass = crypts(crypts(crypts($password, "MD5", 0), 2, 0), "SHA1", 0);
		$name = ucfirst(strtolower($name));
		$IP_ADD = getenv("REMOTE_ADDR");
		$date = date("d-m-Y");
		$MySQL_Message["user"] = "INSERT INTO users ";
		$MySQL_Message["user"] .= "(username, password, real_name, real_surname, points, rank, email, website, localization, bio, user_status, theme, photo, cover, status, ip, anonymous_view, reg_date) ";
		$MySQL_Message["user"] .= "VALUES ";
		$MySQL_Message["user"] .= "('$username', '$pass', '$name', '', '99', '2', '$email', ";
		$MySQL_Message["user"] .= "'', '', '', '', 'default', 'photo_default.png', '', ";
		$MySQL_Message["user"] .= "'1', '$IP_ADD', '1', '$date')";
		$user_query = mysql_query($MySQL_Message["user"]);
		if($user_query)
		{
			echo '<script>window.location.href = "install.php?step=4";</script>';
		}
		else
		{
			$MySQL_Message["user"] = "DELETE FROM users WHERE 1=1";
			$user_query = mysql_query($MySQL_Message["user"]);
			if($user_query)
			{
				createMyAdmin($username, $password, $name, $email);
			}
			else
			{
				echo "Clear database from previous installation!";
			}
		}
	}
	
}

function bruteError()
{
	return '<p><h3>Oops! Error !</h3>Unknown Error <a href="install.php?step=1">Start new installation</a>.';
}

function createConfig($dbServer, $dbUser, $dbPass, $dbDatabase)
{
	$filename = '../core/config/mysql.config.php';
	$save = "<?php
			define('DB_SERVER', '$dbServer');
			define('DB_USERNAME', '$dbUser');
			define('DB_PASSWORD', '$dbPass');
			define('DB_NAME', '$dbDatabase');	
			?>";
	if (is_writable($filename)) {
		if (!$handle = fopen($filename, 'w')) {
			 echo "Cannot open file ($filename)";
			 exit;
		}
		if (fwrite($handle, $save) === FALSE) {
			echo "Cannot write to file ($filename)";
			exit;
		}
		fclose($handle);
	} 
	else 
	{
		echo "The file $filename is not writable";
	}
}

function addhtml($mode)
{
	if(empty($mode))
	{
		return '';
	}
	$mode = strtolower($mode);
	$message = '';
	if(isset($mode))
	{
		if($mode == "header")
		{
			$message .= "<html>";
			$message .= "<head>";
			$message .= "<title>WebWall - Installation</title>";
		}
		elseif($mode == "css")
		{
			require_once 'style.css';
		}
		elseif($mode == "body")
		{
			$message .= "</head>";
			$message .= "<body>";
			$message .= "<div class='w'>";
			$message .= "<div class='i'>";
		}
		elseif($mode == "footer")
		{
			$message .= "<center>";
			for ($i = 0; $i <= 80; $i++) 
			{	
				$message .= "_"; 
			}
			$message .= "<br>";
			$message .= '<a href="http://xandr.me" style="text-decoration:none" target="_blank"><span class="logox">X</span></a>';
			$message .= "<small>WebWall v1.0 &copy; 2014</small>";
			$message .= "</center>";
			$message .= "</div>";
			$message .= "<br>";
			$message .= "</div>";
			$message .= "</body>";
			$message .= "</html>";
		}
		if($mode != "css")
		{
			return $message;
		}
	}
}

echo(addhtml("header"));
addhtml("css"); 
echo(addhtml("body")); 

if($get["step"] > 0 && $get["step"] < 6) { ?>
<?php if($get["step"] == 1) { ?> 
	<img src="../install/logo.png" class="startlogo">
	<h2>Wellcome to WebWall!</h2>	
	<hr>
	<p>Thank you for purchasing WebWall licence!</p>
	<hr>
	<div style="width:80%;margin-left:10%;background-color:rgba(255,255,255,0.8)">
		<h1>Requirements:</h1>
		<div style="display:inline-block;width:45%;padding:10px">
			<b>Server side:</b><br>
			- PHP 5.3<br>
			- MySQL 5.x<br>
			- GD Library<br>
			- htaccess<br>
			<span style="color:red;font-size:13px">* This are minimal requirements. Application requires high parameters for database. If application will use more than 500 online users will be needed dedicated server. With free hosting it will work for under 100 online users.</span>
		</div>
		<div style="display:inline-block;width:45%;padding:10px">
			<b>Client side:</b><br>
			- Internet access<br>
			- Browser application<br>
			<img src="../install/chrome.png"> 
			<img src="../install/opera.png"> 
			<img src="../install/mozilla.png"> 
			<img src="../install/safari.png"><br>
			<span style="color:red;font-size:13px">* Application was developed for Chrome using. For normal using is needed display resolution from 960 px in width. For mobile devices can be developed mobile version or responsive design. This feature may appear in next versions.</span>
		</div>
	</div>
	<br>
	<a class="btn" href="http://<?php echo $_SERVER["SERVER_NAME"]; ?>/site/install?step=2">Start installation</a>
	<br>

        
<?php } elseif($get["step"] == 2) { ?>   
		<h1 style="text-align:left;padding-left:30px">
			<img src="../install/logo.png" class="secondlogo">    
			<span style="line-height:3em">Database connection. MySQL database</span>
			<span style="float:right;margin:10px"><span class="step" style="background-color:green">1</span><span class="step">2</span><span class="step">3</span><span class="step">4</span></span>
		</h1>
		<br>
		<p>
        	WebWall use database. Please, create database for next using WebWall.<br> 
        	Find on Google how to create it or contact hosting support.<br>
        	At this step will be needed created database with user with all privilegies.<br>
        	<span class="extra">Attention!</span> Verify if database exists!
		</p>
		<?php
			$filename = '../core/config/mysql.config.php';
			if (is_writable($filename)) 
			{
				echo '<center>';
				if($get["action"] == "db")
				{
					if(!empty($_POST["db_server"]) || !empty($_POST["db_user"]) || !empty($_POST["db_pass"]) || !empty($_POST["db_database"]))
					{
						$con = mysql_connect($_POST["db_server"], $_POST["db_user"], $_POST["db_pass"]);
						if($con)
						{
							$db = mysql_select_db($_POST["db_database"], $con);
							if($db)
							{
								createConfig($_POST["db_server"], $_POST["db_user"], $_POST["db_pass"], $_POST["db_database"]);
								if(getstructure())
								{
									echo '<script>window.location.href = "install.php?step=3";</script>';
								}
								else
								{
									echo('<font color="red"><b>Error</b> - Unable to create database structure.</font>'); 
								}
							}
							else 
							{ 
								echo('<font color="red"><b>Error</b> - Unable to connect to database, please check your name and if the database exists.</font>'); 
							}
						}
						else 
						{ 
							echo('<font color="red"><b>Error</b> - Could not connect to MySQL, please check your data is entered correctly.</font>'); 
						}
					}
					else 
					{ 
						echo('<font color="red"><b>Error</b> - All fields must be completed.</font>'); 
					}
				}
				echo '<form action="install.php?step=2&action=db" method="post">
						MySQL Host Name<br>
						<input name="db_server" type="text" class="textfields" value="localhost" size="40" placeholder="MySQL Host Name">
						<br>
						MySQL Username<br>
						<input name="db_user" type="text" class="textfields" value="" size="40" placeholder="MySQL Username">
						<br>
						MySQL Password<br>
						<input name="db_pass" type="text" class="textfields" value="" size="40" placeholder="MySQL Password">
						<br>
						Database Name<br>
						<input name="db_database" type="text" class="textfields" value="" size="40" placeholder="Database Name">
						<br><br>
						<input name="submit" class="btn" type="submit" value="Continue"> &nbsp; &nbsp; <input name="reset" class="btn" type="reset" value="Reset">
					   </form>
					   </center>';
			} 
			else
			{
				echo '<p><span style="color:red"> ATTENTION! File "mysql.config" (core/config/mysql.config) is NOT avaible for editing! You can not continue installation! Change file permission for core folder, config folder and mysql.config file into 777. After installation restore it like was at start.</span></p>';
				echo '<p><a href="http://www.dummies.com/how-to/content/how-to-change-file-permissions-using-filezilla-on-.html" target="_blank">How to change file permissions</a></p>';
			} 
		?>
		<p></p>
        
		<?php } elseif($get["step"] == 3){ ?>
        <h1 style="text-align:left;padding-left:30px">
			<img src="../install/logo.png" class="secondlogo">    
			<span style="line-height:3em">Administrator account.</span>
			<span style="float:right;margin:10px"><span class="step">1</span><span class="step" style="background-color:green">2</span><span class="step">3</span><span class="step">4</span></span>
		</h1>
		<br>
        Congratulations, connection to the database is successful.<br>
        Now you will create an administrator account. Please, remember username and password for it.<br>
        Through this account, you will have access to the administration panel.<br>
        <span class="extra">Attention: </span>Username must contain only letters or numbers.<br>
		</p>
        <center>
        
		<?php
		if($get["action"] == "adm")
		{
			if(!empty($_POST["adm_username"]) || !empty($_POST["adm_pass"]) || !empty($_POST["adm_name"]) || !empty($_POST["adm_email"]))
			{
				$admUser = ucfirst(strtolower($_POST["adm_username"]));
				if(!in_array($admUser, $blocked["names"]))
				{
					if(!strstr($_POST["adm_username"], ' '))
					{
						createMyAdmin($_POST["adm_username"], $_POST["adm_pass"], $_POST["adm_name"], $_POST["adm_email"]);
					}
					else 
					{ 
						echo('<font color="red"><b>Error</b> - Invalid characters in the username.</font>'); 
					}				
				}
				else 
				{ 
					echo('<font color="red"><b>Erroe=r</b> - This username is blocked, choose another.</font>'); 
				}
			}
			else 
			{ 
				echo('<font color="red"><b>Error</b> - All fields must be completed.</font>'); 
			}
		}
		?>
        <form action="install.php?step=3&action=adm" method="post">
        Username<br>
        <input name="adm_username" type="text" class="textfields" value="" size="40" maxlength="32" placeholder="Username">
        <br>
        Password<br>
        <input name="adm_pass" type="text" class="textfields" value="" size="40" placeholder="Password">
        <br>
        Real name<br>
        <input name="adm_name" type="text" class="textfields" value="" size="40" placeholder="Real name">
        <br>
        Email<br>
        <input name="adm_email" type="text" class="textfields" value="mail@sasha-k.ru" size="40" placeholder="Email address">
        <br><br>
        <input name="submit" class="btn" type="submit" value="Continue"> &nbsp; &nbsp; <input name="reset" class="btn" type="reset" value="Reset">
        </form>
		</center>
		<p></p>
        <?php } elseif($get["step"] == 4){ ?>
        <h1 style="text-align:left;padding-left:30px">
			<img src="../install/logo.png" class="secondlogo">    
			<span style="line-height:3em">Site configuration</span>
			<span style="float:right;margin:10px"><span class="step">1</span><span class="step">2</span><span class="step" style="background-color:green">3</span><span class="step">4</span></span>
		</h1>
		<br>
		<p>
		Congratulations, administration account was created successful.<br>
        Now, you need to introduce information about site name and site domain.<br> 
		This information can be changed in administration panel.
        <br>
		</p>
        <center>
        <?php
        if($get["action"] == "web")
		{
			if(!empty($_POST["web_name"]) || !empty($_POST["web_url"]))
			{
				if(empty($_POST["web_name"]))
				{
					echo('<font color="red"><b>Erro</b> - All fields must be completed.</font>');			
				}
				else
				{
					updateWeb($_POST["web_name"], $_POST["web_url"]);
				}
			}
			else 
			{ 
				echo('<font color="red"><b>Error</b> - All fields must be completed.</font>'); 
			}
		}
		?>
        <form action="install.php?step=4&action=web" method="post">
        Website name<br>
        <input name="web_name" type="text" class="textfields" value="" size="40" placeholder="Website name"><br>
        <font size="2">For example: WebWall</font>
        <br><br>
        URL / Website domain<br>
        http:// <input name="web_url" type="text" class="textfields" value="" size="40" placeholder="mysite.com">/
        <br>
        <font size="2">Introduce only part between <b>http://</b> and <b>/</b></font>
        <br><br>
        <input name="submit" class="btn" type="submit" value="Continue"> &nbsp; &nbsp; <input name="reset" class="btn" type="reset" value="Reset">
        </form>
		</center>
		<p></p>
        <?php } elseif($get["step"] == 5){ ?>
			<?php
			if($get["action"] == "gifts")
			{
				addgifts();
			}
			?>
        <h1 style="text-align:left;padding-left:30px">
			<img src="../install/logo.png" class="secondlogo">    
			<span style="line-height:3em">Finish installation</span>
			<span style="float:right;margin:10px"><span class="step">1</span><span class="step">2</span><span class="step">3</span><span class="step" style="background-color:green">4</span></span>
		</h1>
		<br>
		<p>
        Congratulations, WebWall was installed successful.<br>
        Enjoy it :)<br>
       <p>
        <center>
        <?php 
		include("../core/media/website.config.php");
		?>
        <a href="http://<?php echo $_SESSION['link']; ?>/" class="btn">Main page</a>&nbsp;&nbsp; - &nbsp;&nbsp; <a href="http://<?php echo $_SESSION['link']; ?>/account/login" class="btn">Login</a>
		<br><br>
        <span class="extra">Attention!</span> For security reasons rename or delete INSTALL folder.
		<br>
		<?php if($_GET['gifts']=='done') { ?>
			<span class="extra">Gift package installed :)</span><br>	
		<?php } else { ?>
		<span class="extra">Also</span> You can install for free 102 gifts on your site!<br>
		<br>
		<form action="install.php?step=5&action=gifts" method="post">
			<input name="install" class="btn" type="submit" value="Install 102 free gifts" onclick="this.style.display='none'; var e=document.getElementById('loading'); e.style.display='block';">
			<p id="loading" style="display:none;"><br><img src="../media/images/loading.gif" /><br>Please waiting :)</p>
		</form>
		<?php }?>
        <?php } ?>
        
<?php } else { echo(bruteError()); } ?>
<?php 
echo(addhtml("footer")); ?>