-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_new_members
executable file
·184 lines (157 loc) · 3.49 KB
/
import_new_members
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/env perl
use strict;
use warnings;
use Env qw($MYSQL_U $MYSQL_P);
use MIME::Lite;
use DBI;
my $sql = qq~
select
*
from
user_queue
~;
my $ds = "DBI:mysql:database=cobug_xmpp;host=localhost;port=3306";
my $dbh = DBI->connect($ds, $MYSQL_U, $MYSQL_P);
my $sth = $dbh->prepare($sql);
$sth->execute;
sub sendEmail {
my ($u, $pass) = @_;
my $msg = MIME::Lite->new(
From => '[email protected]',
To => $u->{email},
Subject => 'CoBUG XMPP Account Info',
Type => 'multipart/mixed'
);
$msg->attach(
Type => 'TEXT',
Data => qq~
Your CoBUG XMPP account has been created!
Jabber ID: $u->{username}\@cobug.org
Password: $pass
Configure instructions for Pidgin:
1. Click 'Accounts' in the main menu.
2. Click 'Manage Accounts'.
3. Then click 'Add'.
4. Select XMPP from the 'Protocol' list.
5. Set 'Username' to '$u->{username}'.
6. Set 'Domain' to 'cobug.org'.
7. Type in the above password and click 'Add'.
Joining the Multi User Chat:
1. Click 'Buddies', then 'Join Chat'.
2. Make sure you have your '$u->{username}\@cobug.org' account selected.
3. Set 'Room' to 'discussion'.
4. Set 'Server' to 'conference.cobug.org'.
5. Click 'Join'!
Changing your XMPP password (RECOMMENDED):
1. In Pidgin select 'Accounts'.
2. Click the name of your account ($u->{username}\@cobug.org).
3. Click 'Change Password'.
Configure instructions for irssi:
1. Install the irssi-xmpp plugin (e.g. "pkg_add irssi-xmpp" on OpenBSD).
2. After starting irssi, run: /load xmpp
3. Connect to the cobug.org XMPP server:
/xmppconnect -host cobug.org JABBER_ID PASSWORD
4. To join the Multi User Chat:
/j discussion\@conference.cobug.org
If you have further questions, please email them to admin\@cobug.org!
~
);
$msg->send('smtp','localhost');
}
sub addMember {
my $u = shift;
my $asql = qq~
insert into members (
fname,
lname,
email,
username,
has_xmpp,
reminders,
co_native
) values (
?,
?,
?,
?,
?,
?,
?
)
~;
my $asth = $dbh->prepare($asql);
$asth->execute(
$u->{fname},
$u->{lname},
$u->{email},
$u->{username},
$u->{has_xmpp},
$u->{reminders},
$u->{co_native}
);
print "$u->{email} added to the memebers list.\n";
}
sub addUser {
my $u = shift;
my @a = split("\n", `apg`);
my $pass = $a[0];
my $asql = qq~
insert into users (
username,
password
) values (
?,
?
)
~;
if ($u->{has_xmpp}) {
my $asth = $dbh->prepare($asql);
$asth->execute($u->{username}, $pass);
print "$u->{email} added to active users in XMPP.\n";
sendEmail($u, $pass);
}
if ($u->{reminders}) {
`/usr/local/bin/mlmmj-sub -c -a $u->{email} -L /var/spool/mlmmj/announce/`;
print "$u->{email} subscribed to announce@\n";
}
addMember($u);
deleteTmpU($u);
}
sub deleteTmpU {
my $u = shift;
my $dsql = qq~
delete from
user_queue
where
email = ? and
username = ?
~;
my $dsth = $dbh->prepare($dsql);
$dsth->execute($u->{email}, $u->{username});
print "$u->{email} removed from the queue.\n";
}
while (my $row = $sth->fetchrow_hashref()) {
my $str = qq~
$row->{email}
\t$row->{fname} $row->{lname}
\t$row->{username}
\tWants XMPP: $row->{has_xmpp}
\tWants Sub: $row->{reminders}
\tCo Native: $row->{co_native}
~;
print $str;
print "Add? (y/n)\n";
my $resp = <>;
if ($resp =~ m/yes|y/i) {
print "adding $row->{email}\n";
addUser($row);
} else {
print "Purge entry?\n";
my $purge = <>;
if ($purge =~ m/yes|y/i) {
deleteTmpU($row);
}
}
}
$sth->finish();
$dbh->disconnect();