Location: PHPKode > scripts > NSFW-Redirect > malte70-nsfw-redirect-0d39fde/src/index.php
<?php
/**
 * Not Safe for Work-Redirect - (originally written for http://nsfw-redirect.tk)
 *
 * @author Malte Bublitz <hide@address.com>
 * @version 2012-07-17
 * @copyright Copyright (c) 2012 Malte Bublitz
 * @license FreeBSD
 */

/**
 * configuration
 */
class Config {
	static const ServiceName = "My NSFW Redirect Service";
	static const ServiceDescription = "NSWF-Redirect is a free redirect service which informs the user about a website which might be not safe for work.";
	static const ServiceURL = "http://nsfw-redirect.example.org";
}

/**
 * avoid opening the template files directly
 */
$template_called_correctly=true;

/**
 * get the requested URI
 */
$url = urldecode($_SERVER["QUERY_STRING"]);

/**
 * validate $url as an URL
 */
$url = filter_var($url, FILTER_VALIDATE_URL);

/**
 * check if an URL was passed.
 * If not so, show the welcome page, else, show the redirect page.
 */
if ($url==false) {
	/**
	 * check if a redirect URL was generated through the form.
	 */
	$url = filter_var(@$_POST["url"], FILTER_VALIDATE_URL);
	if ($url) {
		$new_url_info=<<<EOF
			<p>
				Your redirect page is located at:<br>
				<input type="text" width="60" value="http://nsfw-redirect.tk/?<?php echo urlencode($url);?>">
			</p>
EOF;
	} else {
		$new_url_info="";
	}
	
	/**
	 * show the welcome page
	 * @todo use a template system
	 */
	require_once("welcome.template.php");
} else {
	/**
	 * show the warning page
	 */
	require_once("redirect.template.php");
}
?>
Return current item: NSFW-Redirect