<?php
/*

Some debug information can be obtained by typing this after the url:

      ?php        lots of information about your server's configuration of php
      ?array      the data obtained by this script after parsing the various xml files
	  ?debug	  used to define AUTOINDEX_DEBUG
*/


$reverseit = false;  // change to true if you'd like the album displayed in reverse order

// define page structure via functions
function write_top() {
	include "./pages-resources/php/php_hooks.php";
	echo '
<!DOCTYPE html>

<html lang="en" dir="ltr" class="no-js">';

	include "./pages-resources/html/head.html";

	echo '
<body>
<div id="container">

	<header>';
	include "./pages-resources/html/header.html";
	echo '
	</header>

	<div id="page-content">
';

	include "./pages-resources/php/description.php";
	echo '
	<section id="thumbnail-grid">
	<div class="thumbnail-grid">
		<!-- Gallery Index Begins Here -->
		<div id="gallery-index">
';

}

function write_bottom() {
	echo '
		</div>
		<!-- Gallery Index Ends Here -->
	</div>
	</section>
';
	include "./pages-resources/php/php_hooks_ttg_user_body.php";
	echo '	
	</div> <!-- /page-content -->

	<footer>';
	include "./pages-resources/html/footer.html";
	echo '
	</footer>

</div> <!-- /container -->';
	
	include "./pages-resources/html/footer_scripts.html";
	include "./pages-resources/php/php_hooks_ttg_user_lastcall.php";
	echo '
	</body>
</html>';
}


// autoindex functions
include "./pages-resources/php/autoindex.php";

// output page
$show = trim($_SERVER["QUERY_STRING"]);
if ($show == 'php') {
	echo '<pre>';
	phpinfo();
	echo '</pre>';
}

// for debugging; displays $w in human-readable format
function debug($w) {
   echo '<div style="text-align: left"><pre>';
   if (is_string($w)) echo htmlentities($w);
     else print_r ($w);
   echo "</pre></div>";
   write_bottom();
   exit;
}

write_top();

if ($show == 'debug')
{
	define ('AUTOINDEX_DEBUG', true);			// enable statement to output debugging info from autoindex()
}

$albums = autoindex('./galleries/');

if ($reverseit) $albums = array_reverse($albums);
if ($show == 'array') debug($albums);

for($i=0; $i<count($albums); $i++)
{ ?>

<?php include "./pages-resources/php/layout.php"; ?>

<?php
}

write_bottom();

?>