ah, thix for the tips, in between i got it running.
i think its always useful when u can shoot urls with GET_variables.
maybe its noobish.
the thing in my case is: im having more information cause the admin is always a phpbb user.
ingame rights are in fact hooked to phpbb groups, from phpbb integrates mumble, irc and teh rest.
so i have a user that posts, its the admin. that user can attach a demo, a poll is automatically started.
here u can see a (srv very) old "
dswp cheatsheet" (05-2009)
oki first the result...
http://www.dswp.de/old/lamas-corner/(all posts with red name are auto- generated)
now i have 2 scripts...
1.) B3 Linkshooter
#
# BanTopic Plugin for BigBrotherBot(B3) (www.bigbrotherbot.net)
# Copyright (C) 2011 <[dswp]Wursti>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Changelog:
# version 0.0.1: 10.10.2011 Basic functionality by sending banned clients ID via http request PHP $_GET variable
#
#
#
__version__ = '0.0.1'
__author__ = 'plz'
import b3, time, threading, re
from b3 import clients
import b3.events
import b3.plugin
import b3.cron
import datetime, string
import urllib
class BantopicPlugin(b3.plugin.Plugin):
def startup(self):
# listen for !ban events
self.registerEvent(b3.events.EVT_CLIENT_BAN_TEMP)
def onEvent(self, event):
clientid = event.client.id
urlStr = 'http://www.dswp.de/old/dswp_tools/bantopic/bantopic.php?srvport=22222&clientid=' + str(clientid)
try:
fileHandle = urllib.urlopen(urlStr)
fileHandle.close()
except IOError:
self.plugin.warn("http request failed")
2.) PhpBB Poster
// know that phpbb has its own posting api, this is cheap hax.
// maden 10-2011 by wursti && do not try this at home! :P
include '../../config.php' ;
$testmode = 0;
$sqllog = 0;
//who let the dogs in?
if ($testmode == 0) {
$ip = $_SERVER['REMOTE_ADDR'];
if ( $ip != '192.168.9.1' ) {echo "$ip must go home now!"; die; }
}
$clientid = $_GET['clientid'];
$srvport = $_GET['srvport'];
if ($clientid == '') {echo 'hello world?'; die; }
if ($srvport == '') {echo 'forgot some serwer port?'; die; }
//debug $clientid = 7900; $srvport = 22225;
//Grab corresponting Admin and Userdata
$db = mysql_connect ($dbhost, $dbuser, $dbpasswd) or die(mysql_error());
mysql_select_db($dbname, $db) or die('Cannot select database');
$sql_banned = "SELECT
pu.user_id AS admin_phpbb_id,
pe.admin_id AS admin_b3_id,
pu.username AS admin_phpbb_name,
cla.name AS admin_b3_name,
sta.id AS admin_xlr_id,
cl.id AS client_b3_id,
stc.id AS client_xlr_id,
cl.name AS client_name,
FROM_UNIXTIME(pe.time_add) AS time_add_normal,
pe.time_add,
UNIX_TIMESTAMP(now()) as time_now,
FROM_UNIXTIME(pe.time_edit) AS time_edit_normal,
FROM_UNIXTIME(pe.time_expire) AS time_expire_normal,
pe.duration,
pe.reason,
pe.id AS penalty_id
FROM
phpbb_users pu
INNER JOIN bot$srvport.penalties pe on pu.b3_id_$srvport = pe.admin_id
INNER JOIN bot$srvport.clients cl on pe.client_id = cl.id
INNER JOIN bot$srvport.clients cla on pe.admin_id = cla.id
INNER JOIN bot$srvport.xlr_playerstats sta on pe.admin_id = sta.client_id
LEFT JOIN bot$srvport.xlr_playerstats stc on pe.client_id = stc.client_id -- maybe victim has no stats yet...
where pe.client_id = $clientid
order by pe.time_add desc
limit 0,1;"
;
//debug echo $sql_banned;
$query=mysql_query($sql_banned, $db);
$row=mysql_fetch_assoc($query);
// htmlentities($str, ENT_QUOTES)
$admin_phpbb_id = $row['admin_phpbb_id'];
$admin_b3_id = $row['admin_b3_id'];
$admin_phpbb_name = htmlentities($row['admin_phpbb_name'], ENT_QUOTES);
$admin_b3_name = htmlentities($row['admin_b3_name'], ENT_QUOTES);
$admin_xlr_id = $row['admin_xlr_id'];
$client_b3_id = $row['client_b3_id'];
$client_xlr_id = $row['client_xlr_id'];
$client_name = htmlentities($row['client_name'], ENT_QUOTES);
$time_add_normal = $row['time_add_normal'];
$time_add = $row['time_add'];
$time_now = $row['time_now'];
$time_edit_normal = $row['time_edit_normal'];
$time_expire_normal = $row['time_expire_normal'];
$duration = $row['duration'];
$reason = htmlentities($row['reason'], ENT_QUOTES);
$penalty_id = $row['penalty_id'];
//logging excel- compatible csv omg
$logfile = "./autobanlog.csv";
if (file_exists($logfile)) { $logexist = 1; }
$linebreak = "\n";
$firstline = "admin_phpbb_id ; admin_b3_id ;admin_phpbb_name ; admin_b3_name ; admin_xlr_id ; client_b3_id ; client_xlr_id ; client_name ; time_add_normal ; time_add ; time_now ; time_edit_normal ; time_expire_normal ; duration ; reason ; penalty_id ;";
$logline = "$admin_phpbb_id ; $admin_b3_id ;$admin_phpbb_name ; $admin_b3_name ; $admin_xlr_id ; $client_b3_id ; $client_xlr_id ; $client_name ; $time_add_normal ; $time_add ; $time_now ; $time_edit_normal ; $time_expire_normal ; $duration ; $reason ; $penalty_id ;";
$fh = fopen($logfile, 'a') or die("can't open $logfile");
if ($logexist != 1) {
fwrite($fh, $firstline);
fwrite($fh, $linebreak);
}
fwrite($fh, $logline);
fwrite($fh, $linebreak);
if ($sqllog == 1) {
fwrite($fh, $linebreak);
fwrite($fh, $sql_banned);
fwrite($fh, $linebreak);
fwrite($fh, $linebreak);
}
fclose($fh);
$duration_days = $duration / ( 1440 );
$time_add_ago = $time_now - $time_add ;
//die on several reasons^^
if ($testmode == 0) {
if ($duration == 0 ) {echo 'kick only?'; die; }
if ($duration < 4319 ) {echo 'shorter then 3d ban.'; die; }
if ($admin_b3_id == 0 ) {echo 'b3 generated penalty. ciao.'; die; }
if ($reason == '' ) {echo 'admin must give a reason lol.'; die; }
if ( $time_add_ago > 3 ) {echo "that ban is $time_add_ago seconds old. 3 seconds is maximum"; die; }
}
if ($srvport == 22222) {$statspath = "[url=http://www.dswp.de/old/tdm-player$client_xlr_id:359wpamd] $client_xlr_id [/url:359wpamd]";
$echlonpath = "[url=http://www.dswp.de/echelon/clientdetails.php?game=1&id=$client_b3_id:359wpamd] $client_b3_id [/url:359wpamd]";
}
elseif ($srvport == 22223) {$statspath = "[url=http://www.dswp.de/old/bomb-player$client_xlr_id:359wpamd] $client_xlr_id [/url:359wpamd]";
$echlonpath = "[url=http://bomb.dswp.de/echelon/clientdetails.php?game=1&id=$client_b3_id:359wpamd] $client_b3_id [/url:359wpamd]";
}
elseif ($srvport == 22225) {$statspath = "[url=http://www.dswp.de/old/ts-player$client_xlr_id:359wpamd] $client_xlr_id [/url:359wpamd]";
$echlonpath = "[url=http://teamsurvivor.dswp.de/echelon/clientdetails.php?game=1&id=$client_b3_id:359wpamd] $client_b3_id [/url:359wpamd]";
}
if ($client_xlr_id == ''){ $statspath = "No Stats collected yet."; }
//create topic in lamas corner
// post a new topic, post, edit forums
//setup post text
$post_text= <<
$client_name banned cause $reason
XLR ID: $statspath
B3 ID: $echlonpath
Ban Added: $time_add_normal
TempBan Expires: $time_expire_normal
Duration: $duration_days days
Penalty ID: $penalty_id
ENDE;
$new_cyc_time = time();
// new post
mysql_query("INSERT INTO phpbb_posts (forum_id,poster_id,post_time,post_subject,post_text,bbcode_bitfield,bbcode_uid)
VALUES ('16','$admin_phpbb_id','$new_cyc_time','$client_name banned [$reason]','$post_text','EA==','359wpamd')");
$cyc_postid = mysql_insert_id();
// new topic with poll
mysql_query("INSERT INTO phpbb_topics
(forum_id,topic_title,topic_poster,topic_time,topic_first_post_id,topic_first_poster_name,topic_first_poster_colour,topic_last_post_id,topic_last_poster_id,topic_last_poster_name,topic_last_poster_colour,topic_last_post_subject,topic_last_post_time,topic_auto_created,poll_title,poll_start,poll_max_options,poll_vote_change)
VALUES ('16','[BANNED] $client_name BY [$admin_b3_name] CAUSE [$reason]','$admin_phpbb_id','$new_cyc_time','$cyc_postid','$admin_phpbb_name','FC0204','$cyc_postid','$admin_phpbb_id','$admin_phpbb_name','FC0204','$client_name banned [$reason]','$new_cyc_time','1','Extend Ban?','$new_cyc_time','1','1')");
$cyc_topicid = mysql_insert_id();
//new poll with topic id
mysql_query("INSERT INTO phpbb_poll_options
(poll_option_id,topic_id,poll_option_text,poll_option_total)
VALUES('1','$cyc_topicid','Extend Ban!','1')");
mysql_query("INSERT INTO phpbb_poll_options
(poll_option_id,topic_id,poll_option_text,poll_option_total)
VALUES('2','$cyc_topicid','Drop Ban!','0')");
//store a vote for the admin as Extend!
mysql_query("INSERT INTO phpbb_poll_votes
(topic_id,poll_option_id,vote_user_id,vote_user_ip)
VALUES('$cyc_topicid','1','$admin_phpbb_id','192.168.9.1')");
// topic_id into post
mysql_query("UPDATE phpbb_posts SET topic_id=$cyc_topicid WHERE post_id=$cyc_postid");
// edit forum
mysql_query("UPDATE phpbb_forums SET forum_posts=forum_posts+1,forum_topics=forum_topics+1,
forum_topics_real=forum_topics_real+1,forum_last_post_id='$cyc_postid',forum_last_poster_id='$admin_phpbb_id',
forum_last_post_subject='$client_name banned [$reason]',forum_last_post_time='$new_cyc_time',
forum_last_poster_name='$admin_phpbb_name',forum_last_poster_colour='FC0204' WHERE forum_id='16'");
// +1 post for the admin :)
mysql_query("UPDATE phpbb_users SET user_posts=user_posts+1 WHERE user_id=$admin_phpbb_id");
?>
ill post the thing again when its finished.
i dunno how big the need of other people is, its everything dependent on phpbb.
the b3 1.70 should have more variables coming with the CLIENT_TEMP_BAN, so the query and filtering could be less intensively done (for exampe get wether a human or B3 bans before shooting mysql)