<?php
	if(isset($_GET['symbol'])) {
		if(isset($_GET['version']))
			$version = $_GET['version'] == '1.0' ? '2.0' : '1.0';
		else
			$version = '2.0';

		$name = $_GET['symbol'];
		$name = preg_replace('[^a-z0-9_\.]', '', $name);
		$module = substr($name, 0, strrpos($name, '.'));
		$function = substr($name, strrpos($name, '.') + 1);

		$module = str_replace('.', '_', $module);

		$url = "http://digitalmars.com/d/$version/phobos/$module.html#$function";

		header("Location: $url");
		//echo $url;
		exit;
	}
?>
<html>
<head>
	<title>Find D Symbol</title>
</head>
<body onload="document.getElementById('symbol').focus();">

<h1>D Doc finder</h1>

<p>Enter the full name of the symbol in here. Example: <tt>std.file.read</tt> or <tt>std.string.indexOf</tt>.</p>

<table>
<form>
<tr>
	<th>D version</th>
	<td><input name="version" value="1.0" type="radio" /> 1.0
	<br><input name="version" value="2.0" checked type="radio" /> 2.0
</tr>
<tr>
<th>Symbol:</th>
<td><input id="symbol" name="symbol" size="40" /></td>
</tr>
<tr>
<th>&nbsp;</th>
<td><input type="submit" value="Go to" /></td>
</tr>
</form>
</table>


</body>
</html>
