+ sendnoticetouser(proxyscannick,np,"%-20s %-22s %s","IP","Found at","What was open");
+ while(dbfetchrow(pgres)) {
+ sendnoticetouser(proxyscannick,np, "%-20s %-22s %s",dbgetvalue(pgres, 0),
+ dbgetvalue(pgres, 1),
+ dbgetvalue(pgres, 2));
+ }
+ dbclear(pgres);
+ sendnoticetouser(proxyscannick,np,"--- End of list ---");
+}
+
+int proxyscandolistopen(void *sender, int cargc, char **cargv) {
+ nick *usernick = (nick *)sender;
+
+ dbasyncquery(proxyscandolistopen_real,(void *)usernick->numeric,
+ "SELECT IP,TS,RH FROM openproxies WHERE TS>'%lu' ORDER BY TS",time(NULL)-rescaninterval);
+ return CMD_OK;
+}
+
+/*
+ * proxyscanspewip
+ * Check db for open proxies matching the given IP, send to user usernick.
+ */
+
+void proxyscanspewip_real(DBConn *dbconn, void *arg) {
+ nick *np=getnickbynumeric((unsigned long)arg);
+ DBResult *pgres;
+
+ pgres=dbgetresult(dbconn);
+ if (!dbquerysuccessful(pgres)) {
+ Error("proxyscan", ERR_ERROR, "Error loading data.");
+ return;
+ }
+
+ if (dbnumfields(pgres) != 4) {
+ Error("proxyscan", ERR_ERROR, "data format error.");
+ dbclear(pgres);
+ return;
+ }
+
+ if (!np) {
+ dbclear(pgres);
+ return;
+ }
+
+ sendnoticetouser(proxyscannick,np,"%-5s %-20s %-22s %s","ID","IP","Found at","What was open");
+ while(dbfetchrow(pgres)) {
+ sendnoticetouser(proxyscannick,np, "%-5s %-20s %-22s %s",dbgetvalue(pgres, 0),
+ dbgetvalue(pgres, 1),
+ dbgetvalue(pgres, 2),
+ dbgetvalue(pgres, 3));
+ }
+ dbclear(pgres);
+ sendnoticetouser(proxyscannick,np,"--- End of list ---");
+}
+
+void proxyscanspewip(nick *mynick, nick *usernick, unsigned long a, unsigned long b, unsigned long c, unsigned long d) {
+ dbasyncquery(proxyscanspewip_real,(void *)usernick->numeric,
+ "SELECT ID,IP,TS,RH FROM openproxies WHERE IP='%lu.%lu.%lu.%lu' ORDER BY TS DESC LIMIT 10",a,b,c,d);
+
+}
+
+/*
+ * proxyscanshowkill
+ * Check db for open proxies matching the given kill/gline ID, send to user usernick.
+ */
+
+void proxyscanshowkill_real(DBConn *dbconn, void *arg) {
+ nick *np=getnickbynumeric((unsigned long)arg);
+ DBResult *pgres;
+
+ pgres=dbgetresult(dbconn);
+ if (!dbquerysuccessful(pgres)) {
+ Error("proxyscan", ERR_ERROR, "Error loading data.");