Location: PHPKode > projects > Php4dvd - movie database > php4dvd/index.php
<?php
/**
================================================================================ 
 LISENCE
================================================================================

    This file is part of php4dvd.

    php4dvd is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    php4dvd is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with php4dvd. If not, see <http://www.gnu.org/licenses/>.
**/

/**
 * This page controls your site. Do not change anything unless you know what you are doing. 
 * If you want to change the looks of your page, copy the default_en directory in /tpl/ and create your own template.
 */
$time_start = microtime(true);

// Default config
require_once("common.inc.php");

// Login script
require_once("includes/login.inc.php");

// Template
$template = "index.html";

// Include
$template_dir = $settings["smarty"]["template_include_dir"];
$w->assign("template_dir", $template_dir);

$go = isset($_GET['go']) ? $_GET['go'] : '';
switch ($go) {
	default:			/**
						 * Default opening page
						 */
						// Template
						$w->assign("main", "movies/collection.html");
						
						// Movies
						require_once("includes/movies.inc.php");
						
						break;
						
	case "list":		/**
						 * Create a list of the movies
						 */
						// Template
						$template = "movies/list.html";
						
						// Viewing movies is only possible when logged in or when guests can view movie information
						if(!$loggedin && !$guestview) {
							header("Location: ./");
							exit();
						}
						
						// Movies
						require_once("includes/movies.inc.php");
						
						break;
						
	case "movie":		/**
						 * Show the information of one movie
						 */
						// Template
						$w->assign("main", "movies/movie.html");
						
						// Viewing movie information is only possible when logged in or when guests can view movie information
						if(!$loggedin && !$guestview) {
							header("Location: ./");
							exit();
						}
						
						// Movies
						require_once("includes/movies.inc.php");
						
						break;
						
	case "add":			/**
						 * Add a new movie
						 */
						// Template
						$w->assign("main", "movies/add.html");
						
						// Adding is only possible if the user is logged in and editor
						if(!isset($User) || !$User->isEditor()) {
							header("Location: ./");
							exit();
						}
						
						// Movies
						require_once("includes/movies.inc.php");
						
						break;
						
	case "edit":		/**
						 * Edit the movie information
						 */
						// Template
						$w->assign("main", "movies/edit.html");
						
						// Editing is only possible if the user is logged in and editor
						if(!isset($User) || !$User->isEditor()) {
							header("Location: ./");
							exit();
						}
						
						// Movies
						require_once("includes/movies.inc.php");
						
						break;
						
	case "update":		/**
						 * Update the movie information from IMDb
						 */
						// Template
						$w->assign("main", "movies/update.html");
						
						// Updating is only possible if the user is logged in and editor
						if(!isset($User) || !$User->isEditor()) {
							header("Location: ./");
							exit();
						}
						
						// IMDb
						require_once("includes/imdb.inc.php");
						
						break;
						
	case "profile":		/**
						 * Change your profile (password and e-mail)
						 */
						// Template
						$w->assign("main", "users/profile.html");
						
						// Updating is only possible if the user is logged in
						if(!isset($User)) {
							header("Location: ./");
							exit();
						}
						
						// Users
						require_once("includes/users.inc.php");
						
						break;
						
	case "users":		/**
						 * Modify the user accounts
						 */
						// Template
						$w->assign("main", "users/users.html");
						
						// Updating is only possible if the user is logged in and admin
						if(!isset($User) || !$User->isAdmin()) {
							header("Location: ./");
							exit();
						}
						
						// Users
						require_once("includes/users.inc.php");
						
						break;
						
	case "user":		/**
						 * Modify a single user account
						 */
						// Template
						$w->assign("main", "users/user.html");
						
						// Updating is only possible if the user is logged in and admin
						if(!isset($User) || !$User->isAdmin()) {
							header("Location: ./");
							exit();
						}
						
						// Users
						require_once("includes/users.inc.php");
						
						break;
}

// PHP parse time
$time_end = microtime(true); 
$managertime = $time_end - $time_start;  

// Display template
$w->display($template);

// Smarty template parse time
$time_end = microtime(true); 
$tpltime = $time_end - $time_start - $managertime;  

// Print the parse timings at the end of the HTML page
print "\n\n<!-- ** php parsetime: ".number_format($managertime, 5)." sec. ** -->\n"; 
print "<!-- ** tpl parsetime: ".number_format($tpltime, 5)." sec. ** -->";

?>
Return current item: Php4dvd - movie database