<?php

$theme = $settings["theme"];

if (isset($_POST['proekle'])) {
	$seourl = seo($_POST['programci']);
	$image = new Upload($_FILES['image']);
	$upload = PATH . "/public/{$theme}/images/programci/";
	$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 = 400;
	$image->image_y = 400;
	$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/programci/" . $name . "." . $uzanti;
	$kaydet = $db->prepare("INSERT INTO programci SET
	    email=:email,
		sifre=:sifre,
		programci=:programci,
		program=:program,
		image=:image,
		facebook=:facebook,
		twitter=:twitter,
		instagram=:instagram,
		durum=:durum,
		seourl=:seourl
		");
	$insert = $kaydet->execute(array(
		'email' => $_POST['email'],
		'sifre' => (md5($_POST['sifre'])),
		'programci' => $_POST['programci'],
		'program' => $_POST['program'],
		'image' => $image,
		'facebook' => $_POST['facebook'],
		'twitter' => $_POST['twitter'],
		'instagram' => $_POST['instagram'],
		'durum' => $_POST['durum'],
		'seourl' => $seourl
	));
	if ($insert) {
		$success = 'İşlem başarıyla gerçekleşti.';
	} else {
		$error = 'Bir hata oluştu.';
	}
}

require admin_view('programci-ekle');
