<?
/******************************************************************************/
/* MODUL: install/install_2.php4 */
/* */
/* DATUM: 27.03.2006, Version 0.1 */
/* BESCHR.: Benutzer hinzufuegen oder Rechte modifizieren */
/* */
/* AUTOR: Marcus Groh */
/* LIZENZ: GPL v2 vom Juni 1991 */
/* */
/* AENDERUNGEN: 12.06.2004 -initiale Version */
/* 21.07.2005, -Komplett neu strukturiert und */
/* schrittweise aufgebaut */
/* 27.03.2006 v 0.1, -Versionskennzeichnung eingefuehrt */
/* -Code unter GPL v2 gestellt */
/* */
/******************************************************************************/
include ('./header.php4');
include "../config/conf_glbl.php4";
// Some default-values
$error_msg=" ";
$submit_text="Anlegen";
$disabled="";
$canwrite="";
$canread="checked";
$db_action=1;
if (! isset($uname)) { $uname=""; }
if (! isset($dbuid)) { $dbuid=""; }
// Prepare form with dataset to modify
if (isset($mod))
{
$select_users="select * from $T_user where uid=$dbuid";
$result_users=@mysql_db_query($database["database"],$select_users,$db);
$row=mysql_fetch_array($result_users);
$uname=$row['u_name'];
if ( $row['w_rights'] == "Y" )
{
$canwrite="checked";
$canread="";
}
$submit_text="Ändern";
$disabled="disabled";
}
if (! isset($mod)) { $mod=""; }
// retrieve values from form, check them and modify database
if (isset($crt_user))
{
// Check length of username
if ( strlen($uname) == 0)
{
$error_msg="Keinen Benutzernamen angegeben";
$db_action=0;
}
// check if passwords are the same
if ( $upwd1 != $upwd2 )
{
$error_msg="Passwörter waren nicht identisch.";
$db_action=0;
}
// password-fields can be blank if we modify an existing dataset
if ( ( (strlen($upwd1) == 0) || (strlen($upwd2) == 0) ) && (!$mod) )
{
$error_msg="Leere Passwörter sind nicht erlaubt.";
$db_action=0;
}
// check if password and username are the same
if ( ($upwd1 == $uname) || ($upwd2 == $uname) )
{
$error_msg="Name und Passwort dürfen nicht identisch sein.";
$db_action=0;
}
// ok, enough checks. Get kind of access (read/write)
if ( $rwacc == "WR" )
{
$r_rights="Y";
$w_rights="Y";
}
else
{
$r_rights="Y";
$w_rights="N";
}
if ($db_action)
{
// crypt passwords
$newpass=crypt($upwd1,"webetb");
// Check wheter we have to store new values or only upadte existing
if ($mod)
{
// Check if also password should be modified
if ( strlen($upwd1) == 0 )
{
$update_user="Update $T_user set u_name='$uname',r_rights='$r_rights',w_rights='$w_rights', einheit='$frm_grp' where uid=$dbuid";
}
else
{
$update_user="Update $T_user set u_name='$uname',u_pwd='$newpass',r_rights='$r_rights',w_rights='$w_rights',einheit='$frm_grp' where uid=$dbuid";
}
mysql_db_query($database["database"],$update_user,$db);
}
else
{
// Check if username exists allready
$select_uid="select uid from $T_user where u_name like '$uname'";
$result_uid=@mysql_db_query($database["database"],$select_uid,$db);
if ( mysql_num_rows($result_uid) == 0)
{
$create_user="Insert into $T_user values ('%','$uname','$newpass','$r_rights','$w_rights','$frm_grp')";
mysql_db_query($database["database"],$create_user,$db);
}
else
{
$error_msg="Der Benutzer existiert bereits.";
}
}
$db_action=0;
}
// Reset-Form-values
$mod="";
$crt_user="";
$uname="";
}
?>
<script language="JavaScript">
<!--
function reloader()
{
window.location.href='./install_2.php4';
}
//-->
</script>
<br>
<center>
<p id="ERR"><? echo $error_msg; ?></p>
<form action="" name="user_data" method="post">
<table border="0" cellspacing="0" cellpadding="0" width="450">
<tr>
<th colspan="5">web-ETB Benutzerverwaltung</th>
</tr>
<tr>
<td colspan="5" height="3"></td>
</tr>
<tr>
<td width="120">Benutzername</td>
<td width="5"> </td>
<td width="120"><input type=text <? echo $disabled; ?> name="uname" value="<? echo $uname; ?>" style="border: 1px solid silver; width: 100px"></td>
<td width="5"> </td>
<td width="200" ><select name="frm_grp" size=1 style="width: 200px; border-width: 1px solid silver;">
<option value="reg">Registratur
<option selected value="elw">SEG-ELW
<option value="sons">Sonstige
<option value="trans">Transport
<option value="san">Verbandsplatz</td>
</tr>
<tr>
<td colspan="4" height="5"></td>
</tr>
<tr>
<td width="120">Passwort</td>
<td width="5"> </td>
<td width="120"><input type=password name="upwd1" style="border: 1px solid silver; width: 100px"></td>
<td width="5"> </td>
<td width="200" rowspan="4"><input type="radio" name="rwacc" <? echo $canread; ?> value="RD">Nur Lesezugriff<br>
<input type="radio" name="rwacc" <? echo $canwrite; ?> value="WR">Schreib- und Lesezugriff</td>
</tr>
<tr>
<td colspan="4" height="5"></td>
</tr>
<tr>
<td width="120">Passwort wiederh.</td>
<td width="5"> </td>
<td width="120"><input type=password name="upwd2" style="border: 1px solid silver; width: 100px"></td>
<td > </td>
</tr>
</table>
<input type="submit" Value="<? echo $submit_text; ?>" style="border: 1px solid silver;">
<input type="reset" Value="Rücksetzen" onClick="reloader();" style="border: 1px solid silver;">
<input type="hidden" name="crt_user" value="true">
</form>
<br>
<table border="0" cellspacing="0" cellpadding="0" width="500">
<tr>
<th colspan="6">Bereits erstellte Benutzeraccounts</th>
</tr>
<tr>
<td width="25" align="middle"><p id="GR07">ID</p></td>
<td width="225"><p id="GR07">Benutzername</p></td>
<td width="100"><p id="GR07">Einheit</p></td>
<td width="50" align="middle"><p id="GR07">Read</p></td>
<td width="50" align="middle"><p id="GR07">Write</p></td>
<td width="50" align="middle"><p id="GR07"> </p></td>
</tr>
<tr>
<td colspan="6" height="1" width="500" style="background-color: #000000;"><img src="../_img/spacer.gif" height="1" width="500" border="0"></td>
</tr>
<?
// Bereits definierte Benutzer auflisten
$select_users="select * from $T_user order by u_name";
$result_users=@mysql_db_query($database["database"],$select_users,$db);
$anzahl_users=mysql_num_rows($result_users);
if ( $anzahl_users <= 0 )
{
echo "<tr>\n<td colspan=\"6\">Noch keine Benutzer definiert.</td>\n</tr>\n";
}
else
{
while ( $row=mysql_fetch_array($result_users) )
{
$db_read="-";
$db_write="-";
if ( $row['r_rights'] == "Y" )
{
$db_read="+"; }
if ( $row['w_rights'] == "Y" )
{
$db_write="+"; }
echo "<tr>\n";
echo "<td align=\"middle\"><p id=\"sw10_s\">$row[uid]</p></td>\n";
echo "<td><p id=\"sw10_s\">$row[u_name]</p></td>\n";
switch ( $row['einheit'] )
{
case 'reg': $GRUPPE="Registratur";
break;
case 'elw': $GRUPPE="SEG-ELW";
break;
case 'trans': $GRUPPE="Transport";
break;
case 'san': $GRUPPE="Verbandsplatz";
break;
case 'sons': $GRUPPE="Sonstige";
break;
}
echo "<td><p id=\"sw10_s\">$GRUPPE</p></td>\n";
echo "<td align=\"middle\"><p id=\"sw10_s\">$db_read</p></td>\n";
echo "<td align=\"middle\"><p id=\"sw10_s\">$db_write</p></td>\n";
echo "<td align=\"middle\"><a href=\"?mod=true&dbuid=$row[uid]\" onFocus=blur(); style=\"text-decoration: none;\"><img src=\"../_img/props.png\" border=\"0\" title=\"Ändern\"></a></td>\n";
echo "</tr>\n";
echo "<tr>";
echo "<td colspan=\"6\" height=\"1\" width=\"500\" style=\"background-color: #999999;\"><img src=\"../_img/spacer.gif\" height=\"1\" width=\"500\" border=\"0\"></td>\n";
echo "</tr>";
}
}
?>
</table>
</center>
<?
include ('./footer.php4');
?>