<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

<?php
### ERROR HANDLING ###

function warnError($errno, $errstr, $errfile, $errline)
{
  echo "<br><p style='padding:0px;margin:0px;background-color:white;color:black;'><b style='color:red;'>Error:</b> [$errno] $errstr <br> in file <b style='color:blue'>$errfile</b> line <b style='color:red'>$errline</b></p>";
}
set_error_handler("warnError");

if (!$_SERVER['DOCUMENT_ROOT']) {
  $_SERVER['DOCUMENT_ROOT'] = '/weblink';
}
# TODO separate file
?>

<style>
body{
  color: white;
}
</style>

<head>
  <!--!Copyright © 2023 Aliberk Sandıkçı-->
  <meta charset="UTF-8">

  <!-- CSS Files -->
  <?php
  $dir = new DirectoryIterator($_SERVER['DOCUMENT_ROOT'] . "/assets/css");
  foreach ($dir as $file) {
    if ((!$file->isDot()) && str_ends_with($file, ".css")) {
      echo '<link rel="stylesheet" href="/assets/css/' . $file . '">' . PHP_EOL . '  ';
    }
  } ?>

  <title>DEVELOPMENT PAGE</title>
</head>


<body>
  <h1>DEVELOPMENT PAGE</h1>
  <hr>
  <sup><a href="/dev/playground/">dev playground</a></sup><br>

  <?php

  echo 'DOCUMENTS_ROOT:' . $_SERVER['DOCUMENT_ROOT']  . PHP_EOL . "<br>";
  echo 'PHP_SELF:' . $_SERVER['PHP_SELF']  . PHP_EOL . "<br>";
  echo 'GATEWAY_INTERFACE:' . $_SERVER['GATEWAY_INTERFACE']  . PHP_EOL . "<br>";
  echo 'SERVER_ADDR:' . $_SERVER['SERVER_ADDR']  . PHP_EOL . "<br>";
  echo 'SERVER_NAME:' . $_SERVER['SERVER_NAME']  . PHP_EOL . "<br>";
  echo 'SERVER_SOFTWARE:' . $_SERVER['SERVER_SOFTWARE']  . PHP_EOL . "<br>";
  echo 'SERVER_PROTOCOL:' . $_SERVER['SERVER_PROTOCOL']  . PHP_EOL . "<br>";
  echo 'REQUEST_METHOD:' . $_SERVER['REQUEST_METHOD']  . PHP_EOL . "<br>";
  echo 'REQUEST_TIME:' . $_SERVER['REQUEST_TIME']  . PHP_EOL . "<br>";
  echo 'REQUEST_TIME_FLOAT:' . $_SERVER['REQUEST_TIME_FLOAT']  . PHP_EOL . "<br>";
  echo 'QUERY_STRING:' . $_SERVER['QUERY_STRING']  . PHP_EOL . "<br>";
  echo 'DOCUMENT_ROOT:' . $_SERVER['DOCUMENT_ROOT']  . PHP_EOL . "<br>";
  echo 'HTTPS:' . $_SERVER['HTTPS']  . PHP_EOL . "<br>";
  echo 'REMOTE_ADDR:' . $_SERVER['REMOTE_ADDR']  . PHP_EOL . "<br>";
  echo 'REMOTE_HOST:' . $_SERVER['REMOTE_HOST']  . PHP_EOL . "<br>";
  echo 'REMOTE_PORT:' . $_SERVER['REMOTE_PORT']  . PHP_EOL . "<br>";
  echo 'REMOTE_USER:' . $_SERVER['REMOTE_USER']  . PHP_EOL . "<br>";
  echo 'REDIRECT_REMOTE_USER:' . $_SERVER['REDIRECT_REMOTE_USER']  . PHP_EOL . "<br>";
  echo 'SCRIPT_FILENAME:' . $_SERVER['SCRIPT_FILENAME']  . PHP_EOL . "<br>";
  echo 'SERVER_ADMIN:' . $_SERVER['SERVER_ADMIN']  . PHP_EOL . "<br>";
  echo 'SERVER_PORT:' . $_SERVER['SERVER_PORT']  . PHP_EOL . "<br>";
  echo 'SERVER_SIGNATURE:' . $_SERVER['SERVER_SIGNATURE']  . PHP_EOL . "<br>";
  echo 'PATH_TRANSLATED:' . $_SERVER['PATH_TRANSLATED']  . PHP_EOL . "<br>";
  echo 'SCRIPT_NAME:' . $_SERVER['SCRIPT_NAME']  . PHP_EOL . "<br>";
  echo 'REQUEST_URI:' . $_SERVER['REQUEST_URI']  . PHP_EOL . "<br>";
  echo 'PHP_AUTH_DIGEST:' . $_SERVER['PHP_AUTH_DIGEST']  . PHP_EOL . "<br>";
  echo 'PHP_AUTH_USER:' . $_SERVER['PHP_AUTH_USER']  . PHP_EOL . "<br>";
  echo 'PHP_AUTH_PW:' . $_SERVER['PHP_AUTH_PW']  . PHP_EOL . "<br>";
  echo 'AUTH_TYPE:' . $_SERVER['AUTH_TYPE']  . PHP_EOL . "<br>";
  echo 'PATH_INFO:' . $_SERVER['PATH_INFO']  . PHP_EOL . "<br>";
  echo 'ORIG_PATH_INFO:' . $_SERVER['ORIG_PATH_INFO']  . PHP_EOL . "<br>";
  ?>


  <?php
  $dir = new DirectoryIterator($_SERVER['DOCUMENT_ROOT'] . "/assets/js");
  foreach ($dir as $file) {
    if ((!$file->isDot()) && str_ends_with($file, ".js") && $file != "jquery.js") {
      echo '<script src="/assets/js/' . $file . '"></script>' . PHP_EOL . '  ';
    }
  } ?>
</body>

</html>