示例#1
0
/**
 * First method to call when using the lib_acl
 * @param string $netid the user's netID
 * @return bool error status
 */
function acl_init($netid)
{
    // initializing ezmam (we'll need it later)
    global $repository_path;
    ezmam_repository_path($repository_path);
    // Retrieving the permissions
    acl_update_permissions_list();
    // All is set, we're good to go
    return true;
}
示例#2
0
/**
 * Used to sign in without a login
 * @global array $input
 * @global type $template_folder
 * @global type $login_error
 * @global type $repository_path
 * @global type $user_files_path
 * @global type $ezplayer_url
 */
function anonymous_login()
{
    global $input;
    global $template_folder;
    global $login_error;
    global $repository_path;
    global $user_files_path;
    global $ezplayer_url;
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    $login_error = '';
    $login = $input['login'];
    $passwd = $input['passwd'];
    unset($input['login']);
    unset($input['passwd']);
    $input['action'] = $_SESSION['ezplayer_mode'];
    $album_tokens = $_SESSION['acl_album_tokens'];
    unset($input['click']);
    // 0) Sanity checks
    if (!isset($login) || !isset($passwd) || empty($login) || empty($passwd)) {
        $login_error = template_get_message('empty_username_password', get_lang());
        load_page();
        die;
    }
    // checks if runas
    if (count($login_parts) == 2) {
        if (!file_exists('admin.inc')) {
            $error = "Not admin. runas login failed";
            view_login_form();
            die;
        }
        include 'admin.inc';
        //file containing an assoc array of admin users
        if (!isset($admin[$login_parts[0]])) {
            $error = "Not admin. runas login failed";
            view_login_form();
            die;
        }
        $_SESSION['user_is_admin'] = true;
        $_SESSION['user_runas'] = true;
    } else {
        if (file_exists('admin.inc')) {
            include 'admin.inc';
            //file containing an assoc array of admin users
            if (isset($admin[$login])) {
                $_SESSION['user_is_admin'] = true;
            }
        }
    }
    $res = checkauth($login, $passwd);
    if (!$res) {
        $login_error = checkauth_last_error();
        load_page();
        die;
    }
    // 1) Initializing session vars
    $_SESSION['ezplayer_logged'] = "user_logged";
    // "boolean" stating that we're logged
    unset($_SESSION['ezplayer_anonymous']);
    // "boolean" stating that we're logged
    $_SESSION['user_login'] = $res['login'];
    $_SESSION['user_real_login'] = $res['real_login'];
    $_SESSION['user_full_name'] = $res['full_name'];
    $_SESSION['user_email'] = $res['email'];
    $_SESSION['admin_enabled'] = false;
    if (isset($album_tokens)) {
        user_prefs_tokens_add($_SESSION['user_login'], $album_tokens);
    }
    // 2) Initializing the ACLs
    acl_init($login);
    // 3) Logging the login operation
    log_append("anonymous user logged in");
    // lvl, action, browser_name, browser_version, user_os, browser_full_info
    $lvl = $_SESSION['album'] != '' && $_SESSION['asset'] != '' ? 3 : ($_SESSION['album'] != '' ? 2 : 1);
    trace_append(array($lvl, "login_from_anonymous", $_SESSION['browser_name'], $_SESSION['browser_version'], $_SESSION['user_os'], $_SESSION['browser_full'], session_id()));
    if (count($input) > 0) {
        $ezplayer_url .= '/index.php?';
    }
    foreach ($input as $key => $value) {
        $ezplayer_url .= "{$key}={$value}&";
    }
    // 4) Displaying the previous page
    header("Location: " . $ezplayer_url);
    load_page();
}
示例#3
0
 * This file is meant to provide media and RSS feeds to students
 * @param action rss|media
 */
/**
 * @package ezcast.ezmanager.distribute
 */
require_once 'config.inc';
require_once 'lib_ezmam.php';
require_once 'lib_error.php';
require_once '../commons/lib_template.php';
require_once 'lib_various.php';
require_once 'external_products/rangeDownload.php';
//
// Inits
//
ezmam_repository_path($repository_path);
ezmam_video_distribution_url($ezmanager_url . 'distribute.php');
//template_load_dictionnary('translations.xml');
$input = array_merge($_GET, $_POST);
//
// Page logic goes here
//
switch ($input['action']) {
    // The user wants to grab the RSS feed
    case 'rss':
        if (!isset($input['album']) || !isset($input['quality']) || !isset($input['token'])) {
            echo 'Usage: view.php?action=rss&album=ALBUM&quality=QUALITY&token=TOKEN';
            die;
        }
        view_rss();
        break;
示例#4
0
/**
 * Deletes the file that contains the bookmarks
 * @param type $album the album containing bookmarks
 * @return boolean true if the file has been deleted; false otherwise
 */
function toc_album_bookmarks_delete_all($album)
{
    // Sanity check
    if (!ezmam_album_exists($album)) {
        return false;
    }
    // 1) set the repository path
    $toc_path = ezmam_repository_path();
    if ($toc_path === false) {
        return false;
    }
    // set user's file path
    $toc_path = $toc_path . '/' . $album;
    unlink($toc_path . "/_bookmarks.xml");
    return true;
}
示例#5
0
/**
 * Displays the popup with the ulb code to copypaste
 * @global type $input
 * @global type $repository_path
 * @global type $url 
 */
function popup_ulb_code()
{
    global $input;
    global $repository_path;
    $asset_name = $input['asset'];
    ezmam_repository_path($repository_path);
    template_load_dictionnary('translations.xml');
    //
    // Sanity checks
    //
    if (!isset($input['album']) || !isset($input['asset']) || !isset($input['media'])) {
        echo 'Usage: index.php?action=show_popup&popup=ulb_code&album=ALBUM&asset=ASSET&media=MEDIA';
        die;
    }
    if (!ezmam_album_exists($input['album']) || !ezmam_asset_exists($input['album'], $input['asset'])) {
        error_print_message(ezmam_last_error());
        die;
    }
    $ulb_code = get_code_to_media($input['album'], $input['asset'], $input['media']);
    // Displaying the popup
    require_once template_getpath('popup_ulb_code.php');
}
示例#6
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);
    }
}
示例#7
0
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This software 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
require_once 'lib_ezmam.php';
// Set to true to see changes step by step; false for all tests at once
$step_by_step = false;
ezmam_repository_path('/path/to/test/repository');
//
// Creating albums for our tests
//
if ($step_by_step) {
    echo 'Step by step mode enabled. Press enter between each test to continue.';
}
if ($step_by_step) {
    echo 'Creating album COURSE-MNEMO';
}
$metadata = array('name' => 'COURSE-MNEMO-priv', 'description' => 'RSS Feed test', 'date' => '2011-07-26', 'anac' => '2011-2012');
ezmam_album_new("COURSE-MNEMO-priv", $metadata);
if ($step_by_step) {
    exec('read');
}
if ($step_by_step) {
示例#8
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;
}
示例#9
0
function acl_update_watched_assets()
{
    global $repository_path;
    global $user_files_path;
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    $watched_assets = array();
    if (acl_user_is_logged()) {
        $album_tokens_list = acl_album_tokens_get();
        foreach ($album_tokens_list as $album_token) {
            $global_count[$album_token['album']] = ezmam_asset_count($album_token['album']);
        }
        $watched_assets = user_prefs_watchedlist_get($_SESSION['user_login'], false);
        $_SESSION['acl_global_count'] = $global_count;
    }
    $_SESSION['acl_watched_assets'] = $watched_assets;
}