/** * Called whenever someone wants to track their package(s). * * @param object $parent The object that's calling the module * @param array $data Data * @param array $extra Extra data such as regexps * * @return none */ public function locatepackage($parent, $data, $extra) { extract($extra); $http = new httpSession('server.logistik.posten.se'); $http->setMaxLength(4096); $http->getPage(array($this, 'simpleQuery'), array_merge($extra, array('parent' => $parent)), '/servlet/PacTrack?lang=SE&kolliid=' . $regexp['kollinr']); }
/** * Looks for new oui data if it doesn't exist in database yet * * @param object $parent The calling object. * @param array $extra Extra data * * @return none */ public function getNewVendorData($parent, $extra) { extract($extra); $http = new httpSession('www.macvendorlookup.com'); $http->setMaxLength(4096); $http->getPage(array($this, 'SaveVendor'), array_merge($extra, array('parent' => $parent)), '/api/' . CONFIG_MACVENDOR_APIKEY . '/' . $regexp['oui']); }
public function fetchSearch($parent, $data, $extra) { extract($extra); if (!isset($regexp['term'])) { $this->parent->privmsg($replyto, "[Google] Requires a string"); } else { $regexp['term'] = urlencode($regexp['term']); $http = new httpSession('www.google.com'); $http->setMaxLength(4096); $http->getPage(array($this, 'replySearch'), array_merge($extra, array('parent' => $parent), array('Regexp' => $regexp)), '/search?hl=en&q=' . $regexp['term']); } }
/** * Opens twitter httpSession * * @param object $parent The object that's calling the module * @param array $data Data * @param array $extra Extra data such as regexps * * @return none */ public function twitter($parent, $data, $extra) { extract($extra); $http = new httpSession('search.twitter.com'); $http->getPage(array($this, 'twitterResult'), $extra, '/search.json?q=' . urlencode($regexp['search']) . '&result_type=recent&rpp=1'); }
public function html($http, $page, $vars) { extract($vars); echo "html(): {$page->url}" . PHP_EOL; switch ($type) { case 'uri': if ($page->status == 200) { if (preg_match('~<title>(.*?)</title>~is', $page->data, $out) == 1) { $title = str_replace(array("\r", "\n", "\t"), "", trim($out[1])); if (strlen($title) > 150) { $title = substr($title, 0, 150) . '...'; } $parent->privmsg($replyto, (isset($httphost) ? '[' . $httphost . '] ' : '') . sprintf("Link title: %s", html_entity_decode($title))); } else { $extra = ''; if (isset($page->header['content-length'])) { $bytes = $page->header['content-length']; $prefix = array('', 'k', 'M', 'G', 'T', 'P'); $i = 0; while ($bytes > 1024 && ++$i < count($prefix)) { $bytes /= 1024; } $extra .= ', ' . round($bytes, 2) . $prefix[$i] . 'B'; } if ($page->header['content-type'] == 'image/gif' && strlen($page->data) < 16 * 1048576) { if (false !== ($pos = strpos($page->data, 'GIF89a'))) { list(, $width, $height) = unpack('v*', substr($page->data, $pos + 6, 4)); $extra .= ", {$width}x{$height}px"; } if (false !== strpos($page->data, 'NETSCAPE2.0')) { $count = preg_match_all('/\\x00\\x21\\xF9\\x04.(..).\\x00/s', $page->data, $out); if ($count > 0) { $total_delay = 0; foreach ($out[1] as $delay) { list(, $delay) = unpack('v', $delay); $total_delay += $delay; } $extra .= ', animated (' . $count . ' frames, ' . $total_delay / 100 . ' seconds)'; } } } $parent->privmsg($replyto, (isset($httphost) ? '[' . $httphost . '] ' : '') . sprintf("[%s] %s", $page->header['content-type'], ltrim($extra, ', '))); } } elseif (isset($page->header['location'])) { if (isset($redir) && $redir > 2) { return; } if ($url = $this->url($page->header['location'])) { $http = new httpSession($url[1]); $http->setMaxLength(16384); echo "html(): http redirect to {$page->header['location']}" . PHP_EOL; $http->getPage(array($this, 'html'), array_merge($vars, array('redir' => isset($redir) ? $redir + 1 : 1, 'httphost' => $url[1], 'type' => 'uri', 'parent' => $parent)), $url[2]); } } else { echo "html(): Got {$page->status}" . PHP_EOL; } break; case 'spotify': if ($page->status == 200) { $spotify = simplexml_load_string($page->data); if (isset($spotify->artist) && isset($spotify->album)) { $r = sprintf('%s - %s', $parent->charsetDecode($spotify->artist->name), $parent->charsetDecode($spotify->name)); if (isset($spotify->album)) { $r .= ' / ' . $parent->charsetDecode($spotify->album->name); } $len_m = floor($spotify->length / 60); $len_s = floor($spotify->length % 60); $r .= sprintf(' (%d:%02d)', $len_m, $len_s); } else { if (isset($spotify->artist)) { $r = sprintf('%s / %s', $parent->charsetDecode($spotify->artist->name), $parent->charsetDecode($spotify->name)); } else { $r = $parent->charsetDecode($spotify->name); } } $parent->privmsg($replyto, sprintf("[spotify] {$r}")); } break; } }
/** * IMDB Handler * * @param object $parent The object that's calling the module * @param array $data Data * @param array $extra Extra data such as regexps * * @return none */ public function imdb($parent, $data, $extra) { extract($extra); $http = new httpSession('omdbapi.com'); $http->getPage(array($this, 'imdbResult'), $extra, '/?t=' . urlencode($regexp['search'])); }
/** * Initiates a yahoo currency conversion * * @param array $vars Array with extra stuff * * @return non */ public function yahooCurrency($extra) { if ($extra['toCurrency'] == "btc") { $extra['toCurrency'] = 'usd'; } extract($extra); list($cr, $cn) = self::_cacheName($fromCurrency, $toCurrency); if (isset(self::$rateCache[$cn]) && self::$rateCache[$cn][1] > time() - 3600) { $exR = self::$rateCache[$cn][0]; if ($cr) { $exR = 1 / $exR; } echo "yahooCurrency [{$fromCurrency}-{$toCurrency}] [rate:{$exR}] [cache:{$cn}]" . PHP_EOL; $newamount = $exR * $amount; if ($origTo == "btc") { $vars["amount"] = $newamount; $vars["fromCurrency"] = "usd"; $vars["toCurrency"] = "btc"; $this->mtgoxCurrency($vars); } else { $this->sendReponse($parent, $replyto, $origAmount, $origFrom, $newamount, $origTo); } return; } // http://download.finance.yahoo.com/d/quotes.csv?s=AUDUSD=X&f=l1 $http = new httpSession('download.finance.yahoo.com'); $http->setMaxLength(4096); $http->getPage(array($this, 'replyYahoo'), $extra, '/d/quotes.csv?s=' . strtoupper($fromCurrency) . strtoupper($toCurrency) . '=X&f=l1'); }
/** * Requests the information from httpSession. * * @param array $extra Extra data such as regexps * */ public function TVJustnu($extra) { extract($extra); $http = new httpSession('omtv.se'); $http->getPage(array($this, 'TVJustnu_results'), $extra, '/rss/justnu/'); }
} unset($http); // verificando si se pudo contactar a feedvalidator.org if (!isset($vresults)) { $vresults = "No se pudo contactar a feedvalidator.org\r\n"; } $vresults .= "\r\nhttp://www.feedvalidator.org/check.cgi?url=" . urlencode($input["feed"]); $message = MESSAGE_PREFIX; foreach ($input as $field => $value) { $message .= "{$field}:\r\n\t{$value}\r\n\r\n"; } $message .= "\r\n\r\nLa opinion de feedvalidator.org:\r\n---\r\n{$vresults}"; sendmail(MAIL_RECIPIENT, SUBJECT_PREFIX . "{$input["subject"]}", $message, "text/plain"); if (isset($_POST["subscribe"]) && $_POST["subscribe"]) { // suscribiendo a la lista $http = new httpSession("damog.net", "80"); $postVars = array("email" => $input["email"], "fullname" => $input["nombre"]); $http->post("/mailman/subscribe/planetalinux_damog.net", $postVars); $http->close(); } // incrementando contador de acceso para evitar flood antiflood_countaccess(); message_die("Gracias, tu petición ya ha sido enviada, será revisada y le avisaremos del resultado."); } else { message_die("Verifica que tu nombre, feed y hackergotchi esten completos."); } } include "../header.php"; ?> <h2>Suscripción a *.planetalinux.org</h2>