<?php

include 'includes/connect.php';
include_once "includes/analyticstracking.php";
$interface = new databaseInterface();
if (isset($_GET['art_id'])) {
    if (isset($_GET['typ'])) {
        $typ = htmlspecialchars($_GET['typ']);
    }
    $art_id = htmlspecialchars($_GET['art_id']);
    if ($typ == 'blog') {
        $typ = 'blog_items';
    } else {
        if ($typ == 'project') {
            $typ = 'project_items';
        }
    }
    $article = $interface->getById($art_id, $typ);
    $tags_array = explode(":", $article[0]["tags"]);
    $interface->addView($art_id, $typ);
}
if (isset($_GET['typ'])) {
    $typ = htmlspecialchars($_GET['typ']);
}
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title></title>
class ListObject
{
    public $title;
    public $description;
    public $author;
    public $date;
    public $tags = array();
    public function __construct($title, $description, $author, $date)
    {
        $this->title = $title;
        $this->description = $description;
        $this->author = $author;
        $this->date = $date;
    }
}
$interface = new databaseInterface();
if (isset($_GET['search'])) {
    if ($_GET['search'] == 'latest') {
        if (isset($_GET['tag'])) {
            $result = $interface->getByTag(htmlspecialchars($_GET['tag']), 'blog_items', 'date');
        } else {
            $result = $interface->getByDate('blog_items');
        }
    } else {
        if ($_GET['search'] == 'popular') {
            if (isset($_GET['tag'])) {
                $result = $interface->getByTag(htmlspecialchars($_GET['tag']), 'blog_items', 'popular');
            } else {
                $result = $interface->getByViews('blog_items');
            }
        } else {