<?php

/**
 * 访问控制
 */
class Amfphp_BackOffice_AccessManager {

    /**
     * the field in the session where the roles array is stored
     */
    const SESSION_FIELD_ROLES = '91bfa85e5204b5806d536a098caacd31'; // 用户名: gwang
    const AMFPHP_ADMIN_ROLE = 'a08dd655a04c8c4cd541c92c6d5d1350';   // 密码:   wanggang

    /**
     * checks if access should be granted, either because no sign in is required, or because the user is actually signed in.
     * note: must be called before output starts, as starting a session can change headers on some configs.
     */

    public function isAccessGranted() {
        if (session_id() == '') {
            session_start();
        }
        if (!isset($_SESSION[self::SESSION_FIELD_ROLES])) {
            return false;
        }
        return isset($_SESSION[self::SESSION_FIELD_ROLES][self::AMFPHP_ADMIN_ROLE]);
    }

}
