<?php 

/**
 * 
 * Index Page 
 * Activation Page
 * Login Page
 * Admin Page
 * Book Page
 * Cookies Page
 * Terms Page
 * Privacy Page
 * Search Page
 * Password Reset Page
 * 
 */

// Index Page
if($page == 'index'){ // First page from website is here
if($_SESSION['uid']){

?>

<div class="w3-row w3-margin-bottom w3-hide-small w3-hide-medium">

<div class="w3-container w3-bluepm" style="margin-top:0px;padding-top:5px;padding-bottom:5px;">
<?php include THM.$set['theme'].'/searchform.php'; ?>
</div>

</div>

<?php
echo '<div class="w3-row w3-margin-bottom">';

echo '<div class="w3-half">';

echo '<div class="w3-row">';

echo '<div class="w3-container">';
$time = date("H");    
    $timezone = date("e");    
    if ($time < "10") {
        $hello = $lng['good_morning'];
    } else    
    if ($time >= "10" && $time < "18") {
        $hello = $lng['good_day'];
    } else    
    if ($time >= "18" && $time < "20") {
        $hello = $lng['good_evening'];
    } else    
    if ($time >= "20") {
        $hello = $lng['good_evening'];
    }

echo '<h2 class="w3-center">'.$hello.', ';

if(!empty($_SESSION['first_name'])){
    echo $_SESSION['first_name'];
    }else{
        $grun = explode('-', $_SESSION['user_name']);
        echo $grun[0];}

echo '!</h2>';

echo $lng['msj_welcome'];

echo '<h3>'.$lng['home_status'].'</h3>';
include(BASE);
$cuchmp = $dbc->query("SELECT COUNT(*) 
                                AS cucbk 
                              FROM `champions` 
                             WHERE `uid`='".$_SESSION['uid']."'");
$curch = $cuchmp->fetch_assoc();
$cucch = $curch['cucbk'];
$procent_chmp = '10';

$cupair = $dbc->query("SELECT COUNT(*) 
                                AS cuprc 
                              FROM `pairs` 
                             WHERE `uid`='".$_SESSION['uid']."'");
$curpr = $cupair->fetch_assoc();
$cucpr = $curpr['cuprc'];
$procent_pair = '5';

$scor_champ = $cucch * $procent_chmp;
$scor_pairs = $cucpr * $procent_pair;
$scor_total = $scor_champ + $scor_pairs;

$sufc = $dbc->query("SELECT * FROM users WHERE uid='{$_SESSION['uid']}' LIMIT 1");
$ufc = $sufc->fetch_assoc();
$dbc->close();

echo '<h5>'.$lng['champs_capital'].' ('.$cucch.'/5), '.$lng['pairs_capital'].' ('.$cucpr.'/10)</h5>';

echo '<div class="w3-col l12 m12 s12">';
echo '<div class="w3-section w3-pale-red w3-tiny"><div class="w3-container w3-padding-tiny w3-green w3-center" style="width:'.$scor_total.'%">'.$scor_total.'%</div></div>';
echo '</div>';

echo '<p class="w3-container w3-center">
<a class="w3-button w3-bluepm w3-hover-seagreen" href="'.BASE_URL.PATH.$ufc['user_name'].'.html" style="text-decoration:none;">'.$lng['gotopage_button'].'</a>
</p>';

echo '</div></div></div>';

echo '<div class="w3-half w3-card_" style="max-width:100%;height:auto;">';

if($set['map'] == '1'){
    
    if(file_exists(THM.$set['theme'].'/maps/eumap.php')){
   include THM.$set['theme'].'/maps/eumap.php';
         }else{
           echo '<div class="w3-center w3-padding-64"><h3>'.$lng['alert_nomap'].'</h3></div>';
         }
         
}

if($set['map'] == '2'){
    
    $setmap = 'Romania';
$rwco['country_code'] = 'ro';
$rwco['country_name'] = 'Romania';
include THM.$set['theme'].'/maps/countrymap.php';

}

echo '</div>';

echo '</div>';

   }else{ ?><div class="w3-row w3-margin-bottom w3-hide-small w3-hide-medium"><div class="w3-container w3-bluepm" style="margin-top:0px;padding-top:5px;padding-bottom:5px;"><?php include THM.$set['theme'].'/searchform.php'; ?></div></div><?php    
echo '<div class="row w3-margin-bottom"">';


echo '<div class="w3-half">';
echo '<div class="w3-row">';
echo '<div class="w3-container">';
echo '<h2 class="w3-center">'.$lng['cpt_welcome'].'</h2>';

echo $lng['msj_welcome'];
if(!empty($set['reg'])){
?>

<div class="w3-row w3-center"><h2 class="w3-bluepm_"><a onclick="document.getElementById('dsf45gff3r4tygdf65').style.display='block'" class="w3-button w3-block_ w3-bluepm w3-hover-seagreen w3-padding-small"><i class="fa fa-user-plus"></i> <?=$lng['form_create_account']?></a></h2><?php // Error Notice
include_once(FORM);

if(isset($fn_err)){echo '<div class="w3-panel w3-red"><h5>'.$fn_err.'</h5></div>';}
if(isset($ln_err)){echo '<div class="w3-panel w3-red"><h5>'.$ln_err.'</h5></div>';}
if(isset($e_err)){echo '<div class="w3-panel w3-red"><h5>'.$e_err.'</h5></div>';}
if(isset($err_exist)){echo '<div class="w3-panel w3-red"><h5>'.$err_exist.'</h5></div>';}

if(isset($completed)){
echo '<a href="'.PATH.'">';

echo '<div style="position:fixed;top:0;left:0;background-color: #107493; opacity:0.5;filter: alpha(opacity=50); color:#000;width:100%;height:100%;z-index:1008;">';
echo '</div>';

echo '<div style="position:fixed;top:0;left:0;opacity:1;filter: alpha(opacity=100);width:100%;height:100%;z-index:1011;">';
echo '<div class="w3-content w3-panel w3-seagreen" style="margin-top:20%;">';
echo '<h5>'.$completed.'</h5>';
echo '</div></div>';


echo '</a>';
$url = PATH;
header( "refresh:60;url=$url" );

 }
 
echo '</div>';
// Register by Modal
echo '<div id="dsf45gff3r4tygdf65" class="w3-modal" style="z-index:1007;margin-top:0px;">';
echo '<div class="w3-modal-content w3-animate-top" style="width:740px;max-width:100%;margin:auto;">';

echo '<div class="w3-container_">';
echo '<span onclick="document.getElementById(\'dsf45gff3r4tygdf65\').style.display=\'none\'" class="w3-button w3-display-topright w3-seagreen w3-hover-red" style="margin-top:5px;"><i class="fa fa-close w3-xlarge"></i></span>';

echo '<div class="w3-row w3-hide-large_">';

echo '<div class="w3-container w3-seagreen w3-text-white w3-card">';
echo '<h3 style="margin-top:8px;font-size:22px;"><i class="fa fa-user-plus"></i> '.$lng['form_create_account'].'</h3>';
echo '</div>';

echo '<div class="w3-container w3-bluepm">';

echo '<div class="w3-row-padding w3-margin-top">';

echo '<div class="w3-col l6 m6 s12">';
echo '<h4 class="w3-center"><i class="fa fa-address-card-o"></i> '.$lng['form_select_county'].':</h4>';
echo '</div>';

echo '<div class="w3-col l6 m6 s12">';

echo '<form action="" method="POST">';

echo '<select class="w3-select w3-border w3-large w3-margin-bottom w3-white" name="cnty_id" id="county" required="">';

include(BASE);
$res = $dbc->query("SELECT * FROM `counties` WHERE `country_id`='23'");
if($res->num_rows > 0){
echo "<option selected=\"\" value=\"\">".$lng['form_select_choise_county']."</option>"; 
while($r = $res->fetch_array()){
echo "<option value='".$r['cnty_id']."'>".$r['county_name']."</option>";          
 }
 }else{
    echo "<option selected=\"\" disabled=\"\">".$lng['form_no_county']."...</option>"; 
 }
 $dbc->close();

echo '</select>';
echo '</div></div>';

echo '<div class="w3-row-padding">';

echo '<div class="w3-col l6 m12 s12">';
echo '<input class="w3-input w3-border w3-margin-bottom" type="text" name="first_name" placeholder="'.$lng['form_first_name'].'..." required=""/>';
echo '</div>';

echo '<div class="w3-col l6 m12 s12">';
echo '<input class="w3-input w3-border w3-margin-bottom" type="text" name="last_name" placeholder="'.$lng['form_last_name'].'..." required=""/>';
echo '</div>';

echo '<div class="w3-col l6 m12 s12">';
echo '<input class="w3-input w3-border w3-margin-bottom" type="email" name="email" placeholder="'.$lng['form_email'].'..." required=""/>';
echo '</div>';

echo '<div class="w3-col l6 m12 s12">';
echo '<input class="w3-input w3-border w3-margin-bottom" type="tel" name="mobile" placeholder="'.$lng['form_mobile'].'..."/>';
echo '</div>';

echo '<div class="w3-col l12 m12 s12">';
echo '<input class="w3-input w3-border w3-margin-bottom" type="text" name="url" placeholder="'.$lng['form_url'].'"/>';
echo '</div>';

echo '<div class="w3-col l12 m12 s12">';
echo '<textarea class="w3-input w3-border w3-margin-bottom" rows="3" name="comment" placeholder="'.$lng['form_comm_to_admin'].'...">';
echo '</textarea>';
echo '</div>';

if($set['terms'] == '1'){
echo '<div class="w3-col l12 m12 s12">';
echo '<input class="w3-check w3-margin-bottom" type="checkbox" name="terms" value="0" id="checkTenable"/>';
echo '<label> '.$lng['form_agree_with'].' <a href="'.$set['trm_url'].'" target="'.$set['tc_o'].'">'.$lng['form_terms'].'</a></label>';
echo '</div>';
  }

if($set['privacy'] == '1'){
echo '<div class="w3-col l12 m12 s12">';
echo '<input class="w3-check w3-margin-bottom" type="checkbox" name="privacy" value="0" id="checkPenable" disabled="disabled"/>';
echo '<label> '.$lng['form_agree_with'].' <a href="'.$set['prv_url'].'" target="'.$set['pp_o'].'">'.$lng['form_privacy'].'</a></label>';
echo '</div>';
  }

echo '<div class="w3-col l12 m12 s12">';
echo '<input class="w3-check w3-margin-bottom" type="checkbox" name="news"/>';
echo '<label> '.$lng['form_check_news'].'</label>';
echo '</div>';

echo '<div class="w3-col l12 m12 s12 w3-center">';
echo '<button type="submit" class="w3-button w3-bluepm w3-border w3-border-cadetblue w3-hover-seagreen w3-margin-bottom" id="ischeckenable" disabled="disabled" id="ischeckenable" disabled="disabled">'.$lng['form_create_account'].'</button>';
echo '</div>';

echo '<input type="hidden" name="county_location" value="'.$rwcnt['county_name'].'"/>';
//echo '<input type="hidden" name="country_id" value="23"/>';
echo '<input type="hidden" name="activate" value="'.md5(uniqid(rand(), true)).'"/>';
echo '<input type="hidden" name="submitforapproval" value="true"/>';

echo '</div>';
echo '</form>';

echo '</div>';

echo '</div></div></div></div>';

//End Modal
}
echo '</div></div></div>';


echo '<div class="w3-half w3-card" style="max-width:100%;height:auto;">';

if($set['map'] == '1'){
    
    if(file_exists(THM.$set['theme'].'/maps/eumap.php')){
   include THM.$set['theme'].'/maps/eumap.php';
         }else{
           echo '<div class="w3-center w3-padding-64"><h3>'.$lng['alert_nomap'].'</h3></div>';
         }
         
}

if($set['map'] == '2'){
    
    $setmap = 'Romania';
$rwco['country_code'] = 'ro';
$rwco['country_name'] = 'Romania';
include THM.$set['theme'].'/maps/countrymap.php';

}

         
echo '</div>';


echo '</div>';

echo '<div class="w3-margin-top w3-padding-32 w3-hide-medium w3-hide-small"></div>'
?><script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script><script type="text/javascript">
$(document).ready(function(){
    $('#country').on("change",function () {
        var country_id = $(this).find('option:selected').val();
        $.ajax({
            url: "plugins/loadcounty.php",
            type: "POST",
            //data: "cat_id = "+catId,
            data: {country_id : country_id},
            success: function (response) {
                console.log(response);
                $("#county").html(response);
            },
        });
    });
});
</script><?php
   }

 }
// END Index Page

// Activation Page
 elseif($page == 'activate'){ // This is activation page 
$accact    = $_SERVER["REQUEST_URI"];
$parts     = explode('&', $accact);
$part_e    = explode('=', $parts[1]);
$_GET['e'] = $part_e[1];
$part_a    = explode('=', $parts[2]);
$_GET['a'] = $part_a[1];
if(isset($_GET['e'], $_GET['a']) && filter_var($_GET['e'], FILTER_VALIDATE_EMAIL) && (strlen($_GET['a']) == 32)) {
    
function randomPassword() {
    $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
    $pass = array(); //remember to declare $pass as an array
    $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
    for ($i = 0; $i < 8; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
    }
    return implode($pass); //turn the array into a string
}
$password = randomPassword();
$_GET['pass'] = $password;
include(BASE);
$raccact = $dbc->query("UPDATE `users` SET `confirmed` = NULL, `password`=SHA('$password') WHERE (`email`='" . $dbc->real_escape_string($_GET['e']) . "' AND `confirmed`='" . $dbc->real_escape_string($_GET['a']) . "') LIMIT 1");
    
if ($dbc->affected_rows == 1) {
    
    $selusetodt = $dbc->query("SELECT * FROM `users` WHERE `email`='" . $dbc->real_escape_string($_GET['e']) . "' LIMIT 1") or die($dbc->error);
    if($selusetodt->num_rows > 0){
    $rudtact = $selusetodt->fetch_assoc();
    //$fnSE = $rudtact['first_name'];
    $_GET['fn'] = $rudtact['first_name'];
    
    $addtodb = $dbc->query("INSERT INTO `user_details`(`usdet_id`, `uid`, `url`, `seo`, `pictures`, `facebook`, `twitter`, `instagram`, `linkedin`, `last_update`) VALUES ('0', '{$rudtact['uid']}', '', '{$rudtact['user_name']}', '', '', '', '', '', NOW())") or die($dbc->error);
        }    

$getSE = $dbc->query("SELECT `title`, `content_ro`, `content_en` FROM `email_template` WHERE `title`='account_activation_email_template' LIMIT 1") or die($dbc->error);
      $rSE = $getSE->fetch_assoc();
      $content = $rSE['content_'.$lang];
      
function BuildContent($content){     
$content = str_replace('{{ first_name }}', ''.$_GET['fn'].'', $content);
$content = str_replace('{{ user_email }}', ''.$_GET['e'].'', $content);
$content = str_replace('{{ user_pass }}', ''.$_GET['pass'].'', $content);
$content = str_replace('{{ site_login }}', '<a href="'.BASE_URL.PATH.'login.html" target="_blank">Conectare</a>', $content);
$content = str_replace('{{ site_name }}', ''.BASE_NAME.'', $content);
$content = str_replace('{{ link_site }}', '<a href="'. BASE_URL.PATH.'" style="text-decoration:none;">', $content);
$content = str_replace('{{ end_link_site }}', '</a>', $content);
return $content;
 } 
$build_content = BuildContent($content);
    
require_once(SML.'mail.php');
$to = $dbc->real_escape_string($_GET['e']);
$subject = BASE_NAME." :: ".$lng[$rSE['title']]."!";                    
$body = "<!DOCTYPE HTML>
      <head>
      <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>".$lng[$rSE['title']]."</title>
      </head>
      <body>
        <div style=\"margin:16px;width:800px;max-width:100%;\">      
          <div style=\"margin:16px;padding:16px;border:dotted 1px; #ddd;\">
            ".$build_content."
          </div>
        </div>
     </body>
     </html>";
                    
Send_Mail($to,$subject,$body);
    
        $activated  =  "1";
    } else {
        $unactivated = "1";
    }
 $dbc->close();
    
  }
?>
<div class="w3-row">
<div class="row w3-margin-bottom">

<div class="w3-col l6 m6 s12 w3-card" style="max-width:100%;height:auto;"><?php 
if($set['map'] == '1'){
    
    if(file_exists(THM.$set['theme'].'/maps/eumap.php')){
   include THM.$set['theme'].'/maps/eumap.php';
         }else{
           echo '<div class="w3-center w3-padding-64"><h3>'.$lng['alert_nomap'].'</h3></div>';
         }
         
}

if($set['map'] == '2'){
    
    $setmap = 'Romania';
$rwco['country_code'] = 'ro';
$rwco['country_name'] = 'Romania';
include THM.$set['theme'].'/maps/countrymap.php';

}
?></div>

<div class="w3-col l6 m6 s12">

<div class="w3-row_">
<div class="w3-container">
<?php
echo '<h2 class="w3-center">'.$lng['cpt_welcome'].'</h2>';
echo $lng['msj_welcome'];
?>

<h3 class="w3-center"><i class="fa fa-plug"></i> <?=$lng['form_title_activate_process']?></h3>

<?php if(isset($activated)) { ?>
<div class="w3-panel w3-pale-green"><h5 class=" w3-green w3-center"><i class="fa fa-check"></i> <?=$lng['form_result_title_activated']?></h5><div class="w3-container w3-text-green w3-margin-bottom w3-hide_"><p><?=$lng['form_result_content_activated']?></p></div></div><?php } ?>

<?php if(isset($unactivated)) { ?><div class="w3-panel w3-pale-red"><h5 class=" w3-red w3-center"><i class="fa fa-close"></i> <?=$lng['form_result_title_confirmed']?></h5><div class="w3-container w3-text-red w3-margin-bottom w3-hide"><?=$lng['form_result_content_confirmed']?></div></div><?php } ?>

</div>
</div>

</div>

</div></div>
<?php 

 }
// END Activation Page

// Login Page
 elseif($page == 'login'){ // This is login page
if(isset($_SESSION['uid'])){
    $url = PATH.'myaccount.html';
    ob_end_clean();
    header("Location: $url");
    exit();
   }else{
     
?>
<div class="w3-row w3-margin-bottom">
<div class="w3-half w3-card w3-hide-small" style="max-width:100%;height:auto;">
<?php 
if($set['map'] == '1'){
    
    if(file_exists(THM.$set['theme'].'/maps/eumap.php')){
   include THM.$set['theme'].'/maps/eumap.php';
         }else{
           echo '<div class="w3-center w3-padding-64"><h3>'.$lng['alert_nomap'].'</h3></div>';
         }
         
}

if($set['map'] == '2'){
    
    $setmap = 'Romania';
$rwco['country_code'] = 'ro';
$rwco['country_name'] = 'Romania';
include THM.$set['theme'].'/maps/countrymap.php';

}
?>
</div>

<div class="w3-half">
<div class="w3-row">
<div class="w3-container">
<h2 class="w3-center w3-margin-top w3-margin-bottom w3-text-bluepm">
<i class="fa fa-lock" style="font-size:48px;"></i><br/>
<?=$lng['top_smenu_sign_in']?></h2>
<style>.field-icon {float: right;margin-right: 10px;margin-top: -30px;position: relative;z-index: 2;}.left-icon {float: left;margin-left: 10px;margin-top: -30px;padding-right:10px;position: relative;z-index: 2;}</style><?php if(isset($errrst)){ ?><div class="w3-panel w3-red"><?php
if(isset($err_e))       {echo '<p>'.$err_e.       '</p>';}
if(isset($err_p))       {echo '<p>'.$err_p.       '</p>';}
if(isset($noexist))     {echo '<p>'.$noexist.     '</p>';}
if(isset($notverifyed)) {echo '<p>'.$notverifyed. '</p>';}
if(isset($rejected))    {echo '<p>'.$rejected.    '</p>';}
if(isset($r_reason))    {echo '<p>'.$r_reason.    '</p>';}
if(isset($blocked))     {echo '<p>'.$blocked.     '</p>';}
if(isset($b_reason))    {echo '<p>'.$b_reason.    '</p>';}
if(isset($wrongpass))   {echo '<p>'.$wrongpass.   '</p>';}
if(isset($notconfirmed)){echo '<p>'.$notconfirmed.'</p>';}
if(isset($tryagain))    {echo '<p>'.$tryagain.    '</p>';}
?></div><?php } ?>
<form action="" method="POST">
<div class="w3-margin-bottom">
<input class="w3-input w3-border" type="email" name="email" placeholder="<?=$lng['form_email']?>" autocomplete="off" tabindex="1" style="padding-left:60px;font-size:12px;"/
><i class="fa fa-fw fa-at left-icon w3-xlarge w3-text-bluepm w3-border-right"></i>
<i class="fa fa-fw fa-envelope-o field-icon w3-xlarge w3-text-bluepm"></i>
</div>
<div class="w3-margin-bottom">
<input id="password-field" class="w3-input w3-border" type="password" name="pass" placeholder="<?=$lng['form_password']?>" autocomplete="off" tabindex="2" style="padding-left:60px;font-size:12px;"/>
<i class="fa fa-fw fa-key left-icon w3-xlarge w3-text-bluepm w3-border-right">
</i><span toggle="#password-field" class="fa fa-fw fa-eye-slash field-icon w3-xlarge toggle-password w3-text-bluepm"></span>
</div>
<div class="w3-margin-bottom w3-center">
<button class="w3-button w3-bluepm w3-hover-seagreen" type="submit"><i class="fa fa-sign-in"></i> <?=$lng['top_smenu_sign_in']?></button>
<a href="pswreset.html" class="w3-button w3-bluepm w3-hover-seagreen"><i class="fa fa-key"></i> <?=$lng['form_reset_password_btn']?></a>
</div><input type="hidden" name="userlogin" value="true"/></form><script>$(".toggle-password").click(function() {
  $(this).toggleClass("fa-eye fa-eye-slash");
  var input = $($(this).attr("toggle"));
  if (input.attr("type") == "password") {
    input.attr("type", "text");
  } else {
    input.attr("type", "password");
  }
});</script><?php if(isset($activated)) { ?><div class="w3-panel w3-pale-green"><h5 class=" w3-green w3-center"><i class="fa fa-check"></i> <?=$lang['form_result_title_activated']?></h5><div class="w3-container w3-text-green w3-margin-bottom"><p><?=$lang['form_result_content_activated']?></p></div></div><?php } ?>

<?php if(isset($unactivated)) { ?>
<div class="w3-panel w3-pale-red">
<h5 class=" w3-red w3-center"><i class="fa fa-close"></i> <?=$lang['form_result_title_confirmed']?></h5>
<div class="w3-container w3-text-red w3-margin-bottom">
<p><?=$lng['form_result_content_confirmed']?></p>
</div>
</div>
<?php } ?>

</div>
</div>
</div>


</div>
<?php }
 }
// END Login Page

// Password Reset Page
 elseif($page == 'pswreset'){ // This is password reset page
if(isset($_SESSION['uid'])){
    $url = PATH.'myaccount.html';
    ob_end_clean();
    header("Location: $url");
    exit();
   }else{
     
?>
<div class="w3-row w3-margin-bottom">
<div class="w3-half w3-card w3-hide-small" style="max-width:100%;height:auto;">
<?php 
if($set['map'] == '1'){
    
    if(file_exists(THM.$set['theme'].'/maps/eumap.php')){
   include THM.$set['theme'].'/maps/eumap.php';
         }else{
           echo '<div class="w3-center w3-padding-64"><h3>'.$lng['alert_nomap'].'</h3></div>';
         }
         
}

if($set['map'] == '2'){
    
    $setmap = 'Romania';
$rwco['country_code'] = 'ro';
$rwco['country_name'] = 'Romania';
include THM.$set['theme'].'/maps/countrymap.php';

}
?>
</div>

<div class="w3-half">
<div class="w3-row">
<div class="w3-container">
<h2 class="w3-center w3-margin-top w3-margin-bottom w3-text-bluepm">
<i class="fa fa-key" style="font-size:48px;"></i><br/>
<?=$lng['form_reset_password_btn']?></h2>
<style>.field-icon {float: right;margin-right: 10px;margin-top: -30px;position: relative;z-index: 2;}.left-icon {float: left;margin-left: 10px;margin-top: -30px;padding-right:10px;position: relative;z-index: 2;}</style>
<?php if(isset($errrst)){ ?>
<div class="w3-panel w3-red">
<?php
if(isset($err_e))       {echo '<p>'.$err_e.       '</p>';}
if(isset($noexist))     {echo '<p>'.$noexist.     '</p>';}
if(isset($notverifyed)) {echo '<p>'.$notverifyed. '</p>';}
if(isset($rejected))    {echo '<p>'.$rejected.    '</p>';}
if(isset($r_reason))    {echo '<p>'.$r_reason.    '</p>';}
if(isset($blocked))     {echo '<p>'.$blocked.     '</p>';}
if(isset($b_reason))    {echo '<p>'.$b_reason.    '</p>';}
if(isset($notconfirmed)){echo '<p>'.$notconfirmed.'</p>';}
if(isset($tryagain))    {echo '<p>'.$tryagain.    '</p>';}
?>
</div>
<?php } ?>

<?php if(isset($completed)){
    echo '<div class="w3-panel w3-green"><p>'.$completed.'</p></div>';
    } ?>
<form action="" method="POST">
<div class="w3-margin-bottom">
<input class="w3-input w3-border" type="email" name="email" placeholder="<?=$lng['form_email']?>" autocomplete="off" tabindex="1" style="padding-left:60px;font-size:12px;"/
><i class="fa fa-fw fa-at left-icon w3-xlarge w3-text-bluepm w3-border-right"></i>
<i class="fa fa-fw fa-envelope-o field-icon w3-xlarge w3-text-bluepm"></i>
</div>

<div class="w3-margin-bottom w3-center">
<button class="w3-button w3-bluepm w3-hover-seagreen" type="submit"><i class="fa fa-key"></i> <?=$lng['form_reset_password_btn']?></button>

<a href="login.html" class="w3-button w3-bluepm w3-hover-seagreen"><i class="fa fa-sign-in"></i> <?=$lng['top_smenu_sign_in']?></a>

</div>
<input type="hidden" name="forgotcode" value="<?=md5(uniqid(rand(), true))?>"/>
<input type="hidden" name="userpassforgotandreset" value="true"/>
</form>
<script>$(".toggle-password").click(function() {
  $(this).toggleClass("fa-eye fa-eye-slash");
  var input = $($(this).attr("toggle"));
  if (input.attr("type") == "password") {
    input.attr("type", "text");
  } else {
    input.attr("type", "password");
  }
});</script><?php if(isset($activated)) { ?><div class="w3-panel w3-pale-green"><h5 class=" w3-green w3-center"><i class="fa fa-check"></i> <?=$lang['form_result_title_activated']?></h5><div class="w3-container w3-text-green w3-margin-bottom"><p><?=$lang['form_result_content_activated']?></p></div></div><?php } ?>

<?php if(isset($unactivated)) { ?>
<div class="w3-panel w3-pale-red">
<h5 class=" w3-red w3-center"><i class="fa fa-close"></i> <?=$lang['form_result_title_confirmed']?></h5>
<div class="w3-container w3-text-red w3-margin-bottom">
<p><?=$lng['form_result_content_confirmed']?></p>
</div>
</div>
<?php } ?>

</div>
</div>
</div>


</div>
<?php }
 }
// END Password Reset Page

// Admin Page
 elseif($page == 'admin'){ // This is admin page
$actaurl  = $_SERVER["REQUEST_URI"];

$acts_aps = explode('&', $actaurl);
$acts_ap  = explode('=', $acts_aps[0]);

$acts     = explode('&', $actaurl);
$act_p    = explode('=', $acts[1]);
$act_s    = explode('=', $acts[2]);

$_GET['ap']     = $acts_ap[1];
$_GET['str']    = $act_p[1];
$_GET['action'] = $act_s[1];

if($_GET['ap'] == 'finbox'){

if(isset($_GET['str'], $_GET['action']) && filter_var($_GET['str']) && filter_var($_GET['action'])) {

if($_GET['action'] == 'approve'){    
include(BASE);
$resok = $dbc->query("UPDATE `users` SET `approved` = '1' WHERE `password`='" . $dbc->real_escape_string($_GET['str']) . "' LIMIT 1");
    
if ($dbc->affected_rows == 1) {
    
    $getSE = $dbc->query("SELECT `title`, `content_ro`, `content_en` FROM `email_template` WHERE `title`='account_approved_email_template' LIMIT 1") or die($dbc->error);
      $rSE = $getSE->fetch_assoc();
      $content = $rSE['content_'.$lang];
      
function BuildContent($content){ 
    
$content = str_replace('{{ first_name }}', ''.$_POST['first_name'].'', $content);

$content = str_replace('{{ confirm_code }}', '<a href="'.BASE_URL.PATH.'activate.html?p=activate&e='.$_POST['email'].'&a='.$_POST['activate'].'" target="_blank">Confirmă adresa de e-mail</a>', $content);

$content = str_replace('{{ site_name }}', ''.BASE_NAME.'', $content);

$content = str_replace('{{ link_site }}', '<a href="'. BASE_URL . '" style="text-decoration:none;">', $content);

$content = str_replace('{{ end_link_site }}', '</a>', $content);

return $content;

 }
 
$build_content = BuildContent($content);

    $getuserp = $dbc->query("SELECT email FROM users WHERE password='" . $dbc->real_escape_string($_GET['str']) . "' LIMIT 1");
    $rgum = $getuserp->fetch_assoc();
    
require_once(SML.'mail.php');
$to = $rgum['email'];
$subject = BASE_NAME." :: ".$lng[$rSE['title']]."!";                    
$body = "<!DOCTYPE HTML>
      <head>
      <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>".$lng[$rSE['title']]."!</title>
      </head>
  <body>
    <div style=\"margin:16px;width:800px;max-width:100%;\">      
      <div style=\"margin:16px;padding:16px;\">
        ".$build_content."
      </div>
    </div>
  </body>
</html>";
                    
Send_Mail($to,$subject,$body);
    
        $approved  =  "1";
    } else {
        $unapproved = "1";
    }
 $dbc->close();
 
  }elseif($_GET['action'] == 'refuse'){    
include(BASE);
$checkifapp = $dbc->query("SELECT `approved`, `r_reason` FROM `users` WHERE `password`='" . $dbc->real_escape_string($_GET['str']) . "' LIMIT 1") or die($dbc->error);

if($checkifapp->num_rows > 0){
    $rwapp = $checkifapp->fetch_assoc();
   

$resok = $dbc->query("UPDATE `users` SET `rejected` = '1', `r_reason`='".$lng['rejected_reason_auto']."' WHERE `password`='" . $dbc->real_escape_string($_GET['str']) . "' LIMIT 1");
    
if ($dbc->affected_rows == 1) {
    
    $getSE = $dbc->query("SELECT `title`, `content_ro`, `content_en` FROM `email_template` WHERE `title`='account_declined_email_template' LIMIT 1") or die($dbc->error);
      $rSE = $getSE->fetch_assoc();
      $content = $rSE['content_'.$lang];
      
function BuildContent($content){ 
    
$content = str_replace('{{ first_name }}', ''.$_POST['first_name'].'', $content);

$content = str_replace('{{ confirm_code }}', '<a href="'.BASE_URL.PATH.'activate.html?p=activate&e='.$_POST['email'].'&a='.$_POST['activate'].'" target="_blank">Confirmă adresa de e-mail</a>', $content);

$content = str_replace('{{ site_name }}', ''.BASE_NAME.'', $content);

$content = str_replace('{{ link_site }}', '<a href="'. BASE_URL . '" style="text-decoration:none;">', $content);

$content = str_replace('{{ end_link_site }}', '</a>', $content);

return $content;

 }
 
$build_content = BuildContent($content);
    
    $getuserp = $dbc->query("SELECT email FROM users WHERE password='" . $dbc->real_escape_string($_GET['str']) . "' LIMIT 1");
    $rgum = $getuserp->fetch_assoc();
    
require_once(SML.'mail.php');
$to = $rgum['email'];
$subject = BASE_NAME." :: ".$lng[$rSE['title']]."!";                    
$body = "<!DOCTYPE HTML>
      <head>
      <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
      <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">
      <title>".$lng[$rSE['title']]."</title>
      </head>
  <body>
    <div style=\"margin:16px;width:800px;max-width:100%;\">      
      <div style=\"margin:16px;padding:16px;border:dotted 1px; #FF0000;\">
        ".$build_content."
      </div>
    </div>
  </body>
</html>";
                    
Send_Mail($to,$subject,$body);
    
        $rejectedok  =  $lng['account_declined_title'];
    } else {
        $rejectednot = $lng['account_declined_details'].":<p>{$rwapp['r_reason']}</p>";
    }
     }
 $dbc->close();
 
  }
 }
 
 

?>
<div class="w3-row">
<div class="row w3-margin-bottom">

<div class="w3-quarter w3-card w3-hide-small">
<?php include THM.$set['theme'].'/admin_sidebar.php'; ?>
</div>
<div class="w3-threequarter">

<div class="w3-row">
<div class="w3-container">

<h2 class="w3-center w3-margin-bottom w3-text-brown"><i class="fa fa-envelope"></i> <?=$lng['from_inbox_title']?></h2>


<?php if(isset($approved)) { ?>
<div class="w3-panel w3-pale-green">
<h5 class=" w3-green w3-center"><i class="fa fa-check"></i> <?=$lng['from_inbox_content_approved']?></h5>
</div>
<?php } ?>

<?php if(isset($unapproved)) { ?>
<div class="w3-panel w3-pale-red">
<h5 class=" w3-red w3-center"><i class="fa fa-close"></i> <?=$lng['from_inbox_content_not_approved']?></h5>
</div>
<?php } ?>

<?php if(isset($rejectedok)) { ?>
<div class="w3-panel w3-pale-green">
<h5 class=" w3-green w3-center"><i class="fa fa-check"></i> <?=$rejectedok?></h5>
</div>
<?php } ?>

<?php if(isset($rejectednot)) { ?>
<div class="w3-panel w3-pale-red">
<h5 class=" w3-red w3-center"><i class="fa fa-close"></i> <?=$rejectednot?></h5>
</div>
<?php } ?>


</div>
</div>
</div>


</div>
</div>

  <?php   
  }else{
    include THM.$set['theme'].'/404.php';
 }
  ?>


<?php }
// END Admin Page

// Book Page
elseif($page == 'book'){ // This is for book page 

echo '<div class="row w3-margin-bottom">';

echo '<div class="w3-half w3-card" style="max-width:100%;height:auto;">';

if($set['map'] == '1'){
    
    if(file_exists(THM.$set['theme'].'/maps/eumap.php')){
   include THM.$set['theme'].'/maps/eumap.php';
         }else{
           echo '<div class="w3-center w3-padding-64"><h3>'.$lng['alert_nomap'].'</h3></div>';
         }
         
}

if($set['map'] == '2'){
    
    $setmap = 'Romania';
$rwco['country_code'] = 'ro';
$rwco['country_name'] = 'Romania';
include THM.$set['theme'].'/maps/countrymap.php';

}

echo '</div>';
echo '<div class="w3-half">';

echo '<div class="w3-row">';
echo '<div class="w3-container">';
echo '<h2 class="w3-center w3-text-bluepm"><i class="fa fa-address-book-o w3-xxlarge"></i> '.$lng['cpt_address_book'].'</h2>';

include(BASE);
$rcountryB = $dbc->query("SELECT * FROM `countries` WHERE 1=1 ORDER BY country_name ASC");
 if($rcountryB->num_rows > 0){
     while($rowcntB = $rcountryB->fetch_assoc()){
               
echo '<a href="'.PATH.'country-';
$link = strtolower(str_replace(' ', '-', $rowcntB['country_name']));
echo $link.'.html" style="text-decoration:none;">';

echo '<div class="w3-col l6 m12 s12" style="padding:5px;">';
echo '<div class="w3-container w3-card w3-bluepm w3-hover-seagreen" style="height:33px;">';

echo '<img src="'.PATH.'libs/img/flags/'.$rowcntB['country_code'].'.png" alt="'.$lng['lng_'.$rowcntB['country_code']].'" title="'.$lng['lng_'.$rowcntB['country_code']].'" style="float:left;width:24px;height:24px;margin:0;margin-top:5px;" loading="lazy"/><p style="margin:0;margin-top:5px;">';
echo '&nbsp;'.$lng['lng_'.$rowcntB['country_code']].'</p>';

echo '</div>';
echo '</div>';

echo '</a>'."\n";     
    } 
   }else{
      echo '<div class="w3-padding w3-center">Not country found.</div>';
 }
 $dbc->close(); 

echo '</div></div></div></div>';
  }
// END Book Page

// Cookies Page
elseif($page == 'cookies'){ // This is for cookies page 
  
echo '<div class="row w3-margin-bottom">';

echo '<div class="w3-container w3-col l12 m12 s12 w3-bluepm">';
echo '<h3 class=""><i class="fa fa-cogs"></i>  '.$title.'</h3>';
echo '</div>';

echo '<div class="w3-container w3-col l12 m12 s12 w3-card">';
echo $row['content'];
echo '</div>';

echo '</div>';
  }
// END Cookies Page

// Terms Page
elseif($page == 'terms'){ // This is for terms page 
  
echo '<div class="w3-row w3-margin-bottom">';

echo '<div class="w3-container w3-col l12 m12 s12 w3-bluepm">';
echo '<h3 class=""><i class="fa fa-legal"></i> '.$title.'</h3>';
echo '</div>';

echo '<div class="w3-container w3-col l12 m12 s12 w3-card">';
echo $row['content'];
echo '</div>';

echo '</div>';
  }
// END Terms Page

// Privacy Page
  elseif($page == 'privacy'){ // This is for privacy page 
  
echo '<div class="row w3-margin-bottom">';

echo '<div class="w3-container w3-col l12 m12 s12 w3-bluepm">';
echo '<h3 class=""><i class="fa fa-shield"></i> '.$title.'</h3>';
echo '</div>';

echo '<div class="w3-container w3-col l12 m12 s12 w3-card">';
echo $row['content'];
echo '</div>';

echo '</div>';
  }
// END Privacy Page

// Search Page
  elseif($page == 'search'){ // This is for search page 
  
   include(BASE);
   
   $firstname = $_POST['first_name'];
   $lastname  = $_POST['last_name'];
   $countryID = $_POST['country_id'];
   $countyID  = $_POST['cnty_id'];   
 
        
               
if( (!empty($firstname)) && (!empty($lastname)) && (!empty($countyID)) ){
// Daca scrie prenumele, numele si judetul
$getuser = $dbc->query("SELECT * FROM `users` WHERE `confirmed` IS NULL 
                                  AND (`city_id` = '".$countyID."')
                                  AND (`approved`='1') 
                                  AND (`book`='1') 
                                  AND (`first_name` LIKE '%".$firstname."%' 
                                        OR `last_name` LIKE '%".$lastname."%')"); 
                     
 }elseif( (!empty($firstname)) && (empty($lastname)) && (!empty($countyID)) ){
// Daca scrie prenumele si judetul
$getuser = $dbc->query("SELECT * FROM `users` WHERE `confirmed` IS NULL 
                                  AND (`city_id` = '".$countyID."')
                                  AND (`approved`='1') 
                                  AND (`book`='1') 
                                  AND (`first_name` LIKE '%".$firstname."%')"); 
                     
 }elseif( (!empty($firstname)) && (!empty($lastname)) && (empty($countyID)) ){
// Daca scrie prenumele si numele
$getuser = $dbc->query("SELECT * FROM `users` WHERE `confirmed` IS NULL     
                                  AND (`approved`='1') 
                                  AND (`book`='1') 
                                  AND (`first_name` LIKE '%".$firstname."%' 
                                        OR `last_name` LIKE '%".$lastname."%')"); 
                     
 }elseif( (!empty($firstname)) && (empty($lastname)) && (empty($countyID)) ){
// Daca scrie doar prenumele
$getuser = $dbc->query("SELECT * FROM `users` WHERE `confirmed` IS NULL 
                                  AND (`approved`='1') 
                                  AND (`book`='1')
                                  AND (`first_name` LIKE '%".$firstname."%')"); 
                     
 }
                       
?>

<div class="w3-row w3-margin-bottom w3-hide-small w3-hide-medium">

<div class="w3-container w3-bluepm" style="margin-top:0px;padding-top:5px;padding-bottom:5px;">
<?php include THM.$set['theme'].'/searchform.php'; ?>
</div>

</div>

<div class="w3-row">
<h2 class="w3-container w3-bluepm" style="font-size:24px;"> <img src="<?=IMG?>dove.png" alt="<?=$lng['search_title_img']?>" title="<?=$lng['search_title_img']?>" loading="lazy" style="width:30px;"/> <?=$lng['search_result_title']?></h2>

</div>

<div class="w3-row">
<?php
if($getuser->num_rows > 0){
while($rws = $getuser->fetch_assoc()){
    
$getusrdtls = $dbc->query("SELECT * FROM `user_details` 
                            WHERE `user_details`.`uid`='{$rws['uid']}' 
                            LIMIT 1");
if($getusrdtls->num_rows == 1){$rwudt = $getusrdtls->fetch_assoc(); }

$getcountry = $dbc->query("SELECT * FROM `countries`                               
                                   WHERE `country_id`='{$rws['country_id']}' 
                                   LIMIT 1");
if($getcountry->num_rows == 1){$rwctry = $getcountry->fetch_assoc();}

$getcounty = $dbc->query("SELECT * FROM `counties` 
                                  WHERE `cnty_id`='{$rws['city_id']}' 
                                  LIMIT 1");
if($getcounty->num_rows == 1){$rwcty = $getcounty->fetch_assoc();}
?>



<div class="w3-col l2 m3 s6 w3-cell" style="padding:2px;">     
<!--<a onclick="document.getElementById('dsf45gff3r<?=$rws['uid']?>4tygdf65').style.display='block'" class="w3-button w3-block w3-white w3-hover-bluepm w3-padding-small">-->

<a href="<?=PATH.$rwudt['seo'].'.html'?>" class="w3-button w3-block w3-white w3-hover-bluepm w3-padding-small">
<div class="w3-card w3-hover-pale-blue">

<?php if(!empty($rwudt['pictures'])){?>
<img class="w3-circle_" src="<?=PATH.'images/'.$rwudt['pictures']?>" alt="" style="object-fit:cover;width:100%;max-width:100%;height:150px;max-height:auto;"/>
<?php }else{ ?>
<img class="w3-circle_" src="<?=PATH.'images/no-user-image.png'?>" alt="" style="object-fit:cover;width:100%;max-width:100%;height:150px;max-height:auto;"/>
<?php } ?>
<h5 class="w3-center" style="margin-top:0px;">
<?=$rws['first_name']?> <?=$rws['last_name']?></h5>
     
</div>
</a>  
</div>
    
    
<?php       

// Details by Modal
/*
echo '<div id="dsf45gff3r'.$rws['uid'].'4tygdf65" class="w3-modal" style="z-index:1007;margin-top:-50px;">';
echo '<div class="w3-modal-content w3-animate-zoom" style="width:640px;max-width:100%;margin:auto;">';

echo '<div class="w3-container_">';
echo '<span onclick="document.getElementById(\'dsf45gff3r'.$rws['uid'].'4tygdf65\').style.display=\'none\'" class="w3-button w3-display-topright w3-green w3-hover-red" style="margin-top:5px;"><i class="fa fa-close w3-xlarge"></i></span>';

echo '<div class="w3-row w3-hide-large_">';

echo '<div class="w3-container w3-bluepm w3-text-white w3-card">';
echo '<h3 style="margin-top:8px;font-size:22px;">Informations</h3>';
echo '</div>';

echo '<div class="w3-bar-block w3-white">';

echo '<div class="w3-col l4" style="padding:4px;">';

if(!empty($rwudt['pictures'])){
echo '<img src="'.PATH.'images/'.$rwudt['pictures'].'" alt="imagine" style="object-fit:cover;width:100%;max-width:100%;height:250px;max-height:auto;"/>';
}else{
echo '<img src="'.PATH.'images/no-user-image.png" alt="imagine" style="object-fit:cover;width:100%;max-width:100%;height:250px;max-height:auto;"/>';
  }
  
echo '</div>';

echo '<div class="w3-col l8" style="padding:4px;">'; 
echo '<h3 class="w3-container w3-center">'.$rws['first_name'].' '.$rws['last_name'].'</h3>';
echo '<h4 class="w3-container w3-center"><a href="'.PATH.$rwudt['seo'].'.html" title="">Visit my Business Page</a></h4>';
echo '<h5 class="w3-container">Mobile: '.$rws['mobile'].'</h5>';
echo '<h5 class="w3-container">E-mail: '.str_replace('@', '[Here Is At]', $rws['email']).'</h5>';
echo '<h5 class="w3-container">Web: <a href="'.$rwudt['url'].'" target="_blank">'.str_replace('https://', '', $rwudt['url']).'</a> <i class="fa fa-external-link w3-small" title="Visit the site to an external source"></i></h5>';
     
echo '<div class="w3-row w3-margin-top">';
echo '<div class="w3-container w3-left"><i class="fa fa-map-marker"></i> '.$rwcty['county_name'].'</div>';
echo '<div class="w3-container w3-right"><i class="fa fa-globe"></i> '.$rwctry['country_name'];
echo '</div>';

echo '</div></div></div></div></div></div></div>';
*/
//End Modal
   }
 }else{
    echo '<div class="w3-col l12 m12 s12" style="padding:2px;">';
    echo '<div class="w3-container w3-center">';
    echo '<p class="w3-padding-64">'.$lng['search_no_result'].'</p>';
    echo '</div></div>';
  }

$dbc->close(); ?>

</div>


<?php }
// END Search Page
?>