Example #1
0
 /**
  * PEAR::Authのインスタンスを生成する
  *
  * @param bool $login ログイン処理に使用するかどうか
  * @return Auth
  */
 function &factory($login = false)
 {
     @session_start();
     if ($login) {
         $auth = new Auth($this->storage, $this->options, '', false);
         $auth->setAllowLogin(true);
     } else {
         $auth = new Auth('null');
         $auth->setAllowLogin(false);
     }
     $auth->setExpire($this->expire);
     $auth->setIdle($this->idle);
     return $auth;
 }
            break;
        case -5:
            $errro = "Security Issue. Please login again";
            break;
        default:
            $error = "Authentication Issue. Please report to Admin";
    }
    if (isset($error)) {
        $templateEngine->assign("error", $error);
    }
    $templateEngine->displayPage('usermin_login.tpl');
    exit;
}
$DatabaseConnections = new DatabaseConnections();
$Usermin = new DatabaseUsermin($DatabaseConnections->getRadiusDB());
$options = array('cryptType' => 'none', 'users' => $Usermin->getUsers());
$Auth = new Auth("Array", $options, "loginForm");
$Auth->setSessionName("GRASE Usermin");
$Auth->setAdvancedSecurity(array(AUTH_ADV_USERAGENT => true, AUTH_ADV_IPCHECK => true, AUTH_ADV_CHALLENGE => false));
$Auth->setIdle(120);
$Auth->start();
if (!$Auth->checkAuth()) {
    echo "Should never get here";
    // THIS CODE SHOULD NEVER RUN
    exit;
} elseif (isset($_GET['logoff'])) {
    $Auth->logout();
    $Auth->start();
} else {
    $templateEngine->assign("LoggedInUsername", $Auth->getUsername());
}
            break;
        default:
            $error = T_("Authentication Issue. Please report to Admin");
            AdminLog::getInstance()->log("Auth Issues: {$status}");
    }
    if (isset($error)) {
        $templateEngine->assign("error", $error);
    }
    $templateEngine->displayPage('loginform.tpl');
    exit;
}
$DatabaseConnections = new DatabaseConnections();
$options = array('dsn' => $DatabaseConnections->getRadminDSN(), 'cryptType' => 'sha1salt', 'sessionName' => 'GRASE Radius Admin For Internet', 'db_fields' => array('accesslevel'));
$Auth = new Auth("MDB2_Salt", $options, "loginForm");
$Auth->setAdvancedSecurity(array(AUTH_ADV_USERAGENT => true, AUTH_ADV_IPCHECK => true, AUTH_ADV_CHALLENGE => false));
$Auth->setIdle(600);
$AdminLog =& AdminLog::getInstance($DatabaseConnections->getRadminDB(), $Auth);
if ($Auth->listUsers() == array()) {
    $templateEngine->assign("error", array(T_("No users defined in database. Please check your install")));
    $templateEngine->displayPage('loginform.tpl');
    exit;
}
$Auth->start();
if (!$Auth->checkAuth()) {
    echo "Should never get here";
    // THIS CODE SHOULD NEVER RUN
    exit;
} elseif (isset($_GET['logoff'])) {
    AdminLog::getInstance()->log("Log out");
    $Auth->logout();
    $Auth->start();