//* Version 1.0
//* Script created by Samiuddin Samiuddin
//* Email: phpdevsami@gmail.com
//* Skype: n0h4cks
//* - This is not an open source project, functions/classes
//*   or any other code form this script cannot be
//*   used for other scripts or applications.
//*   You are not allowed to resell this script.
//* - You are free to make modification/changes,
//*   however it must be for your own use.
//*********************************************************************//
session_start();
if (!isset($_SESSION["logged_in"])) {
    header("location: index.php");
}
include_once "../general/general_class.php";
include_once "../connection_to_db.php";
include_once "../show_data_class.php";
include_once "edit_info_class.php";
include_once "admin_class.php";
$Admin_cp = new Admin($conn);
if (isset($_SESSION["logged_in"]) and $Admin_cp->is_admin()) {
    $Data_display_to_edit = new Data_display($conn);
    $Data_display_to_edit->file = "edit_category.php";
    $Data_display_to_edit->set_title("</br> <b> Click on the category title to edit </b>");
    $Data_display_to_edit->show_categories();
    $Edit_info = new edit_info($conn);
    $Edit_info->edit_category();
} else {
    header("location: ../index.php");
}
if (!$Login->is_user_logged_in("logged_in")) {
    //if user is not logged in then show login, register, and recover_password options
    //link to search bar
    echo "<a href=\"search/search.php\"> Search on this site </a> </br>";
    echo "<a href='login_user/login.php'> Login </a> </br>";
    echo "<a href='register_account/register.php'> Register new account </a> </br>";
    echo "<a href='recover_password/recover_password.php'> Recover password </a> </br>";
}
if ($Login->is_user_logged_in("logged_in")) {
    //greet user
    echo "<p style=\"display:inline\">Hello</p> <p style=\"display:inline\" class='thread_by'> {$_SESSION["logged_in"]} </p> </br>";
    //link to search bar
    echo "<a href=\"search/search.php\"> Search on this site </a> </br>";
    echo "<a href=\"login_user/logout.php\"> Logout </a> </br>";
    echo "<a href=\"user_profile.php\"> My profile </a> </br>";
    echo "<a href=\"chatbox/chat_box.php\"> Join chat </a> </br>";
    //If user is logged in(session exists), we're going to check if user is admin.
    //..checks if user is admin
    if ($Login->is_user_admin()) {
        echo "<a href=\"admin/admin_cp.php\"> Admin control panel </a> </br>";
    }
}
//Shows categories and other things.
$Data_display->show_categories();
//instantiating Click class.
$click_tracker = new Click($conn);
//Calling store_clicks();
$click_tracker->store_clicks();
//Calling show_hits_amount(), this shows the amount your site has been hit.
$click_tracker->show_hits_amount();
echo "</br> </br> </br> </br> </br> <p  style='background-color:yellow; color:black; width:300px'>Forum script by <a href='https://github.com/phpdevsami/samforum'> samforum S. Samiuddin</a> </p>";