Click to See Complete Forum and Search --> : Help needed


invision
02-15-2004, 07:11 AM
I was hoping to add this moderate.cgi and ModeratedChat.cgi to my site to allow people to chat and I can moderate. Ive looked at almost every possible problem but can't seem to get it working, any help?

http://www.michaelmcg.co.uk/cgi-bin/ModeratedChat.cgi :
#!/usr/bin/perl @INC=('../lib', @INC); require 'web.pl'; $Port = 4005; %Form =
&getStdin; &beginHTML("Rob Dougan Chat", "bgcolor=ffffff"); $Form{'name'} = "foobar"
unless $Form{'name'}; ($ttl, $numes, @users) = &get_status; $ttl = sprintf("%.02f",
$ttl / 3600); foreach (@users) { ($name, $when) = split(/ /); $Users{$name}++;
} print "<b>Message life:</b> $ttl hours<br>
\n",
"<b>Number</b> of total messages: $numes<p>\n",
"Lisr of <b>users</b> with messages:\n";
undef @users;
foreach $person (sort keys %users) {
push(@users, ucfirst($person));
}
print join(", ",@users),"<p>\n";
if ($Form{'change'}) {
foreach $one (keys %Form) {
if($one =-/^when_(\d+)/) {
$ww = $1;
&do_update($Form{"who_$ww"}, $ww, $Form{"what+$ww});
}
}
}

&display;
exit;

sub display {
print "<a href=\"/cgi-bin/ModeratedChat.cgi\">ModeratedChat</a><p>\n",
"<hr>
\n"; &transcript;
}

sub get_status {
local(@wg, $ttl, $nmes);

chop(@wg ='/export/home/jdw/bookweb/bin/caller $Port misl status');

$ttl = shift @wg;
$nmes = shift @wg;
return ($ttl, $nmes, @wg);
}

sub transcript {
local(@out, $i, $x, $tod, $tod_time, $tod_date);

chop(@out='/export/home/jdw/bookweb/bin/caller $Port misl transcript');

print "<form method=post action=\"/cgi-bin/moderate.cgi\">\n";
foreach $one (@out) {
if($one =-/^\#\#(\d+)\#\#\d+ (.*)::/) {

$tod = $1;
$who = $2;
$tod_date = &pretty_time($tod);

$tod_time = &pretty_time($tod);

if ($gotone) {
print "<p>\n";
$gotone=0;
}
print "<input type=hidden name=\"who_$tod\" value=\"$who\">\n",
print "<input type=hidden name=\"who_$tod\" value=\"$tod\">\n",
print "<b>On $tod_date $todtime</b> $who said:<br>\n";
print "<textarea rows=5 cols=40 name=\"what_$tod\">\n";

}
else
{
print "$one\n";
$gotone=1;
}
}
if ($gotone) {
print "</textarea><p>\n";
}
print "<input type=submit name=\"change\" value=\"Make Changes\"><br>\n",
"<input type=submit name=\"nochange\" value=\"No Changes\"><br>\n";
print"</form>\n";
}

# mmddyy
sub pretty_date {
local($x) = $_[0];
local(@t) = localtime($x);
return sprintf("%d/%d/%d", $t[4]+1,$t[3],$t[5]);
}
sub pretty_time {
local($x) = $_[0];
local(@t) = localtime($x);
return sprintf("%02d:%02d %s", $t[2]>12?$t[2]-12:$t[2],$t[1], $t[2]>12?"PM":"AM");
}

sub do_update {
local($who, $when, $what) = @_;
$args = join(" ", $Port, "misl", "update");
open(PI, "| /export/home/jdw/bookweb/bin/caller $args");
print PI "$who\n",
"$when\n",
"$what\n";
close(PI);
}




http://www.michaelmcg.co.uk/cgi-bin/moderate.cgi :

#!/usr/bin/perl

@INC=('../lib', @INC);
require 'web.pl';

$Port = 4005;

%Form = &getStdin;
&beginHTML("Moderated Chat", "bgcolor=ffffff");

&process if $Form{'process'};

&display
exit;

sub process {

return unless length($Form{'body'})>0;

$args = join(" ", $Port, "$ThisHost",
"\"$Form{'name'}|"");
open(PI, "| /export/home/jdw/bookweb/bin/caller $args");
print PI $Form{'body'}
close PI
}

sub display {

print "\n",
"<title>robdougan.net Chat</title>\n",
"\n",
"<a href=\"/cgi-bin/moderate.cgi\">Link visible only for Moderator",
" - click here to be Moderator</a><p>\n">,
"<form method=\"post\"\n",
" action=\"/cgi-bin/ModeratedChat.cgi\">\n",
"Enter Message here:<br>\n",
"<textarea name=\"body\" rows=5 cols=40>\n",
"</textarea><br>\n",
"<input type=\"hidden\" name=\"process\" value=1>\n",
"<input type=\"hidden\" name=\"name\" ", ",",",","value=\"$Form{'name'}\">\n",
"<input type=\"submit\" value=\"Transmit\">\n",
"</form>\n",
"<form method=\"post\"\n",
" action=\"/cgi-bin/moderate.cgi\">\n",
"<input type=\"hidden\" name=\"process\" value=1>\n",
"<input type=\"hidden\" name=\"name\" ", ",",",","value=\"$Form{'name'}\">\n",
"<input type=\"submit\" value=\"Refresh\">\n",
"</form>\n";

&transcript;

}

sub transcript {

local(@out, $i, $x, $tod, $tod_times, $tod_date);

chop(@out='/export/home/jdw/bookweb/bin/caller $Port $ThisHost transcript');

foreach $one (@out) {
if ($one =-/^\#\#(\d+)\#\#\d+ (.*)::/) {
$tod = $1;
$who = $2;
$tod_date = &pretty_time($tod);

$tod_time = &pretty_time($tod);

print "<b>On $tod_date $tod_time</b> $who said:<br>\n";
}
else
{
print "$one<br>\n";
}
}
}
#mmddyy
sub pretty_date {
local($x) = $_[0];
local(@t) = localtime($x);
return sprintf("%02d/%02d/%02d", $t[4]+1,$t[3],$t[5];

}

sub pretty_time {
local($x) = $_[0];
local(@t) = localtime($x);
return sprintf("%02d:%02d %s", $t[2]>12?$t[2]-12:$t[2],$t[1], $t[2]>12?"PM":"AM");

}



Thanks for any help


Michael.

Jeff Mott
02-15-2004, 02:14 PM
can't seem to get it working, any help?You'll need to be *much* more specific. You have not told us what error messages you get. You have not told us what should happen. And you have not told us what should not happen. You can't expect us to spend hours tracing through pages of poorly formatted code.

invision
02-16-2004, 08:36 AM
Apologies.

Basically it doesn't run on my domain name which is hosted by SupaNames. Im not sure what the problem is. Just doesn't appear to be there.
There's a little info here : http://www.supanames.com/support/scripts.html