<?php

/**
 * osTube
 *
 * @version 2.3
 * @copyright 2008 Auvica GmbH
 * $Id: index.php 17180 2009-02-09 14:05:12Z Andreas $
 */

$root_path = './';
include("{$root_path}includes/header.php");

global $main;

$smarty = new mySmarty();
$media = new MediaInformation();

include("includes/functions_start.php");

$smarty->assign("IS_ADMIN_START_PAGE", $login->isAdmin());

$lang = loadConfig_file("media_newfiles");

$moduls = array();
$dbconn->query("SELECT * FROM ".$dbconn -> getTable("boxsorting")."
                WHERE sorting_sort > 0 
                AND sorting_place = 'startpage' 
                ORDER BY sorting_sort ASC","boxen_query");

while($all = $dbconn -> return_array("boxen_query")){
	if($all["sorting_boxname"]!="videoblock"){
		$moduls[$all["sorting_boxname"]] = $all;
		switch($all["sorting_boxname"]){
			case "mystats" :
				$moduls[$all["sorting_boxname"]]["content"] = start_addMyStats(); break;
			case "infotext":
				$moduls[$all["sorting_boxname"]]["content"] = $main -> getBox($all["sorting_boxname"], "start"); break;
			case "tags":
				$moduls[$all["sorting_boxname"]]["content"] = ($main->getConfig("tags")=="css")? $main->getBox("tags", array("SITE" => "start")) : start_addTagCloud(); break;
			case "newvideos":
				$moduls[$all["sorting_boxname"]]["content"] = start_mediaTypeBox("video", $lang["newfiles_videos_title"], "media.php?type=video&order=date"); break;
			case "newaudios":
				$moduls[$all["sorting_boxname"]]["content"] = start_mediaTypeBox("audio", $lang["newfiles_audios_title"], "media.php?type=audio&order=date"); break;
			case "newimages":
				$moduls[$all["sorting_boxname"]]["content"] = start_mediaTypeBox("photo", $lang["newfiles_photos_title"], "media.php?type=photo&order=date"); break;
			case "newdocuments":
				$moduls[$all["sorting_boxname"]]["content"] = start_mediaTypeBox("document", $lang["newfiles_documents_title"], "media.php?type=document&order=date"); break;
			case "bestrated":
				$moduls[$all["sorting_boxname"]]["content"] = start_addBestrated(); break;
			case "newusers":
				$moduls[$all["sorting_boxname"]]["content"] = ($main -> getConfig("users_show_new_users_with_picture_only") == true) ? $main -> getBox("newusers", array("userswithpicturesonly" => true)) : $main -> getBox("newusers");break;
			default:
				$moduls[$all["sorting_boxname"]]["content"] = $main -> getBox($all["sorting_boxname"]);
		};
	}else{
		if($all["sorting_sort"]!=0)$smarty -> assign("BOX_VIDEOS", start_videoBox($lang["newfiles_videos_title"], "media.php?type=video&order=date"));
	};
};

foreach($moduls as $key=>$modul){
	switch($modul["sorting_boxname"]){
		case "chatbox": $moduls[$key]["boxitems"] = $main->getConfig("box_num_chat"); break;
		case "newusers": $moduls[$key]["boxitems"] = $main->getConfig("users_num_newestusers"); break;
		case "usersonline": $moduls[$key]["boxitems"] = $main->getConfig("users_num_whoisonline"); break;
		case "comments": $moduls[$key]["boxitems"] = $main->getConfig("box_num_comments"); break;
		case "blogbox": $moduls[$key]["boxitems"] = $main->getConfig("box_num_blog"); break;
		case "newimages": $moduls[$key]["boxitems"] = $main->getConfig("media_num_photos_startpage"); break;
		case "newdocuments": $moduls[$key]["boxitems"] = $main->getConfig("media_num_docs_startpage"); break;
		case "newvideos": $moduls[$key]["boxitems"] = $main->getConfig("media_num_videos_startpage"); break;
		case "newaudios": $moduls[$key]["boxitems"] = $main->getConfig("media_num_audios_startpage"); break;
		case "bestrated": $moduls[$key]["boxitems"] = $main->getConfig("media_num_topmedia_startpage"); break;
		default: $moduls[$key]["boxitems"] = 0;
	};
}
$smarty -> assign("MODULS", $moduls);

$main -> EndScript($smarty -> fetch("content/index.tpl"));
?>
