Exemple #1
0
/**
 * Shows the asset details div for the asset passed by POST, GET or SESSION
 * @global type $input
 * @global type $repository_path 
 */
function view_asset_details($refresh_center = true)
{
    global $input;
    global $appname;
    global $repository_path;
    global $ezplayer_url;
    // used in a popup window
    global $asset_meta;
    global $album;
    global $user_files_path;
    global $is_bookmark;
    global $asset_bookmarks;
    global $toc_bookmarks;
    global $default_bookmarks_order;
    global $default_toc_order;
    global $login_error;
    // used to display error when anonymous user login
    // determines if the user is logged and has access to the selected album
    $is_bookmark = false;
    // used in 'div_left_details.php' to precise the video has to be loaded
    $_SESSION['load_video'] = true;
    // the session has expired, the whole page has to be refreshed
    if ($_SESSION['reloaded']) {
        unset($input['click']);
        unset($_SESSION['reloaded']);
        $refresh_center = true;
    }
    // Setting up various variables we'll need later
    if (isset($input['album'])) {
        $album = $input['album'];
    } else {
        $album = $_SESSION['album'];
    }
    if (isset($input['asset'])) {
        $asset = $input['asset'];
    } else {
        $asset = $_SESSION['asset'];
    }
    if (isset($input['asset_token'])) {
        $asset_token = $input['asset_token'];
    } else {
        $asset_token = $_SESSION['asset_token'];
    }
    // init paths
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    //
    // 0) Sanity checks
    //
    if (!isset($album) || !ezmam_album_exists($album)) {
        if ($input['click']) {
            // refresh a part of the page
            include_once template_getpath('error_album_not_found.php');
        } else {
            // refresh the whole page
            $error_path = template_getpath('error_album_not_found.php');
            include_once template_getpath('main.php');
        }
        log_append('warning', 'view_asset_details: tried to access album ' . $album . ' which does not exist');
        die;
    }
    if (!ezmam_asset_exists($album, $asset)) {
        if ($input['click']) {
            include_once template_getpath('error_asset_not_found.php');
        } else {
            $error_path = template_getpath('error_asset_not_found.php');
            include_once template_getpath('main.php');
        }
        log_append('warning', 'view_asset_details: tried to access asset ' . $asset . ' of album ' . $album . ' which does not exist');
        die;
    }
    // the user has access to the album so we don't need a token
    if (acl_user_is_logged() && acl_has_album_permissions($album)) {
        //saves the asset token for the link to display in "share the asset" in left_details.php
        $asset_token = ezmam_asset_token_get($album, $asset);
        $is_bookmark = true;
    } else {
        // either the user is not logged in or he doesn't have access to the album
        if (!ezmam_asset_token_check($album, $asset, $asset_token)) {
            if ($input['click']) {
                // refresh a part of the page
                include_once template_getpath('error_permission_denied.php');
            } else {
                // refresh the whole page
                $error_path = template_getpath('error_permission_denied.php');
                include_once template_getpath('main.php');
            }
            log_append('warning', 'view_asset_details: tried to access asset ' . $input['asset'] . 'in album ' . $input['album'] . ' with invalid token ' . $input['asset_token']);
            die;
        }
    }
    if (acl_user_is_logged()) {
        if (user_prefs_watched_add($_SESSION['user_login'], $album, $asset) && acl_show_notifications()) {
            acl_update_watched_assets();
        }
    }
    // 1) info for the selected asset
    $asset_meta = ezmam_asset_metadata_get($album, $asset);
    if ($asset_meta['record_type'] == 'camslide' || $asset_meta['record_type'] == 'cam') {
        $asset_meta['high_cam_src'] = get_link_to_media($album, $asset, 'high_cam');
        $asset_meta['low_cam_src'] = get_link_to_media($album, $asset, 'low_cam');
        $asset_meta['src'] = $asset_meta['low_cam_src'] . '&origin=' . $appname . "#t=" . $input['t'];
    }
    if ($asset_meta['record_type'] == 'camslide' || $asset_meta['record_type'] == 'slide') {
        $asset_meta['high_slide_src'] = get_link_to_media($album, $asset, 'high_slide');
        $asset_meta['low_slide_src'] = get_link_to_media($album, $asset, 'low_slide');
        if ($asset_meta['record_type'] == 'slide') {
            $asset_meta['src'] = $asset_meta['low_slide_src'] . '&origin=' . $appname . "#t=" . $input['t'];
        }
    }
    if ($is_bookmark) {
        // loads all bookmarks for the selected asset (displayed in 'div_side_details.php')
        $asset_bookmarks = user_prefs_asset_bookmarks_list_get($_SESSION['user_login'], $album, $asset);
        // sorts the bookmarks following user's prefs
        $order = acl_value_get("bookmarks_order");
        if (isset($order) && $order != '' && $order != $default_bookmarks_order) {
            $asset_bookmarks = array_reverse($asset_bookmarks);
        }
    }
    // loads the table of contents for the selected asset (displayed in 'div_side_details.php')
    $toc_bookmarks = toc_asset_bookmark_list_get($album, $asset);
    // sorts the bookmarks following user's prefs
    $order = acl_value_get("toc_order");
    if (isset($order) && $order != '' && $order != $default_toc_order) {
        $toc_bookmarks = array_reverse($toc_bookmarks);
    }
    log_append('view_asset_details: album = ' . $album . ", asset = " . $asset);
    $_SESSION['ezplayer_mode'] = 'view_asset_details';
    $_SESSION['album'] = $album;
    $_SESSION['asset'] = $asset;
    $_SESSION['asset_token'] = $asset_token;
    if ($refresh_center) {
        // the whole page must be displayed
        if (acl_display_threads()) {
            $threads = threads_select_by_asset($album, $asset);
            $_SESSION['thread_display'] = 'list';
        }
        if ($input['click']) {
            // called from a local link
            // lvl, action, album, asset, record type (cam|slide|camslide), permissions (view official | add personal), origin
            trace_append(array('3', 'view_asset_details', $album, $asset, $asset_meta['record_type'], $is_bookmark ? 'view_and_add' : 'view_only', 'from_ezplayer'));
            include_once template_getpath('div_assets_center.php');
        } else {
            // called from the UV or a shared link
            trace_append(array('3', 'view_asset_details', $album, $asset, $asset_meta['record_type'], $is_bookmark ? 'view_and_add' : 'view_only', 'from_external'));
            include_once template_getpath('main.php');
        }
    } else {
        // only the bookmarks on the right must be refreshed
        // i.e: after bookmark add / edit / import / export / ...
        $_SESSION['load_video'] = false;
        include_once template_getpath('div_side_details.php');
    }
}
Exemple #2
0
/**
 * Resets a token for a specific asset
 * @param type $asset
 * @param type $album 
 * @param bool $logging If set to false, the operation won't be logged
 * @return bool error status
 */
function ezmam_asset_token_reset($album, $asset, $logging = true)
{
    $repository_path = ezmam_repository_path();
    $old_token = ezmam_asset_token_get($album, $asset);
    $res = ezmam_asset_token_create($album, $asset);
    if (!$res) {
        ezmam_last_error("ezmam_asset_token_reset: unable to reset token");
        return false;
    }
    // Logging
    if ($logging) {
        log_append('asset_token_reset', 'Asset: ' . $asset . ', Album: ' . $album . ', Old token: ' . $old_token . ', New token: ' . $res);
    }
}
Exemple #3
0
/**
 * Displays the popup with the EZplayer link to copypaste
 * @global type $input
 * @global type $repository_path
 * @global type $url 
 */
function popup_ezplayer_link()
{
    global $input;
    global $ezplayer_url;
    global $repository_path;
    $album = $input['album'];
    $asset = $input['asset'];
    ezmam_repository_path($repository_path);
    //
    // Sanity checks
    //
    if (!isset($input['album']) || !isset($input['asset'])) {
        die;
    }
    if (!ezmam_album_exists($input['album']) || !ezmam_asset_exists($input['album'], $input['asset'])) {
        error_print_message(ezmam_last_error());
        die;
    }
    $token = ezmam_asset_token_get($input['album'], $input['asset']);
    $ezplayer_link = $ezplayer_url . '/index.php?action=view_asset_details' . '&album=' . $album . '&asset=' . $asset . '&asset_token=' . $token . '&anon=true';
    // Displaying the popup
    require_once template_getpath('popup_ezplayer_link.php');
}
Exemple #4
0
/**
 * Returns a special code that contains information about the media
 * @global type $url
 * @param string $album
 * @param string $asset
 * @param string $media
 * @return string Media
 */
function get_code_to_media($album, $asset, $media)
{
    global $ezplayer_url;
    global $distribute_url;
    global $repository_path;
    ezmam_repository_path($repository_path);
    //
    // Usual sanity checks
    //
    if (!ezmam_album_exists($album)) {
        error_print_message('get_link_to_media: Album ' . $album . ' does not exist');
        return false;
    }
    if (!ezmam_asset_exists($album, $asset)) {
        error_print_message('get_link_to_media: Asset ' . $asset . ' does not exist');
        return false;
    }
    // We take the asset's token if it exists.
    // If not, then we use the album's token instead.
    $token = ezmam_asset_token_get($album, $asset);
    if (!$token) {
        $token = ezmam_album_token_get($album);
    }
    if (!$token) {
        error_print_message('get_link_to_media: ' . ezmam_last_error());
        return false;
    }
    $media_infos = explode('_', $media);
    // 'media' is like high_cam, so we want to extract the "high" part (quality) and the "cam" part (type)
    $quality = $media_infos[0];
    $type = $media_infos[1];
    return $album . '/' . $asset . '/' . $type . '/' . $quality . '/' . $token;
}