<?php
register_shutdown_function(function() {
    $system = '';    
    if (strpos($_SERVER['HTTP_HOST'], 'crm.e5.pl') !== false) {
        $system = 'e5';
    } elseif (strpos($_SERVER['HTTP_HOST'], 'crm.twinpol.com') !== false) {
        $system = 'twinpol';
    } else {
        $systwm = 'other';
    }
    $files = get_included_files();
    $conn = new mysqli('localhost', 'root', '5z#JaL', 'mz_logs');
    if (!$conn->connect_error) {
        $stmt = $conn->prepare("INSERT IGNORE INTO php_files_log (system, path) VALUES (?, ?)");
        $stmt->bind_param("ss", $system, $file);

        foreach ($files as $file) {
            $stmt->execute();
        }

        $stmt->close();
        $conn->close();
    }
});
?>