<?php 
$theme = $settings["theme"];

if (isset($_POST['sayfaekle'])) {
	$seourl=seo($_POST['page']);
	$image = new Upload( $_FILES['image']);
	$upload= PATH . "/public/{$theme}/images/sayfalar/";
	$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 = 500;
	$image->image_y = 500;
	$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/sayfalar/".$name.".".$uzanti;
	$kaydet=$db->prepare("INSERT INTO sayfalar SET
		page=:page,
		detail=:detail,
		image=:image,
		seourl=:seourl,  
		seo_title=:seo_title,
		seo_keywords=:seo_keywords,
		seo_description=:seo_description 
		");
	$insert=$kaydet->execute(array(
		'page' => $_POST['page'],
		'detail' => $_POST['detail'],
		'image' => $image,
		'seourl' => $seourl,  
		'seo_title' => $_POST['seo_title'],
		'seo_keywords' => $_POST['seo_keywords'],
		'seo_description' => $_POST['seo_description'] 
	));
	if ($insert) {
		$success = 'Yeni Sayfa başarıyla eklendi.';
	} else {
		$error = 'Bir hata oluştu.';
	}
}

require admin_view('sayfa-ekle');