function geoLocate($a, $k = false) { $this->a = array_merge(array('line1' => '', 'line2' => '', 'city' => '', 'state' => '', 'zip' => '', 'country' => ''), $a); $a = $this->format_address(); if (!$k) { $x = new ternXML(); $r = $this->h->get('http://maps.google.com/maps/api/geocode/xml?sensor=false&language=en&address=' . $a); $r = $x->parse($r['body'], 1, false); return $r['GeocodeResponse']['result']['geometry']['location']; } else { $x = new ternXML(); $r = $this->h->get('http://maps.google.com/maps/geo?output=xml&key=' . $k . '&q=' . $a); $r = $x->parse($r['body'], 1, false); $c = explode(',', $r['kml']['value']['Response']['Placemark']['value']['Point']['coordinates']); array_pop($c); return array('lat' => $c[0], 'lng' => $c[1]); } }
function WP_ayvpp_parse_videos($v, $t = 'channel', $i = 1, $n = 20) { global $tern_wp_youtube_vids, $tern_wp_youtube_feed; $z = $n == '*' ? 50 : $n; $tern_wp_youtube_feed = false; if ($t == 'channel') { $tern_wp_youtube_feed = 'http://gdata.youtube.com/feeds/api/users/' . $v . '/uploads?orderby=published&max-results=' . $z . '&start-index=' . $i; } elseif ($t == 'playlist') { $tern_wp_youtube_feed = 'http://gdata.youtube.com/feeds/api/playlists/' . $v . '?v=2'; } if (!$tern_wp_youtube_feed) { unset($tern_wp_youtube_vids); return false; } $c = new tern_curl(); $r = $c->get(array('url' => $tern_wp_youtube_feed, 'options' => array('RETURNTRANSFER' => true, 'FOLLOWLOCATION' => true), 'headers' => array('Accept-Charset' => 'UTF-8'))); $r->body = preg_replace("/(<media\\:description[^>\\/]*>)/", "\$1<![CDATA[", $r->body); $r->body = preg_replace("/(<\\/media\\:description>)/", "]]>\$1", $r->body); $r->body = preg_replace("/(<title[^>\\/]*>)/", "\$1<![CDATA[", $r->body); $r->body = preg_replace("/(<\\/title>)/", "]]>\$1", $r->body); $r->body = preg_replace("/(<media\\:title[^>\\/]*>)/", "\$1<![CDATA[", $r->body); $r->body = preg_replace("/(<\\/media\\:title>)/", "]]>\$1", $r->body); $r->body = preg_replace("/(<content[^>\\/]*>)/", "\$1<![CDATA[", $r->body); $r->body = preg_replace("/(<\\/content>)/", "]]>\$1", $r->body); $x = new ternXML(); $a = $x->parse($r->body); if ($a['errors']) { if ($a['errors']['error']['code'] == 'too_many_recent_calls') { WP_ayvpp_parse_set_error('Google has responded that you have made too many requests for videos.'); } return; } if (empty($a['feed']['entry']) and empty($a['feed']['entry']['value'])) { return; } else { $a = empty($a['feed']['entry']['value']) ? $a['feed']['entry'] : $a['feed']['entry']['value']; } if ($a['id']) { $a = array($a); } $tern_wp_youtube_vids = $a; unset($c, $r, $x, $a); return true; }