<?php
session_start();
if(isset($_SESSION['yazar'])){ $kulID = $_SESSION['yazar']; 
include("config.php");
include("plugin/functions.php");
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_bin'");
$query = mysql_query("select * from settings");
while($print = mysql_fetch_array($query)){ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="robots" content="noindex,nofollow,nosnippet,noodp,noarchive,noimageindex">	
	<meta name="author" content="radyo sitesi, radyo dinle" />	

	<title>Yazı Gönder | <?php echo $print['title']; ?></title>	

	<link rel="stylesheet" media="screen" href="css/superfish.css" type="text/css" />
	<link rel="stylesheet" media="screen" href="css/stylesheet.css" type="text/css" />
	<link rel="stylesheet" media="screen" href="css/color.css" type="text/css" />		
	<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Serif:regular,italic,bold,bolditalic" type="text/css" />

	<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
	<script src="js/hoverIntent.js" type="text/javascript"></script>	
	<script src="js/superfish.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/jquery-ui.min.js"></script>
	<script type="text/javascript" src="js/custom.js"></script>
	<script type="text/javascript" src="js/jquery.animate-shadow.js"></script>	
<script type="text/javascript" src="yonetim/js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		entity_encoding : "utf-8",
        mode : "exact",
        elements : "elm1",		
		theme : "advanced",
		plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",

		// Theme options
		theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Style formats
		style_formats : [
			{title : 'Bold text', inline : 'b'},
			{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
			{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
			{title : 'Example 1', inline : 'span', classes : 'example1'},
			{title : 'Example 2', inline : 'span', classes : 'example2'},
			{title : 'Table styles'},
			{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
		],

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
</script>	
</head>
<body>

<div id="panel" style="display: none;" align="center">
<div align="center"><b><?php $ozu = mysql_query("select * from uyeler where id='$kulID'"); while($kamil = mysql_fetch_array($ozu)){ echo $kamil['adsoyad']; ?>, hoşgeldin.</b>&nbsp;&nbsp;-&nbsp;&nbsp; <a href="newspost.php">Yazı Gönder</a> &nbsp;&nbsp;-&nbsp;&nbsp; <?php if($print['seourl']==".php"){ ?> <a href="/djpanel.php">İstekler</a> <?php }elseif($print['seourl']==".html"){ ?> <a href="/djpanel.php">İstekler</a> <?php } ?> &nbsp;&nbsp;-&nbsp;&nbsp; <a href="sessionout.php">Çıkış</a></div><?php } ?></div>
<?php include("header.php"); ?> 
  
  <div id="outer-wrapper">
    <div id="content-wrapper">
      <div id="inner-content">
        <div id="entry">
          <div id="post-top">
            <h3 id="post-title">Yazı Gönder</h3>
          </div>
          <div class="entry-content">
		<div id="respond"> 
<?php
function temizle($url)
{
$url = trim($url);
$find = array('<b>', '</b>');
$url = str_replace ($find, '', $url);
$url = preg_replace('/<(\/{0,1})img(.*?)(\/{0,1})\>/', 'image', $url);
$find = array(' ', '&amp;quot;', '&amp;amp;', '&amp;', '\r\n', '\n', '/', '\\', '+', '<', '>');
$url = str_replace ($find, '-', $url);
$find = array('.','..', '...');
$url = str_replace ($find, '', $url);
$find = array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ë', 'Ê');
$url = str_replace ($find, 'e', $url);
$find = array('í', 'ý', 'ì', 'î', 'ï', 'I', 'Ý', 'Í', 'Ì', 'Î', 'Ï','İ','ı');
$url = str_replace ($find, 'i', $url);
$find = array('ó', 'ö', 'Ö', 'ò', 'ô', 'Ó', 'Ò', 'Ô');
$url = str_replace ($find, 'o', $url);
$find = array('á', 'ä', 'â', 'à', 'â', 'Ä', 'Â', 'Á', 'À', 'Â');
$url = str_replace ($find, 'a', $url);
$find = array('ú', 'ü', 'Ü', 'ù', 'û', 'Ú', 'Ù', 'Û');
$url = str_replace ($find, 'u', $url);
$find = array('ç', 'Ç');
$url = str_replace ($find, 'c', $url);
$find = array('þ', 'Þ','ş','Ş');
$url = str_replace ($find, 's', $url);
$find = array('ð', 'Ð','ğ','Ğ');
$url = str_replace ($find, 'g', $url);
$find = array('/[^A-Za-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');
$repl = array('', '-', '');
$url = preg_replace ($find, $repl, $url);
$url = str_replace ('--', '-', $url);
$url = strtolower($url);
return $url;
}

if(isset($_POST['gonder'])){

 $baslik = $_POST['baslik'];
 $resimyolu = $_POST['resimyolu'];
 $kategori = $_POST['kategori'];
 $keywords = $_POST['keywords'];
 $description = $_POST['description'];
 $icerik = $_POST['icerik'];
 $tarih = date('Y-m-d');
 $url=temizle($baslik);
 
if($baslik==""||$kategori==""||$keywords==""||$description==""||$icerik==""){

	echo '<br><font color="red"><b>Lütfen tüm alanları doldurun!</b></font><br>'; }else{

$mack = mysql_query("select * from news where sefurl='$url'"); if(mysql_num_rows($mack)!="0"){

	echo '<br><font color="red"><b>Seçtiğiniz yazı başlığı site de mevcuttur. Lütfen yazı başlığınızı değiştirin!</b></font><br>'; }else{
		
	$kaynak		= $_FILES["resimyolu"]["tmp_name"];
	$dosyaadi   = $_FILES["resimyolu"]["name"];
    $rtipi      = $_FILES["resimyolu"]["type"];               
    $rboyut     = $_FILES["resimyolu"]["size"]; 	
	$klasor		= "upload/resimler/"; 
	$uzanti     = substr($dosyaadi, -4);
	$yeniad     = substr(md5(uniqid(rand())), 0,10);
	$yeniresimadi  = $yeniad.$uzanti;
	$yukle		= $klasor.basename($yeniresimadi);
	$minboyut    = 10240; 
    $avatarboyutu   = 1024*1024*10; 

		if($kaynak==""){ }elseif($rboyut > $avatarboyutu){
        
		echo "<div style=\"color:red; font-weight:bold;\">
		<p>Yüklemeye çalıştığınız resim dosyasının boyutu en fazla 1 MB olabilir.</p>
		</div>";
        
        }elseif(($rtipi!="image/jpeg") && ($rtipi!="image/pjpeg") && ($rtipi!="image/gif") && ($rtipi!="image/png") && ($rtipi!="image/x-png")){         
        
		echo "<div style=\"color:red; font-weight:bold;\">
		<p>Seçtiğiniz dosya bir resim değil. Lütfen sadece izin verilen uzantılar da yükleme yapınız! (.gif, .jpg, .png)</p>
		</div>";

        }elseif($rboyut < $minboyut){
        
		echo "<div style=\"color:red; font-weight:bold;\">
		<p>Resim dosyasının boyutu 10 KB'dan küçük olamaz!</p>
		</div>";
        
        }else{
	
	if (move_uploaded_file($kaynak, $yukle))
	{
 
		$hedefdosya="upload/resimler/" . $yeniresimadi; 

		chmod ($hedefdosya, 0644);
		
$kayit = mysql_query("insert into news(uID,baslik,icerik,keywords,description,resimyolu,kategori,tarih,sefurl) values('$kulID','$baslik','$icerik','$keywords','$description','$hedefdosya','$kategori','$tarih','$url')"); 

	echo '<br><font color="green"><b>Yazı kaydedilmiştir. Yönetici onayından sonra site de gösterilecektir.</b></font><br>';		
	
	}
	else 
	echo '<div style="color:red; font-weight:bold;"><p>Resim Yüklenemedi!</p></div>'; }			
		
	  } } } ?> 		
            <form enctype="multipart/form-data" method="post">
              <p>
                <label>Yazı Başlığı <span class="star">*</span></label>
                <input type="text" name="baslik" />
              </p>
              <p>
                <label>Resim (200 x 200) <span class="star">* </span> </label>
				<input type="file" name="resimyolu" id="resimyolu" lang="tr" />
              </p>			  
              <p>
                <label for="email">Kategori <span class="star">*</span></label>
                <select name="kategori" style="width:293px;">
				<option></option>
<?php $q41 = mysql_query("select * from newskat order by id desc"); while($b51 = mysql_fetch_array($q41)){ ?>
			<option value="<?php echo $b51['sefurl']; ?>"><?php echo $b51['baslik']; ?></option><?php } ?>
			</select>
              </p>			  
              <p>
                <label>Anahtar Kelimeler (keywords)<span class="star">*</span></label>
                <textarea name="keywords" rows="3" cols="30"></textarea>
              </p>
              <p>
                <label>Yazı Tanımlama (description)<span class="star">*</span></label>
                <textarea name="description" rows="3" cols="30"></textarea>
              </p>	
              <p>
                <label>İçerik<span class="star">*</span></label>
                <textarea name="icerik" id="elm1" rows="5" cols="30"></textarea>
              </p>			  			  
              <p>
                <input type="hidden" name="submitted" id="submitted" value="true" />
              </p>
              <p class="submit">
                <button class="btn" name="gonder" type="submit">Gönder</button>
              </p>
            </form>		
		</div>		
          </div>
        </div>
      </div>
	  
      <div id="sidebar">
	<?php include("plugin/sidebar.php"); ?>
      </div>
      <div class="clear"></div>
    </div>
  </div>
  
  <div id="footer"> <span id="Scroll"><a href="#">&uarr;</a></span>
    <div id="footer_inner">
<?php echo $print['reklam3']; ?>
      <div class="clear"></div>
      <div class="footer_bottom">
        <ul class="footer_menu">
          <li><a href="index<?php echo $print['seourl']; ?>">Anasayfa</a> /</li>		
<?php $whistle = mysql_query("select * from pages order by sira asc"); while($baby = mysql_fetch_array($whistle)){ if($print['seourl']==".php"){ ?>		
          <li><a href="pages.php?url=<?php echo $baby['sefurl']; ?>"><?php echo $baby['baslik']; ?></a> /</li>
	<?php }elseif($print['seourl']==".html"){ ?>	  
          <li><a href="sayfa-<?php echo $baby['sefurl']; ?>.html"><?php echo $baby['baslik']; ?></a> /</li>
	<?php } } ?>	
          <li><a href="iletisim<?php echo $print['seourl']; ?>">İletişim</a></li>
        </ul>
        <p>&copy; Copyright <?php echo date('Y'); ?>, <?php echo $print['title']; ?>. Tüm hakları saklıdır.</p>
      </div>
    </div>
  </div>
</div>
</body>
</html>
<?php } }else{ echo '<meta http-equiv="refresh" content="0;URL=404.php">'; } ?>