Esempio n. 1
0
<?php

require_once 'settings.php';
require_once 'template.php';
require_once 'functions.php';
$tree = get_dir_tree();
start_html();
?>

  <article id="viewer">
    <section id="full_page">
      <div id="page_1" class="right_page"></div>
      <div id="page_2" class="left_page"></div>
      <div class="clear"></div>
    </section>

    <section id="half_page">
      <div class="controllers">
        <div class="next next_control left_control"></div>
        <div class="previous previous_control right_control"></div>
      </div>
      <div id="half_page_image"></div>
      <div class="clear"></div>
    </section>
  </article>

  <nav id="menu">
    <a class="controller next next_control left_control">1 ページ進む</a>
    <a class="controller previous previous_control right_control">1 ページ戻る</a>
    <div class="move_page_wrapper">
      <input type="range" name="slider" id="slider_controller" value="1" min="1" max="1" />
    try {
        $form = new Form($database, intval($_REQUEST['id']));
    } catch (Exception $e) {
        redirect_to(array('location' => 'form.php' . (isset($_REQUEST['id']) ? "?action=show&id=" . intval($_REQUEST['id']) : ""), 'status' => 'This form does not exist.', 'class' => 'error'));
    }
    if (!$form->allow($user, '')) {
        redirect_to(array('location' => 'form.php' . (isset($_REQUEST['id']) ? "?action=show&id=" . intval($_REQUEST['id']) : ""), 'status' => 'You are not authorized to create or update forms.', 'class' => 'error'));
    }
    $formID = $form->create_or_update($_POST['form']);
    if ($formID) {
        redirect_to(array('location' => 'form.php?action=view&id=' . intval($formID), 'status' => 'Successfully ' . (intval($_REQUEST['id']) == 0 ? 'created' : 'updated') . ' form.', 'class' => 'success'));
    } else {
        redirect_to(array('location' => 'form.php' . (isset($_REQUEST['id']) ? "?id=" . intval($_REQUEST['id']) : ""), 'status' => 'An error occurred while ' . (intval($_REQUEST['id']) == 0 ? 'creating' : 'updating') . ' this form. Please try again.', 'class' => 'error'));
    }
}
start_html($user, "UC Medicine QA", "Manage Forms", $_REQUEST['status'], $_REQUEST['class']);
switch ($_REQUEST['action']) {
    case 'new':
        if (!$user->isAdmin()) {
            display_error("Error: Insufficient privileges", "You must be an administrator to create forms.");
            break;
        }
        echo "<h1>Create a form</h1>\r\n";
        display_form_edit_form($user);
        break;
    case 'edit':
        if (!$user->isAdmin()) {
            display_error("Error: Insufficient privileges", "You must be an administrator to modify forms.");
            break;
        }
        echo "<h1>Modify a form</h1>\r\n";
<?php

include_once "global/includes.php";
if ($user->loggedIn()) {
    header("Location: main.php");
}
start_html($user, "UC Medicine QA", "", $_REQUEST['status'], $_REQUEST['class']);
?>
<div class="hero-unit">
  <h1>Welcome!</h1>
  <p>This is the QA tracking system for the University of Chicago Medicine's Radiation Oncology department.</p>
  <p>
    <a href="/register.php" class="btn btn-primary btn-large">
      Sign up
    </a>
  </p>
</div>
<?php 
display_footer();
    } elseif (!isset($_POST['machine_type']['name']) || !isset($_POST['machine_type']['description'])) {
        redirect_to(array('location' => 'machine_type.php' . (isset($_REQUEST['id']) ? "?id=" . intval($_REQUEST['id']) : ""), 'status' => 'One or more required fields are missing. Please check your input and try again.'));
    }
    try {
        $machineType = new MachineType($database, intval($_REQUEST['id']));
    } catch (Exception $e) {
        redirect_to(array('location' => 'machine_type.php' . (isset($_REQUEST['id']) ? "?action=show&id=" . intval($_REQUEST['id']) : ""), 'status' => 'This machine type does not exist.', 'class' => 'error'));
    }
    $machineTypeID = $machineType->create_or_update($_POST['machine_type']);
    if ($machineTypeID) {
        redirect_to(array('location' => 'machine_type.php?action=view&id=' . intval($machineTypeID), 'status' => 'Successfully ' . (intval($_REQUEST['id']) == 0 ? 'created' : 'updated') . ' machine type.', 'class' => 'success'));
    } else {
        redirect_to(array('location' => 'machine_type.php' . (isset($_REQUEST['id']) ? "?id=" . intval($_REQUEST['id']) : ""), 'status' => 'An error occurred while ' . (intval($_REQUEST['id']) == 0 ? 'creating' : 'updating') . ' this machine type. Please try again.', 'class' => 'error'));
    }
}
start_html($user, "UC Medicine QA", "Manage Machine Types", $_REQUEST['status'], $_REQUEST['class']);
switch ($_REQUEST['action']) {
    case 'new':
        if (!$user->isAdmin()) {
            display_error("Error: Insufficient privileges", "You must be an administrator to add machine types.");
            break;
        }
        echo "<h1>Add a machine type</h1>\n";
        display_machine_type_edit_form($user);
        break;
    case 'edit':
        if (!$user->isAdmin()) {
            display_error("Error: Insufficient privileges", "You must be an administrator to modify machine types.");
            break;
        }
        echo "<h1>Modify a machine type</h1>\n";
        redirect_to(array('location' => 'equipment.php?action=view&id=' . intval($equipmentID), 'status' => 'Successfully ' . (intval($_REQUEST['id']) == 0 ? 'created' : 'updated') . ' equipment.', 'class' => 'success'));
    } else {
        redirect_to(array('location' => 'equipment.php' . (isset($_REQUEST['id']) ? "?id=" . intval($_REQUEST['id']) : ""), 'status' => 'An error occurred while ' . (intval($_REQUEST['id']) == 0 ? 'creating' : 'updating') . ' this equipment. Please try again.', 'class' => 'error'));
    }
} elseif ($_REQUEST['action'] == 'get_parameters' && isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) {
    // return a js response instantiating all the parameters and values for this equipment.
    try {
        $equipment = new Equipment($database, intval($_REQUEST['id']));
    } catch (Exception $e) {
        echo json_encode(array());
        exit;
    }
    echo json_encode($equipment->parameters);
    exit;
}
start_html($user, "UC Medicine QA", "Manage Equipment", $_REQUEST['status'], $_REQUEST['class']);
switch ($_REQUEST['action']) {
    case 'new':
        if (!$user->isAdmin()) {
            display_error("Error: Insufficient privileges", "You must be an administrator to add equipment.");
            break;
        }
        echo "<h1>Add equipment</h1>\r\n";
        display_equipment_edit_form($user);
        break;
    case 'edit':
        if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
            display_error("Error: Invalid equipment ID", "Please check your ID and try again.");
            break;
        }
        //ensure that user has sufficient privileges to modify this equipment.
<?php

include_once "global/includes.php";
if (!$user->loggedIn()) {
    redirect_to(array('location' => 'index.php', 'status' => 'Please log in to plot history.'));
}
switch ($_REQUEST['action']) {
    case 'json':
        display_history_json($user, explode(",", $_REQUEST['form_fields']), explode(",", $_REQUEST['machines']));
        exit;
        break;
    default:
    case 'show':
        start_html($user, "UC Medicine QA", "Plot History", $_REQUEST['status'], $_REQUEST['class']);
        echo "<h1>Plot History</h1>\r\n";
        display_history_plot($user, $_REQUEST['form_id']);
        break;
    default:
}
display_footer();
    $generateBackup = $database->generate_backup($user, $_POST['backup']);
    redirect_to($generateBackup);
}
switch ($_REQUEST['action']) {
    case 'download':
        //download a specific backup.
        if (!isset($_REQUEST['id']) || intval($_REQUEST['id']) == 0) {
            redirect_to(array('location' => 'backup.php?action=index', 'status' => 'Please specify a valid backup ID.'));
        }
        //fetch this backup entry.
        $backup_path = $database->queryFirstValue("SELECT `path` FROM `backups` WHERE `id` = " . intval($_REQUEST['id']) . " LIMIT 1");
        if (!$backup_path) {
            redirect_to(array('location' => 'backup.php?action=index', 'status' => 'Please specify a valid backup ID.'));
        }
        //otherwise, start piping this file to the user.
        stream_large_file($backup_path, 'application/x-gtar', 1024 * 1024, False);
        break;
    case 'create':
        start_html($user, "UC Medicine QA", "Generate Backup", $_REQUEST['status'], $_REQUEST['class']);
        echo "<h1>Generate a Backup</h1>\r\n";
        display_backup_form();
        display_footer();
        break;
    default:
    case 'index':
        start_html($user, "UC Medicine QA", "Generate Backup", $_REQUEST['status'], $_REQUEST['class']);
        echo "<h1>Backups</h1>\r\n";
        display_backups($user);
        display_footer();
        break;
}