PDA

View Full Version : CGI question


MAWarGod
12-27-2006, 02:36 PM
how do I get $user_stripped to equel $user but be stripped of the html


as passd in browser
?name=%3Cimg+src%3D+http%3A%2F%2Fwww.freespaces.com%2Frealitygonewild%2Fwg1.jpg+align%3Dleft%3E%3Cce nter%3E%3C%2Fimg%3E%3Cbr%3E%3Ccenter%3E%3CFONT+FACE%3Dgaramond%3E%3CFONT+COLOR+%3Dsilver%3E%3CFONT+S IZE%3D4%3EWarGod+of++Venna%3Cbr%3E*Administrator*%3C%2Ffont%3E%3Cbr%3E*Never+say+Never*%3Cbr%3E%3CFO NT+COLOR+%3Dsilver%3E%3CFONT+SIZE%3D4%3E%3Ca+href%3Dhttp%3A%2F%2Fwww.chatvenues.com+target%3D_window %3EChat+Venues%3C%2Fa%3E%3Cbr%3E%3Ca+href%3Dhttp%3A%2F%2Fwww.geocities.com%2Fresortofvenna%2Findex.h tmltarget%3D_window%3EVenna%3C%2Fa%3E%3CFONT+COLOR+%3Dblue%3E%3CFONT+SIZE%3D3%3E%3Ccenter%3E&password=MYPASSWORD&refresh_rate=10&histroy=10&nopic=1&verbose=1&CHATCOLOR=purple&msg=Help








209.34.12.0:::<img src= http://www.freespaces.com/realitygonewild/wg1.jpg align=left><center></img><br><center><FONT FACE=garamond><FONT COLOR =silver><FONT SIZE=4>WarGod of Venna<br>*Administrator*</font><br>*Never say Never*<br><FONT COLOR =silver><FONT SIZE=4><a href=http://www.chatvenues.com target=_window>Chat Venues</a><br><a href=http://www.geocities.com/resortofvenna/index.htmltarget=_window>Venna</a><FONT COLOR =blue><FONT SIZE=3><center>:::MYPASSWORD:::?thathtmluserstringstripped?:::purple:::10:::10:::1:::1:::1167173680:::Help






#!/usr/bin/perl


# open messages
open (MSG, "messages.txt");
my @lines = <MSG>;
@lines = reverse @lines;
close (MSG);
chomp @lines;

print "Content-Type: text/html\n\n";
foreach my $line (@lines) {
my ($ip_addr,$user,$password,$user_stripped,$cc,$rr,$his,$np,$ver,$timestamp,$msg) = split(/:::/, $line, 11);
print "<TABLE WIDTH='100%' border='0' cellpadding='0' cellspacing='0'><TR><TD><font color=$cc>[$timestamp]<b>$user says:</b>$msg<p></font><P></TD></TR></TABLE>\n\n";
}
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
# add a form to add a message to the file
print qq~<form method="POST" name="add" action="testi.cgi">
<input type="text" name="name" value="Anonymous" size="20">Name<br>
<input type="text" name="password" size="20">Password<br>
<input type="text" size="2" value="10" name="refresh_rate">refresh<br>
<input type="text" size="2" value="10" name="histroy">histroy<br>
<input type="checkbox" checked="checked" value="1" name="nopic">nopic<br>
<input type="checkbox" checked="checked" value="1" name="verbose">verbose<br>
<td nowrap><select name="CHATCOLOR" size="1">
<option value="white" selected>white</option>
<option value="blue">blue</option>
<option value="blueviolet">blueviolet</option>
<option value="chocolate">chocolate</option>
<option value="darkgreen">darkgreen</option>
<option value="dimgray">dimgray</option>
<option value="fuchsia">fuchsia</option>
<option value="magenta">magenta</option>
<option value="maroon">maroon</option>
<option value="mediumblue">mediumblue</option>
<option value="navy">navy</option>
<option value="olive">olive</option>
<option value="orangered">orangered</option>
<option value="purple">purple</option>
<option value="scarlet">scarlet</option>
<option value="sienna">sienna</option>
</select></td>Text Color:</td><br>
<input type="text" name="msg">entery text<br>
<input type="submit" value="*Enter*">
</form>~;


##############################
# add.cgi::: #
##############################

use CGI;
my $q = new CGI;
my $ip_addr = $ENV{'REMOTE_ADDR'};
my $new_text = strip_html( $old_text );
open (MSG, ">>messages.txt");
print MSG "\n"
. $ip_addr . ":::" . $q->param('name') . ":::" . $q->param('password') . ":::" . strip_html($q->param('user_stripped')) . ":::" . $q->param('CHATCOLOR') . ":::" . $q->param('refresh_rate') . ":::" . $q->param('histroy') . ":::" . $q->param('nopic') . ":::" . $q->param('verbose') . ":::" . time . ":::" . $q->param('msg');
close (MSG);

sub strip_html {
my $text = shift;
$text =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs;
return $text;
}









also how do I form this to remember all values but $msg each post so that user doesn't fill in name, color ect.

this is kinda what I am trying to do

print qq~<font color=$cc>welcome<b>$user_stripped</b><form method="POST" name="add" action="testi.cgi">
<input type="hidden" name="name" value="$user">
<input type="hidden" name="name" value="$user_stripped">
<input type="hidden" name="password"value="$password">
<input type="hidden" name="refresh_rate" value="$rr">
<input type="hidden" name="histroy" value="$his">
<input type="hidden" name="nopic" value="$np">
<input type="hidden" name="verbose" value="$ver">
<input type="hidden" name="CHATCOLOR" value="$cc">
<input type="text" name="msg">enter text<br>
<input type="submit" value="*Enter*">
</form>~;









and make this like login.cgi or login sub or ?

#!/usr/bin/perl
print "Content-Type: text/html\n\n";
# add a form to add a message to the file
print qq~<form method="POST" name="add" action="testi.cgi">
<input type="text" name="name" value="Anonymous" size="20">Name<br>
<input type="text" name="password" size="20">Password<br>
<input type="text" size="2" value="10" name="refresh_rate">refresh<br>
<input type="text" size="2" value="10" name="histroy">histroy<br>
<input type="checkbox" checked="checked" value="1" name="nopic">nopic<br>
<input type="checkbox" checked="checked" value="1" name="verbose">verbose<br>
<td nowrap><select name="CHATCOLOR" size="1">
<option value="white" selected>white</option>
<option value="blue">blue</option>
<option value="blueviolet">blueviolet</option>
<option value="chocolate">chocolate</option>
<option value="darkgreen">darkgreen</option>
<option value="dimgray">dimgray</option>
<option value="fuchsia">fuchsia</option>
<option value="magenta">magenta</option>
<option value="maroon">maroon</option>
<option value="mediumblue">mediumblue</option>
<option value="navy">navy</option>
<option value="olive">olive</option>
<option value="orangered">orangered</option>
<option value="purple">purple</option>
<option value="scarlet">scarlet</option>
<option value="sienna">sienna</option>
</select></td>Text Color:</td><br>
<input type="text" name="msg">entery text<br>
<input type="submit" value="*Enter*">
</form>~;









can someone please help been struggling with this project for months

KevinADC
12-27-2006, 05:35 PM
You answered your own question and don't see the answer staring you in the face.

MAWarGod
12-27-2006, 09:19 PM
#!/usr/bin/perl


# open messages
open (MSG, "messages.txt");
my @lines = <MSG>;
@lines = reverse @lines;
close (MSG);
chomp @lines;

print "Content-Type: text/html\n\n";
foreach my $line (@lines) {
my ($ip_addr,$user,$password,$user_stripped,$cc,$rr,$his,$np,$ver,$timestamp,$msg) = split(/:::/, $line, 11);
print "<TABLE WIDTH='100%' border='0' cellpadding='0' cellspacing='0'><TR><TD><font color=$cc>[$timestamp]<b>$user says:</b>$msg<p></font><P></TD></TR></TABLE>\n\n";
}
print qq~<font color=$cc>welcome<b>$user_stripped</b><form method="POST" name="add" action="testi.cgi">
<input type="hidden" name="name" value="$user">
<input type="hidden" name="name" value="$user_stripped">
<input type="hidden" name="password"value="$password">
<input type="hidden" name="refresh_rate" value="$rr">
<input type="hidden" name="histroy" value="$his">
<input type="hidden" name="nopic" value="$np">
<input type="hidden" name="verbose" value="$ver">
<input type="hidden" name="CHATCOLOR" value="$cc">
<input type="text" name="msg">enter text<br>
<input type="submit" value="*Enter*">
</form>~;


##############################
# add.cgi::: #
##############################

use CGI;
my $q = new CGI;
my $ip_addr = $ENV{'REMOTE_ADDR'};
my $new_text = strip_html( $old_text );
open (MSG, ">>messages.txt");
print MSG "\n"
. $ip_addr . ":::" . $q->param('name') . ":::" . $q->param('password') . ":::" . strip_html($q->param('user_stripped')) . ":::" . $q->param('CHATCOLOR') . ":::" . $q->param('refresh_rate') . ":::" . $q->param('histroy') . ":::" . $q->param('nopic') . ":::" . $q->param('verbose') . ":::" . time . ":::" . $q->param('msg');
close (MSG);

sub strip_html {
my $text = shift;
$text =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs;
return $text;
}





when I use the code this way it still doesn't remember from post to post