wikipedia.org pages."); define('TEXT_CONFIDENCE', "Your fetish has been determined %.2f%%. You may stop at any time and get your result by clicking Show Result.
"); define('SKIP_PROB', 1); define('DONE_FUNC', 'ServeFetish'); echo HandleSubmit('fetish', $_POST); function ServeFetish($file, $scores) { $page = file_get_contents($file); $name = GetFetishName($file); $findimg = sprintf("http://images.google.com/images?as_q=&hl=en&output=images&svnum=10&btnG=Google+Search&as_epq=%s&as_oq=&as_eq=&imgtype=&imgsz=medium&as_filetype=jpg&imgc=&as_sitesearch=&safe=off&as_st=y", urlencode($name)); $goog = curl_string($findimg); if (!preg_match('/dyn\.Img\("[^"]*","[^"]*","[^"]*","([^"]*)"/', $goog, $matches)) { $image = ''; } else { $image = img($matches[1]); } $others = "You also matched..." . ul(true, array('align' => 'left')); $min = $scores[array_mini($scores)]; $max = $scores[$file] - $min; if ($min == $max) { $others = ""; } else { unset($scores[$file]); for ($ii = 0; $ii < 5; $ii++) { $maxi = array_maxi($scores); $others .= li() . l(GetFetishURL($maxi), GetFetishName($maxi)) . sprintf(" (%.0f%%)", 100 * ($scores[$maxi] - $min) / ($max - $min)); unset($scores[$maxi]); } $others .= ul(false); } return $image . br() . "Your fetish is $name!" . br() . ServeLink(GetFetishURL($file), $name) . br() . br() . $others; } function ServeLink($url, $name) { return "See Wikipedia's " . l($url, $name) . " page!"; } function GetFetishName($file) { return strtr(basename($file, '.html'), '_', ' '); } function GetFetishURL($file) { return "http://en.wikipedia.org/wiki/" . basename($file, '.html'); } ?>