mh, habe nur in den anderen Diskussionen gelesen, dass die Userverwaltung noch etwas schwierig ist. Weiterhin benötige ich eigentlich nur FrontEnd-User mit unterschiedlichen "trustlevel". Anhand dieser "trustlevel" werden dann später nicht komplette Seiten versteckt, sondern nur "vertrauliche" Informationen ausgeblendet.
Na, ist ja auch nur ne Idee von mir, die ich in meinem Projekt verfolge, und die ich anderen gerne zur Verfügung stelle.
Hier dann das UserCenter, über welches sich dann die Benutzer anmelden können. Einstellbar ist ein Standard-"trustlevel", der den neuen User mitgegeben wird. Weiterhin kann noch eine Benachrichtigung per eMail Versand werden.
Code: Alles auswählen
Installation:
In der cfg_sql.inc.php folgende Zeile anfügen:
$cfg["tab"]["cfuser_mod"] = $cfg['sql']['sqlprefix']."fuser_mod";
Danach eine weitere Tabelle anlegen:
CREATE TABLE `con_fuser_mod` (
`id` tinyint(4) NOT NULL auto_increment,
`userid` tinytext NOT NULL,
`password` tinytext NOT NULL,
`username` tinytext NOT NULL,
`email` tinytext NOT NULL,
`trustlevel` tinyint(4) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
Als nächstes einen neuen Baum definieren, dort wird das
User-Center als Modul in den Startartikel eingebunden.
Das neue Login-Modul statt dem alten Modul einbinden.
Im Layout/Modul ist nun über das Abfragen des trustlevel ein
Zugriffsschutz möglich:
z.B.: Container nur Anzeigen, wenn trustlevel>="1"
<?php if($fuser_mod_trustlevel>="1"){?>CMS_CONTAINER[x]<?php } ?>
z.B.: Container[x] nur Anzeigen, wenn trustlevel>="1", ansonsten Container[y]
<?php if($fuser_mod_trustlevel>="1"){?>CMS_CONTAINER[x]<?php }else{?>CMS_CONTAINER[y]<?php } ?>
/**
* fuser_mod_center
*
* INPUT
*
* Contenido-Version: 4.4.2
* Modul-Version: 0.1b
*
* @author Martin Hoffmann <martin.hoffmann@gmx.net>
* @copyright 2004
*/
echo "<table align=\"left\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr><td>trustlevel: <select name=\"CMS_VAR[0]\" size=\"1\">";
if ("CMS_VALUE[0]" != 0 && "CMS_VALUE[0]" != "")
{
echo "<option value=\"0\">0</option>";
}
else
{
echo "<option value=\"0\" selected>0</option>";
}
for ($i=1; $i<=5; $i++)
{
if ($i != "CMS_VALUE[0]")
{
echo "<option value=\"$i\">$i</option>";
}
else
{
echo "<option value=\"$i\" selected>$i</option>";
}
}
echo "</SELECT></td></tr>";
echo "<tr valign=\"top\"><td><INPUT TYPE=\"checkbox\" NAME=\"CMS_VAR[1]\" VALUE=\"1\" ";
if("CMS_VALUE[1]" == 1){echo "checked=checked"; };
echo "> eMail-Benachrichtigung</td></tr><tr><td>";
echo "an: <INPUT TYPE=\"text\" NAME=\"CMS_VAR[2]\" SIZE=\"30\"VALUE=\"";
if("CMS_VALUE[2]"){ echo "CMS_VALUE[2]";};
echo "\"></td></tr>";
echo "</table>";
/**
* fuser_mod_center
*
* OUTPUT
*
* Contenido-Version: 4.4.2
* Modul-Version: 0.1b
*
* @author Martin Hoffmann <martin.hoffmann@gmx.net>
* @copyright 2004
*/
<?php
include($cfg['path']['contenido']."includes/cfg_language_de.inc.php");
if ($fuser_center_act == "") { $fuser_center_act = "add"; }
if ($fuser_center_act == "add")
{
echo "Bitte füllen Sie alle Felder aus:";
echo "<FORM name='gb' id='gb' action=".$auth->url()." method='post' enctype='application/x-www-form-urlencoded'>";
echo "<INPUT TYPE=hidden NAME=fuser_center_act VALUE=check>";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% >
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Vorname:</b></td><td align=\"left\"><INPUT TYPE=text NAME=fuser_anm_vname VALUE=\"$fuser_anm_vname\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Name:</b></td><td align=\"left\"><INPUT TYPE=text NAME=fuser_anm_name VALUE=\"$fuser_anm_name\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%>E-Mail:</td><td align=\"left\"><INPUT TYPE=text NAME=fuser_anm_email VALUE=\"$fuser_anm_email\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%>Benutzername:</td><td align=\"left\"><INPUT TYPE=text NAME=fuser_anm_uid VALUE=\"$fuser_anm_uid\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%>Password:</td><td align=\"left\"><INPUT TYPE=password NAME=fuser_anm_pwd1 VALUE=\"$fuser_anm_pwd1\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%>Password:</td><td align=\"left\"><INPUT TYPE=password NAME=fuser_anm_pwd2 VALUE=\"$fuser_anm_pwd2\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></td></tr>
<tr><td colspan=\"2\"><br><div align=\"center\"><INPUT TYPE=submit VALUE=\"weiter\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></div></td></tr>
</table>
";
}
if($fuser_center_act == "check")
{
if($fuser_anm_vname & $fuser_anm_name & $fuser_anm_email & $fuser_anm_uid & $fuser_anm_pwd1 & $fuser_anm_pwd2 && eregi( "^" ."[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@" . "([a-z0-9]+([\.-][a-z0-9]+)*)+" . "\\.[a-z]{2,}" ."$", $fuser_anm_email))
{
$allesok='1';
$sql="SELECT * FROM ".$cfg["tab"]["fuser_mod"]." WHERE username = '$fuser_anm_vname $fuser_anm_name'";
$db->query($sql);
if($db->next_record())
{
$allesok='0';
echo "Die folgenden Daten werden überprüft:";
echo "<FORM name='gb' id='gb' action=".$auth->url()." method='post' enctype='application/x-www-form-urlencoded'>";
echo "<INPUT TYPE=hidden NAME=fuser_center_act VALUE=add>";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% >
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Vorname:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_vname</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Name:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_name</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td colspan=\"2\">Die Benutzerdaten wurden überprüft. Leider hast du bereits einen Account. Bitte logge dich mit deinem Benutzernamen "".$db->f("userid")."" ein!</td></tr>
<tr><td colspan=\"2\"><br><div align=\"center\"><INPUT TYPE=submit VALUE=\"weiter\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></div></td></tr>
</table>
";
}
if($allesok=='1')
{
$sql="SELECT * FROM ".$cfg["tab"]["fuser_mod"]." WHERE userid = '$fuser_anm_uid'";
$db->query($sql);
if($db->next_record())
{ #Benutzer vorhanden
$allesok='0';
echo "Die folgenden Daten werden überprüft:";
echo "<FORM name='gb' id='gb' action=".$auth->url()." method='post' enctype='application/x-www-form-urlencoded'>";
echo "<INPUT TYPE=hidden NAME=fuser_center_act VALUE=add>
<input type=\"hidden\" name=fuser_anm_vname value=\"$fuser_anm_vname\">
<input type=\"hidden\" name=fuser_anm_name value=\"$fuser_anm_name\">
<input type=\"hidden\" name=fuser_anm_email value=\"$fuser_anm_email\">
<input type=\"hidden\" name=fuser_anm_uid value=\"\">
<input type=\"hidden\" name=fuser_anm_pwd1 value=\"\">
<input type=\"hidden\" name=fuser_anm_pwd2 value=\"\">
";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% >
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Vorname:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_vname</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Name:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_name</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Benutzername:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_uid</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td colspan=\"2\">Die Benutzerdaten wurden überprüft. Leider ist der Benutzername bereits vergeben. Bitte wähle einen anderen Benutzernamen!</td></tr>
<tr><td colspan=\"2\"><br><div align=\"center\"><INPUT TYPE=submit VALUE=\"weiter\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></div></td></tr>
</table>
";
}
}
if($allesok=='1')
{
if($fuser_anm_pwd1==$fuser_anm_pwd2)
{
echo "Die folgenden Daten werden überprüft:";
echo "<FORM name='gb' id='gb' action=".$auth->url()." method='post' enctype='application/x-www-form-urlencoded'>";
echo "<INPUT TYPE=hidden NAME=fuser_center_act VALUE=insert>
<input type=\"hidden\" name=fuser_anm_vname value=\"$fuser_anm_vname\">
<input type=\"hidden\" name=fuser_anm_name value=\"$fuser_anm_name\">
<input type=\"hidden\" name=fuser_anm_email value=\"$fuser_anm_email\">
<input type=\"hidden\" name=fuser_anm_uid value=\"$fuser_anm_uid\">
<input type=\"hidden\" name=fuser_anm_pwd1 value=\"$fuser_anm_pwd1\">
<input type=\"hidden\" name=fuser_anm_pwd2 value=\"$fuser_anm_pwd2\">
";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% >
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Vorname:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_vname</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Name:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_name</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Benutzername:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_uid</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td colspan=\"2\">Die Benutzerdaten wurden überprüft. Nun bist du nur noch einen Click weit entfernt, und wir begrüßen dich als neuen Benutzer auf dieser Seite.</td></tr>
<tr><td colspan=\"2\"><br><div align=\"center\"><INPUT TYPE=submit VALUE=\"Anmelden\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></div></td></tr>
</table>
";
}
else
{
echo "Die folgenden Daten werden überprüft:";
echo "<FORM name='gb' id='gb' action=".$auth->url()." method='post' enctype='application/x-www-form-urlencoded'>";
echo "<INPUT TYPE=hidden NAME=fuser_center_act VALUE=add>
<input type=\"hidden\" name=fuser_anm_vname value=\"$fuser_anm_vname\">
<input type=\"hidden\" name=fuser_anm_name value=\"$fuser_anm_name\">
<input type=\"hidden\" name=fuser_anm_email value=\"$fuser_anm_email\">
<input type=\"hidden\" name=fuser_anm_uid value=\"$fuser_anm_uid\">
<input type=\"hidden\" name=fuser_anm_pwd1 value=\"\">
<input type=\"hidden\" name=fuser_anm_pwd2 value=\"\">
";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% >
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Vorname:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_vname</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Name:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_name</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td align=\"left\" style=\"padding-left:20px;\" width=30%><B>Benutzername:</b></td><td align=\"left\"><DIV style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\">$fuser_anm_uid</DIV></td></tr>
<tr><td height=\"5\" colspan=\"2\"></td></tr>
<tr><td colspan=\"2\">Die Benutzerdaten wurden überprüft. Leider stimmen die Passworte nicht überein. Bitte korrigiere dies!</td></tr>
<tr><td colspan=\"2\"><br><div align=\"center\"><INPUT TYPE=submit VALUE=\"weiter\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></div></td></tr>
</table>
";
}
}
}
else
{
echo "Die Benutzerdaten wurden überprüft. Du hast mindestens ein Feld nicht korrekt ausgefüllt.";
echo "<FORM name='gb' id='gb' action=".$auth->url()." method='post' enctype='application/x-www-form-urlencoded'>";
echo "<INPUT TYPE=hidden NAME=fuser_center_act VALUE=add>
<input type=\"hidden\" name=fuser_anm_vname value=\"$fuser_anm_vname\">
<input type=\"hidden\" name=fuser_anm_name value=\"$fuser_anm_name\">
<input type=\"hidden\" name=fuser_anm_email value=\"\">
<input type=\"hidden\" name=fuser_anm_uid value=\"$fuser_anm_uid\">
<input type=\"hidden\" name=fuser_anm_pwd1 value=\"\">
<input type=\"hidden\" name=fuser_anm_pwd2 value=\"\">
";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% >
<tr><td colspan=\"2\"><br><div align=\"center\"><INPUT TYPE=submit VALUE=\"weiter\" style=\"color:#000099; background-color:#FEF4C6; border-color:#CD0B14; border-style:solid; border-width:1px; text-decoration:none; font-family:verdana, arial, helvetica, sans-serif; font-size:10px;\"></div></td></tr>
</table>#
";
}
}
// wenn ein eintrag geschrieben werden soll
if($fuser_center_act == "insert")
{
include($cfg['path']['contenido']."includes/cfg_language_de.inc.php");
$sql = "INSERT INTO ".$cfg["tab"]["fuser_mod"]." (userid, password, username, email, trustlevel) VALUES ('$fuser_anm_uid', '$fuser_anm_pwd1', '$fuser_anm_vname $fuser_anm_name', '$fuser_anm_email', CMS_VALUE[0])";
$db->query($sql);
if("CMS_VALUE[1]" == 1 && "CMS_VALUE[2]" != "")
{
$message = "Benutzername: $fuser_anm_uid\nechter Name: $fuser_anm_vname $fuser_anm_name\nEmail: $fuser_anm_email";
mail("CMS_VALUE[2]", "neuer Benutzer", $message, "From: Frontend Usersystem <CMS_VALUE[2]>\n");
};
echo "Die Benutzerdaten wurden eingetragen.";
}
?>
ach, fehlt ja noch ne Funktion, mit der man ein neues Passwort anfordern kann, bzw. generell Passwörter und eMail-Adresse ändern kann...
Fortsetzung folgt