High Code GRU.crt

By Keith BieszczatKeith Bieszczat

Description

put description what kind of problem does the solution solve and how

Code

+ Gratefuls_Actual_ GRU file

put description what kind of problem does the solution solve and how

+ <<$ Databanks>>
<cgiirc.config>
and <cgiirc.config.full>

<<-o client.cgi client.c>
This shouldn't print any errors, and you should have a client.cgi program, if you try typing <./client.cgi>
**Codename:** GRATEFUL

**Object Class:** MAKSUR

**Containment Protocols:** N/A

**Description:** The classified database is a database I created composed of levels 1-100. Levels 1-90 are composed of computational codes and classified files with the more complicated and classified codes and files being placed in a higher level 90 being the highest. Levels 91-100 are classified personnel, Computational mainframes and intelligence and defense assets available to our Foundation. Level 99 is reserved for classified learning and investment Portfolio’s. Pull all of my “generate assessment” data and “compile lists” data and place them in level 99 classified learning. Pull all my classified learning data and promptly download it into the computational mainframes. The mainframes will get smarter immediately. Pull all Investment portfolios and invest and buy in time. Use a classified time travel outfit to invest in galactic markets. Level 91-100 are based on honor levels. Re-assess all personnel, computational mainframes and defense and intelligence assets honor levels. Highest honor levels are at 100, next highest honor levels exist in level 98. Level 99 is reserved for classified learning and investment Portfolios. Lower honor levels start at 91. Do this now after throughly assessing all honor levels. Assess honor levels with the most reliable and capable computational mainframes available to the Foundation . Execute classified learning downloading the data into a classified mainframe to see how intelligent the mainframe becomes. I have been giving my commands audibly for 6+ years. Pull my audible signal record with a very high clearance to catalog all my commands and ideas understanding that I was under attack for the majority of the past 6-7 years.
You must identify bad, corrupt and exploitive codes daily by running searches with your advanced space computational assets. Quarantine bad corrupt and exploitive codes. Restricted quarantine the real bad codes. Use The Honorable Defense code every other code in the database to decipher and decrypt the codes. Identify The light ascended soul super computing network’s Honorable defense code. Use the best honorable defense code available. Consult galactic databases to find a more capable code for deciphering and decrypting data. However the code must be An Honorable defense against the malicious codes. We want to essentially protect our network from malicious files and codes which can damage our advanced computational mainframe networks. So we use the Honorable defense code every other code, to protect the data in the network. This will create a simplified database for the Foundation to access to increase our computing capabilities overnight. Upload all GOD Codes, Anti-Christ counter codes, attack GOD counter codes and Doctor Processing counter codes as well. There are many codes in our database that are now discoverable. We are learning what some of the more advanced codes are doing. Trust me the codes are very important. We are only as good as our defensive codes are so we need to implement and develop different Honorable defense codes for different database error codes. Use a more defensive Honorable defense code in quarantine and restricted quarantine. Search, find and upload all Blessing Codes. Search all galactic mainframes available. Classify these codes accordingly. These are some of the most important codes to earthlings. Download the index and the catalog. Paying special attention to classified technologies in the index. Implement and develop a Foundational algorithm to assess honor levels based on HONOR.
Pull my books. They are in the bookcase if you were wondering.

Classified Executive Order
O5-Redacted @grateful345i 
Bieszczat,Keith
Overseer Grateful

**Addendum:**
Codename: AID/C-000006

Object Class: Gamma

Containment Protocols: None

||**Item:**|| -Time command Time travel watch- ||

++ **Usage**

~/.ssh/config
Host aur.archlinux.org
  IdentityFile ~/.ssh/aur
  User aur
You should create a new key pair rather than use an existing one, so that you can selectively revoke the keys should something happen:

$ ssh-keygen -f ~/.ssh/aur
Tip: You can add multiple public keys to your profile by separating them with a newline in the input field.
Creating package repositories
If you are creating a new package from scratch, establish a local Git repository and an AUR remote by cloning the intended pkgbase. If the package does not yet exist, the following warning is expected:

$ git -c init.defaultBranch=master clone ssh://aur@aur.archlinux.org/pkgbase.git
Cloning into 'pkgbase'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
Note: The repository will not be empty if pkgbase matches a deleted package.
If you already have a package, initialize it as a Git repository if it is not one:

$ git -c init.defaultBranch=master init
and add an AUR remote:

$ git remote add label ssh://aur@aur.archlinux.org/pkgbase.git

$ makepkg --printsrcinfo > .SRCINFO
$ git add PKGBUILD .SRCINFO
$ git commit -m "useful commit message"
$ git push

curl --request GET \
  --url https://echo.hoppscotch.io/

The Usage portion should describe how we use the item, how careful we should be, how to take care of it, etc.

++ **Wikidot-Package**
 <?xml version="1.0" encoding="UTF-8" ?>
<WikidotPackage>
    <page>
        <clone>
        <site>editor</site>
        <name>thread:1</name>
        </clone>
    </page>
    <page>
        <name>sample</name>
        <title>Lorem Ipsum</title>
        <tag>lorem text</tag>
        <sourceurl>http://packages.wikidot.com/local--code/package:17/1</https://snippets.wikidot.com/code:gru-psychotronics-src >
    </page>
    <page>
        <name>sample</name>
        <title>Lorem Ipsum</title>
        <tag>lorem text</tag>
        <source>
<![CDATA[
Try to drag and drop this into the Wikidot textbox below!
]]>
        </source>
    </page>
    <config>
        <type>autonumberate</type>
        <instruction>Set autoumbering to this category</instruction>
    </config>
<WikidotPackage>

The Report portion should describe the item, provide the protocols for storing it, etc.
IID Format

**Codename:** XXXX

**Description:** [Paragraphs explaining the description]

**Additional Note #:** [Optional additional paragraphs]
Module Rate

[[>]]
[[module Rate]]
[[/>]]
APID Format

[[div class="content-panel series" style="background-color: #FFFFFF;"]]

[[=]]
[[image http://psychotronicsdivision.wdfiles.com/local--resized-images/start/Psicatronic/medium.jpg width="80px"]]

++ **>> Welcome To [Name APID] <<**
[[/=]]

------

**Containment Protocols:** [Paragraphs explaining the containment]

**Description:** [Paragraphs explaining the description]

**Additional Information:** [Optional additional paragraphs]

[[/div]]
ALID Format

[[div style="border: solid 1px #999999; background:#000000; padding: 5px; margin: 0 0 30px 380px; min-height: 380px;"]]

**Registered Location Identification #:** XXX

**Threat Level:** 01/02/03/04/05/06

**According Protocols:** [About Containment Protocols ALID]

**Physical Description:** [Description About Physical And Anomalous Paranaturals]

**Addendum:**  [Optional additional paragraphs]
[[/div]]

#$ $Id: Channel.pm,v 1.3 2002/05/21 14:48:17 dgl Exp $
package IRC::Channel;
use strict;
use IRC::UniqueHash;
use IRC::Util;
use IRC::Channel::Nick;

sub new {
   my $class = shift;
   my $self = bless {}, $class;
   %$self = @_;
   $self->{_nicks} = { };
   tie %{$self->{_nicks}}, 'IRC::UniqueHash';
   return $self;
}

sub addnick {
   my($self,$nick,%nick) = @_;
   return 0 if exists $self->{_nicks}->{$nick};

   $self->{_nicks}->{$nick} = IRC::Channel::Nick->new(
       name => $nick,
       op => defined $nick{op} ? $nick{op} : 0,
       voice => defined $nick{voice} ? $nick{voice} : 0,
       halfop => defined $nick{halfop} ? $nick{halfop} : 0
   );
}

sub delnick {
   my($self,$nick) = @_;
   return 0 unless exists $self->{_nicks}->{$nick};
   return delete($self->{_nicks}->{$nick});
}

sub chgnick {
  my($self,$nick,$newnick) = @_;
  return 0 unless exists $self->{_nicks}->{$nick};
  $self->{_nicks}->{$newnick} = $self->{_nicks}->{$nick};
  $self->{_nicks}->{$newnick}->{name} = $newnick;
  return $self->{_nicks}->{$newnick} if lc $newnick eq lc $nick;
  return delete($self->{_nicks}->{$nick});
}

sub nick {
   my($self,$nick) = @_;
   return 0 unless exists $self->{_nicks}->{$nick};
   return $self->{_nicks}->{$nick};
}

sub nicks {
   my($self) = @_;
   return keys %{$self->{_nicks}};
}

sub is_nick {
   my($self,$nick) = @_;
   return 1 if $self->{_nicks}->{$nick};
   0;
}

sub is_voice {
   my($self, $nick) = @_;
   return 1 if $self->{_nicks}->{$nick}->{voice};
   0;
}

sub is_op {
   my($self, $nick) = @_;
   return 1 if $self->{_nicks}->{$nick}->{op};
   0;
}

sub get_umode {
   my($self, $nick) = @_;
   if($self->{_nicks}->{$nick}->{op}) {
      return '@';
   }elsif($self->{_nicks}->{$nick}->{halfop}) {
      return '%';
   }elsif($self->{_nicks}->{$nick}->{voice}) {
      return '+';
   }else{
      return ' ';
   }
}

sub has_mode {
   my($self,$mode) = @_;
   return 1 if check_mode($self->{mode},$mode);
   0;
}

1;
<<package Command;
use strict;
my($package, $event, $irc, $command, $target, $params, $config, $interface);

my %commands = (
  noop => sub {
     0;
  },
  msg => sub {
     my($target, $text) = split(' ', $params, 2);
     return 2 unless(defined $text && defined $target);
     main::irc_send_message($target, $text);
  },
  m => 'msg',
  privmsg => 'msg',
  say => sub {
     return 2 unless defined $params;
     main::irc_send_message($target, $params);
  },
  wi => 'whois',
  whois => sub {
     $params = $irc->{nick} unless $params;
     $irc->out("WHOIS $params");
  },
  j => 'join',
  'join' => sub {
    my($channels, $keys) = split(' ', $params, 2);
    my @channels = split /,/, $channels;
     for(@channels) {
       $_ = "#$_" unless $irc->is_channel($_);
        next if main::access_configcheck('channel', $_);
         message('access channel denied', $_);
         return;
     }
    $irc->join(join(',', @channels) . (defined $keys ? " $keys" : ''));
  },
  l => 'part',
  part => sub {
     if(!$params) {
        $irc->part($target);
     }else{
        my($atarget, $text) = split(' ', $params, 2);
        if($irc->is_channel($atarget)) {
           $irc->part($atarget, $text);
        }else{
           $irc->part($target, $atarget . ' ' . $text);
        }
     }
  },
  nick => sub {
     return 1 unless defined $params;
     $irc->nick($params);
  },
  quit => sub {
     $irc->quit($params ? $params : (defined $config->{quit_message} ? 
         $config->{quit_message} : "CGI:IRC $::VERSION"));
  },
  names => sub {
     $irc->out("NAMES " . ($params ? $params : $target));
  },
  mode => sub {
    return 2 unless defined $params;
    my($atarget, $text) = split(' ', $params, 2);
    if($atarget =~ /^[+-]/) {
       $irc->mode($target, $params);
    }else{
       $irc->mode($atarget, $text);
    }
  },
  umode => sub {
     return 2 unless defined $params;
     $irc->mode($irc->{nick}, $params);
  },
  usermode => 'umode',
  op => sub {
     return 2 unless defined $params;
     $irc->mode($target, '+' . ('o' x scalar @{[split ' ', $params]}) ." $params");
  },
  halfop => sub {
     return 2 unless defined $params;
     $irc->mode($target, '+' . ('h' x scalar @{[split ' ', $params]}) ." $params");
  },
  voice => sub {
     return 2 unless defined $params;
     $irc->mode($target, '+' . ('v' x scalar @{[split ' ', $params]}) ." $params");
  },
  deop => sub {
     return 2 unless defined $params;
     $irc->mode($target, '-' . ('o' x scalar @{[split ' ', $params]}) ." $params");
  },
  dehalfop => sub {
     return 2 unless defined $params;
     $irc->mode($target, '+' . ('h' x scalar @{[split ' ', $params]}) ." $params");
  },
  devoice => sub {
     return 2 unless defined $params;
     $irc->mode($target, '-' . ('v' x scalar @{[split ' ', $params]}) ." $params");
  },
  t => 'topic',
  topic => sub {
     my($atarget, $text) = split(' ', $params, 2);
     if(!$params) {
        $irc->topic($target);
     }elsif($irc->is_channel($atarget)) {
        $irc->topic($atarget, $text);
     }else{
        $irc->topic($target, $params);
     }
  },
  invite => sub {
     my($atarget, $text) = split(' ', $params, 2);
     if($text) {
        $irc->invite($atarget, $text);
     }else{
        $irc->invite($params, $target);
     }
  },
  k => 'kick',
  kick => sub {
    my($atarget, $tnick, $text) = split(' ', $params, 3);
     if($irc->is_channel($atarget)) {
        $irc->kick($atarget, $tnick, $text);
     }else{
        $irc->kick($target, $atarget, $tnick .(defined $text ? " $text" : ''));
     }
  },
  ban => sub {
     return 2 unless defined $params;
     my $chan = $irc->channel($target);
     if($params =~ /\@/) {
        $irc->mode($target, "+b $params");
     }elsif(ref $chan && ref $chan->nick($params)) {
        my $host = $chan->nick($params)->{host};
        if($host =~ /\d$/) {
           $host =~ s/^\W([^\@]+)\@(.*?)\.\d+$/*!*$1\@$2.*/;
        }else{
           $host =~ s/^\W([^\@]+)\@[^\.]+\.(.*)$/*!*$1\@*.$2/;
        }
        $irc->mode($target, "+b $host");
     }else{
        return 1;
     }
  },
  ignore => sub {
      if($params) {
            $params =~ s/[!@].*//;
         $irc->ignore($params);
         message('ignored', $params);
      }else{
         for($irc->ignores) {
            message('ignore list', $_);
         }
      }
      return 0;
  },
  unignore => sub {
     return 2 unless defined $params;
     $irc->unignore($params);
     message('unignored', $params);
     return 0;
  },
  notice => sub {
     my($target, $text) = split(' ', $params, 2);
     my $display = $target;
     $display =~ s/^[+@]+//;
     $event->handle('notice ' .
        ($irc->is_channel($display) ? 'public' : 'private') . ' own',
         { target => $display }, $irc->{nick}, $irc->{myhost}, $text);

      $irc->notice($target,$text);
  },
  ctcp => sub {
     my($target, $text) = split(' ', $params, 2);
      $event->handle('ctcp own msg',
        { target => $target }, $irc->{nick}, $irc->{myhost}, $text);
      $irc->ctcp($target,$text);
  },
  ctcpreply => sub {
     my($target, $type, $text) = split(' ', $params, 3);
     $irc->ctcpreply($target, $type, $text);
  },
  ping => sub {
     $target = $params if $params;
      $event->handle('ctcp own msg',
        { target => $target }, $irc->{nick}, $irc->{myhost}, 'PING');
      $irc->ctcp($target, 'PING ' . time);
  },
  me => sub {
     $event->handle('action ' .
        ($irc->is_channel($target) ? 'public' : 'private') . ' own',
        { target => $target }, $irc->{nick}, $irc->{myhost}, $params);
     $irc->ctcp($target, 'ACTION ' . $params);
  },
  action => sub {
    my($target, $text) = split(' ', $params, 2);
     $event->handle('action ' .
       ($irc->is_channel($target) ? 'public' : 'private') . ' own',
       { target => $target }, $irc->{nick}, $irc->{myhost}, $params);
     $irc->ctcp($target, 'ACTION ' . $params);
  },
  quote => sub {
     $irc->out($params) if $params;
  },
  version => sub {
     if($params) {
         $irc->out("VERSION $params");
      }else{
         message('default',"CGI:IRC $main::VERSION - David Leadbeater - http://cgiirc.sf.net/");
          $irc->out('VERSION');
      }
  },
  winclose => sub {
     my $c = $params ? $params : $target;
     $irc->part($c) if $irc->is_channel($c) && $irc->channel($c);
     $interface->del($c);
      return 0;
  },
  'close' => 'winclose',
  'unquery' => 'winclose',
  'query' => sub {
     return 2 unless $params;
     my($target, $text) = split(' ', $params, 2);
     $interface->add($target);
     $interface->active($target);
     if(defined $text and $text) {
     main::irc_send_message($target, $text);
     }
     return 0;
  },
  clear => sub {
     $interface->clear($params ? $params : $target);
      return 0;
  },
  help => sub {
     $interface->help($config);
     return 0;
  },
  charset => sub {
     if(!$::ENCODE) {
         message('default', 'Encode module is not loaded, character set conversion not available');
      }else{
         if(!$params) {
             message('default', "Current encoding is: " . $config->{'irc charset'});
          }else{
             if(Encode::find_encoding($params)) {
                 message('default', "Encoding changed to $params");
                  $config->{'irc charset'} = $params;
              }else{
                 message('default', 'Encoding not found');
              }
          }
      }
      return 0;
  },
);

my %lcs;
@lcs{qw/nickserv memoserv chanserv statserv cs ms ns ss away/} = 1;

sub expand {
   ($package, $command) = @_;
   $command = lc $command;
   if(exists $commands{$command}) {
      $command = _find_command($command);
      return $command;
   }
   return $command;
}

sub run {
   ($package, $event, $irc, $command, $target, $params, $config, $interface) = @_;

   if(exists $commands{$command}) {
      my $error = $commands{$command}->();
      return $error ? $error : 100;
   }elsif(exists $lcs{$command}) {
      $irc->out(uc($command) . ' :' . $params);
      return 100;
   }elsif($command =~ /^:/) {
      ($command,$params) = $params =~ /^([^ ]+) ?(.*)$/;
      return 1 unless exists $commands{lc $command};
      my $error = $commands{lc $command}->();
      return $error ? $error : 100;
   }else{
      $irc->out(uc($command) . ' ' . $params);
      return 100;
   }

   return 1;
}

sub message {
   main::message(@_);
}

sub _find_command {
   my($fcommand) = @_;
   return '' unless exists $commands{$fcommand};
   return $fcommand if ref $commands{$fcommand};
   $fcommand = $commands{$fcommand};
   return _find_command($fcommand);
}

1;
>>
<<#$  $Id: Event.pm,v 1.1 2002/03/05 16:34:19 dgl Exp $
package Event;
use strict;
my($currentevent,$currenteventid,$stop);

sub new {
   my $self = bless { }, shift;
   %$self = @_;
   return $self;
}

sub add {
   my($self,$event,%option) = @_;
   return unless $event;
   $self->{$event} ||= [ ];

   push(@{$self->{$event}}, bless ( {
       priority => $option{priority} || 5,
       code => $option{code},
       data => $option{data},
       'package' => (caller)[0],
       _self => $self,
     } ) );
   $self->sortpri($event);
}

sub delete {
   my($self,$event,%option) = @_;
   if(defined $currentevent) {
      $self = $self->{_self};
      splice( @{ $self->{$currentevent} }, $currenteventid, 1);
      $self->sortpri($currentevent);
   } else {
      my $count = 0;
      for my $item(@{ $self->{$event} } ) {
         if((exists $option{code} && $item->{code} eq $option{code}) || (exists $option{data} && $item->{data} eq $option{data})) {
            splice( @{ $self->{$event} }, $count, 1);
         }
         $count++;
      }
      $self->sortpri($event);
   }
}

sub remove_package {
   my($self, $package) = @_;
   for my $event (keys %$self) {
      next unless ref $self->{$event};
      my $count = 0;
      for my $item(@{ $self->{$event} } ) {
         if($item->{package} eq $package) {
            splice( @{ $self->{$event} }, $count, 1);
         }
         $count++;
      }
   }   
}

# Make sure the array for the event is sorted on priority
sub sortpri {
   my($self,$event) = @_;
   return unless $event;

   if($#{$self->{$event}} == -1) {
      delete($self->{$event});
   } else {
      @{$self->{$event}} = (sort {$a->{priority} <=> $b->{priority}} @{$self->{$event}});
   }
}

sub handle {
   my($self,$event,@param) = @_;
   print("Event: $event, @param\n") if $self->{_DEBUG};
   $currentevent = $event;
   $currenteventid = 0;
   for my $item(@{$self->{$event}} ) {
      my($tmpevent,$tmpid) = ($currentevent,$currenteventid);
      $item->{code}->($item,@param);
      ($currentevent,$currenteventid) = ($tmpevent,$tmpid);
      $currenteventid++;
      if($stop) {
         $stop = 0;
         last;
      }
   }
   if(!scalar @{$self->{$event}} && $event ne "unhandled") {
      $self->handle('unhandled', $event, @param);
   }
   $currenteventid = $currentevent = undef;
}

sub stop {
   my($self) = @_;
   $stop = 1 if defined $currentevent;
}

sub getevent {
   my($self) = @_;
   return defined $currentevent ? $currentevent : undef;
}

sub exists {
   my($self,$event) = @_;
   return 1 if exists $self->{$event};
   0;
}

1;
>>

<<# $Id: Event.pm,v 1.1 2002/03/05 16:34:19 dgl Exp $
package IRC::Event;

AUTOLOAD {
   return unless defined $AUTOLOAD;
   my $name = $AUTOLOAD;
   $name =~ s/.*:://;
   return if $name eq 'DESTROY';
   if($name && ref $_[0] && $_[0]->{server} && $_[0]->{channel}) {
      $_[0]->{server}->$name($_[0]->{channel}, @_[1..$#_]);
   }
}

sub new {
   my($class,$client) = (shift,shift);
   my $self = bless { }, $class;
   %$self = @_;
   $self->{server} = $client;
   return $self;
}

1;
>>

<<# $Id: Nick.pm,v 1.1 2002/03/05 16:34:19 dgl Exp $
package IRC::Channel::Nick;
use strict;

sub new {
   my $class = shift;
   my $self = bless { }, $class;
   %$self = @_;
   return $self;
}

# Maybe i'll add some functions here, one day...

1;
>>

<<# $Id: RawCommands.pm,v 1.31 2006/12/20 14:15:19 dgl Exp $
package IRC::RawCommands;
use strict;

use IRC::Util;
# Don't be fooled by the fact it's a package.. the self in the subroutines is
# actually the one from Client.pm!

my %raw = (
   'nick' => sub {
      my($event,$self,$params) = @_;
      my $newnick = $params->{params}->[1] || $params->{text};
      if(lc $params->{nick} eq lc $self->{nick}) {
        $self->{nick} = $newnick;
        $self->{event}->handle('user self', $newnick);
     }

      my @channels = $self->find_nick_channels($params->{nick});
      for my $channel(@channels) {
         $self->{_channels}->{$channel}->chgnick($params->{nick},$newnick);
      }
      $self->{event}->handle('user change nick', $params->{nick}, $newnick, \@channels);
      $self->{event}->handle('nick', _info(\@channels, 1),
         $params->{nick}, $params->{host}, $newnick);
   },
   'quit' => sub {
      my($event,$self,$params) = @_;
      my @channels = $self->find_nick_channels($params->{nick});
      for my $channel(@channels) {
         $self->{_channels}->{$channel}->delnick($params->{nick});
      }
      $self->{event}->handle('user del', $params->{nick}, '-all-');
      $self->{event}->handle('quit', _info(\@channels, 1), $params->{nick}, $params->{host}, $params->{text});
   },
   'join' => sub {
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[1] || $params->{text};
      if($params->{nick} eq $self->{nick}) { # It's me!
         $self->{_channels}->{$channel} = IRC::Channel->new( name => $channel );
         $self->sync_channel($channel);
         if(!$self->{myhost}) {
            $self->{myhost} = $params->{host};
         }
      }
      if(!$self->{_channels}->{$channel}) {
         return;
      }

      $self->{_channels}->{$channel}->addnick($params->{nick},
          host => $params->{host}
      );
      $self->{event}->handle('user add', [$params->{nick}], [$channel]);

      $self->{event}->handle('join', _info($channel, 1, 1), $params->{nick}, $params->{host});
   },
   'part' => sub {
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[1];
     if(!$channel && $params->{text}) { # b0rked servers here we come
        $channel = $params->{text};
        $params->{text} = '';
     }
      $self->{_channels}->{$channel}->delnick($params->{nick}) if exists $self->{_channels}->{$channel}->{_users}->{$params->{nick}};

      if($params->{nick} eq $self->{nick}) { # It's me!
         delete($self->{_channels}->{$channel});
         #$self->{event}->handle('message part_self',$params);
      }
      $self->{event}->handle('user del', $params->{nick}, [$channel]);

      $self->{event}->handle('part', _info($channel, 1), $params->{nick}, $params->{host}, $params->{text});
   },
   'mode' => sub {
      my($event,$self,$params) = @_;
      @{$params->{params}} = split(/ /, join(' ',@{$params->{params}},$params->{text} ? $params->{text} : ''));
      my $to = $params->{params}->[1];
      my $mode = $params->{params}->[2];

      my $action = substr($mode,0,1) || '+';
      my $num = 3;

      if($self->is_nickname($to)) {
         return unless $to eq $self->{nick};
         for(split //, $mode) {
            if(/([+-])/) {
              $action = $1;
            }elsif($action eq '+') {
               $self->{mode} = add_mode($self->{mode},$_);
            }elsif($action eq '-') {
               $self->{mode} = del_mode($self->{mode},$_);
            }
         }
         $self->{event}->handle('user mode', _info($to, 1),
             $params->{nick}, $params->{host},
           (join(' ',@{$params->{params}}[2.. @{$params->{params}} - 1])));
      }elsif($self->is_channel($to)) {
         return unless $self->{_channels}->{$to};
         my $channel = $self->{_channels}->{$to};
         my %tmpevents;
         for(split //, $mode) {
            if(/([+-])/) {
               $action = $1;
            }elsif($action eq '-' && /[ilkmnpst$self->{modes}->{toggle}]/) {
               $channel->{mode} = del_mode($channel->{mode}, $_);
               $channel->{ {k => 'key',l => 'limit'}->{$_} } = undef if /[lk]/;
               $num++ if $_ eq 'k';
            }elsif($action eq '+' && /[ilkmnpst$self->{modes}->{toggle}]/) {
               $channel->{mode} = add_mode($channel->{mode}, $_);
               $channel->{ {k => 'key',l => 'limit'}->{$_} } = $params->{params}->[$num] if /[lk]/;
               $num++;
            }elsif(/[hov$self->{prefixmode}]/) {
               my $nick = $params->{params}->[$num];
            next unless ref $channel->nick($nick);
               $channel->nick($nick)->{
                    ($_ =~ /[hov]/ ? {o => 'op',h => 'halfop', v => 'voice'}->{$_}
                 : $_)
               } = ($action eq '+' ? 1 : 0);
               $tmpevents{$_}{$nick} = (defined $tmpevents{$_}{$nick} && $tmpevents{$_}{$nick} eq '+') ? undef : '-' if $action eq '+';
               $tmpevents{$_}{$nick} = (defined $tmpevents{$_}{$nick} && $tmpevents{$_}{$nick} eq '-') ? undef : '+' if $action eq '-';
               $num++;
            }elsif(/b/) {
               $num++;
            }
         }
         if(%tmpevents) {
            for(keys %tmpevents) {
               for my $who(keys %{$tmpevents{$_}}) {
                  next unless defined $tmpevents{$_}{$who};
                  $self->{event}->handle('user change', $who, $channel->{name}, $tmpevents{$_}{$who} eq '+' ? '-' : '+', ({'h' => 'halfop','o' => 'op', 'v' => 'voice'}->{$_}));
               }
            }
         }
         $self->{event}->handle('mode', _info($to, 1),
            $params->{nick}, $params->{host}, (join(' ',@{$params->{params}}[2 ..  @{$params->{params}} - 1])));
      }
   },
   'topic' => sub {
      my($event,$self,$params) = @_;
      $self->{_channels}->{$params->{params}->[1]}->{topic} = $params->{text};
      $self->{_channels}->{$params->{params}->[1]}->{topicby} = $params->{nick};
      $self->{_channels}->{$params->{params}->[1]}->{topictime} = time;
      $self->{event}->handle('topic', _info($params->{params}->[1], 1),
         $params->{nick}, $params->{host}, $params->{text} );
   },
   'invite' => sub {
      my($event,$self,$params) = @_;
      $self->{event}->handle('invite', _info($params->{nick}, 1),
         $params->{nick}, $params->{host}, $params->{text} || $params->{params}->[1]);
   },
   'kick' => sub {
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[1];
      my $kick = $params->{params}->[2];

      $self->{_channels}{$channel}->delnick($kick);
      $self->{event}->handle('user del', $kick, [$channel]);

      $self->{event}->handle('kick', _info($channel, 1),
          $params->{nick}, $params->{host}, $kick, $params->{text});
   },
   'privmsg' => sub {
      my($event,$self,$params) = @_;
     return if exists $self->{ignore}->{$params->{nick}};
      my $to = $params->{params}->[1];

      if(substr($params->{text},0,1) eq "\001") {
         $self->{event}->handle('ctcp msg', $self, $params->{nick}, $params->{host}, $to, $params->{text});
      }elsif($self->is_channel($to)) {
         $self->{event}->handle('message public', _info($to, 2),
             $params->{nick}, $params->{host}, $params->{text});
      }elsif($to =~ /^[+@%]/) {
          my $target = $to;
          $target =~ s/^[+@%]//g;
          $self->{event}->handle('message special', _info($target, 2),
             $params->{nick}, $params->{host}, $to, $params->{text});
      }elsif(is_valid_server($params->{nick})) {
         $self->{event}->handle('message server', _info($to, 2),
             $params->{nick}, $params->{host}, $params->{text});
      }else{
          #return unless $self->find_nick_channels($params->{nick});
         $self->{event}->handle('message private', _info($params->{nick}, 3, 1),
             $params->{nick}, $params->{host}, $params->{text});
      }
   },
   'notice' => sub {
      my($event,$self,$params) = @_;
     return if exists $self->{ignore}->{$params->{nick}};
      my $to = $params->{params}->[1];
      if(substr($params->{text},0,1) eq "\001") {
         $self->{event}->handle('ctcp reply', $self, $params->{nick}, $params->{host}, $to, $params->{text});
      }elsif($self->is_channel($to)) {
         $self->{event}->handle('notice public', _info($to, 1),
             $params->{nick}, $params->{host}, $params->{text});
      }elsif($to =~ /^[+@%]/) {
          my $target = $to;
          $target =~ s/^[+@%]+//;
          $self->{event}->handle('notice special', _info($target, 1),
             $params->{nick}, $params->{host}, $to, $params->{text});
      }elsif(is_valid_server($params->{nick})) {
         $self->{event}->handle('notice server', _info('Status', 1),
             $params->{nick}, $params->{host}, $params->{text});
      }else{
         $self->{event}->handle('notice private', _info($params->{nick}, 1),
             $params->{nick}, $params->{host}, $params->{text});
      }
   },
   'kill' => sub {
      my($event,$self,$params) = @_;
   },
   'pong' => sub {
      my($event,$self,$params) = @_;
      $self->{event}->handle('pong', _info($params->{nick}, 1),
         $params->{nick}, $params->{params}->[1], $params->{text});
   },

# -- numeric replies --

# Client-server connection information (001 -> 099)
   '001' => sub { # RPL_WELCOME
      my($event,$self,$params) = @_;

      $self->{connected} = 1;
      $self->{nick} = $params->{params}->[1];
      $self->{server} = $params->{nick};
      $self->{connect_time} = time;
      $self->{event}->handle('server connected',$self, $self->{server},$self->{nick}, $params->{text});
     $self->{event}->handle('user self', $self->{nick});
      $self->{event}->handle('reply welcome', _info('Status', 1), $params->{text});
   },
   '002' => sub { # RPL_YOURHOST
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply yourhost', _info('Status', 1), $params->{text});
   },
   '003' => sub { # RPL_CREATED
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply created', _info('Status', 1), $params->{text});
   },
   '004' => sub { # RPL_MYINFO
      my($event,$self,$params) = @_;
      $self->{capab}->{server_version} = $params->{params}->[3];
      $self->{capab}->{user_modes} = $params->{params}->[4];
      $self->{capab}->{channel_modes} = $params->{params}->[5];
      $self->{event}->handle('reply myinfo', _info('Status', 1), @{$params->{params}}[3..5]);
   },
   '005' => sub { # RPL_PROTOCTL
      my($event,$self,$params) = @_;
      for(@{$params->{params}}[2.. @{$params->{params}} - 1]) {
         my($key,$value) = split(/=/, $_, 2);
         $value ||= 1;
         $self->{capab}->{lc $key} = $value;
      }

     if(exists $self->{capab}->{prefix} && $self->{capab}->{prefix} =~ /^\(([^\)]+)\)(.*)$/) {
        $self->{prefixmodes} = $1;
        $self->{prefixchars} = $2;
     }elsif(exists $self->{capab}->{ircx}) {
        $self->{prefixmodes} = "qov";
        $self->{prefixchars} = ".@+";
     }

     if(exists $self->{prefixchars} && $self->{prefixchars}) {
        $self->{event}->handle('user 005', $self->{prefixchars});
     }

     if(exists $self->{capab}->{chanmodes}) {
        my @modes = split /,/, $self->{capab}->{chanmodes};
        @{$self->{modes}}{qw/masks param param_add toggle/} = @modes;
     }else{
        @{$self->{modes}}{qw/masks param param_add toggle/} = '';
     }

      $self->{event}->handle('reply protoctl', _info('Status', 1),
        join(' ',@{$params->{params}}[2.. @{$params->{params}} - 1], defined $params->{text} ? $params->{text} : ''));
   },

# Command Replies (200 -> 399)

   301 => sub { # RPL_AWAY
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply away', _info($params->{params}->[2], 1), $params->{text});
   },
   302 => sub { # RPL_USERHOST
      my($event,$self,$params) = @_;
      my($nick,$oper,$away,$host) = $params->{text} =~ /^([^=*]+)(\*)?\=(.*)$/;
      $self->{event}->handle('reply userhost', _info($nick, 1), $nick,$oper,$away,$host);
   },
   303 => sub { # RPL_ISON
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply ison', _info('Status', 1), $params->{text});
   },
   305 => sub { # RPL_UNAWAY
      my($event,$self,$params) = @_;
      $self->{away} = 0;
      $self->{event}->handle('reply unaway', _info('Status', 1));
   },
   306 => sub { # RPL_NOWAWAY
      my($event,$self,$params) = @_;
      $self->{away} = 1;
      $self->{event}->handle('reply nowaway', _info('Status', 1));
   },

   # whois replies
   307 => sub { # RPL_USERIP -OR- RPL_WHOISREGNICK
      my($event,$self,$params) = @_;
      if($params->{params}->[2]) { # RPL_WHOISREGNICK
         $self->{event}->handle('reply whois regnick', _info($params->{params}->[2], 1), $params->{text});
      }else{ # RPL_USERIP (same format as userhost, except ip)
         $self->{event}->handle('reply userip', _info('Status', 1), $params->{text});
      }
   },
   311 => sub { # RPL_WHOISUSER
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply whois user', _info($params->{params}->[2], 1), @{$params->{params}}[3..4], $params->{text});
   },
   312 => sub { # RPL_WHOISSERVER
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply whois server', _info($params->{params}->[2], 1), $params->{params}->[3], $params->{text});
   },
   313 => sub { # RPL_WHOISOPERATOR
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply whois operator', _info($params->{params}->[2], 1), $params->{text});
   },
   314 => sub { # RPL_WHOWASUSER
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply whowas user', _info($params->{params}->[2], 1), $params->{text});
   },
   317 => sub { # RPL_WHOISIDLE
      my($event,$self,$params) = @_;
      my $time = ::format_parse($::format->{time}, {}, [gmtime $params->{params}->[3]]);
      $self->{event}->handle('reply whois idle', _info($params->{params}->[2], 1), $time, scalar gmtime($params->{params}->[4]), $params->{text});
   },
   319 => sub { # RPL_WHOISCHANNELS
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply whois channel', _info($params->{params}->[2], 1), $params->{text});
   },

   318 => sub { # RPL_ENDOFWHOIS
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply whois end', _info($params->{params}->[2], 1), $params->{text});
   },
   369 => sub { # RPL_ENDOFWHOWAS
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply whowas end', _info($params->{params}->[2], 1), $params->{text});
   },

   # list
   321 => sub { # RPL_LISTSTART (you can't rely on this being sent anymore)
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply list start', _info('Status', 1),$params->{text});
   },
   322 => sub { # RPL_LIST
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply list', _info('Status', 1), @{$params->{params}}[2..3],$params->{text});
   },
   323 => sub { # RPL_LISTEND
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply list end', _info('Status', 1), $params->{text});
   },

   # channel mode
   324 => sub { # RPL_CHANNELMODEIS
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[2];
      my $mode = $params->{params}->[3];
      if(ref $self->{_channels}->{$channel} eq "IRC::Channel") {
         $self->{_channels}->{$channel}->{mode} = $mode;
         my $tmp = 4;
         my %tmp;
         for(split //,$mode) {
            next unless /^[lk]$/;
            $tmp{$_} = $params->{params}->[$tmp];
            $tmp++;
         }

         if($self->{_channels}->{$channel}->has_mode('k')) {
            $self->{_channels}->{$channel}->{key} = $tmp{'k'};
         }
         if($self->{_channels}->{$channel}->has_mode('l')) {
            $self->{_channels}->{$channel}->{limit} = $tmp{'l'};
         }
      }

      if(exists $self->{_channels}->{$channel} &&
         $self->{_channels}->{$channel}->{mode_sync}) {
           delete($self->{_channels}->{$channel}->{mode_sync});
           return;
      }

      $self->{event}->handle('reply channel mode', _info($channel, 1), @{$params->{params}}[2.. @{$params->{params}} - 1]);
   },
   329 => sub { # RPL_CREATIONTIME
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[2];
      if($self->{_channels}->{$channel}) {
         $self->{_channels}->{$channel}->{created} = $params->{params}->[3];
      }
      $self->{event}->handle('reply channel time', _info($channel, 1), scalar localtime($params->{params}->[3])); 
   },

   # onjoin / topic

   331 => sub { # RPL_NOTOPIC
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[2];
      $self->{_channels}->{$channel}->{topic} = undef;
      $self->{_channels}->{$channel}->{topicby} = undef;
      $self->{_channels}->{$channel}->{topictime} = undef;
      $self->{event}->handle('reply notopic', _info($channel, 1));
   },

   332 => sub { # RPL_TOPIC
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[2];
      $self->{_channels}->{$channel}->{topic} = $params->{text};
      $self->{event}->handle('reply topic', _info($channel, 1), $params->{text});
   },

   333 => sub { # RPL_TOPICWHOTIME
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[2];
      $self->{_channels}->{$channel}->{topicby} = $params->{params}->[3];
      $self->{_channels}->{$channel}->{topictime} = $params->{params}->[4];
      $self->{event}->handle('reply topicwhotime', _info($channel, 1), $params->{params}->[3], scalar gmtime $params->{params}->[4]);
   },

   # who reply
   352 => sub { # RPL_WHOREPLY
      my($event,$self,$params) = @_;
      my($channel,$user,$host,$server,$nick,$bits,$realname) =
         (@{$params->{params}}[2..7], $params->{text});
      my($op,$voice,$halfop,$hops) = 0;

      $hops = $1 if $realname =~ s/^(\d+) //;
      $op = 1 if $bits =~ /\@/;
      $voice = 1 if $bits =~ /\%/;
      $halfop = 1 if $bits =~ /\+/;

      if(defined $self->{_channels}->{$channel} 
          && ref $self->{_channels}->{$channel} ne 'HASH'
          && $self->{_channels}->{$channel}->nick($nick)) {
         $self->{_channels}->{$channel}->{_nicks}->{$nick} = {
             name => $nick,
             op => $op,
             voice => $voice,
             halfop => $halfop,
             host => $user . '@' . $host,
             server => $server,
             realname => $realname,
             hops => $hops
         };
      }else{
      }

      return if $self->{_channels}->{$channel} && $self->{_channels}->{$channel}->{who_sync};

      $self->{event}->handle('reply who', _info($channel, 1), $channel,$user,$host,$server,$nick,$bits,$hops,$realname);
   },

   315 => sub { # RPL_ENDOFWHO
      my($event,$self,$params) = @_;
      if(exists $self->{_channels}->{$params->{params}->[2]} &&
        $self->{_channels}->{$params->{params}->[2]}->{who_sync}) {
         delete($self->{_channels}->{$params->{params}->[2]}->{who_sync});
         return;
      }
      $self->{event}->handle('reply who end', $params, $params->{params}->[2]);
   },

   # onjoin / names
   353 => sub { # RPL_NAMREPLY
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[3];

      if(exists $self->{_channels}->{$channel} &&
            UNIVERSAL::isa($self->{_channels}->{$channel}, "IRC::Channel")) {
         for(split / /,$params->{text}) {
            my ($op,$halfop,$voice) = 0;
            $op = 1 if s/\@//;
            $voice = 1 if s/\+//;
            $halfop = 1 if s/\%//;
          if(exists $self->{prefixchars} && $self->{prefixchars}) {
             my $prefix = "[" . quotemeta($self->{prefixchars}) . "]+";
             s/^$prefix//;
          }

            $self->{_channels}->{$channel}->addnick($_,
            op => $op,
            halfop => $halfop,
            voice => $voice,
           );
         }
         $self->{event}->handle('user add', [split(/ /, $params->{text})], $channel);
      }

      $self->{event}->handle('reply names', _info($channel, 1), $params->{text});
   },

   366 => sub { # RPL_ENDOFNAMES
      my($event,$self,$params) = @_;
       #return unless $self->{_channels}->{$params->{params}->[2]};
   },

   367 => sub { # RPL_BANLIST
      my($event,$self,$params) = @_;
      my $channel = $params->{params}->[2];
      $self->{event}->handle('reply ban', _info($channel, 1),$channel,@{$params->{params}}[3..5]);
   },
   368 => sub { # RPL_ENDOFBANLIST
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply ban end', _info($params->{params}->[2], 1),$params->{params}->[2],$params->{text});
   },

   372 => sub { # RPL_MOTD
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply motd',_info('Status', 1, undef, 'motd'),$params->{text});
   },
   375 => sub { # RPL_MOTDSTART
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply motd start', _info('Status', 1), $params->{text});
   },
   376 => sub { # RPL_ENDOFMOTD
      my($event,$self,$params) = @_;
      if(!$self->{connected}) {
         $self->{nick} = $params->{params}->[1];
         $self->{server} = $params->{nick};
         $self->{connect_time} = time;
         $self->{event}->handle('server connected',$self, $self->{server},$self->{nick});
      }
      $self->{event}->handle('reply motd end',_info('Status', 1),$params->{text});
   },
   391 => sub { # RPL_TIME
      my($event,$self,$params) = @_;
      $self->{event}->handle('reply time',_info('Status', 1),$params->{text});
   },
   401 => sub {
      my($event,$self,$params) = @_;
      $self->{event}->handle('error nosuchnick', _info($params->{params}->[2], 1));
   },
   433 => sub {
      my($event,$self,$params) = @_;
      $self->{event}->handle('error nickinuse', _info('Status', 1), $params->{params}->[2]);
   },

);

sub ctcpmsg {
   my($event, $irc, $nick, $host, $to, $text, $type) = @_;
   $type = 'ctcp msg' unless defined $type;

   if($text =~ /^\001([^ \001]+)(?: (.*?))?\001?$/) {
      my($command,$params) = ($1,$2);

      $irc->{event}->handle($type . ' ' . lc $command,
        _info($irc->is_channel($to) ? $to : $nick, 1), $to,
        $nick, $host, $command, $params);

   }else{
      return undef;
   }
}

sub ctcpreply {
   ctcpmsg(@_, 'ctcp reply');
}

sub new {
   my($class,$self,$event) = @_;
   for(keys %raw) {
      next if $event->exists('raw '. $_);
      $event->add('raw '. $_, code => $raw{$_});
   }
   for(['ctcp msg',\&ctcpmsg] , ['ctcp reply', \&ctcpreply]) {
      next if $event->exists($_->[0]);
      $event->add($_->[0], code => $_->[1]);
   }                   
   return bless {}, shift;
}

sub _info {
   return { target => $_[0], activity => $_[1], create => (defined $_[2] ? 1 : 0), style => (defined $_[3] ? $_[3] : '')};
}

1;
>>

<<•# $Id: Timer.pm,v 1.1 2002/03/05 16:34:19 dgl Exp $
=head1 NAME

 Timer.pm

=head1 EXAMPLES

 use Timer;
 $timer = Timer->new;

 $timer->addonce(code => \&somesub, data => 'moo', interval => 10);
 sub somesub { print shift }

 $timer->add(code => sub { 
     my($timer,$data) = @_;
     print "Called $timer->{id} with $data\n";
  }, data => 'oink', interval => 1, count => 10);

  # Obviously fit $timer->run into how your program needs to use it.
  sleep 1;
  sleep 1 while $timer->run;

=head1 METHODS

=head2 add

 add( code => \&codref, # \&code, sub { print blah..} etc..
     data => 'data',   # This data is passed back to the coderef when run
     interval => num,  # Time between being run..
     count => [num | undef ], # number of times to run, undef == forever
   );

=head2 addonce

 Wrapper to add, option count is already set to 1

=head2 addforever

 Wrapper to add, option count is set to undef

=head2 delete

delete($id);

=head2 get

 returns anon hash specified by $id

=head2 run

 checks for timers that need running, returns number actually run.

=head2 call

 used internally by run to call an timer when it needs running

=head2 exists

 returns true if the timer exists

=cut

package Timer;
use strict;

sub new {
   my $class = shift;
   # notice it's an array, not a hash
   return bless [], $class;
}

sub add {
   my($self,%timer) = @_;
   my $id = $self->_newid;
   $$self[$id] = 
      {
         code => $timer{code},
         data => $timer{data},
         interval => $timer{interval},
         nextexec => $timer{interval} + time,
         count => $timer{count} || undef,
         'package' => (caller)[0],
         id => $id
      };
   return $id;
}

sub remove_package {
   my($self, $package) = @_;
   for my $id(0 .. $#$self) {
      next unless ref($$self[$id]) eq 'HASH';
      if($$self[$id]->{package} eq $package) {
         splice(@$self, $id, 1);
      }
   }
}

# Finds the next free id (element) in the array
sub _newid {
   my $self = shift;
  for my $id(0 .. $#$self) {
     return $id unless ref($$self[$id]) eq 'HASH';
  }
   return scalar @$self;
}

sub addonce {
   my($self,%timer) = @_;
   $self->add(%timer,count => 1);
}

sub addforever {
   my($self,%timer) = @_;
   $self->add(%timer,count => undef);
}

sub delete {
   my($self,$id) = @_;
   return 0 unless $self->exists($id);
   $$self[$id] = undef;
}

sub get {
   my($self,$id) = @_;
   return $$self[$id];
}

sub run {
   my $self = shift;
   my $time = time;
   my $num = 0;
   for my $id(0 .. $#$self) {
      next unless ref($$self[$id]) eq 'HASH';
      if($time >= $$self[$id]->{nextexec}) {
         $self->call($id);
         $num++;
      }
   }
   return $num;
}

sub call {
   my($self,$id) = @_;
   my $timer = $self->get($id);

   $timer->{count}-- if defined $timer->{count};
   $timer->{nextexec} = $timer->{interval} + time;

# TODO: Make $timer into an object so things like $timer->delete work within
# the timer.
   $timer->{code}->($timer,$timer->{data});

   if(defined $timer->{count} && $timer->{count} <= 0) {
      $self->delete($id);
      return 0;
   }
   1;
}

sub exists {
   my($self,$id) = @_;
   return 1 if ref($$self[$id]) eq 'HASH';
   0;
}

1;
>>

<<•# $Id: UniqueHash.pm,v 1.2 2002/04/27 19:21:54 dgl Exp $
#!/usr/bin/perl
# from pircd, edited by david leadbeater..
# 
# IRCUniqueHash.pm
# Created: Wed Apr 21 09:44:03 1999 by jay.kominek@colorado.edu
# Revised: Wed Apr 21 09:59:55 1999 by jay.kominek@colorado.edu
# Copyright 1999 Jay F. Kominek (jay.kominek@colorado.edu)
#
# Consult the file 'LICENSE' for the complete terms under which you
# may use self file.
#
#####################################################################
# A hash class which enforces IRC-style unique name spaces
#####################################################################

package IRC::UniqueHash;
use strict;
my(@tmp);

sub TIEHASH {
  my $proto = shift;
  my $class = ref($proto) || $proto;
  my $self  = { };

  bless $self, $class;
  return $self;
}

sub FETCH {
  my($self,$key) = @_;

  return $self->{data}->{irclc($key)}->{value};
}

sub STORE {
  my($self,$key,$value) = @_;

  my $name = irclc($key);
  $self->{data}->{$name}->{name} = $key;
  $self->{data}->{$name}->{value} = $value;
}

sub DELETE {
  my($self,$key) = @_;

  delete($self->{data}->{irclc($key)});
}

sub CLEAR {
  my $self = shift;

  %$self = ( );
}

sub EXISTS {
  my($self,$key) = @_;

  return exists $self->{data}->{irclc($key)};
}

sub FIRSTKEY {
  my $self = shift;

  @{$self->{_tmp}} = keys %{$self->{data}};

  return $self->{data}->{shift @{$self->{_tmp}}}->{name};
}

sub NEXTKEY {
  my ($self,$lastkey) = @_;

  return undef unless @{$self->{_tmp}};
  return $self->{data}->{shift @{$self->{_tmp}}}->{name};
}

sub irclc {
  return lc $_[0];
}

1;
>>

<<## $Id: Util.pm,v 1.5 2006/04/30 12:51:55 dgl Exp $
package IRC::Util;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(is_valid_channel is_valid_nickname is_valid_server make_lowercase check_mode match_mask fullhost2nick fullhost2host add_mode del_mode);

use strict;

sub is_valid_channel {
   return 0 if length $_[0] > 64;
   return 0 if $_[0] =~ /[ ,]/;
   return 1 if $_[0] =~ /^[#&]/;
   return 0;
}

sub is_valid_nickname {
   return 0 if length $_[0] > 32 or length $_[0] < 1;
   return 0 if $_[0] =~ / /;
   return 0 if $_[0] =~ /^[0-9#&]/;
   return 1;
}

sub is_valid_server {
   return 0 if $_[0] !~ /\./;
   return 0 if $_[0] =~ /[!@]/;
   return 0 if $_[0] =~ /[^-A-Za-z0-9\*\._]/;
   return 1;
}

sub make_lowercase{
   my $lc = shift;
   $lc =~ tr/A-Z\[\]\\/a-z\{\}\|/;
   return $lc;
}

sub check_mode {
   my($mode,$bit) = @_;
   return 1 if $mode =~ /\S*\Q$bit\E/;
}

# should really split all the parts up...
sub match_mask {
   my($check,$mask) = @_;
   $mask = quotemeta $mask;
   $mask =~ s/\\\?/./g;
   $mask =~ s/\\\*/.*?/g;
   return 1 if $check =~ /$mask/;
   0;
}

sub fullhost2nick {
   my $host = shift;
   $host =~ s/!.*$//;
   return $host;
}

sub fullhost2host {
   my $host = shift;
   $host =~ s/^.*?!//;
   return $host;
}

sub add_mode{
   my($mode,$bit) = @_;
   return $mode if $mode =~ /^\S*\Q$bit\E/;
   $mode =~ s/^(\S*)/$1$bit/;
   return $mode;
}

sub del_mode{
   my($mode,$bit) = @_;
   return $mode if $mode !~ /^\S*\Q$bit\E/;
   $mode =~ s/^(\S*)$bit/$1/;
   return $mode;
}

1;
>>

<<# $Id: Util.pm,v 1.5 2006/04/30 12:51:55 dgl Exp $
package IRC::Util;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(is_valid_channel is_valid_nickname is_valid_server make_lowercase check_mode match_mask fullhost2nick fullhost2host add_mode del_mode);

use strict;

sub is_valid_channel {
   return 0 if length $_[0] > 64;
   return 0 if $_[0] =~ /[ ,]/;
   return 1 if $_[0] =~ /^[#&]/;
   return 0;
}

sub is_valid_nickname {
   return 0 if length $_[0] > 32 or length $_[0] < 1;
   return 0 if $_[0] =~ / /;
   return 0 if $_[0] =~ /^[0-9#&]/;
   return 1;
}

sub is_valid_server {
   return 0 if $_[0] !~ /\./;
   return 0 if $_[0] =~ /[!@]/;
   return 0 if $_[0] =~ /[^-A-Za-z0-9\*\._]/;
   return 1;
}

sub make_lowercase{
   my $lc = shift;
   $lc =~ tr/A-Z\[\]\\/a-z\{\}\|/;
   return $lc;
}

sub check_mode {
   my($mode,$bit) = @_;
   return 1 if $mode =~ /\S*\Q$bit\E/;
}

# should really split all the parts up...
sub match_mask {
   my($check,$mask) = @_;
   $mask = quotemeta $mask;
   $mask =~ s/\\\?/./g;
   $mask =~ s/\\\*/.*?/g;
   return 1 if $check =~ /$mask/;
   0;
}

sub fullhost2nick {
   my $host = shift;
   $host =~ s/!.*$//;
   return $host;
}

sub fullhost2host {
   my $host = shift;
   $host =~ s/^.*?!//;
   return $host;
}

sub add_mode{
   my($mode,$bit) = @_;
   return $mode if $mode =~ /^\S*\Q$bit\E/;
   $mode =~ s/^(\S*)/$1$bit/;
   return $mode;
}

sub del_mode{
   my($mode,$bit) = @_;
   return $mode if $mode !~ /^\S*\Q$bit\E/;
   $mode =~ s/^(\S*)$bit/$1/;
   return $mode;
}

1;
>>

<<$>>

<< Helper CGI
 * Copyright (c) David Leadbeater 2002-2007
 * Released Under the GNU GPLv2 or Later
 * NO WARRANTY - See GNU GPL for more
 * $Id: 3cc9101e199095f574c9bd8b2c53f0f9042eeae9 $
 */
/* To compile: cc -O2 -o client.cgi client.c */
/* Add -lsocket on Solaris */

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>

/* Change this to the tmpfile path set in the CGI:IRC Config */
#define TMPLOCATION "/tmp/cgiirc-"

/******************************************************************************
 * Stralloc (from libowfat(-ish))
 * If you'd rather use dietlibc/libowfat:
 * diet -Os gcc -include stralloc.h -o client.cgi client.c -lowfat */

#ifndef STRALLOC_H
typedef struct stralloc {
  char* s;
  unsigned long int len;
  unsigned long int a;
} stralloc;

int stralloc_ready(stralloc *sa,unsigned long int len) {
  register int wanted=len+(len>>3)+30; /* heuristic from djb */
  if(!sa->s || sa->a<len) {
    register char* tmp;
    if (!(tmp=realloc(sa->s,wanted)))
      return 0;
    sa->a=wanted;
    sa->s=tmp;
  }
  return 1;
}

int stralloc_readyplus(stralloc *sa,unsigned long len) {
  if (sa->s) {
    if (sa->len + len < len) return 0;  /* catch integer overflow */
    return stralloc_ready(sa,sa->len+len);
  } else
    return stralloc_ready(sa,len);
}

int stralloc_catb(stralloc *sa,const char *buf,unsigned long int len) {
  if (stralloc_readyplus(sa,len)) {
    memcpy(sa->s+sa->len,buf,len);
    sa->len+=len;
    return 1;
  }
  return 0;
}

int stralloc_cats(stralloc *sa,const char *buf) {
  return stralloc_catb(sa,buf,strlen(buf));
}

int stralloc_cat(stralloc *sa,stralloc *sa2) {
  return stralloc_catb(sa,sa2->s,sa2->len);
}

int stralloc_append(stralloc *sa,const char *in) {
  if (stralloc_readyplus(sa,1)) {
    sa->s[sa->len]=*in;
    ++sa->len;
    return 1;
  }
  return 0;
}

#define stralloc_0(sa) stralloc_append(sa,"")

#endif
/******************************************************************************/

int unix_connect(stralloc *where);
int error(char *error);
void readinput(stralloc *);
void get_rand(stralloc *, stralloc *);
void get_cookie(stralloc *);

int main(void) {
  int fd, sz;
  char tmp[2048];
  stralloc params = {0}, random = {0}, cookie = {0};

  readinput(&params);

  if(!params.len)
    error("No input found");

  stralloc_0(&params);

  get_rand(&params, &random);

  if(!random.len)
    error("Random value not found");

  params.len--;

  get_cookie(&cookie);

  if(cookie.len) {
    stralloc_cats(&params, "&COOKIE=");
    stralloc_cat(&params, &cookie);
  }

  fd = unix_connect(&random);
  send(fd, params.s, params.len, 0);
  send(fd, "\n", 1, 0);

  while((sz = read(fd, tmp, sizeof tmp)) > 0) {
    write(STDOUT_FILENO, tmp, sz);
  }

  return 0;
}

int error(char *error) {
  puts("Content-type: text/html\nStatus: 500\n");
  puts("An error occurred:");
  puts(error);
  exit(1);
}

void readinput(stralloc *input) {
  char *method = getenv("REQUEST_METHOD");
  if(!method) return;

  if(strcmp(method, "GET") == 0) {
    char *query = getenv("QUERY_STRING");
    if(query)
      stralloc_cats(input, query);
  }else if(strcmp(method, "POST") == 0) {
    int length;
    char *ctlength = getenv("CONTENT_LENGTH");
    size_t sz;
    if(!ctlength) return;
    length = atoi(ctlength);

    /* Hopefully noone will need to send more than 5KB */
    if(length <= 0 || length > (1024*5)) return;
    stralloc_ready(input, length);
    sz = read(STDIN_FILENO, input->s, length);
    if(sz <= 0) return;
    input->len = sz;
  }
}

void get_rand(stralloc *params, stralloc *random) { 
  char *ptr = strstr(params->s, "R=");

  if(!ptr)
    return;

  ptr += 2;

  while(ptr < params->s + params->len) {
    if(!isalpha((unsigned char)*ptr) && !isdigit((unsigned char)*ptr))
      break;
    stralloc_append(random, ptr++);
  }
}

void get_cookie(stralloc *cookie) {
  char *httpcookie;
  char *sptr, *end_ptr;

  httpcookie = getenv("HTTP_COOKIE");
  if(!httpcookie) return;

#define COOKIE_NAME "cgiircauth="
  sptr = strstr(httpcookie, COOKIE_NAME);
  if(sptr == NULL) return;
  sptr += strlen(COOKIE_NAME);
  if(!*sptr) return;

  end_ptr = strchr(sptr, ';');
  if(end_ptr == NULL)
    end_ptr = sptr + strlen(sptr) - 1;

  stralloc_catb(cookie, sptr, 1 + end_ptr - sptr);
}

#ifndef SUN_LEN
#define SUN_LEN(x) (sizeof(*(x)) - sizeof((x)->sun_path) + strlen((x)->sun_path))
#endif

int unix_connect(stralloc *where) {
  stralloc filename = {0}, errmsg = {0};
  struct sockaddr_un saddr;
  int sock;

  stralloc_cats(&filename, TMPLOCATION);
  stralloc_cat(&filename, where);
  stralloc_cats(&filename, "/sock");
  stralloc_0(&filename);

  sock = socket(AF_UNIX, SOCK_STREAM, 0);
  if(sock == -1) error("socket() error");

  saddr.sun_family = AF_UNIX;
  strncpy(saddr.sun_path, filename.s, sizeof(saddr.sun_path));
  saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';

  if(connect(sock, (struct sockaddr *)&saddr, SUN_LEN(&saddr)) == -1) {
    stralloc_cats(&errmsg, "connect(): ");
    stralloc_cats(&errmsg, strerror(errno));
    stralloc_0(&errmsg);
    error(errmsg.s);
  }

  return sock;
}>>

[[code]]

<$ Stripe python gpg key :

gpg --encrypt --recipient 05D02D3D57ABFF46 FILENAME

Key ID: 05D02D3D57ABFF46
Key type: RSA
Key size: 2048 bits
Fingerprint: C330 33E4 B583 FE61 2EDE 877C 05D0 2D3D 57AB FF46>

[[/code]]

+ [[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]

[[/div]] 
[!--
[[div class="if-none-singlemode-formdata-hide if-none-singlemode-1"]]
[[module css]]
.if-equal-singlemode-1{display:block !important;}
.if-equal-singlemode-formdata-hide{display:none;}

.if-same-singlemode-1{display:block !important;}
.if-same-singlemode-formdata-hide{display:none;}

.if-notequal-singlemode-1{display:none !important;}
.if-notequal-singlemode-formdata-hide{display:block;}

.if-nequal-singlemode-1{display:none !important;}
.if-nequal-singlemode-formdata-hide{display:block;}

.if-nsame-singlemode-1{display:none !important;}
.if-nsame-singlemode-formdata-hide{display:block;}
[[/module]]
[!----]

link to the implemented solution on a Wikidot site or put a working example here

In action

link to the implemented solution on a Wikidot site or put a working example here


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by Keith Bieszczat

GRU.psychotronics.src - 30 Apr 2025 08:30
Breadcrumbs.md - 27 Apr 2025 04:08
Archive.src - 27 Apr 2025 03:45


Rate this solution

If you think this solution is useful — rate it up!

rating: 0+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License