Advertisement
Guest User

Updated Report System.pl

a guest
Nov 3rd, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.87 KB | None | 0 0
  1. sub EVENT_SAY
  2. {
  3.     if($text=~/^Report/i && !defined $qglobals{Report})
  4.     {
  5.         $dbh = DBI_CONNECT();
  6.         quest::setglobal("Report", 1, 5, "M30");
  7.         my $time = localtime;
  8.         my $split = substr($text, 7);
  9.         quest::gmsay("$name ($time): $split", 331, 1, 0, 80);
  10.         $sth = $dbh->prepare("SELECT max(id) FROM messaging");
  11.         $sth->execute();
  12.         my $id = $sth->fetchrow_array()+1;
  13.         $query = "INSERT INTO messaging VALUES ('$id', '$name', '$split', '$time')";
  14.         $sth = $dbh->do($query);
  15.         $sth->finish();
  16.         $dbh->disconnect();
  17.     }  
  18.     elsif($text=~/^Report/i && defined $qglobals{Report})
  19.     {
  20.         $client->Message(327, "You have sent in a report in the last 30 minutes, try again later.");
  21.     }
  22.     if($status >= 200)
  23.     {
  24.         if($text=~/^ClearMessages/i)
  25.         {
  26.             $dbh = DBI_CONNECT();
  27.             $query = "TRUNCATE TABLE messaging";
  28.             $sth = $dbh->do($query);
  29.             quest::gmsay("All reports have been cleared by $name.", 331, 1, 0, 80);
  30.         }
  31.     }
  32. }
  33.  
  34. sub EVENT_CONNECT
  35. {
  36.     if($status >= 80)
  37.     {
  38.         $dbh = DBI_CONNECT();
  39.         $query = "SELECT COUNT(id) FROM messaging";
  40.         $sth = $dbh->prepare($query);
  41.         $sth->execute();
  42.         my $count = $sth->fetchrow_array();
  43.         if($count > 1)
  44.         {
  45.             quest::popup("Messages!", plugin::PWColor("Green") . "You have " . plugin::PWColor("Yellow") . $count . "</c> messages to view.");
  46.         }
  47.         elsif($count == 1)
  48.         {
  49.             quest::popup("Messages!", plugin::PWColor("Green") . "You have " . plugin::PWColor("Orange") . $count . "</c> message to view.");
  50.         }
  51.         elsif($count == 0)
  52.         {              
  53.             quest::popup("Messages!", plugin::PWColor("Green") . "You have " . plugin::PWColor("Red") . $count . "</c> messages to view.");
  54.         }
  55.     }
  56. }
  57.  
  58. sub DBI_CONNECT
  59. {
  60.     use DBI;
  61.     $database = "DATABASE";
  62.     $host = "HOST";
  63.     $username = "USERNAME";
  64.     $password = "PASSWORD";
  65.     $dbh = DBI->connect("DBI:mysql:database=$database;host=$host", "$username", "$password", {RaiseError => 1});
  66.     return $dbh;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement