Avatar billede Slettet bruger
04. marts 2003 - 23:43 Der er 3 kommentarer og
1 løsning

To "ens" koder, men det ene laver fejl.

Hej Eksperter.

Jeg har to filer der indeholder "ens" kode, men den ene tegner en form som den skal, så man kan submitte, mens den anden ikke gør. Jeg KAN ikke finde fejlen..

Det raske:
-------------------------------------------
<?
$version = "1.2.01";

    /**********************************
    * Configuration Step 1 : Language *
    **********************************/

// Please remove all the unwanted language blocks

//ENGLISH
$langAdminError         = "Administrator Fejl";   
$langBsGuestbook        = "dbn.dk commentsystem";   
$langChPassword            = "Skift password";
$langEmail                 = "E-mail :";
$langEntry                = "Indl&aelig;g";
$langGbAdmin            = "Comment System Administerering";
$langMessage             = "Besked :";
$langName                 = "Navn :";
$langnewPassword         = "Nyt Password :";   
$langOpenError            = "Fejl ved filens åbning !<br>Sikker p&aring; du kan skrive i dette biblotek?";
$langPassChanged        = "Password skiftet.";   
$langPassError            = "Uens passwords !";
$langPassword            = "Skift Password";
$langRetype                = "Skriv Password igen :";
$langSubmit             = "Kommentér";
$langSubmitModif        = "Udfør &aelig;ndringer";   
$langSystemError         = "System Fejl";   
$langSystemMessage        = "System Message";   
$langWrongPassword        = "Forkert Admin Password";

    /*******************************************
    * Configuration Step 2 : Carbon Copy Email *
    *******************************************/
   
   
// carbonCopy = 1 enables mail sending to mailRecipient.
// mailRecipient receives a mail each times an entry is entered (if carbonCopy = 1)
// mailSubject is the subject of the mail which is sent.
$carbonCopy =         1;
$mailRecipient =     "comment@drengenebynight.dk";
$mailSubject =        "drengenebynight.dk - nyt comment indlæg!";


    /********************************
    * Configuration Step 3 : Colors *
    ********************************/


// Choosing colors (Remove the unwanted color-model)

// Standard (Greys, bright background)
$colorWhite    = "\"#FFFFFF\"";
$colorBlack    = "\"#000000\"";
$colorHeads    = "\"#7FB0FF\"";
$colorBody1    = "\"#EEEEEE\"";
$colorBody2    = "\"#DDDDDD\"";

/*
// The Following is the BIG SAM standard
$colorWhite    = "\"#FFFFFF\"";
$colorBlack    = "\"#000000\"";
$colorHeads    = "\"#42426F\"";
$colorBody1    = "\"#FFF8DC\"";
$colorBody2    = "\"#EFE8CC\"";
*/

// Data submission form colors
$formHeadColor    = $colorHeads;
$formBodyColor    = $colorBody1;
$formTailColor    = $colorBody2;
$formHeadText    = $colorWhite;
$formBodyText    = $colorBlack;
// Guestbook entries colors
$entryHeadColor  = $colorHeads;
$entryBodyColor1  = $colorBody2;
$entryBodyColor2  = $colorBody1;
$entryHeadText    = $colorWhite;
$entryBodyText1  = $colorBlack;
$entryBodyText2  = $colorHeads;
// Messages colors
$adminHeadColor  = $colorHeads;
$adminHeadText    = $colorWhite;
$adminBodyColor1  = $colorBody2;
$adminBodyText1  = $colorBlack;
$adminBodyColor2  = $colorBody1;
$adminBodyText2  = $colorHeads;


    /********************************
    * Configuration Step 4 : Header *
    ********************************/
   
   

function displayHeader()
    {
    global $version;
    header ("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
?>

<html>
<head>
<title>Billede</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../rippah.css" rel="stylesheet" type="text/css">
<link href="../../scrollbar.css" rel="stylesheet" type="text/css">
<link href="../../textbokse.css" rel="stylesheet" type="text/css">
</head>
<script type="text/javascript" src="../../fader.js"></script>

<body link="#000000" vlink="#000000" alink="#000000">
<TABLE width="750" border=0 align="center" cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=10 height=10><IMG height=10
      src="../../images/summary2_farleftt.gif"
      width=10></TD>
      <TD background="../../images/summary2_top.gif"
    colSpan=3 height=10><IMG height=10
      src="../../images/spacer.gif" width=10></TD>
      <TD width=10 height=10><IMG height=10
      src="../../images/summary2_farrightt.gif"
      width=10></TD>
    </TR>
    <TR vAlign=top>
      <TD width=10
    background="../../images/summary2_farleft.gif"
    rowSpan=5><IMG height=10
      src="../../images/spacer.gif" width=10></TD>
      <TD colSpan=3 class=summary2head><IMG height=20
      src="../../images/spacer.gif" width=22
      align=absMiddle><A class=filter
      href="java script://">Billede</A> - <A class=filter
      href="subben.html">Oversigt</A></TD>
      <TD width=10
    background="../../images/summary2_farright.gif"
    rowSpan=5><IMG height=10
      src="../../images/spacer.gif" width=10></TD>
    </TR>
    <TR>
      <TD bgColor=#000000 colSpan=3><IMG height=1 alt=""
      src="../../images/spacer.gif" width=1
    border=0></TD>
    </TR>
    <!-- fully cached -->
    <TR vAlign=top>
      <TD width=1 bgColor=#000000 rowSpan=2><IMG height=1 alt=""
      src="../../images/spacer.gif" width=1
    border=0></TD>
      <TD width="941" align="center" valign="middle" class=summary2upperbox>
        <DIV class=summary>
         
<img src="PIC00085.jpg" alt="">

<br> 
<br><br>

<br>
         
<?

    // You migh use and include instead of all this :
    // include ("../../head.inc");
    }

    /********************************
    * Configuration Step 5 : Footer *
    ********************************/
   
   

function displayFooter()

    {
?>

        </DIV></TD>
      <TD width=1 bgColor=#000000 rowSpan=2><IMG height=1 alt=""
      src="../../images/spacer.gif" width=1
    border=0></TD>
      <TD width="4" rowSpan=2></TD>
    </TR>
    <TR vAlign=top>
      <TD class=summary2lowerbox> <DIV class=summary>
          <div align="center"><BR>
            Copyright &copy; 2003 - drengenebynight.dk</div>
        </DIV></TD>
    </TR>
    <TR>
      <TD bgColor=#000000 colSpan=3><IMG height=1 alt=""
      src="../../images/spacer.gif" width=1
    border=0></TD>
    </TR>
    <TR>
      <TD width=10 height=10><IMG height=10
      src="../../images/summary2_farleftb.gif"
      width=10></TD>
      <TD background="../../images/summary2_bottom.gif"
    colSpan=3 height=10><IMG height=10
      src="../../images/spacer.gif" width=10></TD>
      <TD width=10 height=10><IMG height=10
      src="../../images/summary2_farrightb.gif"
      width=10></TD>
    </TR>
  </TBODY>
</TABLE>
</body>
</html>

<?
    }

    /******************************************************
    * Configuration Step 6 : Number of messages displayed *
    ******************************************************/
   

// Number of fields to be displayed simultaneously.
// To display everything, set $displayStep to 0.
$displayStep = 0;


    /***********************************************
    * Configuration Step 7 : Allow AutoLink System *
    ***********************************************/
$allowAutoLink=1;

    /************************
    * End of Configuration  *
    ************************/

// Register_Globals improvements (since version 1.2.0)
// By Hubert Hanghofer (webmaster@BierIG.org)

// $absoluteScriptPath is the name of the current script (this file) and which is going to
// be modified by itself. This means that (theoretically) this file can be
// placed anywhere on the system, with any fileName.

$absoluteScriptPath     = $PATH_TRANSLATED ;     // $_SERVER["PATH_TRANSLATED"];
$relativeScriptPath     = $PHP_SELF;             // $_SERVER["PHP_SELF"];
$refererpage            = $HTTP_REFERER;        // $_SERVER["HTTP_REFERER"];


// when the php preprocessor is installed as an independant binary (as CGI).
if ($PATH_INFO!="")
    {
    $relativeScriptPath     = $PATH_INFO;
    }

// to be used when $PHP_SELF contains virtual directory reference
// (for multi-users servers, eg : free.fr, online.fr ...)
if (($SERVER_NAME=="php.proxad.net")||(($SERVER_NAME=="php3.pro.proxad.net")))
    {
    $relativeScriptPath     = substr($relativeScriptPath, strpos(substr($relativeScriptPath, 1), "/")+1);
    }


$theName=substr($absoluteScriptPath, 0, strrpos($absoluteScriptPath, "."));
$extension=substr($absoluteScriptPath, strrpos($absoluteScriptPath, ".")+1);


// The dataFile contains all the guestbook entries, and $adminpassword .
// $adminpassword is the password which will be asked for any administration
// actions. This password could be changed only if in admin mode (old
// $adminpassword matches $admin).

// Defines the name of the database file where the entries are stored.
$dataFile = "${theName}.dat.${extension}";


//******************************************************************************
// function displayForm : Display the form which enables the client to type a
// message.

function displayForm()
    {
    global $relativeScriptPath;
    $borderThickness = 3;

    global $formHeadColor;
    global $formBodyColor;
    global $formTailColor;
    global $formHeadText;
    global $formBodyText;
   
    global $langName;
    global $langEmail;
    global $langMessage;
    global $langSubmit;
   
    // Writing HTML Code
    echo ("<center>\n");
    echo ("<form method=\"POST\" action=\"$relativeScriptPath\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" class=\"input1\">\n");
    echo ("<tr bgcolor=$formHeadColor>\n");
    echo ("<td><font color=$formHeadText><b>$langName</b></font><input name=\"name\" size=\"20\" maxlength=\"50\" class=\"input1\"></td>\n");
    echo ("<td>&nbsp;</td>\n");
    echo ("<td align=right><font color=$formHeadText><b>$langEmail</b></font><input name=\"email\" size=\"20\" maxlength=\"50\" class=\"input1\"></td>\n");
    echo ("</tr>\n");
    echo ("<tr bgcolor=$formBodyColor><td colspan=\"3\">\n");
    echo ("<font color=$formBodyText><b>$langMessage</b></font><br>\n");
    echo ("<center><textarea name=\"message\" cols=\"60\" rows=\"7\" class=\"input1\" style=\"width:500;height:100\" onFocus=\"if(this.value == this.defaultValue) this.value='';\">Selvom vi virker useriøse, ville vi gerne undgå at se lamme indlæg og unøvendig larm. Tænk dig om før du poster. :-)</textarea></center>\n");
    echo ("</td></tr>\n");
    echo ("<tr bgcolor=$formTailColor><td colspan=\"3\" align=\"right\">\n");
    echo ("<input type=\"submit\" value=\"$langSubmit\" class=\"input1\" style=\"width:150\">");
    echo ("</td></tr>\n");
    echo ("</table>\n");
    echo ("</form>\n");
    echo ("</center>\n");
    }

//******************************************************************************
// function displayMessage displays the $errorMessage error message.

function displayMessage($errorMessage,$msgType)
    {
    global $adminHeadColor;
    global $adminHeadText;
    global $adminBodyColor1;
    global $adminBodyText1;
    global $adminBodyColor2;
    global $adminBodyText2;
    global $langAdminError;
    global $langSystemError;
    global $langSystemMessage;
    global $langBsGuestbook;

   
    displayHeader();
    echo ("<table width=\"100%\" height=\"100%\"><tr><td width=\"100%\" valign=\"middle\" align=\"center\">");
    echo ("<table cellspacing=\"0\" border=\"0\" width=\"250\"><tr><td bgcolor=$adminHeadColor>");
    echo ("<font Color=$adminHeadText size=\"-3\">&nbsp; $langBsGuestbook</font><br>");
    echo ("</td></tr><tr><td bgcolor=$adminBodyColor1><font color=$adminBodyText1>");
    if ($msgType=="1") // Admin Message
        echo ("<i>&nbsp; $langAdminError</i>");
    if ($msgType=="2") // System Error
        echo ("<i>&nbsp; $langSystemError</i>");
    if ($msgType=="3") // System Message
        echo ("<i>&nbsp; $langSystemMessage</i>");
    echo ("</font>");
    echo ("</td></tr><tr><td bgcolor=$adminBodyColor2 align=\"center\">");
    echo ("<font color=$adminBodyText2>");
    echo ("<br><b>$errorMessage</b><br><br>");
    echo ("</font></td></tr></table><p>&nbsp;</p>\n");
    echo ("</td></tr></table>");
    displayFooter();
    exit;
    }


//******************************************************************************
// function standardizeText filters ambiguous chains in $str

function standardizeStoredText($str)
    {
    $str = str_replace("\\'", "'", $str);
    $str = str_replace("\\\"", "\"", $str);
    $str = htmlspecialchars($str);
    $str = str_replace("\n", "<br>", $str);
    $str = str_replace("$", "&#036;", $str);
    return $str;
    }
   

function standardizeDisplayedText($str)
    {
    return $str;
    }
   
function standardizeAdminText($str)
    {
    return $str;
    }
   
   
function seekHttp($rawText)
{   
    $pattern = array(
        "/http:\/\/((\w|\.|\?|\%|=|\/|-|~|#)*)/",
        "/mailto:((\w|\.|@|-)*)/");   
    $replacement = array(
        "<a href=\"http://\\1\" target=\"_blank\">http://\\1</a>",
        "<a href=\"mailto:\\1\">\\1</a>");
    $hyperLinkedText=preg_replace($pattern, $replacement, $rawText);   
       
    return $hyperLinkedText;
}


//******************************************************************************
// function Xfopen : opens a file $fileName and locks it
function Xfopen($fileName, $openMode, $sharing)
    {
    global $langOpenError;
    $fp=@fopen($fileName, $openMode);
    if (!$fp)
        {
        displayMessage($langOpenError,2);
        }
    if ($sharing==true)
        {
        $op=1;
        }
    else
        {
        $op=2;
        }
    if (!@flock($fp,$op))
        {
        @flock($fp,3);
        displayMessage("<i>flock</i> timeout",2);
        }
    return $fp;
    }

//******************************************************************************
// function Xfclose : unlocks the file $fp and closes it
function Xfclose($fp)
    {
    @flock($fp,3);
    @fclose($fp);
    }


//******************************************************************************
// function fullDisplay
function fullDisplay()
{
        global $displayStep,$displayBegin, $maxDisplay ;
        global $entryHeadColor,$entryHeadText, $entryBodyColor1,$entryBodyText1, $entryBodyColor2,$entryBodyText2 ;
        global $relativeScriptPath;
        global $index;
        global $archive_mail, $archive_name, $archive_text, $archive_date;
        global $allowAutoLink;

        // Checks if $displayBegin is not too large (Thanks to Ahmet Sabri ALPER <salper@olympos.org>)
        if ($displayBegin>$maxDisplay)
            {
            $displayBegin=$maxDisplay-$displayStep+1;
            }
           
        displayHeader();
       
        // Displays the entry form to enable the client to type a message.
        displayForm();

        if ($index==0)
            {
            displayFooter();
            return;
            }


        echo ("<p>&nbsp;</p>\n");

        // Message arrays are displayed here :
       
        echo "<center>\n";
       
        // Displaying all the entries.
       
        if ($displayStep==0)
            {
            $displayBegin=1;
            $displayStep=$index;
            }
       
        if ($displayBegin==1)
            {
            $startAt=$index % $displayStep;
            if ($startAt==0) $startAt=$displayStep;
            }
        else
            {
            $startAt=$displayBegin+$displayStep-1;
            }
       
       
        for ($msgNumber=$startAt ; $msgNumber>=$displayBegin ; $msgNumber--)
            {
            echo ("<table cellspacing=\"0\" border=\"0\" width=\"600\"><tr class=\"input1\"><td bgcolor=$entryHeadColor>");
            echo ("<font color=$entryHeadText size=\"-3\"><IMG src=\"http://www.drengenebynight.dk/images/dots.jpg\" align=absMiddle> &nbsp; $archive_date[$msgNumber] &nbsp; &nbsp;</font>");
            echo ("</td></tr><tr class=\"input1\"><td bgcolor=$entryBodyColor2>");
            echo ("<font Color=$entryBodyText1><b>");
            if ($archive_mail[$msgNumber]!="")
                {
                echo ("$msgNumber : <a title=\"".standardizeDisplayedText($archive_mail[$msgNumber])."\" href=\"mailto:".standardizeDisplayedText($archive_mail[$msgNumber])."\">".standardizeDisplayedText($archive_name[$msgNumber])."</a>");
                }
            else
                {
                echo ("$msgNumber : ".standardizeDisplayedText($archive_name[$msgNumber]));
                }
            echo ("</b></font>");
            echo ("</td></tr><tr class=\"input1\"><td bgcolor=$entryBodyColor2>");
            echo ("<font color=$formBodyText>");
            if ($allowAutoLink==1) echo ("<b>".seekHttp(standardizeDisplayedText($archive_text[$msgNumber]))."</b>");
            else echo ("<b>".standardizeDisplayedText($archive_text[$msgNumber])."</b>");
            echo ("</font></td></tr></table><br>\n");
            }
       
        echo ("<p>&nbsp;</p>\n");
       
        for($i=1;$i<=$index;$i=$nextEnd+1)
            {
            $nextBegin = $i;
           
            if ($i==1)
                {
                $nextEnd=$index % $displayStep;
                if ($nextEnd==0) $nextEnd=$displayStep;
                }
            else $nextEnd  = $i+$displayStep-1;
           
            if ($displayBegin==$nextBegin && $nextEnd!=$nextBegin) echo ("");
            else if ($displayBegin==$nextBegin && $nextEnd==$nextBegin) echo ("");
            else if ($nextEnd==$nextBegin) echo ("");
            else echo ("");   
            }
       
        echo "</center>\n";
        displayFooter();
}

//******************************************************************************

function readData($resetBegin)
{
    global $adminpassword;
    global $index;
    global $dataFile;
    global $archive_mail, $archive_name, $archive_text, $archive_date;
    global $displayBegin, $displayStep, $maxDisplay;

    // Includes automatically filled data arrays :
    $index = 0;
    $fout=Xfopen($dataFile, "r", true);
    include($dataFile);
    Xfclose($fout);
    // From now, $index will indicate the number of data entries.
   
    // Beginning of the data to be displayed, default = 1
        if (!isset($displayBegin)) $displayBegin="";
    if ($displayBegin=="" || $resetBegin==1)
        {
        $displayBegin = $index-$displayStep+1;
        if ($displayBegin<=0) $displayBegin=1;
        }
       
    // Sets the maximum that $displayBegin can reach
    $maxDisplay = $index;
}
//******************************************************************************




// If the Datafile does not exist, creates it.
if (!file_exists(${dataFile}))
    {
    $fout = Xfopen($dataFile, "w+", false);
    fputs($fout, "<?\n");
    fputs($fout, "\$adminpassword = \"noorcap\";\n");
    fputs($fout, "\$archive_name[++\$index] = \"drengenebynight.dk\";\n");
    fputs($fout, "\$archive_mail[  \$index] = \"dbn@pacroon.dk\";\n");
    fputs($fout, "\$archive_date[  \$index] = \"4th March 2003 - 12:00:00 PM\";\n");
    fputs($fout, "\$archive_text[  \$index] = \"drengenebynight.dk comment system - skriv en hilsen!\";\n");
    fputs($fout, "?>");
    Xfclose ($fout);
    }

// $admin could be set via Admin-Form by POST or via URL by GET
$admin=$HTTP_POST_VARS["admin"];
if (!isset($admin))
        $admin=$HTTP_GET_VARS["admin"];
else    // assign POST-variables from Admin-Form
        {
        $newPassword1=$HTTP_POST_VARS["newPassword1"];
        $newPassword2=$HTTP_POST_VARS["newPassword2"];
        $command=$HTTP_POST_VARS["command"];
        $index=$HTTP_POST_VARS["index"];
        }

if (!isset($admin))
    {
        // assing variables from Guestbook-From
        $name=$HTTP_POST_VARS["name"];
        $email=$HTTP_POST_VARS["email"];
        $message=$HTTP_POST_VARS["message"];
    if (!isset($name)) { $name=""; $message=""; }
    if ($name=="" || $message=="")
        {

        /****************************************************************************************
        * Use Case no 1-A                                    *
        *                                            *
        * This case is encountered when a client simply wants to add a message to the        *
        * guestbook. (Every variable is empty);                            *
        ************************************************************************************/
        readData(0);
        fullDisplay();
        exit;
        }
    else
        {
       
        /********************************************************************************
        * Use Case no 1-B                                *
        *                                        *
        * Case is encountered when a client has just filled in the appropriate fields    *
        * (name, mail, message).                            *
        *    $name    = "Some Name"                            *
        *    $email  = "Some@Email"                            *
        *    $message = "Some Message"                        *
        *        Simply add message in the top of all previous messages.        *
        ********************************************************************************/
       
        $position = filesize($dataFile);
       
        $fout = Xfopen($dataFile, "r+", false);
        fseek($fout,$position-2);
        $insert_msgdate = date( "d/m-Y - H:i:s" );
        $name=standardizeStoredText($name);
        $email=standardizeStoredText($email);
        $message=standardizeStoredText($message);
        fputs ($fout,"\$archive_name[++\$index] = \"$name\";\n");
        fputs ($fout,"\$archive_mail[  \$index] = \"$email\";\n");
        fputs ($fout,"\$archive_date[  \$index] = \"$insert_msgdate\";\n");
        fputs ($fout,"\$archive_text[  \$index] = \"$message\";\n");
        fputs ($fout,"\n?>");
        Xfclose($fout);
       
        // Sending a mail to $mailRecipient if $carbonCopy=1, with the subject $mailSubject.
        if ($carbonCopy==1)
            {
            $message = str_replace("<br>", "\n", $message);
            $mailBody = "From: $name <$email>\n$insert_msgdate\n\n$message";
            mail($mailRecipient,$mailSubject,$mailBody,"From: $email\nReply-to: $name <$email>");
            }
        if (strpos($refererpage, "?")==false) $page=$refererpage;
        else $page=substr($refererpage, 0, strpos($refererpage, "?"));
        header("Location: $page?");
        exit;
        }
    }
else
    {
    readData(0);
    if ($admin==$adminpassword)
        {
        if ($command=="")
            {
   
            displayHeader();
           
            /************************************************************************
            * Use Case no 2-A                            *
            *                                    *
            * Admin mode (The administrator can modify password, fields, or remove    *
            * messages).                                *
            *    $admin  = $adminpassword                    *
            *        Shows a password modification form.            *
            *        Shows all messages and enables to modify/delete them.    *
            ************************************************************************/
           
            echo("<center><h1>d r e n g e n e b y n i g h t . d k</h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size=\"5\">IDIOT!</font></h2><h4>$langGbAdmin</h4></center>\n");
            echo("<br>\n");            // Display the form which enables the admin to change his password

            echo ("<center><form method=\"POST\" action=\"$relativeScriptPath\">\n");

            echo ("<table cellspacing=\"0\" border=\"0\">\n");
            echo ("<tr><td bgcolor=$adminHeadColor colspan=\"2\"><font color=$adminHeadText>\n");
            echo ("&nbsp;<b>$langPassword</b>.</font></td></tr>\n");
            echo ("<tr><td align=right bgcolor=$adminBodyColor2>");
            echo ("<font color=$adminBodyText2>&nbsp; $langnewPassword</font></td>\n");
            echo ("<td align=left bgcolor=$adminBodyColor2>");
            echo ("<input type=\"password\" name=\"newPassword1\">&nbsp;</td></tr>\n");
            echo ("<tr><td align=\"right\" bgcolor=$adminBodyColor2>");
            echo ("<font color=$adminBodyText2>&nbsp; $langRetype</font></td>\n");
            echo ("<td align=left bgcolor=$adminBodyColor2>");
            echo ("<input type=\"password\" name=\"newPassword2\">&nbsp;</td></tr>\n");
            echo ("<tr><td bgcolor=$adminBodyColor1 colspan=2 align=\"center\">\n");
            echo ("<input type=\"hidden\" name=\"admin\" value=\"$admin\">\n");
            echo ("<input type=\"hidden\" name=\"command\" value=\"passwd\">\n");
            echo ("<input type=\"submit\" value=\"$langChPassword\"></td></tr>\n");
            echo ("</table>\n");
            echo ("</form></center>\n");
           
            echo("<br><hr><br>\n");// Message arrays are displayed here in forms in order to modify them :
           
            echo ("<center><form method=\"POST\" action=\"$relativeScriptPath\">\n");
           
            for ($i=1 ; $i<=$index ; $i++)
                {
                $msgNumber = $index - $i + 1;
                $str = str_replace("<br>", "\n", $archive_text[$msgNumber]);
                echo ("<table cellspacing=\"0\" cellpadding=\"3\"><tr><td colspan=\"4\" bgcolor=$adminHeadColor>\n");
                echo ("<font color=$adminHeadText><b>&nbsp;");
                echo ("$langEntry #$msgNumber</b>.</font>&nbsp;</td></tr>\n");
                echo ("<tr bgcolor=$adminBodyColor2>\n");
                    echo ("<td>&nbsp;<input type=\"checkbox\" name=\"keep${msgNumber}\" checked>&nbsp;</td>\n");
                echo ("<td><input name=\"name${msgNumber}\" value=\"".standardizeAdminText($archive_name[$msgNumber])."\"></td>\n");
                echo ("<td><input name=\"email${msgNumber}\" value=\"".standardizeAdminText($archive_mail[$msgNumber])."\"></td>\n");
                echo ("<td><input name=\"date${msgNumber}\" value=\"".standardizeAdminText($archive_date[$msgNumber])."\"></td>\n");
                echo ("<tr bgcolor=$adminBodyColor1>\n");
                echo ("<td colspan=\"4\" align=\"center\"><textarea cols=\"60\" rows=\"2\" name=\"message${msgNumber}\">".standardizeAdminText($str));
                echo ("</textarea></td>\n</tr></table>\n<br>\n");
                }
            echo ("<input type=\"hidden\" name=\"admin\" value=\"$admin\">\n");
            echo ("<input type=\"hidden\" name=\"index\" value=\"$index\">\n");
            echo ("<input type=\"hidden\" name=\"command\" value=\"modify\">\n");
            echo ("<input type=\"submit\" value=\"$langSubmitModif\">\n <br><b><font size=\"-2\" face=\"verdana\">Pacroon er den galeste h4x0r</font></b>");
            echo ("</form></center>\n");
            displayFooter();
            exit;
           
            }
        else if ($command=="passwd")
            {
            // Use Case no 2-B
            // Admin mode (The administrator is modifying his password.).
            //    $admin        = $adminpassword
            //    $newPassword1 = "New Password 1"
            //    $newPassword2 = "New Password 2"
            //         Check if $newPassword1 matches $newPassword2
            //         Set the $adminpassword line to :
            //         $adminpassword = "$newPassword1" in the dataFile
           
            if($newPassword1!=$newPassword2)
                {
                // The passwords doesn't match
                displayMessage("$langPassError",1);
                }
            else
                {
                // Rewrites the whole Datafile with the new password, and all the entries.
                $fout = Xfopen($dataFile, "w", false);
                fputs ($fout,"<?\n");
                fputs ($fout,"\$adminpassword = \"$newPassword1\";\n");
                for ($i=1 ; $i<=$index ; ++$i)
                    {
                    fputs ($fout,"\$archive_name[++\$index] = \"${archive_name[$i]}\";\n");
                    fputs ($fout,"\$archive_mail[  \$index] = \"${archive_mail[$i]}\";\n");
                    fputs ($fout,"\$archive_date[  \$index] = \"${archive_date[$i]}\";\n");
                    fputs ($fout,"\$archive_text[  \$index] = \"${archive_text[$i]}\";\n");
                    }
                fputs ($fout,"?>");
                Xfclose($fout);
                displayMessage("$langPassChanged",3);
                exit;
                }
            }
        else if ($command=="modify")
            {

            /********************************************************************************
            * Use Case no 2-C                                *
            *                                        *
            * Admin mode (The administrator is updating entries).                *
            *    $admin      = $adminpassword                        *
            *    $nameXXX    = "Modified name (no XXX)"                    *
            *    $emailXXX  = "Modified email (no XXX)"                    *
            *    $messageXXX = "Modified message (no XXX)"                *
            *    $keep      = "on" or ""                        *
            *     Check if $admin matches $adminpassword.                    *
            *     Rewrites ALL the fields except when $keepXXX = ""            *
            *    Rewrites the whole Datafile with the new password, and all the entries.    *
            ********************************************************************************/

            $fout = Xfopen($dataFile, "w", false);
            fputs ($fout,"<?\n");
            fputs ($fout,"\$adminpassword = \"$adminpassword\";\n");   
                for ($i=1 ; $i<=$index ; $i++)
                {
                // Get values from the form, and standardize them
                $variable=$HTTP_POST_VARS["name$i"];
                $name=standardizeStoredText("$variable");
                $variable=$HTTP_POST_VARS["email$i"];
                $email=standardizeStoredText("$variable");
                $variable=$HTTP_POST_VARS["date$i"];
                $insert_msgdate=standardizeStoredText("$variable");
                $variable=$HTTP_POST_VARS["message$i"];
                $message=standardizeStoredText("$variable");

                $variable=$HTTP_POST_VARS["keep$i"];
                if (${variable}!="")
                    {
                    fputs ($fout,"\$archive_name[++\$index] = \"$name\";\n");
                    fputs ($fout,"\$archive_mail[  \$index] = \"$email\";\n");
                    fputs ($fout,"\$archive_date[  \$index] = \"$insert_msgdate\";\n");
                    fputs ($fout,"\$archive_text[  \$index] = \"$message\";\n");
                    }
                }   
            fputs ($fout,"?>");
            Xfclose($fout);
           
            if (strpos($refererpage, "?")==false) $page=$refererpage;
            else $page=substr($refererpage, 0, strpos($refererpage, "?"));
            header("Location: $page?");
            exit;
            }
        }
    else
        {
       
        /************************************************
        * Use Case no 2-Z                *
        *                        *
        * If $admin does NOT match $adminpassword.    *
        *    $admin  != $adminpassword        *
        *    Error message : "Wrong Admin Password"    *
        ************************************************/

        displayMessage("$langWrongPassword",1);
        }
    }
?>
-------------------------------------------------------

Det syge:
--------------------------------------------------------
<?
$version = "1.2.01";

    /**********************************
    * Configuration Step 1 : Language *
    **********************************/

// Please remove all the unwanted language blocks

//ENGLISH
$langAdminError         = "Administrator Fejl";   
$langBsGuestbook        = "dbn.dk commentsystem";   
$langChPassword            = "Skift password";
$langEmail                 = "E-mail :";
$langEntry                = "Indl&aelig;g";
$langGbAdmin            = "Comment System Administerering";
$langMessage             = "Besked :";
$langName                 = "Navn :";
$langnewPassword         = "Nyt Password :";   
$langOpenError            = "Fejl ved filens åbning !<br>Sikker p&aring; du kan skrive i dette biblotek?";
$langPassChanged        = "Password skiftet.";   
$langPassError            = "Uens passwords !";
$langPassword            = "Skift Password";
$langRetype                = "Skriv Password igen :";
$langSubmit             = "Kommentér";
$langSubmitModif        = "Udfør &aelig;ndringer";   
$langSystemError         = "System Fejl";   
$langSystemMessage        = "System Message";   
$langWrongPassword        = "Forkert Admin Password";

    /*******************************************
    * Configuration Step 2 : Carbon Copy Email *
    *******************************************/
   
   
// carbonCopy = 1 enables mail sending to mailRecipient.
// mailRecipient receives a mail each times an entry is entered (if carbonCopy = 1)
// mailSubject is the subject of the mail which is sent.
$carbonCopy =         1;
$mailRecipient =     "comment@drengenebynight.dk";
$mailSubject =        "drengenebynight.dk - nyt comment indlæg!";


    /********************************
    * Configuration Step 3 : Colors *
    ********************************/


// Choosing colors (Remove the unwanted color-model)

// Standard (Greys, bright background)
$colorWhite    = "\"#FFFFFF\"";
$colorBlack    = "\"#000000\"";
$colorHeads    = "\"#7FB0FF\"";
$colorBody1    = "\"#EEEEEE\"";
$colorBody2    = "\"#DDDDDD\"";

/*
// The Following is the BIG SAM standard
$colorWhite    = "\"#FFFFFF\"";
$colorBlack    = "\"#000000\"";
$colorHeads    = "\"#42426F\"";
$colorBody1    = "\"#FFF8DC\"";
$colorBody2    = "\"#EFE8CC\"";
*/

// Data submission form colors
$formHeadColor    = $colorHeads;
$formBodyColor    = $colorBody1;
$formTailColor    = $colorBody2;
$formHeadText    = $colorWhite;
$formBodyText    = $colorBlack;
// Guestbook entries colors
$entryHeadColor  = $colorHeads;
$entryBodyColor1  = $colorBody2;
$entryBodyColor2  = $colorBody1;
$entryHeadText    = $colorWhite;
$entryBodyText1  = $colorBlack;
$entryBodyText2  = $colorHeads;
// Messages colors
$adminHeadColor  = $colorHeads;
$adminHeadText    = $colorWhite;
$adminBodyColor1  = $colorBody2;
$adminBodyText1  = $colorBlack;
$adminBodyColor2  = $colorBody1;
$adminBodyText2  = $colorHeads;


    /********************************
    * Configuration Step 4 : Header *
    ********************************/
   
   

function displayHeader()
    {
    global $version;
    header ("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
?>

<html>
<head>
<title>Billede</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../rippah.css" rel="stylesheet" type="text/css">
<link href="../../scrollbar.css" rel="stylesheet" type="text/css">
<link href="../../textbokse.css" rel="stylesheet" type="text/css">
</head>
<script type="text/javascript" src="../../fader.js"></script>

<body link="#000000" vlink="#000000" alink="#000000">
<TABLE width="750" border=0 align="center" cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=10 height=10><IMG height=10
      src="../../images/summary2_farleftt.gif"
      width=10></TD>
      <TD background="../../images/summary2_top.gif"
    colSpan=3 height=10><IMG height=10
      src="../../images/spacer.gif" width=10></TD>
      <TD width=10 height=10><IMG height=10
      src="../../images/summary2_farrightt.gif"
      width=10></TD>
    </TR>
    <TR vAlign=top>
      <TD width=10
    background="../../images/summary2_farleft.gif"
    rowSpan=5><IMG height=10
      src="../../images/spacer.gif" width=10></TD>
      <TD colSpan=3 class=summary2head><IMG height=20
      src="../../images/spacer.gif" width=22
      align=absMiddle><A class=filter
      href="java script://">Billede</A></TD>
      <TD width=10
    background="../../images/summary2_farright.gif"
    rowSpan=5><IMG height=10
      src="../../images/spacer.gif" width=10></TD>
    </TR>
    <TR>
      <TD bgColor=#000000 colSpan=3><IMG height=1 alt=""
      src="../../images/spacer.gif" width=1
    border=0></TD>
    </TR>
    <!-- fully cached -->
    <TR vAlign=top>
      <TD width=1 bgColor=#000000 rowSpan=2><IMG height=1 alt=""
      src="../../images/spacer.gif" width=1
    border=0></TD>
      <TD width="941" align="center" valign="middle" class=summary2upperbox>
        <DIV class=summary>
         
<img src="PIC00086.jpg" alt="">

<br> 
<br><br>

<br>
         
<?

    // You migh use and include instead of all this :
    // include ("../../head.inc");
    }

    /********************************
    * Configuration Step 5 : Footer *
    ********************************/
   
   

function displayFooter()

    {
?>

        </DIV></TD>
      <TD width=1 bgColor=#000000 rowSpan=2><IMG height=1 alt=""
      src="../../images/spacer.gif" width=1
    border=0></TD>
      <TD width="4" rowSpan=2></TD>
    </TR>
    <TR vAlign=top>
      <TD class=summary2lowerbox> <DIV class=summary>
          <div align="center"><BR>
            Copyright &copy; 2003 - drengenebynight.dk</div>
        </DIV></TD>
    </TR>
    <TR>
      <TD bgColor=#000000 colSpan=3><IMG height=1 alt=""
      src="../../images/spacer.gif" width=1
    border=0></TD>
    </TR>
    <TR>
      <TD width=10 height=10><IMG height=10
      src="../../images/summary2_farleftb.gif"
      width=10></TD>
      <TD background="../../images/summary2_bottom.gif"
    colSpan=3 height=10><IMG height=10
      src="../../images/spacer.gif" width=10></TD>
      <TD width=10 height=10><IMG height=10
      src="../../images/summary2_farrightb.gif"
      width=10></TD>
    </TR>
  </TBODY>
</TABLE>
</body>
</html>

<?
    }

    /******************************************************
    * Configuration Step 6 : Number of messages displayed *
    ******************************************************/
   

// Number of fields to be displayed simultaneously.
// To display everything, set $displayStep to 0.
$displayStep = 0;


    /***********************************************
    * Configuration Step 7 : Allow AutoLink System *
    ***********************************************/
$allowAutoLink=1;

    /************************
    * End of Configuration  *
    ************************/

// Register_Globals improvements (since version 1.2.0)
// By Hubert Hanghofer (webmaster@BierIG.org)

// $absoluteScriptPath is the name of the current script (this file) and which is going to
// be modified by itself. This means that (theoretically) this file can be
// placed anywhere on the system, with any fileName.

$absoluteScriptPath     = $PATH_TRANSLATED ;     // $_SERVER["PATH_TRANSLATED"];
$relativeScriptPath     = $PHP_SELF;             // $_SERVER["PHP_SELF"];
$refererpage            = $HTTP_REFERER;        // $_SERVER["HTTP_REFERER"];


// when the php preprocessor is installed as an independant binary (as CGI).
if ($PATH_INFO!="")
    {
    $relativeScriptPath     = $PATH_INFO;
    }

// to be used when $PHP_SELF contains virtual directory reference
// (for multi-users servers, eg : free.fr, online.fr ...)
if (($SERVER_NAME=="php.proxad.net")||(($SERVER_NAME=="php3.pro.proxad.net")))
    {
    $relativeScriptPath     = substr($relativeScriptPath, strpos(substr($relativeScriptPath, 1), "/")+1);
    }


$theName=substr($absoluteScriptPath, 0, strrpos($absoluteScriptPath, "."));
$extension=substr($absoluteScriptPath, strrpos($absoluteScriptPath, ".")+1);


// The dataFile contains all the guestbook entries, and $adminpassword .
// $adminpassword is the password which will be asked for any administration
// actions. This password could be changed only if in admin mode (old
// $adminpassword matches $admin).

// Defines the name of the database file where the entries are stored.
$dataFile = "${theName}.dat.${extension}";


//******************************************************************************
// function displayForm : Display the form which enables the client to type a
// message.

function displayForm()
    {
    global $relativeScriptPath;
    $borderThickness = 3;

    global $formHeadColor;
    global $formBodyColor;
    global $formTailColor;
    global $formHeadText;
    global $formBodyText;
   
    global $langName;
    global $langEmail;
    global $langMessage;
    global $langSubmit;
   
    // Writing HTML Code
    echo ("<center>\n");
    echo ("<form method=\"POST\" action=\"$relativeScriptPath\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" class=\"input1\">\n");
    echo ("<tr bgcolor=$formHeadColor>\n");
    echo ("<td><font color=$formHeadText><b>$langName</b></font><input name=\"name\" size=\"20\" maxlength=\"50\" class=\"input1\"></td>\n");
    echo ("<td>&nbsp;</td>\n");
    echo ("<td align=right><font color=$formHeadText><b>$langEmail</b></font><input name=\"email\" size=\"20\" maxlength=\"50\" class=\"input1\"></td>\n");
    echo ("</tr>\n");
    echo ("<tr bgcolor=$formBodyColor><td colspan=\"3\">\n");
    echo ("<font color=$formBodyText><b>$langMessage</b></font><br>\n");
    echo ("<center><textarea name=\"message\" cols=\"60\" rows=\"7\" class=\"input1\" style=\"width:500;height:100\" onFocus=\"if(this.value == this.defaultValue) this.value='';\">Selvom vi virker useriøse, ville vi gerne undgå at se lamme indlæg og unøvendig larm. Tænk dig om før du poster. :-)</textarea></center>\n");
    echo ("</td></tr>\n");
    echo ("<tr bgcolor=$formTailColor><td colspan=\"3\" align=\"right\">\n");
    echo ("<input type=\"submit\" value=\"$langSubmit\" class=\"input1\" style=\"width:150\">");
    echo ("</td></tr>\n");
    echo ("</table>\n");
    echo ("</form>\n");
    echo ("</center>\n");
    }

//******************************************************************************
// function displayMessage displays the $errorMessage error message.

function displayMessage($errorMessage,$msgType)
    {
    global $adminHeadColor;
    global $adminHeadText;
    global $adminBodyColor1;
    global $adminBodyText1;
    global $adminBodyColor2;
    global $adminBodyText2;
    global $langAdminError;
    global $langSystemError;
    global $langSystemMessage;
    global $langBsGuestbook;

   
    displayHeader();
    echo ("<table width=\"100%\" height=\"100%\"><tr><td width=\"100%\" valign=\"middle\" align=\"center\">");
    echo ("<table cellspacing=\"0\" border=\"0\" width=\"250\"><tr><td bgcolor=$adminHeadColor>");
    echo ("<font Color=$adminHeadText size=\"-3\">&nbsp; $langBsGuestbook</font><br>");
    echo ("</td></tr><tr><td bgcolor=$adminBodyColor1><font color=$adminBodyText1>");
    if ($msgType=="1") // Admin Message
        echo ("<i>&nbsp; $langAdminError</i>");
    if ($msgType=="2") // System Error
        echo ("<i>&nbsp; $langSystemError</i>");
    if ($msgType=="3") // System Message
        echo ("<i>&nbsp; $langSystemMessage</i>");
    echo ("</font>");
    echo ("</td></tr><tr><td bgcolor=$adminBodyColor2 align=\"center\">");
    echo ("<font color=$adminBodyText2>");
    echo ("<br><b>$errorMessage</b><br><br>");
    echo ("</font></td></tr></table><p>&nbsp;</p>\n");
    echo ("</td></tr></table>");
    displayFooter();
    exit;
    }


//******************************************************************************
// function standardizeText filters ambiguous chains in $str

function standardizeStoredText($str)
    {
    $str = str_replace("\\'", "'", $str);
    $str = str_replace("\\\"", "\"", $str);
    $str = htmlspecialchars($str);
    $str = str_replace("\n", "<br>", $str);
    $str = str_replace("$", "&#036;", $str);
    return $str;
    }
   

function standardizeDisplayedText($str)
    {
    return $str;
    }
   
function standardizeAdminText($str)
    {
    return $str;
    }
   
   
function seekHttp($rawText)
{   
    $pattern = array(
        "/http:\/\/((\w|\.|\?|\%|=|\/|-|~|#)*)/",
        "/mailto:((\w|\.|@|-)*)/");   
    $replacement = array(
        "<a href=\"http://\\1\" target=\"_blank\">http://\\1</a>",
        "<a href=\"mailto:\\1\">\\1</a>");
    $hyperLinkedText=preg_replace($pattern, $replacement, $rawText);   
       
    return $hyperLinkedText;
}


//******************************************************************************
// function Xfopen : opens a file $fileName and locks it
function Xfopen($fileName, $openMode, $sharing)
    {
    global $langOpenError;
    $fp=@fopen($fileName, $openMode);
    if (!$fp)
        {
        displayMessage($langOpenError,2);
        }
    if ($sharing==true)
        {
        $op=1;
        }
    else
        {
        $op=2;
        }
    if (!@flock($fp,$op))
        {
        @flock($fp,3);
        displayMessage("<i>flock</i> timeout",2);
        }
    return $fp;
    }

//******************************************************************************
// function Xfclose : unlocks the file $fp and closes it
function Xfclose($fp)
    {
    @flock($fp,3);
    @fclose($fp);
    }


//******************************************************************************
// function fullDisplay
function fullDisplay()
{
        global $displayStep,$displayBegin, $maxDisplay ;
        global $entryHeadColor,$entryHeadText, $entryBodyColor1,$entryBodyText1, $entryBodyColor2,$entryBodyText2 ;
        global $relativeScriptPath;
        global $index;
        global $archive_mail, $archive_name, $archive_text, $archive_date;
        global $allowAutoLink;

        // Checks if $displayBegin is not too large (Thanks to Ahmet Sabri ALPER <salper@olympos.org>)
        if ($displayBegin>$maxDisplay)
            {
            $displayBegin=$maxDisplay-$displayStep+1;
            }
           
        displayHeader();
       
        // Displays the entry form to enable the client to type a message.
        displayForm();

        if ($index==0)
            {
            displayFooter();
            return;
            }


        echo ("<p>&nbsp;</p>\n");

        // Message arrays are displayed here :
       
        echo "<center>\n";
       
        // Displaying all the entries.
       
        if ($displayStep==0)
            {
            $displayBegin=1;
            $displayStep=$index;
            }
       
        if ($displayBegin==1)
            {
            $startAt=$index % $displayStep;
            if ($startAt==0) $startAt=$displayStep;
            }
        else
            {
            $startAt=$displayBegin+$displayStep-1;
            }
       
       
        for ($msgNumber=$startAt ; $msgNumber>=$displayBegin ; $msgNumber--)
            {
            echo ("<table cellspacing=\"0\" border=\"0\" width=\"600\"><tr class=\"input1\"><td bgcolor=$entryHeadColor>");
            echo ("<font color=$entryHeadText size=\"-3\"><IMG src=\"http://www.drengenebynight.dk/images/dots.jpg\" align=absMiddle> &nbsp; $archive_date[$msgNumber] &nbsp; &nbsp;</font>");
            echo ("</td></tr><tr class=\"input1\"><td bgcolor=$entryBodyColor2>");
            echo ("<font Color=$entryBodyText1><b>");
            if ($archive_mail[$msgNumber]!="")
                {
                echo ("$msgNumber : <a title=\"".standardizeDisplayedText($archive_mail[$msgNumber])."\" href=\"mailto:".standardizeDisplayedText($archive_mail[$msgNumber])."\">".standardizeDisplayedText($archive_name[$msgNumber])."</a>");
                }
            else
                {
                echo ("$msgNumber : ".standardizeDisplayedText($archive_name[$msgNumber]));
                }
            echo ("</b></font>");
            echo ("</td></tr><tr class=\"input1\"><td bgcolor=$entryBodyColor2>");
            echo ("<font color=$formBodyText>");
            if ($allowAutoLink==1) echo ("<b>".seekHttp(standardizeDisplayedText($archive_text[$msgNumber]))."</b>");
            else echo ("<b>".standardizeDisplayedText($archive_text[$msgNumber])."</b>");
            echo ("</font></td></tr></table><br>\n");
            }
       
        echo ("<p>&nbsp;</p>\n");
       
        for($i=1;$i<=$index;$i=$nextEnd+1)
            {
            $nextBegin = $i;
           
            if ($i==1)
                {
                $nextEnd=$index % $displayStep;
                if ($nextEnd==0) $nextEnd=$displayStep;
                }
            else $nextEnd  = $i+$displayStep-1;
           
            if ($displayBegin==$nextBegin && $nextEnd!=$nextBegin) echo ("");
            else if ($displayBegin==$nextBegin && $nextEnd==$nextBegin) echo ("");
            else if ($nextEnd==$nextBegin) echo ("");
            else echo ("");   
            }
       
        echo "</center>\n";
        displayFooter();
}

//******************************************************************************

function readData($resetBegin)
{
    global $adminpassword;
    global $index;
    global $dataFile;
    global $archive_mail, $archive_name, $archive_text, $archive_date;
    global $displayBegin, $displayStep, $maxDisplay;

    // Includes automatically filled data arrays :
    $index = 0;
    $fout=Xfopen($dataFile, "r", true);
    include($dataFile);
    Xfclose($fout);
    // From now, $index will indicate the number of data entries.
   
    // Beginning of the data to be displayed, default = 1
        if (!isset($displayBegin)) $displayBegin="";
    if ($displayBegin=="" || $resetBegin==1)
        {
        $displayBegin = $index-$displayStep+1;
        if ($displayBegin<=0) $displayBegin=1;
        }
       
    // Sets the maximum that $displayBegin can reach
    $maxDisplay = $index;
}
//******************************************************************************




// If the Datafile does not exist, creates it.
if (!file_exists(${dataFile}))
    {
    $fout = Xfopen($dataFile, "w+", false);
    fputs($fout, "<?\n");
    fputs($fout, "\$adminpassword = \"noorcap\";\n");
    fputs($fout, "\$archive_name[++\$index] = \"drengenebynight.dk\";\n");
    fputs($fout, "\$archive_mail[  \$index] = \"dbn@pacroon.dk\";\n");
    fputs($fout, "\$archive_date[  \$index] = \"4th March 2003 - 12:00:00 PM\";\n");
    fputs($fout, "\$archive_text[  \$index] = \"drengenebynight.dk comment system - skriv en hilsen!\";\n");
    fputs($fout, "?>");
    Xfclose ($fout);
    }

// $admin could be set via Admin-Form by POST or via URL by GET
$admin=$HTTP_POST_VARS["admin"];
if (!isset($admin))
        $admin=$HTTP_GET_VARS["admin"];
else    // assign POST-variables from Admin-Form
        {
        $newPassword1=$HTTP_POST_VARS["newPassword1"];
        $newPassword2=$HTTP_POST_VARS["newPassword2"];
        $command=$HTTP_POST_VARS["command"];
        $index=$HTTP_POST_VARS["index"];
        }

if (!isset($admin))
    {
        // assing variables from Guestbook-From
        $name=$HTTP_POST_VARS["name"];
        $email=$HTTP_POST_VARS["email"];
        $message=$HTTP_POST_VARS["message"];
    if (!isset($name)) { $name=""; $message=""; }
    if ($name=="" || $message=="")
        {

        /****************************************************************************************
        * Use Case no 1-A                                    *
        *                                            *
        * This case is encountered when a client simply wants to add a message to the        *
        * guestbook. (Every variable is empty);                            *
        ************************************************************************************/
        readData(0);
        fullDisplay();
        exit;
        }
    else
        {
       
        /********************************************************************************
        * Use Case no 1-B                                *
        *                                        *
        * Case is encountered when a client has just filled in the appropriate fields    *
        * (name, mail, message).                            *
        *    $name    = "Some Name"                            *
        *    $email  = "Some@Email"                            *
        *    $message = "Some Message"                        *
        *        Simply add message in the top of all previous messages.        *
        ********************************************************************************/
       
        $position = filesize($dataFile);
       
        $fout = Xfopen($dataFile, "r+", false);
        fseek($fout,$position-2);
        $insert_msgdate = date( "d/m-Y - H:i:s" );
        $name=standardizeStoredText($name);
        $email=standardizeStoredText($email);
        $message=standardizeStoredText($message);
        fputs ($fout,"\$archive_name[++\$index] = \"$name\";\n");
        fputs ($fout,"\$archive_mail[  \$index] = \"$email\";\n");
        fputs ($fout,"\$archive_date[  \$index] = \"$insert_msgdate\";\n");
        fputs ($fout,"\$archive_text[  \$index] = \"$message\";\n");
        fputs ($fout,"\n?>");
        Xfclose($fout);
       
        // Sending a mail to $mailRecipient if $carbonCopy=1, with the subject $mailSubject.
        if ($carbonCopy==1)
            {
            $message = str_replace("<br>", "\n", $message);
            $mailBody = "From: $name <$email>\n$insert_msgdate\n\n$message";
            mail($mailRecipient,$mailSubject,$mailBody,"From: $email\nReply-to: $name <$email>");
            }
        if (strpos($refererpage, "?")==false) $page=$refererpage;
        else $page=substr($refererpage, 0, strpos($refererpage, "?"));
        header("Location: $page?");
        exit;
        }
    }
else
    {
    readData(0);
    if ($admin==$adminpassword)
        {
        if ($command=="")
            {
   
            displayHeader();
           
            /************************************************************************
            * Use Case no 2-A                            *
            *                                    *
            * Admin mode (The administrator can modify password, fields, or remove    *
            * messages).                                *
            *    $admin  = $adminpassword                    *
            *        Shows a password modification form.            *
            *        Shows all messages and enables to modify/delete them.    *
            ************************************************************************/
           
            echo("<center><h1>d r e n g e n e b y n i g h t . d k</h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size=\"5\">IDIOT!</font></h2><h4>$langGbAdmin</h4></center>\n");
            echo("<br>\n");            // Display the form which enables the admin to change his password

            echo ("<center><form method=\"POST\" action=\"$relativeScriptPath\">\n");

            echo ("<table cellspacing=\"0\" border=\"0\">\n");
            echo ("<tr><td bgcolor=$adminHeadColor colspan=\"2\"><font color=$adminHeadText>\n");
            echo ("&nbsp;<b>$langPassword</b>.</font></td></tr>\n");
            echo ("<tr><td align=right bgcolor=$adminBodyColor2>");
            echo ("<font color=$adminBodyText2>&nbsp; $langnewPassword</font></td>\n");
            echo ("<td align=left bgcolor=$adminBodyColor2>");
            echo ("<input type=\"password\" name=\"newPassword1\">&nbsp;</td></tr>\n");
            echo ("<tr><td align=\"right\" bgcolor=$adminBodyColor2>");
            echo ("<font color=$adminBodyText2>&nbsp; $langRetype</font></td>\n");
            echo ("<td align=left bgcolor=$adminBodyColor2>");
            echo ("<input type=\"password\" name=\"newPassword2\">&nbsp;</td></tr>\n");
            echo ("<tr><td bgcolor=$adminBodyColor1 colspan=2 align=\"center\">\n");
            echo ("<input type=\"hidden\" name=\"admin\" value=\"$admin\">\n");
            echo ("<input type=\"hidden\" name=\"command\" value=\"passwd\">\n");
            echo ("<input type=\"submit\" value=\"$langChPassword\"></td></tr>\n");
            echo ("</table>\n");
            echo ("</form></center>\n");
           
            echo("<br><hr><br>\n");// Message arrays are displayed here in forms in order to modify them :
           
            echo ("<center><form method=\"POST\" action=\"$relativeScriptPath\">\n");
           
            for ($i=1 ; $i<=$index ; $i++)
                {
                $msgNumber = $index - $i + 1;
                $str = str_replace("<br>", "\n", $archive_text[$msgNumber]);
                echo ("<table cellspacing=\"0\" cellpadding=\"3\"><tr><td colspan=\"4\" bgcolor=$adminHeadColor>\n");
                echo ("<font color=$adminHeadText><b>&nbsp;");
                echo ("$langEntry #$msgNumber</b>.</font>&nbsp;</td></tr>\n");
                echo ("<tr bgcolor=$adminBodyColor2>\n");
                    echo ("<td>&nbsp;<input type=\"checkbox\" name=\"keep${msgNumber}\" checked>&nbsp;</td>\n");
                echo ("<td><input name=\"name${msgNumber}\" value=\"".standardizeAdminText($archive_name[$msgNumber])."\"></td>\n");
                echo ("<td><input name=\"email${msgNumber}\" value=\"".standardizeAdminText($archive_mail[$msgNumber])."\"></td>\n");
                echo ("<td><input name=\"date${msgNumber}\" value=\"".standardizeAdminText($archive_date[$msgNumber])."\"></td>\n");
                echo ("<tr bgcolor=$adminBodyColor1>\n");
                echo ("<td colspan=\"4\" align=\"center\"><textarea cols=\"60\" rows=\"2\" name=\"message${msgNumber}\">".standardizeAdminText($str));
                echo ("</textarea></td>\n</tr></table>\n<br>\n");
                }
            echo ("<input type=\"hidden\" name=\"admin\" value=\"$admin\">\n");
            echo ("<input type=\"hidden\" name=\"index\" value=\"$index\">\n");
            echo ("<input type=\"hidden\" name=\"command\" value=\"modify\">\n");
            echo ("<input type=\"submit\" value=\"$langSubmitModif\">\n <br><b><font size=\"-2\" face=\"verdana\">Pacroon er den galeste h4x0r</font></b>");
            echo ("</form></center>\n");
            displayFooter();
            exit;
           
            }
        else if ($command=="passwd")
            {
            // Use Case no 2-B
            // Admin mode (The administrator is modifying his password.).
            //    $admin        = $adminpassword
            //    $newPassword1 = "New Password 1"
            //    $newPassword2 = "New Password 2"
            //         Check if $newPassword1 matches $newPassword2
            //         Set the $adminpassword line to :
            //         $adminpassword = "$newPassword1" in the dataFile
           
            if($newPassword1!=$newPassword2)
                {
                // The passwords doesn't match
                displayMessage("$langPassError",1);
                }
            else
                {
                // Rewrites the whole Datafile with the new password, and all the entries.
                $fout = Xfopen($dataFile, "w", false);
                fputs ($fout,"<?\n");
                fputs ($fout,"\$adminpassword = \"$newPassword1\";\n");
                for ($i=1 ; $i<=$index ; ++$i)
                    {
                    fputs ($fout,"\$archive_name[++\$index] = \"${archive_name[$i]}\";\n");
                    fputs ($fout,"\$archive_mail[  \$index] = \"${archive_mail[$i]}\";\n");
                    fputs ($fout,"\$archive_date[  \$index] = \"${archive_date[$i]}\";\n");
                    fputs ($fout,"\$archive_text[  \$index] = \"${archive_text[$i]}\";\n");
                    }
                fputs ($fout,"?>");
                Xfclose($fout);
                displayMessage("$langPassChanged",3);
                exit;
                }
            }
        else if ($command=="modify")
            {

            /********************************************************************************
            * Use Case no 2-C                                *
            *                                        *
            * Admin mode (The administrator is updating entries).                *
            *    $admin      = $adminpassword                        *
            *    $nameXXX    = "Modified name (no XXX)"                    *
            *    $emailXXX  = "Modified email (no XXX)"                    *
            *    $messageXXX = "Modified message (no XXX)"                *
            *    $keep      = "on" or ""                        *
            *     Check if $admin matches $adminpassword.                    *
            *     Rewrites ALL the fields except when $keepXXX = ""            *
            *    Rewrites the whole Datafile with the new password, and all the entries.    *
            ********************************************************************************/

            $fout = Xfopen($dataFile, "w", false);
            fputs ($fout,"<?\n");
            fputs ($fout,"\$adminpassword = \"$adminpassword\";\n");   
                for ($i=1 ; $i<=$index ; $i++)
                {
                // Get values from the form, and standardize them
                $variable=$HTTP_POST_VARS["name$i"];
                $name=standardizeStoredText("$variable");
                $variable=$HTTP_POST_VARS["email$i"];
                $email=standardizeStoredText("$variable");
                $variable=$HTTP_POST_VARS["date$i"];
                $insert_msgdate=standardizeStoredText("$variable");
                $variable=$HTTP_POST_VARS["message$i"];
                $message=standardizeStoredText("$variable");

                $variable=$HTTP_POST_VARS["keep$i"];
                if (${variable}!="")
                    {
                    fputs ($fout,"\$archive_name[++\$index] = \"$name\";\n");
                    fputs ($fout,"\$archive_mail[  \$index] = \"$email\";\n");
                    fputs ($fout,"\$archive_date[  \$index] = \"$insert_msgdate\";\n");
                    fputs ($fout,"\$archive_text[  \$index] = \"$message\";\n");
                    }
                }   
            fputs ($fout,"?>");
            Xfclose($fout);
           
            if (strpos($refererpage, "?")==false) $page=$refererpage;
            else $page=substr($refererpage, 0, strpos($refererpage, "?"));
            header("Location: $page?");
            exit;
            }
        }
    else
        {
       
        /************************************************
        * Use Case no 2-Z                *
        *                        *
        * If $admin does NOT match $adminpassword.    *
        *    $admin  != $adminpassword        *
        *    Error message : "Wrong Admin Password"    *
        ************************************************/

        displayMessage("$langWrongPassword",1);
        }
    }
?>
Avatar billede esoulman Nybegynder
04. marts 2003 - 23:45 #1
*lol*
Avatar billede Slettet bruger
04. marts 2003 - 23:48 #2
Ja.. ved nærmere eftertanke var det her ret lame..
Avatar billede esoulman Nybegynder
04. marts 2003 - 23:49 #3
Sorry, jeg kunne ikke lade være.. lav et nyt ? med links til koden i separate filer eller lignende... :)
Avatar billede tefcke Nybegynder
04. marts 2003 - 23:50 #4
tror ikke at der var særlig mange som lige havde lyst til at knalde 1600 liniers kode igennem for at finde din fejl ;-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester