/*
GML 2 Color Source Code
Copyright 2007 Daniel Lubarov
Please contact me for permissions
*/

// Database login hidden

$data = mysql_query("SELECT * FROM statistics") or die(mysql_error());
while ($row = mysql_fetch_array($data)) {
	$variable = $row['variable'];
	$value = $row['value'];
	switch ($variable) {
		case "pageViews":
			$pageViews = $value;
			settype($pageViews,"int");
			$pageViews += 1;
			mysql_query("UPDATE statistics SET value=$pageViews WHERE variable='pageViews'");
			break;
	}
}

// Process page request
$page = $_GET["page"];
switch ($page) {
	case "home":
	case "":
		$page_title = "Home";
		$page_content = '<h4>Welcome to GM2Color!</h4>
<p><em>GML2Color</em> is a free utility which converts GML code from plain text into a choice of HTML, BBcode, or <a href="http://www.wikidot.com/doc:wiki-syntax">Wikidot markup</a>. The tool originally took around four days to create, but since that time it\'s undergone a number of improvements. I have to say, the most exciting part of the process was categorizing the 1,812 syntax constructs which comprise the language. I hope you enjoy using this site as much as I enjoyed building it!</p>
<p>I\'ve made the code lists publicly available for download (see the left navigation bar) in case anyone wishes to take on a similar project without having to organize all of the GML constructs. The PHP source code is also up for download.</p>
<br />

<h4>Let me see?! I want to see!!</h4>
<p>Below is an example of code generated using GML2Color.</p>
<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><pre class="codebox"><font face="Courier New" style="font-size: 10pt;"><font color="#000000"><b>var</b></font> <font color="#000000">ii;</font>

<font color="#0000FF">room_caption</font> <font color="#000000">=</font> <font color="#808080">"Prime Number Gen ("</font> <font color="#000000">+</font> <font color="#000080">string</font><font color="#000000">(</font><font color="#0000FF">fps</font><font color="#000000">)</font> <font color="#000000">+</font> <font color="#808080">" FPS)"</font><font color="#000000">;</font>

<font color="#008000"><i>// A cool color-shifting button</i></font>
<font color="#000000"><b>for</b></font> <font color="#000000">(ii</font> <font color="#000000">=</font> <font color="#000000">0;</font> <font color="#000000">ii</font> <font color="#000000"><</font> <font color="#000000">btn_count;</font> <font color="#000000">ii</font> <font color="#000000">+=</font> <font color="#000000">1)</font>
  <font color="#000000">btn_hue[ii]</font> <font color="#000000">+=</font> <font color="#000080">random</font><font color="#000000">(100/(</font><font color="#000080">max</font><font color="#000000">(</font><font color="#0000FF">fps</font><font color="#000000">,30)+1));</font>

<font color="#008000"><i>/*
Blah blah current_time blah blah
Blah ds_list_add(id,val) blah // blah
*/</i></font>

<font color="#000000"><b>if</b></font> <font color="#000000">running</font> <font color="#000000"><b>{</b></font>
  <font color="#000000">start_timestamp</font> <font color="#000000">=</font> <font color="#0000FF">current_time</font><font color="#000000">;</font>
  <font color="#000000"><b>for</b></font> <font color="#000000">(ii</font> <font color="#000000">=</font> <font color="#000000">0;</font> <font color="#000000">ii</font> <font color="#000000"><</font> <font color="#000000">freq;</font> <font color="#000000">ii</font> <font color="#000000">+=</font> <font color="#000000">1)</font> <font color="#000000"><b>{</b></font>
    <font color="#000000"><b>if</b></font> <font color="#000000">is_prime(num_current)</font> <font color="#000000"><b>{</b></font>
      <font color="#000080">ds_list_add</font><font color="#000000">(lst_primes,num_current);</font>
      <font color="#000000">prime_count</font> <font color="#000000">+=</font> <font color="#000000">1;</font>
    <font color="#000000"><b>}</b></font>
    <font color="#000000">num_current</font> <font color="#000000">+=</font> <font color="#000000">2;</font>
    <font color="#008000"><i>// Determine time used in calculating last prime</i></font>
    <font color="#000000"><b>if</b></font> <font color="#000000">ii</font> <font color="#000000">==</font> <font color="#000000">freq</font> <font color="#000000">-</font> <font color="#000000">2</font> <font color="#000000"><b>then</b></font> <font color="#000000">prev_timestamp</font> <font color="#000000">=</font> <font color="#0000FF">current_time</font><font color="#000000">;</font>
    <font color="#000000"><b>if</b></font> <font color="#000000">ii</font> <font color="#000000">==</font> <font color="#000000">freq</font> <font color="#000000">-</font> <font color="#000000">1</font> <font color="#000000"><b>then</b></font> <font color="#000000">last_time</font> <font color="#000000">=</font> <font color="#0000FF">current_time</font> <font color="#000000">-</font> <font color="#000000">prev_timestamp;</font>
  <font color="#000000"><b>}</b></font>
  <font color="#000000">total_time</font> <font color="#000000">+=</font> <font color="#0000FF">current_time</font> <font color="#000000">-</font> <font color="#000000">start_timestamp;</font>
<font color="#000000"><b>}</b></font></font></pre></td></tr></table>
<br /><br />

<h4>Ew, it\'s a bug! I found a bug! Ewww!</h4>
<p>I am human; I make mistakes from time to time. If you find any bugs, please <a href="mailto:dlubarov@hmc.edu">let me know</a>.</p>';
		break;
	case "html":
	case "bbcode":
	case "wikidot":
		if ($page == "html") {
			$page_title = "GML 2 HTML";
		}
		elseif ($page == "bbcode") {
			$page_title = "GML 2 BBcode";
		}
		elseif ($page == "wikidot") {
			$page_title = "GML 2 Wikidot";
		}
		if ($_GET["action"] == "process") {
			$code = $_POST["code"];
			$code = stripslashes($code);
			
			$list_variables = file("variables.txt");
			$list_functions = file("functions.txt");
			$list_keywords = file("keywords.txt");
			$list_constants = file("constants.txt");
			
			// User-defined resources
			$list_resources = $_POST["resources"];
			$list_resources = str_replace(" ","",$list_resources);
			$list_resources = explode(",",$list_resources);
			// User-defined constants
			$list_uconstants = $_POST["uconstants"];
			$list_uconstants = str_replace(" ","",$list_uconstants);
			$list_uconstants = explode(",",$list_uconstants);
			
			// Settings
			
			$imagehack = false;
			if ($page == "html") {
				// Add breaks
				if ($_POST["breaks"] == "breaks") $add_breaks = true;
				else $add_breaks = false;
				// Encode spaces
				if ($_POST["encodespaces"] == "encodespaces") $encodespaces = true;
				else $encodespaces = false;
			}
			else {
				$add_breaks = false;
				$encodespaces = false;
				if ($page == "wikidot") {
					if ($_POST['imagehack'] == 'imagehack') {
						$imagehack = true;
						$image_fname = $_POST['fname'];
					}
				}
			}
			
			// Gray quotes
			if ($_POST["grayquotes"] == "grayquotes") $grayquotes = true;
			else $grayquotes = false;
			
			// Change font
			if ($_POST["changefont"] == "changefont") $changefont = true;
			else $changefont = false;
			
			$loops = 0;
			while (strlen($code) > 0) { // While code remains to be parsed
				$loops++;
				$firstchar = substr($code,0,1);
				
				// Check for string
				if ($firstchar == "'" || $firstchar == '"') {
					$end = strpos($code,$firstchar,1); // Find ending quote
					if ($end !== false) { // If there is a corresponding end quote
						if ($grayquotes) {
							$qcol = "#808080";
						}
						else {
							$qcol = "#000000";
						}
						if ($page == "html") {
							$otag = '<font color="' . $qcol . '">';
							$ctag = '</font>';
						}
						elseif ($page == "bbcode") {
							$otag = '[color=' . $qcol . ']';
							$ctag = '[/color]';
						}
						else {
							$otag = '##' . $qcol . '|';
							$ctag = '##';
						}
						$quote = substr($code,0,$end+1);
						$fcode[$loops] = $otag . $quote . $ctag;
						$code = substr($code,strlen($quote));
						continue;
					}
					// GM's editor actually treats the rest of the code as part of the string when there is a quote is left unclosed
					// But that's just wack so we'll ignore the quote and just let it turn black at the end of the loop
				}
				
				// Check for a "/* ... */" comment
				if (substr($code,0,2) == "/*") {
					if ($page == "html") {
						$otag = '<font color="#008000"><i>';
						$ctag = '</i></font>';
					}
					elseif ($page == "bbcode") {
						$otag = "[color=#008000][i]";
						$ctag = "[/i][/color]";
					}
					else {
						$otag = '##008000|//';
						$ctag = '//##';
					}
					$end = strpos($code,"*/");
					if ($end === false) { // No end comment
						$comment = $code; // Entire code is commented
						$code = "";
					}
					else {
						$comment = substr($code,0,$end+2);
						$code = substr($code,strlen($comment));
					}
					if ($page == "wikidot") {
						$comment = str_replace(array("\r\n","\n","\r"),"<<NEWLINE>>",$comment);
						$comment = str_replace("<<NEWLINE>>",$ctag."}}\n{{".$otag,$comment);
					}
					$fcode[$loops] = $otag . $comment . $ctag;
					continue;
				}
				// Check for a "//" comment
				if (substr($code,0,2) == "//") {
					if ($page == "html") {
						$otag = '<font color="#008000"><i>';
						$ctag = '</i></font>';
					}
					elseif ($page == "bbcode") {
						$otag = "[color=#008000][i]";
						$ctag = "[/i][/color]";
					}
					else {
						$otag = '##008000|//';
						$ctag = '//##';
					}
					$end = strpos($code,"\r");
					if (strpos($code,"\n") !== false) {
						if ($end === false) {
							$end = strpos($code,"\n");
						}
						else {
							$end = min($end,strpos($code,"\n"));
						}
					}
					if ($end === false) { // This is the last line
						$comment = $code;
						$code = "";
					}
					else {
						$comment = substr($code,0,$end);
						$code = substr($code,strlen($comment));
					}
					$fcode[$loops] = $otag . $comment . $ctag;
					continue;
				}
				
				// This next big chunk of code segments the input code (actually just the first piece of it)
				$end = false;
				$list_endchars = array(" ",".","(",")","\n","\r",";",",","<",">","=","+","-","*","/","[","]","{","}",":","!");
				foreach ($list_endchars as $endchar) {
					$pos = strpos($code,$endchar);
					if ($pos !== false) { // This endchar was found in the code
						if ($end === false) {
							$end = $pos;
						}
						else {
							// We're only interested in the first segmentor, since the others will be processed later
							$end = min($end,$pos);
						}
					}
				}
				if ($end === 0) { // $code starts with a space, dot, etc.
					$thischar = substr($code,0,1);
					if ($thischar == "\n" || $thischar == "\r" || $thischar == " ") {
						// Don't need formatting for blank space
						$otag = "";
						$ctag = "";
					}
					else {
						if ($page == "html") {
							$otag = '<font color="#000000">';
							$ctag = "</font>";
						}
						elseif ($page == "bbcode") {
							$otag = "[color=#000000]";
							$ctag = "[/color]";
						}
						else {
							$otag = '##000000|';
							$ctag = '##';
						}
					}
					$fcode[$loops] = $otag . $thischar . $ctag;
					$code = substr($code,1);
					continue;
				}
				
				if ($end === false) { // This is the last bit of code
					$codepiece = $code;
					$code = "";
				}
				else {
					$codepiece = substr($code,0,$end);
					$code = substr($code,strlen($codepiece));
				}
				
				// User-defined resources
				foreach ($list_resources as $resource) {
					if ($codepiece == $resource) {
						if ($page == "html") {
							$otag = '<font color="#800080">';
							$ctag = "</font>";
						}
						elseif ($page == "bbcode") {
							$otag = "[color=#800080]";
							$ctag = "[/color]";
						}
						else {
							$otag = '##800080|';
							$ctag = '##';
						}
						$fcode[$loops] = $otag . $codepiece . $ctag;
						continue 2;
					}
				}
				// User-defined constants
				foreach ($list_uconstants as $uconstant) {
					if ($codepiece == $uconstant) {
						if ($page == "html") {
							$otag = '<font color="#800000">';
							$ctag = "</font>";
						}
						elseif ($page == "bbcode") {
							$otag = "[color=#800000]";
							$ctag = "[/color]";
						}
						else {
							$otag = '##800000|';
							$ctag = '##';
						}
						$fcode[$loops] = $otag . $codepiece . $ctag;
						continue 2;
					}
				}
				// Keywords
				foreach ($list_keywords as $keyword) {
					$keyword = substr($keyword,0,strlen($keyword)-1);
					if ($codepiece == $keyword) {
						if ($page == "html") {
							$otag = '<font color="#000000"><b>';
							$ctag = "</b></font>";
						}
						elseif ($page == "bbcode") {
							$otag = '[color=#000000][b]';
							$ctag = "[/b][/color]";
						}
						else {
							$otag = '##000000|**';
							$ctag = '**##';
						}
						$fcode[$loops] = $otag . $codepiece . $ctag;
						continue 2;
					}
				}
				// Variables
				foreach ($list_variables as $variable) {
					$variable = substr($variable,0,strlen($variable)-1);
					if ($codepiece == $variable) {
						if ($page == "html") {
							$otag = '<font color="#0000FF">';
							$ctag = "</font>";
						}
						elseif ($page == "bbcode") {
							$otag = "[color=#0000FF]";
							$ctag = "[/color]";
						}
						else {
							$otag = '##0000FF|';
							$ctag = '##';
						}
						$fcode[$loops] = $otag . $codepiece . $ctag;
						continue 2;
					}
				}
				// Constants
				foreach ($list_constants as $constant) {
					$constant = substr($constant,0,strlen($constant)-1);
					if ($codepiece == $constant) {
						if ($page == "html") {
							$otag = '<font color="#800000">';
							$ctag = "</font>";
						}
						elseif ($page == "bbcode") {
							$otag = "[color=#800000]";
							$ctag = "[/color]";
						}
						else {
							$otag = '##800000|';
							$ctag = '##';
						}
						$fcode[$loops] = $otag . $codepiece . $ctag;
						continue 2;
					}
				}
				// Functions
				foreach ($list_functions as $function) {
					$function = substr($function,0,strlen($function)-1);
					if ($codepiece == $function) {
						if ($page == "html") {
							$otag = '<font color="#000080">';
							$ctag = "</font>";
						}
						elseif ($page == "bbcode") {
							$otag = "[color=#000080]";
							$ctag = "[/color]";
						}
						else {
							$otag = '##000080|';
							$ctag = '##';
						}
						$fcode[$loops] = $otag . $codepiece . $ctag;
						continue 2;
					}
				}
				// Add string as plain black text by default
				if ($page == "html") {
					$otag = '<font color="#000000">';
					$ctag = "</font>";
				}
				elseif ($page == "bbcode") {
					$otag = "[color=#000000]";
					$ctag = "[/color]";
				}
				else {
					$otag = '##000000|';
					$ctag = '##';
				}
				$fcode[$loops] = $otag . $codepiece . $ctag;
			} // End giant parsing loop
			
			// Remove extraneous tags by merging identical formatting blocks
			// First, initialize generic tag identifiers
			if ($page == "html") {
				$colpos = 13;
				$open = "<";
				$otag_len = 22;
				$ctag_len = 7;
			}
			elseif ($page == "bbcode") {
				$colpos = 7;
				$open = "[";
				$otag_len = 15;
				$ctag_len = 8;
			}
			else {
				$colpos = 2;
				$open = "#";
				$otag_len = 9;
				$ctag_len = 2;
			}
			// Now... do stuff!
			for ($i = 1; $i < $loops; $i++) { // For each code piece
				$code1 = $fcode[$i];
				$code2 = $fcode[$i+1];
				// If either code piece is uncolored, don't try to merge them
				if (substr($code1,0,1) != $open) continue;
				if (substr($code2,0,1) != $open) continue;
				// Isolate color values
				$col1 = substr($code1,$colpos,7);
				$col2 = substr($code2,$colpos,7);
				if ($col1 == $col2) {
					// Delete the closing tag of the first, and the opening tag of the second
					$code1 = substr($code1,0,strlen($code1)-$ctag_len);
					$code2 = substr($code2,$otag_len);
					// Move both code pieces up to the upper piece so it can continue to merge with other code pieces properly
					$fcode[$i] = "";
					$fcode[$i+1] = $code1 . $code2;
				}
			}
			
			// Apply monospace font for Wikidot
			if ($changefont && $page=="wikidot") {
				foreach ($fcode as $key => $ref_codepiece) {
					if ($ref_codepiece != "\r" && $ref_codepiece != "\n")
						$fcode[$key] = '{{' . $ref_codepiece . '}}';
				}
			}
			
			// Compile the whole code structure back into the $code variable
			foreach ($fcode as $codepiece) $code .= $codepiece;
			
			// Merge extraeneous monspace markup for Wikidot
			if ($page=="wikidot") {
				$code = str_replace('}}{{','',$code);
			}
			
			// Encode spaces if appropriate
			if ($encodespaces) $code = str_replace("  ","&amp;nbsp; ",$code);
			
			// Apply image hack if appropriate
			if ($imagehack) {
				$image_code = "[[image $image_fname]]";
				$code = str_replace("  "," $image_code ",$code);
				$code = str_replace("  "," $image_code ",$code);
				// Add the image at the beginning of each line
				$code = str_replace(array("\r\n","\n","\r"), "<<NEWLINE>>", $code);
				$code = $image_code . str_replace("<<NEWLINE>>","\n$image_code",$code);
			}
			if ($page == "wikidot") {
				$code = str_replace(array("\r\n","\n","\r"), "<<NEWLINE>>", $code);
				$code = '> ' . str_replace("<<NEWLINE>>","\n".'> ',$code);
			}
			
			// Add HTML line breaks if appropriate
			if ($add_breaks) $code = nl2br($code);
			
			// Change font if appropriate
			if ($changefont) {
				if ($page == "html") $code = '<font face="Courier New" style="font-size: 10pt;">' . $code . '</font>';
				elseif ($page == "bbcode") $code = '[font=Courier New]' . $code . '[/font]';
				/*else {
					$code = '{{' . str_replace(array("\r\n", "\n", "\r"),"}}<<NEWLINE>>{{",$code) . '}}';
					$code = str_replace('<<NEWLINE>>', "\n", $code);
				}*/
			}
			
			$page_content = '<center>Below is the formatted code.<br /><br />
<textarea rows="20" cols="50">' . $code . '</textarea><br /><br />
Loops used: ' . $loops . "<center>";
		}
		else {
			if ($page == "html") {
				$breaks_code = '<input type="checkbox" name="breaks" value="breaks" checked="true" /> Insert <a href="http://www.w3schools.com/tags/tag_br.asp">&#60;BR&#62;</a> tags into HTML. (Do not check if using the <a href="http://www.w3schools.com/tags/tag_pre.asp">&#60;PRE&#62;</a> tag.)<br />
<input type="checkbox" name="encodespaces" value="encodespaces" checked="true" /> Use <a href="http://en.wikipedia.org/wiki/Non-breaking_space">hard spaces</a> to force indentation.<br />';
			}
			elseif ($page == "wikidot") {
				$breaks_code = '<input type="checkbox" name="imagehack" value="imagehack" checked="true" onchange="document.getElementById(\'file_spec\').style.display = (this.checked)? \'\' : \'none\';" /> Use spacing hack (separates spaces with tiny image)
				<span id="file_spec">
					<br />
					Location of image: <input type="text" name="fname" value="blank.gif" />*<br />
					<small>* I recommend that the image be a 1px*1px transparent gif</small>
				</span>
				<br />';
			}
			else {
				$breaks_code = "";
			}
			$page_content = '<form action="index.php?page=' . $page . '&action=process" method="post">
<div style="width: 430px; margin: 0 auto;">
Enter the GML code to be formatted.<br /><br />
<textarea name="code" rows="20" cols="50" wrap="off"></textarea><br /><br />
[Optional] User-defined constants: <input name="uconstants" type="text" size="25" /><br />
[Optional] User-defined resources: <input name="resources" type="text" size="25" /> *<br />
<small>Note: Each item should be separated with a comma.</small><br />
<small>* Includes sprites, sounds, backgrounds, paths, scripts, fonts, time lines, objects, and rooms.</small>
<br /><br />' . $breaks_code . '
<input type="checkbox" name="grayquotes" value="grayquotes" checked="true" /> Use gray quotes for enhanced readability.<br />
<input type="checkbox" name="changefont" value="changefont" checked="true" /> Change the font to emulate GM editor.<br /><br />
<center><input type="submit" value="Format" /></center>
</div>
</form>';
		}
		break;
	case "shout":
		$action = $_GET["action"];
		$page_title = "Shout Box";
		$page_content = "";
		if ($action == "send") {
			$time = time();
			$name = $_POST["name"];
			$_name = htmlspecialchars($name);
			$message = $_POST["message"];
			$_message = htmlspecialchars($message);
			$drink = $_POST["drink"];
			$drink = strtolower($drink);
			if ($drink == 'water' || $drink == 'milk') {
				$ip = $_SERVER['REMOTE_ADDR'];
				if (strlen($name) > 0 && strlen($message) > 0 && $name != "Name" && (stripos($name,"Daniel") === FALSE || $_GET["password"] === "PASSWORD HIDDEN")) {
					mysql_query("INSERT INTO shoutbox (timestamp, name, message, ip) VALUES('$time','$_name','$_message','$ip')") or die(mysql_error());
					$page_content .= "Message sent successfully.";
				}
				else {
					$page_content .= "Error sending message.<br /><br />\nName: " . $_name . "<br />\nMessage: " . $_message . "<br /><br />";
				}
			}
			else {
				$page_content .= "Sorry, you failed the uber tricky <a href=\"http://en.wikipedia.org/wiki/CAPTCHA\">CAPTCHA</a> test. You must enter \"water\" or \"milk\"<br /><br />\nName: " . $_name . "<br />\nMessage: " . $_message . "<br /><br />";
			}
		}
		$query = mysql_query("SELECT * FROM shoutbox ORDER BY timestamp") or die(mysql_error());
		$odd = false;
		$page_content .= '<table cellpadding="0" cellspacing="0" width="100%">';
		while ($row = mysql_fetch_array($query)) {
			if ($odd) {
				$color = "#E3E2F4";
			}
			else {
				$color = "white";
			}
			$page_content .= '<tr bgcolor="' . $color . '"><td>' . date("F j, Y, g:i a",$row["timestamp"]) . "</td><td>" . $row["name"] . "</td><td>" . $row["message"] . "</td></tr>\n";
			$odd = !$odd;
		}
		$page_content .= "</table>";
		if (mysql_num_rows($query) == 0) {
			$page_content = "There were no messages to display.";
		}
		break;
	default:
		$page_title = "Page Not Found";
		$page_content = 'Error - invalid request. The page "' . $page . '" was not found on the server.';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"><head>	
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<style type="text/css"><!-- 
			@import "st_gargoyles.css";
			@import "st_gargoyles_theme.css";
		--></style>
		<script type="text/javascript" src="ruthsarian_utilities.js"></script>
		<script type="text/javascript">
		<!--
			if ( ( typeof( NN_reloadPage ) ).toLowerCase() != 'undefined' ) { NN_reloadPage( true ); }
			if ( ( typeof( opacity_init  ) ).toLowerCase() != 'undefined' ) { opacity_init(); }
			if ( ( typeof( set_min_width ) ).toLowerCase() != 'undefined' ) { set_min_width( 'pageWrapper' , 600 , true ); }
		//-->
		</script><title>GML 2 Color >> <?php echo $page_title; ?></title></head><body>
		<div id="pageWrapper">
			<div id="outerColumnContainer">
				<div id="innerColumnContainer">
					<div id="middleColumn">
						<div id="masthead" class="inside">
<h1>by <a href="http://daniel.lubarov.com/">Daniel Lubarov</a></h1>
<h2>/* GML 2 Color */</h2>
							<hr class="hide">
						</div>
						<div id="content">

<div class="hnav bottomBorderOnly">
	<ul class="nshnav"><li><a href="index.php">Home</a><span class="divider"> : </span></li><li><a href="index.php?page=html">HTML</a><span class="divider"> : </span></li><li><a href="index.php?page=bbcode">BBcode</a><span class="divider"> : </span></li><li><a href="index.php?page=wikidot">Wikidot</a><span class="divider"> : </span></li><li><a href="mailto:dlubarov@gmail.com">Contact</a></li></ul>
	<hr class="hide">
</div>

<h3 class="pageTitle"><?php echo $page_title; ?></h3>
							<div id="contentColumnContainer">
								<div id="innerContent">
									<div class="inside">
<?php echo $page_content; ?>
									</div>
									<hr class="hide">
								</div>
								<div id="rightColumn">
									<div class="inside">

<a href="index.php?page=shout&action=view"><h4 class="sbtitle" align="center">&nbsp;&nbsp; Shout Box &nbsp;&nbsp;</h4></a>
<hr color="#abaaba" size="1" noshade="1" />
<p>
<?php
$shoutbox_content = "";
$firstrow = true;
$query = mysql_query("SELECT * FROM shoutbox ORDER BY timestamp DESC LIMIT 15");

while ($row = mysql_fetch_array($query)) {
	if (!$firstrow) {
		$shoutbox_content = "<br />" . $shoutbox_content;
	}
	$shoutbox_content = "<strong><u>" . $row["name"] . "</u></strong>: " . $row["message"] . "\n" . $shoutbox_content;
	$firstrow = false;
}
if (mysql_num_rows($query) == 0) {
	$shoutbox_content = "There were no messages to display.";
}
echo $shoutbox_content;
?>
</p>
<hr color="#abaaba" size="1" noshade="1" />
<form action="index.php?page=shout&action=send<?php if (isset($_GET["password"])) echo "&password=" . $_GET["password"]; ?>" method="post">
<br />
<center>
<input type="text" name="name" size="25" value="Name" maxlength="30" onfocus="if (this.value == 'Name') this.value = '';" /><br />
<textarea type="text" name="message" cols="25" onfocus="if (this.value == 'Message...') this.value = '';" />Message...</textarea><br />
What do cows drink? <input type="text" name="drink" size="10" /><br />
<input type="submit" value="Shout" />
</center>
</form>

									</div>
									<hr class="hide">
								</div>
								<div class="clear"></div>
							</div>
						</div>
					</div>
					<div id="leftColumn">
						<div class="inside">

<div id="cornerLogo">
	<div class="placeHolder">
		<a href="index.php"><img src="logo.gif" /></a>
	</div>
</div>

<div id="mainMenu" class="leftBlock">
	<div class="vnav">
		<ul><li><a href="index.php">Home</a></li><li><a href="mailto:dlubarov@gmail.com">Contact</a></li></ul>
	</div>
</div>

<div style="text-align: center;">
	<a href="http://peerfly.com/x/5747/867/4117/gml/"><img src="http://peerfly.com/banners/5747-180x150.gif" border="0"></a>
</div>

<div class="leftBlock">
	<h3>Main</h3>
	<div class="vnav">
		<ul><li><a href="index.php?page=html">GML 2 HTML</a></li><li><a href="index.php?page=bbcode">GML 2 BBcode</a></li><li><a href="index.php?page=wikidot">GML 2 Wikidot</a></li></ul>
	</div>
</div>

<div class="leftBlock">
	<h3>Source</h3>
	<div class="vnav">
		<ul><li><a href="source.php">PHP Source</a></li><li><a href="variables.txt">Variables</a></li><li><a href="functions.txt">Functions</a></li><li><a href="keywords.txt">Keywords</a></li><li><a href="constants.txt">Constants</a></li></ul>
	</div>
</div>

<div class="leftBlock">
	<h3>Affiliates</h3>
	<div class="vnav">
		<ul><li><a href="http://gamemakernetwork.com/">Game Maker Network</a></li><li><a href="http://gmtutorials.com/aff_in/id:20/">GM Tutorials</a></li><li><a href="http://www.gamemakertech.info/">GM Tech Magazine</a></li></ul>
	</div>
</div>

<div class="leftBlock">
	<h3>Links</h3>
	<div class="vnav">
		<ul><li><a href="http://yoyogames.com/">YoYo Games</a></li><li><a href="http://gmc.yoyogames.com/">Game Maker Community</a></li><li><a href="http://www.nickbostrom.com/existential/risks.html">Some casual reading</a></li></ul>
	</div>
</div>

<!--<div class="leftBlock leftTextBlock">
	
</div>-->
							<hr class="hide">
						</div>
					</div>
					<div id="footer">

<p>
	Copyright © 2007 Daniel Lubarov &nbsp;&middot;&nbsp; Last Update: March 25, 2008 &nbsp;&middot;&nbsp; Page Views: <?php echo $pageViews; ?>
</p>

						<hr class="hide">
					</div>
					<div class="clear"></div>
				</div>
			</div>
		</div>

</body></html>