Esempio n. 1
0
<?php

require 'functions.php';
require 'config.php';
require 'lib/magpierss/rss_fetch.inc';
// define variables
$apptitle = 'pin11870';
$placeholder = 'Localidad';
$btn_search = 'Buscar restaurantes';
$credits = 'experimento realizado por <a href="http://miquelcamps.com" target="_blank">Miquel Camps Orteza</a> con la api de <a href="http://www.11870.com/" target="_blank">11870</a>, <a href="https://developers.google.com/maps/?hl=es" target="_blank">google maps</a>, <a href="http://jquery.com" target="_blank">jquery</a> y <a href="http://masonry.desandro.com/index.html" target="_blank">masonry</a>';
$limit = 50;
$items = array();
// geolocation
$default = array('lat' => 40.416691, 'lng' => -3.7003453, 'q' => 'Madrid');
list($q, $lat, $lng) = getGeolocation($default);
// get results
$lat_min = (double) $lat - 0.0036;
$lng_min = (double) $lng - 0.0036;
$lat_max = (double) $lat + 0.0036;
$lng_max = (double) $lng + 0.0036;
$tags = str_replace(',', '&tag=', 'restaurante,restaurantes');
$url = 'http://11870.com/api/v1/search?appToken=' . TOKEN_11870 . '&authSign=' . AUTH_11870 . '&count=' . $limit . '&tag=' . $tags . '&tagOp=or&bbox=' . $lng_min . ',' . $lat_min . ',' . $lng_max . ',' . $lat_max;
$xml = @fetch_rss($url);
if (isset($xml->items) && $xml->items) {
    foreach ($xml->items as $item) {
        $item = (object) $item;
        $items[] = array('img' => str_replace('ps_', 'pl_', $item->link_media), 'title' => utf8_encode($item->title), 'text' => utf8_encode($item->oos['useraddress'] . ', ' . $item->oos['locality'] . ' (' . $item->oos['country'] . ')'), 'url' => $item->link);
    }
}
require 'template.php';
Esempio n. 2
0
/**
 * Parses an array of peers and applies our filtering
 *
 * @param array $peers The array of peers to parse
 *
 * @return array
 */
function parsePeers($peers)
{
    global $config;
    $to_return = array();
    foreach ($peers as $peer) {
        // Extract IP address for later
        $peer_addr_array = explode(':', $peer['addr']);
        $peer_ip = $peer_addr_array[0];
        // Continue if peer is 'dark'
        if ($config['hide_dark_peers'] === true) {
            if (strcmp($peer_ip, '127.0.0.1') == 0 || strpos($peer_ip, '.onion') !== false) {
                continue;
            }
        }
        // Do geolocation
        if ($config['geolocate_peer_ip'] === true) {
            $peer['country'] = getGeolocation($peer_ip, 'geoplugin_countryCode');
        }
        // Override peer addr with IP
        if ($config['display_peer_port'] === false) {
            array_pop($peer_addr_array);
            $peer['addr'] = str_replace(array('[', ']'), '', implode(':', $peer_addr_array));
        }
        $to_return[] = $peer;
    }
    return $to_return;
}