· 9 years ago · May 21, 2017, 06:54 PM
1on *:LOAD:{
2 ipstore.setup
3}
4
5alias ipstore.setup {
6 ; Ask for database info, loop for as long as we get valid info
7 while (1) {
8 var %host = $?="Please insert the hostname of the MySQL server to connect to:"
9 var %user = $?="Please insert the username to identify with:"
10 var %pass = $?*="Please insert the password to identify with:"
11
12 ; Test the connection
13 var %ipstore.db = $mysql_connect(%host, %user, %pass)
14 if (!%ipstore.db) {
15 var %confirm = $?!="Failed to connect to the specified MySQL server with given username and password. Try again?"
16 if (!%confirm) {
17 echo 4 -a The script wasn't loaded.
18 unload -rs $script
19 return
20 }
21 }
22 else {
23 ; All fine, break out of the loop
24 break
25 }
26 }
27
28 ; Ask for database name
29 while (1) {
30 var %db = $?="Please insert the name of the database that is used:"
31
32 ; Test the database
33 if (!$mysql_select_db(%ipstore.db, %db)) {
34 echo 4 -a error: %mysql_errstr
35 var %confirm = $?!="Failed to use the specified database name. Try again?"
36 if (!%confirm) {
37 echo 4 -a The script wasn't loaded.
38 mysql_close %ipstore.db
39 unload -rs $script
40 return
41 }
42 }
43 else {
44 ; All fine, break out of the loop
45 break
46 }
47 }
48
49 ; Write the database info to an INI file so it can be loaded later on
50 writeini ipharvest.ini info host %host
51 writeini ipharvest.ini info user %user
52 writeini ipharvest.ini info pass %pass
53 writeini ipharvest.ini info db %db
54
55 ; Create the table
56 mysql_exec %ipstore.db CREATE TABLE IF NOT EXISTS MissionDM ( $&
57 id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, $&
58 nick VARCHAR(50) NOT NULL, $&
59 ip VARCHAR(100) NOT NULL, $&
60 hostmask VARCHAR(100) NOT NULL, $&
61 time DATETIME NOT NULL, $&
62 INDEX (ip, nick, hostmask) $&
63 )
64
65 ; Tell that setup was successful
66 echo 3 -a ipstore script loaded successfully!
67
68 ; Close test connection
69 mysql_close %ipstore.db
70}
71
72on *:text:*:#:{
73 if ($chan == #mp-missiondm-admin) {
74 if (mpmdmbr == $nick) {
75 if ((($1 == name:) && ($3 == IP:) && ($5 == Host:))) {
76 var %sql = INSERT INTO missiondm (nick, ip, hostmask, time) VALUES (?, ?, ?, NOW())
77 noop $mysql_exec(%ipstore.db, %sql, $2, $4, $6)
78 }
79 }
80 if ($nick isop #) {
81 if ($1 == !testread ) {
82 ; Find all nicks for matching addresses
83 var %wildcard = $+($replace($2,*,%,?,_))
84 var %sql = SELECT id, nick, ip, hostmask, time FROM track WHERE missiondm = ? AND ip LIKE ?
85 var %res = $mysql_query(%ipstore.db, %sql, %wildcard)
86
87 ; Display results
88 var %i = 1
89 msg $chan Found $mysql_num_rows(%res) nicks for $2
90 while ($mysql_fetch_row(%res, row)) {
91 msg $chan $+(%i,:) $hget(row, nick) from $hget(row, ip) last used at $hget(row, hostmask) $hget(row, time)
92
93 inc %i
94 }
95 }
96 }
97 }
98}
99
100
101
102
103
104;msg $chan Sending Message on command: $2 $+ , $4 $+ , $6
105;{ var %sql = SELECT id FROM missiondm WHERE nick = ? AND ip = ? AND hostmask = ? {
106;[04-16|13:55:45] <mpmdmbr> Name: Spinzaku IP: 80.126.167.248 Host: a80-126-167-248.adsl.xs4all.nl