function isTriggered() { if (!isset($this->data['text'])) { $this->printUsage(); return; } $player = $this->data['text']; // API by EastBite ! $url = 'http://ebeur.eastbit.net:8888/get/' . rawurlencode($player) . '/matchall'; $page = libHTTP::GET($url); if ($page === FALSE || strlen($page) == 0) { $this->reply('An error occured while retrieving the data.'); return; } $result = json_decode($page, true); if ($result == NULL) { $this->reply('The data could not be parsed successfully.'); return; } if (!isset($result["error"])) { for ($i = 0; $i < count($result["players"]); $i++) { $this->reply(sprintf("%s is currently playing %s on server : %s.", $result["players"][$i]["name"], trim($result["servers"][$i]["map"]), $result["servers"][$i]["name"])); } } else { $this->reply(sprintf("No %s found online.", $player)); } }
function getWikiText($term, $server, $path, $notfound) { $term = str_replace(" ", "_", $term); $term[0] = strtoupper($term[0]); $html = libHTTP::GET('http://' . $server . $path . str_replace("%23", "#", urlencode($term))); $content = str_replace(array("\r", "\n"), ' ', $html); while (strstr($content, ' ')) { $content = str_replace(' ', ' ', $content); } if (stristr($content, $notfound)) { return false; } $pos = strpos($content, '<div id="contentSub">'); $content = substr($content, $pos); $content = preg_replace("#<tr.*?</tr>#", '', $content); $content = str_replace("</li>", ",</li>", $content); preg_match_all("#<(p|li)>(.*?)</(p|li)>#", $content, $arr); $content = ""; foreach ($arr[2] as $row) { $row = trim(strip_tags($row)); if (empty($row)) { continue; } $content .= $row . " "; } $content = html_entity_decode($content); $content = str_replace(chr(160), " ", $content); $output['text'] = $content; $output['link'] = "http://" . $server . $path . urlencode($term); return $output; }
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); }
function getRecentTracks($nick) { if ($this->apiKey !== false) { $ret = libHTTP::GET('http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks' . '&user='******'&api_key=' . $this->apiKey); $xml = simplexml_load_string($ret); if (!$xml || !empty($xml->error[0])) { return false; } if (intval($xml->recenttracks['total']) == 0) { return array('notracks' => true); } $res['title'] = $xml->recenttracks->track[0]->artist . ' - ' . $xml->recenttracks->track[0]->name; $res['nowplaying'] = $xml->recenttracks->track[0]['nowplaying'] == 'true'; return $res; } else { $ret = libHTTP::GET('http://ws.audioscrobbler.com/2.0/user/' . urlencode($nick) . '/recenttracks.rss'); $xml = simplexml_load_string($ret); if (!$xml) { return false; } if (empty($xml->channel->item)) { return array('notracks' => true); } return array('title' => $xml->channel->item[0]->title, 'nowplaying' => false); } }
static function getYoutubeData($youtube_id) { if (empty($youtube_id)) { return false; } $res = libHTTP::GET('gdata.youtube.com', '/feeds/api/videos/' . $youtube_id); if ($res['raw'] == 'Invalid id') { return false; } $xml = simplexml_load_string($res['raw']); $data = array(); $media = $xml->children('http://search.yahoo.com/mrss/'); $data['title'] = (string) $media->group->title; $data['description'] = (string) $media->group->description; $data['category'] = (string) $media->group->category; $data['keywords'] = explode(', ', $media->group->keywords); $data['link'] = (string) $media->group->player->attributes()->url; $data['duration'] = (int) $media->children('http://gdata.youtube.com/schemas/2007')->duration->attributes()->seconds; $data['thumbnails'] = array(); foreach ($media->group->thumbnail as $thumbnail) { array_push($data['thumbnails'], array('url' => (string) $thumbnail->attributes()->url, 'width' => (int) $thumbnail->attributes()->width, 'height' => (int) $thumbnail->attributes()->height)); } $data['published'] = strtotime($xml->published); $data['author'] = (string) $xml->author->name; $gd = $xml->children('http://schemas.google.com/g/2005')->rating->attributes(); $data['rating'] = (double) $gd->average; $data['num_raters'] = (int) $gd->numRaters; $data['views'] = (int) $xml->children('http://gdata.youtube.com/schemas/2007')->statistics->attributes()->viewCount; return $data; }
function isTriggered() { if (isset($this->info['text'])) { $target = $this->info['text']; } else { $target = $this->info['nick']; } $host = $this->IRCBot->getHost($target); if (!$host) { $this->sendOutput($target . ' is not online.'); return; } $res = libHTTP::GET('www.geoiptool.com', '/de/?IP=' . urlencode($host)); if (strstr($res['raw'], 'function.gethostbyaddr')) { $this->sendOutput("Can't trace " . $target . ". Host is cloaked."); return; } else { $raw = strtr($res['raw'], array("\n" => " ", "\r" => " ")); preg_match('#IP-Addresse:.*?<td.*?>(.*?)</td>#', $raw, $arr); $ip = $arr[1]; preg_match('#Stadt:.*?<td.*?>(.*?)</td>#', $raw, $arr); $city = utf8_encode($arr[1]); preg_match('#Land:.*?<td.*?><a.*?>(.*?)</a>#', $raw, $arr); $country = utf8_encode(trim($arr[1])); preg_match('#Region.*?</td.*?><a.*?>(.*?)</a>#', $raw, $arr); $region = utf8_encode($arr[1]); //$this->sendOutput('IP: '.$ip); $this->sendOutput($target . '\'s location: ' . $city . ', ' . $region . ', ' . $country); } }
function onChannelMessage() { $link = libString::getLink($this->info['text']); if (!$link) { return; } if (substr(strtolower($link), 0, 7) == 'http://') { $link = substr($link, 7); } list($host, $get) = explode('/', $link, 2); if ($host == 'youtube.com' || $host == 'www.youtube.com') { return; } $get = '/' . $get; $res = libHTTP::GET($host, $get); if (!$res) { return; } if (substr($res['header']['Content-Type'], 0, 9) != 'text/html') { return; } $check = preg_match('#<title>(.*?)</title>#i', $res['raw'], $arr); if (!$check || empty($arr[1])) { return; } $title = html_entity_decode($arr[1], null, 'UTF-8'); $title = strtr($title, array("\r" => ' ', "\n" => ' ')); if ($title == '301 Moved') { return; } $this->sendOutput($title . " ( http://" . $link . " )"); }
function getWikiText($term, $server, $path, $notfound) { $term = str_replace(" ", "_", $term); $term[0] = strtoupper($term[0]); $result = libHTTP::GET($server, $path . str_replace("%23", "#", urlencode($term))); $header = $result['header']; if (isset($header['Location'])) { preg_match("#" . $path . "(.*)#", $header['Location'], $arr); return $this->getWikiText(urldecode($arr[1]), $server, $path, $notfound); } $content = implode(" ", $result['content']); if (stristr($content, $notfound)) { return false; } $pos = strpos($content, '<div id="contentSub">'); $content = substr($content, $pos); $content = preg_replace("#<tr.*?</tr>#", '', $content); $content = str_replace("</li>", ",</li>", $content); preg_match_all("#<(p|li)>(.*?)</(p|li)>#", $content, $arr); $content = ""; foreach ($arr[2] as $row) { $row = trim(strip_tags($row)); if (empty($row)) { continue; } var_dump($content); $content .= $row . " "; } $content = html_entity_decode($content); $content = str_replace(chr(160), " ", $content); $output['text'] = $content; $output['link'] = "http://" . $server . $path . urlencode($term); return $output; }
private function getStatus() { $array = array(); $page = libHTTP::GET('https://www.harmony-hosting.com/help/monitoring/'); preg_match_all('#<td>(\\w+)<\\/td>[^"]+"[^"]+">([^<]+)#', $page, $array); $array = $this->buildArray($array); return $array; }
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); }
function cacheRanklist() { $result = libHTTP::POST("caesum.com", "/game/stats.php?action=rollyourown", "maxusers=0&ind=on&action=showcustomhof&blah=Show+HOF", "key=M0qUaqlkmfMoLq0Jdlb2aQ4F8032"); $tmp = $result['content']; $fp = fopen("plugins/Electrica/cache", "w"); foreach ($tmp as $line) { fputs($fp, $line . "\n"); } fclose($fp); }
function isTriggered() { if (isset($this->info['text'])) { $target = $this->info['text']; } else { $target = $this->info['nick']; } $result = libHTTP::GET("mibs-challenges.de", "/userinfo.php?profile=" . urlencode($target)); $this->sendOutput($result['content'][0]); }
private function getHappyHardcoreStats() { $html = libHTTP::GET('http://www.happyhardcore.com/radio/player/tools/timequery.asp'); preg_match_all('/station\\.(.+?)\\s*=\\s*\'?(.*?)\'?\\s*;/', $html, $arr); $raw_data = array(); for ($x = 0; $x < sizeof($arr[1]); $x++) { $raw_data[$arr[1][$x]] = $arr[2][$x]; } $data = array('is_live' => $raw_data['IsLive'] === 'false' ? false : true, 'artist' => str_replace('\\', '', $raw_data['TrackArtist']), 'title' => str_replace('\\', '', $raw_data['TrackTitle']), 'length' => $raw_data['TrackLength'], 'progress' => $raw_data['TrackLength'] - $raw_data['TrackRemain'], 'listeners' => $raw_data['ListenerCount']); return $data; }
function isTriggered() { if (isset($this->data['text'])) { $target = $this->data['text']; } else { $target = $this->User->name; } if ($target[0] == '!' && strstr($target, ' ') === false) { $target .= ' ' . $this->User->name; } $html = libHTTP::GET('http://www.wechall.net/wechall.php?username=' . urlencode($target)); $this->reply($html); }
function isTriggered() { $isUser = true; $host = false; if (isset($this->data['text'])) { if (strpos($this->data['text'], '.') === false) { $target = strtolower($this->data['text']); $host = isset($this->Server->users[$target]) ? $this->Server->users[$target]->host : false; foreach ($this->cloakedRegexps as $regex) { if (preg_match($regex, $host)) { $this->reply("Can't trace " . $target . ". Host is cloaked."); return; } } } else { // if we got a non-nick treat it as IP or host $host = $this->data['text']; $isUser = false; } } else { // no param, trace current user $target = $this->User->nick; $host = $this->User->host; } if ($host === false) { $this->reply('I don\'t know this nick.'); return; } $html = libHTTP::GET('http://www.geoiptool.com/?IP=' . urlencode($host)); preg_match('#IP Address:.*?<td.*?>(.*?)</td>#s', $html, $arr); $ip = $arr[1]; preg_match('#City:.*?<td.*?>(.*?)</td>#s', $html, $arr); $city = utf8_encode($arr[1]); preg_match('#Country:.*?<td.*?><a.*?>(.*?)</a>#s', $html, $arr); $country = utf8_encode(trim($arr[1])); preg_match('#Region.*?</td.*?><a.*?>(.*?)</a>#s', $html, $arr); $region = utf8_encode($arr[1]); if ($isUser) { if (empty($city) && empty($region) && empty($country)) { $this->reply('Can\'t trace ' . $target . '. Host seems cloaked.'); } else { $this->reply($target . '\'s location: ' . (!empty($city) ? $city . ', ' : '') . (!empty($region) ? $region . ', ' : '') . $country); } } else { if (empty($city) && empty($region) && empty($country)) { $this->reply('Can\'t trace ' . $host . '.'); } else { $this->reply($this->data['text'] . '\'s location: ' . (!empty($city) ? $city . ', ' : '') . (!empty($region) ? $region . ', ' : '') . $country); } } }
function validYoutubeId($id) { if ($id == "") { return false; } $res = libHTTP::GET('gdata.youtube.com', '/feeds/api/videos/' . $id); $data = $res['raw']; if (!$data) { return false; } if ($data == "Invalid id") { return false; } return true; }
function isTriggered() { if (isset($this->info['text'])) { $target = $this->info['text']; } else { $target = $this->info['nick']; } $result = libHTTP::GET("www.net-force.nl", "/wechall/userscore.php?username="******":", $result['content'][0]); $text = sprintf($this->CONFIG['text'], $target, $tmp[1], $tmp[2], $tmp[0], $tmp[3]); $this->sendOutput($text); }
function isTriggered() { if (isset($this->info['text'])) { $target = $this->info['text']; } else { $target = $this->info['nick']; } $result = libHTTP::GET("www.dareyourmind.net", "/userscore.php?username="******":", $result['content'][0]); if ($tmp[1] == 0) { $this->sendOutput($this->CONFIG['notfound_text']); return; } $text = sprintf($this->CONFIG['text'], $target, round($tmp[4] * $tmp[1] / 100), $tmp[4], $tmp[0], $tmp[3]); $this->sendOutput($text); }
function isTriggered() { if (isset($this->info['text'])) { $target = $this->info['text']; } else { $target = $this->info['nick']; } $result = libHTTP::GET("www.bright-shadows.net", "/userdata.php?username="******"Unknown User") { $this->sendOutput($this->CONFIG['notfound_text']); return; } $tmp = explode(":", $result['content'][0]); $text = sprintf($this->CONFIG['text'], $tmp[0], $tmp[3], $tmp[4], $tmp[1], $tmp[2]); $this->sendOutput($text); }
function isTriggered() { $target = isset($this->info['text']) ? $this->info['text'] : $this->info['nick']; $res = libHTTP::GET("newbiecontest.org", "/userscore.php?username="******"Member : unknown") { $text = sprintf($this->CONFIG['text_notfound'], $target); $this->sendOutput($text); return; } preg_match('#Member : (.*?)<br>Ranking : (.*?)/(.*?)<br>Points : (.*?)/(.*?)<br>Challenges solved : (.*?)/(.*?)<br>#', $res['raw'], $arr); $name = $arr[1]; $rank = $arr[2]; $rank_total = $arr[3]; $points = $arr[4]; $points_total = $arr[5]; $challs = $arr[6]; $challs_total = $arr[7]; $output = sprintf($this->CONFIG['text'], $name, $challs, $challs_total, $rank, $rank_total, $points, $points_total); $this->sendOutput($output); }
function isTriggered() { if (!isset($this->data['text'])) { $this->printUsage(); return; } $google = libHTTP::GET('http://www.google.com/search?q=' . urlencode($this->data['text']) . '&hl=de&safe=off'); if ($google === false) { $this->reply($this->connection_error); return; } if (!preg_match('#<h2 class="r" style="display:inline;font-size:138%">(.*?)</h2>#s', $google, $arr)) { $this->reply($this->parse_error); return; } $result = preg_replace("/<sup>/", '^', $arr[1]); while (false !== strstr($result, ' ')) { $result = str_replace(' ', ' ', $result); } $this->reply(utf8_encode(html_entity_decode(strip_tags($result)))); }
public function getDefinition($term) { $data = array('term' => $term); $html = libHTTP::GET('http://www.urbandictionary.com/define.php?term=' . urlencode($term)); if ($html === false) { $data['timeout'] = true; return $data; } if (strstr($html, "isn't defined.<br/>")) { $data['undefined'] = true; return $data; } preg_match('#<div class=\'meaning\'>(.+?)</div>.*?<div class=\'example\'>(.*?)</div>#s', $html, $arr); $definition = trim(html_entity_decode(strip_tags(br2nl($arr[1])))); $definition = strtr($definition, array("\r" => ' ', "\n" => ' ')); $definition = preg_replace_callback('/&#([a-z0-9]+);/i', create_function('$a', 'return chr(hexdec($a[0]));'), $definition); while (false !== strstr($definition, ' ')) { $definition = str_replace(' ', ' ', $definition); } if (strlen($definition) > 800) { $definition = substr($definition, 0, 800) . '...'; } $data['definition'] = $definition; if (!empty($arr[2])) { $example = trim(html_entity_decode(strip_tags(br2nl($arr[2])))); $example = strtr($example, array("\r" => ' | ', "\n" => ' | ')); $example = preg_replace_callback('/&#([a-z0-9]+);/i', create_function('$a', 'return chr(hexdec($a[0]));'), $example); while (false !== strstr($example, ' | | ')) { $example = str_replace(' | | ', ' | ', $example); } while (false !== strstr($example, ' ')) { $example = str_replace(' ', ' ', $example); } if (strlen($example) > 800) { $example = substr($example, 0, 800) . '...'; } $data['example'] = $example; } return $data; }
public final function getData($username) { if (!$this->url) { return false; } if (empty($this->triggers)) { return false; } if ($this->profileUrl !== false) { $html = libHTTP::GET(sprintf($this->profileUrl, urlencode($username))); } else { $html = null; } if ($html === false || 'timeout' === ($stats = $this->getStats($username, $html))) { $result = sprintf($this->timeoutText, $this->url); } elseif ($stats === false) { $result = sprintf($this->notfoundText, $this->url); } else { $result = $this->getStatsText($stats); } return $result; }
function isTriggered() { if (isset($this->info['text'])) { $target = $this->info['text']; } else { $target = $this->info['nick']; } $tmp = explode(' ', $this->info['text']); if (isset($tmp[0]) && $tmp[0][0] == '!' && !isset($tmp[1])) { $target .= ' ' . $this->info['nick']; } if ($this->info['triggerUsed'] == '!wcc') { $this->info['text'] = !empty($this->info['text']) ? '!wechall ' . $this->info['text'] : '!wechall'; $this->info['triggerUsed'] = '!wc'; return $this->isTriggered(); } $result = libHTTP::GET("www.wechall.net", "/wechall.php?username=" . urlencode($target)); $tmp = $result['content'][0]; if ($tmp == 'The user \'' . $target . '\' doesnt exist.') { $this->sendOutput($this->CONFIG['notfound_text']); return; } $this->sendOutput($tmp); }
function isTriggered() { if (isset($this->info['text'])) { $target = $this->info['text']; } else { $target = $this->info['nick']; } $result = libHTTP::GET("www.thisislegal.com", "/userscore.php?username="******":", $result['content'][0]); $nick = $target; $rank = $tmp[0]; $score = $tmp[1]; $score_total = $tmp[2]; $users = $tmp[3]; $challs_total = $tmp[4]; $result = libHTTP::GET("www.thisislegal.com", "/profile.php?username=" . urlencode($target)); $challs = substr_count($result['raw'], '<font color=\'#00FF00\' face=\'Verdana\' size=\'2\'>Yes</font>'); $text = sprintf($this->CONFIG['text'], $target, $challs, $challs_total, $rank, $users, $score, $score_total); $this->sendOutput($text); }
static function tinyURL($longurl) { return libHTTP::GET('http://tinyurl.com/api-create.php?url=' . urlencode($longurl)); }
private function getScoreboard() { $data = libHTTP::GET('https://ctf.internetwache.org/scoreboard.json'); $this->json = json_decode($data, true); $this->json = $this->json['standings']; }
private function checkMD5OnlineOrg($hash) { $html = libHTTP::POST('http://md5online.org/', array('md5' => $hash, 'action' => 'decrypt', 'a' => '123456')); // csrf token is not validated if ($html === false) { return false; } if (preg_match('#Found : <b>(.+?)</b>#', $html, $arr)) { return $arr[1]; } else { return false; } }
private function getWixxerdChalls($count) { $html = libHTTP::GET('http://www.wixxerd.com/challenges/'); if (!$html) { return false; } if (!preg_match('#<span.+?>New Challenges</span>(.+?)\\s{3,}#', $html, $arr)) { return false; } preg_match_all('#<a href="(.+?)">(.+?)</a>#', $arr[1], $arr); $texts = array(); for ($i = 0; $i < $count && $i < sizeof($arr[1]); $i++) { preg_match('#>' . preg_quote($arr[2][$i]) . '</a>\\s+?</td>\\s+?<td.+?>(.+?)(?: )*</td>\\s+?<td.+?>(.+?)</td>#', $html, $arr2); $texts[] = sprintf("%s in category %s rated %s ( %s )", $arr[2][$i], $arr2[1], $arr2[2], $arr[1][$i]); } return $texts; }
private function getStatus() { return libHTTP::GET('http://ddnet.tw/status/json/stats.json'); }