<?php session_start();?>
<?php
include_once 'ayarlar.php';
$mysql_baglanti= new yonetici(); 
$mysql_baglanti->mysql_baglan();
error_reporting(E_ALL ^ E_NOTICE);
ini_set('error_reporting', E_ALL ^ E_NOTICE); 
?>
<? if (isset($_SESSION['adminuser'])){?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?=$site_name?></title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="css/colorpicker.css" />
<link rel="stylesheet" href="css/datepicker.css" />
<link rel="stylesheet" href="css/uniform.css" />
<link rel="stylesheet" href="css/select2.css" />
<link rel="stylesheet" href="css/matrix-style.css" />
<link rel="stylesheet" href="css/matrix-media.css" />
<link rel="stylesheet" href="css/bootstrap-wysihtml5.css" />
<link href="font-awesome/css/font-awesome.css" rel="stylesheet" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
<? include 'tiny_script.php';?>
</head>
<body>
<? include 'inc_header.php'?>
<? include 'inc_leftmenu.php'?>
<div id="content">
<div id="content-header">
  <div id="breadcrumb"> <a href="index.php" title="Anasayfaya Git" class="tip-bottom"><i class="icon-home"></i>ANASAYFA</a><a href="#" class="current">DOSYALAR</a> </div>
  <h1>DOSYALAR</h1>
</div>
<div class="container-fluid">
  <hr>
  <div class="row-fluid">
  <? if (isset($_GET['f'])){?>
	<? if (isset($_POST['form_submit'])&&($_POST['form_submit']==1)){?>
        <? if ($_GET['f']=='add'){?>
        	
            <? mysql_query("Insert into l_gallery (title, link, gallery, language, meta_title, meta_keywords, meta_description) values ('".addslashes($_POST['title'])."','".addslashes($_POST['link'])."','".$_POST['gallery']."', '".$_POST['language']."', '".addslashes($_POST['meta_title'])."','".addslashes($_POST['meta_keywords'])."','".addslashes($_POST['meta_description'])."')");?>
            
            <? mysql_query("Insert into links (link, link_type, language, page) values ('".addslashes($_POST['link'])."','5','".$_POST['language']."','".$_POST['gallery']."')");?>
            <div class="alert green">
                <p><strong>Kayıt Başarılı!</strong> Kayıt başarıyla eklenmiştir.</p>
                <a href="#" class="close">close</a>
            </div>
            <script type="text/javascript" language="JavaScript">window.location.href="gallery.php"</script>
        <? }?>	
        <? if ($_GET['f']=='edit'){?>
            <? mysql_query("Update l_gallery set title='".addslashes($_POST['title'])."', link='".addslashes($_POST['link'])."', meta_title='".addslashes($_POST['meta_title'])."', meta_keywords='".addslashes($_POST['meta_keywords'])."', meta_description='".addslashes($_POST['meta_description'])."' where id='".$_POST['id']."'");?>
            <? mysql_query("Update links set link='".addslashes($_POST['link'])."' where page='".$_POST['gallery']."' and language='".$_POST['language']."' and link_type='5'");?>
            <div class="alert orange">
                <p><strong>Düzenleme Başarılı!</strong> Kayıt başarıyla güncellenmiştir.</p>
                <a href="#" class="close">close</a>
            </div>
            <script type="text/javascript" language="JavaScript">window.location.href="gallery.php"</script>
        <? }?>	
    <? }?>
    <? if(($_GET['f']=='edit')&&(!isset($_POST['form_submit']))){?>
    <? $data=mysql_fetch_assoc(mysql_query("Select * from l_gallery where language='".$_GET['language']."' and gallery='".$_GET['gallery']."'"))?>
    <div class="span12">
      <div class="widget-box">
        <div class="widget-title"> <span class="icon"> <i class="icon-align-justify"></i> </span>
          <h5>Kayıt Düzenle</h5>
        </div>
        <div class="widget-content nopadding">
          <form action="gallery_content.php?f=edit" method="post" enctype="multipart/form-data" class="form-horizontal">
            <div class="control-group">
              <label class="control-label">Başlık :</label>
              <div class="controls">
                <input type="text" class="span11" value="<?=stripslashes($data['title'])?>" name="title" />
              </div>
            </div>
           <div class="control-group">
              <label class="control-label">Link :</label>
              <div class="controls">
                <input type="text" class="span11" value="<?=stripslashes($data['link'])?>" name="link" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Meta Title :</label>
              <div class="controls">
                <input type="text" class="span11" value="<?=stripslashes($data['meta_title'])?>" name="meta_title" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Meta Keywords :</label>
              <div class="controls">
                <input type="text" class="span11" value="<?=stripslashes($data['meta_keywords'])?>" name="meta_keywords" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Meta Description :</label>
              <div class="controls">
                <input type="text" class="span11" value="<?=stripslashes($data['meta_description'])?>" name="meta_description" />
              </div>
            </div>
            <div class="form-actions">
                <input type="hidden" name="form_submit" value="1" />   
                
                <input type="hidden" name="gallery" value="<?=$_GET['gallery']?>" /> 
                <input type="hidden" name="language" value="<?=$_GET['language']?>" />                              
               <input type="hidden" name="id" value="<?=$data['id']?>" /> 
              <button type="submit" class="btn btn-success">Kaydet</button>
            </div>
          </form>
        </div>
      </div>
    </div>
    <? }?>
	<? if(($_GET['f']=='add')&&(!isset($_POST['form_submit']))){?>
    <? $data=mysql_fetch_assoc(mysql_query("Select * from gallery where id='".$_GET['gallery']."'"))?>
    <div class="span12">
      <div class="widget-box">
        <div class="widget-title"> <span class="icon"> <i class="icon-align-justify"></i> </span>
          <h5>Kayıt Ekle</h5>
        </div>
        <div class="widget-content nopadding">
          <form action="gallery_content.php?f=add" method="post" enctype="multipart/form-data" class="form-horizontal">
            <div class="control-group">
              <label class="control-label">Başlık :</label>
              <div class="controls">
                <input type="text" class="span11" value="" name="title" />
              </div>
            </div>
           <div class="control-group">
              <label class="control-label">Link :</label>
              <div class="controls">
                <input type="text" class="span11" value="" name="link" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Meta Title :</label>
              <div class="controls">
                <input type="text" class="span11" value="" name="meta_title" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Meta Keywords :</label>
              <div class="controls">
                <input type="text" class="span11" value="" name="meta_keywords" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Meta Description :</label>
              <div class="controls">
                <input type="text" class="span11" value="" name="meta_description" />
              </div>
            </div>
            <div class="form-actions">
                <input type="hidden" name="form_submit" value="1" />                                
               <input type="hidden" name="gallery" value="<?=$_GET['gallery']?>" />     
    			<input type="hidden" name="language" value="<?=$_GET['language']?>" />
              <button type="submit" class="btn btn-success">Kaydet</button>
            </div>
          </form>
        </div>
      </div>
    </div>
    <? }?>
    <? }?>
  </div>
</div></div>
<script src="js/jquery.min.js"></script> 
<script src="js/jquery.ui.custom.js"></script> 
<script src="js/bootstrap.min.js"></script> 
<script src="js/bootstrap-colorpicker.js"></script> 
<script src="js/bootstrap-datepicker.js"></script> 
<script src="js/jquery.toggle.buttons.html"></script> 
<script src="js/masked.js"></script> 
<script src="js/jquery.uniform.js"></script> 
<script src="js/select2.min.js"></script> 
<script src="js/matrix.js"></script> 
<script src="js/matrix.form_common.js"></script> 
<script src="js/wysihtml5-0.3.0.js"></script> 
<script src="js/jquery.peity.min.js"></script> 
</body>
</html>
<? } else { header('location:login.php');}?>