<?php
require_once(dirname(__FILE__) . '/../includes/base.inc.php');

$scriptLoc = dirname(__FILE__)."/../../scripts/NFU_DiagnosticProfile.sh";
$cmd = "sudo $scriptLoc 2>&1";
exec($cmd, $output, $errors);

if($errors) {
    header('Content-type: text/html; charset=UTF-8');
    print_r($output);
}
else {
    header('Content-type: application/octet-stream');
    header('Content-Disposition: attachment; filename="profile.zip"');
    readfile('/usr/local/nagiosfusion/tmp/profile.zip');
}