<?php
session_start();
setlocale(LC_TIME, "tr_TR");
date_default_timezone_set("Europe/Istanbul");
define("WEEN", true);
if (getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
} else {
if (getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
if (strstr($ip, ",")) {
$tmp = explode(",", $ip);
$ip = trim($tmp[0]);
}
} else {
$ip = getenv("REMOTE_ADDR");
}
}
if (isset($_POST["categoryid2"]) || isset($_POST["kategori_name"]) || isset($_POST["type"]) || isset($_POST["testadi"]) || isset($_POST["testduzenle"]) || isset($_POST["blogekle"]) || isset($_POST["blogid"]) || isset($_POST["ads1"])) {
require "backend/classes/PHPMailer/PHPMailer.php";
require "backend/classes/PHPMailer/Exception.php";
require "backend/classes/PHPMailer/SMTP.php";
$function_glob = glob("backend/functions/func.*.php");
foreach ($function_glob as $function) {
require $function;
}
$configuration_glob = glob("backend/configuration/config.*.php");
foreach ($configuration_glob as $configuration) {
require $configuration;
}
date_default_timezone_set($config["general"]["timezone"]);
$classlar = glob("backend/classes/class.*.php");
foreach ($classlar as $class) {
require $class;
}
$host = cngz20_decode($config["database"]["host"]);
$username = cngz20_decode($config["database"]["username"]);
$password = cngz20_decode($config["database"]["password"]);
$dbname = cngz20_decode($config["database"]["dbname"]);
try {
$db = new PDO("mysql:host=" . $host . ";dbname=" . $dbname . ";charset=utf8", $username, $password);
} catch (PDOException $e) {
if (!is_cngz20($config["database"]["host"]) || !is_cngz20($config["database"]["username"]) || !is_cngz20($config["database"]["password"]) || !is_cngz20($config["database"]["dbname"])) {
$config_database = fopen("backend/configuration/config.database.php", "r+");
$config_database_content = fread($config_database, filesize("backend/configuration/config.database.php"));
if (!is_cngz20($config["database"]["host"])) {
$config_database_content = str_replace("\"host\" => \"" . $config["database"]["host"] . "\"", "\"host\" => \"" . cngz20($config["database"]["host"]) . "\"", $config_database_content);
}
if (!is_cngz20($config["database"]["username"])) {
$config_database_content = str_replace("\"username\" => \"" . $config["database"]["username"] . "\"", "\"username\" => \"" . cngz20($config["database"]["username"]) . "\"", $config_database_content);
}
if (!is_cngz20($config["database"]["password"])) {
$config_database_content = str_replace("\"password\" => \"" . $config["database"]["password"] . "\"", "\"password\" => \"" . cngz20($config["database"]["password"]) . "\"", $config_database_content);
}
if (!is_cngz20($config["database"]["dbname"])) {
$config_database_content = str_replace("\"dbname\" => \"" . $config["database"]["dbname"] . "\"", "\"dbname\" => \"" . cngz20($config["database"]["dbname"]) . "\"", $config_database_content);
}
unlink("backend/configuration/config.database.php");
$config_database2 = fopen("backend/configuration/config.database.php", "w");
fwrite($config_database2, $config_database_content);
$system_error = "Config dosyası güncellendi lütfen sayfayı yenileyin.";
require "frontend/themes/system/error.php";
exit;
}
$system_error = $e->getMessage();
require "frontend/themes/system/error.php";
exit;
}
} else {
$function_glob = glob("apps/backend/functions/func.*.php");
foreach ($function_glob as $function) {
require $function;
}
$configuration_glob = glob("apps/backend/configuration/config.*.php");
foreach ($configuration_glob as $configuration) {
require $configuration;
}
date_default_timezone_set($config["general"]["timezone"]);
$classlar = glob("apps/backend/classes/class.*.php");
foreach ($classlar as $class) {
require $class;
}
$host = cngz20_decode($config["database"]["host"]);
$username = cngz20_decode($config["database"]["username"]);
$password = cngz20_decode($config["database"]["password"]);
$dbname = cngz20_decode($config["database"]["dbname"]);
try {
$db = new PDO("mysql:host=" . $host . ";dbname=" . $dbname . ";charset=utf8", $username, $password);
} catch (PDOException $e) {
if (!is_cngz20($config["database"]["host"]) || !is_cngz20($config["database"]["username"]) || !is_cngz20($config["database"]["password"]) || !is_cngz20($config["database"]["dbname"])) {
$config_database = fopen("apps/backend/configuration/config.database.php", "r+");
$config_database_content = fread($config_database, filesize("apps/backend/configuration/config.database.php"));
if (!is_cngz20($config["database"]["host"])) {
$config_database_content = str_replace("\"host\" => \"" . $config["database"]["host"] . "\"", "\"host\" => \"" . cngz20($config["database"]["host"]) . "\"", $config_database_content);
}
if (!is_cngz20($config["database"]["username"])) {
$config_database_content = str_replace("\"username\" => \"" . $config["database"]["username"] . "\"", "\"username\" => \"" . cngz20($config["database"]["username"]) . "\"", $config_database_content);
}
if (!is_cngz20($config["database"]["password"])) {
$config_database_content = str_replace("\"password\" => \"" . $config["database"]["password"] . "\"", "\"password\" => \"" . cngz20($config["database"]["password"]) . "\"", $config_database_content);
}
if (!is_cngz20($config["database"]["dbname"])) {
$config_database_content = str_replace("\"dbname\" => \"" . $config["database"]["dbname"] . "\"", "\"dbname\" => \"" . cngz20($config["database"]["dbname"]) . "\"", $config_database_content);
}
unlink("apps/backend/configuration/config.database.php");
$config_database2 = fopen("apps/backend/configuration/config.database.php", "w");
fwrite($config_database2, $config_database_content);
$system_error = "Config dosyası güncellendi lütfen sayfayı yenileyin.";
require "apps/frontend/themes/system/error.php";
exit;
}
$system_error = $e->getMessage();
require "apps/frontend/themes/system/error.php";
exit;
}
}
if (isset($_POST["testduzenle"])) {
for ($sayi = 1; $sayi < $_POST["sayi"] + 1; $sayi++) {
if ($_FILES["fileimage" . $sayi]["tmp_name"] != "") {
$dosya = $_FILES["fileimage" . $sayi]["tmp_name"];
$test = copy($dosya, "frontend/tests/" . $_FILES["fileimage" . $sayi]["name"]);
$question5 = "<img src=\"/apps/frontend/tests/" . $_FILES["fileimage" . $sayi]["name"] . "\" class=\"sorular\">";
} else {
$question5 = $_POST["SORU" . $sayi];
}
$question[$sayi] = base64_encode(json_encode(["question" => $question5, "a" => $_POST["A" . $sayi], "b" => $_POST["B" . $sayi], "c" => $_POST["C" . $sayi], "d" => $_POST["D" . $sayi], "e" => $_POST["E" . $sayi]]));
$answers[$sayi] = $_POST["cevap" . $sayi];
}
$test_id = rand(100000000, 999999999);
$question = base64_encode(json_encode($question));
$answers = base64_encode(json_encode($answers));
$test = Ween\DataBase::Update("tests", ["test_name" => $_POST["testadi"], "seourl" => $_POST["seourl"], "questions" => $question, "category" => $_POST["category"], "questions_count" => $_POST["sayi"], "status" => "1", "answers" => $answers, "views" => "0"], ["id" => $_POST["testid"]]);
header("location:/adminpanel/testler");
exit;
}
if (isset($_POST["testadi"])) {
for ($sayi = 1; $sayi < $_POST["sayi"] + 1; $sayi++) {
if ($_POST["SORU" . $sayi] == "") {
$dosya = $_FILES["fileimage" . $sayi]["tmp_name"];
$test = copy($dosya, "frontend/tests/" . $_FILES["fileimage" . $sayi]["name"]);
$question5 = "<img src=\"/apps/frontend/tests/" . $_FILES["fileimage" . $sayi]["name"] . "\" class=\"sorular\">";
} else {
$question5 = $_POST["SORU" . $sayi];
}
$question[$sayi] = base64_encode(json_encode(["question" => $question5, "a" => $_POST["A" . $sayi], "b" => $_POST["B" . $sayi], "c" => $_POST["C" . $sayi], "d" => $_POST["D" . $sayi], "e" => $_POST["E" . $sayi]]));
$answers[$sayi] = $_POST["cevap" . $sayi];
}
$question = base64_encode(json_encode($question));
$answers = base64_encode(json_encode($answers));
$test = Ween\DataBase::Insert("tests", ["test_name" => $_POST["testadi"], "seourl" => $_POST["seourl"], "category" => $_POST["category"], "questions" => $question, "questions_count" => $_POST["sayi"], "time" => "10000000", "creation_date" => time(), "status" => "1", "answers" => $answers, "views" => "0"]);
header("location:/adminpanel/testler");
exit;
}
if (isset($_POST["blogekle"])) {
$title = $_POST["title"];
$seolink = $_POST["seolink"];
$content = $_POST["content"];
$category_id = $_POST["category"];
$dosya = $_FILES["fileimage"]["tmp_name"];
copy($dosya, "frontend/blogs/on/" . $_FILES["fileimage"]["name"]);
$blog = Ween\DataBase::Insert("blogs", ["title" => $title, "seolink" => $seolink, "category_id" => $category_id, "content" => $content, "views" => "0", "adminid" => "0", "youtubelink" => $_POST["youtubelink"], "img" => $_FILES["fileimage"]["name"], "date" => time()]);
header("location:/adminpanel/bloglar");
exit;
}
if (isset($_POST["kategori_name"])) {
$kategori = $_POST["kategori_name"];
$blog_categorys = Ween\DataBase::Insert("blog_categorys", ["name" => $kategori]);
header("location:/adminpanel/blog-kategoriler");
}
if (isset($_POST["blogid"])) {
$title = $_POST["title"];
$seolink = $_POST["seolink"];
$content = $_POST["content"];
$category_id = $_POST["category"];
$youtubelink = $_POST["youtubelink"];
$dosya = $_FILES["fileimage"]["tmp_name"];
if ($_FILES["fileimage"]["name"] == "") {
$blog = Ween\DataBase::Update("blogs", ["title" => $title, "seolink" => $seolink, "content" => $content, "category_id" => $category_id, "youtubelink" => $youtubelink], ["id" => $_POST["blogid"]]);
header("location:/adminpanel/bloglar");
return NULL;
}
copy($dosya, "frontend/blogs/on/" . $_FILES["fileimage"]["name"]);
$blog = Ween\DataBase::Update("blogs", ["title" => $title, "seolink" => $seolink, "content" => $content, "img" => $_FILES["fileimage"]["name"], "youtubelink" => $youtubelink], ["id" => $_POST["blogid"]]);
header("location:/adminpanel/bloglar");
return NULL;
}
if (isset($_POST["ads1"])) {
$ads1 = $_POST["ads1"];
$ads2 = $_POST["ads2"];
$ads3 = $_POST["ads3"];
$ads4 = $_POST["ads4"];
$ads5 = $_POST["ads5"];
$ads6 = $_POST["ads6"];
$ads = Ween\DataBase::Update("ads", ["ads1" => $ads1, "ads2" => $ads2, "ads3" => $ads3, "ads4" => $ads4, "ads5" => $ads5, "ads6" => $ads6]);
header("location:/adminpanel/reklam-alanlari");
return NULL;
}
if (isset($_POST["categoryid2"])) {
$category_name = $_POST["category_name"];
$categoryid = $_POST["categoryid2"];
$blog = Ween\DataBase::Update("blog_categorys", ["name" => $category_name], ["id" => $categoryid]);
header("location:/adminpanel/blog-kategoriler");
return NULL;
}
if (isset($_SESSION["id"])) {
$user = Ween\DataBase::From("users", "first", ["id" => $_SESSION["id"]]);
}
if (isset($_POST["sayi"])) {
header("location:/adminpanel/test-ekle/" . $_POST["sayi"]);
}
if (isset($_GET["page"])) {
define("URL", explode("/", $_GET["page"]));
} else {
define("URL", [$config["general"]["home"]]);
}
if (URL[0] == "callback" && isset(URL[1])) {
if (!file_exists("apps/backend/modules/gateways/" . URL[1] . "/" . URL[1] . ".php")) {
exit("ERROR: No such payment module found.");
}
if (isset(URL[2])) {
$cngz20code = cngz10(cngz20(URL[2]));
if ($cngz20code == URL[2]) {
require "apps/backend/modules/gateways/" . URL[1] . "/" . URL[1] . ".php";
$callback_array = ["post" => $_POST];
array_push($_POST, "config");
$_POST["config"] = ["meta" => [], "settings" => []];
echo callback($callback_array);
exit;
}
exit("You entered the wrong module code.");
}
}
if (isset($_POST["type"])) {
if (!is_cngz20($config["general"]["admin-folder"])) {
$config_general = fopen("apps/backend/configuration/config.general.php", "r+");
$config_general_content = fread($config_general, filesize("apps/backend/configuration/config.general.php"));
$config_general_content = str_replace("\"admin-folder\" => \"" . $config["general"]["admin-folder"] . "\"", "\"admin-folder\" => \"" . cngz20($config["general"]["admin-folder"]) . "\"", $config_general_content);
unlink("apps/backend/configuration/config.general.php");
$config_general2 = fopen("apps/backend/configuration/config.general.php", "w");
fwrite($config_general2, $config_general_content);
$system_error = "Config dosyası güncellendi lütfen sayfayı yenileyin.";
require "apps/frontend/themes/system/error.php";
return NULL;
}
if ($_POST["type"] == "adminlogin") {
if (!isset($_POST["email"]) || !isset($_POST["password"])) {
exit("ERROR!");
}
$email = $_POST["email"];
$password = cngz10($_POST["password"]);
$user = Ween\DataBase::From("admins", "first", ["email" => $email, "password" => $password]);
if ($user) {
$idlogin = rand(100000000, 999999999);
Ween\DataBase::Insert("admin_logins", ["id" => $idlogin, "userid" => $user["id"], "ip" => $ip, "date" => time()]);
$_SESSION["adminid"] = $user["id"];
exit("OK");
}
exit("Account information is incorrect.");
}
if ($_POST["type"] == "ayarlaredit") {
$site_logo = $_POST["site_logo"];
$site_name = $_POST["site_name"];
$site_title = $_POST["site_title"];
$site_description = $_POST["site_description"];
$hakkimizda = $_POST["hakkimizda"];
$youtube_link = $_POST["youtube_link"];
$youtubeapikey = $_POST["youtubeapikey"];
Ween\DataBase::Update("settings", ["logo" => $site_logo, "site_name" => $site_name, "title" => $site_title, "description" => $site_description, "hakkimizda" => $hakkimizda, "youtube_link" => $youtube_link, "youtubeapikey" => $youtubeapikey]);
exit("OK");
}
if ($_POST["type"] == "categoryedit") {
$categoryid = $_POST["categoryid"];
$name = $_POST["name"];
$seolink = $_POST["seolink"];
$category = $_POST["altcategory"];
Ween\DataBase::Update("categorys", ["name" => $name, "seolink" => $seolink, "category" => $category], ["id" => $categoryid]);
exit("OK");
}
if ($_POST["type"] == "contact") {
$email = $_POST["email"];
$full_name = $_POST["full_name"];
$message = $_POST["message"];
Ween\DataBase::Insert("contacts", ["email" => $email, "full_name" => $full_name, "message" => $message]);
}
if ($_POST["type"] == "testedit") {
$testid = $_POST["testid"];
$name = $_POST["testname"];
$seourl = $_POST["seourl"];
Ween\DataBase::Update("tests", ["test_name" => $name, "seourl" => $seourl], ["id" => $testid]);
exit("OK");
}
if ($_POST["type"] == "blogedit") {
$blogid = $_POST["blogid"];
$title = $_POST["title"];
$seolink = $_POST["seolink"];
$content = $_POST["content"];
$query = $db->prepare("UPDATE blogs SET title = :title, seolink = :seolink, content = :content WHERE id = '" . $blogid . "'");
$test = $query->execute(["title" => $title, "seolink" => $seolink, "content" => $content]);
exit("OK");
}
if ($_POST["type"] == "blogolustur") {
$title = $_POST["title"];
$seolink = $_POST["seolink"];
$content = $_POST["content"];
$blog = Ween\DataBase::Insert("blogs", ["title" => $title, "seolink" => $seolink, "content" => $content, "views" => "0", "adminid" => "0", "date" => time()]);
exit("OK");
}
if ($_POST["type"] == "kategoriekle") {
$name = $_POST["name"];
$seolink = $_POST["seolink"];
$category = $_POST["category"];
$query = $db->prepare("INSERT INTO categorys SET name = :name, seolink = :seolink, category = :category, views = :views");
$test = $query->execute(["name" => $name, "seolink" => $seolink, "category" => $category, "views" => "0"]);
exit("OK");
}
if ($_POST["type"] == "register") {
if (!isset($_POST["email"]) || !isset($_POST["password"])) {
exit("ERROR!");
}
$email = $_POST["email"];
$full_name = $_POST["full_name"];
$password = cngz10($_POST["password"]);
$type = $_POST["type2"];
$user = Ween\DataBase::From("users", "first", ["email" => $email]);
if ($user) {
exit("Lütfen kayıtlı olmayan bir email girin.");
}
$query = $db->prepare("INSERT INTO users SET full_name = :full_name, email = :email, password = :password, created_date = :created_date, type = :type, role = :role, status = :status");
$test = $query->execute(["full_name" => $full_name, "email" => $email, "password" => $password, "created_date" => time(), "type" => $type, "role" => "1", "status" => "1"]);
exit("OK");
}
if ($_POST["type"] == "login") {
if (!isset($_POST["email"]) || !isset($_POST["password"])) {
exit("ERROR!");
}
$email = $_POST["email"];
$password = cngz10($_POST["password"]);
$user = Ween\DataBase::From("users", "first", ["email" => $email, "password" => $password]);
if ($user) {
$idlogin = rand(100000000, 999999999);
if (ismobile()) {
$device_type = "phone";
} else {
$device_type = "computer";
}
Ween\DataBase::Insert("logins", ["id" => $idlogin, "userid" => $user["id"], "device_name" => devicename(), "date" => time(), "device_type" => $device_type, "ip" => $ip]);
$_SESSION["id"] = $user["id"];
exit("OK");
}
exit("Lütfen doğru bilgi girdiğinizden emin olun.");
}
if ($_POST["type"] == "testbitir") {
$test_id = $_POST["test_id"];
$usertests = Ween\DataBase::From("usertests", "first", ["id" => $test_id, "status" => "0"]);
$tests = Ween\DataBase::From("tests", "first", ["id" => $usertests["test_no"]]);
if ($usertests) {
$questions = json_decode(base64_decode($usertests["answers"]), true)["answers"];
$answers = json_decode(base64_decode($tests["answers"]), true);
$results = [];
foreach ($questions as $question1 => $question2) {
if ($question2 == $answers[$question1]) {
$results[$question1] = true;
} else {
$results[$question1] = false;
}
}
Ween\DataBase::Update("usertests", ["results" => base64_encode(json_encode($results)), "status" => "1"], ["id" => $test_id]);
}
}
if ($_POST["type"] == "profile-edit") {
if (isset($_POST["full_name"])) {
Ween\DataBase::Update("users", ["full_name" => $_POST["full_name"], "type" => $_POST["type2"]], ["id" => $_SESSION["id"]]);
exit("OK");
}
if ($_POST["password1"] != $_POST["password2"]) {
exit("Lütfen şifrelerin uyuşup uyuşmadığını kontrol ediniz.");
}
Ween\DataBase::Update("users", ["password" => cngz10($_POST["password1"])], ["id" => $_SESSION["id"]]);
exit("OK");
}
if ($_POST["type"] == "testcevap") {
$test_id = $_POST["test_id"];
$cevap = $_POST["cevap"];
$soru = $_POST["soru"];
$usertests = Ween\DataBase::From("usertests", "first", ["id" => $test_id, "status" => "0"]);
if ($usertests) {
if ($usertests["end_time"] < time()) {
Ween\DataBase::Update("usertests", ["status" => "1"], ["id" => $usertests["id"]]);
echo "Testin süresi doldu.";
return NULL;
}
$answers = json_decode(base64_decode($usertests["answers"]), true);
$answers["answers"][$soru] = $cevap;
$answers = base64_encode(json_encode($answers));
Ween\DataBase::Update("usertests", ["answers" => $answers], ["id" => $test_id]);
exit("OK");
}
exit("Testin süresi doldu.");
}
if ($_POST["type"] == "page") {
if (!isset($_POST["page"])) {
exit("ERROR!");
}
$page = $_POST["page"];
$page_array = explode("/", $page);
$testler = Ween\DataBase::From("tests", "all");
foreach ($testler as $test) {
if ($page_array[0] == $test["seourl"]) {
$test_database = Ween\DataBase::From("tests", "first", ["id" => $test["id"]]);
$category = Ween\DataBase::From("categorys", "first", ["id" => $test_database["category"]]);
if (!isset($_COOKIE["gor" . $test["id"]])) {
Ween\DataBase::Update("tests", ["views" => $test_database["views"] + 1], ["id" => $test["id"]]);
setcookie("gor" . $test["id"], true, time() + 86400);
}
if ($test_database) {
if (isset($_SESSION["id"])) {
$control = Ween\DataBase::From("usertests", "first", ["userid" => $_SESSION["id"], "test_no" => $test_code, "status" => "0"]);
if ($control) {
document_location("/test/" . $control["id"]);
exit;
}
$userid = $_SESSION["id"];
} else {
$control = Ween\DataBase::From("usertests", "first", ["ip" => $ip, "test_no" => $test_code, "status" => "0"]);
if ($control) {
document_location("/test/" . $control["id"]);
exit;
}
$userid = "ziyaretçi";
}
$test_id = rand(100000000, 999999999);
Ween\DataBase::Insert("usertests", ["test_no" => $test_database["id"], "userid" => $userid, "ip" => $ip, "start_time" => time(), "end_time" => date(strtotime("+" . $test_database["time"] . " minutes")), "status" => "0", "answers" => base64_encode(json_encode(["answers" => []])), "results" => base64_encode(json_encode([]))]);
$test = $test_database;
$test_database = Ween\DataBase::From("usertests", "first", ["id" => $db->lastInsertId()]);
$category2site = Ween\DataBase::From("categorys", "first", ["id" => $test["category"]]);
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/tests.php";
} else {
document_location("/");
}
return NULL;
}
}
if ($page_array[0] == "search") {
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/search.php";
return NULL;
}
$categorys = Ween\DataBase::From("categorys", "all");
foreach ($categorys as $category2) {
if ($page_array[0] == $category2["seolink"]) {
if (!isset($_COOKIE["gor" . $category2["id"]])) {
Ween\DataBase::Update("category", ["views" => $category2["views"] + 1], ["id" => $category2["id"]]);
setcookie("gor" . $category2["id"], true, time() + 86400);
}
$tests = Ween\DataBase::From("tests", "all", ["category" => $category2["id"]]);
$categorysite = Ween\DataBase::From("categorys", "first", ["id" => $category2["id"]]);
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/test.php";
exit;
}
}
if ($page_array[0] == "test123") {
}
$blogs = Ween\DataBase::From("blogs", "all");
foreach ($blogs as $blog) {
if ($page_array[0] == $blog["seolink"]) {
$no = $page_array[0];
$blog = Ween\DataBase::From("blogs", "first", ["seolink" => $no]);
$admin = Ween\DataBase::From("admins", "first", ["id" => $blog["adminid"]]);
if (!isset($_COOKIE["gor" . $blog["id"]])) {
Ween\DataBase::Update("blogs", ["views" => $blog["views"] + 1], ["id" => $blog["id"]]);
setcookie("gor" . $blog["id"], true, time() + 86400);
}
$date = strftime("%e %B %Y %A %H.%M", date($blog["date"]));
if ($blog) {
require "apps/backend/theme/site/blog.php";
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/blog.php";
} else {
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/404.php";
}
return NULL;
}
}
if ($page_array[0] == "logout") {
unset($_SESSION["id"]);
document_location("/");
}
if ($page_array[0] == "test") {
if (isset($page_array[2])) {
if ($page_array[2] == "view") {
$test_database = Ween\DataBase::From("tests", "first", ["id" => $page_array[1]]);
$category = Ween\DataBase::From("categorys", "first", ["id" => $test_database["category"]]);
if (!isset($_COOKIE["gor" . $page_array[1]])) {
Ween\DataBase::Update("tests", ["views" => $test_database["views"] + 1], ["id" => $page_array[1]]);
setcookie("gor" . $page_array[1], true, time() + 86400);
}
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/test_gor.php";
return NULL;
}
if ($page_array[2] == "start") {
$test_code = $page_array[1];
$test_database = Ween\DataBase::From("tests", "first", ["id" => $test_code]);
if ($test_database) {
if (isset($_SESSION["id"])) {
$control = Ween\DataBase::From("usertests", "first", ["userid" => $_SESSION["id"], "test_no" => $test_code, "status" => "0"]);
if ($control) {
document_location("/test/" . $control["id"]);
exit;
}
$userid = $_SESSION["id"];
} else {
$control = Ween\DataBase::From("usertests", "first", ["ip" => $ip, "test_no" => $test_code, "status" => "0"]);
if ($control) {
document_location("/test/" . $control["id"]);
exit;
}
$userid = "ziyaretçi";
}
$test_id = rand(100000000, 999999999);
Ween\DataBase::Insert("usertests", ["test_no" => $test_database["id"], "userid" => $userid, "ip" => $ip, "start_time" => time(), "end_time" => date(strtotime("+" . $test_database["time"] . " minutes")), "status" => "0", "answers" => base64_encode(json_encode(["answers" => []])), "results" => base64_encode(json_encode([]))]);
document_location("/test/" . $db->lastInsertId());
} else {
document_location("/");
}
return NULL;
}
}
$test_code = $page_array[1];
$test_database = Ween\DataBase::From("usertests", "first", ["id" => $test_code]);
if ($test_database) {
if ($test_database["userid"] != "ziyaretçi") {
if (!isset($_SESSION["id"])) {
document_location("/");
} else {
if ($_SESSION["id"] != $test_database["userid"]) {
document_location("/");
}
}
}
} else {
document_location("/");
}
if ($test_database["end_time"] < time()) {
Ween\DataBase::Update("usertests", ["status" => "1"], ["id" => $test_database["id"]]);
}
$test = Ween\DataBase::From("tests", "first", ["id" => $test_database["test_no"]]);
$category2 = Ween\DataBase::From("categorys", "first", ["id" => $test["category"]]);
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/tests.php";
return NULL;
}
if ($page_array[0] == "blog") {
$no = $page_array[1];
if (!isset($no)) {
document_location("/blogs");
}
$blog = Ween\DataBase::From("blogs", "first", ["id" => $no]);
$admin = Ween\DataBase::From("admins", "first", ["id" => $blog["adminid"]]);
$date = strftime("%e %B %Y %A %H.%M", date($blog["date"]));
if ($blog) {
require "apps/backend/theme/site/blog.php";
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/blog.php";
} else {
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/404.php";
}
return NULL;
}
if ($page_array[0] == "adminpanel") {
$page = str_replace(["adminpanel/", cngz20_decode($config["general"]["admin-folder"])], ["", ""], $page);
if (!isset($_SESSION["adminid"])) {
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/login.php";
return NULL;
}
$admin = Ween\DataBase::From("admins", "first", ["id" => $_SESSION["adminid"]]);
if ($page_array[1] == "test-ekle") {
if (isset($page_array[2])) {
$getid = $page_array[2];
}
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/test-ekle.php";
return NULL;
}
if (isset($page_array[1]) && $page_array[1] == "gir") {
$_SESSION["id"] = $page_array[2];
document_location("/panel");
}
if (isset($page_array[1]) && $page_array[1] == "uyeler") {
if (isset($page_array[2])) {
if ($page_array[2] == "sil") {
Ween\DataBase::Delete("users", ["id" => $page_array[3]]);
header("location:/adminpanel/uyeler");
return NULL;
}
$uye = $page_array[2];
$uye = Ween\DataBase::From("users", "first", ["id" => $uye]);
}
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/uyeler.php";
return NULL;
}
if (isset($page_array[1]) && $page_array[1] == "kategoriler") {
if (isset($page_array[2])) {
if ($page_array[2] == "sil") {
Ween\DataBase::Delete("categorys", ["id" => $page_array[3]]);
header("location:/adminpanel/kategoriler");
return NULL;
}
$kategori = $page_array[2];
$kategori = Ween\DataBase::From("categorys", "first", ["id" => $kategori]);
}
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/kategoriler.php";
return NULL;
}
if (isset($page_array[1]) && $page_array[1] == "bloglar") {
if (isset($page_array[2])) {
if ($page_array[2] == "sil") {
Ween\DataBase::Delete("blogs", ["id" => $page_array[3]]);
header("location:/adminpanel/bloglar");
return NULL;
}
$blog2 = $page_array[2];
$blog2 = Ween\DataBase::From("blogs", "first", ["id" => $blog2]);
}
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/bloglar.php";
return NULL;
}
if (isset($page_array[1]) && $page_array[1] == "testler") {
if (isset($page_array[2])) {
if ($page_array[2] == "sil") {
Ween\DataBase::Delete("tests", ["id" => $page_array[3]]);
header("location:/adminpanel/testler");
return NULL;
}
$test123 = $page_array[2];
$test123 = Ween\DataBase::From("tests", "first", ["id" => $test123]);
}
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/testler.php";
return NULL;
}
if (isset($page_array[1]) && $page_array[1] == "gir") {
$_SESSION["id"] = $page_array[2];
document_location("/panel");
}
if (isset($page_array[1]) && $page_array[1] == "uyeler") {
if (isset($page_array[2])) {
$uye = $page_array[2];
$uye = Ween\DataBase::From("users", "first", ["id" => $uye]);
}
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/uyeler.php";
return NULL;
}
if (!isset($page_array[1])) {
if (!file_exists("apps/frontend/themes/admin/" . $config["general"]["theme"] . "/" . $config["general"]["home"] . ".php")) {
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/404.php";
exit;
}
require "apps/backend/theme/admin/" . $config["general"]["home"] . ".php";
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/" . $config["general"]["home"] . ".php";
return NULL;
}
if (!file_exists("apps/frontend/themes/admin/" . $config["general"]["theme"] . "/" . $page . ".php")) {
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/404.php";
exit;
}
require "apps/backend/theme/admin/" . $page . ".php";
require "apps/frontend/themes/admin/" . $config["general"]["theme"] . "/" . $page . ".php";
return NULL;
}
if (!file_exists("apps/backend/theme/site/" . $page . ".php")) {
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/404.php";
exit;
}
if (!file_exists("apps/frontend/themes/site/" . $config["general"]["theme"] . "/" . $page . ".php")) {
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/404.php";
exit;
}
require "apps/backend/theme/site/" . $page . ".php";
require "apps/frontend/themes/site/" . $config["general"]["theme"] . "/" . $page . ".php";
}
exit;
} else {
$settings = Ween\DataBase::From("settings", "first");
Ween\Modules::Loader("addons");
}
function isMobile()
{
$mobile = false;
$useragent = $_SERVER["HTTP_USER_AGENT"];
if (preg_match("/(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i", $useragent) || preg_match("/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i", substr($useragent, 0, 4))) {
$mobile = true;
}
return $mobile;
}
function devicename()
{
$tespit = $_SERVER["HTTP_USER_AGENT"];
if (stristr($tespit, "x64")) {
$tur = "64 bit";
} else {
if (stristr($tespit, "x86")) {
$tur = "64 bit";
} else {
$tur = "32 bit";
}
}
if (stristr($tespit, "Windows 95")) {
$os = "Windows 95 " . $tur;
} else {
if (stristr($tespit, "Windows 98")) {
$os = "Windows 98 " . $tur;
} else {
if (stristr($tespit, "Windows NT 5.0")) {
$os = "Windows 2000 " . $tur;
} else {
if (stristr($tespit, "Windows NT 5.1")) {
$os = "Windows XP " . $tur;
} else {
if (stristr($tespit, "Windows NT 6.0")) {
$os = "Windows Vista " . $tur;
} else {
if (stristr($tespit, "Windows NT 6.1")) {
$os = "Windows 7 " . $tur;
} else {
if (stristr($tespit, "Windows NT 6.2")) {
$os = "Windows 8 " . $tur;
} else {
if (stristr($tespit, "Windows NT 6.3")) {
$os = "Windows 8.1 " . $tur;
} else {
if (stristr($tespit, "Windows NT 10")) {
$os = "Windows 10 " . $tur;
} else {
if (stristr($tespit, "Linux")) {
$os = "Linux " . $tur;
} else {
if (stristr($tespit, "iPhone")) {
$os = "iPhone";
} else {
if (stristr($tespit, "Mac OS")) {
$os = "Mac OS";
} else {
$os = $tur;
}
}
}
}
}
}
}
}
}
}
}
}
return $os;
}
function error_add($title, $content, $type)
{
$error_id = rand("1000", "9999");
Ween\DataBase::Insert("errors", ["id" => $error_id, "type" => $type, "title" => $title, "content" => $content]);
return true;
}
?>