Example #1
0
<?php

/**
 * This is a Branax pagecontroller.
 *
 */
// Include the essential config-file which also creates the $branax variable with its defaults.
include __DIR__ . '/config.php';
// Create the user object
$user = new CUser($branax['database']);
// Check if user is authenticated
$output = $user->isAuthenticated() ? "Du är inloggad som: {$user->getAcronym()} ({$user->getName()})" : "Du är INTE inloggad.";
// Logout the user
if (isset($_POST['logout'])) {
    $user->logout();
    header('Location: user_status.php');
}
// Do it and store it all in variables in the Anax container.
$branax['title'] = "Logout";
$branax['main'] = <<<EOD
<h1>{$branax['title']}</h1>
<form method=post>
  <fieldset>
  <legend>Logout</legend>
  <p><input type='submit' name='logout' value='Logout'/></p>
  <p><a href='user_login.php'>Login</a></p>
  <output><b>{$output}</b></output>
  </fieldset>
</form>

EOD;
Example #2
0
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
require_once 'include/config.inc.php';
require_once 'include/forms.inc.php';
define('ZBX_NOT_ALLOW_ALL_NODES', 1);
define('ZBX_HIDE_NODE_SELECTION', 1);
$page['title'] = 'S_ZABBIX_BIG';
$page['file'] = 'index.php';
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('name' => array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, 'isset({enter})', S_LOGIN_NAME), 'password' => array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({enter})'), 'sessionid' => array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), 'message' => array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), 'reconnect' => array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0, 65535), NULL), 'enter' => array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'form_refresh' => array(T_ZBX_INT, O_OPT, NULL, NULL, NULL), 'request' => array(T_ZBX_STR, O_OPT, NULL, NULL, NULL));
check_fields($fields);
$sessionid = get_cookie('zbx_sessionid', null);
if (isset($_REQUEST['reconnect']) && isset($sessionid)) {
    add_audit(AUDIT_ACTION_LOGOUT, AUDIT_RESOURCE_USER, 'Manual Logout');
    CUser::logout($sessionid);
    jsRedirect('index.php');
    exit;
}
$config = select_config();
$authentication_type = $config['authentication_type'];
if ($authentication_type == ZBX_AUTH_HTTP) {
    if (isset($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_USER'])) {
        if (!isset($sessionid)) {
            $_REQUEST['enter'] = 'Enter';
        }
        $_REQUEST['name'] = $_SERVER['PHP_AUTH_USER'];
        $_REQUEST['password'] = '******';
        //$_SERVER['PHP_AUTH_PW'];
    } else {
        access_deny();