Location: PHPKode > scripts > ASCII Art Generator > index.php
<?php

include_once('ascii.class.php');

if(isset($_GET['url']))
{
	$image = new Ascii($_GET['url']);
}
else
{
	$image = new Ascii();
}

if(isset($_GET['color'])) $image->color = ($_GET['color'] == 'on') ? true : false;
if(isset($_GET['size']))
{
	$image->size = $_GET['size'];
}
if(isset($_GET['quality']))
{
	$image->quality = $_GET['quality'];
}

if(isset($_GET['plaintext']) && $_GET['plaintext'] == 1)
{
	header('Content-Type: text/plain;');
	$image->color = false;
	echo $image->draw();
	exit();
}
elseif(isset($_GET['html']) && $_GET['html'] == 1)
{
	echo '<pre style="font: ' . $image->size * 2 . 'px/' . $image->size . 'px monospace;">';
	echo $image->draw();
	echo '</pre>';
	exit();
}
else
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="author" content="Jonathan Ford" />
		<title>ASCII Art - <?php echo htmlentities($image->url) ?></title>	
		<style type="text/css">
			@import "style.css";
		</style>
	</head>
	<body>
		<h1 class="white">ASCII Art Generator</h1>
<?php

	echo '<pre class="white" style="font: ' . $image->size * 2 . 'px/' . $image->size . 'px monospace; text-align: center;">';
	echo $image->draw();
	echo '</pre>';
}
?>
	
	<p class="white" style="text-align: center;">
		<em><?php echo htmlentities($image->url); ?></em><br />
		<a href="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>&amp;plaintext=1" title="Plain text">Plain text</a> - <a href="index.php?<?php echo $_SERVER['QUERY_STRING']; ?>&amp;html=1" title="HTML">Get the HTML</a> - <a href="ascii.class.phps" title="PHP source">Get the PHP</a> - <a href="ascii.tar.gz" title="Archive">Download the archive (.tar.gz)</a> - <a href="ascii.zip" title="Archive">Download the archive (.zip)</a> - <a href="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] ; ?>" title="">Link to this page</a>
	</p>
	
	<form action="index.php" method="get">
		<fieldset class="white">
			<label>URL of image: <input type="text" name="url" value="<?php echo $image->url; ?>" /></label><br />
			<label>Quality (1 = highest): <input type="text" name="quality" value="<?php echo $image->quality; ?>" /></label><br />
			<label>Size (1 = smallest): <input type="text" name="size" value="<?php echo $image->size; ?>" /></label><br />
			<label>Colour: <input type="checkbox" name="color" <?php if($image->color == true) { echo('checked="yes"'); } ?> /></label><br />
			<input type="submit" name="submit" value="Submit" />
		</fieldset>
	</form>
	
	<div class="white">
		<p>
			This ASCII Art Generator was created by me, Jonathan Ford. If you like it or find it useful, please get in touch. You can email/MSN/PayPal sirjavabean [at] gmail [dot] com. Thanks to Adam from <a href="http://www.eastsolid.com" title="EastSolid">EastSolid</a> for hosting this mirror. For some slightly less interesting stuff, go to <a href="http://www.techhappens.com" title="TechHappens">http://www.techhappens.com</a>. This program is <strong>Public Domain</strong> - edit, copy and distribute as you see fit.
		</p>
		<p>
			Currently supported file formats:
			<ul>
				<li><a href="http://en.wikipedia.org/wiki/GIF" title="Graphics Interchange Format">Graphics Interchange Format (GIF)</a></li>
				<li><a href="http://en.wikipedia.org/wiki/PNG" title="Portable Network Graphic">Portable Network Graphic (PNG, with transparency!)</a></li>
				<li><a href="http://en.wikipedia.org/wiki/JPEG" title="JPEG">JPEG</a></li>
				<li><a href="http://en.wikipedia.org/wiki/WBMP" title="WBMP">WBMP</a></li>
				<li><a href="http://en.wikipedia.org/wiki/XBM" title="X BitMap">X BitMap</a></li>
			</ul>
		</p>
		<p>
			Maximum file size: <?php echo round(Ascii::max_filesize / 1024); ?> KB
		</p>
	</div>
	
	<div style="text-align: center;">
		<script type='text/javascript'>
		<!-- 
		var sid = '1178'; 
		var title_color = '000000'; 
		var description_color = '646360'; 
		var link_color = '7FBE00'; 
		var background_color = 'FFFFFF'; 
		var border_color = 'DDDDDD';
		var body_color = 'FFFFFF';
		src_str = "http://www.mediagridwork.com/p.php?sid="+sid+"&tc="+title_color+"&dc="+description_color+"&lc="+link_color+"&bgc="+background_color+"&bc="+border_color+"&bdc="+body_color;
		document.write("<iframe marginheight='0' marginwidth='0' id='adfrm' name='adfrm' src=" + src_str + " scrolling='no' height='60' width='468' frameborder='0'></iframe>"); 
		//--> 
		</script>
	</div>


	</body>
</html>
Return current item: ASCII Art Generator