Example #1
0
/**
 *  recoverInfoMovies
 *
 *  function
 *
 * 	@param array        $var   Contains all movie found script jonathan with id table files
 *
 *  @return             no return data
 */
function recoverInfoMovies($var)
{
    $id_movie_tmbd = array();
    $key = KEY_TMDB;
    $lang = LANG_TMDB;
    $tmdb = new tmdb($key, $lang);
    $pdo = connectDB();
    foreach ($var as $data) {
        //research id movie in thMovieDB
        $id_movies_tmdb = Search_id_movie($data[FILES_TITLE], $tmdb);
        // if id movie is not found, next movie.
        if ($id_movies_tmdb === false) {
            continue;
        }
        // research full info movie in TheMovieDB
        $Full_Info = Search_info_movie($id_movies_tmdb, $tmdb);
        // if info movie is not found, next movie.
        if ($Full_Info === false) {
            continue;
        }
        //if movie exist in db, it not insert
        if (checkMovie($Full_Info, $pdo) === false) {
            // it insert information in db (Title, Year, tagline, Description, poster)
            $id_movie_db = inserMovies($Full_Info, $pdo);
            // if exist, insert data in db
            foreach ($Full_Info["genres"] as $row) {
                if (($id_genres = getidGenre(get_object_vars($row)["name"], $pdo)) === false) {
                    $id_genres = insertGenre(get_object_vars($row)["name"], $pdo);
                }
                insert_genres_Movie($id_genres, $id_movie_db, $pdo);
            }
            foreach ($Full_Info["production_countries"] as $row) {
                if (($id_countrie = getidCountries(get_object_vars($row)["name"], $pdo)) === false) {
                    $id_countrie = Insert_Countries(get_object_vars($row)["name"], $pdo);
                }
                insert_countrie_movie($id_countrie, $id_movie_db, $pdo);
            }
            foreach ($Full_Info["production_companies"] as $row) {
                if (($id_studios = getidstudios(get_object_vars($row)["name"], $pdo)) === false) {
                    $id_studios = Insert_studios(get_object_vars($row)["name"], $pdo);
                }
                insert_studios_Movie($id_studios, $id_movie_db, $pdo);
            }
            // insert ten actor in db
            $nbcast = 10;
            if (count(get_object_vars($Full_Info["casts"])["cast"]) < 10) {
                $nbcast = count(get_object_vars($Full_Info["casts"])["cast"]);
            }
            $id_role = getrollebyid("Actor", $pdo);
            for ($i = 0; $i < $nbcast; $i++) {
                if (($idPeople = getidPeople(get_object_vars(get_object_vars($Full_Info["casts"])["cast"][$i])["name"], $pdo)) === false) {
                    $idPeople = insert_people(get_object_vars(get_object_vars($Full_Info["casts"])["cast"][$i])["name"], $pdo);
                }
                insert_people_role_movies($idPeople, $id_role, $id_movie_db, $pdo);
            }
            // insert crew, director, writer and producer.
            foreach (get_object_vars($Full_Info["casts"])["crew"] as $crew) {
                $crew = get_object_vars($crew);
                switch ($crew["job"]) {
                    case 'Producer':
                    case 'Director':
                    case 'Writer':
                        if ($id_crew = getidPeople($crew["name"], $pdo) === false) {
                            $id_crew = insert_people($crew["name"], $pdo);
                        }
                        $id_role = getrollebyid($crew["job"], $pdo);
                        insert_people_role_movies($id_crew, $id_role, $id_movie_db, $pdo);
                        break;
                }
            }
        } else {
            $id_movie_db = getIdMovie($Full_Info["original_title"], $pdo);
        }
        // update table files
        Update_files($id_movie_db, $data[FILES_ID], $pdo);
    }
    return;
}
Example #2
0
     $_SESSION["error_msg"] = "All fields are required";
     header('location: /app/admin/?action=view_survey');
     exit;
 }
 echo "<!-- Begin the transaction and lock the database. -->\n";
 $app->beginTransaction();
 require '../model/links.php';
 require '../model/genres.php';
 require '../model/features.php';
 require '../model/comments.php';
 for ($i = 0; $i < $num; $i++) {
     echo "<!-- Check the genre and insert it in the database if it's new. -->\n";
     echo "<!-- Genre: " . $new_genres[$i] . " -->";
     $genres[$i] = getGenreByName($new_genres[$i]);
     if ($genres[$i] == NULL) {
         insertGenre($new_genres[$i]);
         $genres[$i]["genre_id"] = $app->lastInsertId();
     }
     echo "<!-- Link genre with game -->";
     if (checkGamesGenres($game_id, $genres[$i]["genre_id"]) == NULL) {
         linkGamesGenres($game_id, $genres[$i]["genre_id"]);
     }
     echo "<!-- Check the feature and insert it in the database if it's new. -->\n";
     echo "<!-- Feature: " . $new_features[$i] . " -->";
     if ($new_features[$i] != "none") {
         $features[$i]["feature_id"] = 0;
         $features[$i]["not_like_it"] = 0;
         $features[$i]["like_it"] = 0;
         $features[$i] = getFeatureByName($new_features[$i]);
         if ($features[$i] == NULL) {
             insertFeature($new_features[$i]);
Example #3
0
     $review["strengths"] = NULL;
 }
 if ($review["weaknesses"] == "") {
     $review["weaknesses"] = NULL;
 }
 // echo "<!-- Begin the transaction and lock the database. -->\n";
 $app->beginTransaction();
 // echo "<!-- Get the audience ID from the database. -->\n";
 require 'model/audiences.php';
 $audience = getAudience($review);
 $review["audience_id"] = $audience["audience_id"];
 // echo "<!-- Check the genre and insert it in the database if it's a new one. -->\n";
 require 'model/genres.php';
 $genre = getGenreByName($review["genre"]);
 if ($genre == NULL) {
     insertGenre($review["genre"]);
     $genre["genre_id"] = $app->lastInsertId();
 }
 $review["genre_id"] = $genre["genre_id"];
 // echo "<!-- Check the game and insert it in the database if it's a new one. -->\n";
 // echo "<!-- game: " . $review["game"] . " -->";
 require 'model/games.php';
 $game = getGameByName($review["game"]);
 // echo "<!-- $game: " . $game . " -->";
 if ($game == NULL) {
     // echo "<!-- The game doesn't exist. -->";
     insertGame($review["game"]);
     // echo "<!-- Game inserted with success. -->\n";
     $game["game_id"] = $app->lastInsertId();
     // echo "<!-- game_id: " . $game["game_id"] . " -->";
 }
Example #4
0
function updateSong($currentSong, $currentDirectory, $mtimeDirectory, $mtime, $time, $artist, $title, $track, $album, $date, $genre)
{
    global $cfg, $db, $allAlbumIds, $allGenreIds;
    // phase
    if (isset($allAlbumIds[$cfg['media_dir'] . $currentDirectory]) === TRUE) {
        $album_id = $allAlbumIds[$cfg['media_dir'] . $currentDirectory];
    } else {
        // create a new album_id
        $album_id = base_convert(uniqid(), 16, 36);
        $album_add_time = $mtimeDirectory;
        mysql_query("\n\t\t\tINSERT INTO album_id(\n\t\t\t\talbum_id,\n\t\t\t\tpath,\n\t\t\t\talbum_add_time,\n\t\t\t\tupdated\n\t\t\t) VALUES ('" . mysql_real_escape_string($album_id) . "','" . mysql_real_escape_string($cfg['media_dir'] . $currentDirectory) . "','" . $album_add_time . "',\n\t\t\t\t'1'\n\t\t\t)");
        $allAlbumIds[$cfg['media_dir'] . $currentDirectory] = $album_id;
        // initial insert with album-tags based on (first) track
        # genre is currently '1(Unknown)' - it will be updated in on of the next import/update phases
        mysql_query("\n\t\t\tINSERT INTO album(\n\t\t\t\tartist,\n\t\t\t\tartist_alphabetic,\n\t\t\t\talbum,\n\t\t\t\tyear,\n\t\t\t\talbum_id,\n\t\t\t\talbum_add_time,\n\t\t\t\tgenre_id,\n\t\t\t\tdiscs,\n\t\t\t\tupdated\n\t\t\t) VALUES (\n\t\t\t\t'" . mysql_real_escape_string($artist) . "',\n\t\t\t\t'" . mysql_real_escape_string($artist) . "',\n\t\t\t\t'" . mysql_real_escape_string($album) . "',\n\t\t\t\t'" . mysql_real_escape_string($date) . "',\n\t\t\t\t'" . mysql_real_escape_string($album_id) . "',\n\t\t\t\t'" . (int) $album_add_time . "',\n\t\t\t\t'1',\n\t\t\t\t'1',\n\t\t\t\t'1'\n\t\t\t)");
    }
    // TODO: assign multiple genres to track and album based on splitchars
    $genre = genreUnifier($genre);
    $genreAz09 = az09($genre);
    // get Genre id
    $genre_id = isset($allGenreIds[$genreAz09]) === TRUE ? $allGenreIds[$genreAz09] : insertGenre($genre);
    $allGenreIds[$genreAz09] = $genre_id;
    // check if we do already have a matching track
    $res = mysql_query('SELECT track_id FROM track
		WHERE album_id		= "' . mysql_real_escape_string($album_id) . '"
		AND relative_file	= BINARY "' . mysql_real_escape_string($currentDirectory . $currentSong) . '"
		LIMIT 1');
    if (mysql_num_rows($res) == 0) {
        mysql_query('
			INSERT INTO track (
				artist,
				title,
				relative_file,
				relative_file_hash,
				number,
				album_id,
				updated,
				track_id,
				filemtime,
				genre,
				year,
				disc,
				miliseconds,
				track_artist
			)
			VALUES (
				"' . mysql_real_escape_string($artist) . '",
				"' . mysql_real_escape_string($title) . '",
				"' . mysql_real_escape_string($currentDirectory . $currentSong) . '",
				"' . pathhash($currentDirectory . $currentSong) . '",
				' . (is_numeric($track) ? (int) $track : 'NULL') . ',
				"' . mysql_real_escape_string($album_id) . '",
				1,
				\'' . $album_id . '_' . fileId($cfg['media_dir'] . $currentDirectory . $currentSong) . '\',
				' . (int) $mtime . ',
				' . (int) $genre_id . ',
				' . (int) $date . ',
				1,
				' . $time * 1000 . ',
				\'' . mysql_real_escape_string($artist) . '\'
			)');
    } else {
        $row = mysql_fetch_assoc($res);
        $track_id = $row["track_id"];
        mysql_query('UPDATE track SET
			artist				= "' . mysql_real_escape_string($artist) . '",
			title				= "' . mysql_real_escape_string($title) . '",
			number				= ' . (is_numeric($track) ? (int) $track : 'NULL') . ',
			album_id			= "' . mysql_real_escape_string($album_id) . '",
			updated				= 1
			WHERE track_id		= "' . mysql_real_escape_string($track_id) . '"
			LIMIT 1');
    }
}