Location: PHPKode > projects > Php4dvd - movie database > php4dvd/includes/imdb.inc.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/>.
**/

/**
 * Some important variables for other users to work with in code or templates:
 * - 'imdbmovie' is the movie containing the information directly from IMDb
 */
// Datamanagers
require_once($loc."/lib/db/MovieDataManager.class.php");
$moviedm = new MovieDataManager($db, $settings);
require ($loc."/lib/util/imdbphp/imdb.class.php");

// If the user logged in and is editor, it can be updated from IMDb
if($loggedin && $User->isEditor()) {
	/***********************************************************
	 * Update movie information from IMDb
	 ***********************************************************/
	
	// Updating is only possible if the user is logged in and editor
	if(isset($User) && $User->isEditor()) {
		// Get movie
		if(isset($_GET["id"])) {
			$movie = $moviedm->getMovie($_GET["id"]);
			if(!$movie)
				goBack();
			$w->assign("mymovie", $movie);
			
			// Search IMDb for this movie
			$imdbmovie = new imdb($movie->imdbid);
			$w->assign("movie", $imdbmovie);
		}
		
		// Update
		if(isset($movie) && isset($_POST["update"]) && $_POST["update"] == 1) {
			$movie = Factory::FillObject($movie, $_POST);
			$movie->update();
			
			// Save its image
			if(isset($movie->image) && $imdbmovie) {
				$bestand = $settings["foto"]["movies"].$movie->id.".jpg";
				if(file_exists($bestand))
					unlink($bestand);
				$imdbmovie->savephoto($bestand);
			}
			// Save its cover
			if(isset($_FILES["cover"]) && isset($_FILES["cover"]["size"]) && $_FILES["cover"]["size"] > 0) {
				$movie->addCover("cover", $settings["foto"]["covers"]);
			}
			
			header("Location: ./?go=edit&id=".$movie->id);
			exit();
		}
	}
}
?>
Return current item: Php4dvd - movie database