<?php	 	
/**
* Template Name: CONTACTKZ
*/
?>
<?php	 	
    function rpHash($value) { 
            $hash = 5381; 
            $value = strtoupper($value); 
            for($i = 0; $i < strlen($value); $i++) { 
                $hash = (leftShift32($hash, 5) + $hash) + ord(substr($value, $i)); 
            } 
            return $hash; 
    } 
     
    // Perform a 32bit left shift 
    function leftShift32($number, $steps) { 
        // convert to binary (string) 
        $binary = decbin($number); 
        // left-pad with 0's if necessary 
        $binary = str_pad($binary, 32, "0", STR_PAD_LEFT); 
        // left shift manually 
        $binary = $binary.str_repeat("0", $steps); 
        // get the last 32 bits 
        $binary = substr($binary, strlen($binary) - 32); 
        // if it's a positive number return it 
        // otherwise return the 2's complement 
        return ($binary[0] == "0" ? bindec($binary) : 
            -(pow(2, 31) - bindec(substr($binary, 1)))); 
    } 
    if (!empty($_POST)) {
        $nume = $_POST['nume'] ?? '';
        $email = $_POST['email'] ?? '';
        $message = $_POST['mesaj'] ?? '';
        $subject = $_POST['subject'] ?? '';
        $validation_code = $_POST['validation'] ?? '';
        $hash = $_POST['hash'] ?? '';
        $hash_not_valid = false;
        if ($hash != rpHash($validation_code)) {
            $hash_not_valid = true;
        }
        else {
            require_once 'class.phpmailer.php';
            $new_mail = new PHPMailer(true);
            try {
              $new_mail->AddReplyTo($email, $nume);
              $admin_email = 'office@iqon.com';
              $new_mail->AddAddress($admin_email);
              //$new_mail->AddAddress('gabriel.ilie@gmail.com', 'Gabriel Ilie');
              $new_mail->SetFrom('contact@iqon.com', 'CONTACT FORM');
              $new_mail->Subject = '[IQON CONTACT FORM] '.$nume.' has sent you a message. Subject: '.$subject;
              $new_mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
              //$new_mail->MsgHTML(file_get_contents('contents.html'));
              $html = $nume.' has sent you an message.<br /><b>E-mail:</b> '.$email.'<br /><b>Subject:</b> '.$subject.'<br /><b>Message:</b> '.$message;
              $new_mail->MsgHTML($html);
              $new_mail->Send();
            } catch (phpmailerException $e) {
              echo $e->errorMessage(); //Pretty error messages from PHPMailer
            } catch (Exception $e) {
              echo $e->getMessage(); //Boring error messages from anything else!
            }
            
            echo '<script>top.location = "'.get_permalink(12).'?sent=ok";</script>';
            die();    
        }  
    }
?>
<?php	 	 $ascunde_services = true; ?>
<?php	 	 get_header(); ?>
<div class="contentleft">
    <p><h1 class="fontsize20 marginbottom20">Bucharest Office:</h1>
	10th Montreal Sq. <br />
	3rd Floor 3.01 bis Office <br />
	011469 Bucharest, Romania <br />
    <div id="linie-punctata"></div>
    <a href="mailto:office@iqon.com">office@iqon.com</a><br />
    <a href="https://t.me/infobidgebot">@infobidgebot</a></p>
</div>
<div class="contentright">
    <iframe width="700" height="250" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=str+montreal+bucuresti+iqon&amp;aq=&amp;sll=44.475036,26.07116&amp;sspn=0.006546,0.016512&amp;t=m&amp;g=str+montreal+bucuresti+nr+10&amp;ie=UTF8&amp;hq=iqon&amp;hnear=Pia%C5%A3a+Montreal,+Sector+1,+Bucure%C8%99ti,+Romania&amp;ll=44.475732,26.069977&amp;spn=0.003828,0.014999&amp;z=16&amp;output=embed"></iframe><br /><small><a href="https://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=str+montreal+bucuresti+iqon&amp;aq=&amp;sll=44.475036,26.07116&amp;sspn=0.006546,0.016512&amp;t=m&amp;g=str+montreal+bucuresti+nr+10&amp;ie=UTF8&amp;hq=iqon&amp;hnear=Pia%C5%A3a+Montreal,+Sector+1,+Bucure%C8%99ti,+Romania&amp;ll=44.475732,26.069977&amp;spn=0.003828,0.014999&amp;z=16" target="_blank" style="color:#0000FF;text-align:left">View Larger Map</a></small>
    <h2 class="margintop40">Please fill in the form below <?php	 	 if (($_GET['sent'] ?? '') == 'ok') { ?>[Your message has been sent.]<?php	 	 } ?></h2>
    <form action="" method="POST" id="formular_contact">
    <div class="rowInput">
        <label id="label_name">Your name (required):</label>
        <input type="text" name="nume" id="name" />
    </div>
    <div class="rowInput">
        <label id="label_email">Your email (required):</label>
        <input type="text" name="email" id="email" />
    </div>
    <div class="clear"></div>
    <!--<div class="rowInput">
        <label>Category:</label>
        <input type="text" name="name" id="name" />
    </div>-->
    <div class="rowInput">
        <label id="label_subject">Subject:</label>
        <input type="text" name="subject" id="subject" />
    </div>
    <div class="clear"></div>
    <div class="rowTextarea">
        <label id="label_mesaj">Message:</label>
        <textarea name="mesaj" id="mesaj"></textarea>
    </div>
    <div class="rowInput rowInputValidation">
        <label id="label_validation">Validation code(required):</label>
        <input type="text" name="validation" id="validation" value="" data-default="validation code" class="text validation" style="width: 100px!important; text-transform: uppercase;" />
    </div>
    <div class="clear"></div>
    <input type="submit" class="submitMessage" value="" />
    </form>
    <script type="text/javascript">
    $(document).ready(function() {
        $('#validation').realperson({length: 5, includeNumbers: false, hashName: 'hash'});
        $('#formular_contact').submit(function(event) {
            if (!$('#name').val()) {
                $('#label_name').addClass('notCompleted');
                event.preventDefault();   
            }
            else $('#label_name').removeClass('notCompleted');
            if (!$('#email').val()) {
                $('#label_email').addClass('notCompleted');
                event.preventDefault();   
            }
            else $('#label_email').removeClass('notCompleted');
            if (!$('#validation').val()) {
                $('#label_validation').addClass('notCompleted');
                event.preventDefault();   
            }
            else $('#label_validation').removeClass('notCompleted');
        });
    });
    </script>
    <div class="disclaimer">
        <strong>Disclaimer:</strong> IQON Romania takes all necessary measures to keep your personal information private and secure. Only authorized IQON Romania staff, Third Party companies (i.e. service providers) staff or our business partners' authorized staff (who have contractually agreed to keep all information secure) have access to your personal information.
    </div>
</div>
<?php	 	 get_footer(); ?>
