ソースを参照

Checking in scripts

Morten Brix Pedersen 25 年 前
コミット
467149e413
5 ファイル変更341 行追加0 行削除
  1. 19 0
      scripts/addalias/README
  2. 24 0
      scripts/addalias/addalias.htm
  3. 168 0
      scripts/addalias/addalias.pl
  4. 9 0
      scripts/crontab
  5. 121 0
      scripts/dropegg.pl

+ 19 - 0
scripts/addalias/README

@@ -0,0 +1,19 @@
+This is a small Perl script/webinterface enabling users to add their own
+aliases/pictures/links to users.cfg
+
+It was made by Doomshammer <doomshammer@doomshammer.yi.org>, so any
+questions/suggestions etc. should go to him.
+
+Documentation:
+--
+The user just has to fill out the form "addalias.htm" and "submit" :) First of
+all the script searches the users.cfg if the nick allready exists in the
+users.cfg If thats not the point it adds the Aliases aso. in syntax-style of
+your users.cfg
+
+For the user it is possible to set "Nickname, Alias, Userpic-URL, Link (Mail or
+URL), and Ignore"
+
+I think this script makes it more easier to spent the users.cfg up-to-date,
+because YOU haven't to search the log for aliases and so on... it's time to
+make the users work :)

+ 24 - 0
scripts/addalias/addalias.htm

@@ -0,0 +1,24 @@
+<html><body>
+<form action="../cgi-bin/addalias.pl" method="POST">
+ <table>
+  <tr>
+   <td>Nickname: </td><td><input name="nick" type="text" width="30"></td>
+  </tr>
+  <tr>
+   <td>Aliases:<sup>*</sup> </td><td><input name="alias" type="text" width="30"></td>
+  </tr>
+  <tr>
+   <td>URL/Link: </td><td><input name="link" type="text" width="30"></td>
+  </tr>
+  <tr>
+   <td>Userpic: </td><td><input name="pic" type="text" width="30"></td>
+  </tr>
+  <tr>
+   <td><input type="checkbox" name="ignore"></td><td> Ignore?</td>
+  </tr>
+  <tr>
+   <td colspan="2"><center><input type="submit" value="Submit"></center></td>
+  </tr>
+ </table>
+</form>
+</body></html>

+ 168 - 0
scripts/addalias/addalias.pl

@@ -0,0 +1,168 @@
+#!/usr/bin/perl -w
+
+# By Doomshammer <doomshammer@doomshammer.yi.org>
+
+print "Content-Type: text/html\n\n";
+
+my %oldnicks;
+open(FILE, "<users.cfg") || die "Datei nicht gefunden";
+$i = 0;
+while(<FILE>) {
+	if($_ =~ /^<user/) {
+		$users[$i] = $_;
+		chomp $users[$i];
+		$i++;
+	}
+}
+close(FILE);
+$i=0;
+foreach(@users) {
+	if($users[$i] =~ /nick=/) {
+		if($users[$i] =~ /nick="(\S+)"(.*)/) {
+			$nick[$i] = $1;
+			$oldnicks{$nick[$i]}{'nick'} = $nick[$i];
+		}
+		if($users[$i] =~ /alias="(\S+)".*/ or $users[$i] =~ /alias="(.*)"\s/ or $users[$i] =~ /alias="(.*)">/) {
+			$alias = $1;
+			$oldnicks{$nick[$i]}{'alias'} = $alias;
+		}
+        if($users[$i] =~ /link="(\S+)"(.*)/) {
+            $link = $1;
+			$oldnicks{$nick[$i]}{'link'} = $link;
+        }
+        if($users[$i] =~ /pic="(\S+)"(.*)/) {
+            $pic = $1;
+            $oldnicks{$nick[$i]}{'pic'} = $pic;
+        }
+        if($users[$i] =~ /ignore="(\S+)"(.*)/) {
+            $ignore = $1;
+			if($ignore eq "y" or $ignore eq "Y") { 
+				$ignore = 1; 
+			} else {
+				$ignore = 0;
+			}
+            $oldnicks{$nick[$i]}{'ignore'} = $ignore;
+        }
+	} else {
+		$search = 1;
+	}
+	$i++;
+}
+
+if($ENV{'REQUEST_METHOD'} eq 'GET') {  
+	$input = $ENV{'QUERY_STRING'} 
+} else {
+	read(STDIN, $input, $ENV{'CONTENT_LENGTH'}); 
+}
+
+@formfields = split(/&/, $input);
+foreach $field (@formfields) {
+	($name, $value) = split(/=/, $field);
+	$value =~ tr/+/ /;
+	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
+	$value =~ s/<!--(.|\n)*-->//g;
+	$form{$name} = $value;
+}
+if($form{'ignore'} eq "on") { $form{'ignore'} = 1; }
+if($search ne "1") {
+	foreach (@nick) {
+		if($oldnicks{$_}{'nick'} eq $form{'nick'}) {
+			$found = 1;
+		}
+	}
+	if($found eq "1") { 
+		print "<p>F&uuml;r den angegebenen Nicknamen sind bereits Einstellung gesetzt:</p>\n";
+		print "<table>\n <tr>\n";
+		print "  <td>Nickname:</td>\n  <td>$oldnicks{$form{'nick'}}{'nick'}</td>\n";
+		print " </tr>\n";
+		if($oldnicks{$form{'nick'}}{'alias'}) { 
+			print " <tr>\n";
+			print "  <td>Aliase:</td>\n  <td>$oldnicks{$form{'nick'}}{'alias'}</td>\n";
+			print " </tr>\n";
+		}
+		if($oldnicks{$form{'nick'}}{'link'}) {
+			print " <tr>\n"; 
+			if($oldnicks{$form{'nick'}}{'link'} =~ /^http:|ftp:/) {
+				print "  <td>Link:</td>\n  <td><a href=\"$oldnicks{$form{'nick'}}{'link'}\">$oldnicks{$form{'nick'}}{'link'}</a></td>\n";
+			}
+			elsif ($oldnicks{$form{'nick'}}{'link'} =~ /(.*)@(.*).(.*)/) {
+				print "  <td>Link:</td>\n  <td><a href=\"mailto:$oldnicks{$form{'nick'}}{'link'}\">$oldnicks{$form{'nick'}}{'link'}</a></td>\n";
+			} else {
+				print "  <td>Link:</td>\n  <td>$oldnicks{$form{'nick'}}{'link'}</td>\n";
+			}
+			print " </tr>\n";
+		}
+		if($oldnicks{$form{'nick'}}{'pic'}) { 
+			print " <tr>\n";
+			print "  <td>Userpic:</td>\n  <td valign=\"middel\"><a href=\"$oldnicks{$form{'nick'}}{'pic'}\"><img src=\"$oldnicks{$form{'nick'}}{'pic'}\" border=\"0\"></a></td>\n";
+			print " </tr>\n";
+		}
+		if($oldnicks{$form{'nick'}}{'ignore'} eq "1") {
+            print " <tr>\n";
+            print "  <td>Ignorieren:</td>\n  <td>Ja</td>\n";
+            print " </tr>\n";
+		}
+		print "</table>\n";
+		print "<p>Bitte <a href=\"javascript:history.back()\">hier</a> klicken um einen anderen Nicknamen zu w&auml;hlen</p>\n";
+		exit(0);
+	}
+}
+if(!$form{'nick'}) { 
+	print "Kein Nickname eingegeben... Anfrage ung&uuml;ltig<br>";
+	print "Bitte <a href=\"javascript:history.back()\">hier</a> klicken um einen Nicknamen zu w&auml;hlen";
+	exit(0);
+}
+if($form{'nick'} and !$form{'alias'} and !$form{'link'} and !$form{'pic'} and !$form{'ignore'}) {
+	print "Sie haben zwar einen Nicknamen gew&auml;hlt aber keine weiteren Einstellungen<br>\n";
+	print "Bitte <a href=\"javascript:history.back()\">hier</a> klicken um weitere Einstellungen zu machen";
+	exit(0);
+}
+$eintrag = "<user";
+if($form{'nick'}) {
+	$eintrag = $eintrag . " nick=\"$form{'nick'}\"";
+}
+if($form{'alias'}) {
+	$eintrag = $eintrag . " alias=\"$form{'alias'}\"";
+}
+if($form{'link'}) {
+	$eintrag = $eintrag . " link=\"$form{'link'}\"";
+}
+if($form{'pic'}) {
+	$eintrag = $eintrag . " pic=\"$form{'pic'}\"";
+}
+if($form{'ignore'} eq "1") {
+	$eintrag = $eintrag . " ignore=\"y\"";
+}
+$eintrag = $eintrag . ">";
+
+print <<HTML
+Dein Nickname wurde erfolgreich eingetragen:<br>\n
+<table>
+ <tr>
+  <td>Nickname:</td><td>$form{'nick'}</td>
+ </tr>
+HTML
+;
+if($form{'alias'}) { 
+	print " <tr>\n";
+	print "  <td>Aliase:</td><td>$form{'alias'}</td>\n";
+	print " </tr>\n";
+}
+if($form{'link'}) {
+    print " <tr>\n";
+    print "  <td>Link:</td><td><a href=\"$form{'link'}\">$form{'link'}</a></td>\n";
+    print " </tr>\n";
+}
+if($form{'pic'}) {
+    print " <tr>\n";
+    print "  <td>Userpic:</td><td><img src=\"$form{'pic'}\"></td>\n";
+    print " </tr>\n";
+}
+if($form{'ignore'} eq "1") {
+    print " <tr>\n";
+    print "  <td>Ignorieren:</td><td>Ja</td>\n";
+    print " </tr>\n";
+}
+open(FILE, ">>users.cfg") || die "Datei nicht gefunden";
+print FILE "$eintrag\n";
+close(FILE);

+ 9 - 0
scripts/crontab

@@ -0,0 +1,9 @@
+# In order to run pisg in crontab, then do 'crontab -e' as a normal user,
+# and insert a line like this:
+
+10,20,30,40,50,60 * * * * /path/to/pisg.pl
+
+# This will make pisg run every 10 minutes, or you could do it every hour
+# by doing this:
+
+* 0 * * * /path/to/pisg.pl

+ 121 - 0
scripts/dropegg.pl

@@ -0,0 +1,121 @@
+#!/usr/bin/perl
+
+# Drop Egg
+#
+# This script takes a heap of daily eggdrop logs and changes them around
+# to look a little more mIRC-like. (So that they can be fed through PISG
+# and whatnot)
+#
+# Copyright 2001, Emil Mikulic. <darkmoon7@optushome.com.au>
+
+use Time::Local;
+
+$logdir = "/home/darkmoon/eggdrop/logs";
+$logname = "gencorp.log";
+$outfile = "gencorp.out";
+$channel = "#gencorp";
+
+open(OUTFILE, ">$outfile");
+
+foreach (`ls $logdir/$logname.*`)
+{
+ chomp( $current_log = $_ );
+ print "Sanitizing $current_log...";
+
+ ($year,$mon,$day) = $current_log =~ /$logdir\/$logname\.(\d\d\d\d)(\d\d)(\d\d)/;
+ $time = timelocal(1,0,0,$day,$mon,$year);
+ print OUTFILE "\nSession Start: " . localtime($time) . "\n";
+ print OUTFILE "[00:00] *** Now talking in $channel\n";
+
+ foreach (`cat $current_log`)
+ {
+  chomp( $line = $_ );
+
+  $line =~ s/\cB//g;
+  $line =~ s/\c_//g;
+  $line =~ s/\cO//g;
+  $line =~ s/\cC\d+//g;
+
+  # [02:25] DTails (~Dtails@co3033554-a.mckinn1.vic.optushome.com.au) joined #gencorp.
+  # [14:48] *** shai (cmot_dblah@a1-46.melbpc.org.au) has joined #breakfastclub
+
+  if (($line =~ /joined/) && !($line =~ /\</))
+  {
+   ($timestamp,$nick,$hostmask) = $line =~ /(\[\d\d\:\d\d\]) (\S+) \(([^)]+)\) joined/;
+   $line = "$timestamp *** $nick ($hostmask) has joined $channel";
+  }
+
+  # [02:26] DTails (~Dtails@co3033554-a.mckinn1.vic.optushome.com.au) left irc: We're the
+  # [14:46] *** alice (noidea@dialup-33.ap1-nas7.unite.mel.dav.net.au) Quit
+
+  if (($line =~ /left irc/) && !($line =~ /\[\d\d\:\d\d\] \</))
+  {
+   ($timestamp,$nick,$hostmask) = $line =~ /(\[\d\d\:\d\d\]) (\S+) \(([^)]+)\) left irc/;
+   $line = "$timestamp *** $nick ($hostmask) Quit";
+  }
+
+  if (($line =~ /got netsplit/) && !($line =~ /\[\d\d\:\d\d\] \</))
+  {
+   ($timestamp,$nick,$hostmask) = $line =~ /(\[\d\d\:\d\d\]) (\S+) \(([^)]+)\) got netsplit/;
+   $line = "$timestamp *** $nick ($hostmask) Quit";
+  }
+
+  # [19:42] Action: G..... wipes away tear
+  # [19:42] * G..... is a SED KENT
+
+  if ($line =~ /\[\d\d\:\d\d\] Action/)
+  {
+   $line =~ s/Action\:/\*/;
+  }
+
+  # [12:06] Nick change: DTails -> DT|Work
+  # [14:53] *** Death is now known as Memnoch
+
+  if ($line =~ /\[\d\d\:\d\d\] Nick change/)
+  {
+   $line =~ s/(\[\d\d\:\d\d\]) Nick change\: (\S+) \-\> (\S+)/$1 *** $2 is now known as $3/;
+  }
+
+  # [11:23] #gencorp: mode change '+o ark|tv' by curtis!~curtis@co...
+  # [11:23] *** curtis sets mode: +o ark
+  if ($line =~ /\[\d\d\:\d\d\] \#\S+ mode change/)
+  {
+   ($timestamp,$mode,$setter) = $line =~
+	/(\[\d\d\:\d\d\]) \#\S+ mode change \'([^']+)\' by ([^!]+)\!/;
+   $line = "$timestamp *** $setter sets mode: $mode";
+  }
+
+  # [19:32] Gumpy kicked from #gencorp by curtis: flood
+  # [18:49] *** darkmoon was kicked by dark|away (BLAM!)
+  if ($line =~ /\[\d\d\:\d\d\] \S+ kicked from \#/)
+  {
+   ($timestamp,$victim,$kicker,$reason) = $line =~
+	/(\[\d\d\:\d\d\]) (\S+) kicked from \#\S+ by ([^:]+)\: (.+)/;
+   $line = "$timestamp *** $victim was kicked by $kicker ($reason)";
+  }
+
+  # [00:48] Topic changed on #gen by arknstone!~...: <topic>
+  # [14:43] *** arknstone changes topic to 'this is a test'
+  if ($line =~ /\[\d\d\:\d\d\] Topic changed/)
+  {
+   ($timestamp,$changer,$topic) = $line =~
+	/(\[\d\d\:\d\d\]) Topic changed on \#\S+ by ([^!]+)\![^:]+\: (.+)/;
+   $line = "$timestamp *** $changer changes topic to '$topic'";
+  }
+
+
+
+  if (!(($line =~ /got lost/) && !($line =~ /\[\d\d\:\d\d\] \</)))
+  {
+   print OUTFILE "$line\n";
+  }
+
+ }
+
+ $time = timelocal(59,59,23,$day,$mon,$year);
+ print OUTFILE "Session Close: " . localtime($time) . "\n";
+ print "done!\n";
+}
+
+close(OUTFILE);
+