<?php

use CCDN\Helpers\Logger\Log;
use CCDN\Helpers\Logger\LogType;
use CCDN\Init;

@ini_set('memory_limit', '512M');

require_once ENGINE_DIR . '/inc/CCDN/vendor/autoload.php';

try {
    $init = new Init();
    echo $init->run();
} catch (Exception $e) {
    $log = new Log();
    $enter = PHP_EOL;
    $error = "Message: {$e->getMessage()}{$enter}File: {$e->getFile()} Line: {$e->getLine()}{$enter}Trace: {$e->getTraceAsString()}";

    $statusCode = method_exists($e, 'getStatus') ? $e->getStatus() : 500;
    http_response_code($statusCode);
    $log->write(LogType::PLUGIN, $error);
    ob_start();
    ?>
	<h3>CCDN Exception</h3>
	<p><b>Message:</b> <?php echo $e->getMessage() ?></p>
    <?php
    echo ob_get_clean();
    die();
}
