<?php
session_start();
include_once 'control/ayarlar.php';
$mysql_baglanti= new yonetici(); 
$mysql_baglanti->mysql_baglan();
error_reporting(E_ALL ^ E_NOTICE);
ini_set('error_reporting', E_ALL ^ E_NOTICE); 
?>
<? include 'functions.php'?>

<? if ($_POST['islem'] == "gng"){?>
   	<? $page_data=mysql_fetch_assoc(mysql_query("Select * from news where id='".addslashes($_POST['news'])."' and status='0'")) ?>
    <? $page_data_l=mysql_fetch_assoc(mysql_query("Select * from l_news where news='".addslashes($_POST['news'])."' and language='".$language."'")) ?>
   	<img src="<?=$page_data['image']?>" class="big_image"  alt="<?=stripslashes($page_data_l['title'])?>" />
    
<? }?>
<? if ($_POST['islem'] == "get_service_point"){?>
  	
  	<section class="m_bottom_48">
	<h5 class="color_dark  second_font fw_light m_bottom_13 m_top_15">Servis Noktalarımız</h5>
	<hr class="divider_bg m_bottom_30">
   	<? $query=mysql_query("Select * from service_point where city='".addslashes($_POST['plakakodu'])."'") ?>
   	<div class="row">
		<? while ($page_data=mysql_fetch_assoc($query)){?>
		<div class="col-lg-6 col-md-6 col-sm-12 m_xs_bottom_10">
			<div class="banner_type_2 not_link scheme_color m_xs_bottom_30 m_bottom_10">
				<div class="bg_scheme_color inner color_white">

					<div class="m_left_15 lh_large m_xs_left_0">
						<p class="second_font  fw_bold m_bottom_5 fs_big_4"><?=stripslashes($page_data['title'])?></p>
						<p class="fs_large fw_light"><strong>Yetkili Kişi:</strong> <?=stripslashes($page_data['person'])?></p>
						<p class="fs_large fw_light"><?=stripslashes($page_data['address'])?><br />
							<? if ($page_data['gsm']<>''){?><strong>Gsm :</strong> <?=stripslashes($page_data['gsm'])?> <? }?>
							<? if ($page_data['phone']<>''){?><strong>Telefon :</strong> <?=stripslashes($page_data['phone'])?> <? }?>
							<? if ($page_data['fax']<>''){?><strong>Faks:</strong> <?=stripslashes($page_data['fax'])?><? }?>
						</p>
					</div>
				</div>

			</div>
		</div>

		<? }?>
	</div>
    </section>
<? }?>
<? if ($_POST['islem'] == "get_sales_point"){?>
  	
  	<section class="m_bottom_48">
	<h5 class="color_dark  second_font fw_light m_bottom_13 m_top_15">Satış Noktalarımız</h5>
	<hr class="divider_bg m_bottom_30">
   	<? $query=mysql_query("Select * from sales_point where city='".addslashes($_POST['plakakodu'])."'") ?>
   	<div class="row">
   	
		<? while ($page_data=mysql_fetch_assoc($query)){?>
		<div class="col-lg-6 col-md-6 col-sm-12 m_xs_bottom_10">
		<!--call to action-->
			<div class="banner_type_2 not_link scheme_color m_xs_bottom_30 m_bottom_10">
				<div class="bg_scheme_color inner color_white">

					<div class="m_left_15 lh_large m_xs_left_0">
						<p class="second_font  fw_bold m_bottom_5 fs_big_4"><?=stripslashes($page_data['title'])?></p>
						<p class="fs_large fw_light"><?=stripslashes($page_data['address'])?><br />
							<? if ($page_data['phone']<>''){?><strong>Telefon :</strong> <?=stripslashes($page_data['phone'])?> <? }?>
							<? if ($page_data['fax']<>''){?><strong>Faks:</strong> <?=stripslashes($page_data['fax'])?><? }?>
							
						</p>
					</div>

				</div>
			</div>
		</div>
		<? }?>
    
    </div>
    </section>
<? }?>

<? if ($_POST['islem'] == "newsletter"){?>
	<? $qq=mysql_query("Select * from newsletter where email='".addslashes($_POST['newsletter-email'])."'")?>
    <? if (mysql_num_rows($qq)==0){?>
	<? mysql_query("INSERT INTO newsletter (email,created) VALUES ('".addslashes($_POST['newsletter-email'])."','".date('Y-m-d H:i:s')."')")?>
  	<? echo "success";?>
    <? }else{?>
    <? echo "decline";?>
    <? }?>
<? }?>
<? if ($_POST['islem'] == "calc"){?>   
<? 
	$power=$_POST['power'];
	$power_top=$power*1.5;
?>
<div class="col-full">

	<div class="widget widget_links clearfix">
		<h4>(Hesaplanan Değer - <?=$power?> VA)<br />İhtiyacınıza Uygun UPS Modelleri </h4>
		<ul>
		<? $q=mysql_query("Select * from products where kwa<>'' order by parent");?>
		<? while ($d=mysql_fetch_assoc($q)){?>
		<? $l=mysql_fetch_assoc(mysql_query("Select * from l_products where product='".$d['id']."' and language='".$language."'"));?>
		<? $control=0;?>
		<?
		$powerlist=explode(",",$d['kwa']);
		$size=sizeof($powerlist);
		for ($i=1; $i<$size; $i++){
			if (($powerlist[$i] >= $power) && ($powerlist[$i] <= $power_top)){$control=1;};
		}
		?>
		<? if ($control==1){?>
			<li><a href="<?=stripslashes($l['link'])?>"><?=stripslashes($l['title'])?> <?=stripslashes($l['power'])?></a></li>
		<? }?>
		
		<? $control=0;?>
			
		<? }?>
			
		</ul>
		<div class="clear"></div>
	</div>
	<div class="clear"></div>
</div>
<? }?>



<? if ($_POST['islem'] == "contactform"){?>
	<? if (($_POST['cf_control']==8)&&($_POST['cf_name']!='')&&($_POST['cf_email']!='')&&($_POST['cf_telephone']!='')&&(strlen($_POST['cf_message'])<20)){?>
    <? require_once("mail/class.phpmailer.php");?>
	
    	<?php
        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        $mail->IsHTML(true);
	
		$mail->Host = 'mail.mustafabalakar.com';
		$mail->Port = 587; 
		$mail->Username = "noreply@mustafabalakar.com";
		$mail->Password = "nor2017/";
		$mail->From = "noreply@artemis.com.tr";
       
		$mail->CharSet="UTF-8";
		$mail->FromName = 'Artemis Websitesi';

		$mail->AddAddress('info@artemis.com.tr','İletişim Formu');

		$mail->Subject = 'Artemis İletişim Formu - '.addslashes($_POST['cf_name']);
        
		$mail_content='
		<table align="center" border="0" cellpadding="0" cellspacing="0" width="680">
		 		
		<tr><td><table align="center" border="0" cellpadding="0" cellspacing="0" width="680">
				<tr>
				  <td colspan="2" style="padding: 20px; border: 1px solid rgb(236, 236, 236); font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: rgb(51, 51, 51);">
				  <b>İletişim Formu</b></td>
				</tr>
			  </table>
			</td>
		</tr>
		<tr>
			<td><table align="center" border="0" cellpadding="0" cellspacing="0" width="680">
				<tr>
				  <td colspan="2" style="padding: 20px; border: 1px solid rgb(236, 236, 236); font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: rgb(51, 51, 51);">
				  <p>Sayın yetkili aşağıda yer alan bilgilere göre iletişime geçmeniz önemle rica olunur. <br />
					<br />
					</p>
					<p><b>İsim :</b>'.addslashes($_POST['cf_name']).'</p>
					<p><b>Telefon  :</b>'.addslashes($_POST['cf_telephone']).'</p>
					<p><b>E-Posta  :</b>'.addslashes($_POST['cf_email']).'</p>
					<p><b>Mesaj  :</b>'.addslashes($_POST['cf_message']).'</p>
					</td>
				</tr>
			  </table></td>
		  </tr>
		 </table> 
		 ';
		
		$mail_body=$mail_content;
        $mail->Body = $mail_body;
        $mail->Send();
		echo "success";}else{ 
		echo "warning";
		}
		?>
        
    
    
<? }?>


<? if ($_POST['islem'] == "hrform"){?>
	<? $dizin="files";?>
	<? if (($_POST['cf_control']==8)&&($_POST['cf_name']!='')&&($_POST['cf_email']!='')&&($_POST['cf_telephone']!='')&&(strlen($_POST['cf_message'])>20)){?>
	
	<? 
    $file='';
    if ($_FILES["cf_file"]["error"]== 0)
    {
        $file=turkcekarakter($_FILES['cf_file']['name']);
        $random=rand(1,99999);
        $file="$dizin/".$random.$file;
        move_uploaded_file($_FILES['cf_file']['tmp_name'],$file); // yükleme işlemi
    }?>
    <? 
    mysql_query("Insert Into hr (name, phone, email, comments, file, created_date) values ('".addslashes($_POST['cf_name'])."', '".addslashes($_POST['cf_telephone'])."', '".addslashes($_POST['cf_email'])."','".addslashes($_POST['cf_message'])."','".$file."', '".date('Y-m-d H:i:s')."')");
    ?>
    <? require_once("mail/class.phpmailer.php");?>
    	<?php
        $mail = new PHPMailer();
		$mail->SetLanguage("tr", 'mail/language');
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        $mail->IsHTML(true);
		$mail->Host = 'mail.mustafabalakar.com';
		$mail->Port = 587; 
		$mail->Username = "noreply@mustafabalakar.com";
		$mail->Password = "nor2017/";
		$mail->From = "noreply@artemis.com.tr";
       
		$mail->CharSet="UTF-8";
		$mail->FromName = 'Artemis Websitesi';

		$mail->AddAddress('info@artemis.com.tr','Kariyer Formu');
		$mail->Subject = 'Artemis Kariyer Formu - '.addslashes($_POST['cf_name']);
        
		$mail_content='
		<table align="center" border="0" cellpadding="0" cellspacing="0" width="680">
		 		
		<tr><td><table align="center" border="0" cellpadding="0" cellspacing="0" width="680">
				<tr>
				  <td colspan="2" style="padding: 20px; border: 1px solid rgb(236, 236, 236); font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: rgb(51, 51, 51);">
				  <b>İnsan Kaynakları Formu</b></td>
				</tr>
			  </table>
			</td>
		</tr>
		<tr>
			<td><table align="center" border="0" cellpadding="0" cellspacing="0" width="680">
				<tr>
				  <td colspan="2" style="padding: 20px; border: 1px solid rgb(236, 236, 236); font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: rgb(51, 51, 51);">
				  <p>Sayın yetkili aşağıda yer alan bilgilere göre iletişime geçmeniz önemle rica olunur. <br />
					<br />
					</p>
					<p><b>İsim :</b>'.addslashes($_POST['cf_name']).'</p>
					<p><b>Ev Telefonu  :</b>'.addslashes($_POST['cf_telephone']).'</p>
					<p><b>E-Posta  :</b>'.addslashes($_POST['cf_email']).'</p>
					<p><b>Mesaj  :</b>'.addslashes($_POST['cf_message']).'</p>';
					?>
					<?
					if($file!=''){$mail_content.='<p><b>Ekli Dosya  :</b><a href="http://www.artemis.com.tr/'.$file.'">Dosyayı İndir </a></p><br />';}?>
                    <? $mail_content.='
					</td>
				</tr>
			  </table></td>
		  </tr>
		 </table> 
		 ';
		$mail_body=$mail_content;
        $mail->Body = $mail_body;
			if(!$mail->Send()){
				echo "Mailer Error: ".$mail->ErrorInfo;
			} else {
				echo "success";
			}
		}else{ 
		echo "warning";
		}
		?>
<? }?>