Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git
<?php
class Config {
  public const SITE_TITLE  = "Dave Jarvis' Repositories";
  private const REPOS_DIR  = '/repos';
  private const ORDER_FILE = '/order.txt';
  private const LOG_FILE   = '/error.log';

  public function init() {
    ini_set( 'display_errors', 0 );
    ini_set( 'log_errors', 1 );
    ini_set( 'error_log', __DIR__ . self::LOG_FILE );

    set_time_limit( 0 );
  }

  public function createRouter() {
    $repos = $this->getHomeDirectory() . self::REPOS_DIR;

    return new Router( $repos, $repos . self::ORDER_FILE );
  }

  private function getHomeDirectory() {
    $home = !empty( $_SERVER['HOME'] ) ? $_SERVER['HOME'] : '';
    $home = $home === '' && !empty( getenv( 'HOME' ) )
      ? getenv( 'HOME' )
      : $home;

    return
        $home === '' &&
        function_exists( 'posix_getpwuid' ) &&
        function_exists( 'posix_getuid' )
      ? (posix_getpwuid( posix_getuid() )['dir'] ?? '')
      : $home;
  }
}