BBS-Universal
view release on metacpan or search on metacpan
lib/BBS/Universal/SysOp.pm view on Meta::CPAN
$ch = $self->{'sysop_tokens'}->{$key}->($self);
} else {
$ch = $self->{'sysop_tokens'}->{$key};
}
$text =~ s/\[\%\s+$key\s+\%\]/$ch/gi;
} ## end elsif ($text =~ /\[\%\s+$key\s+\%\]/)
} ## end foreach my $key (keys %{ $self...})
$text = $self->ansi_decode($text);
return ($text);
} ## end sub sysop_detokenize
sub sysop_menu_choice {
my $self = shift;
my $choice = shift;
my $color = shift;
my $desc = shift;
$self->{'debug'}->DEBUG(['Start SysOp Menu Choice']);
my $response;
if ($choice eq 'TOP') {
$response = charnames::string_vianame('BOX DRAWINGS LIGHT ARC DOWN AND RIGHT') . charnames::string_vianame('BOX DRAWINGS LIGHT HORIZONTAL') . charnames::string_vianame('BOX DRAWINGS LIGHT ARC DOWN AND LEFT') . "\n";
} elsif ($choice eq 'BOTTOM') {
$response = $self->news_title_colorize(charnames::string_vianame('BOX DRAWINGS LIGHT ARC UP AND RIGHT') . charnames::string_vianame('BOX DRAWINGS LIGHT HORIZONTAL') . charnames::string_vianame('BOX DRAWINGS LIGHT ARC UP AND LEFT')) . "\n";
} else {
$response = $self->ansi_decode(charnames::string_vianame('BOX DRAWINGS LIGHT VERTICAL') . '[% BOLD %][% ' . $color . ' %]' . $choice . '[% RESET %]' . charnames::string_vianame('BOX DRAWINGS LIGHT VERTICAL') . ' [% ' . $color . ' %]' . charna...
}
$self->{'debug'}->DEBUG(['End SysOp Menu Choice']);
return ($response);
} ## end sub sysop_menu_choice
sub sysop_showenv {
my $self = shift;
$self->{'debug'}->DEBUG(['Start SysOp ShowENV']);
my $MAX = 0;
my $text = '';
foreach my $e (keys %ENV) {
$MAX = max(length($e), $MAX);
}
foreach my $env (sort(keys %ENV)) {
if ($ENV{$env} =~ /\n/g || $env eq 'WHATISMYIP_INFO') {
my @in = split(/\n/, $ENV{$env});
my $indent = $MAX + 4;
$text .= '[% BRIGHT WHITE %]' . sprintf("%${MAX}s", $env) . "[% RESET %] = ---\n";
foreach my $line (@in) {
if ($line =~ /\:/) {
my ($f, $l) = $line =~ /^(.*?):(.*)/;
chomp($l);
chomp($f);
$f = uc($f);
if ($f eq 'IP') {
$l = colored(['bright_green'], $l);
$f = 'IP ADDRESS';
}
my $le = 11 - length($f);
$f .= ' ' x $le;
$l = colored(['green'], uc($l)) if ($l =~ /^ok/i);
$l = colored(['bold red'], 'U') . colored(['bold bright_white'], 'S') . colored(['bold bright_blue'], 'A') if ($l =~ /^us/i);
$text .= colored(['bold bright_cyan'], sprintf("%${indent}s", $f)) . " = $l\n";
} else {
$text .= "$line\n";
}
} ## end foreach my $line (@in)
} else {
my $orig = $ENV{$env};
my $new;
if ($orig =~ /(256color)/) {
$new = colored(['red'], '2') . colored(['green'], '5') . colored(['yellow'], '6') . colored(['cyan'], 'c') . colored(['bright_blue'], 'o') . colored(['magenta'], 'l') . colored(['bright_green'], 'o') . colored(['bright_blue'], 'r');
$orig =~ s/$1/$new/g;
} elsif ($orig =~ /(truecolor)/) {
$new = colored(['red'], 't') . colored(['green'], 'r') . colored(['yellow'], 'u') . colored(['cyan'], 'e') . colored(['bright_blue'], 'c') . colored(['magenta'], 'o') . colored(['bright_green'], 'l') . colored(['bright_blue'], 'o') . ...
$orig =~ s/$1/$new/g;
} elsif ($orig =~ /(\d+\.\d+\.\d+\.\d+)/) {
$new = '[% BRIGHT GREEN %]' . $1 . '[% RESET %]';
$orig =~ s/$1/$new/g;
} elsif ($orig =~ /(ubuntu)/i) {
$new = '[% ORANGE %]' . $1 . '[% RESET %]';
$orig =~ s/$1/$new/g;
} elsif ($orig =~ /(redhat)/i) {
$new = colored(['bright_red'], $1);
$orig =~ s/$1/$new/g;
} elsif ($orig =~ /(fedora)/i) {
$new = colored(['bright_cyan'], $1);
$orig =~ s/$1/$new/g;
} elsif ($orig =~ /(mint)/i) {
$new = colored(['bright_green'], $1);
$orig =~ s/$1/$new/g;
} elsif ($orig =~ /(zorin)/i) {
$new = colored(['bright_white'], $1);
$orig =~ s/$1/$new/g;
} elsif ($orig =~ /(wayland)/i) {
$new = colored(['bright_yellow'], $1);
$orig =~ s/$1/$new/g;
}
$text .= colored(['bold white'], sprintf("%${MAX}s", $env)) . ' = ' . $orig . "\n";
} ## end else [ if ($ENV{$env} =~ /\n/g...)]
} ## end foreach my $env (sort(keys ...))
$self->{'debug'}->DEBUG(['End SysOp ShowENV']);
return ($text);
} ## end sub sysop_showenv
sub sysop_scroll {
my $self = shift;
$self->{'debug'}->DEBUG(['Start SysOp Scroll']);
my $response = TRUE;
print $self->{'ansi_meta'}->{'attributes'}->{'RESET'}->{'out'}, "\rScroll? ";
if ($self->sysop_keypress(ECHO, BLOCKING) =~ /N/i) {
$response = FALSE;
} else {
print "\r" . clline;
}
$self->{'debug'}->DEBUG(['End SysOp Scroll']);
return (TRUE);
} ## end sub sysop_scroll
sub sysop_list_bbs {
my $self = shift;
$self->{'debug'}->DEBUG(['Start SysOp List BBS']);
my $sth = $self->{'dbh'}->prepare('SELECT * FROM bbs_listing_view ORDER BY bbs_name');
$sth->execute();
my @listing;
my ($id_size, $name_size, $hostname_size, $poster_size) = (2, 4, 14, 6);
while (my $row = $sth->fetchrow_hashref()) {
push(@listing, $row);
$name_size = max(length($row->{'bbs_name'}), $name_size);
$hostname_size = max(length($row->{'bbs_hostname'}), $hostname_size);
$id_size = max(length('' . $row->{'bbs_id'}), $id_size);
$poster_size = max(length($row->{'bbs_poster'}), $poster_size);
} ## end while (my $row = $sth->fetchrow_hashref...)
my $table = Text::SimpleTable->new($id_size, $name_size, $hostname_size, 5, $poster_size);
$table->row('ID', 'NAME', 'HOSTNAME/PHONE', 'PORT', 'POSTER');
$table->hr();
foreach my $line (@listing) {
$table->row($line->{'bbs_id'}, $line->{'bbs_name'}, $line->{'bbs_hostname'}, $line->{'bbs_port'}, $line->{'bbs_poster'});
}
$self->sysop_output($table->round('BRIGHT BLUE')->draw());
print 'Press a key to continue... ';
$self->sysop_keypress();
$self->{'debug'}->DEBUG(['End SysOp List BBS']);
return (TRUE);
} ## end sub sysop_list_bbs
sub sysop_edit_bbs {
my $self = shift;
$self->{'debug'}->DEBUG(['Start SysOp Edit BBS']);
my @choices = (qw( bbs_id bbs_name bbs_hostname bbs_port ));
$self->sysop_prompt('Please enter the ID, the hostname/phone, or the BBS name to edit');
my $search;
$search = $self->sysop_get_line(ECHO, 50, '');
return (FALSE) if ($search eq '');
print "\r", cldown, "\n";
my $sth = $self->{'dbh'}->prepare('SELECT * FROM bbs_listing_view WHERE bbs_id=? OR bbs_name=? OR bbs_hostname=?');
( run in 0.776 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )