Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help??? a good deal of questions 2

Status
Not open for further replies.

MAWarGod

Programmer
Feb 15, 2002
352
US
Code:
#!/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,$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";
}

# add a form to add a message to the file
print qq~<form 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">enter text<br>
<input type="submit" value="*Enter*">
</form>~;

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

use CGI;
my $q = new CGI;

open (MSG, ">>messages.txt");
print MSG "\n"
   . $q->param('ip') . ":::" . $q->param('name') . ":::" . $q->param('password') . ":::" .$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);
Code:
as passd in browser
?name=%3Cimg+src%3D+http%3A%2F%2F[URL unfurl="true"]www.freespaces.com%2Frealitygonewild%2Fwg1.jpg+align%3Dleft%3E%3Ccenter%3E%3C%2Fimg%3E%3Cbr%3E%3Ccenter%3E%3CFONT+FACE%3Dgaramond%3E%3CFONT+COLOR+%3Dsilver%3E%3CFONT+SIZE%3D4%3EWarGod+of++Venna%3Cbr%3E*Administrator*%3C%2Ffont%3E%3Cbr%3E*Never+say+Never*%3Cbr%3E%3CFONT+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.htmltarget%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[/URL]

as writen to file messages.txt
Code:
:::<img src= [URL unfurl="true"]http://www.freespaces.com/realitygonewild/wg1.jpg[/URL] 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=[URL unfurl="true"]http://www.chatvenues.com[/URL] target=_window>Chat Venues</a><br><a href=[URL unfurl="true"]http://www.geocities.com/resortofvenna/index.htmltarget=_window>Venna</a><FONT[/URL] COLOR =blue><FONT SIZE=3><center>:::MYPASSWORD:::?thathtmluserstringstripped?:::purple:::10:::10:::1:::1:::1167173680:::Help

ok with each post you have to input your name, color, ect. again and again
How do I make it remember all values but $msg
being that $msg would be newly inputed each post
Do I use a getdata or ???
also I would like to uptain IP and have it print to file where $ip is
and have the html user input stripped and added in this space ?thathtmluserstringstripped?


MA WarGod

I believe if someone can think it, it can be programmed
 
Kevin with reading that I have come up with this am I on the correct path here?

How you got that after reading the link I posted, I don't understand. You are not on the correct path. Use the CGI modlue to generate the form:

Code:
use CGI:
my $q = CGI->new:
print $q->header,
      $q->start_html,
      $q->start_form,
      etc
      etc

read the CGI documentation again.

- Kevin, perl coder unexceptional!
 
ok like done here

Code:
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') . ":::" . $q->param('CHATCOLOR') . ":::" . $q->param('refresh_rate') . ":::" . $q->param('histroy') . ":::" . $q->param('nopic') . ":::" . $q->param('verbose') . ":::" . time . ":::" . $q->param('msg');
close (MSG);

open (WHO, ">>userlog.who");
&strip_html
print WHO "\n"
   . $ip_addr . ":::" . $q->param('name');
close (WHO);

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

so I do the output the same way?

MA WarGod

I believe if someone can think it, it can be programmed
 
well, not really. I'm not sure what else to suggest to you. I've saide the same thing a few times: use the CGI module to generate the form code and to parse the data recieved from the form. The documentation explains that and there is an example at the end of the documentation.

- Kevin, perl coder unexceptional!
 
Code:
#!/usr/bin/perl


use CGI ':standard';

print header;
print start_html("demo chat");
print "<h1>demo chat</h1>\n";
        print_prompt();
do_work();
print_tail();
print end_html;

sub print_prompt {
   print start_form;
   print "<em>Name?</em><br>";
   print textfield('name');
   print "<p><em>Message</em><br>";
   print textfield('Comments');
   

   print "<p>",reset;
   print submit('Action','Send');
   print endform;
   print "<hr>\n";
}

sub do_work {
   my(@values,$key);


   foreach $key (param) {
      print "<strong>$key</strong> -> ";
      @values = param($key);
      print join(", ",@values),"<br>\n";
  }
}

sub print_tail {
   print <<END;
<hr>

END
}

Ok I see what You mean now My Browser for some reason would let Me see the end of the page it was cutting off the part You spoke of...

I use Opera and got the page veiwing correctly

Now is there a way to log the the chat within this type forum?

MA WarGod

I believe if someone can think it, it can be programmed
 
really this is cool I see some possibilities here

reads more


MA WarGod

I believe if someone can think it, it can be programmed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top