<?php include("header.php");?>

<?php
if(p('blog_adi') && g('islem')=="")
{
	$blog_adi 	= $_POST['blog_adi'];
	$etiket 	= $_POST['etiket'];
	$boluma 	= $_POST['boluma'];
	$bolumb 	= $_POST['bolumb'];
	$bolumc 	= $_POST['bolumc'];
	$bolumd 	= $_POST['bolumd'];
	$bolume 	= $_POST['bolume'];
	$bolumf 	= $_POST['bolumf'];
	$bolumg 	= $_POST['bolumg'];
	

	$durum 		= p('durum');
	$aciklama	= addslashes($_POST['aciklama']);
	$seo		= seo($blog_adi);
	$t			= date("Y-m-d H:i:s");
	$k_tarih	= tarih($t);
	
	include_once('class.upload.php');
	$upload = new upload($_FILES['resim']);
	if ($upload->uploaded){
	$upload->file_auto_rename = true;
	$upload->process("../resimler/dataa");
	
	$upload->file_auto_rename = true;
	$upload->image_resize = true;
	$upload->image_ratio_crop = true;
	$upload->image_x = 345;
	$upload->image_y = 243;
	$upload->process("../resimler/dataa/kucuk");
	
	if ($upload->processed){
	$blogResim=''.$upload->file_dst_name.'';
	}
	}
	$gitti=$blogResim=''.$upload->file_dst_name.'';
	
	$blog_sorgu	=	Sorgu("INSERT INTO dataa SET
										adi		=	'$blog_adi', 
										boluma		=	'$boluma',
										bolumb		=	'$bolumb',
										bolumc		=	'$bolumc',
										bolumd		=	'$bolumd',
											bolume		=	'$bolume',
											bolumf		=	'$bolumf',                    
											bolumg		=	'$bolumg',
											
										resim	=	'$blogResim',
										seo		=	'$seo',
										etiket	=	'$etiket', 										
										aciklama=	'$aciklama',
										durum	=	'$durum',
										tarih	=	'$k_tarih'");	
																								   
		$bilgi = '  		  <div class="alert alert-success alert-block fade in">
                                  <button data-dismiss="alert" class="close close-sm" type="button">
                                      <i class="fa fa-times"></i>
                                  </button>
                                  <h4>
                                      <i class="fa fa-ok-sign"></i>
                                      Başarılı!
                                  </h4>
                                  <p>Başarıyla eklenmiştir...</p>
                              </div>
		 ' ;
		
}


if(p('blog_adi') && g('islem')=="duzenle")
{
	$blog_adi 	= $_POST['blog_adi'];
	$etiket 	= $_POST['etiket'];
	$boluma 	= $_POST['boluma'];
	$bolumb 	= $_POST['bolumb'];
	$bolumc 	= $_POST['bolumc'];
	$bolumd 	= $_POST['bolumd'];
	$bolume 	= $_POST['bolume'];
	$bolumf 	= $_POST['bolumf'];
	$bolumg 	= $_POST['bolumg'];

	$durum 		= p('durum');
	$d_id 		= g('id');
	$aciklama	= addslashes($_POST['aciklama']);
	$seo		= seo($blog_adi);
	$t			= date("Y-m-d H:i:s");
	$k_tarih	= tarih($t);
	
	include_once('class.upload.php');
	$upload = new upload($_FILES['resim']);
	if ($upload->uploaded){
	$upload->file_auto_rename = true;
	$upload->process("../resimler/dataa");
	
	
	$upload->file_auto_rename = true;
	$upload->image_resize = true;
	$upload->image_ratio_crop = true;
	$upload->image_x = 345;
	$upload->image_y = 243;
	$upload->process("../resimler/dataa/kucuk");
	
	if ($upload->processed){
	$blogResim=''.$upload->file_dst_name.'';
	}
	}
	if($blogResim!="")
	{
		$resim_bul	=Sonuc(Sorgu("SELECT * FROM dataa WHERE id='$d_id'"));
		$resim_sil	=unlink("../resimler/dataa/".$resim_bul->resim);
		$resim_sil	=unlink("../resimler/dataa/kucuk/".$resim_bul->resim);
	
		$blog_duzenle_sorgu	=	Sorgu("UPDATE dataa SET 
											adi		=	'$blog_adi', 
											
											boluma		=	'$boluma',
											bolumb		=	'$bolumb',
											bolumc		=	'$bolumc',
											bolumd		=	'$bolumd',
											bolume		=	'$bolume',
											bolumf		=	'$bolumf',
											bolumg		=	'$bolumg',
										
											
											resim	=	'$blogResim', 
											aciklama=	'$aciklama',
											seo		=	'$seo', 
											etiket	=	'$etiket', 
											durum	=	'$durum', 
											tarih	=	'$k_tarih'
											WHERE id=	'$d_id'");
		$gitti=$blogResim=''.$upload->file_dst_name.'';
	}else{	
		$blog_duzenle_sorgu = Sorgu("UPDATE dataa SET 
											durum	=	'$durum', 
											aciklama=	'$aciklama', 
											seo		=	'$seo', 
											etiket	=	'$etiket', 
											adi		=	'$blog_adi', 
											boluma	=	'$boluma',
											bolumb		=	'$bolumb',
											bolumc		=	'$bolumc',
											bolumd		=	'$bolumd',
											bolume		=	'$bolume',
											bolumf		=	'$bolumf',
											bolumg		=	'$bolumg',
											
										
											tarih	=	'$k_tarih' 
											WHERE id=	'$d_id'");
	}
				  $bilgi = ' 		  
							  <div class="alert alert-success alert-block fade in">
                                  <button data-dismiss="alert" class="close close-sm" type="button">
                                      <i class="fa fa-times"></i>
                                  </button>
                                  <h4>
                                      <i class="fa fa-ok-sign"></i>
                                      Başarılı!
                                  </h4>
                                  <p>Başarıyla güncellenmiştir...</p>
                              </div>
							  
							  
		 ' ;
}


if($_GET['islem']=="duzenle")
{
	$sayfaid = $_GET['id'];	
	$durum = "duzenle" ;
	
	$blogSonuc = Sonuc(Sorgu("SELECT * FROM dataa WHERE id='$sayfaid'"));
	
}

?>

 <!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              <!-- page start-->
        
            

              <div class="row">
                  <div class="col-lg-12">
				    <?php echo $bilgi;?>
                      <section class="panel">
                          <header class="panel-heading">
                          Kurumsal Sayfa Ekle
                          </header>
                          <div class="panel-body">
                              <form class="form-horizontal tasi-form" method="post" action="" enctype="multipart/form-data">
							  
							  

                                  <div class="form-group">
                                      <label class="col-sm-2 col-sm-2 control-label">Sayfa Adı</label>
                                      <div class="col-sm-10">
                                        <input type="text" class="form-control" name="blog_adi" value="<?php echo $blogSonuc->adi;?>" id="blog_adi" placeholder="">
                                      </div>
                                  </div>
                             
                         
						 
						 
						 
						 
						 
						 
						          <div class="row m-bot15">
                                  <?php if($_GET['islem']=="duzenle"){?>
								 <label class="col-sm-2 col-sm-2 control-label">Durumu</label>
                                           <div class="col-sm-10">
                                           <input type="checkbox" name="durum" <?php if($blogSonuc->durum == '1') {?> checked <?php } ?> value="1" data-toggle="switch"/>
                                          </div>
                                        	<?php }else{?>
											 <label class="col-sm-2 col-sm-2 control-label">Durumu</label>
                                          <div class="col-sm-10">
                                           	<input type="checkbox" name="durum" value="1" checked data-toggle="switch"/>
                                          </div>
										  <?php } ?>
                                      </div>
						 
						 
						 
						 
							 
						 
						 			 			 		 
						   <div class="form-group">
                                         <label class="col-sm-2 col-sm-2 control-label">Açıklama</label>
                                          <div class="col-sm-10">
                                            
                   
                    <textarea class="ckeditor" id="summernote" name="aciklama" placeholder="İçerik Giriniz."><?php echo $blogSonuc->aciklama;?></textarea>
                   

                        
                                          </div>
                                      </div>
						 
						 
						 
						         <div class="form-group">
                                        <div class="col-sm-10">
									    <?php if($_GET['islem']=="duzenle"){?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                          <button class="btn btn-shadow btn-danger" type="submit">Güncelle</button>
										  <?php }else{?>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										  <button class="btn btn-shadow btn-success" type="submit">Kaydet</button>
										   <?php } ?>
                                      </div>
                                  </div>
						 
						 
						 
						 
						 
						 
                              </form>
                          </div>
                      </section>
                  
                      

           

               

                  </div>
              </div>
              <!-- page end-->
          </section>
      </section>
      <!--main content end-->





















<?php include("footer.php");?>