Esempio n. 1
0
 function isTriggered()
 {
     clearstatcache();
     if (!file_exists("plugins/Electrica/cache") || filemtime("plugins/Electrica/cache") < time() - 60 * 20 && filectime("plugins/Electrica/cache") < time() - 60 * 20) {
         $this->cacheRanklist();
     }
     if (isset($this->info['text'])) {
         $target = $this->info['text'];
     } else {
         $target = $this->info['nick'];
     }
     $tmp = file_get_contents("plugins/Electrica/cache");
     $pos = stripos($tmp, '>' . $target . '<');
     if ($pos === false) {
         $this->sendOutput($this->CONFIG['notfound_text']);
         return;
     }
     $tmp1 = substr($tmp, 0, $pos);
     $rankpos = strrpos($tmp1, '<b>');
     preg_match("#^<b>(.*?)</b>#", substr($tmp1, $rankpos, 50), $arr);
     $rank = $arr[1];
     $tmp = substr($tmp, $pos - 100, 200);
     $target = preg_quote($target);
     preg_match('#<td align=center>(.*?)</td><td>(' . $target . ')</td><td align=right>(.*?)</td><td.*?>(.*?)</td>#i', $tmp, $arr);
     $output = sprintf($this->CONFIG['chall_text'], $arr[2], $rank, $arr[3], libString::end_s("challenge", $arr[3]), $arr[4]);
     $this->sendOutput($output);
 }
Esempio n. 2
0
 function isTriggered()
 {
     if (isset($this->info['text'])) {
         $target = $this->info['text'];
     } else {
         $target = $this->info['nick'];
     }
     $result = libHTTP::GET("www.rankk.org", "/profile/" . urlencode($target));
     var_dump($result);
     $result = implode("\n", $result['content']);
     if (preg_match("#<title>User Not Found</title>#", $result)) {
         $this->sendOutput($this->CONFIG['notfound_text']);
         return;
     }
     $nick = $target;
     preg_match("#>Rankk Title</td><td>(.*?)</td>#", $result, $arr);
     $title = $arr[1];
     preg_match("#>Rankked</td><td>(.*?)</td>#", $result, $arr);
     $rank = $arr[1];
     preg_match("#>Points</td><td>(.*?)</td>#", $result, $arr);
     $points = $arr[1];
     preg_match("#>Solved</td><td>(.*?)</td>#", $result, $arr);
     $solved = $arr[1];
     preg_match("#>Points</td><td>(.*?)</td>#", $result, $arr);
     $points = $arr[1];
     preg_match("#>Level</td><td>(.*?)</td>#", $result, $arr);
     $level = $arr[1];
     $output = sprintf($this->CONFIG['chall_text'], $nick, $title, $rank, $points, libString::end_s("point", $points), $solved, libString::end_s("challenge", $solved), $nick, $level);
     $this->sendOutput($output);
 }
Esempio n. 3
0
 function showStats()
 {
     $sql = "SELECT COUNT(*) FROM slaps";
     $res = $this->MySQL->sendQuery($sql);
     $count = $res['result'][0]['COUNT(*)'];
     $output = sprintf($this->CONFIG['status_text'], $count, libString::end_s("way", $count));
     $this->sendOutput($output);
     return;
 }
Esempio n. 4
0
 function isTriggered()
 {
     if (!isset($this->info['text'])) {
         $nick = $this->info['nick'];
     } else {
         $nick = $this->info['text'];
     }
     $domain = $this->CONFIG['domain'];
     $get = sprintf($this->CONFIG['get'], urlencode($nick));
     $result = libHTTP::GET($domain, $get);
     $result = implode($result['content'], "\n");
     if (preg_match("/There is no available information for/", $result)) {
         $this->sendOutput(sprintf($this->CONFIG['doesnt_exist'], $nick, $this->CONFIG['domain']));
         return;
     }
     preg_match('#<h3>User information of (VIP )?(.*?)</h3>#', $result, $arr);
     $nick = $arr[2];
     preg_match('#<b>Rank:</b>.*?<font color=".*?">(.*?)</font>#', $result, $arr);
     $rank = $arr[1];
     preg_match('#<b>Donated:</b>.*?<font color=".*?">(.*?)</font>#', $result, $arr);
     $donated = $arr[1];
     if ($donated == "This guy didn't donate anything yet!") {
         $donated = false;
     } else {
         $donated = str_replace(" ", "", $donated);
     }
     preg_match('#<b>Number of hacks:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $solved = $arr[1];
     preg_match('#<b>Rankpoints:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $rankpoints = $arr[1];
     preg_match('#<b>Visited:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $visited = $arr[1];
     preg_match('#<b>Time spent overall:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $timeSpent = $arr[1];
     preg_match('#<b>Last online:</b>.*?<td>(.*?)</td>#', $result, $arr);
     $lastOnline = trim($arr[1]);
     preg_match('#<b>User\'s current status:</b>.*?<td>(.*?)</td>#', $result, $arr);
     if ($arr[1] == "offline") {
         $online = false;
     } else {
         $online = true;
     }
     $output = sprintf($this->CONFIG['text_status'], $nick, $rank, $solved, libString::end_s("challenge", $solved), $rankpoints);
     $output .= " ";
     $output .= sprintf($this->CONFIG['text_visit'], $nick, $this->CONFIG['domain'], $visited, libTime::secondsToString($timeSpent));
     if ($donated) {
         $output .= " ";
         $output .= sprintf($this->CONFIG['text_donate'], $nick, $donated);
     }
     $output .= " ";
     if ($online) {
         $output .= sprintf($this->CONFIG['text_online'], $nick, $domain);
     } else {
         $output .= sprintf($this->CONFIG['text_lastonline'], $nick, $lastOnline);
     }
     $this->sendOutput($output);
 }
Esempio n. 5
0
 function showStats()
 {
     $target = isset($this->info['text']) ? $this->info['text'] : $this->info['nick'];
     if ($this->info['isQuery']) {
         $sql = "SELECT nick FROM stats WHERE nick='" . addslashes($target) . "'";
         $res = $this->MySQL->sendQuery($sql);
         if ($res['count'] == 0) {
             $this->sendOutput("No stats available about '" . $target . ".");
             return;
         }
         $nick = $res['result'][0]['nick'];
         $sql = "SELECT\n\t\t\t\t\t\tSUM(chars) chars,\n\t\t\t\t\t\tSUM(words) words,\n\t\t\t\t\t\tSUM(`lines`) `lines`,\n\t\t\t\t\t\tSUM(actions) actions,\n\t\t\t\t\t\tSUM(smilies) smilies,\n\t\t\t\t\t\tSUM(kicks) kicks,\n\t\t\t\t\t\tSUM(kicked) kicked,\n\t\t\t\t\t\tSUM(modes) modes,\n\t\t\t\t\t\tSUM(topics) topics\n\t\t\t\t\tFROM\n\t\t\t\t\t\tstats\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tnick='" . addslashes($target) . "'\n\t\t\t\t\t";
         $res = $this->MySQL->sendQuery($sql);
         $data = $res['result'][0];
         $output = $nick . ": ";
     } else {
         $sql = "SELECT * FROM stats WHERE channel='" . addslashes($this->info['channel']) . "' AND nick = '" . addslashes($target) . "'";
         $res = $this->MySQL->sendQuery($sql);
         if ($res['count'] == 0) {
             $this->sendOutput("No stats available about '" . $target . "' in '" . $this->info['channel'] . "'");
             return;
         }
         $data = $res['result'][0];
         $output = $data['nick'] . " in " . $data['channel'] . ": ";
     }
     $output .= $data['chars'] . " " . libString::end_s("char", $data['chars']) . ", ";
     $output .= $data['words'] . " " . libString::end_s("word", $data['words']) . ", ";
     $output .= $data['lines'] . " " . libString::end_s("line", $data['lines']) . ", ";
     $output .= round($data['chars'] / $data['lines'], 2) . " cpl, ";
     $output .= round($data['words'] / $data['lines'], 2) . " wpl, ";
     $output .= $data['actions'] . " " . libString::end_s("action", $data['actions']) . ", ";
     $output .= $data['smilies'] . " " . libString::end_s("smilie", $data['smilies']) . ", ";
     $output .= "kicked " . $data['kicks'] . " " . libString::end_s("luser", $data['kicks']) . ", ";
     $output .= "been kicked " . $data['kicked'] . " " . libString::end_s("time", $data['kicked']) . ", ";
     $output .= "set " . $data['modes'] . " " . libString::end_s("mode", $data['modes']) . ", ";
     $output .= "changed the topic " . $data['topics'] . " " . libString::end_s("time", $data['topics']) . ".";
     $this->sendOutput($output);
 }
Esempio n. 6
0
 function showUserStats($nick, $channel)
 {
     $sql = "SELECT\n\t\t\t\t\tnick, points, last_played\n\t\t\t\tFROM\n\t\t\t\t\thangman_stats\n\t\t\t\tWHERE\n\t\t\t\t\tchannel='" . addslashes($channel) . "'\n\t\t\t\tORDER BY\n\t\t\t\t\tpoints\n\t\t\t\tDESC\n\t\t\t\t";
     $res = $this->MySQL->sendQuery($sql);
     $check = false;
     foreach ($res['result'] as $key => $value) {
         if (strtolower($value['nick']) == strtolower($nick)) {
             $check = true;
             $nick = $value['nick'];
             $rank = $key + 1;
             $points = $value['points'];
             $last_played = $value['last_played'];
             break;
         }
     }
     if (!$check) {
         $this->sendOutput($nick . " has never played Hangman.");
         return;
     }
     $output = sprintf($this->CONFIG['userstats_text'], $nick, $points, libString::end_s("point", $points), $rank, $nick, $last_played);
     $this->sendOutput($output);
 }
Esempio n. 7
0
 function showPlayerStats($nick, $channel = null)
 {
     $sql = "SELECT\n\t\t\t\t\tnick,\n\t\t\t\t\tSUM(played) played,\n\t\t\t\t\tSUM(won) won,\n\t\t\t\t\tSUM(lost) lost,\n\t\t\t\t\tSUM(trigger_pulled) trigger_pulled,\n\t\t\t\t\tSUM(clicks) clicks\n\t\t\t\tFROM\n\t\t\t\t\troulette_stats\n\t\t\t\tWHERE\n\t\t\t\t\tnick='" . addslashes($nick) . "'\n\t\t\t\t\t" . (isset($channel) ? " AND channel='" . addslashes($channel) . "'" : "") . "\n\t\t\t\tGROUP BY\n\t\t\t\t\tnick";
     $res = $this->MySQL->sendQuery($sql);
     if ($res['count'] == 0) {
         $this->sendOutput(sprintf("%s has never played roulette.", $nick));
         return;
     }
     $stats = $res['result'][0];
     $text = "%s has played %s %s, won %s and lost %s. %s pulled the trigger %s %s and found the chamber empty on %s %s.";
     $this->sendOutput(sprintf($text, $stats['nick'], $stats['played'], libString::end_s("game", $stats['played']), $stats['won'], $stats['lost'], $stats['nick'], $stats['trigger_pulled'], libString::end_s("time", $stats['trigger_pulled']), $stats['clicks'], libString::end_s("ocassion", $stats['clicks'])));
 }