Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub EVENT_SAY
- {
- if($text=~/^Report/i && !defined $qglobals{Report})
- {
- $dbh = DBI_CONNECT();
- quest::setglobal("Report", 1, 5, "M30");
- my $time = localtime;
- my $split = substr($text, 7);
- quest::gmsay("$name ($time): $split", 331, 1, 0, 80);
- $sth = $dbh->prepare("SELECT max(id) FROM messaging");
- $sth->execute();
- my $id = $sth->fetchrow_array()+1;
- $query = "INSERT INTO messaging VALUES ('$id', '$name', '$split', '$time')";
- $sth = $dbh->do($query);
- $sth->finish();
- $dbh->disconnect();
- }
- elsif($text=~/^Report/i && defined $qglobals{Report})
- {
- $client->Message(327, "You have sent in a report in the last 30 minutes, try again later.");
- }
- if($status >= 80)
- {
- if($text=~/^ViewMessages/i)
- {
- $dbh = DBI_CONNECT();
- $query = "SELECT id, name, message, time FROM messaging ORDER BY id ASC LIMIT 0,1000";
- $sth = $dbh->prepare($query);
- $sth->execute();
- $query2 = "SELECT COUNT(id) FROM messaging";
- $sth2 = $dbh->prepare($query2);
- $sth2->execute();
- my $results = $sth2->fetchrow_array();
- if($results > 0)
- {
- while(my($pid, $pname, $pmessage, $ptime) = $sth->fetchrow_array())
- {
- $client->Message(327, "Message $pid - $pname ($ptime): $pmessage");
- }
- $sth->finish();
- $dbh->disconnect();
- }
- else
- {
- $client->Message(327, "There are currently no reports.");
- }
- }
- }
- if($status >= 200)
- {
- if($text=~/^ClearMessages/i)
- {
- $dbh = DBI_CONNECT();
- $query = "TRUNCATE TABLE messaging";
- $sth = $dbh->do($query);
- quest::gmsay("All reports have been cleared by $name.", 331, 1, 0, 80);
- }
- }
- }
- sub DBI_CONNECT
- {
- use DBI;
- $database = "CHANGEME";
- $host = "CHANGEME";
- $username = "CHANGEME";
- $password = "CHANGEME";
- $dbh = DBI->connect("DBI:mysql:database=$database;host=$host", "$username", "$password", {RaiseError => 1});
- return $dbh;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement