<?php

$theme = $settings["theme"];

if (isset($_POST['haberekle'])) {
	$seourl=seo($_POST['haber']);
	$image = new Upload( $_FILES['image']);
	$upload= PATH . "/public/{$theme}/images/haberler/";
	$s1=rand(1000,3200);
	$s2=rand(1000,3200);
	$s3=rand(1000,3200);
	$s4=rand(1000,3200);
	$names=$s1.$s2.$s3.$s4;
	$image->image_resize = true;
	$image->image_ratio_crop = true;
	$image->image_x = 1200;
	$image->image_y = 650;
	$name=$image->file_new_name_body = $names;
	$uzantiss=$image->file_src_name;
	$uzantis=ext($uzantiss);
	$uzanti=$image->image_convert = $uzantis;
	$image->Process($upload);
	$image->allowed = array ('image/*');
	$image="images/haberler/".$name.".".$uzanti;
	$kaydet=$db->prepare("INSERT INTO haberler SET
		haber=:haber,
		aciklama=:aciklama,
		image=:image,
		seourl=:seourl, 
		durum=:durum,
		seo_title=:seo_title,
		seo_keywords=:seo_keywords,
		seo_description=:seo_description 
		");
	$insert=$kaydet->execute(array(
		'haber' => $_POST['haber'],
		'aciklama' => $_POST['aciklama'],
		'image' => $image,
		'seourl' => $seourl, 
		'durum' => $_POST['durum'],
		'seo_title' => $_POST['seo_title'],
		'seo_keywords' => $_POST['seo_keywords'],
		'seo_description' => $_POST['seo_description'] 
	));
	if ($insert) {
		$success = 'Yeni Haber başarıyla eklendi.';
	} else {
		$error = 'Bir hata oluştu.';
	}
}

require admin_view('haber-ekle');