Location: PHPKode > projects > NewsP > admin/eintragen.inc.php
<?php include("auth.php");
session_start();
$username = $_SESSION['username'];
if($username == 'Admin')
{
unset($user_del);
unset($neu);
unset($edited);
$neu = $HTTP_POST_VARS["neu"];
$user_del = $HTTP_POST_VARS["user_del"];
$email = $HTTP_POST_VARS["email"];
$r1 = $HTTP_POST_VARS["r1"];
$r2 = $HTTP_POST_VARS["r2"];
$r3 = $HTTP_POST_VARS["r3"];
$r4 = $HTTP_POST_VARS["r4"];
$edited = $HTTP_POST_VARS["edited"];
	if (isset($edited))
	{
	$password_e = $HTTP_POST_VARS["passwort_e"];
	$password2_e = $HTTP_POST_VARS["passwort2_e"];
	$email_e = $HTTP_POST_VARS["email_e"];
		if (!empty($password_e))
		{
			if ($password_e == $password2_e){
			$new_pass = md5($password_e);
			}else{
			echo"<p style=\"background-color:#FFFF00\"><B>$lg[us014]</B></p>";
			}
		}

	}

if ($neu == 'ja'){
$username_n = $HTTP_POST_VARS["username"];
include("make_pass.php");
   $user_vorhanden = array();
   $passwort = md5($k_passwort);

   $userdatei = fopen ("user.txt","r");
   while (!feof($userdatei))
      {
      $zeile = fgets($userdatei,500);
      $userdata = explode("|", $zeile);
      array_push ($user_vorhanden,$userdata[0]);
      }
   fclose($userdatei);
   if (in_array($username_n,$user_vorhanden))
      {
      echo "<p style=\"background-color:#FFFF00\"><B>$username_n: $lg[us022] <a href=\"index.php?p=eintragen\">&lt;&lt;&lt; $lg[us016] &lt;&lt;&lt;</a> !!!</B></p>";
      }
   else
      {
      $userdatei = fopen ("user.txt","a");
      fwrite($userdatei, $username_n);
      fwrite($userdatei, "|");
      fwrite($userdatei, $passwort);
      fwrite($userdatei, "|");
      fwrite($userdatei, $r1);
      fwrite($userdatei, "|");
      fwrite($userdatei, $r2);
      fwrite($userdatei, "|");
      fwrite($userdatei, $r3);
      fwrite($userdatei, "|");
      fwrite($userdatei, $r4);
      fwrite($userdatei, "|");
      fwrite($userdatei, $email);
      fwrite($userdatei, "\n");
      fclose($userdatei);
      echo "<p style=\"background-color:#00FF00\"><B>$lg[us003] $username_n, $lg[us015]</B></p>";

$empfaenger = "$email";
$us018 = html_entity_decode($lg[us018]);
$us019 = html_entity_decode($lg[us019]);
$us020 = html_entity_decode($lg[us020]);

$betreff = "User account for $www$teil_link";
$from = "From: $www <$domains[mail]>";
$text = "$us018\nhttp://$www$teil_link/admin/\n\n$us019\n\n$lg[us003] $username_n\n$lg[us004] $k_passwort\n\n$us020\n\nRegards PHP-NewsGerd";
mail($empfaenger, $betreff, $text, $from);
      }


}else{
### D ###
if ((!empty($user_del)) && $neu !== 'ja'){
echo "<p style=\"background-color:#00FF00\">$lg[us003] <B>$user_del</B> $lg[ml_del2] !!!</P>";
 $userdatei = fopen ("user.txt","r");
   while (!feof($userdatei))
      {	$zeile = fgets($userdatei,500);
	$userdata = explode("|", $zeile);
	$uu_user=$userdata[0];
			if ($uu_user !== $user_del)
			{
			$user_stay[$uu_user][USER] = "$uu_user";
			$user_stay[$uu_user][PW] = "$userdata[1]";
			$user_stay[$uu_user][R1] = "$userdata[2]";
			$user_stay[$uu_user][R2] = "$userdata[3]";
			$user_stay[$uu_user][R3] = "$userdata[4]";
			$user_stay[$uu_user][R4] = "$userdata[5]";
			$user_stay[$uu_user][MAIL] = "$userdata[6]";
			}
      }   
fclose($userdatei);
$userdatei = fopen ("user.txt","w");
			foreach ($user_stay as $person)
			{
if($person[PW] !==""){
			fwrite($userdatei, $person[USER]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[PW]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[R1]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[R2]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[R3]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[R4]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[MAIL]);
			}}
			fclose($userdatei);
}
### E ###
if ((!empty($edited)) && $neu !== 'ja'){
 $userdatei = fopen ("user.txt","r");
   while (!feof($userdatei))
      {	$zeile = fgets($userdatei,500);
	$userdata = explode("|", $zeile);
	$uu_user=$userdata[0];
			if ($uu_user !== "$edited")
			{
			$user_stay[$uu_user][USER] = "$uu_user";
			$user_stay[$uu_user][PW] = "$userdata[1]";
			$user_stay[$uu_user][R1] = "$userdata[2]";
			$user_stay[$uu_user][R2] = "$userdata[3]";
			$user_stay[$uu_user][R3] = "$userdata[4]";
			$user_stay[$uu_user][R4] = "$userdata[5]";
			$user_stay[$uu_user][MAIL] = "$userdata[6]";
			}else{
			$user_stay[$uu_user][USER] = "$uu_user";
				if (!empty($new_pass))
					{
					$user_stay[$uu_user][PW] = "$new_pass";
					}else{
					$user_stay[$uu_user][PW] = "$userdata[1]";
					}
			$user_stay[$uu_user][R1] = "$r1";
			$user_stay[$uu_user][R2] = "$r2";
			$user_stay[$uu_user][R3] = "$r3";
			$user_stay[$uu_user][R4] = "$r4";
			$user_stay[$uu_user][MAIL] = "$email_e";
}
      }   
fclose($userdatei);
$userdatei = fopen ("user.txt","w");
			foreach ($user_stay as $person)
			{
if($person[PW] !==""){
			fwrite($userdatei, $person[USER]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[PW]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[R1]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[R2]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[R3]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[R4]);
			fwrite($userdatei, "|");
			fwrite($userdatei, $person[MAIL]);
if($edited == $person[USER])
{fwrite($userdatei, "\n");}
			}}
			fclose($userdatei);

					if($edited == 'Admin' && (!empty($email_e))){
					$m_set_file = "../settings/m_settings.txt";
					$zaehlfile = fopen("$m_set_file","r"); 
					$inhalt_zaehlfile = fgets($zaehlfile);  
					fclose($zaehlfile); 
					$set_in_dom = unserialize($inhalt_zaehlfile);
					
					$set_in_dom[mail] = "$email_e";
					
					$loglink = serialize($set_in_dom);
					$loglinkfile = "$m_set_file";
					$logger = fopen("$loglinkfile","w"); 
					fputs($logger, $loglink); 
					fclose($logger); 
					}
}

?>
<H2><? echo"$lg[us001]"; ?></H2>
<HR>
<? echo"<B>$lg[us002]</B><BR>"; 
echo"$lg[us021]<P>";?>
<form action="" method="post" name="form1">
<TABLE>
<TR>
	<TD><? echo"$lg[us003]"; ?><br>
<input type="text" size="22" maxlength="50" name="username" value=""></TD>
	<TD><? echo"$lg[us011]"; ?><br>
<input type="text" size="22" maxlength="50" name="email" value=""></TD>
</TR>
</TABLE><P>
<?
echo"<input type=\"checkbox\" name=\"r1\" value=\"1\">$lg[uk03]<BR>";
echo"<input type=\"checkbox\" name=\"r2\" value=\"1\">$lg[us013]<BR>";
echo"<input type=\"checkbox\" name=\"r3\" value=\"1\">$lg[uk02]<BR>";
echo"<input type=\"checkbox\" name=\"r4\" value=\"1\">$lg[uk01]<P>";
?>
<input type="hidden" name="neu" value="ja"><input type="submit" value="<? echo"$lg[us006]"; ?>">
</form>
<HR>
<B><? echo"$lg[us007]"; ?></B>
<?
;}
   $userdatei = fopen ("user.txt","r");
   while (!feof($userdatei))
      {	$zeile = fgets($userdatei,500);
	$userdada = explode("|", $zeile);
	$uda_user=$userdada[0];
	$user_there[$uda_user] = array('USER' =>"$userdada[0]", 'PW' =>"$userdada[1]", 'R1' => "$userdada[2]", 'R2' => "$userdada[3]", 'R3' => "$userdada[4]", 'R4' => "$userdada[5]", 'MAIL' => "$userdada[6]");
      }   
fclose($userdatei);
$fb=1;
echo"<TABLE cellspacing=\"0\" cellpadding=\"5\"><TR>";
echo"<TD class=td_lk$fb><B>$lg[us003]</B></TD>";
echo"<TD class=td_lk$fb><B>$lg[us011]</B></TD>";
echo"<TD class=td_lk$fb><B>$lg[us008]</B></TD>";
echo"<TD class=td_lk$fb><B>$lg[us005]</B></TD>";
echo"<TD class=td_lk$fb>$lg[uk03]</TD>";
echo"<TD class=td_lk$fb>$lg[us013]</TD>";
echo"<TD class=td_lk$fb>$lg[uk02]</TD>";
echo"<TD class=td_lk$fb>$lg[uk01]</TD>";
echo"<TD class=td_lk$fb>$lg[us009]</TD>";
echo"<TD class=td_lk$fb>DEL</TD></TR>";
$fb=2;

$keys_sort = (array_keys($user_there));
$keys_lowercase = array_map('strtolower', $keys_sort);
array_multisort($user_there, SORT_ASC, SORT_STRING, $keys_lowercase); 

foreach ($user_there as $user_da)
{
if($user_da[PW] !==""){
if ($fb > 2){$fb = 1;}
echo"<TR><TD class=td_lk$fb><B>$user_da[USER]</B>"; 
echo"</TD><TD class=td_lk$fb>";
$mail = $user_da[MAIL];
?>
<form action="" method="post" name="form1">

<input type="text" size="20" maxlength="50" name="email_e" value="<? echo "$mail";?>">
</TD>
<? echo "<TD class=td_lk$fb>";?>
<input type="password" size="6" maxlength="50" name="passwort_e" value="">
</TD>
<? echo "<TD class=td_lk$fb>";?>
<input type="password" size="6" maxlength="50" name="passwort2_e" value="">
</TD>
<?
if ($user_da[USER] !=='Admin'){

echo"<TD class=td_lk$fb>"; ?> <CENTER><input type="checkbox" name="r1" value="1" <? if($user_da[R1] == 1){echo "checked=\"checked\"";} ?>></CENTER></TD><?
echo"<TD class=td_lk$fb>"; ?> <CENTER><input type="checkbox" name="r2" value="1" <? if($user_da[R2] == 1){echo "checked=\"checked\"";} ?>></CENTER></TD><?
echo"<TD class=td_lk$fb>"; ?> <CENTER><input type="checkbox" name="r3" value="1" <? if($user_da[R3] == 1){echo "checked=\"checked\"";} ?>></CENTER></TD><?
echo"<TD class=td_lk$fb>"; ?> <CENTER><input type="checkbox" name="r4" value="1" <? if($user_da[R4] == 1){echo "checked=\"checked\"";} ?>></CENTER></TD><?
}else{
echo"<TD class=td_lk$fb><CENTER><IMG SRC=\"../templates/ok.gif\" WIDTH=24 HEIGHT=24 BORDER=0></CENTER></TD><TD class=td_lk$fb><CENTER><IMG SRC=\"../templates/ok.gif\" WIDTH=24 HEIGHT=24 BORDER=0></CENTER></TD><TD class=td_lk$fb><CENTER><IMG SRC=\"../templates/ok.gif\" WIDTH=24 HEIGHT=24 BORDER=0></CENTER></TD><TD class=td_lk$fb><CENTER><IMG SRC=\"../templates/ok.gif\" WIDTH=24 HEIGHT=24 BORDER=0></CENTER></TD><input type=\"hidden\" name=\"r1\" value=\"1\"><input type=\"hidden\" name=\"r2\" value=\"1\"><input type=\"hidden\" name=\"r3\" value=\"1\"><input type=\"hidden\" name=\"r4\" value=\"1\">";
}
echo"<TD class=td_lk$fb><input type=\"hidden\" name=\"edited\" value=\"$user_da[USER]\"><input type=\"hidden\" name=\"user_del\" value=\"\"><input type=\"submit\" value=\"$lg[us010]\"></form></TD>";

echo"<TD class=td_lk$fb>";
if ($user_da[USER] !=='Admin'){
echo"<form name=\"del\" method=\"post\" action=\"\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"user_del\" value=\"$user_da[USER]\"><input type=\"image\" name=\"delete\" onClick=\"if(confirm('$lg[q_009] &quot;$user_da[USER]&quot; $lg[q_011]')) this.form.submit(); else return false;\" src=\"../templates/delete.gif\" width=\"24\" height=\"24\" border=\"0\" /></form> ";
}else{echo"<CENTER><IMG SRC=\"../templates/ok.gif\" WIDTH=24 HEIGHT=24 BORDER=0></CENTER>";}
echo"</TD></TR>";
$fb++;
}}
echo "</TABLE>";
}
?>

Return current item: NewsP