<?php
session_start();

// include all stuff
include_once "include/db_connect.php";
include_once "include/functions_sql.php";
include_once "include/functions_www.php";
include_once "include/functions_display.php";
include_once "include/global.php";
include_once "include/section.php";
include_once "include/menu.php";
include_once "include/connection.php";
include_once "include/home.php";
include_once "include/news.php";
include_once "include/videos.php";
include_once "include/members.php";
include_once "include/contacts.php";
include_once "include/dailymotion.php";
include_once "admin/admin_home.php";

// define user right and id if new session
if (!$_SESSION["user_id"] or !$_SESSION["user_right"]) {
  $_SESSION["user_id"] = 0;
  $_SESSION["user_right"] = 0;
 }

// if user is blacklisted redirect it
if ($_SESSION["user_right"] == -1) {
  go_random_blacksite();
  return;
 }

// No logged user is allowed without https!
if ($_SERVER['HTTPS'] != "on" && $_SESSION["user_id"] > 0)
  userDisconnect();

// Authentification process
if ($_GET['connect']) {
  $connect_tv = $_GET['connect'];
  if ($connect_tv == 1)
      checkUser($_POST['user_login'], $_POST['user_pass']);
  else if ($connect_tv == -1)
    userDisconnect();
 }

// Download video
if ($_GET['video'])
  return getVideo();

// Dailymotion playback
if ($_GET['dailymotion'])
  return getDailymotion();

// Display section
getSection();
?>

