File: spamarmor.pl

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 (67 lines) | stat: -rwxr-xr-x 2,067 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
#!/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: spamarmor.pl,v 1.1.2.9 2001/09/17 20:17:20 jamie Exp $

use strict;
use vars qw( %task $me );
use Safe;
use Slash;
use Slash::DB;
use Slash::Display;
use Slash::Utility;

(my $VERSION) = ' $Revision: 1.1.2.9 $ ' =~ /\$Revision:\s+([^\s]+)/;

$task{$me}{timespec} = '30 0 * * *';
$task{$me}{timespec_panic_1} = ''; # not that important

# Handles rotation of fakeemail address of all users.
$task{$me}{code} = sub {
	my($virtual_user, $constants, $slashdb, $user) = @_;

#	# Loop over all users. The call to iterateUsers gets a block of 
#	# users and iterates over that. As opposed to trying to grab all
#	# of the ENTIRE USERBASE at once. Since a statement handle would
#	# be the best way to get this data, but the API doesn't return 
#	# statement handles, we'll have to use a few tricks.
#	my ($count, $usr_block) = (0, 0);
#	do {
#		my $usr_block = $slashdb->iterateUsers(1000);
#
#		for my $user (@{$usr_block}) {
#	# Should be a constant somewhere, probably. The naked '1' below
#	# refers to the code in $users->{emaildisplay} corresponding to
#	# random rotation of $users->{fakeemail}.
#			next if !defined($user->{emaildisplay})
#				or $user->{emaildisplay} != 1;
#
#	# Randomize the email armor.
#			$user->{fakeemail} = getArmoredEmail($_);
#
#	# If executed properly, $user->{fakeemail} should have a value.
#	# If so, save the result.
#			if ($user->{fakeemail}) {
#				$slashdb->setUser($user->{uid}, {
#					fakeemail	=> $user->{fakeemail},
#				});
#				$count++;
#			}
#		}
#	} while $usr_block;

	my $count = 0;
	my $hr = $slashdb->getTodayArmorList();
	for my $uid (sort { $a <=> $b } keys %$hr) {
		my $fakeemail = getArmoredEmail($uid, $hr->{$uid}{realemail});
		$slashdb->setUser($uid, { fakeemail => $fakeemail });
		++$count;
		sleep 1 if ($count % 20) == 0;
	}

	return "rotated armoring for $count users";
};

1;