Beispiel #1
0
/**
 * Renders an "access denied" message and stops the execution of the script.
 *
 * The $mode parameters controls the layout of the message:
 * - ACCESS_DENY_OBJECT     - render the message when denying access to a specific object
 * - ACCESS_DENY_PAGE       - render a complete access denied page
 *
 * @param int $mode
 */
function access_deny($mode = ACCESS_DENY_OBJECT)
{
    // deny access to an object
    if ($mode == ACCESS_DENY_OBJECT) {
        require_once dirname(__FILE__) . '/page_header.php';
        show_error_message(_('No permissions to referred object or it does not exist!'));
        require_once dirname(__FILE__) . '/page_footer.php';
    } else {
        // url to redirect the user to after he loggs in
        $url = new CUrl(!empty($_REQUEST['request']) ? $_REQUEST['request'] : '');
        $url->setArgument('sid', null);
        $url = urlencode($url->toString());
        // if the user is logged in - render the access denied message
        if (CWebUser::isLoggedIn()) {
            $header = _('Access denied.');
            $message = array(_('Your are logged in as'), ' ', bold(CWebUser::$data['alias']), '. ', _('You have no permissions to access this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.'));
            $buttons = array();
            // display the login button only for guest users
            if (CWebUser::isGuest()) {
                $buttons[] = new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist');
            }
            $buttons[] = new CButton('back', _('Go to dashboard'), 'javascript: document.location = "dashboard.php"', 'formlist');
        } else {
            $header = _('You are not logged in.');
            $message = array(_('You must login to view this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.'));
            $buttons = array(new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist'));
        }
        $warning = new CWarning($header, $message);
        $warning->setButtons($buttons);
        $warningView = new CView('general.warning', array('warning' => $warning));
        $warningView->render();
        exit;
    }
}
function access_deny()
{
    require_once dirname(__FILE__) . '/page_header.php';
    if (CWebUser::$data['alias'] != ZBX_GUEST_USER) {
        show_error_message(_('No permissions to referred object or it does not exist!'));
    } else {
        $url = new CUrl(!empty($_REQUEST['request']) ? $_REQUEST['request'] : '');
        $url->setArgument('sid', null);
        $url = urlencode($url->toString());
        $warning = new CWarning(_('You are not logged in.'), array(_('You cannot view this URL as a'), SPACE, bold(ZBX_GUEST_USER), '. ', _('You must login to view this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.')));
        $warning->setButtons(array(new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist'), new CButton('back', _('Cancel'), 'javascript: window.history.back();', 'formlist')));
        $warning->show();
    }
    require_once dirname(__FILE__) . '/page_footer.php';
}
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
$pageHeader = new CPageHeader(_('Warning') . ' [' . _s('refreshed every %1$s sec.', 30) . ']');
$pageHeader->addCssInit();
$pageHeader->display();
?>
<body>
<?php 
// check if a CWarning object is passed
if (!($warning = $this->get('warning'))) {
    $message = $this->get('message');
    if (is_array($message) && isset($message['header'])) {
        $message = array(bold($message['header']), BR(), $message['text']);
    }
    // if not - render a standard warning with a message
    $warning = new CWarning('Zabbix ' . ZABBIX_VERSION, $message);
    $warning->setButtons(array(new CButton('login', _('Retry'), 'document.location.reload();', 'formlist')));
}
$warning->show();
?>
<script type="text/javascript">
	setTimeout('document.location.reload();', 30000);
</script>

</body>
</html>
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
require_once dirname(__FILE__) . '/include/config.inc.php';
$page['title'] = _('Warning');
$page['file'] = 'warning.php';
define('ZBX_PAGE_DO_REFRESH', 1);
if (!defined('PAGE_HEADER_LOADED') && !defined('ZBX_PAGE_NO_MENU')) {
    define('ZBX_PAGE_NO_MENU', 1);
}
$refresh_rate = 30;
// seconds
// VAR	TYPE	OPTIONAL	FLAGS	VALIDATION	EXCEPTION
$fields = array('warning_msg' => array(T_ZBX_STR, O_OPT, null, null, null), 'message' => array(T_ZBX_STR, O_OPT, null, null, null), 'retry' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null));
check_fields($fields, false);
if (isset($_REQUEST['cancel'])) {
    zbx_unsetcookie('ZBX_CONFIG');
    redirect('index.php');
}
CWebUser::$data['refresh'] = $refresh_rate;
require_once dirname(__FILE__) . '/include/page_header.php';
unset($USER_DETAILS);
$msg = isset($_REQUEST['warning_msg']) ? $_REQUEST['warning_msg'] : _('Zabbix is temporarily unavailable!');
$warning = new CWarning(_('Zabbix') . SPACE . ZABBIX_VERSION, $msg);
$warning->setAlignment('center');
$warning->setAttribute('style', 'margin-top: 100px;');
$warning->setPaddings(SPACE);
$warning->setButtons(new CButton('retry', _('Retry'), 'javascript: location.replace(location.href);', 'formlist'));
$warning->show();
zbx_add_post_js('setTimeout("location.replace(location.href);", ' . $refresh_rate * 1000 . ');');
echo SBR;
require_once dirname(__FILE__) . '/include/page_footer.php';