<div>
    <div class="">
        <div class="">
            <form role="form" method="post" action="">
				<div class="page-hd" style="background-image: url(<?php print $site_url; ?>images/recovery.png)">
					<div class="bd-c">
						<h2 class="pre-social"><?php if($message==7) print 'Schimbare cod PIN'; else print 'Recuperare cod PIN'; ?></h2>
					</div>
				</div>
				<div class="content-body">
				<?php
					if(isset($_GET['email']) && isset($_GET['code']) && !empty($_GET['email']) && !empty($_GET['code']) && isValidEmail($_GET['email']))
					{
						if($message==6)
						{
							print '<div class="alert alert-danger alert-dismissible fade in" role="alert">
							  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							  </button>';
							print $lang['incorrect-recovery'];
							print '</div>';
						}
						else if(isset($_POST['password']) && isset($_POST['rpassword']) && $message==9)
						{
							$message = 7;
							print '<div class="alert alert-danger alert-dismissible fade in" role="alert">
							  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							  </button>';
							print 'Codul PIN introdus nu se potrivește cu cel introdus anterior. Te rugăm să încerci din nou!';
							print '</div>';
						}
						else if(isset($_POST['password']) && isset($_POST['rpassword']) && $message==8)
						{
							$message = 11;
							print '<div class="alert alert-success alert-dismissible fade in" role="alert">
							  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							  </button>';
							print 'Codul PIN a fost schimbat cu success!';
							print '</div>';
						}
						else if(isset($_POST['password']) && isset($_POST['rpassword']) && $message==10)
						{
							$message = 7;
							print '<div class="alert alert-danger alert-dismissible fade in" role="alert">
							  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							  </button>';
							print 'Codul PIN introdus nu este valid.';
							print '</div>';
						}
					} else if(isset($_POST['username']) && isset($_POST['email']) && isset($_POST['captcha']))
					{
						if($message==5)
						{
							print '<div class="alert alert-danger alert-dismissible fade in" role="alert">
							  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							  </button>';
							print $lang['incorrect-security'];
							print '</div>';
						}
						else {
							print '<div class="alert alert-info alert-dismissible fade in" role="alert">
							  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							  </button>';
							print $lang['email-recovery'];
							print '</div>';
							
							if($message==1)
							{
								$alt_message = $lang['code-delete-chars'];
								$subject = $lang['account-recovery'];
								$sendName = $_POST['username'];
								$sendEmail = $_POST['email'];
								
								$code = generateSocialID(32);
								update_passlost_token($_POST['username'], $code);
								$html_mail = recoveryPIN($code, $_POST['email'], $_POST['username']);
								include 'include/functions/sendEmail.php';
							}
						}
					}
					require 'include/captcha/simple-php-captcha.php';
					$_SESSION['captcha_lost'] = simple_php_captcha();
					
				if($message!=11) {
				?>
				<table class="table table-responsive-md ranking">
					<tbody>
						<?php if($message==7) { ?>
						<tr>
							<td>Cod PIN:</td>
							<td><input class="form-control" name="password" id="password" pattern=".{4,4}" maxlength="4" placeholder="****" required="" type="password"></td>
						</tr>
						<tr>
							<td>Repetă codul PIN:</td>
							<td><input class="form-control" name="rpassword" id="rpassword" pattern=".{4,4}" maxlength="4" placeholder="****" required="" type="password">
							<p class="text-danger" id="checkpassword"></p>
							</td>
						</tr>
						<?php } else { ?>
						<tr>
							<td><?php print $lang['user-name']; ?>:</td>
							<td><input class="form-control" name="username" pattern=".{5,16}" maxlength="16" pattern="[A-Za-z0-9]" placeholder="<?php print $lang['user-name']; ?>..." required="" title="Între 5 și 16 caractere permise." type="text" autocomplete="off"></td>
						</tr>
						<tr>
							<td><?php print $lang['email-address']; ?>:</td>
							<td><input class="form-control" name="email" pattern=".{7,64}" maxlength="64" placeholder="<?php print $lang['email-address']; ?>" required="" title="Maxim 64 caractere." type="email"></td>
						</tr>
						<tr>
							<td><?php print '<img src='.$_SESSION['captcha_lost']['image_src'].'>'; ?></td>
							<td><input style="height:70px; font-size: 30px;" class="form-control" name="captcha" pattern=".{4,6}" maxlength="5" placeholder="<?php print $lang['captcha-code']; ?>" required="" title="Maxim 15 caractere." type="text"></td>
						</tr>
						<?php } ?>
					</tbody>
				</table>
				<hr>
				<input type="submit" value="<?php if($message==7) print 'Schimbă codul PIN'; else print 'Recuperare cod PIN'; ?>" class="btn btn-<?php if($message==7) print 'success'; else print 'info'; ?> btn-lg btn-block" tabindex="7">
			<?php } ?>
            </div>
            </form>
        </div>
    </div>
</div>