×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

$in (inroom) in a drop down menue?????can it be done?
3

$in (inroom) in a drop down menue?????can it be done?

$in (inroom) in a drop down menue?????can it be done?

(OP)
sub FindOnline{
dbmopen(%li,"$htmlpath/login",0644);
my $time = time;
$li{$cookie{'CHATUSER'}} = $time;
foreach $i (keys %li){
$mt = $time - $li{$i};
  ($mt < ($refresh * 2))?((push(@occ,$i))&&($uo++)):(($uol=1)&&(delete($li{$i})));
  }
dbmclose %li;
&cuol;
$in{'inroom'} = join(" | ",@occ);
}

ok sorta defined

I get it to print out this way

<p align="left"><font color="white"><b>In Room:</b>  in(inroom)</td>

it works fine til say there's like 20 people in room and it
starts misshaping banner so is there a way I can put these in a drop down box? I have tried for two days I know its probably simple html but I can not from it to work

RE: $in (inroom) in a drop down menue?????can it be done?

2

CODE

$in{'inroom'} = '<select name="inroom">' . "\n"
   . "<option>" . join ("</option>\n<option>",@occ)
   . "</option>\n</select>";

output

CODE

<select name="inroom">
<option>some name</option>
<option>
some name</option>
<option>
some name</option>
<option>
some name</option>
<option>
some name</option>
<option>
</option>
</select>

-------------
Cuvou.com | The NEW Kirsle.net

RE: $in (inroom) in a drop down menue?????can it be done?

Actually, that way would leave a blank option at the end. Here's a less of a one-liner way to do it...

CODE

$in{'inroom'} = '<select name="inroom">' . "\n";
foreach (@occ) {
   $in{'inroom'} .= "<option>$_</option>\n";
}
$in{'inroom'} .= '</select>';

That would leave no extra HTML (no blank options).

-------------
Cuvou.com | The NEW Kirsle.net

RE: $in (inroom) in a drop down menue?????can it be done?

(OP)
Thank You Kirsle

CODE

<select name="inroom">
<option>some name</option>
<option>some name</option>
<option>some name</option>
<option>some name</option>
<option>some name</option>
<option></option>
</select>

CODE

sub FindOnline{
dbmopen(%li,"$htmlpath/login",0644);
my $time = time;
$li{$cookie{'CHATUSER'}} = $time;
foreach $i (keys %li){
$mt = $time - $li{$i};
  ($mt < ($refresh * 2))?((push(@occ,$i))&&($uo++)):(($uol=1)&&(delete($li{$i})));
  }
dbmclose %li;
&cuol;

$in{'Occupants'} = '<select name="Occupants">' . "\n";
foreach (@occ) {
   $in{'Occupants'} .= "<option>$_</option>\n";
}
$in{'Occupants'} .= '</select>';

}
is there a way either in this sub or makeing a new sub
when some name 1 is talking to some name 2 that I can give value to each like I think $sn1, $sn2, $sn3, $sn4, $sn5

each string I guess would = the values that are generated in the dropdown

or would I have to open dbm and have it writen to a file
I am lost on how to do this

MA WarGod

I believe if someone can think it, it can be programmed

RE: $in (inroom) in a drop down menue?????can it be done?

CODE

$in{'Occupants'} = '<select name="Occupants">' . "\n";
foreach (@occ) {
   $in{'Occupants'} .= qq~<option value="$foo">$_</option>\n~;
}
$in{'Occupants'} .= '</select>';

where $foo can be used to change the values of each option item. Of course like this all items will have the value of $foo, using a hash linked to @occ values would work well:

CODE

$in{'Occupants'} = '<select name="Occupants">' . "\n";
foreach (@occ) {
   $in{'Occupants'} .= qq~<option value="$hash{$_}">$_</option>\n~;
}
$in{'Occupants'} .= '</select>';

- Kevin, perl coder unexceptional!

RE: $in (inroom) in a drop down menue?????can it be done?

(OP)
ok the value $hash or $foo would give say $u to be able to appear to be speaking to $hash or $foo

CODE

open(MSGT,">$htmlpath/mymgfile.cgi.tmp");

print MSGT qq|<TABLE WIDTH="92%" border=0 cellpadding=0 cellspacing=0><TR><TD><font color="$c"><b>$u:</b>$in{'m'}</TD></TR></TABLE>\n|;
$u = user1 or you in chat
in('m') is the message
$c is color code

so do I add $hash

CODE

sub WriteToChat{
(!$in{'m'})&&(exit);
&GetCookies;
if($in{'color'}){
  $c = $in{'color'};
  }
else{
  $c = $cookie{'CHATCOLOR'};
  }
$u = $cookie{'CHATUSER'};
if($flock){
  open(LCK,">$htmlpath/mylockfile");
  flock(LCK,2);
  }

open(MSGT,">$htmlpath/mymsgfile.cgi.tmp");

print MSGT qq|<TABLE WIDTH="92%" border=0 cellpadding=0 cellspacing=0><TR><TD><font color="$c"><b>$u:</b>$in{'m'}</TD></TR></TABLE>\n|;

open(MSG,"<$htmlpath/mymsgfile.cgi");
while(<MSG>){
  last if $. > 50;
  print MSGT;
  }
close MSG;
close MSGT;


rename("$htmlpath/mymsgfile.cgi.tmp","$htmlpath/mymsgfile.cgi");

if($flock){
  flock(LCK,8);
  close LCK;
  }


}

ok here's My sub I tryed added $hash maybe I am not following this

confussed

MA WarGod

I believe if someone can think it, it can be programmed

RE: $in (inroom) in a drop down menue?????can it be done?

I think I'm more confused than you are, maybe Kirsle will understand your question.

- Kevin, perl coder unexceptional!

RE: $in (inroom) in a drop down menue?????can it be done?

(OP)

CODE

<select name="inroom">
<option>some name1</option>
<option>some name2</option>
<option>some name3</option>
<option>some name4</option>
<option>some name5</option>
<option></option>
</select>

ok when you enter the chat you are $U
so I want to make it so $u or default user can talk each otheir user or some name 1,2,3,4, ect.

like some name1 says to some name2 hello
the way its phased now when $u speaks in forum $u speaks to ALL in forum

CODE

|<TABLE WIDTH="92%" border=0 cellpadding=0 cellspacing=0><TR><TD><font color="$c"><b>$u:</b>says to $user1 $in{'m'}</TD></TR></TABLE>\n|;
<b>$u:</b>says to $user1
being the name selected in dropdown

so I guess My question is can you define $foo or $hash while or after it returns data???


I hope I fromed that correctly and am not confussing You.

MA WarGod

I believe if someone can think it, it can be programmed

RE: $in (inroom) in a drop down menue?????can it be done?

bomb

- Kevin, perl coder unexceptional!

RE: $in (inroom) in a drop down menue?????can it be done?

where do you get the list of names that will populate the select menu?

<select name="inroom">
<option>some name</option>
<option>some name</option>
<option>some name</option>
<option>some name</option>
<option>some name</option>
<option></option>
</select>

you will have to have a file  or table that has those names stored in it to dynamically insert them into the menu as you build it.

- Kevin, perl coder unexceptional!

RE: $in (inroom) in a drop down menue?????can it be done?

(OP)

CODE

sub Getlogin{
&GetCookies;
if(!$cookie{'CHATUSER'}){
  print "\n";
  $in{'UserName'} = $ENV{'REMOTE_USER'};
  &PageOut("$htmlpath/defaultlogin");
  exit;
  }
else{
  $time = time;
  dbmopen(%li,"$htmlpath/login",0644);
  $li{$cookie{'CHATUSER'}} = $time;
  dbmclose %li;
  }
}

sub login{
$in{'UserName'} = $ENV{'REMOTE_USER'};
&PageOut("$htmlpath/defaultlogin");
exit;
}

sub FindOnline{
dbmopen(%li,"$htmlpath/login",0644);
my $time = time;
$li{$cookie{'CHATUSER'}} = $time;
foreach $i (keys %li){
$mt = $time - $li{$i};
  ($mt < ($refresh * 2))?((push(@occ,$i))&&($uo++)):(($uol=1)&&(delete($li{$i})));
  }
dbmclose %li;
&cuol;

$in{'Occupants'} = '<select name="Occupants">' . "\n";
foreach (@occ) {
   $in{'Occupants'} .= qq~<option value="$hash{$_}">$_</option>\n~;
}
$in{'Occupants'} .= '</select>';

}

sub cuol{
($in{'command'} ne 'body')&&(return);
($uo > (3))&&(&PError("User limited reached. Unable to log on"));
}
sub PageOut{
#format
local($file) = @_;
open(OUT,"$file");
while(<OUT>){
$_ =~ s/in\((.+?)\)/$in{$1}/g;
print;
}
close OUT;
}
1;

CODE

sub getdata{
local($usecgi)=@_;
if($usecgi){
use CGI;
$query = new CGI;
@names = $query->param;
foreach $i (@names){
  @values = $query->param("$i");
  if($#values > 0){
  $in{$i} = join('\0',@values);
  }
  else{
  $in{$i} = $query->param("$i");
  }
 
  }
}
else{
# Read in text
  if ($ENV{'REQUEST_METHOD'} eq "GET") {
    $in = $ENV{'QUERY_STRING'};
  } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    for ($i = 0; $i < $ENV{'CONTENT_LENGTH'}; $i++) {
      $in .= getc;
    }
  }

  @in = split(/&/,$in);

  foreach $i (0 .. $#in) {
    # Convert plus's to spaces
    $in[$i] =~ s/\+/ /g;

    # Convert %XX from hex numbers to alphanumeric
    $in[$i] =~ s/%(..)/pack("c",hex($1))/ge;

    # Split into key and value.
    $loc = index($in[$i],"=");
    $key = substr($in[$i],0,$loc);
    $val = substr($in[$i],$loc+1);
    $in{$key} .= '\0' if (defined($in{$key})); # \0 is the multiple separator
    $in{$key} .= $val;
    }
}
}

plus in this sub I am haveing trouble with $loc = index($in[$i],"="); "=" stops the name input of = key or sign

so tags or html in like

CODE

<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><br><FONT FACE =garamond><FONT COLOR =blue><FONT SIZE=3>
can not be put in forum it stops at <img src= of the = sign or key

MA WarGod

I believe if someone can think it, it can be programmed

RE: $in (inroom) in a drop down menue?????can it be done?

Where have you defined the values for %hash that you are using here:

CODE

foreach (@occ) {
   $in{'Occupants'} .= qq~<option value="$hash{$_}">$_</option>\n~;
}

if you had been using "strict" as you should be, but appear not to be, your script would exit with an error.

maybe you should just be doing this:

CODE

foreach (@occ) {
   $in{'Occupants'} .= qq~<option value="$_">$_</option>\n~;
}


The entire getdata subroutine is rather unusual.

- Kevin, perl coder unexceptional!

RE: $in (inroom) in a drop down menue?????can it be done?

(OP)
Kevin I can post full script on My forum if You need a clear look at what I am trying to do? trying to follow this sites rules..so not posting email or contact
this way I can lock the forum to provent script getting to otheir chat sites

http://www.chatvenues.com/scgi-bin/forums/main.cgi?board=askcvstaff

MA WarGod

I believe if someone can think it, it can be programmed

RE: $in (inroom) in a drop down menue?????can it be done?

No,I don't want to see the entire script. I will be glad to help you with questions you post here though.

If the project interested me I would consider it, but a perl based internet chat script is a good 10+ years behind the times and is something I would have worked on long ago. In fact I wrote some commercial perl based bulletin board/chat scripts back in the day when they were still in vogue and did well selling them for a few years.

But the internet has turned over a few times since then and perl has really become the ugly cousin for stuff like that, where PHP is now the prom queen and IM's replaced chat scripts years ago.

You keep working on it and it will be your baby, plus you are learning as you go, so version 2 will probably be much better written if you stick with perl and continue to learn.

- Kevin, perl coder unexceptional!

RE: $in (inroom) in a drop down menue?????can it be done?

(OP)
Thank You I feel like I am slaming My head off a wall here lol..

but sometimes I'll have that

and Yes I am trying to learn just getting fusterated I guess...

all I want is a simple html chat yes its years behide the time and I guess thats why there are none out there anymore and this is why I am trying to make one I can run on the web shell I have

see the old ones only had two frame well with .net now they need 3 frames I have the old magma software but its so out dated and I know it can be done in perl/cgi with some java tossed in but its forming it..so I learn nods

MA WarGod

I believe if someone can think it, it can be programmed

RE: $in (inroom) in a drop down menue?????can it be done?

(OP)
scraps scripts goes back to drawing board

MA WarGod

I believe if someone can think it, it can be programmed

RE: $in (inroom) in a drop down menue?????can it be done?

>> scraps scripts goes back to drawing board

This time start using "warnings" and "stict"

CODE

#!/usr/bin/perl

use strict;
use warnings;

and start with the CGI module as the foundation for your script. Dump all this ancient baggage:

CODE

else{
# Read in text
  if ($ENV{'REQUEST_METHOD'} eq "GET") {
    $in = $ENV{'QUERY_STRING'};
  } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    for ($i = 0; $i < $ENV{'CONTENT_LENGTH'}; $i++) {
      $in .= getc;
    }
  }

  @in = split(/&/,$in);

  foreach $i (0 .. $#in) {
    # Convert plus's to spaces
    $in[$i] =~ s/\+/ /g;

    # Convert %XX from hex numbers to alphanumeric
    $in[$i] =~ s/%(..)/pack("c",hex($1))/ge;

    # Split into key and value.
    $loc = index($in[$i],"=");
    $key = substr($in[$i],0,$loc);
    $val = substr($in[$i],$loc+1);
    $in{$key} .= '\0' if (defined($in{$key})); # \0 is the multiple separator
    $in{$key} .= $val;
    }
}
}

logging off for now.....

- Kevin, perl coder unexceptional!

RE: $in (inroom) in a drop down menue?????can it be done?

(OP)

CODE

#/usr/bin/perl

use strict;
use warnings;
use CGI qw(:standard);


my $filename = '\path\to\my\file.txt';

&noFileData() unless(defined(param('fileData')));

&updateFile();

sub noFileData
{
    open FILE, "<$filename" or die "Cannot open $filename: $!";
    my @lines = <FILE>;
    close FILE;
    
    form(join("",@lines))
    ;
    exit;
}

sub updateFile
{
    my $name = param('fileData');
    
    open FILE, ">$filename" or die "Cannot open $filename: $!";
    print FILE $name;
    close FILE;
    
    form($name);
    print "<BR><CENTER>File Updated at ".localtime()."</CENTER>\n";
}

sub form
{
my $name = shift;
print qq ~Content-type: text/html

<HTML>
<HEAD>
<TITLE> test names </TITLE>
<BODY  TEXT = '#FFFFFF' LINK = '#FFCC66' VLink = '#99CC66' ALINK = '#FF0000'>
<center><img src = ""></a>
<CENTER>
<FORM METHOD="post" ACTION="cvchat.cgi">
<TEXTAREA NAME=fileData ROWS=8 COLS=50 WRAP>$name</TEXTAREA>
<BR><BR>
<INPUT TYPE="submit">
</FORM>
</CENTER>
~;
}

ok thanks I made it this far
from a old thread on here where someone was helping now if I can this to work lol on My server lol

MA WarGod

I believe if someone can think it, it can be programmed

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close