Get Fortune

 

$line) { if (strcmp(substr($line,0,1),'%') ==0) { $result[] = $current; $current = ""; } else { // escape & $tmp = str_replace("&", " &", substr($line,0, strlen($line))); // Preserve spaces $tmp = str_replace(" ", "  ", substr($tmp,0, strlen($tmp))); // escape < $tmp = str_replace("<", " <", substr($tmp,0, strlen($tmp))); // escape > and replace line feed with br tag $tmp = str_replace(">", " >", substr($tmp,0, strlen($tmp)-1)). "
"; // add to current fortune $current .= $tmp; } } if (strlen($current) > 0 ) $result[] = $current; DataCache::Put("fortunes", $fileName, 6000, $result); } // Do something useful with $result srand ((double) microtime() * 1000000); $randomquote = rand(0,count($result)-1); $format = ""; if (isset($_GET["format"])) $format = $_GET["format"]; // prevent caching header("Cache-Control: no-store"); header("Pragma: no-cache"); header("Expires: Thursday, 05-May-05 05:05:05 GMT"); switch ($format) { case "js": header("Content-type: text/plain"); echo "function fortune() {"; echo "document.write(\"

\");"; echo "document.write(unescape(\"" . rawurlencode($result[$randomquote]) . "\"));"; echo "document.write(\"

\");"; echo "}"; break; case "jsVar": header("Content-type: text/plain"); echo "var fortune=\"" . rawurlencode($result[$randomquote]) . "\";"; break; case "xml": header("Content-type: application/xml; charset=utf-8"); echo ""; echo ""; echo ""; echo ""; break; default: header("Content-type: text/html"); echo $result[$randomquote] ; } ?>


Fortune updated daily. Come back soon to view the next one!
Message service provider: The Fortune Service.

Note: The fortune service is based on the classic Unix fortune program whose humor encompasses wide-ranging topics. Regretably, it may occasionally include those of questionable taste; the service currently lacks an exclusionary filter.

 

 
Graphics by Linda (nee Designer Originals) formerly http://www.subdesigns.com
Send to Facebook  Send to Delicious