<?php
require_once "PrivateConfig.inc.php";
function displayLinkLogOut($confirm = false) {
if ($confirm) {
$linkVis = XP_INVISIBLE;
$confirmVis = XP_VISIBLE;
} else {
$linkVis = XP_VISIBLE;
$confirmVis = XP_INVISIBLE;
}
// Visible : "logout" link
displayVisibleInvisibleSectionStart($linkVis, "linkLogout");
displayDivStart("intro");
?>
<?=getJavascriptLink("reset", getLang("logout"), visibleInvisible(array("confirmLogout", "linkLogout")), "")?>
<?php
displayDivEnd(); // intro
displayVisibleInvisibleSectionEnd($linkVis, "linkLogout");
// Invisible : confirmation ("ok" / "cancel")
displayVisibleInvisibleSectionStart($confirmVis, "confirmLogout");
?>
<table class="loginForm" align="center">
<tr><td>
<?=getLang("confirm_logout")?><br/><br/>
<?php
displayDivStart("okCancel");
?>
<?=getJavascriptLink("cancel", getLang("cancel"), visibleInvisible(array("linkLogout","confirmLogout")), "")?>
<?php
lib_login_show_logout_link(getLang("logout"), "reset");
displayDivEnd();
?>
</td></tr>
</table>
<?php
displayVisibleInvisibleSectionEnd($confirmVis, "confirmLogout");
}
function displayTopLoginLink($pbError, $psErrorText) {
if ($pbError) {
echoSpan("errorLogin",$psErrorText." ");
}
if (!isset($GLOBALS["gConnectedUser"]) || $GLOBALS["gConnectedUser"]->isAnonymous || $pbError) {
echo getLink("logInLink","[".getLangNbsp("log_in")."]",$GLOBALS["gCurrentPath"]."Login.php", "_top");
} else {
// Someone is logged in
echo getLink("logOutLink",
forceNbSpaces($GLOBALS["gConnectedUser"]->name)." ",
$GLOBALS["gCurrentPath"]."Login.php?confirm=1", "_top", getLangNbsp("logout"));
}
}
function displayFormLogin($error) {
global $gMembers;
global $LIB_LOGIN_BASEDIR;
global $gString;
// Used by "old visibility mode"
if (!isset($extraValue)) {
if (isset($_POST["extraValue"])) {
$extraValue = $_POST["extraValue"];
$newLogin = $extraValue;
} else {
$newLogin = @$_POST["userSelect"];
}
}
if (isset($_POST["extraValue"])) {
$extraValue = $_POST["extraValue"];
$newLogin = $extraValue;
} else {
$newLogin = @$_POST["userSelect"];
}
// From lib_login
if($error=="timeout") {
$errorText = $gString[17];
}
if($error=="invalid"){
$errorText = $gString[18];
}
if($error=="punished"){
$errorText = $gString[83];
}
if (XP_LOGIN_LIST_USERS) {
$form_target = $LIB_LOGIN_BASEDIR . "confirm_login.php";
} else {
// If we don't list users, we'll have call the page one more time...
$form_target = "Login.php";
}
if (isSet($errorText)) {
echoSpan("error",$errorText."<br/><br/>");
}
$formName = "loginForm";
displaySimpleFormStart($formName, $form_target, "submitLoginForm();");
//displaySimpleFormStart($formName, $form_target, "alert('test');");
?>
<input type="hidden" name="username" value="<?=XP_FORBIDDEN_ID?>"/>
<table border="0" cellpadding="5" cellspacing="5" class="loginForm" align="center">
<tr>
<td valign="top" width="200" rowspan="4"> </td>
<td><?=getLang("loginUser")?></td>
<td valign="top"><select onchange="checkSelect(this);<?=changeLoginInForm()?>" name="userSelect">
<?php
if (XP_LOGIN_LIST_USERS) {
?>
<option value="<?=XP_FORBIDDEN_ID2?>"><?=getLang("select_user")?></option>
<option value="<?=XP_FORBIDDEN_ID3?>" disabled="disabled"> </option>
<?php
$i = 0;
if (!is_array($gMembers)) {
$gMembers = array();
}
reset($gMembers);
while (list($id,$name) = each($gMembers)) {
echo "<option value=\"$id\"";
if ($newLogin==$id) {
echo " selected=\"selected\"";
}
echo ">".$name."</option>\r\n";
$i++;
}
} else {
?>
<option value="textUser" <?=($newLogin!="admin")?" selected=\"selected\"":""?>><?=getLang("user")?></option>
<?php
}
?>
<option value="<?=XP_FORBIDDEN_ID4?>" disabled="disabled"> </option>
<option value="admin" <?=($newLogin=="admin")?" selected=\"selected\"":""?>><?=getLang("admin_user")?></option>
</select>
</td>
<?php
// The textUsername is visible if:
// - admin attempt to log in
// - users are not listed
$lsVisib = (!XP_LOGIN_LIST_USERS || ($newLogin=="admin"))
?XP_VISIBLE:XP_INVISIBLE;
?>
<td valign="top" width="200" rowspan="3"><?php
displayVisibleInvisibleSectionStart($lsVisib, "textLogin", "span");
?>
<input type="text" name="textUsername"/>
<?php
displayVisibleInvisibleSectionEnd($lsVisib, "textLogin", "span");
?></td>
</tr>
<tr>
<td><?=getLang("password")?></td>
<td valign="top">
<input type="password" name="password" onkeypress="formKeyPress(this.form.name);"/>
</td>
</tr>
<tr>
<td> </td>
<td valign="top">
<?php
$autoLogId = "autoLog";
?>
<input id="<?=$autoLogId?>" type="checkbox" name="auto_login" value="ON"/>
<label for="<?=$autoLogId?>"><?=getLang("remember_me")?></label>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<!--
<a class="ok" href="javascript:submitLoginForm();document.forms['loginForm'].submit();" target="_top"><?=getLang("log_in")?></a>
-->
<?=getJavascriptLink("ok", getLang("log_in"), "sub('$formName');", "")?>
</td>
</tr>
</table>
<?php
displaySimpleFormEnd($formName);
}
function displayTimeOut() {
displayDivStart("intro");
displayDivStart("bigError");
echoLang("timeout");
echo "<br/>";
displayDivEnd();
displayDivStart("error");
echoLang("timeout_desc");
echo "<br/>";
displayDivEnd();
displayDivEnd();
displayOkWindowLink();
}
function displayTimeOutWarning() {
displayDivStart("intro");
displayDivStart("bigError");
echoLang("warning");
echo "<br/>";
displayDivEnd();
echoLang("warning_desc_1");
echo "<br/>";
echoLang("warning_desc_2");
echo "<br/>";
displayDivEnd();
displayOkWindowLink();
}
class UserView extends User {
function displayLoginResult() {
$logged = !$this->isAnonymous;
if ($logged) {
displayDivStart("loginMsg");
echo getLang("user")." ".$this->name." ".getLang("success_log_in");
displayDivEnd();
displayLinkLogOut();
} else {
echo "Unexpected error: Login failed";
}
}
function displayLogoutResult() {
$logged = !$this->isAnonymous;
if (!$logged) {
echoLang("success_log_out");
echo "<br/><br/>";
echo getLink("",getLang("login_again"),"Login.php");
}
}
function getCurrentUser() {
return User::getCurrentUser(true);
}
function displayAllowedOrNot($content, $contentTitle = "", $html = true) {
if ($this->isAllowedToDisplaySection($content)) {
return true;
} else {
if ($GLOBALS["gDb"]->status == $GLOBALS["gDb"]->CONNECTION_OK && $GLOBALS["gDb"]->version > 2) {
$txt = $this->getErrorMsg($contentTitle);
if ($html) {
displayDivStart("error");
echo $txt;
echo "<br/><br/>";
echoLang("access_section_or_project");
echo "<br/><br/>";
echoLang("try_diff_login");
displayDivEnd();
} else {
displayXMLError("not allowed");
}
}
return false;
}
}
function getErrorMsg($contentTitle = "") {
if ($contentTitle == "") {
$txt = getLang("not_allowed_this_section");
} else {
$txt = getLang("not_allowed_some_section")." \"".getSectionLang($contentTitle)."\"";
}
return $txt;
}
}
?>