<?php
/****************************************************
 COPYRIGHT (C) Anna Kaminska Internetsysteme
 
  NAME 
   Client Panel Login  
  
  AUTHOR
   author name
    
  DESCRIPTION
   few words of description, explanation of module name abbreviation     

  VERSION 
   1.0.1
     
  HISTORY 
   DATE		MODIFICATIION		INITIALS 
   yyyy.mm.dd modification description 	initials 
   2008.08.23 fixs			WZ
 ***************************************************/ 

require('includes/website_start.php');
require('includes/languages/'.$_SESSION['language'].'.php');
require('includes/languages/'.$_SESSION['language'].'/c_login.php');
require('../_common/classes/ms_class.php');


$error_no  	=  (isset($_GET['err_no']) 	? $_GET['err_no'] 	: '');
$action  	=  (isset($_GET['action']) 	? $_GET['action'] 	: '');
$email_error  	=  (isset($_GET['email_err']) 	? $_GET['email_err'] 	: '');
$code  		=  (isset($_GET['code'])) 	? pf_db_prepare_input($_GET['code']) : '';


// action  ==  process
if (isset($action) && ($action == 'process'))
{
    $error = false;
	
    if (isset($_POST['reservation_code']))	
    {
        $code  =  pf_db_prepare_input($_POST['reservation_code']);
        $emailPost  =  pf_db_prepare_input($_POST['email']);
    }
    
    if(isset($_GET['code']))
    {
        $code  = pf_db_prepare_input($_GET['code']);
    }
    
    $ipAddress = pf_get_ip();
    
    $bruteForceQuery = pf_db_query("SELECT  
	SUM(CASE WHEN timestampdiff(minute, timestamp, now())<10 AND ip = '{$ipAddress}' THEN 1 ELSE 0 END) IP10Min,
	SUM(CASE WHEN timestampdiff(minute, timestamp, now())<60 AND ip = '{$ipAddress}' THEN 1 ELSE 0 END) IP60Min,
	SUM( CASE WHEN timestampdiff(minute, timestamp, now())<1440 AND ip = '{$ipAddress}' THEN 1 ELSE 0 END) IP1D,
	SUM( CASE WHEN timestampdiff(minute, timestamp, now())<10 THEN 1 ELSE 0 END) All10Min,
	SUM( CASE WHEN timestampdiff(minute, timestamp, now())<60 THEN 1 ELSE 0 END) All60Min,
	SUM( CASE WHEN timestampdiff(minute, timestamp, now())<1440 THEN 1 ELSE 0 END) All1D
FROM `log` 
WHERE `type` = 3 AND level ='error'
	AND timestampdiff(hour, TimeStamp, now())<=24");
    
    $bruteForceQuery = pf_db_fetch_array($bruteForceQuery);
  
    if($bruteForceQuery['IP10Min']>=10 || $bruteForceQuery['IP60Min']>=15 || $bruteForceQuery['IP1H']>=20 || $bruteForceQuery['All10Min']>=50 || $bruteForceQuery['All60Min']>=60 || $bruteForceQuery['All1D']>=70)
    {


        $body = "<html>\n";
        $body .='<head><title></title></head>';
        $body .='<body>';
        $body .= "Adres IP: {$ipAddress}\n\n<BR>Limity 10, 15, 20, 50, 60, 70\n\n<BR>" . nl2br(print_r($bruteForceQuery, true));
        $body .= "</body>\n";
        $body .= "</html>\n";
        
        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
        mail('feha@marcinsky.pl',"Alert - Przekroczono dopuszczalna  ilosc logowan do panelu klienta", $body, $headers);
        
        $error = true;
        $err_no = 2;
    }
    elseif(!pf_not_null($code) || ctype_digit($code)===false ) /* no code */
    {
      $error  =  true;
      $err_no  =  2;
    } 
    else /* code exists */ 
    {

        $code_query =  pf_db_query("select * from " . TABLE_RESERVATIONS . " r, " .TABLE_CUSTOMERS . " c where code = '" . addslashes($code) . "' and r.reservation_id = c.reservation_id");
    	$code_data  =  pf_db_fetch_array($code_query);
    	
    	mysql_query("INSERT INTO log (type, timestamp, text, ip, `level`) VALUES ('3', CURRENT_TIMESTAMP, 'Próba logowania z kodem: {$code}', '".pf_get_ip()."', 'notice');");

            /*
            if ($code == 'test') // test ? 
            { 
                $code_query =  pf_db_query("select * from " . TABLE_RESERVATIONS . " , " .TABLE_CUSTOMERS . " WHERE reservation_id = 110");
                $code_data  =  pf_db_fetch_array($code_query);
            }
                */
        
    	if(pf_db_num_rows($code_query)  ==  0 || (strtolower($code_data['customer_email']) != strtolower($emailPost) && md5(strtotime($code_data['add_date']))!=$_GET['auth'])  ) /* bad code */
        {
            mysql_query("INSERT INTO log (type, timestamp, text, ip, `level`) VALUES ('3', CURRENT_TIMESTAMP, 'Próba logowania z kodem: {$code}', '".pf_get_ip()."', 'error');");
            $error 	= true;
            $err_no  	=  2;
  
        } 
        else /* good code */ 
        {  
    	    if ($code_data['outdated'] && ($code_data['trash'] == 0)) /* good code but reservation expired */
    	    { 
    	        //if(!isset($_GET['auth']) && md5(strtotime($code_data['add_date']))!=$_GET['auth'])
    	        {
                pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN, 'action=extend&code=' . $code));
                }
              $error = true;
              $err_no = 7;
    
    	    }
    	    else /* finally good code */
    	    {
              mysql_query("update customers set last_login=now() where reservation_id = " . $code_data['reservation_id']);
    	        $_SESSION['customer_login']  		= 'true';
    	        $_SESSION['reservation_id']  		= $code_data['reservation_id'];
    	        $_SESSION['code']  		= $code_data['code'];
    	        $_SESSION['customer_block_panel']  	= $code_data['panel_blocked'];
    	        $CustomerClass = new ms_customer($_SESSION['code']);
              if(strpos($_SERVER['SERVER_NAME'], $CustomerClass->getDomain())===false)
                {
                  //pf_redirect($CustomerClass->getCustomerPanelUrl());
                }
    	    }
    
        }
    
    	if ($code_data['customer_deleted'] == 1) /* reservation deleted */
    	{
    	    //$error = true;
    	    //$err_no = 3;
    	}
    	
        if(isset($_GET['auth']) && md5(strtotime($code_data['add_date']))==$_GET['auth'])
        {
    
            //mysql_query("update customers set last_login=now() where reservation_id = " . $code_data['reservation_id']);
            $_SESSION['customer_login']  		= 'true';
            $_SESSION['reservation_id']  		= $code_data['reservation_id'];
            $_SESSION['code']  		= $code_data['code'];
            $_SESSION['customer_block_panel']  	= $code_data['panel_blocked'];
            $CustomerClass = new ms_customer($_SESSION['code']);
            $error = false;
            $err_no = '';
        }
      
    }
	
    include_once 'securimage/securimage.php';
    $securimage = new Securimage();
	
	/*if ($securimage->check($_POST['captcha_code'])   ==   false) 
	{
  		$error = true;
  		$err_no = 6;
	}*/


    if(($error == true) && ($err_no == 2))
    {	
        pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'err_no=' . $err_no . '&code=' . $code));
    }
    else
    {
	if($error ==  true)
	{
    	    pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'err_no=' . $err_no));
	}
	else 
	{
    	    
    	   if(isset($_GET['redirect']) && $_GET['redirect']=='messages')
            {
            pf_redirect(pf_href_link(FILENAME_MESSAGES));
            }
           elseif(isset($_GET['redirect']) && $_GET['redirect']=='reviews')
            {
            pf_redirect(pf_href_link(FILENAME_HOUSE_REVIEW));
            }
	       else
            {
            //echo ifas;
            //exit;
            //pf_redirect(FILENAME_INDEX);
            pf_redirect('../customer2/index.php');
            }
	}
    }
}

// action  ==  email_code
if (isset($action) && ($action == 'email_code'))
{
    $email = pf_db_prepare_input($_POST['email']);
    if(pf_not_null($email)) /* email exists */
    { 
    $email_query  	=  pf_db_query("select * from (select r.reservation_id, code from " . TABLE_CUSTOMERS . " c left join reservations r on c.reservation_id=r.reservation_id where customer_email like '" . addslashes($email) . "' and datediff( now( ) , add_date ) <720 and contract_date is not null order by r.reservation_id desc) a  union select * from  (select r.reservation_id, code from " . TABLE_CUSTOMERS . " c left join reservations r on c.reservation_id=r.reservation_id where customer_email like '" . addslashes($email) . "'  order by c.customers_id DESC limit 5) b  order by reservation_id desc");
    
	if(pf_db_num_rows($email_query)  ==  0) /* bad email */
	{
	    $err_no  =  2;
	    pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'err_no=' . $err_no . '&email_err=1'));
	} 
	else /* good email */ 
	{ 
	    $err_no  		=  2;
	    //echo pf_db_num_rows($email_query);
	    /*
	    while($email = pf_db_fetch_array($email_query))
        {
        echo $email['code'] . '   ' . $email['contract_date'] . '<br>';
        }
	    exit;
	    */
	    while($email = pf_db_fetch_array($email_query))
        {
        $code  		=  $email['code'];
        $event = new ms_event(10, $code);
        $event->execute();
        }

	    pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'err_no=' . $err_no . '&action=email_succes'));
	}	
    }
    $err_no  =  2;
    pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'err_no=' . $err_no));
}

// action reservation_extend
if (isset($action) && ($action == 'reservation_extend'))
{
	// sprawdzanie czy okres nie zajęty
    $e_reservation_query  	=  pf_db_query("select * from " . TABLE_RESERVATIONS . " r, " .TABLE_CUSTOMERS . " c where code = '" . addslashes($code) . "' and r.reservation_id = c.reservation_id");
    $e_reservation  		=  pf_db_fetch_array($e_reservation_query);
 // $start_date_temp = date('Y-m-d', (strtotime($e_reservation['start_day'])+86400));
 // $end_date_temp = date('Y-m-d', (strtotime($e_reservation['end_day'])-86400));
 
//	$reservation_query = pf_db_query("select * from " . TABLE_RESERVATIONS . " where (house_id  =  " . $e_reservation['house_id'] . ") AND  (('" . $start_date_temp . "' BETWEEN start_day AND end_day ) OR ('" . $end_date_temp . "' BETWEEN start_day AND end_day ) OR ( start_day BETWEEN '" . $start_date_temp . "'AND '" . $end_date_temp . "' ) OR ( end_day BETWEEN '" . $start_date_temp . "' AND '" . $end_date_temp . "' ) ) AND outdated = '0' AND reservation_id!= '" . $e_reservation['reservation_id'] . "'");
  

$house_query  	=  pf_db_query("select h.house_id, type_id, multi_count from " . TABLE_HOUSES . " h, " . TABLE_RESERVATIONS . " r , " . TABLE_HOUSES_PROPERTIES . "  hp where (r.code = " . $code . ") AND (r.house_id = h.house_id) AND (hp.house_id  =  h.house_id)");	
$house_info  	=  pf_db_fetch_array($house_query);
$house_id  	=  $house_info['house_id'];
$house_type	=  $house_info['type_id'];
$multi_count	=  $house_info['multi_count'];

/////////////////////// sprawdzanie czy okres nie zajęty ////////////////////////////////////


$start_date_temp 	= date('Y-m-d', (strtotime($e_reservation['start_day'])+86400));
$end_date_temp 		= date('Y-m-d', (strtotime($e_reservation['end_day'])-86400));

$reservation_query 	= pf_db_query("select * from " . TABLE_RESERVATIONS . " where  (house_id = '" . $house_id . "')  AND (('" . $start_date_temp . "' BETWEEN start_day AND end_day ) OR ('" . $end_date_temp . "' BETWEEN start_day AND end_day ) OR ( start_day BETWEEN '" . $start_date_temp . "'AND '" . $end_date_temp . "' ) OR ( end_day BETWEEN '" . $start_date_temp . "'AND '" . $end_date_temp . "' ) ) AND outdated = '0' AND trash = '0' AND code!= '" . $code . "'");

    if($house_type  ==  0) //zwykly
    {
	if(pf_db_num_rows($reservation_query))
	{
	    pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'&action=extend&info=no'));
	}
    }
    
    if($house_type  ==  1) //zbiorczy
    {
	$period_array  		=  array();
	$start_day_array  	=  array();	
	$end_day_array  	=  array();
	$counter 		= 0;
    
	while($row = pf_db_fetch_array($reservation_query))
	{
	    $period_array[]  	= array('start' =>$row['start_day'],'end'  => $row['end_day']);
	    $start_day_array[] 	= $row['start_day'];	
	    $end_day_array[] 	= $row['end_day'];
	}

	$current_date = $e_reservation['start_day'];
	$ii = 0;
    
	while($current_date != $e_reservation['end_day'])
	{
      
    	    if($ii>100) {break;}
    	    $ii++;
      
    	    $counter = 0;
    	    foreach($period_array as $line)
          {
          if((strtotime($current_date) >=  strtotime($line['start'])) && (strtotime($current_date) <=  strtotime($line['end'])))
            {
              $counter++;
            }
          }

    	    if(in_array($current_date,$end_day_array))
            {
        	foreach($end_day_array as $line)
        	{
        	    if($line  ==  $current_date)
		    {
            	        $counter--;
		    }
        	}
         
            }
      
    	    if($counter >=  $multi_count)
    	    {
    		pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'&action=extend&info=no'));
    	    } 
        
    		 $current_date  =  date('Y-m-d', (strtotime($current_date)+86400));
	}
  
  } 
  
  if($house_type  ==  2) // podrzedny
  {
  //echo 'pod<br>';
    $houses_temp=search_rel(array($house_id));
    $sql_query="select reservation_id from reservations where (trash='0') AND outdated='0' AND (house_id IN (" .  implode(',', $houses_temp ) . ")) AND  (('" . $start_date_temp . "' BETWEEN start_day AND end_day ) OR ('" . $end_date_temp . "' BETWEEN start_day AND end_day ) OR ( start_day BETWEEN '" . $start_date_temp . "'AND '" . $end_date_temp . "' ) OR ( end_day BETWEEN '" . $start_date_temp . "'AND '" . $end_date_temp . "' ) )  AND reservation_id!= '" . (int)$e_reservation['reservation_id'] . "'";

   
    $reservation_query  =  pf_db_query($sql_query);

    if(pf_db_num_rows($reservation_query) || !pf_checkdate($start_date_temp) || !pf_checkdate($end_date_temp) || strtotime($start_date_temp)< time()-86400 || $start_year-1 > (int)date('Y') || (strtotime($end_date_temp) - strtotime($start_date_temp)) > 31104000)
    {
	pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'&action=extend&info=no'));
    }
  
  }
  if($house_type  ==  3) // nadrzedny
  {
  //echo 'nad<br>';
    $houses_temp=search_rel(array($house_id));
    $sql_query="select reservation_id from reservations where (trash='0') AND outdated='0' AND (house_id IN (" .  implode(',', $houses_temp ) . ")) AND  (('" . $start_date_temp . "' BETWEEN start_day AND end_day ) OR ('" . $end_date_temp . "' BETWEEN start_day AND end_day ) OR ( start_day BETWEEN '" . $start_date_temp . "'AND '" . $end_date_temp . "' ) OR ( end_day BETWEEN '" . $start_date_temp . "'AND '" . $end_date_temp . "' ) )  AND reservation_id!= '" . (int)$e_reservation['reservation_id'] . "'";
  
    $reservation_query  =  pf_db_query($sql_query);

    if (pf_db_num_rows($reservation_query) || !pf_checkdate($start_date_temp) || !pf_checkdate($end_date_temp) || strtotime($start_date_temp)< time()-86400 || $start_year-1 > (int)date('Y') || (strtotime($end_date_temp) - strtotime($start_date_temp)) > 31104000)
    {
    pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'&action=extend&info=no'));
    }
  }

  //if(pf_db_num_rows($reservation_query))
//    {
    // podany okres zajęty
    //pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'&action = extend&info = no'));
//    }
   // else
//    {
    $new_expired = -((strtotime($e_reservation['add_date']) - time())/3600)+1;
    pf_db_query("update ". TABLE_RESERVATIONS . " set outdated = '0', expired = '" . $new_expired . "' where reservation_id = '" . (int)$e_reservation['reservation_id'] . "'");
    pf_redirect(pf_href_link(FILENAME_CUSTOMER_LOGIN,'code='.$code));
//		}
	
 
/////////////////////// sprawdzanie czy okres nie zajęty _EOF ////////////////////////////////////
		
}

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv = "Content-Type" content = "text/html; charset = <?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel = "stylesheet" type = "text/css" href = "stylesheet.css">
</head>
<body onLoad = "document.login.reservation_code.focus()" style="text-align:center;">
<!-- body //-->
<?php require(KAT_INCLUDES . 'header.php'); ?>

<!-- body_text //-->
			<table border = "0" cellspacing = "0" cellpadding = "0" align = "center"> 
				<tr>
					<td><?php echo pf_draw_separator('pixel_trans.gif','100%', '55');?></td>
				</tr>
				<tr valign = "middle">
					<td>
							<table border = "0" width = "100%" cellspacing = "0" cellpadding = "0">
								<tr>
									<td align = "left" class = "header_left"></td>
									<td class = "header_center"><?php echo TEXT_HEADER;?>&nbsp;&nbsp;</td>
									<td align = "right" class = "header_right"></td>
								</tr>
							</table>
					</td>
				</tr>
				<tr>
					<td class = "main_left_right">
<?php
	 if((!isset($error_no) || $error_no!= 2) && $action!= 'extend')
	 { // zwykly formularz
?>
<!-- formularz do logowania -->
<?php
echo pf_draw_form('login', FILENAME_CUSTOMER_LOGIN ,'action=process' . (isset($_GET['auth']) ? '&amp;auth=' . htmlspecialchars($_GET['auth']) : '') . (isset($_GET['redirect']) ? '&amp;redirect=' . htmlspecialchars($_GET['redirect']) : ''));
?>
						<table border = "0" cellspacing = "0" cellpadding = "2" class = "solidBox">
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '10');?></td>
							</tr>
							<tr>	
								<td colspan = "2" class = "main"><b><?php echo TEXT_INFO;?></b></td>
							</tr>
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_silver.gif','100%', '1');?></td>
							</tr>
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '5');?></td>
							</tr>
<?php 
	if(pf_not_null($error_no) && $error_no  ==  1)
	{ //monit jesli nie podany kod
?>
							<tr>
								<td colspan = "2" class = "smallRedText"><?php echo TEXT_ERROR1;?></td>
							</tr>
<?php
	}
?>

<?php 
	if(pf_not_null($error_no) && $error_no  ==  3)
	{ //monit jesli usunieta
?>
							<tr>
								<td colspan = "2" class = "smallRedText"><?php echo TEXT_ERROR3;?></td>
							</tr>
<?php
	}
?>

<?php 
	if(pf_not_null($error_no) && $error_no  ==  6)
	{ //monit jesli usunieta
?>
							<tr>
								<td colspan = "2" class = "smallRedText"><?php echo TEXT_ERROR6;?></td>
							</tr>
<?php
	}
?>
			
			<?php if (isset($_SERVER['HTTPS']))
			{
			?>
			<tr>
				<td colspan="2" class = "main" style="color:green;" align = "right"><?php echo TEXT_SAFE_LOGIN_DESC;?>
				<img src="images/padlock.png" width="20px" alt="padlock" title="<?php echo TEXT_SAFE_LOGIN_DESC; ?>">
				</td>
			</tr>
			<?php 	
			}?>
			
              <tr>
                <td class = "main" align = "right"><?php echo ENTRY_CODE;?></td>
                <td class = "main" align = "left"><?php echo pf_draw_text_field('reservation_code',$code,'size = 25');?></td>
              </tr>
              <tr>
              	<td class = "main" align = "right"><?php echo ENTRY_EMAIL;?></td>
                <td class = "main" align = "left"><?php echo pf_draw_text_field('email',$emailPost,'size = 25');?></td>
							</tr>
							<?php
							/*
							<tr>
								<td colspan = "2"><center><img id = "siimage" src = "securimage/securimage_show.php?sid = <?php echo md5(uniqid(time())); ?>"><br/>
	<a title = "Wersja Audio" href = "securimage/securimage_play.php" style = "border-style: none;" tabindex = "-1"><img border = "0" align = "top" onclick = "this.blur()" alt = "Audio Version" src = "securimage/images/audio_icon.gif"/></a>
<a onclick = "document.getElementById('siimage').src  =  'securimage/securimage_show.php?sid = ' + Math.random(); return false" title = "Refresh Image" href = "#" style = "border-style: none;" tabindex = "-1">
<img border = "0" align = "bottom" onclick = "this.blur()" alt = "Reload Image" src = "securimage/images/refresh.gif"/></a></center></td>
							</tr>
							<tr>
							<td class = "main"><?php echo ENTRY_CAPTCHA;?></td>
							<td class = "main"><?php echo pf_draw_text_field('captcha_code','','size = 6');?></td>							
							</tr>
							*/
							?>
							<tr>
							<td></td>
								<td colspan = "2" class = "main" align = "left"><a href="<?php echo FILENAME_CUSTOMER_LOGIN . '?err_no=2' ;?>"><?php echo TEXT_FORGOTTEN_CODE;?></a></td>
							</tr>
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '10');?></td>
							</tr>
							<tr>
								<td class = "main"  colspan = "2" align = "center	">
									<input type = "submit" value = "<?php echo TEXT_ENTRANCE;?>"></td>
									<td class = "main">
								</td>
							</tr>
							
							<tr>
								<td class = "main"  colspan = "2" align = "right">
								<?php 
								$code_link=($code!='') ? '?code='.$code : '';
								$lang_ling = ($code!='') ? '&lng='.$_SESSION['language'] : '?lng='.$_SESSION['language'];
								
								if(isset($_SERVER['HTTPS']))
								{	
								echo '<a href="'.str_replace('https:', 'http:', SERVER.KAT_WEBSITE).'c_login.php'.$code_link.$lang_link.'" style="text-align: right;color:blue;text-decoration:underline">'. TEXT_NOT_SAFE_LOGIN.'</a></td>';
								}
								else 
								{
								echo '<a href="'.str_replace('http:', 'https:', SERVER.KAT_WEBSITE).'c_login.php'.$code_link.$lang_ling.'" style="text-align: right;color:blue;text-decoration:underline">'. TEXT_SAFE_LOGIN.'</a></td>'; 	
								}?>
									<td class = "main">
								</td>
							</tr>
							
						</table>						
						</form>
						
<!-- formularz do logowania  EOF -->

<?php
} 
 if((@$_GET['err_no']  ==  2) && ($action != 'email_succes'))
 { //formularz do wyslania maila z zapomnianym kodem
?>
<!-- formularz do logowania  2 -->
<?php
    echo pf_draw_form('code_forgotten',FILENAME_CUSTOMER_LOGIN,'action=email_code');
?>
						<table border = "0" cellspacing = "0" cellpadding = "2" class = "solidBox">
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '10');?></td>
							</tr>
							<tr>	
								<td colspan = "2" class = "main"><b><?php echo (isset($_GET['code']) ? htmlspecialchars($_GET['code']) . '<br>' . TEXT_CODE_FORGOTTEN :  TEXT_MAIL_CODE) ?></b></td>
							</tr>
							<tr>	
								<td colspan = "2" class = "main"><b><?php echo TEXT_CHECK_SPAM; ?></b></td>
							</tr>
<?php
	if($email_error  ==  1){
?>
							<tr>
								<td colspan = "2" class = "smallRedText"><?php echo TEXT_EMAIL_ERROR;?></td>
							</tr>
<?php
	}
?>
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_silver.gif','100%', '1');?></td>
							</tr>
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '5');?></td>
							</tr>
              <tr>
                <td class = "main" align = "right"><?php echo ENTRY_EMAIL;?></td>
                <td class = "main" align = "left"><?php echo pf_draw_text_field('email','','size = 40');?></td>
							</tr>
			
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '10');?></td>
							</tr>
							<tr>
								<td class = "main"  colspan = "2" align = "center	">
									<input type = "submit" value = "<?php echo TEXT_SUBMIT;?>"></td>
									<td class = "main">
								</td>
							</tr>
							

						</table>
						</form>
<!-- formularz do logowania  2 EOF -->
<?php
}
if ($action  ==  'email_succes'){ // info o wyslaniu maila z przypomnieniem kodu
?>
						<table border = "0" cellspacing = "0" cellpadding = "2" class = "solidBox">
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '10');?></td>
							</tr>
							<tr>	
								<td colspan = "2" class = "main"><b><?php echo TEXT_EMAIL_SUCCESS;?></b></td>
							</tr>
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '10');?></td>
							</tr>
							<tr>
								<td colspan = "2" class = "main" align = "center"><a href = "<?php echo pf_href_link(FILENAME_CUSTOMER_LOGIN);?>"><input type = "button" value = "<?php echo TEXT_BACK;?>"></a></td>
							</tr>
						</table>
<?php
} else {
if($action  ==  'extend') { // przedluzenie rezerwacji

	echo pf_draw_form('reservation_extend',FILENAME_CUSTOMER_LOGIN,'action=reservation_extend&code=' .$code );
?>
			
						<table border = "0" cellspacing = "0" cellpadding = "2" class = "solidBox">
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '10');?></td>
							</tr>
					<?php if(isset($_GET['info']) && $_GET['info']  ==  'no'){ // juz zajety termin
					?>
							<tr>	
								<td colspan = "2" class = "main"><b><?php echo TEXT_EXTEND_RESERVATION_UNABLE;?></b></td>
							</tr>
					<?php
							} else {								
					?>
							<tr>	
								<td colspan = "2" class = "main"><b><?php echo TEXT_EXTEND_RESERVATION;?></b></td>
							</tr>
							<tr>
								<td colspan = "2" class = "main"><?php echo pf_draw_separator('pixel_trans.gif','100%', '10');?></td>
							</tr>
							<tr>
								<td colspan = "2" class = "main" align = "center"><input type = "submit" value = "<?php echo TEXT_GO;?>"></td></td>
							</tr>
					<?php
									}
					 ?>
						</table>
</form>
<?php
}
}
?>


				</td>
			</tr>
			<tr>
				<td class = "main_bottom"><?php echo pf_draw_separator('pixel_trans.gif','100%', '5');?></td>
			</tr>
			</table>
			<div style='margin-left: auto; margin-right: auto; width: 450px; text-align: center; padding: 30px; margin-top: 30px; color: #444; font-family: "trebuchet ms",Arial,Verdana,sans-serif; font-size: 11px;line-height: 1.5;'>
        <?php echo TEXT_LOGIN_CUSTOMER_INFO;?>
			</div>
<!-- body text eof //-->
<!-- body_eof //-->
</body>
</html>
