<?php
include('indexes.php'); // Get the indexes

$title = $_GET['title'];
$type = $_GET['type'];
$page = $u[$title];

if ($type == 'png') {
  header('Content-type: image/png');
  $spl = explode('.', $page);
  $page = 'icons/' . substr($page, 0, strlen($page) - strlen($spl[sizeof($spl) - 1]) - 1) . '.png';
  if (!is_file($page)) $page = 'icons/default.png';
  
  $filename = $page;
  $handle = fopen($filename, "rb"); // Open the icon
  $contents = fread($handle, filesize($filename));
  fclose($handle);
  echo $contents; // Print the icon
}
else {
  header('Content-type: text/html; charset=utf-8');
  if (!is_file($page)) $page = 'error.htm';
  include($page); // Print the page
}
?>