<?php require "include/include.php"; $extra = getMoreAthleteData(); foreach ($extra as &$data) { if (strtolower($data[1] . $data[0]) == strtolower($_GET["name"])) { $extraData = $data; } } $name = $_GET["name"]; if (empty($_GET["medal"])) { $searchName = urlencode($name . " olympics 2012"); } else { $searchName = urlencode($name . " " . $_GET["medal"] . " olympics"); } $result = getGoogleImage($searchName); if (!empty($name) && !empty($result)) { if (empty($extraData)) { echo "<p><img src=\"" . $result . "\" align=\"left\" class=\"profile\">We were unable to find any extra data about this athlete.</p>"; } else { echo "<p><img src=\"" . $result . "\" align=\"left\"/ class=\"profile\">Height: {$extraData[2]}cm <br />Weight: {$extraData[3]}kg <br />Sport: {$extraData[8]} <br />Extra data: {$extraData[9]}</p><br /><p><div id=\"map\" width=\"500px\" height=\"300px\"></div></p>"; } } else { echo "Something went wrong!"; }
* [titleNoFormatting] => 2.-Sea-cucumber_ph.jpg * [originalContextUrl] => http://www.thestudentroom.co.uk/showthread.php?t=601293&page=2 * [content] => Guys, how big are your <b>dicks</b>? * [contentNoFormatting] => Guys, how big are your dicks? * [tbUrl] => http://images.google.com/images?q=tbn:wLUInM5M4g_laM:www.wwf.org.hk/images/hoihawan/gallery/seashore/2.-Sea-cucumber_ph.jpg ****************************/ function getGoogleImage($search, $numresults = 1) { if ($numresults > 4) { $numresults = 4; } $content = @file_get_contents('http://www.google.com/uds/GimageSearch?v=1.0&safe=off&q=' . rawurlencode($search)); if (!$content) { return FALSE; } $result = json_decode($content); return array_slice($result->responseData->results, 0, $numresults); } if ($argv[1] == "") { die("Usage: @image [1-4] search string\n"); } $argv = explode(' ', $argv[1]); $num = 1; if (ctype_digit($argv[0])) { $num = array_shift($argv); } $search = implode(' ', $argv); $arr = getGoogleImage($search, $num); foreach ($arr as $image) { echo $image->url . ' - ' . $image->width . 'x' . $image->height . '<br>'; }