File: modslap

package info (click to toggle)
slash 2.2.6-8etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 3,672 kB
  • ctags: 1,915
  • sloc: perl: 23,113; sql: 1,878; sh: 433; makefile: 233
file content (84 lines) | stat: -rwxr-xr-x 1,864 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl -w
# This code is a part of Slash, and is released under the GPL.
# Copyright 1997-2001 by Open Source Development Network. See README
# and COPYING for more information, or see http://slashcode.com/.
# $Id: modslap,v 1.1.2.2 2001/07/03 20:50:05 jamie Exp $

use strict;
use File::Basename;
use FindBin '$Bin';
use Getopt::Std;
use Slash::Utility;
use Slash::DB;

(my $VERSION) = ' $Revision: 1.1.2.2 $ ' =~ /\$Revision:\s+([^\s]+)/;
my $PROGNAME = basename($0);
(my $PREFIX = $Bin) =~ s|/[^/]+/?$||;

my %opts;
# Remember to doublecheck these match usage()!
usage('Options used incorrectly') unless getopts('hvu:', \%opts);
usage() if ($opts{'h'} || !keys %opts);
usage('Please specify a list of User IDs') if (! scalar @ARGV);
version() if $opts{'v'};
$opts{'u'} ||= 'slash';

# We turn off warnings here because it's distracting.
$^W = 0; createEnvironment($opts{'u'}); $^W = 1;

my $slashdb = getCurrentDB();
my $constants = getCurrentStatic();

# main program logic (in braces to offset nicely)
{

	for (@ARGV) {
		my $user = $slashdb->getUser($_);
		if (! $user) {
			print "User ID#$_ is invalid.\n";
			next;
		}

		print "Mod Slapping #$_...\n";
		$slashdb->setUser($_, {
			-karma	=> $constants->{badkarma},
			-points	=> 0,
			rtbl	=> 1,
		});
	}
}


sub usage {
	print "*** $_[0]\n" if $_[0];
	# Remember to doublecheck these match getopts()!
	print <<EOT;

Usage: $PROGNAME [OPTIONS] ... [UIDs]

SHORT PROGRAM DESCRIPTION

Main options:
	-h	Help (this message)
	-v	Version
	-u	Virtual user (default is "slash")

	[UIDs]	Space separated list of IDs to slap.
EOT
	exit;
}

sub version {
	print <<EOT;

$PROGNAME $VERSION

This code is a part of Slash, and is released under the GPL.
Copyright 1997-2001 by Open Source Development Network. See README
and COPYING for more information, or see http://slashcode.com/.

EOT
	exit;
}

__END__