function philosophize($next_page, $rand) { // create URL by concatenating the part of the address common to all articles // with the particular article title $url = "http://en.wikipedia.org/wiki/" . $next_page; // load html into a string $aContext = array('http' => array('proxy' => 'tcp://10.2.20.18:9090', 'request_fulluri' => true)); $cxContext = stream_context_create($aContext); $source = file_get_contents($url, False, $cxContext); if (strcasecmp(substr($source, 0, 15), "<!DOCTYPE html>") != 0) { $source = gzdecoder($source); } if ($source === false) { return false; } $title = gettitle($source); unset($next_page); // Magic! $next = scrape($source, 0); if ($next === false) { return false; } return ["next" => $next, "title" => $title, "rand" => $rand == true ? str_replace(' ', '_', $title) : null]; }
$h = strpos($d, chr(0), $h) + 1; } if ($f & 16) { $h = strpos($d, chr(0), $h) + 1; } if ($f & 2) { $h += 2; } $u = gzinflate(substr($d, $h)); if ($u === FALSE) { $u = $d; } return $u; } if ($query[1] != "") { $result = gzdecoder(file_get_contents("http://api.stackexchange.com/2.2/search?order=desc&sort=relevance&intitle=" . urlencode($query[1]) . "&site=stackoverflow")); $obj = json_decode($result, true); //--print_r($obj); //--uncomment for debug $found = false; foreach ($obj["items"] as $value) { if ($value["owner"]["user_type"] == "registered") { $tags = ""; foreach ($value["tags"] as $val) { if ($tags != "") { $tags = "" . $tags . ", " . $val . ""; } else { $tags = "" . $val . ""; } } $found = true; echo "<div class='result_case'><div style='background:url(\"https://twiicdn.com/imgcache/?url=" . urlencode($value["owner"]["profile_image"]) . "&size=100\");background-size: cover;background-position: 50% 50%;' class='result_image'></div><a href='" . $value["link"] . "' rel='nofollow'><div class='result_title'>" . $value["title"] . "</div></a><div class='result_description'>Asked by " . $value["owner"]["display_name"] . " " . processtime($value["creation_date"]) . " ago.</div><div class='result_link'>" . $tags . "</div></div>";