Hi,
Once again i have another problem regarding my message board lol. This time the 
message board is fine but i have made an admin so that it will read the contents of a 
text file where all the entries are printed to and display them into a <textarea> so 
that i can easily remove/change messages.
Below is the code for the script...

#!C:/Perl/bin/Perl.exe

$password = "andy";
$path = "admin.cgi";
$entries = "C:/localhost/test.txt";

if ($ENV{"REQUEST_METHOD"} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; }
else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
        ($name, $value) = split(/=/, $pair);
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        unless ($name eq "head" || $name eq "foot") {
                $value =~ s/<([^>]|\n)*>//g;
                $value =~ s/<//g;
                $value =~ s/>//g;
                $value =~ tr/+/ /;
        }
        $value =~ s/\n//g; # did sumthing here
        $in{$name} = $value;
}

if($in{'action'} eq ""){&login;}
elsif($in{'action'} eq "check"){&auth;}
elsif($in{'action'} eq "change"){&changeit;}
else{&login;}

sub login {
print "Content-type: text/html\n\n";
print <<DANE;
<html>
<head>
<meta http-equiv="Cache-Control" Content="No-Cache">
<title>Password Required</title>
<link rel="stylesheet" type="text/css" href="../../stylesheets/mboard/body.css">
</head>
<body>
<p class="subheading" align="center"><font color="#FF0000">Sorry but you need a 
password to view my message board</font></p>
<form method="post" action="$path">
<div align="center">
  <center>
<table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse" 
width="330" id="AutoNumber1">
  <tr>
    <td width="163">
    <p class="ident">Password: </td>
    <td width="218"><input type="password" name="pass" size="30"></td>
  </tr>
  <tr>
    <td width="163">&nbsp;</td>
    <td width="218"><input type="submit" value="Submit" name="submit">
    <input type="hidden" name="action" value="check"></td>
  </tr>
</table>
  </center>
</div>
</form>
</body>
</html>
DANE
exit;
}

sub auth {
       if ($in{'pass'} eq $password) {
              &main;
              exit;
       }
       elsif ($in{'pass'} ne $password) {
             print "Content-type: text/html\n\n";
             print "<html><body text=\"silver\" bgcolor=\"black\">INCORRECT password. 
LOL.</body>\n";
             exit;
       }
}

sub main {
open(DATA, "$entries");
flock DATA, 2;
@data = <DATA>;
close(DATA);

print "Content-type: text/html\n\n";
print <<DANE;
<html>
<head>
<title>Administration of Message Board</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form method="post" action="$path">
  <div align="center"> 
    <p><b>Administration Page</b></p>
    <p align="left"><font size="2">Add or Remove Entries:</font></p>
    <p align="left"> 
      <textarea name="w00t" cols="70" rows="10">@data</textarea>
   <input type="hidden" name="action" value="change">
    </p>
    <p align="left">
      <input type="submit" name="Submit" value="Change It">
    </p>
  </div>
</form>
</body>
</html>
DANE
exit;
}

sub changeit {
open(DATA,">$entries");
flock DATA, 2;
print DATA "$in{'w00t'}";
close(DATA);

&main;
exit;
}

....the problem that i am faced with is when it prints to the file called test.txt a 
little symbol comes up where the next line should be. I tried to paste the symbol onto 
here but it just goes to the next line without showing it. Here is what the text file 
looks like:
Andrew#Hello<<Funny symbol goes here>>James#Nice Board

This is how i would LIKE it too look like:
Andrew#Hello
James#Nice Board

ANY HELP YOU COULD SEND ME WOULD BE MUCH APPRECIATED :o)

Andrew


Reply via email to