removeMagicQuotes($_GET); $secret = isset($_GET['secret']) ? $_GET['secret'] : ''; $query = isset($_GET['query']) ? $_GET['query'] : ''; $context = isset($_GET['context']) ? $_GET['context'] : ''; $xpath = isset($_GET['xpath']) ? $_GET['xpath'] : ''; $section = isset($_GET['section']) ? $_GET['section'] : ''; $timeout = isset($_GET['timeout']) ? $_GET['timeout'] : ''; $cookedSecret = htmlentities($secret); $cookedQuery = htmlentities($query); $cookedContext = htmlentities($context); $cookedXpath = htmlentities($xpath); $cookedSection = htmlentities($section); $cookedTimeout = htmlentities($timeout); require_once 'client/WikiSlurpClient.php'; $client = new WikiSlurpClient(); $result = $client->getData("http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/", $secret, $query, array('context' => $context, 'xpath' => $xpath, 'section' => $section, 'timeout' => $timeout)); ?> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>WikiSlurp Tester</title> </head> <body> <h1>WikiSlurp Tester</h1> <form method="get" action="example.php"> <p> <label for="secret">Secret</label> <input type="text" name="secret" id="secret" value="<?php echo $cookedSecret; ?> ">
$url = "{$imgApiBaseUrl}&method={$method}&user_id={$img['owner']}"; $result = $curl->getFromPhpSource($url, array('cache-ident' => $method)); $ownerHtml = $img['owner']; if (isset($result['person'])) { $profileUrl = $result['person']['profileurl']['_content']; $profileUser = $result['person']['username']['_content']; $ownerHtml = "<a href='{$profileUrl}'>{$profileUser}</a>"; } $imgUrl = "http://farm{$img['farm']}.static.flickr.com/{$img['server']}/{$img['id']}_{$img['secret']}.jpg"; $imgLink = "http://www.flickr.com/photos/{$img['owner']}/{$img['id']}"; $imgAttribution = "<p><a href='{$imgLink}'>{$img['title']}</a> by {$ownerHtml} on Flickr</p>"; } require_once 'externals/wikislurp/client/WikiSlurpClient.php'; $query = strrchr($hatedOriginal, '_') ? $hatedOriginal : ucwords($hatedNoUnderscore); $wiki = new WikiSlurpClient(); $result = $wiki->getData("http://" . $_SERVER['SERVER_NAME'] . ":8888/externals/wikislurp/index.php", $wikiSlurpSecret, $query, array('xpath' => '/html/body/p[position()<=3]', 'section' => 0)); if (isset($result['error'])) { $wikiText = 'Nothing'; } else { $wikiText = $result['html'] . "<p><a href='" . $result['url'] . "'>Read more about \"" . $result['title'] . "\" on Wikipedia</a>.</p>"; } // turn any wikipedia links into links for this site $wikiText = preg_replace('/<a href="\\/wiki\\//', '<a href="/', $wikiText); // now string replace all the things we need to replace $tmpl = str_replace('%%answer-string%%', $answerString, $tmpl); $tmpl = str_replace('%%background-image%%', $imgUrl, $tmpl); $tmpl = str_replace('%%background-image-link%%', $imgLink, $tmpl); $tmpl = str_replace('%%background-image-attributation%%', $imgAttribution, $tmpl); $tmpl = str_replace('%%wikipedia-says%%', $wikiText, $tmpl); $tmpl = str_replace('%%current-description%%', $currentDescription, $tmpl); // finally output the page