$temp[] = $result;
        }
        $imdbresults = $temp;
        $Website->assign("imdbresults", $imdbresults);
    }
}
// Update movie
if (isset($_POST["movieid"])) {
    // Editing existing movie?
    $movieid = $_POST["movieid"];
    $movie = $moviedm->get($movieid);
    if (!$movie) {
        $movie = new Movie();
    }
    // Update movie
    $movie = fillObject($movie, $_POST, array(), array('movieid', 'autoupdate', 'submit'));
    // Save movie
    $movie->id = $moviedm->save($movie);
    // Save its image
    if (isset($movie->imdbid) && strlen(trim($movie->imdbid)) > 0) {
        // IMDB engine
        require_once $loc . "/lib/imdbphp/imdb.class.php";
        $m = new imdb($movie->imdbid);
        $m->savephoto($photopath . $movie->id . ".jpg");
    }
    // Save its cover
    if (isset($_FILES["cover"]) && isset($_FILES["cover"]["size"]) && $_FILES["cover"]["size"] > 0) {
        $movie->addCover("cover", $coverpath);
    }
    // Go to the next auto update step
    if (isset($_POST["autoupdate"]) && $_POST["autoupdate"]) {
Esempio n. 2
0
<?php

/**
 * Some important variables for other users to work with in code or templates:
 * - 'users' are all users
 */
// Datamanagers
require_once $loc . "/lib/db/Users.class.php";
$userdm = new Users($settings["db"]);
// Get all users if the user is allowed to
if ($loggedin || $User->isAdmin()) {
    $users = $userdm->all();
    $Website->assign("users", $users);
}
// Add a new user
if ($loggedin && $User->isAdmin() && isset($_POST["username"])) {
    $newuser = new User();
    $newuser = fillObject($newuser, $_POST, array(), array('password2', 'submit'));
    $newuser->password = md5($newuser->password);
    // No other user with this username?
    if ($userdm->existsUser($newuser->username, $newuser->email)) {
        $Website->assign("username_error", DUPLICATE_USER_NAME_OR_EMAIL);
        $Website->assign("newuser", $newuser);
    } else {
        $userdm->save($newuser);
        reload();
    }
}
if (!$loggedin || !$User->isAdmin() && $User->id != $user->id) {
    home();
}
// Update the user information
if (isset($user) && isset($_POST["email"])) {
    $exclude = array('username', 'password2', 'submit');
    // Only admins can update permissions when they are not editing themselves
    if (!$User->isAdmin() || $User->id == $user->id) {
        $exclude[] = 'permission';
    }
    // Do not update password when there was no new password entered
    if (!isset($_POST["password"]) || empty($_POST["password"])) {
        $exclude[] = 'password';
    }
    // Update user
    $user = fillObject($user, $_POST, array(), $exclude);
    // Update password when a new password was entered
    if (isset($_POST["password"]) && !empty($_POST["password"])) {
        $user->password = md5($user->password);
    }
    // Check for duplicate users with the same e-mail address
    $duplicateUsers = $userdm->usersWithEmail($user->email);
    if ($duplicateUsers > 1) {
        $Website->assign("username_error", DUPLICATE_USER_NAME_OR_EMAIL);
    } else {
        // Save to the database
        $userdm->save($user);
        // Go to user overview (when the user has no permissions, the page will send him back to the home page)
        header("Location: ./?go=users");
        exit;
    }