Hjælp (Haster)
Hej, Eksperter.Der er noget som jeg ikke kan finde ud af.
Det er at jeg godt vil have at man skal kunne oprette en bruger fra index.php altså forsiden. Men den jeg har kan man kun oprette en bruger hvis man er logget ind.
Her kommer spørgsmålet:
Hvordan kan jeg gøre så den her add.php kan bruges uden at være online.
Add.php =
<?
include("includes/checkauth.php");
?>
<HEAD>
<TITLE>-::- RDC.lir.dk -::-</TITLE>
<LINK REL=stylesheet HREF=includes/style.css>
</HEAD>
<BODY BGCOLOR=E8E8E8 TOPMARGIN=0 MARGINHEIGHT=0>
<?
include("includes/top.php");
include("includes/global.php");
include("includes/add_user.php");
include("includes/footer.php");
?>
checkauth.php =
<?
session_start();
if (!$lstatus || $lstatus != $PHPSESSID) {
header("Location: index.php");
}
?>
add_user.php =
<?
if (isset($lstatus) && $lstatus == $PHPSESSID) {
global $Enc, $Dec;
if(!isset($mode)) {
$mode = 'index';
}
echo "<DIV CLASS=headline>Tilføj Bruger</DIV><HR>";
switch($mode) {
case 'index':
echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10><TR><TD>";
echo "<FORM ACTION=$PHP_SELF?mode=add_user METHOD=POST>";
echo "<B>Brugernavn:</B></TD><TD><INPUT TYPE=text NAME=uname SIZE=30></TD></TR>";
echo "<TR><TD VALIGN=TOP><B>Password:</B></TD><TD><INPUT TYPE=password NAME=pass SIZE=30> ";
?>
<BR><DIV ALIGN=RIGHT><A HREF="#" onclick="NewWindow('includes/randpw.php','RandomPW','200','200','yes');return false">Tilfældigt Password</A></DIV>
<?
echo "</TD></TR>";
echo "<TR><TD><B>Skærm Navn:</B></TD><TD><INPUT TYPE=text name=dispname SIZE=30></TD></TR>";
echo "<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=SUBMIT VALUE='Tilføj Bruger'></FORM></TD></TR></TABLE>";
break;
case 'add_user':
if($uname && $pass && $dispname) {
echo "<DIV CLASS=normal>Brugernavn $uname er nu oprettet.<P><A HREF=$PHP_SELF?mode=index>Tilbage</A>";
// what to do with the form data
// $thepass = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $pass, MCRYPT_MODE_ECB, $iv);
$thepass = strtr($pass, $Dec, $Enc);
$userdetails = "$dispname\n$thepass";
if ($dn = fopen("$usrdir/$uname", 'w')) {
fwrite ($dn, $userdetails);
}
$welcome="<B>Velkommen til RDC, $dispname. Hvis dette er første gang du logger ind, så bør du ændre din<A HREF=prefs.php>Profil</a> og skrive dit email adresse og lidt om dig selv.<HR></B>";
if ($wm = fopen("$usrdir/$uname.welcome", 'w')) {
fwrite ($wm, $welcome);
}
}
break;
}
}
?>
global.php =
<?
// Define Common Functions and variables
function GetDisplayName($login) {
global $usrdir;
if (!file_exists("$usrdir/$login")) {
echo "(undefined)";
}
else {
$files = array();
$user = file("$usrdir/$login");
$user[] = $value;
for (reset ($user); list ($key, $value) = each ($user);) {
if ($key == "0") { /* Display name*/
echo "$value";
}
}
}
}
function GetRawPass($login) {
global $usrdir, $Enc, $Dec;
$files = array();
$user = file("$usrdir/$login");
$user[] = $value;
for (reset ($user); list ($key, $value) = each ($user);) {
if ($key == "1") { /* Password */
echo "$value";
}
}
}
function GetDecPass($login) {
global $usrdir, $Enc, $Dec;
$files = array();
$user = file("$usrdir/$login");
$user[] = $value;
for (reset ($user); list ($key, $value) = each ($user);) {
if ($key == "1") { /* Password */
$passwd = strtr($value, $Dec, $Enc);
echo $passwd;
}
}
}
function GetUserEmail($login) {
global $usrdir;
if (!file_exists("$usrdir/$login")) {
echo "(undefined)";
}
else {
$files = array();
$user = file("$usrdir/$login");
$user[] = $value;
for (reset ($user); list ($key, $value) = each ($user);) {
if ($key == "2") { /* User Email */
echo "$value";
}
}
}
}
function GetUserBio($login) {
global $usrdir;
if (!file_exists("$usrdir/$login")) {
echo "(undefined)";
}
else {
$files = array();
$user = file("$usrdir/$login");
$user[] = $value;
for (reset ($user); list ($key, $value) = each ($user);) {
if ($key = "3") { /* User Bio */
echo "$value";
}
}
}
}
function random() {
srand ((double) microtime() * 1000000);
return rand();
}
?>
index.php =
<?
/*
* If you wish to use a different directory structure than the
* default, scroll down toward the end of this file, where the
* session variables are set and follow the instructions for
* each.
*/
// Set the default mode to index if it isn't set
if (!isset($mode)) {
$mode = 'index';
}
switch($mode) {
case 'index':
session_start();
if (isset($lstatus) && $lstatus == $PHPSESSID) {
header("Location: main.php");
}
else {
echo "<HEAD>";
echo "<TITLE>:: - RDC.lir.dk - ::</TITLE>";
echo "<LINK REL=STYLESHEET HREF=includes/style.css>";
echo "</HEAD>";
echo "<BODY BGCOLOR=E8E8E8>";
echo "<DIV ALIGN=CENTER>";
echo "<P> </P><P> </P><P> </P>";
echo "<TABLE CELLSPACING=0 BORDER=0 WIDTH=400 HEIGHT=300 BGCOLOR=E8E8E8>";
echo "<TR>";
echo "<TD ALIGN=CENTER VALIGN=CENTER BGCOLOR=E8E8E8>";
echo "<TABLE CELLSPACING=0 CELLPADDING=10 BORDER=0 BGCOLOR=002F55>";
echo "<TR>";
echo "<TD WIDTH=70 BGCOLOR=E8E8E8>";
echo "<FORM ACTION=$PHP_SELF?mode=dologin METHOD=post>";
echo "Brugernavn:</TD>";
echo "<TD BGCOLOR=E8E8E8><INPUT TYPE=text NAME=uname WIDTH=30></TD>";
echo "</TR><TR>";
echo "<TD WIDTH=70 BGCOLOR=E8E8E8>Password:</TD>";
echo "<TD BGCOLOR=E8E8E8><INPUT TYPE=password NAME=passwd WIDTH=30></TD>";
echo "</TR><TR>";
echo "<TD WIDTH=160 BGCOLOR=E8E8E8 title=GRATIS><a href=http://www.rdc.lir.dk/admin/test/add.php> Ingen Bruger? Opret En Her!</a></TD>";
echo "<TD COLSPAN=2 BGCOLOR=E8E8E8><DIV ALIGN=RIGHT><INPUT TYPE=submit NAME=Login VALUE=Login></DIV></TD>";
echo "</TR>";
echo "</TABLE>";
echo "</TD>";
echo "</TR>";
echo "</TABLE>";
}
break;
case 'dologin':
$Enc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$Dec = "9876543210ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba";
$passwd = strtr($passwd, $Enc, $Dec);
// Leave these in, useful for bug tracking, be sure to comment them out
// before sending any header info.
// echo "<B>Brugernavn: $uname<BR>Password: $passwd</B><HR>";
$entries=opendir("$DOCUMENT_ROOT/admin/users");
// Load files into an array
$files = array();
while ($file = readdir($entries)) {
if ($file != "." && $file != "..") {
$files[] = $file;
}
}
for (reset ($files); list ($key, $value) = each ($files); ) {
$ruser = file("$DOCUMENT_ROOT/admin/users/$value");
$ufile = "$DOCUMENT_ROOT/admin/users/$value";
$filename = "$value";
$user = chop($value);
$ruser[] = $value;
for (reset ($ruser); list ($key, $value) = each ($ruser); ) {
if ($key == "1") { /* password */
$pass = chop($value);
if (($user == "$uname") && ($pass == "$passwd")) {
session_start();
// DO NOT CHANGE THESE!!!
session_register("login");
$login = $uname;
session_register("lstatus");
$lstatus = "$PHPSESSID";
// Edit this if you want to use a different path for the user directory.
session_register("usrdir");
$usrdir = "$DOCUMENT_ROOT/admin/users";
// Edit this if you want to use a different path for the articles directory.
session_register("articlesdir");
$articlesdir = "$DOCUMENT_ROOT/admin/articles";
// Edit this if you want to use a different path for the mail directory.
session_register("maildir");
$maildir = "$DOCUMENT_ROOT/admin/mail";
session_register("incdir");
$incdir = "$DOCUMENT_ROOT/admin/includes";
// DO NOT CHANGE THESE!!!
session_register("Enc");
$Enc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
session_register("Dec");
$Dec = "9876543210ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba";
// Edit this if you want to change the base directory for hte file manager.
session_register("BaseDir");
$BaseDir = "$DOCUMENT_ROOT";
header("Location: main.php");
exit;
}
else
{
header("Location: $PHP_SELF?mode=index");
}
break;
}
}
}
}
?>
MVH/
RDC